| 1 |
lars |
1 |
<?php
|
|
|
2 |
/*
|
|
|
3 |
* Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
|
4 |
*
|
|
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License").
|
|
|
6 |
* You may not use this file except in compliance with the License.
|
|
|
7 |
* A copy of the License is located at
|
|
|
8 |
*
|
|
|
9 |
* http://aws.amazon.com/apache2.0
|
|
|
10 |
*
|
|
|
11 |
* or in the "license" file accompanying this file. This file is distributed
|
|
|
12 |
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
|
13 |
* express or implied. See the License for the specific language governing
|
|
|
14 |
* permissions and limitations under the License.
|
|
|
15 |
*/
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* Amazon Simple Queue Service (Amazon SQS) offers a reliable, highly scalable, hosted queue for
|
|
|
19 |
* storing messages as they travel between computers. By using Amazon SQS, developers can simply
|
|
|
20 |
* move data between distributed components of their applications that perform different tasks,
|
|
|
21 |
* without losing messages or requiring each component to be always available. Amazon SQS makes it
|
|
|
22 |
* easy to build an automated workflow, working in close conjunction with the Amazon Elastic
|
|
|
23 |
* Compute Cloud (Amazon EC2) and the other AWS infrastructure web services.
|
|
|
24 |
*
|
|
|
25 |
* Amazon SQS works by exposing Amazon's web-scale messaging infrastructure as a web service. Any
|
|
|
26 |
* computer on the Internet can add or read messages without any installed software or special
|
|
|
27 |
* firewall configurations. Components of applications using Amazon SQS can run independently, and
|
|
|
28 |
* do not need to be on the same network, developed with the same technologies, or running at the
|
|
|
29 |
* same time.
|
|
|
30 |
*
|
|
|
31 |
* Visit <a href="http://aws.amazon.com/sqs/">http://aws.amazon.com/sqs/</a> for more information.
|
|
|
32 |
*
|
|
|
33 |
* @version 2012.01.29
|
|
|
34 |
* @license See the included NOTICE.md file for complete information.
|
|
|
35 |
* @copyright See the included NOTICE.md file for complete information.
|
|
|
36 |
* @link http://aws.amazon.com/sqs/ Amazon Simple Queue Service
|
|
|
37 |
* @link http://aws.amazon.com/sqs/documentation/ Amazon Simple Queue Service documentation
|
|
|
38 |
*/
|
|
|
39 |
class AmazonSQS extends CFRuntime
|
|
|
40 |
{
|
|
|
41 |
/*%******************************************************************************************%*/
|
|
|
42 |
// CLASS CONSTANTS
|
|
|
43 |
|
|
|
44 |
/**
|
|
|
45 |
* Specify the queue URL for the United States East (Northern Virginia) Region.
|
|
|
46 |
*/
|
|
|
47 |
const REGION_US_E1 = 'sqs.us-east-1.amazonaws.com';
|
|
|
48 |
|
|
|
49 |
/**
|
|
|
50 |
* Specify the queue URL for the United States East (Northern Virginia) Region.
|
|
|
51 |
*/
|
|
|
52 |
const REGION_VIRGINIA = self::REGION_US_E1;
|
|
|
53 |
|
|
|
54 |
/**
|
|
|
55 |
* Specify the queue URL for the United States West (Northern California) Region.
|
|
|
56 |
*/
|
|
|
57 |
const REGION_US_W1 = 'sqs.us-west-1.amazonaws.com';
|
|
|
58 |
|
|
|
59 |
/**
|
|
|
60 |
* Specify the queue URL for the United States West (Northern California) Region.
|
|
|
61 |
*/
|
|
|
62 |
const REGION_CALIFORNIA = self::REGION_US_W1;
|
|
|
63 |
|
|
|
64 |
/**
|
|
|
65 |
* Specify the queue URL for the United States West (Oregon) Region.
|
|
|
66 |
*/
|
|
|
67 |
const REGION_US_W2 = 'sqs.us-west-2.amazonaws.com';
|
|
|
68 |
|
|
|
69 |
/**
|
|
|
70 |
* Specify the queue URL for the United States West (Oregon) Region.
|
|
|
71 |
*/
|
|
|
72 |
const REGION_OREGON = self::REGION_US_W2;
|
|
|
73 |
|
|
|
74 |
/**
|
|
|
75 |
* Specify the queue URL for the Europe West (Ireland) Region.
|
|
|
76 |
*/
|
|
|
77 |
const REGION_EU_W1 = 'sqs.eu-west-1.amazonaws.com';
|
|
|
78 |
|
|
|
79 |
/**
|
|
|
80 |
* Specify the queue URL for the Europe West (Ireland) Region.
|
|
|
81 |
*/
|
|
|
82 |
const REGION_IRELAND = self::REGION_EU_W1;
|
|
|
83 |
|
|
|
84 |
/**
|
|
|
85 |
* Specify the queue URL for the Asia Pacific Southeast (Singapore) Region.
|
|
|
86 |
*/
|
|
|
87 |
const REGION_APAC_SE1 = 'sqs.ap-southeast-1.amazonaws.com';
|
|
|
88 |
|
|
|
89 |
/**
|
|
|
90 |
* Specify the queue URL for the Asia Pacific Southeast (Singapore) Region.
|
|
|
91 |
*/
|
|
|
92 |
const REGION_SINGAPORE = self::REGION_APAC_SE1;
|
|
|
93 |
|
|
|
94 |
/**
|
|
|
95 |
* Specify the queue URL for the Asia Pacific Northeast (Tokyo) Region.
|
|
|
96 |
*/
|
|
|
97 |
const REGION_APAC_NE1 = 'sqs.ap-northeast-1.amazonaws.com';
|
|
|
98 |
|
|
|
99 |
/**
|
|
|
100 |
* Specify the queue URL for the Asia Pacific Northeast (Tokyo) Region.
|
|
|
101 |
*/
|
|
|
102 |
const REGION_TOKYO = self::REGION_APAC_NE1;
|
|
|
103 |
|
|
|
104 |
/**
|
|
|
105 |
* Specify the queue URL for the South America (Sao Paulo) Region.
|
|
|
106 |
*/
|
|
|
107 |
const REGION_SA_E1 = 'sqs.sa-east-1.amazonaws.com';
|
|
|
108 |
|
|
|
109 |
/**
|
|
|
110 |
* Specify the queue URL for the South America (Sao Paulo) Region.
|
|
|
111 |
*/
|
|
|
112 |
const REGION_SAO_PAULO = self::REGION_SA_E1;
|
|
|
113 |
|
|
|
114 |
/**
|
|
|
115 |
* Default service endpoint.
|
|
|
116 |
*/
|
|
|
117 |
const DEFAULT_URL = self::REGION_US_E1;
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
/*%******************************************************************************************%*/
|
|
|
121 |
// CONSTRUCTOR
|
|
|
122 |
|
|
|
123 |
/**
|
|
|
124 |
* Constructs a new instance of <AmazonSQS>.
|
|
|
125 |
*
|
|
|
126 |
* @param array $options (Optional) An associative array of parameters that can have the following keys: <ul>
|
|
|
127 |
* <li><code>certificate_authority</code> - <code>boolean</code> - Optional - Determines which Cerificate Authority file to use. A value of boolean <code>false</code> will use the Certificate Authority file available on the system. A value of boolean <code>true</code> will use the Certificate Authority provided by the SDK. Passing a file system path to a Certificate Authority file (chmodded to <code>0755</code>) will use that. Leave this set to <code>false</code> if you're not sure.</li>
|
|
|
128 |
* <li><code>credentials</code> - <code>string</code> - Optional - The name of the credential set to use for authentication.</li>
|
|
|
129 |
* <li><code>default_cache_config</code> - <code>string</code> - Optional - This option allows a preferred storage type to be configured for long-term caching. This can be changed later using the <set_cache_config()> method. Valid values are: <code>apc</code>, <code>xcache</code>, or a file system path such as <code>./cache</code> or <code>/tmp/cache/</code>.</li>
|
|
|
130 |
* <li><code>key</code> - <code>string</code> - Optional - Your AWS key, or a session key. If blank, the default credential set will be used.</li>
|
|
|
131 |
* <li><code>secret</code> - <code>string</code> - Optional - Your AWS secret key, or a session secret key. If blank, the default credential set will be used.</li>
|
|
|
132 |
* <li><code>token</code> - <code>string</code> - Optional - An AWS session token.</li></ul>
|
|
|
133 |
* @return void
|
|
|
134 |
*/
|
|
|
135 |
public function __construct(array $options = array())
|
|
|
136 |
{
|
|
|
137 |
$this->api_version = '2011-10-01';
|
|
|
138 |
$this->hostname = self::DEFAULT_URL;
|
|
|
139 |
$this->auth_class = 'AuthV2Query';
|
|
|
140 |
|
|
|
141 |
return parent::__construct($options);
|
|
|
142 |
}
|
|
|
143 |
|
|
|
144 |
|
|
|
145 |
/*%******************************************************************************************%*/
|
|
|
146 |
// SETTERS
|
|
|
147 |
|
|
|
148 |
/**
|
|
|
149 |
* This allows you to explicitly sets the region for the service to use.
|
|
|
150 |
*
|
|
|
151 |
* @param string $region (Required) The region to explicitly set. Available options are <REGION_US_E1>, <REGION_US_W1>, <REGION_US_W2>, <REGION_EU_W1>, <REGION_APAC_SE1>, <REGION_APAC_NE1>, <REGION_SA_E1>.
|
|
|
152 |
* @return $this A reference to the current instance.
|
|
|
153 |
*/
|
|
|
154 |
public function set_region($region)
|
|
|
155 |
{
|
|
|
156 |
// @codeCoverageIgnoreStart
|
|
|
157 |
$this->set_hostname($region);
|
|
|
158 |
return $this;
|
|
|
159 |
// @codeCoverageIgnoreEnd
|
|
|
160 |
}
|
|
|
161 |
|
|
|
162 |
|
|
|
163 |
/*%******************************************************************************************%*/
|
|
|
164 |
// CONVENIENCE METHODS
|
|
|
165 |
|
|
|
166 |
/**
|
|
|
167 |
* Converts a queue URI into a queue ARN.
|
|
|
168 |
*
|
|
|
169 |
* @param string $queue_url (Required) The queue URL to perform the action on. Retrieved when the queue is first created.
|
|
|
170 |
* @return string An ARN representation of the queue URI.
|
|
|
171 |
*/
|
|
|
172 |
function get_queue_arn($queue_url)
|
|
|
173 |
{
|
|
|
174 |
return str_replace(
|
|
|
175 |
array('http://', 'https://', '.amazonaws.com', '/', '.'),
|
|
|
176 |
array('arn:aws:', 'arn:aws:', '', ':', ':'),
|
|
|
177 |
$queue_url
|
|
|
178 |
);
|
|
|
179 |
}
|
|
|
180 |
|
|
|
181 |
/**
|
|
|
182 |
* Returns the approximate number of messages in the queue.
|
|
|
183 |
*
|
|
|
184 |
* @param string $queue_url (Required) The queue URL to perform the action on. Retrieved when the queue is first created.
|
|
|
185 |
* @return mixed The Approximate number of messages in the queue as an integer. If the queue doesn't exist, it returns the entire <CFResponse> object.
|
|
|
186 |
*/
|
|
|
187 |
public function get_queue_size($queue_url)
|
|
|
188 |
{
|
|
|
189 |
$response = $this->get_queue_attributes($queue_url, array(
|
|
|
190 |
'AttributeName' => 'ApproximateNumberOfMessages'
|
|
|
191 |
));
|
|
|
192 |
|
|
|
193 |
if (!$response->isOK())
|
|
|
194 |
{
|
|
|
195 |
return $response;
|
|
|
196 |
}
|
|
|
197 |
|
|
|
198 |
return (integer) $response->body->Value(0);
|
|
|
199 |
}
|
|
|
200 |
|
|
|
201 |
/**
|
|
|
202 |
* ONLY lists the queue URLs, as an array, on the SQS account.
|
|
|
203 |
*
|
|
|
204 |
* @param string $pcre (Optional) A Perl-Compatible Regular Expression (PCRE) to filter the names against.
|
|
|
205 |
* @return array The list of matching queue names. If there are no results, the method will return an empty array.
|
|
|
206 |
* @link http://php.net/pcre Perl-Compatible Regular Expression (PCRE) Docs
|
|
|
207 |
*/
|
|
|
208 |
public function get_queue_list($pcre = null)
|
|
|
209 |
{
|
|
|
210 |
if ($this->use_batch_flow)
|
|
|
211 |
{
|
|
|
212 |
throw new SQS_Exception(__FUNCTION__ . '() cannot be batch requested');
|
|
|
213 |
}
|
|
|
214 |
|
|
|
215 |
// Get a list of queues.
|
|
|
216 |
$list = $this->list_queues();
|
|
|
217 |
if ($list = $list->body->QueueUrl())
|
|
|
218 |
{
|
|
|
219 |
$list = $list->map_string($pcre);
|
|
|
220 |
return $list;
|
|
|
221 |
}
|
|
|
222 |
|
|
|
223 |
return array();
|
|
|
224 |
}
|
|
|
225 |
|
|
|
226 |
|
|
|
227 |
/*%******************************************************************************************%*/
|
|
|
228 |
// OVERWRITTEN METHODS
|
|
|
229 |
|
|
|
230 |
/**
|
|
|
231 |
* This overwrites the default authenticate method in sdk.class.php to address SQS queue URLs.
|
|
|
232 |
*
|
|
|
233 |
* @return CFResponse Object containing a parsed HTTP response.
|
|
|
234 |
*/
|
|
|
235 |
public function authenticate($operation, $payload)
|
|
|
236 |
{
|
|
|
237 |
// Save the current hostname
|
|
|
238 |
$hostname = $this->hostname;
|
|
|
239 |
|
|
|
240 |
if (isset($payload['QueueUrl']))
|
|
|
241 |
{
|
|
|
242 |
// Change the hostname to the queue URL
|
|
|
243 |
$this->hostname = $payload['QueueUrl'];
|
|
|
244 |
|
|
|
245 |
// Remove "QueueURL" from the payload
|
|
|
246 |
unset($payload['QueueUrl']);
|
|
|
247 |
}
|
|
|
248 |
|
|
|
249 |
// Perform the request
|
|
|
250 |
$response = parent::authenticate($operation, $payload);
|
|
|
251 |
|
|
|
252 |
// Restore the hostname
|
|
|
253 |
$this->hostname = $hostname;
|
|
|
254 |
|
|
|
255 |
return $response;
|
|
|
256 |
}
|
|
|
257 |
|
|
|
258 |
|
|
|
259 |
/*%******************************************************************************************%*/
|
|
|
260 |
// SERVICE METHODS
|
|
|
261 |
|
|
|
262 |
/**
|
|
|
263 |
* The AddPermission action adds a permission to a queue for a specific <a href=
|
|
|
264 |
* "http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Glossary.html#d0e3892">
|
|
|
265 |
* principal</a>. This allows for sharing access to the queue.
|
|
|
266 |
*
|
|
|
267 |
* When you create a queue, you have full control access rights for the queue. Only you (as owner
|
|
|
268 |
* of the queue) can grant or deny permissions to the queue. For more information about these
|
|
|
269 |
* permissions, see <a href=
|
|
|
270 |
* "http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/?acp-overview.html">
|
|
|
271 |
* Shared Queues</a> in the Amazon SQS Developer Guide.
|
|
|
272 |
*
|
|
|
273 |
* <code>AddPermission</code> writes an SQS-generated policy. If you want to write your own
|
|
|
274 |
* policy, use SetQueueAttributes to upload your policy. For more information about writing your
|
|
|
275 |
* own policy, see <a href=
|
|
|
276 |
* "http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/?AccessPolicyLanguage.html">
|
|
|
277 |
* Appendix: The Access Policy Language</a> in the Amazon SQS Developer Guide.
|
|
|
278 |
*
|
|
|
279 |
* @param string $queue_url (Required) The URL of the SQS queue to take action on.
|
|
|
280 |
* @param string $label (Required) The unique identification of the permission you're setting (e.g., <code>AliceSendMessage</code>). Constraints: Maximum 80 characters; alphanumeric characters, hyphens (-), and underscores (_) are allowed.
|
|
|
281 |
* @param string|array $aws_account_id (Required) The AWS account number of the <a href="http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Glossary.html">principal</a> who will be given permission. The principal must have an AWS account, but does not need to be signed up for Amazon SQS. Pass a string for a single value, or an indexed array for multiple values.
|
|
|
282 |
* @param string|array $action_name (Required) The action the client wants to allow for the specified principal. Pass a string for a single value, or an indexed array for multiple values.
|
|
|
283 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
|
|
284 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
|
|
285 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
|
|
286 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
|
|
287 |
*/
|
|
|
288 |
public function add_permission($queue_url, $label, $aws_account_id, $action_name, $opt = null)
|
|
|
289 |
{
|
|
|
290 |
if (!$opt) $opt = array();
|
|
|
291 |
$opt['QueueUrl'] = $queue_url;
|
|
|
292 |
$opt['Label'] = $label;
|
|
|
293 |
|
|
|
294 |
// Required list (non-map)
|
|
|
295 |
$opt = array_merge($opt, CFComplexType::map(array(
|
|
|
296 |
'AWSAccountId' => (is_array($aws_account_id) ? $aws_account_id : array($aws_account_id))
|
|
|
297 |
)));
|
|
|
298 |
|
|
|
299 |
// Required list (non-map)
|
|
|
300 |
$opt = array_merge($opt, CFComplexType::map(array(
|
|
|
301 |
'ActionName' => (is_array($action_name) ? $action_name : array($action_name))
|
|
|
302 |
)));
|
|
|
303 |
|
|
|
304 |
return $this->authenticate('AddPermission', $opt);
|
|
|
305 |
}
|
|
|
306 |
|
|
|
307 |
/**
|
|
|
308 |
* The <code>ChangeMessageVisibility</code> action changes the visibility timeout of a specified
|
|
|
309 |
* message in a queue to a new value. The maximum allowed timeout value you can set the value to
|
|
|
310 |
* is 12 hours. This means you can't extend the timeout of a message in an existing queue to more
|
|
|
311 |
* than a total visibility timeout of 12 hours. (For more information visibility timeout, see
|
|
|
312 |
* <a href=
|
|
|
313 |
* "http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/AboutVT.html">
|
|
|
314 |
* Visibility Timeout</a> in the Amazon SQS Developer Guide.)
|
|
|
315 |
*
|
|
|
316 |
* For example, let's say you have a message and its default message visibility timeout is 30
|
|
|
317 |
* minutes. You could call <code>ChangeMessageVisiblity</code> with a value of two hours and the
|
|
|
318 |
* effective timeout would be two hours and 30 minutes. When that time comes near you could again
|
|
|
319 |
* extend the time out by calling ChangeMessageVisiblity, but this time the maximum allowed
|
|
|
320 |
* timeout would be 9 hours and 30 minutes.
|
|
|
321 |
*
|
|
|
322 |
* <p class="important">
|
|
|
323 |
* If you attempt to set the <code>VisibilityTimeout</code> to an amount more than the maximum
|
|
|
324 |
* time left, Amazon SQS returns an error. It will not automatically recalculate and increase the
|
|
|
325 |
* timeout to the maximum time remaining.
|
|
|
326 |
* </p>
|
|
|
327 |
* <p class="important">
|
|
|
328 |
* Unlike with a queue, when you change the visibility timeout for a specific message, that
|
|
|
329 |
* timeout value is applied immediately but is not saved in memory for that message. If you don't
|
|
|
330 |
* delete a message after it is received, the visibility timeout for the message the next time it
|
|
|
331 |
* is received reverts to the original timeout value, not the value you set with the
|
|
|
332 |
* ChangeMessageVisibility action.
|
|
|
333 |
* </p>
|
|
|
334 |
*
|
|
|
335 |
* @param string $queue_url (Required) The URL of the SQS queue to take action on.
|
|
|
336 |
* @param string $receipt_handle (Required) The receipt handle associated with the message whose visibility timeout should be changed.
|
|
|
337 |
* @param integer $visibility_timeout (Required) The new value (in seconds) for the message's visibility timeout.
|
|
|
338 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
|
|
339 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
|
|
340 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
|
|
341 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
|
|
342 |
*/
|
|
|
343 |
public function change_message_visibility($queue_url, $receipt_handle, $visibility_timeout, $opt = null)
|
|
|
344 |
{
|
|
|
345 |
if (!$opt) $opt = array();
|
|
|
346 |
$opt['QueueUrl'] = $queue_url;
|
|
|
347 |
$opt['ReceiptHandle'] = $receipt_handle;
|
|
|
348 |
$opt['VisibilityTimeout'] = $visibility_timeout;
|
|
|
349 |
|
|
|
350 |
return $this->authenticate('ChangeMessageVisibility', $opt);
|
|
|
351 |
}
|
|
|
352 |
|
|
|
353 |
/**
|
|
|
354 |
* This is a batch version of <code>ChangeMessageVisibility</code>. It takes multiple receipt
|
|
|
355 |
* handles and performs the operation on each of the them. The result of the operation on each
|
|
|
356 |
* message is reported individually in the response.
|
|
|
357 |
*
|
|
|
358 |
* @param string $queue_url (Required) The URL of the SQS queue to take action on.
|
|
|
359 |
* @param array $change_message_visibility_batch_request_entry (Required) A list of receipt handles of the messages for which the visibility timeout must be changed. <ul>
|
|
|
360 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
|
|
361 |
* <li><code>Id</code> - <code>string</code> - Required - An identifier for this particular receipt handle. This is used to communicate the result. Note that the <code>Id</code> s of a batch request need to be unique within the request.</li>
|
|
|
362 |
* <li><code>ReceiptHandle</code> - <code>string</code> - Required - A receipt handle.</li>
|
|
|
363 |
* <li><code>VisibilityTimeout</code> - <code>integer</code> - Optional - The new value (in seconds) for the message's visibility timeout.</li>
|
|
|
364 |
* </ul></li>
|
|
|
365 |
* </ul>
|
|
|
366 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
|
|
367 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
|
|
368 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
|
|
369 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
|
|
370 |
*/
|
|
|
371 |
public function change_message_visibility_batch($queue_url, $change_message_visibility_batch_request_entry, $opt = null)
|
|
|
372 |
{
|
|
|
373 |
if (!$opt) $opt = array();
|
|
|
374 |
$opt['QueueUrl'] = $queue_url;
|
|
|
375 |
|
|
|
376 |
// Required list + map
|
|
|
377 |
$opt = array_merge($opt, CFComplexType::map(array(
|
|
|
378 |
'ChangeMessageVisibilityBatchRequestEntry' => (is_array($change_message_visibility_batch_request_entry) ? $change_message_visibility_batch_request_entry : array($change_message_visibility_batch_request_entry))
|
|
|
379 |
)));
|
|
|
380 |
|
|
|
381 |
return $this->authenticate('ChangeMessageVisibilityBatch', $opt);
|
|
|
382 |
}
|
|
|
383 |
|
|
|
384 |
/**
|
|
|
385 |
* The <code>CreateQueue</code> action creates a new queue, or returns the URL of an existing one.
|
|
|
386 |
* When you request <code>CreateQueue</code>, you provide a name for the queue. To successfully
|
|
|
387 |
* create a new queue, you must provide a name that is unique within the scope of your own queues.
|
|
|
388 |
*
|
|
|
389 |
* You may pass one or more attributes in the request. If you do not provide a value for any
|
|
|
390 |
* attribute, the queue will have the default value for that attribute. Permitted attributes are
|
|
|
391 |
* the same that can be set using <code>SetQueueAttributes</code>.
|
|
|
392 |
*
|
|
|
393 |
* If you provide the name of an existing queue, a new queue isn't created. If the values of
|
|
|
394 |
* attributes provided with the request match up with those on the existing queue, the queue URL
|
|
|
395 |
* is returned. Otherwise, a <code>QueueNameExists</code> error is returned.
|
|
|
396 |
*
|
|
|
397 |
* @param string $queue_name (Required) The name for the queue to be created.
|
|
|
398 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
|
|
399 |
* <li><code>Attribute</code> - <code>array</code> - Optional - A map of attributes with their corresponding values. <ul>
|
|
|
400 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
|
|
401 |
* <li><code>Name</code> - <code>string</code> - Optional - The name of a queue attribute. [Allowed values: <code>Policy</code>, <code>VisibilityTimeout</code>, <code>MaximumMessageSize</code>, <code>MessageRetentionPeriod</code>, <code>ApproximateNumberOfMessages</code>, <code>ApproximateNumberOfMessagesNotVisible</code>, <code>CreatedTimestamp</code>, <code>LastModifiedTimestamp</code>, <code>QueueArn</code>, <code>ApproximateNumberOfMessagesDelayed</code>, <code>DelaySeconds</code>]</li>
|
|
|
402 |
* <li><code>Value</code> - <code>string</code> - Optional - The value of a queue attribute.</li>
|
|
|
403 |
* </ul></li>
|
|
|
404 |
* </ul></li>
|
|
|
405 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
|
|
406 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
|
|
407 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
|
|
408 |
*/
|
|
|
409 |
public function create_queue($queue_name, $opt = null)
|
|
|
410 |
{
|
|
|
411 |
if (!$opt) $opt = array();
|
|
|
412 |
$opt['QueueName'] = $queue_name;
|
|
|
413 |
|
|
|
414 |
// Optional map (non-list)
|
|
|
415 |
if (isset($opt['Attribute']))
|
|
|
416 |
{
|
|
|
417 |
$opt = array_merge($opt, CFComplexType::map(array(
|
|
|
418 |
'Attribute' => $opt['Attribute']
|
|
|
419 |
)));
|
|
|
420 |
unset($opt['Attribute']);
|
|
|
421 |
}
|
|
|
422 |
|
|
|
423 |
return $this->authenticate('CreateQueue', $opt);
|
|
|
424 |
}
|
|
|
425 |
|
|
|
426 |
/**
|
|
|
427 |
* The <code>DeleteMessage</code> action unconditionally removes the specified message from the
|
|
|
428 |
* specified queue. Even if the message is locked by another reader due to the visibility timeout
|
|
|
429 |
* setting, it is still deleted from the queue.
|
|
|
430 |
*
|
|
|
431 |
* @param string $queue_url (Required) The URL of the SQS queue to take action on.
|
|
|
432 |
* @param string $receipt_handle (Required) The receipt handle associated with the message to delete.
|
|
|
433 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
|
|
434 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
|
|
435 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
|
|
436 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
|
|
437 |
*/
|
|
|
438 |
public function delete_message($queue_url, $receipt_handle, $opt = null)
|
|
|
439 |
{
|
|
|
440 |
if (!$opt) $opt = array();
|
|
|
441 |
$opt['QueueUrl'] = $queue_url;
|
|
|
442 |
$opt['ReceiptHandle'] = $receipt_handle;
|
|
|
443 |
|
|
|
444 |
return $this->authenticate('DeleteMessage', $opt);
|
|
|
445 |
}
|
|
|
446 |
|
|
|
447 |
/**
|
|
|
448 |
* This is a batch version of <code>DeleteMessage</code>. It takes multiple receipt handles and
|
|
|
449 |
* deletes each one of the messages. The result of the delete operation on each message is
|
|
|
450 |
* reported individually in the response.
|
|
|
451 |
*
|
|
|
452 |
* @param string $queue_url (Required) The URL of the SQS queue to take action on.
|
|
|
453 |
* @param array $delete_message_batch_request_entry (Required) A list of receipt handles for the messages to be deleted. <ul>
|
|
|
454 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
|
|
455 |
* <li><code>Id</code> - <code>string</code> - Required - An identifier for this particular receipt handle. This is used to communicate the result. Note that the <code>Id</code> s of a batch request need to be unique within the request.</li>
|
|
|
456 |
* <li><code>ReceiptHandle</code> - <code>string</code> - Required - A receipt handle.</li>
|
|
|
457 |
* </ul></li>
|
|
|
458 |
* </ul>
|
|
|
459 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
|
|
460 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
|
|
461 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
|
|
462 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
|
|
463 |
*/
|
|
|
464 |
public function delete_message_batch($queue_url, $delete_message_batch_request_entry, $opt = null)
|
|
|
465 |
{
|
|
|
466 |
if (!$opt) $opt = array();
|
|
|
467 |
$opt['QueueUrl'] = $queue_url;
|
|
|
468 |
|
|
|
469 |
// Required list + map
|
|
|
470 |
$opt = array_merge($opt, CFComplexType::map(array(
|
|
|
471 |
'DeleteMessageBatchRequestEntry' => (is_array($delete_message_batch_request_entry) ? $delete_message_batch_request_entry : array($delete_message_batch_request_entry))
|
|
|
472 |
)));
|
|
|
473 |
|
|
|
474 |
return $this->authenticate('DeleteMessageBatch', $opt);
|
|
|
475 |
}
|
|
|
476 |
|
|
|
477 |
/**
|
|
|
478 |
* This action unconditionally deletes the queue specified by the queue URL. Use this operation
|
|
|
479 |
* WITH CARE! The queue is deleted even if it is NOT empty.
|
|
|
480 |
*
|
|
|
481 |
* Once a queue has been deleted, the queue name is unavailable for use with new queues for 60
|
|
|
482 |
* seconds.
|
|
|
483 |
*
|
|
|
484 |
* @param string $queue_url (Required) The URL of the SQS queue to take action on.
|
|
|
485 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
|
|
486 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
|
|
487 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
|
|
488 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
|
|
489 |
*/
|
|
|
490 |
public function delete_queue($queue_url, $opt = null)
|
|
|
491 |
{
|
|
|
492 |
if (!$opt) $opt = array();
|
|
|
493 |
$opt['QueueUrl'] = $queue_url;
|
|
|
494 |
|
|
|
495 |
return $this->authenticate('DeleteQueue', $opt);
|
|
|
496 |
}
|
|
|
497 |
|
|
|
498 |
/**
|
|
|
499 |
* Gets attributes for the specified queue. The following attributes are supported:
|
|
|
500 |
*
|
|
|
501 |
* <ul>
|
|
|
502 |
* <li><code>All</code> - returns all values.</li>
|
|
|
503 |
* <li><code>ApproximateNumberOfMessages</code> - returns the approximate number of visible
|
|
|
504 |
* messages in a queue. For more information, see Resources Required to Process Messages in
|
|
|
505 |
* the Amazon SQS Developer Guide.</li>
|
|
|
506 |
* <li><code>ApproximateNumberOfMessagesNotVisible</code> - returns the approximate number of
|
|
|
507 |
* messages that are not timed-out and not deleted. For more information, see Resources
|
|
|
508 |
* Required to Process Messages in the Amazon SQS Developer Guide.</li>
|
|
|
509 |
* <li><code>VisibilityTimeout</code> - returns the visibility timeout for the queue. For more
|
|
|
510 |
* information about visibility timeout, see Visibility Timeout in the Amazon SQS Developer
|
|
|
511 |
* Guide.</li>
|
|
|
512 |
* <li><code>CreatedTimestamp</code> - returns the time when the queue was created (epoch time in
|
|
|
513 |
* seconds).</li>
|
|
|
514 |
* <li><code>LastModifiedTimestamp</code> - returns the time when the queue was last changed
|
|
|
515 |
* (epoch time in seconds).</li>
|
|
|
516 |
* <li><code>Policy</code> - returns the queue's policy.</li>
|
|
|
517 |
* <li><code>MaximumMessageSize</code> - returns the limit of how many bytes a message can contain
|
|
|
518 |
* before Amazon SQS rejects it.</li>
|
|
|
519 |
* <li><code>MessageRetentionPeriod</code> - returns the number of seconds Amazon SQS retains a
|
|
|
520 |
* message.</li>
|
|
|
521 |
* <li><code>QueueArn</code> - returns the queue's Amazon resource name (ARN).</li>
|
|
|
522 |
* <li><code>ApproximateNumberOfMessagesDelayed</code> - returns the approximate number of
|
|
|
523 |
* messages that are pending to be added to the queue.</li>
|
|
|
524 |
* <li><code>DelaySeconds</code> - returns the default delay on the queue in seconds.</li>
|
|
|
525 |
* </ul>
|
|
|
526 |
*
|
|
|
527 |
* @param string $queue_url (Required) The URL of the SQS queue to take action on.
|
|
|
528 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
|
|
529 |
* <li><code>AttributeName</code> - <code>string|array</code> - Optional - A list of attributes to retrieve information for. Pass a string for a single value, or an indexed array for multiple values.</li>
|
|
|
530 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
|
|
531 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
|
|
532 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
|
|
533 |
*/
|
|
|
534 |
public function get_queue_attributes($queue_url, $opt = null)
|
|
|
535 |
{
|
|
|
536 |
if (!$opt) $opt = array();
|
|
|
537 |
$opt['QueueUrl'] = $queue_url;
|
|
|
538 |
|
|
|
539 |
// Optional list (non-map)
|
|
|
540 |
if (isset($opt['AttributeName']))
|
|
|
541 |
{
|
|
|
542 |
$opt = array_merge($opt, CFComplexType::map(array(
|
|
|
543 |
'AttributeName' => (is_array($opt['AttributeName']) ? $opt['AttributeName'] : array($opt['AttributeName']))
|
|
|
544 |
)));
|
|
|
545 |
unset($opt['AttributeName']);
|
|
|
546 |
}
|
|
|
547 |
|
|
|
548 |
return $this->authenticate('GetQueueAttributes', $opt);
|
|
|
549 |
}
|
|
|
550 |
|
|
|
551 |
/**
|
|
|
552 |
* The <code>GetQueueUrl</code> action returns the URL of an existing queue.
|
|
|
553 |
*
|
|
|
554 |
* @param string $queue_name (Required) The name of the queue whose URL must be fetched.
|
|
|
555 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
|
|
556 |
* <li><code>QueueOwnerAWSAccountId</code> - <code>string</code> - Optional - The AWS account number of the queue's owner.</li>
|
|
|
557 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
|
|
558 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
|
|
559 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
|
|
560 |
*/
|
|
|
561 |
public function get_queue_url($queue_name, $opt = null)
|
|
|
562 |
{
|
|
|
563 |
if (!$opt) $opt = array();
|
|
|
564 |
$opt['QueueName'] = $queue_name;
|
|
|
565 |
|
|
|
566 |
return $this->authenticate('GetQueueUrl', $opt);
|
|
|
567 |
}
|
|
|
568 |
|
|
|
569 |
/**
|
|
|
570 |
* Returns a list of your queues.
|
|
|
571 |
*
|
|
|
572 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
|
|
573 |
* <li><code>QueueNamePrefix</code> - <code>string</code> - Optional - A string to use for filtering the list results. Only those queues whose name begins with the specified string are returned.</li>
|
|
|
574 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
|
|
575 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
|
|
576 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
|
|
577 |
*/
|
|
|
578 |
public function list_queues($opt = null)
|
|
|
579 |
{
|
|
|
580 |
if (!$opt) $opt = array();
|
|
|
581 |
|
|
|
582 |
return $this->authenticate('ListQueues', $opt);
|
|
|
583 |
}
|
|
|
584 |
|
|
|
585 |
/**
|
|
|
586 |
* Retrieves one or more messages from the specified queue, including the message body and message
|
|
|
587 |
* ID of each message. Messages returned by this action stay in the queue until you delete them.
|
|
|
588 |
* However, once a message is returned to a <code>ReceiveMessage</code> request, it is not
|
|
|
589 |
* returned on subsequent <code>ReceiveMessage</code> requests for the duration of the
|
|
|
590 |
* <code>VisibilityTimeout</code>. If you do not specify a <code>VisibilityTimeout</code> in the
|
|
|
591 |
* request, the overall visibility timeout for the queue is used for the returned messages.
|
|
|
592 |
*
|
|
|
593 |
* @param string $queue_url (Required) The URL of the SQS queue to take action on.
|
|
|
594 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
|
|
595 |
* <li><code>AttributeName</code> - <code>string|array</code> - Optional - A list of attributes to retrieve information for. Pass a string for a single value, or an indexed array for multiple values.</li>
|
|
|
596 |
* <li><code>MaxNumberOfMessages</code> - <code>integer</code> - Optional - The maximum number of messages to return. Amazon SQS never returns more messages than this value but may return fewer. All of the messages are not necessarily returned.</li>
|
|
|
597 |
* <li><code>VisibilityTimeout</code> - <code>integer</code> - Optional - The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a <code>ReceiveMessage</code> request.</li>
|
|
|
598 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
|
|
599 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
|
|
600 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
|
|
601 |
*/
|
|
|
602 |
public function receive_message($queue_url, $opt = null)
|
|
|
603 |
{
|
|
|
604 |
if (!$opt) $opt = array();
|
|
|
605 |
$opt['QueueUrl'] = $queue_url;
|
|
|
606 |
|
|
|
607 |
// Optional list (non-map)
|
|
|
608 |
if (isset($opt['AttributeName']))
|
|
|
609 |
{
|
|
|
610 |
$opt = array_merge($opt, CFComplexType::map(array(
|
|
|
611 |
'AttributeName' => (is_array($opt['AttributeName']) ? $opt['AttributeName'] : array($opt['AttributeName']))
|
|
|
612 |
)));
|
|
|
613 |
unset($opt['AttributeName']);
|
|
|
614 |
}
|
|
|
615 |
|
|
|
616 |
return $this->authenticate('ReceiveMessage', $opt);
|
|
|
617 |
}
|
|
|
618 |
|
|
|
619 |
/**
|
|
|
620 |
* The <code>RemovePermission</code> action revokes any permissions in the queue policy that
|
|
|
621 |
* matches the specified <code>Label</code> parameter. Only the owner of the queue can remove
|
|
|
622 |
* permissions.
|
|
|
623 |
*
|
|
|
624 |
* @param string $queue_url (Required) The URL of the SQS queue to take action on.
|
|
|
625 |
* @param string $label (Required) The identification of the permission to remove. This is the label added with the <code>AddPermission</code> operation.
|
|
|
626 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
|
|
627 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
|
|
628 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
|
|
629 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
|
|
630 |
*/
|
|
|
631 |
public function remove_permission($queue_url, $label, $opt = null)
|
|
|
632 |
{
|
|
|
633 |
if (!$opt) $opt = array();
|
|
|
634 |
$opt['QueueUrl'] = $queue_url;
|
|
|
635 |
$opt['Label'] = $label;
|
|
|
636 |
|
|
|
637 |
return $this->authenticate('RemovePermission', $opt);
|
|
|
638 |
}
|
|
|
639 |
|
|
|
640 |
/**
|
|
|
641 |
* The <code>SendMessage</code> action delivers a message to the specified queue.
|
|
|
642 |
*
|
|
|
643 |
* @param string $queue_url (Required) The URL of the SQS queue to take action on.
|
|
|
644 |
* @param string $message_body (Required) The message to send.
|
|
|
645 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
|
|
646 |
* <li><code>DelaySeconds</code> - <code>integer</code> - Optional - The number of seconds the message has to be delayed.</li>
|
|
|
647 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
|
|
648 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
|
|
649 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
|
|
650 |
*/
|
|
|
651 |
public function send_message($queue_url, $message_body, $opt = null)
|
|
|
652 |
{
|
|
|
653 |
if (!$opt) $opt = array();
|
|
|
654 |
$opt['QueueUrl'] = $queue_url;
|
|
|
655 |
$opt['MessageBody'] = $message_body;
|
|
|
656 |
|
|
|
657 |
return $this->authenticate('SendMessage', $opt);
|
|
|
658 |
}
|
|
|
659 |
|
|
|
660 |
/**
|
|
|
661 |
* This is a batch version of <code>SendMessage</code>. It takes multiple messages and adds each
|
|
|
662 |
* of them to the queue. The result of each add operation is reported individually in the
|
|
|
663 |
* response.
|
|
|
664 |
*
|
|
|
665 |
* @param string $queue_url (Required) The URL of the SQS queue to take action on.
|
|
|
666 |
* @param array $send_message_batch_request_entry (Required) A list of <code>SendMessageBatchRequestEntry</code> s. <ul>
|
|
|
667 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
|
|
668 |
* <li><code>Id</code> - <code>string</code> - Required - An identifier for the message in this batch. This is used to communicate the result. Note that the the <code>Id</code> s of a batch request need to be unique within the request.</li>
|
|
|
669 |
* <li><code>MessageBody</code> - <code>string</code> - Required - Body of the message.</li>
|
|
|
670 |
* <li><code>DelaySeconds</code> - <code>integer</code> - Optional - The number of seconds for which the message has to be delayed.</li>
|
|
|
671 |
* </ul></li>
|
|
|
672 |
* </ul>
|
|
|
673 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
|
|
674 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
|
|
675 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
|
|
676 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
|
|
677 |
*/
|
|
|
678 |
public function send_message_batch($queue_url, $send_message_batch_request_entry, $opt = null)
|
|
|
679 |
{
|
|
|
680 |
if (!$opt) $opt = array();
|
|
|
681 |
$opt['QueueUrl'] = $queue_url;
|
|
|
682 |
|
|
|
683 |
// Required list + map
|
|
|
684 |
$opt = array_merge($opt, CFComplexType::map(array(
|
|
|
685 |
'SendMessageBatchRequestEntry' => (is_array($send_message_batch_request_entry) ? $send_message_batch_request_entry : array($send_message_batch_request_entry))
|
|
|
686 |
)));
|
|
|
687 |
|
|
|
688 |
return $this->authenticate('SendMessageBatch', $opt);
|
|
|
689 |
}
|
|
|
690 |
|
|
|
691 |
/**
|
|
|
692 |
* Sets an attribute of a queue. The set of attributes that can be set are - DelaySeconds,
|
|
|
693 |
* MessageRetentionPeriod, MaximumMessageSize, VisibilityTimeout and Policy.
|
|
|
694 |
*
|
|
|
695 |
* @param string $queue_url (Required) The URL of the SQS queue to take action on.
|
|
|
696 |
* @param array $attribute (Required) A map of attributes to set. <ul>
|
|
|
697 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
|
|
698 |
* <li><code>Name</code> - <code>string</code> - Optional - The name of a queue attribute. [Allowed values: <code>Policy</code>, <code>VisibilityTimeout</code>, <code>MaximumMessageSize</code>, <code>MessageRetentionPeriod</code>, <code>ApproximateNumberOfMessages</code>, <code>ApproximateNumberOfMessagesNotVisible</code>, <code>CreatedTimestamp</code>, <code>LastModifiedTimestamp</code>, <code>QueueArn</code>, <code>ApproximateNumberOfMessagesDelayed</code>, <code>DelaySeconds</code>]</li>
|
|
|
699 |
* <li><code>Value</code> - <code>string</code> - Optional - The value of a queue attribute.</li>
|
|
|
700 |
* </ul></li>
|
|
|
701 |
* </ul>
|
|
|
702 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
|
|
703 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
|
|
704 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
|
|
705 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
|
|
706 |
*/
|
|
|
707 |
public function set_queue_attributes($queue_url, $attribute, $opt = null)
|
|
|
708 |
{
|
|
|
709 |
if (!$opt) $opt = array();
|
|
|
710 |
$opt['QueueUrl'] = $queue_url;
|
|
|
711 |
|
|
|
712 |
// Required map (non-list)
|
|
|
713 |
$opt = array_merge($opt, CFComplexType::map(array(
|
|
|
714 |
'Attribute' => (is_array($attribute) ? $attribute : array($attribute))
|
|
|
715 |
)));
|
|
|
716 |
|
|
|
717 |
return $this->authenticate('SetQueueAttributes', $opt);
|
|
|
718 |
}
|
|
|
719 |
}
|
|
|
720 |
|
|
|
721 |
|
|
|
722 |
/*%******************************************************************************************%*/
|
|
|
723 |
// EXCEPTIONS
|
|
|
724 |
|
|
|
725 |
class SQS_Exception extends Exception {}
|