Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
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
 * This is the <em>Amazon CloudWatch API Reference</em>. This guide provides detailed information
19
 * about Amazon CloudWatch actions, data types, parameters, and errors. For detailed information
20
 * about Amazon CloudWatch features and their associated API calls, go to the <a href=
21
 * "http://docs.amazonwebservices.com/AmazonCloudWatch/latest/DeveloperGuide">Amazon CloudWatch
22
 * Developer Guide</a>.
23
 *
24
 * Amazon CloudWatch is a web service that enables you to publish, monitor, and manage various
25
 * metrics, as well as configure alarm actions based on data from metrics. For more information
26
 * about this product go to <a href=
27
 * "http://aws.amazon.com/cloudwatch">http://aws.amazon.com/cloudwatch</a>.
28
 *
29
 * Use the following links to get started using the <em>Amazon CloudWatch API Reference</em>:
30
 *
31
 * <ul>
32
 * 	<li><a href=
33
 * 	"http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_Operations.html">
34
 * 	Actions</a>: An alphabetical list of all Amazon CloudWatch actions.</li>
35
 * 	<li><a href=
36
 * 	"http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_Types.html">Data
37
 * 	Types</a>: An alphabetical list of all Amazon CloudWatch data types.</li>
38
 * 	<li><a href=
39
 * 	"http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/CommonParameters.html">
40
 * 	Common Parameters</a>: Parameters that all Query actions can use.</li>
41
 * 	<li><a href=
42
 * 	"http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/CommonErrors.html">Common
43
 * 	Errors</a>: Client and server errors that all actions can return.</li>
44
 * 	<li><a href="http://docs.amazonwebservices.com/general/latest/gr/index.html?rande.html">Regions
45
 * 	and Endpoints</a>: Itemized regions and endpoints for all AWS products.</li>
46
 * 	<li><a href="http://monitoring.amazonaws.com/doc/2010-08-01/CloudWatch.wsdl">WSDL Location</a>:
47
 * 	http://monitoring.amazonaws.com/doc/2010-08-01/CloudWatch.wsdl</li>
48
 * </ul>
49
 *
50
 * @version 2012.01.16
51
 * @license See the included NOTICE.md file for complete information.
52
 * @copyright See the included NOTICE.md file for complete information.
53
 * @link http://aws.amazon.com/cloudwatch/ Amazon CloudWatch
54
 * @link http://aws.amazon.com/cloudwatch/documentation/ Amazon CloudWatch documentation
55
 */
56
class AmazonCloudWatch extends CFRuntime
57
{
58
	/*%******************************************************************************************%*/
59
	// CLASS CONSTANTS
60
 
61
	/**
62
	 * Specify the queue URL for the United States East (Northern Virginia) Region.
63
	 */
64
	const REGION_US_E1 = 'monitoring.us-east-1.amazonaws.com';
65
 
66
	/**
67
	 * Specify the queue URL for the United States East (Northern Virginia) Region.
68
	 */
69
	const REGION_VIRGINIA = self::REGION_US_E1;
70
 
71
	/**
72
	 * Specify the queue URL for the United States West (Northern California) Region.
73
	 */
74
	const REGION_US_W1 = 'monitoring.us-west-1.amazonaws.com';
75
 
76
	/**
77
	 * Specify the queue URL for the United States West (Northern California) Region.
78
	 */
79
	const REGION_CALIFORNIA = self::REGION_US_W1;
80
 
81
	/**
82
	 * Specify the queue URL for the United States West (Oregon) Region.
83
	 */
84
	const REGION_US_W2 = 'monitoring.us-west-2.amazonaws.com';
85
 
86
	/**
87
	 * Specify the queue URL for the United States West (Oregon) Region.
88
	 */
89
	const REGION_OREGON = self::REGION_US_W2;
90
 
91
	/**
92
	 * Specify the queue URL for the Europe West (Ireland) Region.
93
	 */
94
	const REGION_EU_W1 = 'monitoring.eu-west-1.amazonaws.com';
95
 
96
	/**
97
	 * Specify the queue URL for the Europe West (Ireland) Region.
98
	 */
99
	const REGION_IRELAND = self::REGION_EU_W1;
100
 
101
	/**
102
	 * Specify the queue URL for the Asia Pacific Southeast (Singapore) Region.
103
	 */
104
	const REGION_APAC_SE1 = 'monitoring.ap-southeast-1.amazonaws.com';
105
 
106
	/**
107
	 * Specify the queue URL for the Asia Pacific Southeast (Singapore) Region.
108
	 */
109
	const REGION_SINGAPORE = self::REGION_APAC_SE1;
110
 
111
	/**
112
	 * Specify the queue URL for the Asia Pacific Northeast (Tokyo) Region.
113
	 */
114
	const REGION_APAC_NE1 = 'monitoring.ap-northeast-1.amazonaws.com';
115
 
116
	/**
117
	 * Specify the queue URL for the Asia Pacific Northeast (Tokyo) Region.
118
	 */
119
	const REGION_TOKYO = self::REGION_APAC_NE1;
120
 
121
	/**
122
	 * Specify the queue URL for the United States GovCloud Region.
123
	 */
124
	const REGION_US_GOV1 = 'monitoring.us-gov-west-1.amazonaws.com';
125
 
126
	/**
127
	 * Specify the queue URL for the South America (Sao Paulo) Region.
128
	 */
129
	const REGION_SA_E1 = 'monitoring.sa-east-1.amazonaws.com';
130
 
131
	/**
132
	 * Specify the queue URL for the South America (Sao Paulo) Region.
133
	 */
134
	const REGION_SAO_PAULO = self::REGION_SA_E1;
135
 
136
	/**
137
	 * Default service endpoint.
138
	 */
139
	const DEFAULT_URL = self::REGION_US_E1;
140
 
141
 
142
	/*%******************************************************************************************%*/
143
	// CONSTRUCTOR
144
 
145
	/**
146
	 * Constructs a new instance of <AmazonCloudWatch>.
147
	 *
148
	 * @param array $options (Optional) An associative array of parameters that can have the following keys: <ul>
149
	 * 	<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>
150
	 * 	<li><code>credentials</code> - <code>string</code> - Optional - The name of the credential set to use for authentication.</li>
151
	 * 	<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>
152
	 * 	<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>
153
	 * 	<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>
154
	 * 	<li><code>token</code> - <code>string</code> - Optional - An AWS session token.</li></ul>
155
	 * @return void
156
	 */
157
	public function __construct(array $options = array())
158
	{
159
		$this->api_version = '2010-08-01';
160
		$this->hostname = self::DEFAULT_URL;
161
		$this->auth_class = 'AuthV2Query';
162
 
163
		return parent::__construct($options);
164
	}
165
 
166
 
167
	/*%******************************************************************************************%*/
168
	// SETTERS
169
 
170
	/**
171
	 * This allows you to explicitly sets the region for the service to use.
172
	 *
173
	 * @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_US_GOV1>, <REGION_SA_E1>.
174
	 * @return $this A reference to the current instance.
175
	 */
176
	public function set_region($region)
177
	{
178
		// @codeCoverageIgnoreStart
179
		$this->set_hostname($region);
180
		return $this;
181
		// @codeCoverageIgnoreEnd
182
	}
183
 
184
 
185
	/*%******************************************************************************************%*/
186
	// SERVICE METHODS
187
 
188
	/**
189
	 * Deletes all specified alarms. In the event of an error, no alarms are deleted.
190
	 *
191
	 * @param string|array $alarm_names (Required) A list of alarms to be deleted. Pass a string for a single value, or an indexed array for multiple values.
192
	 * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
193
	 * 	<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>
194
	 * 	<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>
195
	 * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
196
	 */
197
	public function delete_alarms($alarm_names, $opt = null)
198
	{
199
		if (!$opt) $opt = array();
200
 
201
		// Required list (non-map)
202
		$opt = array_merge($opt, CFComplexType::map(array(
203
			'AlarmNames' => (is_array($alarm_names) ? $alarm_names : array($alarm_names))
204
		), 'member'));
205
 
206
		return $this->authenticate('DeleteAlarms', $opt);
207
	}
208
 
209
	/**
210
	 * Retrieves history for the specified alarm. Filter alarms by date range or item type. If an
211
	 * alarm name is not specified, Amazon CloudWatch returns histories for all of the owner's alarms.
212
	 *
213
	 * <p class="note">
214
	 * Amazon CloudWatch retains the history of an alarm for two weeks, whether or not you delete the
215
	 * alarm.
216
	 * </p>
217
	 *
218
	 * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
219
	 * 	<li><code>AlarmName</code> - <code>string</code> - Optional - The name of the alarm.</li>
220
	 * 	<li><code>HistoryItemType</code> - <code>string</code> - Optional - The type of alarm histories to retrieve. [Allowed values: <code>ConfigurationUpdate</code>, <code>StateUpdate</code>, <code>Action</code>]</li>
221
	 * 	<li><code>StartDate</code> - <code>string</code> - Optional - The starting date to retrieve alarm history. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
222
	 * 	<li><code>EndDate</code> - <code>string</code> - Optional - The ending date to retrieve alarm history. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
223
	 * 	<li><code>MaxRecords</code> - <code>integer</code> - Optional - The maximum number of alarm history records to retrieve.</li>
224
	 * 	<li><code>NextToken</code> - <code>string</code> - Optional - The token returned by a previous call to indicate that there is more data available.</li>
225
	 * 	<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>
226
	 * 	<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>
227
	 * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
228
	 */
229
	public function describe_alarm_history($opt = null)
230
	{
231
		if (!$opt) $opt = array();
232
 
233
		// Optional DateTime
234
		if (isset($opt['StartDate']))
235
		{
236
			$opt['StartDate'] = $this->util->convert_date_to_iso8601($opt['StartDate']);
237
		}
238
 
239
		// Optional DateTime
240
		if (isset($opt['EndDate']))
241
		{
242
			$opt['EndDate'] = $this->util->convert_date_to_iso8601($opt['EndDate']);
243
		}
244
 
245
		return $this->authenticate('DescribeAlarmHistory', $opt);
246
	}
247
 
248
	/**
249
	 * Retrieves alarms with the specified names. If no name is specified, all alarms for the user are
250
	 * returned. Alarms can be retrieved by using only a prefix for the alarm name, the alarm state,
251
	 * or a prefix for any action.
252
	 *
253
	 * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
254
	 * 	<li><code>AlarmNames</code> - <code>string|array</code> - Optional - A list of alarm names to retrieve information for. Pass a string for a single value, or an indexed array for multiple values.</li>
255
	 * 	<li><code>AlarmNamePrefix</code> - <code>string</code> - Optional - The alarm name prefix. <code>AlarmNames</code> cannot be specified if this parameter is specified.</li>
256
	 * 	<li><code>StateValue</code> - <code>string</code> - Optional - The state value to be used in matching alarms. [Allowed values: <code>OK</code>, <code>ALARM</code>, <code>INSUFFICIENT_DATA</code>]</li>
257
	 * 	<li><code>ActionPrefix</code> - <code>string</code> - Optional - The action name prefix.</li>
258
	 * 	<li><code>MaxRecords</code> - <code>integer</code> - Optional - The maximum number of alarm descriptions to retrieve.</li>
259
	 * 	<li><code>NextToken</code> - <code>string</code> - Optional - The token returned by a previous call to indicate that there is more data available.</li>
260
	 * 	<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>
261
	 * 	<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>
262
	 * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
263
	 */
264
	public function describe_alarms($opt = null)
265
	{
266
		if (!$opt) $opt = array();
267
 
268
		// Optional list (non-map)
269
		if (isset($opt['AlarmNames']))
270
		{
271
			$opt = array_merge($opt, CFComplexType::map(array(
272
				'AlarmNames' => (is_array($opt['AlarmNames']) ? $opt['AlarmNames'] : array($opt['AlarmNames']))
273
			), 'member'));
274
			unset($opt['AlarmNames']);
275
		}
276
 
277
		return $this->authenticate('DescribeAlarms', $opt);
278
	}
279
 
280
	/**
281
	 * Retrieves all alarms for a single metric. Specify a statistic, period, or unit to filter the
282
	 * set of alarms further.
283
	 *
284
	 * @param string $metric_name (Required) The name of the metric.
285
	 * @param string $namespace (Required) The namespace of the metric. [Constraints: The value must be between 1 and 255 characters, and must match the following regular expression pattern: <code>[^:].*</code>]
286
	 * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
287
	 * 	<li><code>Statistic</code> - <code>string</code> - Optional - The statistic for the metric. [Allowed values: <code>SampleCount</code>, <code>Average</code>, <code>Sum</code>, <code>Minimum</code>, <code>Maximum</code>]</li>
288
	 * 	<li><code>Dimensions</code> - <code>array</code> - Optional - The list of dimensions associated with the metric. <ul>
289
	 * 		<li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
290
	 * 			<li><code>Name</code> - <code>string</code> - Required - The name of the dimension.</li>
291
	 * 			<li><code>Value</code> - <code>string</code> - Required - The value representing the dimension measurement</li>
292
	 * 		</ul></li>
293
	 * 	</ul></li>
294
	 * 	<li><code>Period</code> - <code>integer</code> - Optional - The period in seconds over which the statistic is applied.</li>
295
	 * 	<li><code>Unit</code> - <code>string</code> - Optional - The unit for the metric. [Allowed values: <code>Seconds</code>, <code>Microseconds</code>, <code>Milliseconds</code>, <code>Bytes</code>, <code>Kilobytes</code>, <code>Megabytes</code>, <code>Gigabytes</code>, <code>Terabytes</code>, <code>Bits</code>, <code>Kilobits</code>, <code>Megabits</code>, <code>Gigabits</code>, <code>Terabits</code>, <code>Percent</code>, <code>Count</code>, <code>Bytes/Second</code>, <code>Kilobytes/Second</code>, <code>Megabytes/Second</code>, <code>Gigabytes/Second</code>, <code>Terabytes/Second</code>, <code>Bits/Second</code>, <code>Kilobits/Second</code>, <code>Megabits/Second</code>, <code>Gigabits/Second</code>, <code>Terabits/Second</code>, <code>Count/Second</code>, <code>None</code>]</li>
296
	 * 	<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>
297
	 * 	<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>
298
	 * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
299
	 */
300
	public function describe_alarms_for_metric($metric_name, $namespace, $opt = null)
301
	{
302
		if (!$opt) $opt = array();
303
		$opt['MetricName'] = $metric_name;
304
		$opt['Namespace'] = $namespace;
305
 
306
		// Optional list + map
307
		if (isset($opt['Dimensions']))
308
		{
309
			$opt = array_merge($opt, CFComplexType::map(array(
310
				'Dimensions' => $opt['Dimensions']
311
			), 'member'));
312
			unset($opt['Dimensions']);
313
		}
314
 
315
		return $this->authenticate('DescribeAlarmsForMetric', $opt);
316
	}
317
 
318
	/**
319
	 * Disables actions for the specified alarms. When an alarm's actions are disabled the alarm's
320
	 * state may change, but none of the alarm's actions will execute.
321
	 *
322
	 * @param string|array $alarm_names (Required) The names of the alarms to disable actions for. Pass a string for a single value, or an indexed array for multiple values.
323
	 * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
324
	 * 	<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>
325
	 * 	<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>
326
	 * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
327
	 */
328
	public function disable_alarm_actions($alarm_names, $opt = null)
329
	{
330
		if (!$opt) $opt = array();
331
 
332
		// Required list (non-map)
333
		$opt = array_merge($opt, CFComplexType::map(array(
334
			'AlarmNames' => (is_array($alarm_names) ? $alarm_names : array($alarm_names))
335
		), 'member'));
336
 
337
		return $this->authenticate('DisableAlarmActions', $opt);
338
	}
339
 
340
	/**
341
	 * Enables actions for the specified alarms.
342
	 *
343
	 * @param string|array $alarm_names (Required) The names of the alarms to enable actions for. Pass a string for a single value, or an indexed array for multiple values.
344
	 * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
345
	 * 	<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>
346
	 * 	<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>
347
	 * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
348
	 */
349
	public function enable_alarm_actions($alarm_names, $opt = null)
350
	{
351
		if (!$opt) $opt = array();
352
 
353
		// Required list (non-map)
354
		$opt = array_merge($opt, CFComplexType::map(array(
355
			'AlarmNames' => (is_array($alarm_names) ? $alarm_names : array($alarm_names))
356
		), 'member'));
357
 
358
		return $this->authenticate('EnableAlarmActions', $opt);
359
	}
360
 
361
	/**
362
	 * Gets statistics for the specified metric.
363
	 *
364
	 * <p class="note">
365
	 * The maximum number of data points returned from a single <code>GetMetricStatistics</code>
366
	 * request is 1,440. If a request is made that generates more than 1,440 data points, Amazon
367
	 * CloudWatch returns an error. In such a case, alter the request by narrowing the specified time
368
	 * range or increasing the specified period. Alternatively, make multiple requests across adjacent
369
	 * time ranges.
370
	 * </p>
371
	 * Amazon CloudWatch aggregates data points based on the length of the <code>period</code> that
372
	 * you specify. For example, if you request statistics with a one-minute granularity, Amazon
373
	 * CloudWatch aggregates data points with time stamps that fall within the same one-minute period.
374
	 * In such a case, the data points queried can greatly outnumber the data points returned.
375
	 *
376
	 * <p class="note">
377
	 * The maximum number of data points that can be queried is 50,850; whereas the maximum number of
378
	 * data points returned is 1,440.
379
	 * </p>
380
	 * The following examples show various statistics allowed by the data point query maximum of
381
	 * 50,850 when you call <code>GetMetricStatistics</code> on Amazon EC2 instances with detailed
382
	 * (one-minute) monitoring enabled:
383
	 *
384
	 * <ul>
385
	 * 	<li>Statistics for up to 400 instances for a span of one hour</li>
386
	 * 	<li>Statistics for up to 35 instances over a span of 24 hours</li>
387
	 * 	<li>Statistics for up to 2 instances over a span of 2 weeks</li>
388
	 * </ul>
389
	 *
390
	 * @param string $namespace (Required) The namespace of the metric. [Constraints: The value must be between 1 and 255 characters, and must match the following regular expression pattern: <code>[^:].*</code>]
391
	 * @param string $metric_name (Required) The name of the metric.
392
	 * @param string $start_time (Required) The time stamp to use for determining the first datapoint to return. The value specified is inclusive; results include datapoints with the time stamp specified. <p class="note">The specified start time is rounded down to the nearest value. Datapoints are returned for start times up to two weeks in the past. Specified start times that are more than two weeks in the past will not return datapoints for metrics that are older than two weeks.</p> May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.
393
	 * @param string $end_time (Required) The time stamp to use for determining the last datapoint to return. The value specified is exclusive; results will include datapoints up to the time stamp specified. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.
394
	 * @param integer $period (Required) The granularity, in seconds, of the returned datapoints. <code>Period</code> must be at least 60 seconds and must be a multiple of 60. The default value is 60.
395
	 * @param string|array $statistics (Required) The metric statistics to return. Pass a string for a single value, or an indexed array for multiple values.
396
	 * @param string $unit (Required) The unit for the metric. [Allowed values: <code>Seconds</code>, <code>Microseconds</code>, <code>Milliseconds</code>, <code>Bytes</code>, <code>Kilobytes</code>, <code>Megabytes</code>, <code>Gigabytes</code>, <code>Terabytes</code>, <code>Bits</code>, <code>Kilobits</code>, <code>Megabits</code>, <code>Gigabits</code>, <code>Terabits</code>, <code>Percent</code>, <code>Count</code>, <code>Bytes/Second</code>, <code>Kilobytes/Second</code>, <code>Megabytes/Second</code>, <code>Gigabytes/Second</code>, <code>Terabytes/Second</code>, <code>Bits/Second</code>, <code>Kilobits/Second</code>, <code>Megabits/Second</code>, <code>Gigabits/Second</code>, <code>Terabits/Second</code>, <code>Count/Second</code>, <code>None</code>]
397
	 * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
398
	 * 	<li><code>Dimensions</code> - <code>array</code> - Optional - A list of dimensions describing qualities of the metric. <ul>
399
	 * 		<li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
400
	 * 			<li><code>Name</code> - <code>string</code> - Required - The name of the dimension.</li>
401
	 * 			<li><code>Value</code> - <code>string</code> - Required - The value representing the dimension measurement</li>
402
	 * 		</ul></li>
403
	 * 	</ul></li>
404
	 * 	<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>
405
	 * 	<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>
406
	 * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
407
	 */
408
	public function get_metric_statistics($namespace, $metric_name, $start_time, $end_time, $period, $statistics, $unit, $opt = null)
409
	{
410
		if (!$opt) $opt = array();
411
		$opt['Namespace'] = $namespace;
412
		$opt['MetricName'] = $metric_name;
413
		$opt['Period'] = $period;
414
		$opt['Unit'] = $unit;
415
		$opt['StartTime'] = $this->util->convert_date_to_iso8601($start_time);
416
		$opt['EndTime'] = $this->util->convert_date_to_iso8601($end_time);
417
 
418
		// Required list (non-map)
419
		$opt = array_merge($opt, CFComplexType::map(array(
420
			'Statistics' => (is_array($statistics) ? $statistics : array($statistics))
421
		), 'member'));
422
 
423
		// Optional list + map
424
		if (isset($opt['Dimensions']))
425
		{
426
			$opt = array_merge($opt, CFComplexType::map(array(
427
				'Dimensions' => $opt['Dimensions']
428
			), 'member'));
429
			unset($opt['Dimensions']);
430
		}
431
 
432
		return $this->authenticate('GetMetricStatistics', $opt);
433
	}
434
 
435
	/**
436
	 * Returns a list of valid metrics stored for the AWS account owner. Returned metrics can be used
437
	 * with <code>GetMetricStatistics</code> to obtain statistical data for a given metric.
438
	 *
439
	 * <p class="note">
440
	 * Up to 500 results are returned for any one call. To retrieve further results, use returned
441
	 * <code>NextToken</code> values with subsequent <code>ListMetrics</code> operations.
442
	 * </p>
443
	 * <p class="note">
444
	 * If you create a metric with the <code>PutMetricData</code> action, allow up to fifteen minutes
445
	 * for the metric to appear in calls to the <code>ListMetrics</code> action. Statistics about the
446
	 * metric, however, are available sooner using <code>GetMetricStatistics</code>.
447
	 * </p>
448
	 *
449
	 * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
450
	 * 	<li><code>Namespace</code> - <code>string</code> - Optional - The namespace to filter against. [Constraints: The value must be between 1 and 255 characters, and must match the following regular expression pattern: <code>[^:].*</code>]</li>
451
	 * 	<li><code>MetricName</code> - <code>string</code> - Optional - The name of the metric to filter against.</li>
452
	 * 	<li><code>Dimensions</code> - <code>array</code> - Optional - A list of dimensions to filter against. <ul>
453
	 * 		<li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
454
	 * 			<li><code>Name</code> - <code>string</code> - Required - The dimension name to be matched.</li>
455
	 * 			<li><code>Value</code> - <code>string</code> - Optional - The value of the dimension to be matched. <p class="note">Specifying a <code>Name</code> without specifying a <code>Value</code> returns all values associated with that <code>Name</code>.</p></li>
456
	 * 		</ul></li>
457
	 * 	</ul></li>
458
	 * 	<li><code>NextToken</code> - <code>string</code> - Optional - The token returned by a previous call to indicate that there is more data available.</li>
459
	 * 	<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>
460
	 * 	<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>
461
	 * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
462
	 */
463
	public function list_metrics($opt = null)
464
	{
465
		if (!$opt) $opt = array();
466
 
467
		// Optional list + map
468
		if (isset($opt['Dimensions']))
469
		{
470
			$opt = array_merge($opt, CFComplexType::map(array(
471
				'Dimensions' => $opt['Dimensions']
472
			), 'member'));
473
			unset($opt['Dimensions']);
474
		}
475
 
476
		return $this->authenticate('ListMetrics', $opt);
477
	}
478
 
479
	/**
480
	 * Creates or updates an alarm and associates it with the specified Amazon CloudWatch metric.
481
	 * Optionally, this operation can associate one or more Amazon Simple Notification Service
482
	 * resources with the alarm.
483
	 *
484
	 * When this operation creates an alarm, the alarm state is immediately set to
485
	 * <code>INSUFFICIENT_DATA</code>. The alarm is evaluated and its <code>StateValue</code> is set
486
	 * appropriately. Any actions associated with the <code>StateValue</code> is then executed.
487
	 *
488
	 * <p class="note">
489
	 * When updating an existing alarm, its <code>StateValue</code> is left unchanged.
490
	 * </p>
491
	 *
492
	 * @param string $alarm_name (Required) The descriptive name for the alarm. This name must be unique within the user's AWS account
493
	 * @param string $metric_name (Required) The name for the alarm's associated metric.
494
	 * @param string $namespace (Required) The namespace for the alarm's associated metric. [Constraints: The value must be between 1 and 255 characters, and must match the following regular expression pattern: <code>[^:].*</code>]
495
	 * @param string $statistic (Required) The statistic to apply to the alarm's associated metric. [Allowed values: <code>SampleCount</code>, <code>Average</code>, <code>Sum</code>, <code>Minimum</code>, <code>Maximum</code>]
496
	 * @param integer $period (Required) The period in seconds over which the specified statistic is applied.
497
	 * @param integer $evaluation_periods (Required) The number of periods over which data is compared to the specified threshold.
498
	 * @param double $threshold (Required) The value against which the specified statistic is compared.
499
	 * @param string $comparison_operator (Required) The arithmetic operation to use when comparing the specified <code>Statistic</code> and <code>Threshold</code>. The specified <code>Statistic</code> value is used as the first operand. [Allowed values: <code>GreaterThanOrEqualToThreshold</code>, <code>GreaterThanThreshold</code>, <code>LessThanThreshold</code>, <code>LessThanOrEqualToThreshold</code>]
500
	 * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
501
	 * 	<li><code>AlarmDescription</code> - <code>string</code> - Optional - The description for the alarm.</li>
502
	 * 	<li><code>ActionsEnabled</code> - <code>boolean</code> - Optional - Indicates whether or not actions should be executed during any changes to the alarm's state.</li>
503
	 * 	<li><code>OKActions</code> - <code>string|array</code> - Optional - The list of actions to execute when this alarm transitions into an <code>OK</code> state from any other state. Each action is specified as an Amazon Resource Number (ARN). Currently the only action supported is publishing to an Amazon SNS topic or an Amazon Auto Scaling policy. Pass a string for a single value, or an indexed array for multiple values.</li>
504
	 * 	<li><code>AlarmActions</code> - <code>string|array</code> - Optional - The list of actions to execute when this alarm transitions into an <code>ALARM</code> state from any other state. Each action is specified as an Amazon Resource Number (ARN). Currently the only action supported is publishing to an Amazon SNS topic or an Amazon Auto Scaling policy. Pass a string for a single value, or an indexed array for multiple values.</li>
505
	 * 	<li><code>InsufficientDataActions</code> - <code>string|array</code> - Optional - The list of actions to execute when this alarm transitions into an <code>INSUFFICIENT_DATA</code> state from any other state. Each action is specified as an Amazon Resource Number (ARN). Currently the only action supported is publishing to an Amazon SNS topic or an Amazon Auto Scaling policy. Pass a string for a single value, or an indexed array for multiple values.</li>
506
	 * 	<li><code>Dimensions</code> - <code>array</code> - Optional - The dimensions for the alarm's associated metric. <ul>
507
	 * 		<li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
508
	 * 			<li><code>Name</code> - <code>string</code> - Required - The name of the dimension.</li>
509
	 * 			<li><code>Value</code> - <code>string</code> - Required - The value representing the dimension measurement</li>
510
	 * 		</ul></li>
511
	 * 	</ul></li>
512
	 * 	<li><code>Unit</code> - <code>string</code> - Optional - The unit for the alarm's associated metric. [Allowed values: <code>Seconds</code>, <code>Microseconds</code>, <code>Milliseconds</code>, <code>Bytes</code>, <code>Kilobytes</code>, <code>Megabytes</code>, <code>Gigabytes</code>, <code>Terabytes</code>, <code>Bits</code>, <code>Kilobits</code>, <code>Megabits</code>, <code>Gigabits</code>, <code>Terabits</code>, <code>Percent</code>, <code>Count</code>, <code>Bytes/Second</code>, <code>Kilobytes/Second</code>, <code>Megabytes/Second</code>, <code>Gigabytes/Second</code>, <code>Terabytes/Second</code>, <code>Bits/Second</code>, <code>Kilobits/Second</code>, <code>Megabits/Second</code>, <code>Gigabits/Second</code>, <code>Terabits/Second</code>, <code>Count/Second</code>, <code>None</code>]</li>
513
	 * 	<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>
514
	 * 	<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>
515
	 * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
516
	 */
517
	public function put_metric_alarm($alarm_name, $metric_name, $namespace, $statistic, $period, $evaluation_periods, $threshold, $comparison_operator, $opt = null)
518
	{
519
		if (!$opt) $opt = array();
520
		$opt['AlarmName'] = $alarm_name;
521
		$opt['MetricName'] = $metric_name;
522
		$opt['Namespace'] = $namespace;
523
		$opt['Statistic'] = $statistic;
524
		$opt['Period'] = $period;
525
		$opt['EvaluationPeriods'] = $evaluation_periods;
526
		$opt['Threshold'] = $threshold;
527
		$opt['ComparisonOperator'] = $comparison_operator;
528
 
529
		// Optional list (non-map)
530
		if (isset($opt['OKActions']))
531
		{
532
			$opt = array_merge($opt, CFComplexType::map(array(
533
				'OKActions' => (is_array($opt['OKActions']) ? $opt['OKActions'] : array($opt['OKActions']))
534
			), 'member'));
535
			unset($opt['OKActions']);
536
		}
537
 
538
		// Optional list (non-map)
539
		if (isset($opt['AlarmActions']))
540
		{
541
			$opt = array_merge($opt, CFComplexType::map(array(
542
				'AlarmActions' => (is_array($opt['AlarmActions']) ? $opt['AlarmActions'] : array($opt['AlarmActions']))
543
			), 'member'));
544
			unset($opt['AlarmActions']);
545
		}
546
 
547
		// Optional list (non-map)
548
		if (isset($opt['InsufficientDataActions']))
549
		{
550
			$opt = array_merge($opt, CFComplexType::map(array(
551
				'InsufficientDataActions' => (is_array($opt['InsufficientDataActions']) ? $opt['InsufficientDataActions'] : array($opt['InsufficientDataActions']))
552
			), 'member'));
553
			unset($opt['InsufficientDataActions']);
554
		}
555
 
556
		// Optional list + map
557
		if (isset($opt['Dimensions']))
558
		{
559
			$opt = array_merge($opt, CFComplexType::map(array(
560
				'Dimensions' => $opt['Dimensions']
561
			), 'member'));
562
			unset($opt['Dimensions']);
563
		}
564
 
565
		return $this->authenticate('PutMetricAlarm', $opt);
566
	}
567
 
568
	/**
569
	 * Publishes metric data points to Amazon CloudWatch. Amazon Cloudwatch associates the data points
570
	 * with the specified metric. If the specified metric does not exist, Amazon CloudWatch creates
571
	 * the metric.
572
	 *
573
	 * <p class="note">
574
	 * If you create a metric with the <code>PutMetricData</code> action, allow up to fifteen minutes
575
	 * for the metric to appear in calls to the <code>ListMetrics</code> action.
576
	 * </p>
577
	 * The size of aPutMetricDatarequest is limited to 8 KB for HTTP GET requests and 40 KB for HTTP
578
	 * POST requests.
579
	 *
580
	 * <p class="important">
581
	 * Although the <code>Value</code> parameter accepts numbers of type <code>Double</code>, Amazon
582
	 * CloudWatch truncates values with very large exponents. Values with base-10 exponents greater
583
	 * than 126 (1 x 10^126) are truncated. Likewise, values with base-10 exponents less than -130 (1
584
	 * x 10^-130) are also truncated.
585
	 * </p>
586
	 *
587
	 * @param string $namespace (Required) The namespace for the metric data. <p class="note">You cannot specify a namespace that begins with "AWS/". Namespaces that begin with "AWS/" are reserved for other Amazon Web Services products that send metrics to Amazon CloudWatch.</p> [Constraints: The value must be between 1 and 255 characters, and must match the following regular expression pattern: <code>[^:].*</code>]
588
	 * @param array $metric_data (Required) A list of data describing the metric. <ul>
589
	 * 	<li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
590
	 * 		<li><code>MetricName</code> - <code>string</code> - Required - The name of the metric.</li>
591
	 * 		<li><code>Dimensions</code> - <code>array</code> - Optional - A list of dimensions associated with the metric. <ul>
592
	 * 			<li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
593
	 * 				<li><code>Name</code> - <code>string</code> - Required - The name of the dimension.</li>
594
	 * 				<li><code>Value</code> - <code>string</code> - Required - The value representing the dimension measurement</li>
595
	 * 			</ul></li>
596
	 * 		</ul></li>
597
	 * 		<li><code>Timestamp</code> - <code>string</code> - Optional - The time stamp used for the metric. If not specified, the default value is set to the time the metric data was received. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
598
	 * 		<li><code>Value</code> - <code>double</code> - Optional - The value for the metric. <p class="important">Although the <code>Value</code> parameter accepts numbers of type <code>Double</code>, Amazon CloudWatch truncates values with very large exponents. Values with base-10 exponents greater than 126 (1 x 10^126) are truncated. Likewise, values with base-10 exponents less than -130 (1 x 10^-130) are also truncated.</p></li>
599
	 * 		<li><code>StatisticValues</code> - <code>array</code> - Optional - A set of statistical values describing the metric. <ul>
600
	 * 			<li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
601
	 * 				<li><code>SampleCount</code> - <code>double</code> - Required - The number of samples used for the statistic set.</li>
602
	 * 				<li><code>Sum</code> - <code>double</code> - Required - The sum of values for the sample set.</li>
603
	 * 				<li><code>Minimum</code> - <code>double</code> - Required - The minimum value of the sample set.</li>
604
	 * 				<li><code>Maximum</code> - <code>double</code> - Required - The maximum value of the sample set.</li>
605
	 * 			</ul></li>
606
	 * 		</ul></li>
607
	 * 		<li><code>Unit</code> - <code>string</code> - Optional - The unit of the metric. [Allowed values: <code>Seconds</code>, <code>Microseconds</code>, <code>Milliseconds</code>, <code>Bytes</code>, <code>Kilobytes</code>, <code>Megabytes</code>, <code>Gigabytes</code>, <code>Terabytes</code>, <code>Bits</code>, <code>Kilobits</code>, <code>Megabits</code>, <code>Gigabits</code>, <code>Terabits</code>, <code>Percent</code>, <code>Count</code>, <code>Bytes/Second</code>, <code>Kilobytes/Second</code>, <code>Megabytes/Second</code>, <code>Gigabytes/Second</code>, <code>Terabytes/Second</code>, <code>Bits/Second</code>, <code>Kilobits/Second</code>, <code>Megabits/Second</code>, <code>Gigabits/Second</code>, <code>Terabits/Second</code>, <code>Count/Second</code>, <code>None</code>]</li>
608
	 * 	</ul></li>
609
	 * </ul>
610
	 * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
611
	 * 	<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>
612
	 * 	<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>
613
	 * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
614
	 */
615
	public function put_metric_data($namespace, $metric_data, $opt = null)
616
	{
617
		if (!$opt) $opt = array();
618
		$opt['Namespace'] = $namespace;
619
 
620
		// Handle Timestamps
621
		for ($i = 0, $max = count($metric_data); $i < $max; $i++)
622
		{
623
			if (isset($metric_data[$i]['Timestamp']))
624
			{
625
				$metric_data[$i]['Timestamp'] = $this->util->convert_date_to_iso8601($metric_data[$i]['Timestamp']);
626
			}
627
		}
628
 
629
		// Required parameter
630
		$opt = array_merge($opt, CFComplexType::map(array(
631
			'MetricData' => (is_array($metric_data) ? $metric_data : array($metric_data))
632
		), 'member'));
633
 
634
		return $this->authenticate('PutMetricData', $opt, $this->hostname);
635
	}
636
 
637
	/**
638
	 * Temporarily sets the state of an alarm. When the updated <code>StateValue</code> differs from
639
	 * the previous value, the action configured for the appropriate state is invoked. This is not a
640
	 * permanent change. The next periodic alarm check (in about a minute) will set the alarm to its
641
	 * actual state.
642
	 *
643
	 * @param string $alarm_name (Required) The descriptive name for the alarm. This name must be unique within the user's AWS account. The maximum length is 255 characters.
644
	 * @param string $state_value (Required) The value of the state. [Allowed values: <code>OK</code>, <code>ALARM</code>, <code>INSUFFICIENT_DATA</code>]
645
	 * @param string $state_reason (Required) The reason that this alarm is set to this specific state (in human-readable text format)
646
	 * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
647
	 * 	<li><code>StateReasonData</code> - <code>string</code> - Optional - The reason that this alarm is set to this specific state (in machine-readable JSON format)</li>
648
	 * 	<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>
649
	 * 	<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>
650
	 * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
651
	 */
652
	public function set_alarm_state($alarm_name, $state_value, $state_reason, $opt = null)
653
	{
654
		if (!$opt) $opt = array();
655
		$opt['AlarmName'] = $alarm_name;
656
		$opt['StateValue'] = $state_value;
657
		$opt['StateReason'] = $state_reason;
658
 
659
		return $this->authenticate('SetAlarmState', $opt);
660
	}
661
}
662
 
663
 
664
/*%******************************************************************************************%*/
665
// EXCEPTIONS
666
 
667
class CloudWatch_Exception extends Exception {}