PageRenderTime 33ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/extensions/OpenStackManager/aws-sdk/services/importexport.class.php

https://github.com/ChuguluGames/mediawiki-svn
PHP | 197 lines | 54 code | 25 blank | 118 comment | 9 complexity | 31dde615f593205974e0bd1afdef04bc MD5 | raw file
  1. <?php
  2. /*
  3. * Copyright 2010-2011 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. *
  19. * AWS Import/Export accelerates transferring large amounts of data between the AWS cloud and portable storage devices that you mail to us.
  20. * AWS Import/Export transfers data directly onto 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 more cost effective than upgrading your
  22. * connectivity.
  23. *
  24. * @version Tue Aug 23 12:50:02 PDT 2011
  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/Amazon Import/Export Service
  28. * @link http://aws.amazon.com/documentation/importexport/Amazon Import/Export Service documentation
  29. */
  30. class AmazonImportExport extends CFRuntime
  31. {
  32. /*%******************************************************************************************%*/
  33. // CLASS CONSTANTS
  34. /**
  35. * Specify the default queue URL.
  36. */
  37. const DEFAULT_URL = 'importexport.amazonaws.com';
  38. /*%******************************************************************************************%*/
  39. // CONSTRUCTOR
  40. /**
  41. * Constructs a new instance of <AmazonImportExport>.
  42. *
  43. * @param string $key (Optional) Your Amazon API Key. If blank, it will look for the <code>AWS_KEY</code> constant.
  44. * @param string $secret_key (Optional) Your Amazon API Secret Key. If blank, it will look for the <code>AWS_SECRET_KEY</code> constant.
  45. * @return boolean false if no valid values are set, otherwise true.
  46. */
  47. public function __construct($key = null, $secret_key = null)
  48. {
  49. $this->api_version = '2010-06-01';
  50. $this->hostname = self::DEFAULT_URL;
  51. if (!$key && !defined('AWS_KEY'))
  52. {
  53. // @codeCoverageIgnoreStart
  54. throw new ImportExport_Exception('No account key was passed into the constructor, nor was it set in the AWS_KEY constant.');
  55. // @codeCoverageIgnoreEnd
  56. }
  57. if (!$secret_key && !defined('AWS_SECRET_KEY'))
  58. {
  59. // @codeCoverageIgnoreStart
  60. throw new ImportExport_Exception('No account secret was passed into the constructor, nor was it set in the AWS_SECRET_KEY constant.');
  61. // @codeCoverageIgnoreEnd
  62. }
  63. return parent::__construct($key, $secret_key);
  64. }
  65. /*%******************************************************************************************%*/
  66. // SERVICE METHODS
  67. /**
  68. *
  69. * This operation initiates the process of scheduling an upload or download of your data. You include in the request a manifest that describes
  70. * the data transfer specifics. The response to the request includes a job ID, which you can use in other operations, a signature that you use
  71. * to identify your storage device, and the address where you should ship your storage device.
  72. *
  73. * @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>]
  74. * @param string $manifest (Required) The UTF-8 encoded text of the manifest file.
  75. * @param boolean $validate_only (Required) Validate the manifest and parameter values in the request but do not actually create a job.
  76. * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
  77. * <li><code>ManifestAddendum</code> - <code>string</code> - Optional - For internal use only. </li>
  78. * <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>
  79. * <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>
  80. * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
  81. */
  82. public function create_job($job_type, $manifest, $validate_only, $opt = null)
  83. {
  84. if (!$opt) $opt = array();
  85. $opt['JobType'] = $job_type;
  86. $opt['Manifest'] = $manifest;
  87. $opt['ValidateOnly'] = $validate_only;
  88. return $this->authenticate('CreateJob', $opt, $this->hostname);
  89. }
  90. /**
  91. *
  92. * This operation cancels a specified job. Only the job owner can cancel it. The operation fails if the job has already started or is
  93. * complete.
  94. *
  95. * @param string $job_id (Required) A unique identifier which refers to a particular job.
  96. * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
  97. * <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>
  98. * <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>
  99. * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
  100. */
  101. public function cancel_job($job_id, $opt = null)
  102. {
  103. if (!$opt) $opt = array();
  104. $opt['JobId'] = $job_id;
  105. return $this->authenticate('CancelJob', $opt, $this->hostname);
  106. }
  107. /**
  108. *
  109. * This operation returns information about a job, including where the job is in the processing pipeline, the status of the results, and the
  110. * signature value associated with the job. You can only return information about jobs you own.
  111. *
  112. * @param string $job_id (Required) A unique identifier which refers to a particular job.
  113. * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
  114. * <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>
  115. * <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>
  116. * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
  117. */
  118. public function get_status($job_id, $opt = null)
  119. {
  120. if (!$opt) $opt = array();
  121. $opt['JobId'] = $job_id;
  122. return $this->authenticate('GetStatus', $opt, $this->hostname);
  123. }
  124. /**
  125. *
  126. * This operation returns the jobs associated with the requester. AWS Import/Export lists the jobs in reverse chronological order based on the
  127. * date of creation. For example if Job Test1 was created 2009Dec30 and Test2 was created 2010Feb05, the ListJobs operation would return Test2
  128. * followed by Test1.
  129. *
  130. * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
  131. * <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>
  132. * <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>
  133. * <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>
  134. * <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>
  135. * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
  136. */
  137. public function list_jobs($opt = null)
  138. {
  139. if (!$opt) $opt = array();
  140. return $this->authenticate('ListJobs', $opt, $this->hostname);
  141. }
  142. /**
  143. *
  144. * You use this operation to change the parameters specified in the original manifest file by supplying a new manifest file. The manifest file
  145. * attached to this request replaces the original manifest file. You can only use the operation after a CreateJob request but before the data
  146. * transfer starts and you can only use it on jobs you own.
  147. *
  148. * @param string $job_id (Required) A unique identifier which refers to a particular job.
  149. * @param string $manifest (Required) The UTF-8 encoded text of the manifest file.
  150. * @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>]
  151. * @param boolean $validate_only (Required) Validate the manifest and parameter values in the request but do not actually create a job.
  152. * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
  153. * <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>
  154. * <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>
  155. * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
  156. */
  157. public function update_job($job_id, $manifest, $job_type, $validate_only, $opt = null)
  158. {
  159. if (!$opt) $opt = array();
  160. $opt['JobId'] = $job_id;
  161. $opt['Manifest'] = $manifest;
  162. $opt['JobType'] = $job_type;
  163. $opt['ValidateOnly'] = $validate_only;
  164. return $this->authenticate('UpdateJob', $opt, $this->hostname);
  165. }
  166. }
  167. /*%******************************************************************************************%*/
  168. // EXCEPTIONS
  169. /**
  170. * Default ImportExport Exception.
  171. */
  172. class ImportExport_Exception extends Exception {}