<?php
/**
 * Provider-owned object authorization contract.
 *
 * @package ScheduledChanges
 */

namespace ScheduledChanges\Provider;

use ScheduledChanges\Domain\Operation\TargetDefinition;

/**
 * Authorizes provider-owned targets before scheduler mutations.
 */
interface ProviderAuthorization {
	public const ACTION_INSPECT  = 'inspect';
	public const ACTION_SCHEDULE = 'schedule';
	public const ACTION_EXECUTE  = 'execute';
	public const ACTION_ROLLBACK = 'rollback';
	public const ACTION_DELETE   = 'delete';

	/**
	 * @throws \RuntimeException When provider authorization state is unavailable.
	 */
	public function canInspect( int $actor_id, TargetDefinition $target ): bool;

	/**
	 * @throws \RuntimeException When provider authorization state is unavailable.
	 */
	public function canSchedule( int $actor_id, TargetDefinition $target ): bool;

	/**
	 * @throws \RuntimeException When provider authorization state is unavailable.
	 */
	public function canExecute( int $actor_id, TargetDefinition $target ): bool;

	/**
	 * @throws \RuntimeException When provider authorization state is unavailable.
	 */
	public function canRollback( int $actor_id, TargetDefinition $target ): bool;

	/**
	 * @throws \RuntimeException When provider authorization state is unavailable.
	 */
	public function canDelete( int $actor_id, TargetDefinition $target ): bool;
}
