1: <?php
2:
3: namespace Guzzle\Service\Command;
4:
5: use Guzzle\Common\Collection;
6: use Guzzle\Common\Exception\InvalidArgumentException;
7: use Guzzle\Http\Message\Response;
8: use Guzzle\Http\Message\RequestInterface;
9: use Guzzle\Service\ClientInterface;
10: use Guzzle\Service\Description\OperationInterface;
11: use Guzzle\Service\Exception\CommandException;
12:
13: /**
14: * Command object to handle preparing and processing client requests and responses of the requests
15: */
16: interface CommandInterface
17: {
18: /**
19: * Get the short form name of the command
20: *
21: * @return string
22: */
23: public function getName();
24:
25: /**
26: * Get the API operation information about the command
27: *
28: * @return OperationInterface
29: */
30: public function getOperation();
31:
32: /**
33: * Execute the command and return the result
34: *
35: * @return mixed Returns the result of {@see CommandInterface::execute}
36: * @throws CommandException if a client has not been associated with the command
37: */
38: public function execute();
39:
40: /**
41: * Get the client object that will execute the command
42: *
43: * @return ClientInterface|null
44: */
45: public function getClient();
46:
47: /**
48: * Set the client object that will execute the command
49: *
50: * @param ClientInterface $client The client object that will execute the command
51: *
52: * @return CommandInterface
53: */
54: public function setClient(ClientInterface $client);
55:
56: /**
57: * Get the request object associated with the command
58: *
59: * @return RequestInterface
60: * @throws CommandException if the command has not been executed
61: */
62: public function getRequest();
63:
64: /**
65: * Get the response object associated with the command
66: *
67: * @return Response
68: * @throws CommandException if the command has not been executed
69: */
70: public function getResponse();
71:
72: /**
73: * Get the result of the command
74: *
75: * @return Response By default, commands return a Response object unless overridden in a subclass
76: * @throws CommandException if the command has not been executed
77: */
78: public function getResult();
79:
80: /**
81: * Set the result of the command
82: *
83: * @param mixed $result Result to set
84: *
85: * @return self
86: */
87: public function setResult($result);
88:
89: /**
90: * Returns TRUE if the command has been prepared for executing
91: *
92: * @return bool
93: */
94: public function isPrepared();
95:
96: /**
97: * Returns TRUE if the command has been executed
98: *
99: * @return bool
100: */
101: public function isExecuted();
102:
103: /**
104: * Prepare the command for executing and create a request object.
105: *
106: * @return RequestInterface Returns the generated request
107: * @throws CommandException if a client object has not been set previously or in the prepare()
108: */
109: public function prepare();
110:
111: /**
112: * Get the object that manages the request headers that will be set on any outbound requests from the command
113: *
114: * @return Collection
115: */
116: public function getRequestHeaders();
117:
118: /**
119: * Specify a callable to execute when the command completes
120: *
121: * @param mixed $callable Callable to execute when the command completes. The callable must accept a
122: * {@see CommandInterface} object as the only argument.
123: * @return CommandInterface
124: * @throws InvalidArgumentException
125: */
126: public function setOnComplete($callable);
127: }
128: