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
 * AWS Import/Export accelerates transferring large amounts of data between the AWS cloud and
19
 * portable storage devices that you mail to us. AWS Import/Export transfers data directly onto
20
 * and off of your storage devices using Amazon's high-speed internal network and bypassing the
21
 * Internet. For large data sets, AWS Import/Export is often faster than Internet transfer and
22
 * more cost effective than upgrading your connectivity.
23
 *
24
 * @version 2012.01.16
25
 * @license See the included NOTICE.md file for complete information.
26
 * @copyright See the included NOTICE.md file for complete information.
27
 * @link http://aws.amazon.com/importexport/ AWS Import/Export
28
 * @link http://aws.amazon.com/importexport/documentation/ AWS Import/Export documentation
29
 */
30
class AmazonImportExport extends CFRuntime
31
{
32
	/*%******************************************************************************************%*/
33
	// CLASS CONSTANTS
34
 
35
	/**
36
	 * Specify the queue URL for the United States East (Northern Virginia) Region.
37
	 */
38
	const REGION_US_E1 = 'importexport.amazonaws.com';
39
 
40
	/**
41
	 * Specify the queue URL for the United States East (Northern Virginia) Region.
42
	 */
43
	const REGION_VIRGINIA = self::REGION_US_E1;
44
 
45
	/**
46
	 * Default service endpoint.
47
	 */
48
	const DEFAULT_URL = self::REGION_US_E1;
49
 
50
 
51
	/*%******************************************************************************************%*/
52
	// CONSTRUCTOR
53
 
54
	/**
55
	 * Constructs a new instance of <AmazonImportExport>.
56
	 *
57
	 * @param array $options (Optional) An associative array of parameters that can have the following keys: <ul>
58
	 * 	<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>
59
	 * 	<li><code>credentials</code> - <code>string</code> - Optional - The name of the credential set to use for authentication.</li>
60
	 * 	<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>
61
	 * 	<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>
62
	 * 	<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>
63
	 * 	<li><code>token</code> - <code>string</code> - Optional - An AWS session token.</li></ul>
64
	 * @return void
65
	 */
66
	public function __construct(array $options = array())
67
	{
68
		$this->api_version = '2010-06-01';
69
		$this->hostname = self::DEFAULT_URL;
70
		$this->auth_class = 'AuthV2Query';
71
 
72
		return parent::__construct($options);
73
	}
74
 
75
 
76
	/*%******************************************************************************************%*/
77
	// SETTERS
78
 
79
	/**
80
	 * This allows you to explicitly sets the region for the service to use.
81
	 *
82
	 * @param string $region (Required) The region to explicitly set. Available options are <REGION_US_E1>.
83
	 * @return $this A reference to the current instance.
84
	 */
85
	public function set_region($region)
86
	{
87
		// @codeCoverageIgnoreStart
88
		$this->set_hostname($region);
89
		return $this;
90
		// @codeCoverageIgnoreEnd
91
	}
92
 
93
 
94
	/*%******************************************************************************************%*/
95
	// SERVICE METHODS
96
 
97
	/**
98
	 * This operation cancels a specified job. Only the job owner can cancel it. The operation fails
99
	 * if the job has already started or is complete.
100
	 *
101
	 * @param string $job_id (Required) A unique identifier which refers to a particular job.
102
	 * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
103
	 * 	<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>
104
	 * 	<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>
105
	 * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
106
	 */
107
	public function cancel_job($job_id, $opt = null)
108
	{
109
		if (!$opt) $opt = array();
110
		$opt['JobId'] = $job_id;
111
 
112
		return $this->authenticate('CancelJob', $opt);
113
	}
114
 
115
	/**
116
	 * This operation initiates the process of scheduling an upload or download of your data. You
117
	 * include in the request a manifest that describes the data transfer specifics. The response to
118
	 * the request includes a job ID, which you can use in other operations, a signature that you use
119
	 * to identify your storage device, and the address where you should ship your storage device.
120
	 *
121
	 * @param string $job_type (Required) Specifies whether the job to initiate is an import or export job. [Allowed values: <code>Import</code>, <code>Export</code>]
122
	 * @param string $manifest (Required) The UTF-8 encoded text of the manifest file.
123
	 * @param boolean $validate_only (Required) Validate the manifest and parameter values in the request but do not actually create a job.
124
	 * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
125
	 * 	<li><code>ManifestAddendum</code> - <code>string</code> - Optional - For internal use only.</li>
126
	 * 	<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>
127
	 * 	<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>
128
	 * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
129
	 */
130
	public function create_job($job_type, $manifest, $validate_only, $opt = null)
131
	{
132
		if (!$opt) $opt = array();
133
		$opt['JobType'] = $job_type;
134
		$opt['Manifest'] = $manifest;
135
		$opt['ValidateOnly'] = $validate_only;
136
 
137
		return $this->authenticate('CreateJob', $opt);
138
	}
139
 
140
	/**
141
	 * This operation returns information about a job, including where the job is in the processing
142
	 * pipeline, the status of the results, and the signature value associated with the job. You can
143
	 * only return information about jobs you own.
144
	 *
145
	 * @param string $job_id (Required) A unique identifier which refers to a particular job.
146
	 * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
147
	 * 	<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>
148
	 * 	<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>
149
	 * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
150
	 */
151
	public function get_status($job_id, $opt = null)
152
	{
153
		if (!$opt) $opt = array();
154
		$opt['JobId'] = $job_id;
155
 
156
		return $this->authenticate('GetStatus', $opt);
157
	}
158
 
159
	/**
160
	 * This operation returns the jobs associated with the requester. AWS Import/Export lists the jobs
161
	 * in reverse chronological order based on the date of creation. For example if Job Test1 was
162
	 * created 2009Dec30 and Test2 was created 2010Feb05, the ListJobs operation would return Test2
163
	 * followed by Test1.
164
	 *
165
	 * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
166
	 * 	<li><code>MaxJobs</code> - <code>integer</code> - Optional - Sets the maximum number of jobs returned in the response. If there are additional jobs that were not returned because MaxJobs was exceeded, the response contains<IsTruncated>true</IsTruncated>. To return the additional jobs, see Marker.</li>
167
	 * 	<li><code>Marker</code> - <code>string</code> - Optional - Specifies the JOBID to start after when listing the jobs created with your account. AWS Import/Export lists your jobs in reverse chronological order. See MaxJobs.</li>
168
	 * 	<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>
169
	 * 	<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>
170
	 * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
171
	 */
172
	public function list_jobs($opt = null)
173
	{
174
		if (!$opt) $opt = array();
175
 
176
		return $this->authenticate('ListJobs', $opt);
177
	}
178
 
179
	/**
180
	 * You use this operation to change the parameters specified in the original manifest file by
181
	 * supplying a new manifest file. The manifest file attached to this request replaces the original
182
	 * manifest file. You can only use the operation after a CreateJob request but before the data
183
	 * transfer starts and you can only use it on jobs you own.
184
	 *
185
	 * @param string $job_id (Required) A unique identifier which refers to a particular job.
186
	 * @param string $manifest (Required) The UTF-8 encoded text of the manifest file.
187
	 * @param string $job_type (Required) Specifies whether the job to initiate is an import or export job. [Allowed values: <code>Import</code>, <code>Export</code>]
188
	 * @param boolean $validate_only (Required) Validate the manifest and parameter values in the request but do not actually create a job.
189
	 * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
190
	 * 	<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>
191
	 * 	<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>
192
	 * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
193
	 */
194
	public function update_job($job_id, $manifest, $job_type, $validate_only, $opt = null)
195
	{
196
		if (!$opt) $opt = array();
197
		$opt['JobId'] = $job_id;
198
		$opt['Manifest'] = $manifest;
199
		$opt['JobType'] = $job_type;
200
		$opt['ValidateOnly'] = $validate_only;
201
 
202
		return $this->authenticate('UpdateJob', $opt);
203
	}
204
}
205
 
206
 
207
/*%******************************************************************************************%*/
208
// EXCEPTIONS
209
 
210
class ImportExport_Exception extends Exception {}