Version Description
- use AWS SDK ver.1.2.4 now for Amazon S3
- Update rackspase cloud files to ver.1.7.6
- Added Job setteing import/export
- Download link for last backup in Jobs tab
- Link for last Log in Jobs tab
- Logs can now compressed
- Backup destinations can now be disabled (see help)
- Bug fixes and improvements
Download this release
Release Info
Developer | danielhuesken |
Plugin | BackWPup – WordPress Backup Plugin |
Version | 1.5.0 |
Comparing to | |
See all releases |
Code changes from version 1.4.1 to 1.5.0
- app/backwpup_dojob.php +193 -160
- app/compatibility/class-wp-list-table.php +3 -9
- app/css/options.css +1 -1
- app/functions.php +13 -6
- app/functions5.php +28 -27
- app/libs/S3.php +0 -1377
- app/libs/aws/lib/cachecore/LICENSE +25 -0
- app/libs/aws/lib/cachecore/README +1 -0
- app/libs/aws/lib/cachecore/_sql/README +5 -0
- app/libs/aws/lib/cachecore/_sql/mysql.sql +7 -0
- app/libs/aws/lib/cachecore/_sql/pgsql.sql +6 -0
- app/libs/aws/lib/cachecore/_sql/sqlite3.sql +2 -0
- app/libs/aws/lib/cachecore/cacheapc.class.php +119 -0
- app/libs/aws/lib/cachecore/cachecore.class.php +141 -0
- app/libs/aws/lib/cachecore/cachefile.class.php +170 -0
- app/libs/aws/lib/cachecore/cachemc.class.php +176 -0
- app/libs/aws/lib/cachecore/cachepdo.class.php +290 -0
- app/libs/aws/lib/cachecore/cachexcache.class.php +122 -0
- app/libs/aws/lib/cachecore/icachecore.interface.php +66 -0
- app/libs/aws/lib/requestcore/LICENSE +25 -0
- app/libs/aws/lib/requestcore/README.md +15 -0
- app/libs/aws/lib/requestcore/requestcore.class.php +910 -0
- app/libs/aws/lib/yaml/LICENSE +19 -0
- app/libs/aws/lib/yaml/README.markdown +15 -0
- app/libs/aws/lib/yaml/lib/sfYaml.php +135 -0
- app/libs/aws/lib/yaml/lib/sfYamlDumper.php +60 -0
- app/libs/aws/lib/yaml/lib/sfYamlInline.php +442 -0
- app/libs/aws/lib/yaml/lib/sfYamlParser.php +612 -0
- app/libs/aws/sdk.class.php +1192 -0
- app/libs/aws/services/as.class.php +901 -0
- app/libs/aws/services/cloudfront.class.php +1391 -0
- app/libs/aws/services/cloudwatch.class.php +497 -0
- app/libs/aws/services/ec2.class.php +3108 -0
- app/libs/aws/services/elasticbeanstalk.class.php +955 -0
- app/libs/aws/services/elb.class.php +605 -0
- app/libs/aws/services/emr.class.php +415 -0
- app/libs/aws/services/iam.class.php +1155 -0
- app/libs/aws/services/importexport.class.php +189 -0
- app/libs/aws/services/rds.class.php +831 -0
- app/libs/aws/services/s3.class.php +3309 -0
- app/libs/aws/services/sdb.class.php +625 -0
app/backwpup_dojob.php
CHANGED
@@ -17,6 +17,7 @@ class backwpup_dojob {
|
|
17 |
private $backupfile='';
|
18 |
private $backupfileformat='.zip';
|
19 |
private $backupdir='';
|
|
|
20 |
public $logdir='';
|
21 |
public $logfile='';
|
22 |
private $tempdir='';
|
@@ -31,7 +32,6 @@ class backwpup_dojob {
|
|
31 |
$this->jobid=$jobid; //set job id
|
32 |
$this->cfg=get_option('backwpup'); //load config
|
33 |
$jobs=get_option('backwpup_jobs'); //load jobdata
|
34 |
-
$this->job=backwpup_check_job_vars($jobs[$this->jobid],$this->jobid);//Set and check job settings
|
35 |
//set Logs Dir
|
36 |
$this->logdir=trailingslashit($this->cfg['dirlogs']);
|
37 |
if (empty($this->logdir) or $this->logdir=='/') {
|
@@ -41,25 +41,28 @@ class backwpup_dojob {
|
|
41 |
//Check log file dir
|
42 |
if (!$this->_check_folders($this->logdir))
|
43 |
return false;
|
|
|
|
|
|
|
44 |
//set Log file name
|
45 |
$this->logfile='backwpup_log_'.date_i18n('Y-m-d_H-i-s').'.html';
|
46 |
//create log file
|
47 |
-
$fd=fopen($this->logdir.$this->logfile,'w
|
48 |
//Create log file header
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
//set function for PHP user defineid error handling
|
64 |
if (defined(WP_DEBUG) and WP_DEBUG)
|
65 |
set_error_handler(array($this,'joberrorhandler'),E_ALL | E_STRICT);
|
@@ -70,25 +73,25 @@ class backwpup_dojob {
|
|
70 |
if ($jobs[$this->jobid]['starttime']+600<current_time('timestamp')) { //Abort old jo if work longer as 10 min. because websever has 300 sec timeout
|
71 |
trigger_error(__('Working Job will closed!!! And a new started!!!','backwpup'),E_USER_WARNING);
|
72 |
//old logfile end
|
73 |
-
$fd=fopen($jobs[$this->jobid]['logfile'],'a
|
74 |
-
|
75 |
-
fputs($fd,"</body>\n</html>\n");
|
76 |
fclose($fd);
|
77 |
$logheader=backwpup_read_logheader($jobs[$this->jobid]['logfile']); //read waring count from log header
|
78 |
$logheader['errors']++;
|
79 |
//write new log header
|
80 |
-
$fd
|
81 |
while (!feof($fd)) {
|
82 |
-
if (stripos(
|
83 |
-
|
84 |
-
|
85 |
break;
|
86 |
}
|
87 |
$filepos=ftell($fd);
|
88 |
}
|
89 |
-
|
|
|
90 |
} else {
|
91 |
-
trigger_error(sprintf(__('Job %1$s already running!!!','backwpup'),$this->
|
92 |
return false;
|
93 |
}
|
94 |
}
|
@@ -96,7 +99,11 @@ class backwpup_dojob {
|
|
96 |
$jobs[$this->jobid]['starttime']=current_time('timestamp'); //set start time for job
|
97 |
$jobs[$this->jobid]['logfile']=$this->logdir.$this->logfile; //Set current logfile
|
98 |
$jobs[$this->jobid]['cronnextrun']=backwpup_cron_next($jobs[$this->jobid]['cron']); //set next run
|
|
|
|
|
|
|
99 |
update_option('backwpup_jobs',$jobs); //Save job Settings
|
|
|
100 |
//set waht to do
|
101 |
$this->todo=explode('+',$this->job['type']);
|
102 |
//set Backup File format
|
@@ -146,12 +153,18 @@ class backwpup_dojob {
|
|
146 |
elseif ($this->backupfileformat==".tar.gz" or $this->backupfileformat==".tar.bz2" or $this->backupfileformat==".tar")
|
147 |
$this->tar_pack_files();
|
148 |
}
|
|
|
149 |
if (is_file($this->backupdir.$this->backupfile)) { // Put backup file to destination
|
|
|
150 |
$this->destination_mail();
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
|
|
|
|
|
|
155 |
$this->destination_dir();
|
156 |
}
|
157 |
|
@@ -166,7 +179,33 @@ class backwpup_dojob {
|
|
166 |
}
|
167 |
}
|
168 |
|
169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
}
|
171 |
|
172 |
//function for PHP error handling
|
@@ -214,9 +253,9 @@ class backwpup_dojob {
|
|
214 |
|
215 |
if (!empty($massage)) {
|
216 |
//wirte log file
|
217 |
-
$fd=fopen($this->logdir.$this->logfile,'a
|
218 |
-
|
219 |
-
|
220 |
|
221 |
//output on run now
|
222 |
if (!defined('DOING_CRON')) {
|
@@ -227,30 +266,26 @@ class backwpup_dojob {
|
|
227 |
|
228 |
//write new log header
|
229 |
if (isset($errors) or isset($warnings)) {
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
}
|
243 |
-
$filepos=ftell($fd);
|
244 |
}
|
245 |
-
|
246 |
}
|
|
|
247 |
}
|
248 |
|
249 |
if ($args[0]==E_ERROR or $args[0]==E_CORE_ERROR or $args[0]==E_COMPILE_ERROR) {//Die on fatal php errors.
|
250 |
-
|
251 |
-
fputs($fd,"</body>\n</html>\n");
|
252 |
-
fclose($fd);
|
253 |
-
}
|
254 |
die();
|
255 |
}
|
256 |
//300 is most webserver time limit. 0= max time! Give script 5 min. more to work.
|
@@ -355,7 +390,7 @@ class backwpup_dojob {
|
|
355 |
update_option('plugin_maintenance-mode',$mamo);
|
356 |
} else { //WP Support
|
357 |
$fdmain=fopen(trailingslashit(ABSPATH).'.maintenance','w');
|
358 |
-
|
359 |
fclose($fdmain);
|
360 |
}
|
361 |
} else {
|
@@ -505,7 +540,7 @@ class backwpup_dojob {
|
|
505 |
$status[$statusdata['Name']]=$statusdata;
|
506 |
}
|
507 |
|
508 |
-
if ($file =
|
509 |
fwrite($file, "-- ---------------------------------------------------------\n");
|
510 |
fwrite($file, "-- Dump with BackWPup ver.: ".BACKWPUP_VERSION."\n");
|
511 |
fwrite($file, "-- Plugin for WordPress by Daniel Huesken\n");
|
@@ -580,14 +615,14 @@ class backwpup_dojob {
|
|
580 |
if (!$return) {
|
581 |
trigger_error(__('cURL:','backwpup').' '.curl_error($ch),E_USER_ERROR);
|
582 |
} else {
|
583 |
-
$fd=fopen($this->tempdir.'wordpress.' . date( 'Y-m-d' ) . '.xml',"w+");
|
584 |
fwrite($fd,$return);
|
585 |
fclose($fd);
|
586 |
}
|
587 |
curl_close($ch);
|
588 |
} elseif (ini_get('allow_url_fopen')==true or ini_get('allow_url_fopen')==1 or strtolower(ini_get('allow_url_fopen'))=="on") {
|
589 |
trigger_error(__('Run Wordpress Export to XML file...','backwpup'),E_USER_NOTICE);
|
590 |
-
if (copy(plugins_url('wp_xml_export.php',__FILE__).'?wpabs='.trailingslashit(ABSPATH).'&_nonce='.substr(md5(md5(SECURE_AUTH_KEY)),10,10),$this->tempdir.'wordpress.' . date( 'Y-m-d' ) . '.xml')) {
|
591 |
trigger_error(__('Export to XML done!','backwpup'),E_USER_NOTICE);
|
592 |
} else {
|
593 |
trigger_error(__('Can not Export to XML!','backwpup'),E_USER_ERROR);
|
@@ -595,11 +630,11 @@ class backwpup_dojob {
|
|
595 |
} else {
|
596 |
trigger_error(__('Can not Export to XML! no cURL or allow_url_fopen Support!','backwpup'),E_USER_WARNING);
|
597 |
}
|
598 |
-
if (is_readable($this->tempdir.'wordpress.' . date( 'Y-m-d' ) . '.xml')) {
|
599 |
//add database file to backupfiles
|
600 |
-
trigger_error(__('Add XML Export to Backup:','backwpup').' wordpress.' . date( 'Y-m-d' ) . '.xml '.backwpup_formatBytes(filesize($this->tempdir.'wordpress.' . date( 'Y-m-d' ) . '.xml')),E_USER_NOTICE);
|
601 |
-
$this->allfilesize+=filesize($this->tempdir.'wordpress.' . date( 'Y-m-d' ) . '.xml');
|
602 |
-
$this->filelist[]=array(79001=>$this->tempdir.'wordpress.' . date( 'Y-m-d' ) . '.xml',79003=>'wordpress.' . date( 'Y-m-d' ) . '.xml');
|
603 |
}
|
604 |
}
|
605 |
|
@@ -1067,50 +1102,62 @@ class backwpup_dojob {
|
|
1067 |
if (empty($this->job['awsAccessKey']) or empty($this->job['awsSecretKey']) or empty($this->job['awsBucket']))
|
1068 |
return;
|
1069 |
|
1070 |
-
if (!(extension_loaded('curl') or @dl(PHP_SHLIB_SUFFIX == 'so' ? 'curl.so' : 'php_curl.dll'))) {
|
1071 |
-
trigger_error(__('Can not load curl extension is needed for S3!','backwpup'),E_USER_ERROR);
|
1072 |
-
return;
|
1073 |
-
}
|
1074 |
|
1075 |
-
if (!class_exists('
|
1076 |
-
require_once(dirname(__FILE__).'/libs/
|
1077 |
-
|
1078 |
-
|
|
|
1079 |
|
1080 |
-
|
1081 |
-
|
1082 |
-
//Transfer Backup to S3
|
1083 |
-
if ($s3->putObjectFile($this->backupdir.$this->backupfile, $this->job['awsBucket'], $this->job['awsdir'].$this->backupfile, S3::ACL_PRIVATE,array(),null,$this->job['awsrrs'])) //transfere file to S3
|
1084 |
-
trigger_error(__('Backup File transferred to S3://','backwpup').$this->job['awsBucket'].'/'.$this->job['awsdir'].$this->backupfile,E_USER_NOTICE);
|
1085 |
-
else
|
1086 |
-
trigger_error(__('Can not transfer backup to S3.','backwpup'),E_USER_ERROR);
|
1087 |
|
1088 |
-
|
1089 |
-
$
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1096 |
}
|
1097 |
}
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
|
|
|
|
1107 |
}
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
|
|
|
|
|
|
1111 |
}
|
1112 |
-
}
|
1113 |
-
trigger_error(__('S3
|
|
|
1114 |
}
|
1115 |
}
|
1116 |
|
@@ -1165,11 +1212,12 @@ class backwpup_dojob {
|
|
1165 |
// $backwpupcontainer->create_paths($this->job['rscdir']);
|
1166 |
$backwpupbackup = $backwpupcontainer->create_object($this->job['rscdir'].$this->backupfile);
|
1167 |
|
1168 |
-
if ($backwpupbackup->load_from_filename($this->backupdir.$this->backupfile))
|
1169 |
trigger_error(__('Backup File transferred to RSC://','backwpup').$this->job['rscContainer'].'/'.$this->job['rscdir'].$this->backupfile,E_USER_NOTICE);
|
1170 |
-
|
|
|
1171 |
trigger_error(__('Can not transfer backup to RSC.','backwpup'),E_USER_ERROR);
|
1172 |
-
|
1173 |
|
1174 |
if ($this->job['rscmaxbackups']>0) { //Delete old backups
|
1175 |
$backupfilelist=array();
|
@@ -1205,6 +1253,7 @@ class backwpup_dojob {
|
|
1205 |
private function destination_dir() {
|
1206 |
if (empty($this->job['backupdir'])) //Go back if no destination dir
|
1207 |
return;
|
|
|
1208 |
//Delete old Backupfiles
|
1209 |
$backupfilelist=array();
|
1210 |
if (!empty($this->job['maxbackups'])) {
|
@@ -1240,95 +1289,79 @@ class backwpup_dojob {
|
|
1240 |
if (!class_exists('DropboxUploader'))
|
1241 |
try {
|
1242 |
require_once (dirname(__FILE__).'/libs/DropboxUploader.php');
|
|
|
1243 |
$uploader = new DropboxUploader($this->job['dropemail'], base64_decode($this->job['dropepass']));
|
1244 |
$uploader->upload($this->backupdir.$this->backupfile,$this->job['dropedir']);
|
|
|
1245 |
} catch (Exception $e) {
|
1246 |
trigger_error(__('DropBox:','backwpup').' '.__($e->getMessage(),'backwpup'),E_USER_ERROR);
|
1247 |
}
|
1248 |
}
|
1249 |
|
1250 |
-
private function job_end() {
|
|
|
|
|
|
|
|
|
|
|
1251 |
|
1252 |
-
|
1253 |
-
|
|
|
1254 |
|
1255 |
-
//delete
|
1256 |
-
|
1257 |
-
if ( $dir = @opendir($this->logdir) ) { //make file list
|
1258 |
-
while (($file = readdir($dir)) !== false ) {
|
1259 |
-
if ('backwpup_log_' == substr($file,0,strlen('backwpup_log_')) and ".html" == substr($file,-5))
|
1260 |
-
$logfilelist[]=$file;
|
1261 |
-
}
|
1262 |
-
@closedir( $dir );
|
1263 |
-
}
|
1264 |
-
if (sizeof($logfilelist)>0) {
|
1265 |
-
rsort($logfilelist);
|
1266 |
-
$numdeltefiles=0;
|
1267 |
-
for ($i=$this->cfg['maxlogs'];$i<sizeof($logfilelist);$i++) {
|
1268 |
-
unlink($this->logdir.$logfilelist[$i]);
|
1269 |
-
$numdeltefiles++;
|
1270 |
-
}
|
1271 |
-
if ($numdeltefiles>0)
|
1272 |
-
trigger_error($numdeltefiles.' '.__('old Log files deleted!!!','backwpup'),E_USER_NOTICE);
|
1273 |
-
}
|
1274 |
}
|
1275 |
-
|
1276 |
-
$jobs=get_option('backwpup_jobs');
|
1277 |
$jobs[$this->jobid]['lastrun']=$jobs[$this->jobid]['starttime'];
|
1278 |
$jobs[$this->jobid]['lastruntime']=current_time('timestamp')-$jobs[$this->jobid]['starttime'];
|
1279 |
$jobs[$this->jobid]['logfile']='';
|
1280 |
$jobs[$this->jobid]['starttime']='';
|
|
|
1281 |
update_option('backwpup_jobs',$jobs); //Save Settings
|
1282 |
$this->job['lastrun']=$jobs[$this->jobid]['lastrun'];
|
1283 |
$this->job['lastruntime']=$jobs[$this->jobid]['lastruntime'];
|
1284 |
-
|
1285 |
-
|
1286 |
-
}
|
1287 |
-
|
1288 |
-
public function __destruct() {
|
1289 |
-
|
1290 |
-
if (!($filesize=@filesize($this->backupdir.$this->backupfile))) //Set the filezie corectly
|
1291 |
-
$filesize=0;
|
1292 |
-
|
1293 |
-
//clean up
|
1294 |
-
if (is_file($this->tempdir.DB_NAME.'.sql') ) { //delete sql temp file
|
1295 |
-
unlink($this->tempdir.DB_NAME.'.sql');
|
1296 |
-
}
|
1297 |
-
|
1298 |
-
if (is_file($this->tempdir.'wordpress.' . date( 'Y-m-d' ) . '.xml') ) { //delete WP XML Export temp file
|
1299 |
-
unlink($this->tempdir.'wordpress.' . date( 'Y-m-d' ) . '.xml');
|
1300 |
-
}
|
1301 |
-
|
1302 |
-
if (empty($this->job['backupdir']) and is_file($this->backupdir.$this->backupfile)) { //delete backup file in temp dir
|
1303 |
-
unlink($this->backupdir.$this->backupfile);
|
1304 |
-
}
|
1305 |
-
|
1306 |
//write heder info
|
1307 |
-
$fd
|
1308 |
$found=0;
|
1309 |
while (!feof($fd)) {
|
1310 |
-
$line
|
1311 |
if (stripos($line,"<meta name=\"backwpup_jobruntime\"") !== false) {
|
1312 |
-
|
1313 |
-
|
1314 |
$found++;
|
1315 |
}
|
1316 |
if (stripos($line,"<meta name=\"backwpup_backupfilesize\"") !== false) {
|
1317 |
-
|
1318 |
-
|
1319 |
$found++;
|
1320 |
}
|
1321 |
if ($found>=2)
|
1322 |
break;
|
1323 |
$filepos=ftell($fd);
|
1324 |
}
|
1325 |
-
|
1326 |
//logfile end
|
1327 |
-
$fd=fopen($
|
1328 |
-
|
1329 |
fclose($fd);
|
1330 |
-
|
1331 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1332 |
//Send mail with log
|
1333 |
$sendmail=false;
|
1334 |
if ($logdata['errors']>0 and $this->job['mailerroronly'] and !empty($this->job['mailaddresslog']))
|
@@ -1371,12 +1404,12 @@ class backwpup_dojob {
|
|
1371 |
$phpmailer->From = $this->cfg['mailsndemail'];
|
1372 |
$phpmailer->FromName = $this->cfg['mailsndname'];
|
1373 |
$phpmailer->AddAddress($this->job['mailaddresslog']);
|
1374 |
-
$phpmailer->Subject = __('BackWPup
|
1375 |
$phpmailer->IsHTML(false);
|
1376 |
$phpmailer->Body = $mailbody;
|
1377 |
-
$phpmailer->AddAttachment($
|
1378 |
$phpmailer->Send();
|
1379 |
-
}
|
1380 |
}
|
1381 |
}
|
1382 |
?>
|
17 |
private $backupfile='';
|
18 |
private $backupfileformat='.zip';
|
19 |
private $backupdir='';
|
20 |
+
private $lastbackupdownloadurl='';
|
21 |
public $logdir='';
|
22 |
public $logfile='';
|
23 |
private $tempdir='';
|
32 |
$this->jobid=$jobid; //set job id
|
33 |
$this->cfg=get_option('backwpup'); //load config
|
34 |
$jobs=get_option('backwpup_jobs'); //load jobdata
|
|
|
35 |
//set Logs Dir
|
36 |
$this->logdir=trailingslashit($this->cfg['dirlogs']);
|
37 |
if (empty($this->logdir) or $this->logdir=='/') {
|
41 |
//Check log file dir
|
42 |
if (!$this->_check_folders($this->logdir))
|
43 |
return false;
|
44 |
+
//check exists gzip functions
|
45 |
+
if(!function_exists('gzopen'))
|
46 |
+
$this->cfg['gzlogs']=false;
|
47 |
//set Log file name
|
48 |
$this->logfile='backwpup_log_'.date_i18n('Y-m-d_H-i-s').'.html';
|
49 |
//create log file
|
50 |
+
$fd=fopen($this->logdir.$this->logfile,'w');
|
51 |
//Create log file header
|
52 |
+
fwrite($fd,"<html>\n<head>\n");
|
53 |
+
fwrite($fd,"<meta name=\"backwpup_version\" content=\"".BACKWPUP_VERSION."\" />\n");
|
54 |
+
fwrite($fd,"<meta name=\"php_version\" content=\"".phpversion()."\" />\n");
|
55 |
+
fwrite($fd,"<meta name=\"mysql_version\" content=\"".$wpdb->get_var("SELECT VERSION() AS version")."\" />\n");
|
56 |
+
fwrite($fd,"<meta name=\"backwpup_logtime\" content=\"".current_time('timestamp')."\" />\n");
|
57 |
+
fwrite($fd,str_pad("<meta name=\"backwpup_errors\" content=\"0\" />",100)."\n");
|
58 |
+
fwrite($fd,str_pad("<meta name=\"backwpup_warnings\" content=\"0\" />",100)."\n");
|
59 |
+
fwrite($fd,"<meta name=\"backwpup_jobid\" content=\"".$this->jobid."\" />\n");
|
60 |
+
fwrite($fd,"<meta name=\"backwpup_jobname\" content=\"".$jobs[$this->jobid]['name']."\" />\n");
|
61 |
+
fwrite($fd,"<meta name=\"backwpup_jobtype\" content=\"".$jobs[$this->jobid]['type']."\" />\n");
|
62 |
+
fwrite($fd,str_pad("<meta name=\"backwpup_backupfilesize\" content=\"0\" />",100)."\n");
|
63 |
+
fwrite($fd,str_pad("<meta name=\"backwpup_jobruntime\" content=\"0\" />",100)."\n");
|
64 |
+
fwrite($fd,"<title>".sprintf(__('BackWPup Log for %1$s from %2$s at %3$s','backwpup'),$jobs[$this->jobid]['name'],date_i18n(get_option('date_format')),date_i18n(get_option('time_format')))."</title>\n</head>\n<body style=\"font-family:monospace;font-size:12px;white-space:nowrap;\">\n");
|
65 |
+
fclose($fd);
|
66 |
//set function for PHP user defineid error handling
|
67 |
if (defined(WP_DEBUG) and WP_DEBUG)
|
68 |
set_error_handler(array($this,'joberrorhandler'),E_ALL | E_STRICT);
|
73 |
if ($jobs[$this->jobid]['starttime']+600<current_time('timestamp')) { //Abort old jo if work longer as 10 min. because websever has 300 sec timeout
|
74 |
trigger_error(__('Working Job will closed!!! And a new started!!!','backwpup'),E_USER_WARNING);
|
75 |
//old logfile end
|
76 |
+
$fd=fopen($jobs[$this->jobid]['logfile'],'a');
|
77 |
+
fwrite($fd,"<span style=\"background-color:c3c3c3;\" title=\"[Line: ".__LINE__."|File: ".basename(__FILE__)."\">".date_i18n('Y-m-d H:i.s').":</span> <span style=\"background-color:red;\">".__('[ERROR]','backwpup')." ".__('Backup Aborted working to long!!!','backwpup')."</span><br />\n");
|
|
|
78 |
fclose($fd);
|
79 |
$logheader=backwpup_read_logheader($jobs[$this->jobid]['logfile']); //read waring count from log header
|
80 |
$logheader['errors']++;
|
81 |
//write new log header
|
82 |
+
$fd=fopen($jobs[$this->jobid]['logfile'],'r+');
|
83 |
while (!feof($fd)) {
|
84 |
+
if (stripos(fgets($fd),"<meta name=\"backwpup_errors\"") !== false) {
|
85 |
+
fseek($fd,$filepos);
|
86 |
+
fwrite($fd,str_pad("<meta name=\"backwpup_errors\" content=\"".$logheader['errors']."\" />",100)."\n");
|
87 |
break;
|
88 |
}
|
89 |
$filepos=ftell($fd);
|
90 |
}
|
91 |
+
fclose($fd);
|
92 |
+
$this->job_end($jobs[$this->jobid]['logfile']);
|
93 |
} else {
|
94 |
+
trigger_error(sprintf(__('Job %1$s already running!!!','backwpup'),$jobs[$this->jobid]['name']),E_USER_ERROR);
|
95 |
return false;
|
96 |
}
|
97 |
}
|
99 |
$jobs[$this->jobid]['starttime']=current_time('timestamp'); //set start time for job
|
100 |
$jobs[$this->jobid]['logfile']=$this->logdir.$this->logfile; //Set current logfile
|
101 |
$jobs[$this->jobid]['cronnextrun']=backwpup_cron_next($jobs[$this->jobid]['cron']); //set next run
|
102 |
+
$jobs[$this->jobid]['lastbackupdownloadurl']='';
|
103 |
+
$jobs[$this->jobid]['lastlogfile']=$this->logdir.$this->logfile;
|
104 |
+
$jobs[$this->jobid]['cronnextrun']=backwpup_cron_next($jobs[$this->jobid]['cron']); //set next run
|
105 |
update_option('backwpup_jobs',$jobs); //Save job Settings
|
106 |
+
$this->job=backwpup_check_job_vars($jobs[$this->jobid],$this->jobid);//Set and check job settings
|
107 |
//set waht to do
|
108 |
$this->todo=explode('+',$this->job['type']);
|
109 |
//set Backup File format
|
153 |
elseif ($this->backupfileformat==".tar.gz" or $this->backupfileformat==".tar.bz2" or $this->backupfileformat==".tar")
|
154 |
$this->tar_pack_files();
|
155 |
}
|
156 |
+
|
157 |
if (is_file($this->backupdir.$this->backupfile)) { // Put backup file to destination
|
158 |
+
$dests=explode(',',strtoupper(BACKWPUP_DESTS));
|
159 |
$this->destination_mail();
|
160 |
+
if (in_array('FTP',$dests))
|
161 |
+
$this->destination_ftp();
|
162 |
+
if (in_array('DROPBOX',$dests))
|
163 |
+
$this->destination_dropbox();
|
164 |
+
if (in_array('S3',$dests))
|
165 |
+
$this->destination_s3();
|
166 |
+
if (in_array('RSC',$dests))
|
167 |
+
$this->destination_rsc();
|
168 |
$this->destination_dir();
|
169 |
}
|
170 |
|
179 |
}
|
180 |
}
|
181 |
|
182 |
+
//delete old logs
|
183 |
+
if (!empty($this->cfg['maxlogs'])) {
|
184 |
+
if ( $dir = opendir($this->logdir) ) { //make file list
|
185 |
+
while (($file = readdir($dir)) !== false ) {
|
186 |
+
if ('backwpup_log_' == substr($file,0,strlen('backwpup_log_')) and (".html" == substr($file,-5) or ".html.gz" == substr($file,-8)))
|
187 |
+
$logfilelist[]=$file;
|
188 |
+
}
|
189 |
+
closedir( $dir );
|
190 |
+
}
|
191 |
+
if (sizeof($logfilelist)>0) {
|
192 |
+
rsort($logfilelist);
|
193 |
+
$numdeltefiles=0;
|
194 |
+
for ($i=$this->cfg['maxlogs'];$i<sizeof($logfilelist);$i++) {
|
195 |
+
unlink($this->logdir.$logfilelist[$i]);
|
196 |
+
$numdeltefiles++;
|
197 |
+
}
|
198 |
+
if ($numdeltefiles>0)
|
199 |
+
trigger_error($numdeltefiles.' '.__('old Log files deleted!!!','backwpup'),E_USER_NOTICE);
|
200 |
+
}
|
201 |
+
}
|
202 |
+
|
203 |
+
if ($filesize=filesize($this->backupdir.$this->backupfile))
|
204 |
+
trigger_error(sprintf(__('Backup Archive File size is %1s','backwpup'),backwpup_formatBytes($filesize)),E_USER_NOTICE);
|
205 |
+
|
206 |
+
trigger_error(sprintf(__('Job done in %1s sec.','backwpup'),current_time('timestamp')-$this->job['starttime']),E_USER_NOTICE);
|
207 |
+
|
208 |
+
$this->job_end();
|
209 |
}
|
210 |
|
211 |
//function for PHP error handling
|
253 |
|
254 |
if (!empty($massage)) {
|
255 |
//wirte log file
|
256 |
+
$fd=fopen($this->logdir.$this->logfile,'a');
|
257 |
+
fwrite($fd,$massage."<br />\n");
|
258 |
+
fclose($fd);
|
259 |
|
260 |
//output on run now
|
261 |
if (!defined('DOING_CRON')) {
|
266 |
|
267 |
//write new log header
|
268 |
if (isset($errors) or isset($warnings)) {
|
269 |
+
$fd=fopen($this->logdir.$this->logfile,'r+');
|
270 |
+
while (!feof($fd)) {
|
271 |
+
$line=fgets($fd);
|
272 |
+
if (stripos($line,"<meta name=\"backwpup_errors\"") !== false and isset($errors)) {
|
273 |
+
fseek($fd,$filepos);
|
274 |
+
fwrite($fd,str_pad("<meta name=\"backwpup_errors\" content=\"".$errors."\" />",100)."\n");
|
275 |
+
break;
|
276 |
+
}
|
277 |
+
if (stripos($line,"<meta name=\"backwpup_warnings\"") !== false and isset($warnings)) {
|
278 |
+
fseek($fd,$filepos);
|
279 |
+
fwrite($fd,str_pad("<meta name=\"backwpup_warnings\" content=\"".$warnings."\" />",100)."\n");
|
280 |
+
break;
|
|
|
|
|
281 |
}
|
282 |
+
$filepos=ftell($fd);
|
283 |
}
|
284 |
+
fclose($fd);
|
285 |
}
|
286 |
|
287 |
if ($args[0]==E_ERROR or $args[0]==E_CORE_ERROR or $args[0]==E_COMPILE_ERROR) {//Die on fatal php errors.
|
288 |
+
$this->send_log_mail();
|
|
|
|
|
|
|
289 |
die();
|
290 |
}
|
291 |
//300 is most webserver time limit. 0= max time! Give script 5 min. more to work.
|
390 |
update_option('plugin_maintenance-mode',$mamo);
|
391 |
} else { //WP Support
|
392 |
$fdmain=fopen(trailingslashit(ABSPATH).'.maintenance','w');
|
393 |
+
fwrite($fdmain,'<?php $upgrading = ' . time() . '; ?>');
|
394 |
fclose($fdmain);
|
395 |
}
|
396 |
} else {
|
540 |
$status[$statusdata['Name']]=$statusdata;
|
541 |
}
|
542 |
|
543 |
+
if ($file = fopen($this->tempdir.DB_NAME.'.sql', 'w')) {
|
544 |
fwrite($file, "-- ---------------------------------------------------------\n");
|
545 |
fwrite($file, "-- Dump with BackWPup ver.: ".BACKWPUP_VERSION."\n");
|
546 |
fwrite($file, "-- Plugin for WordPress by Daniel Huesken\n");
|
615 |
if (!$return) {
|
616 |
trigger_error(__('cURL:','backwpup').' '.curl_error($ch),E_USER_ERROR);
|
617 |
} else {
|
618 |
+
$fd=fopen($this->tempdir.sanitize_key(get_bloginfo('name')).'.wordpress.' . date( 'Y-m-d' ) . '.xml',"w+");
|
619 |
fwrite($fd,$return);
|
620 |
fclose($fd);
|
621 |
}
|
622 |
curl_close($ch);
|
623 |
} elseif (ini_get('allow_url_fopen')==true or ini_get('allow_url_fopen')==1 or strtolower(ini_get('allow_url_fopen'))=="on") {
|
624 |
trigger_error(__('Run Wordpress Export to XML file...','backwpup'),E_USER_NOTICE);
|
625 |
+
if (copy(plugins_url('wp_xml_export.php',__FILE__).'?wpabs='.trailingslashit(ABSPATH).'&_nonce='.substr(md5(md5(SECURE_AUTH_KEY)),10,10),$this->tempdir.sanitize_key(get_bloginfo('name')).'.wordpress.' . date( 'Y-m-d' ) . '.xml')) {
|
626 |
trigger_error(__('Export to XML done!','backwpup'),E_USER_NOTICE);
|
627 |
} else {
|
628 |
trigger_error(__('Can not Export to XML!','backwpup'),E_USER_ERROR);
|
630 |
} else {
|
631 |
trigger_error(__('Can not Export to XML! no cURL or allow_url_fopen Support!','backwpup'),E_USER_WARNING);
|
632 |
}
|
633 |
+
if (is_readable($this->tempdir.sanitize_key(get_bloginfo('name')).'.wordpress.' . date( 'Y-m-d' ) . '.xml')) {
|
634 |
//add database file to backupfiles
|
635 |
+
trigger_error(__('Add XML Export to Backup:','backwpup').' '.sanitize_key(get_bloginfo('name')).'.wordpress.' . date( 'Y-m-d' ) . '.xml '.backwpup_formatBytes(filesize($this->tempdir.sanitize_key(get_bloginfo('name')).'.wordpress.' . date( 'Y-m-d' ) . '.xml')),E_USER_NOTICE);
|
636 |
+
$this->allfilesize+=filesize($this->tempdir.sanitize_key(get_bloginfo('name')).'.wordpress.' . date( 'Y-m-d' ) . '.xml');
|
637 |
+
$this->filelist[]=array(79001=>$this->tempdir.sanitize_key(get_bloginfo('name')).'.wordpress.' . date( 'Y-m-d' ) . '.xml',79003=>sanitize_key(get_bloginfo('name')).'.wordpress.' . date( 'Y-m-d' ) . '.xml');
|
638 |
}
|
639 |
}
|
640 |
|
1102 |
if (empty($this->job['awsAccessKey']) or empty($this->job['awsSecretKey']) or empty($this->job['awsBucket']))
|
1103 |
return;
|
1104 |
|
|
|
|
|
|
|
|
|
1105 |
|
1106 |
+
if (!class_exists('CFRuntime'))
|
1107 |
+
require_once(dirname(__FILE__).'/libs/aws/sdk.class.php');
|
1108 |
+
|
1109 |
+
try {
|
1110 |
+
$s3 = new AmazonS3($this->job['awsAccessKey'], $this->job['awsSecretKey']);
|
1111 |
|
1112 |
+
if ($s3->if_bucket_exists($this->job['awsBucket'])) {
|
1113 |
+
trigger_error(__('Connected to S3 Bucket:','backwpup').' '.$this->job['awsBucket'],E_USER_NOTICE);
|
|
|
|
|
|
|
|
|
|
|
1114 |
|
1115 |
+
//Transfer Backup to S3
|
1116 |
+
if ($this->job['awsrrs']) //set reduced redundancy or not
|
1117 |
+
$storage=AmazonS3::STORAGE_REDUCED;
|
1118 |
+
else
|
1119 |
+
$storage=AmazonS3::STORAGE_STANDARD;
|
1120 |
+
|
1121 |
+
if ($s3->create_object($this->job['awsBucket'], $this->job['awsdir'].$this->backupfile, array('fileUpload' => $this->backupdir.$this->backupfile,'acl' => AmazonS3::ACL_PRIVATE,'storage' => $storage))) {//transfere file to S3
|
1122 |
+
trigger_error(__('Backup File transferred to S3://','backwpup').$this->job['awsBucket'].'/'.$this->job['awsdir'].$this->backupfile,E_USER_NOTICE);
|
1123 |
+
$this->lastbackupdownloadurl='admin.php?page=BackWPup&subpage=backups&action=downloads3&file='.$this->job['awsdir'].$this->backupfile.'&jobid='.$this->jobid;
|
1124 |
+
} else {
|
1125 |
+
trigger_error(__('Can not transfer backup to S3.','backwpup'),E_USER_ERROR);
|
1126 |
+
}
|
1127 |
+
|
1128 |
+
if ($this->job['awsmaxbackups']>0) { //Delete old backups
|
1129 |
+
$backupfilelist=array();
|
1130 |
+
if (($contents = $s3->list_objects($this->job['awsBucket'],array('prefix'=>$this->job['awsdir']))) !== false) {
|
1131 |
+
foreach ($contents->body->Contents as $object) {
|
1132 |
+
$file=basename($object->Key);
|
1133 |
+
if ($this->job['awsdir'].$file == $object->Key) {//only in the folder and not in complete bucket
|
1134 |
+
if ($this->job['fileprefix'] == substr($file,0,strlen($this->job['fileprefix'])) and $this->backupfileformat == substr($file,-strlen($this->backupfileformat)))
|
1135 |
+
$backupfilelist[]=$file;
|
1136 |
+
}
|
1137 |
}
|
1138 |
}
|
1139 |
+
if (sizeof($backupfilelist)>0) {
|
1140 |
+
rsort($backupfilelist);
|
1141 |
+
$numdeltefiles=0;
|
1142 |
+
for ($i=$this->job['awsmaxbackups'];$i<sizeof($backupfilelist);$i++) {
|
1143 |
+
if ($s3->delete_object($this->job['awsBucket'], $this->job['awsdir'].$backupfilelist[$i])) //delte files on S3
|
1144 |
+
$numdeltefiles++;
|
1145 |
+
else
|
1146 |
+
trigger_error(__('Can not delete file on S3://','backwpup').$this->job['awsBucket'].'/'.$this->job['awsdir'].$backupfilelist[$i],E_USER_ERROR);
|
1147 |
+
}
|
1148 |
+
if ($numdeltefiles>0)
|
1149 |
+
trigger_error($numdeltefiles.' '.__('files deleted on S3 Bucket!','backwpup'),E_USER_NOTICE);
|
1150 |
}
|
1151 |
+
}
|
1152 |
+
|
1153 |
+
|
1154 |
+
|
1155 |
+
} else {
|
1156 |
+
trigger_error(__('S3 Bucket not exists:','backwpup').' '.$this->job['awsBucket'],E_USER_ERROR);
|
1157 |
}
|
1158 |
+
} catch (Exception $e) {
|
1159 |
+
trigger_error(__('Amazon S3 API:','backwpup').' '.__($e->getMessage(),'backwpup'),E_USER_ERROR);
|
1160 |
+
return;
|
1161 |
}
|
1162 |
}
|
1163 |
|
1212 |
// $backwpupcontainer->create_paths($this->job['rscdir']);
|
1213 |
$backwpupbackup = $backwpupcontainer->create_object($this->job['rscdir'].$this->backupfile);
|
1214 |
|
1215 |
+
if ($backwpupbackup->load_from_filename($this->backupdir.$this->backupfile)) {
|
1216 |
trigger_error(__('Backup File transferred to RSC://','backwpup').$this->job['rscContainer'].'/'.$this->job['rscdir'].$this->backupfile,E_USER_NOTICE);
|
1217 |
+
$this->lastbackupdownloadurl='admin.php?page=BackWPup&subpage=backups&action=downloadrsc&file='.$this->job['rscdir'].$this->backupfile.'&jobid='.$this->jobid;
|
1218 |
+
} else {
|
1219 |
trigger_error(__('Can not transfer backup to RSC.','backwpup'),E_USER_ERROR);
|
1220 |
+
}
|
1221 |
|
1222 |
if ($this->job['rscmaxbackups']>0) { //Delete old backups
|
1223 |
$backupfilelist=array();
|
1253 |
private function destination_dir() {
|
1254 |
if (empty($this->job['backupdir'])) //Go back if no destination dir
|
1255 |
return;
|
1256 |
+
$this->lastbackupdownloadurl='admin.php?page=BackWPup&subpage=backups&action=download&file='.$this->backupdir.$this->backupfile;
|
1257 |
//Delete old Backupfiles
|
1258 |
$backupfilelist=array();
|
1259 |
if (!empty($this->job['maxbackups'])) {
|
1289 |
if (!class_exists('DropboxUploader'))
|
1290 |
try {
|
1291 |
require_once (dirname(__FILE__).'/libs/DropboxUploader.php');
|
1292 |
+
trigger_error(__('Connect to DropBox ...','backwpup'),E_USER_NOTICE);
|
1293 |
$uploader = new DropboxUploader($this->job['dropemail'], base64_decode($this->job['dropepass']));
|
1294 |
$uploader->upload($this->backupdir.$this->backupfile,$this->job['dropedir']);
|
1295 |
+
trigger_error(__('Backup File transferred to DropBox.','backwpup'),E_USER_NOTICE);
|
1296 |
} catch (Exception $e) {
|
1297 |
trigger_error(__('DropBox:','backwpup').' '.__($e->getMessage(),'backwpup'),E_USER_ERROR);
|
1298 |
}
|
1299 |
}
|
1300 |
|
1301 |
+
private function job_end($logfile ='') {
|
1302 |
+
if (empty($logfile)) $logfile=$this->logdir.$this->logfile;
|
1303 |
+
restore_error_handler();
|
1304 |
+
|
1305 |
+
if (!($filesize=@filesize($this->backupdir.$this->backupfile))) //Set the filezie corectly
|
1306 |
+
$filesize=0;
|
1307 |
|
1308 |
+
//clean up
|
1309 |
+
@unlink($this->tempdir.DB_NAME.'.sql');
|
1310 |
+
@unlink($this->tempdir.sanitize_key(get_bloginfo('name')).'.wordpress.' . date( 'Y-m-d' ) . '.xml');
|
1311 |
|
1312 |
+
if (empty($this->job['backupdir']) and is_file($this->backupdir.$this->backupfile)) { //delete backup file in temp dir
|
1313 |
+
unlink($this->backupdir.$this->backupfile);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1314 |
}
|
1315 |
+
$jobs=get_option('backwpup_jobs');
|
|
|
1316 |
$jobs[$this->jobid]['lastrun']=$jobs[$this->jobid]['starttime'];
|
1317 |
$jobs[$this->jobid]['lastruntime']=current_time('timestamp')-$jobs[$this->jobid]['starttime'];
|
1318 |
$jobs[$this->jobid]['logfile']='';
|
1319 |
$jobs[$this->jobid]['starttime']='';
|
1320 |
+
$jobs[$this->jobid]['lastbackupdownloadurl']=$this->lastbackupdownloadurl;
|
1321 |
update_option('backwpup_jobs',$jobs); //Save Settings
|
1322 |
$this->job['lastrun']=$jobs[$this->jobid]['lastrun'];
|
1323 |
$this->job['lastruntime']=$jobs[$this->jobid]['lastruntime'];
|
1324 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1325 |
//write heder info
|
1326 |
+
$fd=fopen($logfile,'r+');
|
1327 |
$found=0;
|
1328 |
while (!feof($fd)) {
|
1329 |
+
$line=fgets($fd);
|
1330 |
if (stripos($line,"<meta name=\"backwpup_jobruntime\"") !== false) {
|
1331 |
+
fseek($fd,$filepos);
|
1332 |
+
fwrite($fd,str_pad("<meta name=\"backwpup_jobruntime\" content=\"".$this->job['lastruntime']."\" />",100)."\n");
|
1333 |
$found++;
|
1334 |
}
|
1335 |
if (stripos($line,"<meta name=\"backwpup_backupfilesize\"") !== false) {
|
1336 |
+
fseek($fd,$filepos);
|
1337 |
+
fwrite($fd,str_pad("<meta name=\"backwpup_backupfilesize\" content=\"".$filesize."\" />",100)."\n");
|
1338 |
$found++;
|
1339 |
}
|
1340 |
if ($found>=2)
|
1341 |
break;
|
1342 |
$filepos=ftell($fd);
|
1343 |
}
|
1344 |
+
fclose($fd);
|
1345 |
//logfile end
|
1346 |
+
$fd=fopen($logfile,'a');
|
1347 |
+
fwrite($fd,"</body>\n</html>\n");
|
1348 |
fclose($fd);
|
1349 |
+
//gzip logfile
|
1350 |
+
if ($this->cfg['gzlogs']) {
|
1351 |
+
$fd=fopen($logfile,'r');
|
1352 |
+
$zd=gzopen($logfile.'.gz','w9');
|
1353 |
+
while (!feof($fd)) {
|
1354 |
+
gzwrite($zd,fread($fd,4096));
|
1355 |
+
}
|
1356 |
+
gzclose($zd);
|
1357 |
+
fclose($fd);
|
1358 |
+
unlink($logfile);
|
1359 |
+
$logfile=$logfile.'.gz';
|
1360 |
+
$jobs=get_option('backwpup_jobs');
|
1361 |
+
$jobs[$this->jobid]['lastlogfile']=$logfile;
|
1362 |
+
update_option('backwpup_jobs',$jobs); //Save Settings
|
1363 |
+
}
|
1364 |
+
$logdata=backwpup_read_logheader($logfile);
|
1365 |
//Send mail with log
|
1366 |
$sendmail=false;
|
1367 |
if ($logdata['errors']>0 and $this->job['mailerroronly'] and !empty($this->job['mailaddresslog']))
|
1404 |
$phpmailer->From = $this->cfg['mailsndemail'];
|
1405 |
$phpmailer->FromName = $this->cfg['mailsndname'];
|
1406 |
$phpmailer->AddAddress($this->job['mailaddresslog']);
|
1407 |
+
$phpmailer->Subject = __('BackWPup Log from','backwpup').' '.date_i18n('Y-m-d H:i',$this->job['lastrun']).': '.$this->job['name'];
|
1408 |
$phpmailer->IsHTML(false);
|
1409 |
$phpmailer->Body = $mailbody;
|
1410 |
+
$phpmailer->AddAttachment($logfile);
|
1411 |
$phpmailer->Send();
|
1412 |
+
}
|
1413 |
}
|
1414 |
}
|
1415 |
?>
|
app/compatibility/class-wp-list-table.php
CHANGED
@@ -198,7 +198,7 @@ class WP_List_Table {
|
|
198 |
|
199 |
if ( ! empty( $_REQUEST['orderby'] ) )
|
200 |
echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
|
201 |
-
if ( ! empty( $_REQUEST['order'] ) )
|
202 |
echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
|
203 |
?>
|
204 |
<p class="search-box">
|
@@ -420,13 +420,7 @@ class WP_List_Table {
|
|
420 |
if ( $pending_comments )
|
421 |
echo '<strong>';
|
422 |
|
423 |
-
|
424 |
-
|
425 |
-
comments_number(
|
426 |
-
sprintf( $link, /* translators: comment count link */ _x( '0', 'comment count' ) ),
|
427 |
-
sprintf( $link, /* translators: comment count link */ _x( '1', 'comment count' ) ),
|
428 |
-
sprintf( $link, /* translators: comment count link: % will be substituted by comment count */ _x( '%', 'comment count' ) )
|
429 |
-
);
|
430 |
|
431 |
if ( $pending_comments )
|
432 |
echo '</strong>';
|
@@ -482,7 +476,7 @@ class WP_List_Table {
|
|
482 |
$current = $this->get_pagenum();
|
483 |
|
484 |
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
485 |
-
|
486 |
$current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
|
487 |
|
488 |
$page_links = array();
|
198 |
|
199 |
if ( ! empty( $_REQUEST['orderby'] ) )
|
200 |
echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
|
201 |
+
if ( ! empty( $_REQUEST['order'] ) )
|
202 |
echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
|
203 |
?>
|
204 |
<p class="search-box">
|
420 |
if ( $pending_comments )
|
421 |
echo '<strong>';
|
422 |
|
423 |
+
echo "<a href='" . esc_url( add_query_arg( 'p', $post_id, admin_url( 'edit-comments.php' ) ) ) . "' title='" . esc_attr( $pending_phrase ) . "' class='post-com-count'><span class='comment-count'>" . number_format_i18n( get_comments_number() ) . "</span></a>";
|
|
|
|
|
|
|
|
|
|
|
|
|
424 |
|
425 |
if ( $pending_comments )
|
426 |
echo '</strong>';
|
476 |
$current = $this->get_pagenum();
|
477 |
|
478 |
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
479 |
+
|
480 |
$current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
|
481 |
|
482 |
$page_links = array();
|
app/css/options.css
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
width:135px;
|
6 |
}
|
7 |
.column-info {
|
8 |
-
width:
|
9 |
}
|
10 |
.column-size {
|
11 |
width:75px;
|
5 |
width:135px;
|
6 |
}
|
7 |
.column-info {
|
8 |
+
width:150px;
|
9 |
}
|
10 |
.column-size {
|
11 |
width:75px;
|
app/functions.php
CHANGED
@@ -215,6 +215,7 @@ if ( !defined('ABSPATH') )
|
|
215 |
if (empty($cfg['mailmethod'])) $cfg['mailmethod']='mail';
|
216 |
if (empty($cfg['mailsendmail'])) $cfg['mailsendmail']=substr(ini_get('sendmail_path'),0,strpos(ini_get('sendmail_path'),' -'));
|
217 |
if (empty($cfg['maxlogs'])) $cfg['maxlogs']=0;
|
|
|
218 |
if (empty($cfg['dirtemp'])) {
|
219 |
$rand = substr( md5( md5( SECURE_AUTH_KEY ) ), -5 );
|
220 |
$cfg['dirtemp']=backwpup_get_upload_dir();
|
@@ -335,9 +336,15 @@ if ( !defined('ABSPATH') )
|
|
335 |
if (!is_readable($logfile))
|
336 |
return false;
|
337 |
//Read file
|
338 |
-
|
339 |
-
|
340 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
341 |
|
342 |
//get data form file
|
343 |
foreach ($headers as $keyword => $field) {
|
@@ -364,7 +371,7 @@ if ( !defined('ABSPATH') )
|
|
364 |
$logfiles=array();
|
365 |
if ( $dir = @opendir( $cfg['dirlogs'] ) ) {
|
366 |
while (($file = readdir( $dir ) ) !== false ) {
|
367 |
-
if (is_file($cfg['dirlogs'].'/'.$file) and 'backwpup_log_' == substr($file,0,strlen('backwpup_log_')) and '.html' == substr($file,-5))
|
368 |
$logfiles[]=$file;
|
369 |
}
|
370 |
closedir( $dir );
|
@@ -699,13 +706,13 @@ if ( !defined('ABSPATH') )
|
|
699 |
$checks=false;
|
700 |
}
|
701 |
if (!is_dir($cfg['dirlogs'])) { // check logs folder
|
702 |
-
$message.=__('- Logs Folder not exists:','backwpup') . ' '.$cfg['dirlogs'].'<br />';
|
703 |
}
|
704 |
if (!is_writable($cfg['dirlogs'])) { // check logs folder
|
705 |
$message.=__('- Logs Folder not writeable:','backwpup') . ' '.$cfg['dirlogs'].'<br />';
|
706 |
}
|
707 |
if (!is_dir($cfg['dirtemp'])) { // check Temp folder
|
708 |
-
$message.=__('- Temp Folder not exists:','backwpup') . ' '.$cfg['dirtemp'].'<br />';
|
709 |
}
|
710 |
if (!is_writable($cfg['dirtemp'])) { // check Temp folder
|
711 |
$message.=__('- Temp Folder not writeable:','backwpup') . ' '.$cfg['dirtemp'].'<br />';
|
215 |
if (empty($cfg['mailmethod'])) $cfg['mailmethod']='mail';
|
216 |
if (empty($cfg['mailsendmail'])) $cfg['mailsendmail']=substr(ini_get('sendmail_path'),0,strpos(ini_get('sendmail_path'),' -'));
|
217 |
if (empty($cfg['maxlogs'])) $cfg['maxlogs']=0;
|
218 |
+
if (!function_exists('gzopen') or !isset($cfg['gzlogs'])) $cfg['gzlogs']=false;
|
219 |
if (empty($cfg['dirtemp'])) {
|
220 |
$rand = substr( md5( md5( SECURE_AUTH_KEY ) ), -5 );
|
221 |
$cfg['dirtemp']=backwpup_get_upload_dir();
|
336 |
if (!is_readable($logfile))
|
337 |
return false;
|
338 |
//Read file
|
339 |
+
if (strtolower(substr($logfile,-3))==".gz") {
|
340 |
+
$fp = gzopen( $logfile, 'r' );
|
341 |
+
$file_data = gzread( $fp, 1536 ); // Pull only the first 1,5kiB of the file in.
|
342 |
+
gzclose( $fp );
|
343 |
+
} else {
|
344 |
+
$fp = fopen( $logfile, 'r' );
|
345 |
+
$file_data = fread( $fp, 1536 ); // Pull only the first 1,5kiB of the file in.
|
346 |
+
fclose( $fp );
|
347 |
+
}
|
348 |
|
349 |
//get data form file
|
350 |
foreach ($headers as $keyword => $field) {
|
371 |
$logfiles=array();
|
372 |
if ( $dir = @opendir( $cfg['dirlogs'] ) ) {
|
373 |
while (($file = readdir( $dir ) ) !== false ) {
|
374 |
+
if (is_file($cfg['dirlogs'].'/'.$file) and 'backwpup_log_' == substr($file,0,strlen('backwpup_log_')) and ('.html' == substr($file,-5) or '.html.gz' == substr($file,-8)))
|
375 |
$logfiles[]=$file;
|
376 |
}
|
377 |
closedir( $dir );
|
706 |
$checks=false;
|
707 |
}
|
708 |
if (!is_dir($cfg['dirlogs'])) { // check logs folder
|
709 |
+
$message.=__('- Logs Folder not exists (Try too create it on first Job run):','backwpup') . ' '.$cfg['dirlogs'].'<br />';
|
710 |
}
|
711 |
if (!is_writable($cfg['dirlogs'])) { // check logs folder
|
712 |
$message.=__('- Logs Folder not writeable:','backwpup') . ' '.$cfg['dirlogs'].'<br />';
|
713 |
}
|
714 |
if (!is_dir($cfg['dirtemp'])) { // check Temp folder
|
715 |
+
$message.=__('- Temp Folder not exists (Try too create it on first Job run):','backwpup') . ' '.$cfg['dirtemp'].'<br />';
|
716 |
}
|
717 |
if (!is_writable($cfg['dirtemp'])) { // check Temp folder
|
718 |
$message.=__('- Temp Folder not writeable:','backwpup') . ' '.$cfg['dirtemp'].'<br />';
|
app/functions5.php
CHANGED
@@ -203,9 +203,6 @@ if ( !defined('ABSPATH') )
|
|
203 |
if (!isset($jobsettings['awsSecretKey']) or !is_string($jobsettings['awsSecretKey']))
|
204 |
$jobsettings['awsSecretKey']='';
|
205 |
|
206 |
-
if (!isset($jobsettings['awsSSL']) or !is_bool($jobsettings['awsSSL']))
|
207 |
-
$jobsettings['awsSSL']=true;
|
208 |
-
|
209 |
if (!isset($jobsettings['awsrrs']) or !is_bool($jobsettings['awsrrs']))
|
210 |
$jobsettings['awsrrs']=false;
|
211 |
|
@@ -260,19 +257,22 @@ if ( !defined('ABSPATH') )
|
|
260 |
|
261 |
|
262 |
//ajax/normal get backup files and infos
|
263 |
-
function backwpup_get_backup_files() {
|
264 |
$jobs=(array)get_option('backwpup_jobs'); //Load jobs
|
|
|
265 |
$filecounter=0;
|
266 |
$files=array();
|
267 |
$donefolders=array();
|
268 |
if (extension_loaded('curl') or @dl(PHP_SHLIB_SUFFIX == 'so' ? 'curl.so' : 'php_curl.dll')) {
|
269 |
-
if (!class_exists('
|
270 |
-
require_once(dirname(__FILE__).'/libs/
|
271 |
if (!class_exists('CF_Authentication'))
|
272 |
require_once(dirname(__FILE__).'/libs/rackspace/cloudfiles.php');
|
273 |
}
|
274 |
|
275 |
foreach ($jobs as $jobid => $jobvalue) { //go job by job
|
|
|
|
|
276 |
$jobvalue=backwpup_check_job_vars($jobvalue,$jobid); //Check job values
|
277 |
$todo=explode('+',$jobvalue['type']); //only for backup jobs
|
278 |
if (!in_array('FILE',$todo) and !in_array('DB',$todo) and !in_array('WPEXP',$todo))
|
@@ -289,7 +289,7 @@ if ( !defined('ABSPATH') )
|
|
289 |
$files[$filecounter]['jobid']=$jobid;
|
290 |
$files[$filecounter]['file']=$jobvalue['backupdir'].$file;
|
291 |
$files[$filecounter]['filename']=$file;
|
292 |
-
$files[$filecounter]['downloadurl']=
|
293 |
$files[$filecounter]['filesize']=filesize($jobvalue['backupdir'].$file);
|
294 |
$files[$filecounter]['time']=filemtime($jobvalue['backupdir'].$file);
|
295 |
$filecounter++;
|
@@ -300,19 +300,19 @@ if ( !defined('ABSPATH') )
|
|
300 |
}
|
301 |
}
|
302 |
//Get files/filinfo from S3
|
303 |
-
if (class_exists('S3') and !in_array($jobvalue['awsAccessKey'].'|'.$jobvalue['awsBucket'].'|'.$jobvalue['awsdir'],$donefolders)) {
|
304 |
if (!empty($jobvalue['awsAccessKey']) and !empty($jobvalue['awsSecretKey']) and !empty($jobvalue['awsBucket'])) {
|
305 |
-
$s3 = new
|
306 |
-
if (($contents = $s3->
|
307 |
-
foreach ($contents as $object) {
|
308 |
-
if (strtolower(substr($object
|
309 |
$files[$filecounter]['type']='S3';
|
310 |
$files[$filecounter]['jobid']=$jobid;
|
311 |
-
$files[$filecounter]['file']
|
312 |
-
$files[$filecounter]['filename']=basename($object
|
313 |
-
$files[$filecounter]['downloadurl']=
|
314 |
-
$files[$filecounter]['filesize']
|
315 |
-
$files[$filecounter]['time']
|
316 |
$filecounter++;
|
317 |
}
|
318 |
}
|
@@ -321,7 +321,7 @@ if ( !defined('ABSPATH') )
|
|
321 |
}
|
322 |
}
|
323 |
//Get files/filinfo from RSC
|
324 |
-
if (class_exists('CF_Authentication') and !in_array($jobvalue['rscUsername'].'|'.$jobvalue['rscContainer'].'|'.$jobvalue['rscdir'],$donefolders)) {
|
325 |
if (!empty($jobvalue['rscUsername']) and !empty($jobvalue['rscAPIKey']) and !empty($jobvalue['rscContainer'])) {
|
326 |
$auth = new CF_Authentication($jobvalue['rscUsername'], $jobvalue['rscAPIKey']);
|
327 |
$auth->ssl_use_cabundle();
|
@@ -336,7 +336,7 @@ if ( !defined('ABSPATH') )
|
|
336 |
$files[$filecounter]['jobid']=$jobid;
|
337 |
$files[$filecounter]['file']=$object->name;
|
338 |
$files[$filecounter]['filename']=basename($object->name);
|
339 |
-
$files[$filecounter]['downloadurl']=
|
340 |
$files[$filecounter]['filesize']=$object->content_length;
|
341 |
$files[$filecounter]['time']=$object->last_modified;
|
342 |
$filecounter++;
|
@@ -347,7 +347,7 @@ if ( !defined('ABSPATH') )
|
|
347 |
}
|
348 |
}
|
349 |
//Get files/filinfo from FTP
|
350 |
-
if (!empty($jobvalue['ftphost']) and !empty($jobvalue['ftpuser']) and !empty($jobvalue['ftppass']) and !in_array($jobvalue['ftphost'].'|'.$jobvalue['ftpuser'].'|'.$jobvalue['ftpdir'],$donefolders)) {
|
351 |
$ftpport=21;
|
352 |
$ftphost=$jobvalue['ftphost'];
|
353 |
if (false !== strpos($jobvalue['ftphost'],':')) //look for port
|
@@ -412,8 +412,8 @@ if ( !defined('ABSPATH') )
|
|
412 |
$awsselected=$_POST['awsselected'];
|
413 |
$ajax=true;
|
414 |
}
|
415 |
-
if (!class_exists('
|
416 |
-
require_once(dirname(__FILE__).'/libs/
|
417 |
if (empty($awsAccessKey)) {
|
418 |
echo '<span id="awsBucket" style="color:red;">'.__('Missing Access Key ID!','backwpup').'</span>';
|
419 |
if ($ajax)
|
@@ -428,9 +428,10 @@ if ( !defined('ABSPATH') )
|
|
428 |
else
|
429 |
return;
|
430 |
}
|
431 |
-
$s3 = new
|
432 |
-
$buckets
|
433 |
-
|
|
|
434 |
echo '<span id="awsBucket" style="color:red;">'.__('No Buckets found! Or wrong Keys!','backwpup').'</span>';
|
435 |
if ($ajax)
|
436 |
die();
|
@@ -438,8 +439,8 @@ if ( !defined('ABSPATH') )
|
|
438 |
return;
|
439 |
}
|
440 |
echo '<select name="awsBucket" id="awsBucket">';
|
441 |
-
foreach ($buckets as $bucket) {
|
442 |
-
echo "<option ".selected(strtolower($awsselected),strtolower($bucket),false).">".$bucket."</option>";
|
443 |
}
|
444 |
echo '</select>';
|
445 |
if ($ajax)
|
203 |
if (!isset($jobsettings['awsSecretKey']) or !is_string($jobsettings['awsSecretKey']))
|
204 |
$jobsettings['awsSecretKey']='';
|
205 |
|
|
|
|
|
|
|
206 |
if (!isset($jobsettings['awsrrs']) or !is_bool($jobsettings['awsrrs']))
|
207 |
$jobsettings['awsrrs']=false;
|
208 |
|
257 |
|
258 |
|
259 |
//ajax/normal get backup files and infos
|
260 |
+
function backwpup_get_backup_files($onlyjobid='') {
|
261 |
$jobs=(array)get_option('backwpup_jobs'); //Load jobs
|
262 |
+
$dests=explode(',',strtoupper(BACKWPUP_DESTS));
|
263 |
$filecounter=0;
|
264 |
$files=array();
|
265 |
$donefolders=array();
|
266 |
if (extension_loaded('curl') or @dl(PHP_SHLIB_SUFFIX == 'so' ? 'curl.so' : 'php_curl.dll')) {
|
267 |
+
if (!class_exists('CFRuntime'))
|
268 |
+
require_once(dirname(__FILE__).'/libs/aws/sdk.class.php');
|
269 |
if (!class_exists('CF_Authentication'))
|
270 |
require_once(dirname(__FILE__).'/libs/rackspace/cloudfiles.php');
|
271 |
}
|
272 |
|
273 |
foreach ($jobs as $jobid => $jobvalue) { //go job by job
|
274 |
+
if (!empty($onlyjobid) and $jobid!=$onlyjobid)
|
275 |
+
continue;
|
276 |
$jobvalue=backwpup_check_job_vars($jobvalue,$jobid); //Check job values
|
277 |
$todo=explode('+',$jobvalue['type']); //only for backup jobs
|
278 |
if (!in_array('FILE',$todo) and !in_array('DB',$todo) and !in_array('WPEXP',$todo))
|
289 |
$files[$filecounter]['jobid']=$jobid;
|
290 |
$files[$filecounter]['file']=$jobvalue['backupdir'].$file;
|
291 |
$files[$filecounter]['filename']=$file;
|
292 |
+
$files[$filecounter]['downloadurl']='admin.php?page=BackWPup&subpage=backups&action=download&file='.$jobvalue['backupdir'].$file;
|
293 |
$files[$filecounter]['filesize']=filesize($jobvalue['backupdir'].$file);
|
294 |
$files[$filecounter]['time']=filemtime($jobvalue['backupdir'].$file);
|
295 |
$filecounter++;
|
300 |
}
|
301 |
}
|
302 |
//Get files/filinfo from S3
|
303 |
+
if (class_exists('AmazonS3') and in_array('S3',$dests) and !in_array($jobvalue['awsAccessKey'].'|'.$jobvalue['awsBucket'].'|'.$jobvalue['awsdir'],$donefolders)) {
|
304 |
if (!empty($jobvalue['awsAccessKey']) and !empty($jobvalue['awsSecretKey']) and !empty($jobvalue['awsBucket'])) {
|
305 |
+
$s3 = new AmazonS3($jobvalue['awsAccessKey'], $jobvalue['awsSecretKey']);
|
306 |
+
if (($contents = $s3->list_objects($jobvalue['awsBucket'],array('prefix'=>$jobvalue['awsdir']))) !== false) {
|
307 |
+
foreach ($contents->body->Contents as $object) {
|
308 |
+
if (strtolower(substr($object->Key,-4))=='.zip' or strtolower(substr($object->Key,-4))=='.tar' or strtolower(substr($object->Key,-7))=='.tar.gz' or strtolower(substr($object->Key,-8))=='.tar.bz2') {
|
309 |
$files[$filecounter]['type']='S3';
|
310 |
$files[$filecounter]['jobid']=$jobid;
|
311 |
+
$files[$filecounter]['file']=(string)$object->Key;
|
312 |
+
$files[$filecounter]['filename']=basename($object->Key);
|
313 |
+
$files[$filecounter]['downloadurl']='admin.php?page=BackWPup&subpage=backups&action=downloads3&file='.$object->Key.'&jobid='.$jobid;
|
314 |
+
$files[$filecounter]['filesize']=(string)$object->Size;
|
315 |
+
$files[$filecounter]['time']=strtotime($object->LastModified);
|
316 |
$filecounter++;
|
317 |
}
|
318 |
}
|
321 |
}
|
322 |
}
|
323 |
//Get files/filinfo from RSC
|
324 |
+
if (class_exists('CF_Authentication') and in_array('RSC',$dests) and !in_array($jobvalue['rscUsername'].'|'.$jobvalue['rscContainer'].'|'.$jobvalue['rscdir'],$donefolders)) {
|
325 |
if (!empty($jobvalue['rscUsername']) and !empty($jobvalue['rscAPIKey']) and !empty($jobvalue['rscContainer'])) {
|
326 |
$auth = new CF_Authentication($jobvalue['rscUsername'], $jobvalue['rscAPIKey']);
|
327 |
$auth->ssl_use_cabundle();
|
336 |
$files[$filecounter]['jobid']=$jobid;
|
337 |
$files[$filecounter]['file']=$object->name;
|
338 |
$files[$filecounter]['filename']=basename($object->name);
|
339 |
+
$files[$filecounter]['downloadurl']='admin.php?page=BackWPup&subpage=backups&action=downloadrsc&file='.$object->name.'&jobid='.$jobid;
|
340 |
$files[$filecounter]['filesize']=$object->content_length;
|
341 |
$files[$filecounter]['time']=$object->last_modified;
|
342 |
$filecounter++;
|
347 |
}
|
348 |
}
|
349 |
//Get files/filinfo from FTP
|
350 |
+
if (!empty($jobvalue['ftphost']) and in_array('FTP',$dests) and !empty($jobvalue['ftpuser']) and !empty($jobvalue['ftppass']) and !in_array($jobvalue['ftphost'].'|'.$jobvalue['ftpuser'].'|'.$jobvalue['ftpdir'],$donefolders)) {
|
351 |
$ftpport=21;
|
352 |
$ftphost=$jobvalue['ftphost'];
|
353 |
if (false !== strpos($jobvalue['ftphost'],':')) //look for port
|
412 |
$awsselected=$_POST['awsselected'];
|
413 |
$ajax=true;
|
414 |
}
|
415 |
+
if (!class_exists('CFRuntime'))
|
416 |
+
require_once(dirname(__FILE__).'/libs/aws/sdk.class.php');
|
417 |
if (empty($awsAccessKey)) {
|
418 |
echo '<span id="awsBucket" style="color:red;">'.__('Missing Access Key ID!','backwpup').'</span>';
|
419 |
if ($ajax)
|
428 |
else
|
429 |
return;
|
430 |
}
|
431 |
+
$s3 = new AmazonS3($awsAccessKey, $awsSecretKey);
|
432 |
+
$buckets=$s3->list_buckets();
|
433 |
+
//print_r($buckets);
|
434 |
+
if ($buckets->status!=200) {
|
435 |
echo '<span id="awsBucket" style="color:red;">'.__('No Buckets found! Or wrong Keys!','backwpup').'</span>';
|
436 |
if ($ajax)
|
437 |
die();
|
439 |
return;
|
440 |
}
|
441 |
echo '<select name="awsBucket" id="awsBucket">';
|
442 |
+
foreach ($buckets->body->Buckets->Bucket as $bucket) {
|
443 |
+
echo "<option ".selected(strtolower($awsselected),strtolower($bucket->Name),false).">".$bucket->Name."</option>";
|
444 |
}
|
445 |
echo '</select>';
|
446 |
if ($ajax)
|
app/libs/S3.php
DELETED
@@ -1,1377 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* $Id: S3.php 47 2009-07-20 01:25:40Z don.schonknecht $
|
4 |
-
*
|
5 |
-
* Copyright (c) 2008, Donovan Schönknecht. All rights reserved.
|
6 |
-
*
|
7 |
-
* Redistribution and use in source and binary forms, with or without
|
8 |
-
* modification, are permitted provided that the following conditions are met:
|
9 |
-
*
|
10 |
-
* - Redistributions of source code must retain the above copyright notice,
|
11 |
-
* this list of conditions and the following disclaimer.
|
12 |
-
* - Redistributions in binary form must reproduce the above copyright
|
13 |
-
* notice, this list of conditions and the following disclaimer in the
|
14 |
-
* documentation and/or other materials provided with the distribution.
|
15 |
-
*
|
16 |
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
17 |
-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
18 |
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
19 |
-
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
20 |
-
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
21 |
-
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
22 |
-
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
23 |
-
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
24 |
-
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
25 |
-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
26 |
-
* POSSIBILITY OF SUCH DAMAGE.
|
27 |
-
*
|
28 |
-
* Amazon S3 is a trademark of Amazon.com, Inc. or its affiliates.
|
29 |
-
*/
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Amazon S3 PHP class
|
33 |
-
*
|
34 |
-
* @link http://undesigned.org.za/2007/10/22/amazon-s3-php-class
|
35 |
-
* @version 0.4.0
|
36 |
-
*/
|
37 |
-
/**
|
38 |
-
* Amazon S3 PHP class extende from Daniel Hüsken
|
39 |
-
*
|
40 |
-
* @link http://danielhuesken.de
|
41 |
-
* @version 0.4.0.1
|
42 |
-
* added REDUCED_REDUNDANCY support
|
43 |
-
* fixed case sensitive bucket locations
|
44 |
-
* removed curl opt CURLOPT_FOLLOWLOCATION because opdenbasedir warnings
|
45 |
-
*/
|
46 |
-
class S3 {
|
47 |
-
// ACL flags
|
48 |
-
const ACL_PRIVATE = 'private';
|
49 |
-
const ACL_PUBLIC_READ = 'public-read';
|
50 |
-
const ACL_PUBLIC_READ_WRITE = 'public-read-write';
|
51 |
-
const ACL_AUTHENTICATED_READ = 'authenticated-read';
|
52 |
-
|
53 |
-
public static $useSSL = true;
|
54 |
-
|
55 |
-
private static $__accessKey; // AWS Access key
|
56 |
-
private static $__secretKey; // AWS Secret key
|
57 |
-
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Constructor - if you're not using the class statically
|
61 |
-
*
|
62 |
-
* @param string $accessKey Access key
|
63 |
-
* @param string $secretKey Secret key
|
64 |
-
* @param boolean $useSSL Enable SSL
|
65 |
-
* @return void
|
66 |
-
*/
|
67 |
-
public function __construct($accessKey = null, $secretKey = null, $useSSL = true) {
|
68 |
-
if ($accessKey !== null && $secretKey !== null)
|
69 |
-
self::setAuth($accessKey, $secretKey);
|
70 |
-
self::$useSSL = $useSSL;
|
71 |
-
}
|
72 |
-
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Set AWS access key and secret key
|
76 |
-
*
|
77 |
-
* @param string $accessKey Access key
|
78 |
-
* @param string $secretKey Secret key
|
79 |
-
* @return void
|
80 |
-
*/
|
81 |
-
public static function setAuth($accessKey, $secretKey) {
|
82 |
-
self::$__accessKey = $accessKey;
|
83 |
-
self::$__secretKey = $secretKey;
|
84 |
-
}
|
85 |
-
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Get a list of buckets
|
89 |
-
*
|
90 |
-
* @param boolean $detailed Returns detailed bucket list when true
|
91 |
-
* @return array | false
|
92 |
-
*/
|
93 |
-
public static function listBuckets($detailed = false) {
|
94 |
-
$rest = new S3Request('GET', '', '');
|
95 |
-
$rest = $rest->getResponse();
|
96 |
-
if ($rest->error === false && $rest->code !== 200)
|
97 |
-
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
|
98 |
-
if ($rest->error !== false) {
|
99 |
-
trigger_error(sprintf("S3::listBuckets(): [%s] %s", $rest->error['code'], $rest->error['message']), E_USER_WARNING);
|
100 |
-
return false;
|
101 |
-
}
|
102 |
-
$results = array();
|
103 |
-
if (!isset($rest->body->Buckets)) return $results;
|
104 |
-
|
105 |
-
if ($detailed) {
|
106 |
-
if (isset($rest->body->Owner, $rest->body->Owner->ID, $rest->body->Owner->DisplayName))
|
107 |
-
$results['owner'] = array(
|
108 |
-
'id' => (string)$rest->body->Owner->ID, 'name' => (string)$rest->body->Owner->ID
|
109 |
-
);
|
110 |
-
$results['buckets'] = array();
|
111 |
-
foreach ($rest->body->Buckets->Bucket as $b)
|
112 |
-
$results['buckets'][] = array(
|
113 |
-
'name' => (string)$b->Name, 'time' => strtotime((string)$b->CreationDate)
|
114 |
-
);
|
115 |
-
} else
|
116 |
-
foreach ($rest->body->Buckets->Bucket as $b) $results[] = (string)$b->Name;
|
117 |
-
|
118 |
-
return $results;
|
119 |
-
}
|
120 |
-
|
121 |
-
|
122 |
-
/*
|
123 |
-
* Get contents for a bucket
|
124 |
-
*
|
125 |
-
* If maxKeys is null this method will loop through truncated result sets
|
126 |
-
*
|
127 |
-
* @param string $bucket Bucket name
|
128 |
-
* @param string $prefix Prefix
|
129 |
-
* @param string $marker Marker (last file listed)
|
130 |
-
* @param string $maxKeys Max keys (maximum number of keys to return)
|
131 |
-
* @param string $delimiter Delimiter
|
132 |
-
* @param boolean $returnCommonPrefixes Set to true to return CommonPrefixes
|
133 |
-
* @return array | false
|
134 |
-
*/
|
135 |
-
public static function getBucket($bucket, $prefix = null, $marker = null, $maxKeys = null, $delimiter = null, $returnCommonPrefixes = false) {
|
136 |
-
$rest = new S3Request('GET', $bucket, '');
|
137 |
-
if ($prefix !== null && $prefix !== '') $rest->setParameter('prefix', $prefix);
|
138 |
-
if ($marker !== null && $marker !== '') $rest->setParameter('marker', $marker);
|
139 |
-
if ($maxKeys !== null && $maxKeys !== '') $rest->setParameter('max-keys', $maxKeys);
|
140 |
-
if ($delimiter !== null && $delimiter !== '') $rest->setParameter('delimiter', $delimiter);
|
141 |
-
$response = $rest->getResponse();
|
142 |
-
if ($response->error === false && $response->code !== 200)
|
143 |
-
$response->error = array('code' => $response->code, 'message' => 'Unexpected HTTP status');
|
144 |
-
if ($response->error !== false) {
|
145 |
-
trigger_error(sprintf("S3::getBucket(): [%s] %s", $response->error['code'], $response->error['message']), E_USER_WARNING);
|
146 |
-
return false;
|
147 |
-
}
|
148 |
-
|
149 |
-
$results = array();
|
150 |
-
|
151 |
-
$nextMarker = null;
|
152 |
-
if (isset($response->body, $response->body->Contents))
|
153 |
-
foreach ($response->body->Contents as $c) {
|
154 |
-
$results[(string)$c->Key] = array(
|
155 |
-
'name' => (string)$c->Key,
|
156 |
-
'time' => strtotime((string)$c->LastModified),
|
157 |
-
'size' => (int)$c->Size,
|
158 |
-
'hash' => substr((string)$c->ETag, 1, -1)
|
159 |
-
);
|
160 |
-
$nextMarker = (string)$c->Key;
|
161 |
-
}
|
162 |
-
|
163 |
-
if ($returnCommonPrefixes && isset($response->body, $response->body->CommonPrefixes))
|
164 |
-
foreach ($response->body->CommonPrefixes as $c)
|
165 |
-
$results[(string)$c->Prefix] = array('prefix' => (string)$c->Prefix);
|
166 |
-
|
167 |
-
if (isset($response->body, $response->body->IsTruncated) &&
|
168 |
-
(string)$response->body->IsTruncated == 'false') return $results;
|
169 |
-
|
170 |
-
if (isset($response->body, $response->body->NextMarker))
|
171 |
-
$nextMarker = (string)$response->body->NextMarker;
|
172 |
-
|
173 |
-
// Loop through truncated results if maxKeys isn't specified
|
174 |
-
if ($maxKeys == null && $nextMarker !== null && (string)$response->body->IsTruncated == 'true')
|
175 |
-
do {
|
176 |
-
$rest = new S3Request('GET', $bucket, '');
|
177 |
-
if ($prefix !== null && $prefix !== '') $rest->setParameter('prefix', $prefix);
|
178 |
-
$rest->setParameter('marker', $nextMarker);
|
179 |
-
if ($delimiter !== null && $delimiter !== '') $rest->setParameter('delimiter', $delimiter);
|
180 |
-
|
181 |
-
if (($response = $rest->getResponse(true)) == false || $response->code !== 200) break;
|
182 |
-
|
183 |
-
if (isset($response->body, $response->body->Contents))
|
184 |
-
foreach ($response->body->Contents as $c) {
|
185 |
-
$results[(string)$c->Key] = array(
|
186 |
-
'name' => (string)$c->Key,
|
187 |
-
'time' => strtotime((string)$c->LastModified),
|
188 |
-
'size' => (int)$c->Size,
|
189 |
-
'hash' => substr((string)$c->ETag, 1, -1)
|
190 |
-
);
|
191 |
-
$nextMarker = (string)$c->Key;
|
192 |
-
}
|
193 |
-
|
194 |
-
if ($returnCommonPrefixes && isset($response->body, $response->body->CommonPrefixes))
|
195 |
-
foreach ($response->body->CommonPrefixes as $c)
|
196 |
-
$results[(string)$c->Prefix] = array('prefix' => (string)$c->Prefix);
|
197 |
-
|
198 |
-
if (isset($response->body, $response->body->NextMarker))
|
199 |
-
$nextMarker = (string)$response->body->NextMarker;
|
200 |
-
|
201 |
-
} while ($response !== false && (string)$response->body->IsTruncated == 'true');
|
202 |
-
|
203 |
-
return $results;
|
204 |
-
}
|
205 |
-
|
206 |
-
|
207 |
-
/**
|
208 |
-
* Put a bucket
|
209 |
-
*
|
210 |
-
* @param string $bucket Bucket name
|
211 |
-
* @param constant $acl ACL flag
|
212 |
-
* @param string $location Set as "EU" to create buckets hosted in Europe
|
213 |
-
* @return boolean
|
214 |
-
*/
|
215 |
-
public static function putBucket($bucket, $acl = self::ACL_PRIVATE, $location = false) {
|
216 |
-
$rest = new S3Request('PUT', $bucket, '');
|
217 |
-
$rest->setAmzHeader('x-amz-acl', $acl);
|
218 |
-
|
219 |
-
if ($location !== false) {
|
220 |
-
$dom = new DOMDocument;
|
221 |
-
$createBucketConfiguration = $dom->createElement('CreateBucketConfiguration');
|
222 |
-
$locationConstraint = $dom->createElement('LocationConstraint', $location);
|
223 |
-
$createBucketConfiguration->appendChild($locationConstraint);
|
224 |
-
$dom->appendChild($createBucketConfiguration);
|
225 |
-
$rest->data = $dom->saveXML();
|
226 |
-
$rest->size = strlen($rest->data);
|
227 |
-
$rest->setHeader('Content-Type', 'application/xml');
|
228 |
-
}
|
229 |
-
$rest = $rest->getResponse();
|
230 |
-
|
231 |
-
if ($rest->error === false && $rest->code !== 200)
|
232 |
-
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
|
233 |
-
if ($rest->error !== false) {
|
234 |
-
trigger_error(sprintf("S3::putBucket({$bucket}, {$acl}, {$location}): [%s] %s",
|
235 |
-
$rest->error['code'], $rest->error['message']), E_USER_WARNING);
|
236 |
-
return false;
|
237 |
-
}
|
238 |
-
return true;
|
239 |
-
}
|
240 |
-
|
241 |
-
|
242 |
-
/**
|
243 |
-
* Delete an empty bucket
|
244 |
-
*
|
245 |
-
* @param string $bucket Bucket name
|
246 |
-
* @return boolean
|
247 |
-
*/
|
248 |
-
public static function deleteBucket($bucket) {
|
249 |
-
$rest = new S3Request('DELETE', $bucket);
|
250 |
-
$rest = $rest->getResponse();
|
251 |
-
if ($rest->error === false && $rest->code !== 204)
|
252 |
-
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
|
253 |
-
if ($rest->error !== false) {
|
254 |
-
trigger_error(sprintf("S3::deleteBucket({$bucket}): [%s] %s",
|
255 |
-
$rest->error['code'], $rest->error['message']), E_USER_WARNING);
|
256 |
-
return false;
|
257 |
-
}
|
258 |
-
return true;
|
259 |
-
}
|
260 |
-
|
261 |
-
|
262 |
-
/**
|
263 |
-
* Create input info array for putObject()
|
264 |
-
*
|
265 |
-
* @param string $file Input file
|
266 |
-
* @param mixed $md5sum Use MD5 hash (supply a string if you want to use your own)
|
267 |
-
* @return array | false
|
268 |
-
*/
|
269 |
-
public static function inputFile($file, $md5sum = true) {
|
270 |
-
if (!file_exists($file) || !is_file($file) || !is_readable($file)) {
|
271 |
-
trigger_error('S3::inputFile(): Unable to open input file: '.$file, E_USER_WARNING);
|
272 |
-
return false;
|
273 |
-
}
|
274 |
-
return array('file' => $file, 'size' => filesize($file),
|
275 |
-
'md5sum' => $md5sum !== false ? (is_string($md5sum) ? $md5sum :
|
276 |
-
base64_encode(md5_file($file, true))) : '');
|
277 |
-
}
|
278 |
-
|
279 |
-
|
280 |
-
/**
|
281 |
-
* Create input array info for putObject() with a resource
|
282 |
-
*
|
283 |
-
* @param string $resource Input resource to read from
|
284 |
-
* @param integer $bufferSize Input byte size
|
285 |
-
* @param string $md5sum MD5 hash to send (optional)
|
286 |
-
* @return array | false
|
287 |
-
*/
|
288 |
-
public static function inputResource(&$resource, $bufferSize, $md5sum = '') {
|
289 |
-
if (!is_resource($resource) || $bufferSize < 0) {
|
290 |
-
trigger_error('S3::inputResource(): Invalid resource or buffer size', E_USER_WARNING);
|
291 |
-
return false;
|
292 |
-
}
|
293 |
-
$input = array('size' => $bufferSize, 'md5sum' => $md5sum);
|
294 |
-
$input['fp'] =& $resource;
|
295 |
-
return $input;
|
296 |
-
}
|
297 |
-
|
298 |
-
|
299 |
-
/**
|
300 |
-
* Put an object
|
301 |
-
*
|
302 |
-
* @param mixed $input Input data
|
303 |
-
* @param string $bucket Bucket name
|
304 |
-
* @param string $uri Object URI
|
305 |
-
* @param constant $acl ACL constant
|
306 |
-
* @param array $metaHeaders Array of x-amz-meta-* headers
|
307 |
-
* @param array $requestHeaders Array of request headers or content type as a string
|
308 |
-
* @param boolean $rrs put files with REDUCED_REDUNDANCY
|
309 |
-
* @return boolean
|
310 |
-
*/
|
311 |
-
public static function putObject($input, $bucket, $uri, $acl = self::ACL_PRIVATE, $metaHeaders = array(), $requestHeaders = array(),$rrs = false) {
|
312 |
-
if ($input === false) return false;
|
313 |
-
$rest = new S3Request('PUT', $bucket, $uri);
|
314 |
-
|
315 |
-
if (is_string($input)) $input = array(
|
316 |
-
'data' => $input, 'size' => strlen($input),
|
317 |
-
'md5sum' => base64_encode(md5($input, true))
|
318 |
-
);
|
319 |
-
|
320 |
-
// Data
|
321 |
-
if (isset($input['fp']))
|
322 |
-
$rest->fp =& $input['fp'];
|
323 |
-
elseif (isset($input['file']))
|
324 |
-
$rest->fp = @fopen($input['file'], 'rb');
|
325 |
-
elseif (isset($input['data']))
|
326 |
-
$rest->data = $input['data'];
|
327 |
-
|
328 |
-
// Content-Length (required)
|
329 |
-
if (isset($input['size']) && $input['size'] >= 0)
|
330 |
-
$rest->size = $input['size'];
|
331 |
-
else {
|
332 |
-
if (isset($input['file']))
|
333 |
-
$rest->size = filesize($input['file']);
|
334 |
-
elseif (isset($input['data']))
|
335 |
-
$rest->size = strlen($input['data']);
|
336 |
-
}
|
337 |
-
|
338 |
-
// Custom request headers (Content-Type, Content-Disposition, Content-Encoding)
|
339 |
-
if (is_array($requestHeaders))
|
340 |
-
foreach ($requestHeaders as $h => $v) $rest->setHeader($h, $v);
|
341 |
-
elseif (is_string($requestHeaders)) // Support for legacy contentType parameter
|
342 |
-
$input['type'] = $requestHeaders;
|
343 |
-
|
344 |
-
// Content-Type
|
345 |
-
if (!isset($input['type'])) {
|
346 |
-
if (isset($requestHeaders['Content-Type']))
|
347 |
-
$input['type'] =& $requestHeaders['Content-Type'];
|
348 |
-
elseif (isset($input['file']))
|
349 |
-
$input['type'] = self::__getMimeType($input['file']);
|
350 |
-
else
|
351 |
-
$input['type'] = 'application/octet-stream';
|
352 |
-
}
|
353 |
-
|
354 |
-
// We need to post with Content-Length and Content-Type, MD5 is optional
|
355 |
-
if ($rest->size >= 0 && ($rest->fp !== false || $rest->data !== false)) {
|
356 |
-
$rest->setHeader('Content-Type', $input['type']);
|
357 |
-
if (isset($input['md5sum'])) $rest->setHeader('Content-MD5', $input['md5sum']);
|
358 |
-
|
359 |
-
$rest->setAmzHeader('x-amz-acl', $acl);
|
360 |
-
foreach ($metaHeaders as $h => $v) $rest->setAmzHeader('x-amz-meta-'.$h, $v);
|
361 |
-
if ($rrs) $rest->setAmzHeader('x-amz-storage-class', 'REDUCED_REDUNDANCY');
|
362 |
-
$rest->getResponse();
|
363 |
-
} else
|
364 |
-
$rest->response->error = array('code' => 0, 'message' => 'Missing input parameters');
|
365 |
-
|
366 |
-
if ($rest->response->error === false && $rest->response->code !== 200)
|
367 |
-
$rest->response->error = array('code' => $rest->response->code, 'message' => 'Unexpected HTTP status');
|
368 |
-
if ($rest->response->error !== false) {
|
369 |
-
trigger_error(sprintf("S3::putObject(): [%s] %s", $rest->response->error['code'], $rest->response->error['message']), E_USER_WARNING);
|
370 |
-
return false;
|
371 |
-
}
|
372 |
-
return true;
|
373 |
-
}
|
374 |
-
|
375 |
-
|
376 |
-
/**
|
377 |
-
* Put an object from a file (legacy function)
|
378 |
-
*
|
379 |
-
* @param string $file Input file path
|
380 |
-
* @param string $bucket Bucket name
|
381 |
-
* @param string $uri Object URI
|
382 |
-
* @param constant $acl ACL constant
|
383 |
-
* @param array $metaHeaders Array of x-amz-meta-* headers
|
384 |
-
* @param string $contentType Content type
|
385 |
-
* @param boolean $rrs put files with REDUCED_REDUNDANCY
|
386 |
-
* @return boolean
|
387 |
-
*/
|
388 |
-
public static function putObjectFile($file, $bucket, $uri, $acl = self::ACL_PRIVATE, $metaHeaders = array(), $contentType = null, $rrs=false) {
|
389 |
-
return self::putObject(self::inputFile($file), $bucket, $uri, $acl, $metaHeaders, $contentType, $rrs);
|
390 |
-
}
|
391 |
-
|
392 |
-
|
393 |
-
/**
|
394 |
-
* Put an object from a string (legacy function)
|
395 |
-
*
|
396 |
-
* @param string $string Input data
|
397 |
-
* @param string $bucket Bucket name
|
398 |
-
* @param string $uri Object URI
|
399 |
-
* @param constant $acl ACL constant
|
400 |
-
* @param array $metaHeaders Array of x-amz-meta-* headers
|
401 |
-
* @param string $contentType Content type
|
402 |
-
* @return boolean
|
403 |
-
*/
|
404 |
-
public static function putObjectString($string, $bucket, $uri, $acl = self::ACL_PRIVATE, $metaHeaders = array(), $contentType = 'text/plain') {
|
405 |
-
return self::putObject($string, $bucket, $uri, $acl, $metaHeaders, $contentType);
|
406 |
-
}
|
407 |
-
|
408 |
-
|
409 |
-
/**
|
410 |
-
* Get an object
|
411 |
-
*
|
412 |
-
* @param string $bucket Bucket name
|
413 |
-
* @param string $uri Object URI
|
414 |
-
* @param mixed $saveTo Filename or resource to write to
|
415 |
-
* @return mixed
|
416 |
-
*/
|
417 |
-
public static function getObject($bucket, $uri, $saveTo = false) {
|
418 |
-
$rest = new S3Request('GET', $bucket, $uri);
|
419 |
-
if ($saveTo !== false) {
|
420 |
-
if (is_resource($saveTo))
|
421 |
-
$rest->fp =& $saveTo;
|
422 |
-
else
|
423 |
-
if (($rest->fp = @fopen($saveTo, 'wb')) !== false)
|
424 |
-
$rest->file = realpath($saveTo);
|
425 |
-
else
|
426 |
-
$rest->response->error = array('code' => 0, 'message' => 'Unable to open save file for writing: '.$saveTo);
|
427 |
-
}
|
428 |
-
if ($rest->response->error === false) $rest->getResponse();
|
429 |
-
|
430 |
-
if ($rest->response->error === false && $rest->response->code !== 200)
|
431 |
-
$rest->response->error = array('code' => $rest->response->code, 'message' => 'Unexpected HTTP status');
|
432 |
-
if ($rest->response->error !== false) {
|
433 |
-
trigger_error(sprintf("S3::getObject({$bucket}, {$uri}): [%s] %s",
|
434 |
-
$rest->response->error['code'], $rest->response->error['message']), E_USER_WARNING);
|
435 |
-
return false;
|
436 |
-
}
|
437 |
-
return $rest->response;
|
438 |
-
}
|
439 |
-
|
440 |
-
|
441 |
-
/**
|
442 |
-
* Get object information
|
443 |
-
*
|
444 |
-
* @param string $bucket Bucket name
|
445 |
-
* @param string $uri Object URI
|
446 |
-
* @param boolean $returnInfo Return response information
|
447 |
-
* @return mixed | false
|
448 |
-
*/
|
449 |
-
public static function getObjectInfo($bucket, $uri, $returnInfo = true) {
|
450 |
-
$rest = new S3Request('HEAD', $bucket, $uri);
|
451 |
-
$rest = $rest->getResponse();
|
452 |
-
if ($rest->error === false && ($rest->code !== 200 && $rest->code !== 404))
|
453 |
-
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
|
454 |
-
if ($rest->error !== false) {
|
455 |
-
trigger_error(sprintf("S3::getObjectInfo({$bucket}, {$uri}): [%s] %s",
|
456 |
-
$rest->error['code'], $rest->error['message']), E_USER_WARNING);
|
457 |
-
return false;
|
458 |
-
}
|
459 |
-
return $rest->code == 200 ? $returnInfo ? $rest->headers : true : false;
|
460 |
-
}
|
461 |
-
|
462 |
-
|
463 |
-
/**
|
464 |
-
* Copy an object
|
465 |
-
*
|
466 |
-
* @param string $bucket Source bucket name
|
467 |
-
* @param string $uri Source object URI
|
468 |
-
* @param string $bucket Destination bucket name
|
469 |
-
* @param string $uri Destination object URI
|
470 |
-
* @param constant $acl ACL constant
|
471 |
-
* @param array $metaHeaders Optional array of x-amz-meta-* headers
|
472 |
-
* @param array $requestHeaders Optional array of request headers (content type, disposition, etc.)
|
473 |
-
* @return mixed | false
|
474 |
-
*/
|
475 |
-
public static function copyObject($srcBucket, $srcUri, $bucket, $uri, $acl = self::ACL_PRIVATE, $metaHeaders = array(), $requestHeaders = array()) {
|
476 |
-
$rest = new S3Request('PUT', $bucket, $uri);
|
477 |
-
$rest->setHeader('Content-Length', 0);
|
478 |
-
foreach ($requestHeaders as $h => $v) $rest->setHeader($h, $v);
|
479 |
-
foreach ($metaHeaders as $h => $v) $rest->setAmzHeader('x-amz-meta-'.$h, $v);
|
480 |
-
$rest->setAmzHeader('x-amz-acl', $acl);
|
481 |
-
$rest->setAmzHeader('x-amz-copy-source', sprintf('/%s/%s', $srcBucket, $srcUri));
|
482 |
-
if (sizeof($requestHeaders) > 0 || sizeof($metaHeaders) > 0)
|
483 |
-
$rest->setAmzHeader('x-amz-metadata-directive', 'REPLACE');
|
484 |
-
$rest = $rest->getResponse();
|
485 |
-
if ($rest->error === false && $rest->code !== 200)
|
486 |
-
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
|
487 |
-
if ($rest->error !== false) {
|
488 |
-
trigger_error(sprintf("S3::copyObject({$srcBucket}, {$srcUri}, {$bucket}, {$uri}): [%s] %s",
|
489 |
-
$rest->error['code'], $rest->error['message']), E_USER_WARNING);
|
490 |
-
return false;
|
491 |
-
}
|
492 |
-
return isset($rest->body->LastModified, $rest->body->ETag) ? array(
|
493 |
-
'time' => strtotime((string)$rest->body->LastModified),
|
494 |
-
'hash' => substr((string)$rest->body->ETag, 1, -1)
|
495 |
-
) : false;
|
496 |
-
}
|
497 |
-
|
498 |
-
|
499 |
-
/**
|
500 |
-
* Set logging for a bucket
|
501 |
-
*
|
502 |
-
* @param string $bucket Bucket name
|
503 |
-
* @param string $targetBucket Target bucket (where logs are stored)
|
504 |
-
* @param string $targetPrefix Log prefix (e,g; domain.com-)
|
505 |
-
* @return boolean
|
506 |
-
*/
|
507 |
-
public static function setBucketLogging($bucket, $targetBucket, $targetPrefix = null) {
|
508 |
-
// The S3 log delivery group has to be added to the target bucket's ACP
|
509 |
-
if ($targetBucket !== null && ($acp = self::getAccessControlPolicy($targetBucket, '')) !== false) {
|
510 |
-
// Only add permissions to the target bucket when they do not exist
|
511 |
-
$aclWriteSet = false;
|
512 |
-
$aclReadSet = false;
|
513 |
-
foreach ($acp['acl'] as $acl)
|
514 |
-
if ($acl['type'] == 'Group' && $acl['uri'] == 'http://acs.amazonaws.com/groups/s3/LogDelivery') {
|
515 |
-
if ($acl['permission'] == 'WRITE') $aclWriteSet = true;
|
516 |
-
elseif ($acl['permission'] == 'READ_ACP') $aclReadSet = true;
|
517 |
-
}
|
518 |
-
if (!$aclWriteSet) $acp['acl'][] = array(
|
519 |
-
'type' => 'Group', 'uri' => 'http://acs.amazonaws.com/groups/s3/LogDelivery', 'permission' => 'WRITE'
|
520 |
-
);
|
521 |
-
if (!$aclReadSet) $acp['acl'][] = array(
|
522 |
-
'type' => 'Group', 'uri' => 'http://acs.amazonaws.com/groups/s3/LogDelivery', 'permission' => 'READ_ACP'
|
523 |
-
);
|
524 |
-
if (!$aclReadSet || !$aclWriteSet) self::setAccessControlPolicy($targetBucket, '', $acp);
|
525 |
-
}
|
526 |
-
|
527 |
-
$dom = new DOMDocument;
|
528 |
-
$bucketLoggingStatus = $dom->createElement('BucketLoggingStatus');
|
529 |
-
$bucketLoggingStatus->setAttribute('xmlns', 'http://s3.amazonaws.com/doc/2006-03-01/');
|
530 |
-
if ($targetBucket !== null) {
|
531 |
-
if ($targetPrefix == null) $targetPrefix = $bucket . '-';
|
532 |
-
$loggingEnabled = $dom->createElement('LoggingEnabled');
|
533 |
-
$loggingEnabled->appendChild($dom->createElement('TargetBucket', $targetBucket));
|
534 |
-
$loggingEnabled->appendChild($dom->createElement('TargetPrefix', $targetPrefix));
|
535 |
-
// TODO: Add TargetGrants?
|
536 |
-
$bucketLoggingStatus->appendChild($loggingEnabled);
|
537 |
-
}
|
538 |
-
$dom->appendChild($bucketLoggingStatus);
|
539 |
-
|
540 |
-
$rest = new S3Request('PUT', $bucket, '');
|
541 |
-
$rest->setParameter('logging', null);
|
542 |
-
$rest->data = $dom->saveXML();
|
543 |
-
$rest->size = strlen($rest->data);
|
544 |
-
$rest->setHeader('Content-Type', 'application/xml');
|
545 |
-
$rest = $rest->getResponse();
|
546 |
-
if ($rest->error === false && $rest->code !== 200)
|
547 |
-
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
|
548 |
-
if ($rest->error !== false) {
|
549 |
-
trigger_error(sprintf("S3::setBucketLogging({$bucket}, {$uri}): [%s] %s",
|
550 |
-
$rest->error['code'], $rest->error['message']), E_USER_WARNING);
|
551 |
-
return false;
|
552 |
-
}
|
553 |
-
return true;
|
554 |
-
}
|
555 |
-
|
556 |
-
|
557 |
-
/**
|
558 |
-
* Get logging status for a bucket
|
559 |
-
*
|
560 |
-
* This will return false if logging is not enabled.
|
561 |
-
* Note: To enable logging, you also need to grant write access to the log group
|
562 |
-
*
|
563 |
-
* @param string $bucket Bucket name
|
564 |
-
* @return array | false
|
565 |
-
*/
|
566 |
-
public static function getBucketLogging($bucket) {
|
567 |
-
$rest = new S3Request('GET', $bucket, '');
|
568 |
-
$rest->setParameter('logging', null);
|
569 |
-
$rest = $rest->getResponse();
|
570 |
-
if ($rest->error === false && $rest->code !== 200)
|
571 |
-
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
|
572 |
-
if ($rest->error !== false) {
|
573 |
-
trigger_error(sprintf("S3::getBucketLogging({$bucket}): [%s] %s",
|
574 |
-
$rest->error['code'], $rest->error['message']), E_USER_WARNING);
|
575 |
-
return false;
|
576 |
-
}
|
577 |
-
if (!isset($rest->body->LoggingEnabled)) return false; // No logging
|
578 |
-
return array(
|
579 |
-
'targetBucket' => (string)$rest->body->LoggingEnabled->TargetBucket,
|
580 |
-
'targetPrefix' => (string)$rest->body->LoggingEnabled->TargetPrefix,
|
581 |
-
);
|
582 |
-
}
|
583 |
-
|
584 |
-
|
585 |
-
/**
|
586 |
-
* Disable bucket logging
|
587 |
-
*
|
588 |
-
* @param string $bucket Bucket name
|
589 |
-
* @return boolean
|
590 |
-
*/
|
591 |
-
public static function disableBucketLogging($bucket) {
|
592 |
-
return self::setBucketLogging($bucket, null);
|
593 |
-
}
|
594 |
-
|
595 |
-
|
596 |
-
/**
|
597 |
-
* Get a bucket's location
|
598 |
-
*
|
599 |
-
* @param string $bucket Bucket name
|
600 |
-
* @return string | false
|
601 |
-
*/
|
602 |
-
public static function getBucketLocation($bucket) {
|
603 |
-
$rest = new S3Request('GET', $bucket, '');
|
604 |
-
$rest->setParameter('location', null);
|
605 |
-
$rest = $rest->getResponse();
|
606 |
-
if ($rest->error === false && $rest->code !== 200)
|
607 |
-
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
|
608 |
-
if ($rest->error !== false) {
|
609 |
-
trigger_error(sprintf("S3::getBucketLocation({$bucket}): [%s] %s",
|
610 |
-
$rest->error['code'], $rest->error['message']), E_USER_WARNING);
|
611 |
-
return false;
|
612 |
-
}
|
613 |
-
return (isset($rest->body[0]) && (string)$rest->body[0] !== '') ? (string)$rest->body[0] : 'US';
|
614 |
-
}
|
615 |
-
|
616 |
-
|
617 |
-
/**
|
618 |
-
* Set object or bucket Access Control Policy
|
619 |
-
*
|
620 |
-
* @param string $bucket Bucket name
|
621 |
-
* @param string $uri Object URI
|
622 |
-
* @param array $acp Access Control Policy Data (same as the data returned from getAccessControlPolicy)
|
623 |
-
* @return boolean
|
624 |
-
*/
|
625 |
-
public static function setAccessControlPolicy($bucket, $uri = '', $acp = array()) {
|
626 |
-
$dom = new DOMDocument;
|
627 |
-
$dom->formatOutput = true;
|
628 |
-
$accessControlPolicy = $dom->createElement('AccessControlPolicy');
|
629 |
-
$accessControlList = $dom->createElement('AccessControlList');
|
630 |
-
|
631 |
-
// It seems the owner has to be passed along too
|
632 |
-
$owner = $dom->createElement('Owner');
|
633 |
-
$owner->appendChild($dom->createElement('ID', $acp['owner']['id']));
|
634 |
-
$owner->appendChild($dom->createElement('DisplayName', $acp['owner']['name']));
|
635 |
-
$accessControlPolicy->appendChild($owner);
|
636 |
-
|
637 |
-
foreach ($acp['acl'] as $g) {
|
638 |
-
$grant = $dom->createElement('Grant');
|
639 |
-
$grantee = $dom->createElement('Grantee');
|
640 |
-
$grantee->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
|
641 |
-
if (isset($g['id'])) { // CanonicalUser (DisplayName is omitted)
|
642 |
-
$grantee->setAttribute('xsi:type', 'CanonicalUser');
|
643 |
-
$grantee->appendChild($dom->createElement('ID', $g['id']));
|
644 |
-
} elseif (isset($g['email'])) { // AmazonCustomerByEmail
|
645 |
-
$grantee->setAttribute('xsi:type', 'AmazonCustomerByEmail');
|
646 |
-
$grantee->appendChild($dom->createElement('EmailAddress', $g['email']));
|
647 |
-
} elseif ($g['type'] == 'Group') { // Group
|
648 |
-
$grantee->setAttribute('xsi:type', 'Group');
|
649 |
-
$grantee->appendChild($dom->createElement('URI', $g['uri']));
|
650 |
-
}
|
651 |
-
$grant->appendChild($grantee);
|
652 |
-
$grant->appendChild($dom->createElement('Permission', $g['permission']));
|
653 |
-
$accessControlList->appendChild($grant);
|
654 |
-
}
|
655 |
-
|
656 |
-
$accessControlPolicy->appendChild($accessControlList);
|
657 |
-
$dom->appendChild($accessControlPolicy);
|
658 |
-
|
659 |
-
$rest = new S3Request('PUT', $bucket, $uri);
|
660 |
-
$rest->setParameter('acl', null);
|
661 |
-
$rest->data = $dom->saveXML();
|
662 |
-
$rest->size = strlen($rest->data);
|
663 |
-
$rest->setHeader('Content-Type', 'application/xml');
|
664 |
-
$rest = $rest->getResponse();
|
665 |
-
if ($rest->error === false && $rest->code !== 200)
|
666 |
-
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
|
667 |
-
if ($rest->error !== false) {
|
668 |
-
trigger_error(sprintf("S3::setAccessControlPolicy({$bucket}, {$uri}): [%s] %s",
|
669 |
-
$rest->error['code'], $rest->error['message']), E_USER_WARNING);
|
670 |
-
return false;
|
671 |
-
}
|
672 |
-
return true;
|
673 |
-
}
|
674 |
-
|
675 |
-
|
676 |
-
/**
|
677 |
-
* Get object or bucket Access Control Policy
|
678 |
-
*
|
679 |
-
* @param string $bucket Bucket name
|
680 |
-
* @param string $uri Object URI
|
681 |
-
* @return mixed | false
|
682 |
-
*/
|
683 |
-
public static function getAccessControlPolicy($bucket, $uri = '') {
|
684 |
-
$rest = new S3Request('GET', $bucket, $uri);
|
685 |
-
$rest->setParameter('acl', null);
|
686 |
-
$rest = $rest->getResponse();
|
687 |
-
if ($rest->error === false && $rest->code !== 200)
|
688 |
-
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
|
689 |
-
if ($rest->error !== false) {
|
690 |
-
trigger_error(sprintf("S3::getAccessControlPolicy({$bucket}, {$uri}): [%s] %s",
|
691 |
-
$rest->error['code'], $rest->error['message']), E_USER_WARNING);
|
692 |
-
return false;
|
693 |
-
}
|
694 |
-
|
695 |
-
$acp = array();
|
696 |
-
if (isset($rest->body->Owner, $rest->body->Owner->ID, $rest->body->Owner->DisplayName)) {
|
697 |
-
$acp['owner'] = array(
|
698 |
-
'id' => (string)$rest->body->Owner->ID, 'name' => (string)$rest->body->Owner->DisplayName
|
699 |
-
);
|
700 |
-
}
|
701 |
-
if (isset($rest->body->AccessControlList)) {
|
702 |
-
$acp['acl'] = array();
|
703 |
-
foreach ($rest->body->AccessControlList->Grant as $grant) {
|
704 |
-
foreach ($grant->Grantee as $grantee) {
|
705 |
-
if (isset($grantee->ID, $grantee->DisplayName)) // CanonicalUser
|
706 |
-
$acp['acl'][] = array(
|
707 |
-
'type' => 'CanonicalUser',
|
708 |
-
'id' => (string)$grantee->ID,
|
709 |
-
'name' => (string)$grantee->DisplayName,
|
710 |
-
'permission' => (string)$grant->Permission
|
711 |
-
);
|
712 |
-
elseif (isset($grantee->EmailAddress)) // AmazonCustomerByEmail
|
713 |
-
$acp['acl'][] = array(
|
714 |
-
'type' => 'AmazonCustomerByEmail',
|
715 |
-
'email' => (string)$grantee->EmailAddress,
|
716 |
-
'permission' => (string)$grant->Permission
|
717 |
-
);
|
718 |
-
elseif (isset($grantee->URI)) // Group
|
719 |
-
$acp['acl'][] = array(
|
720 |
-
'type' => 'Group',
|
721 |
-
'uri' => (string)$grantee->URI,
|
722 |
-
'permission' => (string)$grant->Permission
|
723 |
-
);
|
724 |
-
else continue;
|
725 |
-
}
|
726 |
-
}
|
727 |
-
}
|
728 |
-
return $acp;
|
729 |
-
}
|
730 |
-
|
731 |
-
|
732 |
-
/**
|
733 |
-
* Delete an object
|
734 |
-
*
|
735 |
-
* @param string $bucket Bucket name
|
736 |
-
* @param string $uri Object URI
|
737 |
-
* @return boolean
|
738 |
-
*/
|
739 |
-
public static function deleteObject($bucket, $uri) {
|
740 |
-
$rest = new S3Request('DELETE', $bucket, $uri);
|
741 |
-
$rest = $rest->getResponse();
|
742 |
-
if ($rest->error === false && $rest->code !== 204)
|
743 |
-
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
|
744 |
-
if ($rest->error !== false) {
|
745 |
-
trigger_error(sprintf("S3::deleteObject(): [%s] %s",
|
746 |
-
$rest->error['code'], $rest->error['message']), E_USER_WARNING);
|
747 |
-
return false;
|
748 |
-
}
|
749 |
-
return true;
|
750 |
-
}
|
751 |
-
|
752 |
-
|
753 |
-
/**
|
754 |
-
* Get a query string authenticated URL
|
755 |
-
*
|
756 |
-
* @param string $bucket Bucket name
|
757 |
-
* @param string $uri Object URI
|
758 |
-
* @param integer $lifetime Lifetime in seconds
|
759 |
-
* @param boolean $hostBucket Use the bucket name as the hostname
|
760 |
-
* @param boolean $https Use HTTPS ($hostBucket should be false for SSL verification)
|
761 |
-
* @return string
|
762 |
-
*/
|
763 |
-
public static function getAuthenticatedURL($bucket, $uri, $lifetime, $hostBucket = false, $https = false) {
|
764 |
-
$expires = time() + $lifetime;
|
765 |
-
$uri = str_replace('%2F', '/', rawurlencode($uri)); // URI should be encoded (thanks Sean O'Dea)
|
766 |
-
return sprintf(($https ? 'https' : 'http').'://%s/%s?AWSAccessKeyId=%s&Expires=%u&Signature=%s',
|
767 |
-
$hostBucket ? $bucket : $bucket.'.s3.amazonaws.com', $uri, self::$__accessKey, $expires,
|
768 |
-
urlencode(self::__getHash("GET\n\n\n{$expires}\n/{$bucket}/{$uri}")));
|
769 |
-
}
|
770 |
-
|
771 |
-
/**
|
772 |
-
* Get upload POST parameters for form uploads
|
773 |
-
*
|
774 |
-
* @param string $bucket Bucket name
|
775 |
-
* @param string $uriPrefix Object URI prefix
|
776 |
-
* @param constant $acl ACL constant
|
777 |
-
* @param integer $lifetime Lifetime in seconds
|
778 |
-
* @param integer $maxFileSize Maximum filesize in bytes (default 5MB)
|
779 |
-
* @param string $successRedirect Redirect URL or 200 / 201 status code
|
780 |
-
* @param array $amzHeaders Array of x-amz-meta-* headers
|
781 |
-
* @param array $headers Array of request headers or content type as a string
|
782 |
-
* @param boolean $flashVars Includes additional "Filename" variable posted by Flash
|
783 |
-
* @return object
|
784 |
-
*/
|
785 |
-
public static function getHttpUploadPostParams($bucket, $uriPrefix = '', $acl = self::ACL_PRIVATE, $lifetime = 3600, $maxFileSize = 5242880, $successRedirect = "201", $amzHeaders = array(), $headers = array(), $flashVars = false) {
|
786 |
-
// Create policy object
|
787 |
-
$policy = new stdClass;
|
788 |
-
$policy->expiration = gmdate('Y-m-d\TH:i:s\Z', (time() + $lifetime));
|
789 |
-
$policy->conditions = array();
|
790 |
-
$obj = new stdClass; $obj->bucket = $bucket; array_push($policy->conditions, $obj);
|
791 |
-
$obj = new stdClass; $obj->acl = $acl; array_push($policy->conditions, $obj);
|
792 |
-
|
793 |
-
$obj = new stdClass; // 200 for non-redirect uploads
|
794 |
-
if (is_numeric($successRedirect) && in_array((int)$successRedirect, array(200, 201)))
|
795 |
-
$obj->success_action_status = (string)$successRedirect;
|
796 |
-
else // URL
|
797 |
-
$obj->success_action_redirect = $successRedirect;
|
798 |
-
array_push($policy->conditions, $obj);
|
799 |
-
|
800 |
-
array_push($policy->conditions, array('starts-with', '$key', $uriPrefix));
|
801 |
-
if ($flashVars) array_push($policy->conditions, array('starts-with', '$Filename', ''));
|
802 |
-
foreach (array_keys($headers) as $headerKey)
|
803 |
-
array_push($policy->conditions, array('starts-with', '$'.$headerKey, ''));
|
804 |
-
foreach ($amzHeaders as $headerKey => $headerVal) {
|
805 |
-
$obj = new stdClass; $obj->{$headerKey} = (string)$headerVal; array_push($policy->conditions, $obj);
|
806 |
-
}
|
807 |
-
array_push($policy->conditions, array('content-length-range', 0, $maxFileSize));
|
808 |
-
$policy = base64_encode(str_replace('\/', '/', json_encode($policy)));
|
809 |
-
|
810 |
-
// Create parameters
|
811 |
-
$params = new stdClass;
|
812 |
-
$params->AWSAccessKeyId = self::$__accessKey;
|
813 |
-
$params->key = $uriPrefix.'${filename}';
|
814 |
-
$params->acl = $acl;
|
815 |
-
$params->policy = $policy; unset($policy);
|
816 |
-
$params->signature = self::__getHash($params->policy);
|
817 |
-
if (is_numeric($successRedirect) && in_array((int)$successRedirect, array(200, 201)))
|
818 |
-
$params->success_action_status = (string)$successRedirect;
|
819 |
-
else
|
820 |
-
$params->success_action_redirect = $successRedirect;
|
821 |
-
foreach ($headers as $headerKey => $headerVal) $params->{$headerKey} = (string)$headerVal;
|
822 |
-
foreach ($amzHeaders as $headerKey => $headerVal) $params->{$headerKey} = (string)$headerVal;
|
823 |
-
return $params;
|
824 |
-
}
|
825 |
-
|
826 |
-
/**
|
827 |
-
* Create a CloudFront distribution
|
828 |
-
*
|
829 |
-
* @param string $bucket Bucket name
|
830 |
-
* @param boolean $enabled Enabled (true/false)
|
831 |
-
* @param array $cnames Array containing CNAME aliases
|
832 |
-
* @param string $comment Use the bucket name as the hostname
|
833 |
-
* @return array | false
|
834 |
-
*/
|
835 |
-
public static function createDistribution($bucket, $enabled = true, $cnames = array(), $comment = '') {
|
836 |
-
self::$useSSL = true; // CloudFront requires SSL
|
837 |
-
$rest = new S3Request('POST', '', '2008-06-30/distribution', 'cloudfront.amazonaws.com');
|
838 |
-
$rest->data = self::__getCloudFrontDistributionConfigXML($bucket.'.s3.amazonaws.com', $enabled, $comment, (string)microtime(true), $cnames);
|
839 |
-
$rest->size = strlen($rest->data);
|
840 |
-
$rest->setHeader('Content-Type', 'application/xml');
|
841 |
-
$rest = self::__getCloudFrontResponse($rest);
|
842 |
-
|
843 |
-
if ($rest->error === false && $rest->code !== 201)
|
844 |
-
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
|
845 |
-
if ($rest->error !== false) {
|
846 |
-
trigger_error(sprintf("S3::createDistribution({$bucket}, ".(int)$enabled.", '$comment'): [%s] %s",
|
847 |
-
$rest->error['code'], $rest->error['message']), E_USER_WARNING);
|
848 |
-
return false;
|
849 |
-
} elseif ($rest->body instanceof SimpleXMLElement)
|
850 |
-
return self::__parseCloudFrontDistributionConfig($rest->body);
|
851 |
-
return false;
|
852 |
-
}
|
853 |
-
|
854 |
-
|
855 |
-
/**
|
856 |
-
* Get CloudFront distribution info
|
857 |
-
*
|
858 |
-
* @param string $distributionId Distribution ID from listDistributions()
|
859 |
-
* @return array | false
|
860 |
-
*/
|
861 |
-
public static function getDistribution($distributionId) {
|
862 |
-
self::$useSSL = true; // CloudFront requires SSL
|
863 |
-
$rest = new S3Request('GET', '', '2008-06-30/distribution/'.$distributionId, 'cloudfront.amazonaws.com');
|
864 |
-
$rest = self::__getCloudFrontResponse($rest);
|
865 |
-
|
866 |
-
if ($rest->error === false && $rest->code !== 200)
|
867 |
-
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
|
868 |
-
if ($rest->error !== false) {
|
869 |
-
trigger_error(sprintf("S3::getDistribution($distributionId): [%s] %s",
|
870 |
-
$rest->error['code'], $rest->error['message']), E_USER_WARNING);
|
871 |
-
return false;
|
872 |
-
} elseif ($rest->body instanceof SimpleXMLElement) {
|
873 |
-
$dist = self::__parseCloudFrontDistributionConfig($rest->body);
|
874 |
-
$dist['hash'] = $rest->headers['hash'];
|
875 |
-
return $dist;
|
876 |
-
}
|
877 |
-
return false;
|
878 |
-
}
|
879 |
-
|
880 |
-
|
881 |
-
/**
|
882 |
-
* Update a CloudFront distribution
|
883 |
-
*
|
884 |
-
* @param array $dist Distribution array info identical to output of getDistribution()
|
885 |
-
* @return array | false
|
886 |
-
*/
|
887 |
-
public static function updateDistribution($dist) {
|
888 |
-
self::$useSSL = true; // CloudFront requires SSL
|
889 |
-
$rest = new S3Request('PUT', '', '2008-06-30/distribution/'.$dist['id'].'/config', 'cloudfront.amazonaws.com');
|
890 |
-
$rest->data = self::__getCloudFrontDistributionConfigXML($dist['origin'], $dist['enabled'], $dist['comment'], $dist['callerReference'], $dist['cnames']);
|
891 |
-
$rest->size = strlen($rest->data);
|
892 |
-
$rest->setHeader('If-Match', $dist['hash']);
|
893 |
-
$rest = self::__getCloudFrontResponse($rest);
|
894 |
-
|
895 |
-
if ($rest->error === false && $rest->code !== 200)
|
896 |
-
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
|
897 |
-
if ($rest->error !== false) {
|
898 |
-
trigger_error(sprintf("S3::updateDistribution({$dist['id']}, ".(int)$enabled.", '$comment'): [%s] %s",
|
899 |
-
$rest->error['code'], $rest->error['message']), E_USER_WARNING);
|
900 |
-
return false;
|
901 |
-
} else {
|
902 |
-
$dist = self::__parseCloudFrontDistributionConfig($rest->body);
|
903 |
-
$dist['hash'] = $rest->headers['hash'];
|
904 |
-
return $dist;
|
905 |
-
}
|
906 |
-
return false;
|
907 |
-
}
|
908 |
-
|
909 |
-
|
910 |
-
/**
|
911 |
-
* Delete a CloudFront distribution
|
912 |
-
*
|
913 |
-
* @param array $dist Distribution array info identical to output of getDistribution()
|
914 |
-
* @return boolean
|
915 |
-
*/
|
916 |
-
public static function deleteDistribution($dist) {
|
917 |
-
self::$useSSL = true; // CloudFront requires SSL
|
918 |
-
$rest = new S3Request('DELETE', '', '2008-06-30/distribution/'.$dist['id'], 'cloudfront.amazonaws.com');
|
919 |
-
$rest->setHeader('If-Match', $dist['hash']);
|
920 |
-
$rest = self::__getCloudFrontResponse($rest);
|
921 |
-
|
922 |
-
if ($rest->error === false && $rest->code !== 204)
|
923 |
-
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
|
924 |
-
if ($rest->error !== false) {
|
925 |
-
trigger_error(sprintf("S3::deleteDistribution({$dist['id']}): [%s] %s",
|
926 |
-
$rest->error['code'], $rest->error['message']), E_USER_WARNING);
|
927 |
-
return false;
|
928 |
-
}
|
929 |
-
return true;
|
930 |
-
}
|
931 |
-
|
932 |
-
|
933 |
-
/**
|
934 |
-
* Get a list of CloudFront distributions
|
935 |
-
*
|
936 |
-
* @return array
|
937 |
-
*/
|
938 |
-
public static function listDistributions() {
|
939 |
-
self::$useSSL = true; // CloudFront requires SSL
|
940 |
-
$rest = new S3Request('GET', '', '2008-06-30/distribution', 'cloudfront.amazonaws.com');
|
941 |
-
$rest = self::__getCloudFrontResponse($rest);
|
942 |
-
|
943 |
-
if ($rest->error === false && $rest->code !== 200)
|
944 |
-
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
|
945 |
-
if ($rest->error !== false) {
|
946 |
-
trigger_error(sprintf("S3::listDistributions(): [%s] %s",
|
947 |
-
$rest->error['code'], $rest->error['message']), E_USER_WARNING);
|
948 |
-
return false;
|
949 |
-
} elseif ($rest->body instanceof SimpleXMLElement && isset($rest->body->DistributionSummary)) {
|
950 |
-
$list = array();
|
951 |
-
if (isset($rest->body->Marker, $rest->body->MaxItems, $rest->body->IsTruncated)) {
|
952 |
-
//$info['marker'] = (string)$rest->body->Marker;
|
953 |
-
//$info['maxItems'] = (int)$rest->body->MaxItems;
|
954 |
-
//$info['isTruncated'] = (string)$rest->body->IsTruncated == 'true' ? true : false;
|
955 |
-
}
|
956 |
-
foreach ($rest->body->DistributionSummary as $summary) {
|
957 |
-
$list[(string)$summary->Id] = self::__parseCloudFrontDistributionConfig($summary);
|
958 |
-
}
|
959 |
-
return $list;
|
960 |
-
}
|
961 |
-
return array();
|
962 |
-
}
|
963 |
-
|
964 |
-
|
965 |
-
/**
|
966 |
-
* Get a DistributionConfig DOMDocument
|
967 |
-
*
|
968 |
-
* @internal Used to create XML in createDistribution() and updateDistribution()
|
969 |
-
* @param string $bucket Origin bucket
|
970 |
-
* @param boolean $enabled Enabled (true/false)
|
971 |
-
* @param string $comment Comment to append
|
972 |
-
* @param string $callerReference Caller reference
|
973 |
-
* @param array $cnames Array of CNAME aliases
|
974 |
-
* @return string
|
975 |
-
*/
|
976 |
-
private static function __getCloudFrontDistributionConfigXML($bucket, $enabled, $comment, $callerReference = '0', $cnames = array()) {
|
977 |
-
$dom = new DOMDocument('1.0', 'UTF-8');
|
978 |
-
$dom->formatOutput = true;
|
979 |
-
$distributionConfig = $dom->createElement('DistributionConfig');
|
980 |
-
$distributionConfig->setAttribute('xmlns', 'http://cloudfront.amazonaws.com/doc/2008-06-30/');
|
981 |
-
$distributionConfig->appendChild($dom->createElement('Origin', $bucket));
|
982 |
-
$distributionConfig->appendChild($dom->createElement('CallerReference', $callerReference));
|
983 |
-
foreach ($cnames as $cname)
|
984 |
-
$distributionConfig->appendChild($dom->createElement('CNAME', $cname));
|
985 |
-
if ($comment !== '') $distributionConfig->appendChild($dom->createElement('Comment', $comment));
|
986 |
-
$distributionConfig->appendChild($dom->createElement('Enabled', $enabled ? 'true' : 'false'));
|
987 |
-
$dom->appendChild($distributionConfig);
|
988 |
-
return $dom->saveXML();
|
989 |
-
}
|
990 |
-
|
991 |
-
|
992 |
-
/**
|
993 |
-
* Parse a CloudFront distribution config
|
994 |
-
*
|
995 |
-
* @internal Used to parse the CloudFront DistributionConfig node to an array
|
996 |
-
* @param object &$node DOMNode
|
997 |
-
* @return array
|
998 |
-
*/
|
999 |
-
private static function __parseCloudFrontDistributionConfig(&$node) {
|
1000 |
-
$dist = array();
|
1001 |
-
if (isset($node->Id, $node->Status, $node->LastModifiedTime, $node->DomainName)) {
|
1002 |
-
$dist['id'] = (string)$node->Id;
|
1003 |
-
$dist['status'] = (string)$node->Status;
|
1004 |
-
$dist['time'] = strtotime((string)$node->LastModifiedTime);
|
1005 |
-
$dist['domain'] = (string)$node->DomainName;
|
1006 |
-
}
|
1007 |
-
if (isset($node->CallerReference))
|
1008 |
-
$dist['callerReference'] = (string)$node->CallerReference;
|
1009 |
-
if (isset($node->Comment))
|
1010 |
-
$dist['comment'] = (string)$node->Comment;
|
1011 |
-
if (isset($node->Enabled, $node->Origin)) {
|
1012 |
-
$dist['origin'] = (string)$node->Origin;
|
1013 |
-
$dist['enabled'] = (string)$node->Enabled == 'true' ? true : false;
|
1014 |
-
} elseif (isset($node->DistributionConfig)) {
|
1015 |
-
$dist = array_merge($dist, self::__parseCloudFrontDistributionConfig($node->DistributionConfig));
|
1016 |
-
}
|
1017 |
-
if (isset($node->CNAME)) {
|
1018 |
-
$dist['cnames'] = array();
|
1019 |
-
foreach ($node->CNAME as $cname) $dist['cnames'][(string)$cname] = (string)$cname;
|
1020 |
-
}
|
1021 |
-
return $dist;
|
1022 |
-
}
|
1023 |
-
|
1024 |
-
|
1025 |
-
/**
|
1026 |
-
* Grab CloudFront response
|
1027 |
-
*
|
1028 |
-
* @internal Used to parse the CloudFront S3Request::getResponse() output
|
1029 |
-
* @param object &$rest S3Request instance
|
1030 |
-
* @return object
|
1031 |
-
*/
|
1032 |
-
private static function __getCloudFrontResponse(&$rest) {
|
1033 |
-
$rest->getResponse();
|
1034 |
-
if ($rest->response->error === false && isset($rest->response->body) &&
|
1035 |
-
is_string($rest->response->body) && substr($rest->response->body, 0, 5) == '<?xml') {
|
1036 |
-
$rest->response->body = simplexml_load_string($rest->response->body);
|
1037 |
-
// Grab CloudFront errors
|
1038 |
-
if (isset($rest->response->body->Error, $rest->response->body->Error->Code,
|
1039 |
-
$rest->response->body->Error->Message)) {
|
1040 |
-
$rest->response->error = array(
|
1041 |
-
'code' => (string)$rest->response->body->Error->Code,
|
1042 |
-
'message' => (string)$rest->response->body->Error->Message
|
1043 |
-
);
|
1044 |
-
unset($rest->response->body);
|
1045 |
-
}
|
1046 |
-
}
|
1047 |
-
return $rest->response;
|
1048 |
-
}
|
1049 |
-
|
1050 |
-
|
1051 |
-
/**
|
1052 |
-
* Get MIME type for file
|
1053 |
-
*
|
1054 |
-
* @internal Used to get mime types
|
1055 |
-
* @param string &$file File path
|
1056 |
-
* @return string
|
1057 |
-
*/
|
1058 |
-
public static function __getMimeType(&$file) {
|
1059 |
-
$type = false;
|
1060 |
-
// Fileinfo documentation says fileinfo_open() will use the
|
1061 |
-
// MAGIC env var for the magic file
|
1062 |
-
if (extension_loaded('fileinfo') && isset($_ENV['MAGIC']) &&
|
1063 |
-
($finfo = finfo_open(FILEINFO_MIME, $_ENV['MAGIC'])) !== false) {
|
1064 |
-
if (($type = finfo_file($finfo, $file)) !== false) {
|
1065 |
-
// Remove the charset and grab the last content-type
|
1066 |
-
$type = explode(' ', str_replace('; charset=', ';charset=', $type));
|
1067 |
-
$type = array_pop($type);
|
1068 |
-
$type = explode(';', $type);
|
1069 |
-
$type = trim(array_shift($type));
|
1070 |
-
}
|
1071 |
-
finfo_close($finfo);
|
1072 |
-
|
1073 |
-
// If anyone is still using mime_content_type()
|
1074 |
-
} elseif (function_exists('mime_content_type'))
|
1075 |
-
$type = trim(mime_content_type($file));
|
1076 |
-
|
1077 |
-
if ($type !== false && strlen($type) > 0) return $type;
|
1078 |
-
|
1079 |
-
// Otherwise do it the old fashioned way
|
1080 |
-
static $exts = array(
|
1081 |
-
'jpg' => 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png',
|
1082 |
-
'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'ico' => 'image/x-icon',
|
1083 |
-
'swf' => 'application/x-shockwave-flash', 'pdf' => 'application/pdf',
|
1084 |
-
'zip' => 'application/zip', 'gz' => 'application/x-gzip',
|
1085 |
-
'tar' => 'application/x-tar', 'bz' => 'application/x-bzip',
|
1086 |
-
'bz2' => 'application/x-bzip2', 'txt' => 'text/plain',
|
1087 |
-
'asc' => 'text/plain', 'htm' => 'text/html', 'html' => 'text/html',
|
1088 |
-
'css' => 'text/css', 'js' => 'text/javascript',
|
1089 |
-
'xml' => 'text/xml', 'xsl' => 'application/xsl+xml',
|
1090 |
-
'ogg' => 'application/ogg', 'mp3' => 'audio/mpeg', 'wav' => 'audio/x-wav',
|
1091 |
-
'avi' => 'video/x-msvideo', 'mpg' => 'video/mpeg', 'mpeg' => 'video/mpeg',
|
1092 |
-
'mov' => 'video/quicktime', 'flv' => 'video/x-flv', 'php' => 'text/x-php'
|
1093 |
-
);
|
1094 |
-
$ext = strtolower(pathInfo($file, PATHINFO_EXTENSION));
|
1095 |
-
return isset($exts[$ext]) ? $exts[$ext] : 'application/octet-stream';
|
1096 |
-
}
|
1097 |
-
|
1098 |
-
|
1099 |
-
/**
|
1100 |
-
* Generate the auth string: "AWS AccessKey:Signature"
|
1101 |
-
*
|
1102 |
-
* @internal Used by S3Request::getResponse()
|
1103 |
-
* @param string $string String to sign
|
1104 |
-
* @return string
|
1105 |
-
*/
|
1106 |
-
public static function __getSignature($string) {
|
1107 |
-
return 'AWS '.self::$__accessKey.':'.self::__getHash($string);
|
1108 |
-
}
|
1109 |
-
|
1110 |
-
|
1111 |
-
/**
|
1112 |
-
* Creates a HMAC-SHA1 hash
|
1113 |
-
*
|
1114 |
-
* This uses the hash extension if loaded
|
1115 |
-
*
|
1116 |
-
* @internal Used by __getSignature()
|
1117 |
-
* @param string $string String to sign
|
1118 |
-
* @return string
|
1119 |
-
*/
|
1120 |
-
private static function __getHash($string) {
|
1121 |
-
return base64_encode(extension_loaded('hash') ?
|
1122 |
-
hash_hmac('sha1', $string, self::$__secretKey, true) : pack('H*', sha1(
|
1123 |
-
(str_pad(self::$__secretKey, 64, chr(0x00)) ^ (str_repeat(chr(0x5c), 64))) .
|
1124 |
-
pack('H*', sha1((str_pad(self::$__secretKey, 64, chr(0x00)) ^
|
1125 |
-
(str_repeat(chr(0x36), 64))) . $string)))));
|
1126 |
-
}
|
1127 |
-
|
1128 |
-
}
|
1129 |
-
|
1130 |
-
final class S3Request {
|
1131 |
-
private $verb, $bucket, $uri, $resource = '', $parameters = array(),
|
1132 |
-
$amzHeaders = array(), $headers = array(
|
1133 |
-
'Host' => '', 'Date' => '', 'Content-MD5' => '', 'Content-Type' => ''
|
1134 |
-
);
|
1135 |
-
public $fp = false, $size = 0, $data = false, $response;
|
1136 |
-
|
1137 |
-
|
1138 |
-
/**
|
1139 |
-
* Constructor
|
1140 |
-
*
|
1141 |
-
* @param string $verb Verb
|
1142 |
-
* @param string $bucket Bucket name
|
1143 |
-
* @param string $uri Object URI
|
1144 |
-
* @return mixed
|
1145 |
-
*/
|
1146 |
-
function __construct($verb, $bucket = '', $uri = '', $defaultHost = 's3.amazonaws.com') {
|
1147 |
-
$this->verb = $verb;
|
1148 |
-
$this->bucket = strtolower($bucket);
|
1149 |
-
$this->uri = $uri !== '' ? '/'.str_replace('%2F', '/', rawurlencode($uri)) : '/';
|
1150 |
-
|
1151 |
-
if ($this->bucket !== '') {
|
1152 |
-
$this->headers['Host'] = $this->bucket.'.'.$defaultHost;
|
1153 |
-
$this->resource = '/'.$this->bucket.$this->uri;
|
1154 |
-
} else {
|
1155 |
-
$this->headers['Host'] = $defaultHost;
|
1156 |
-
//$this->resource = strlen($this->uri) > 1 ? '/'.$this->bucket.$this->uri : $this->uri;
|
1157 |
-
$this->resource = $this->uri;
|
1158 |
-
}
|
1159 |
-
$this->headers['Date'] = gmdate('D, d M Y H:i:s T');
|
1160 |
-
|
1161 |
-
$this->response = new STDClass;
|
1162 |
-
$this->response->error = false;
|
1163 |
-
}
|
1164 |
-
|
1165 |
-
|
1166 |
-
/**
|
1167 |
-
* Set request parameter
|
1168 |
-
*
|
1169 |
-
* @param string $key Key
|
1170 |
-
* @param string $value Value
|
1171 |
-
* @return void
|
1172 |
-
*/
|
1173 |
-
public function setParameter($key, $value) {
|
1174 |
-
$this->parameters[$key] = $value;
|
1175 |
-
}
|
1176 |
-
|
1177 |
-
|
1178 |
-
/**
|
1179 |
-
* Set request header
|
1180 |
-
*
|
1181 |
-
* @param string $key Key
|
1182 |
-
* @param string $value Value
|
1183 |
-
* @return void
|
1184 |
-
*/
|
1185 |
-
public function setHeader($key, $value) {
|
1186 |
-
$this->headers[$key] = $value;
|
1187 |
-
}
|
1188 |
-
|
1189 |
-
|
1190 |
-
/**
|
1191 |
-
* Set x-amz-meta-* header
|
1192 |
-
*
|
1193 |
-
* @param string $key Key
|
1194 |
-
* @param string $value Value
|
1195 |
-
* @return void
|
1196 |
-
*/
|
1197 |
-
public function setAmzHeader($key, $value) {
|
1198 |
-
$this->amzHeaders[$key] = $value;
|
1199 |
-
}
|
1200 |
-
|
1201 |
-
|
1202 |
-
/**
|
1203 |
-
* Get the S3 response
|
1204 |
-
*
|
1205 |
-
* @return object | false
|
1206 |
-
*/
|
1207 |
-
public function getResponse() {
|
1208 |
-
$query = '';
|
1209 |
-
if (sizeof($this->parameters) > 0) {
|
1210 |
-
$query = substr($this->uri, -1) !== '?' ? '?' : '&';
|
1211 |
-
foreach ($this->parameters as $var => $value)
|
1212 |
-
if ($value == null || $value == '') $query .= $var.'&';
|
1213 |
-
// Parameters should be encoded (thanks Sean O'Dea)
|
1214 |
-
else $query .= $var.'='.rawurlencode($value).'&';
|
1215 |
-
$query = substr($query, 0, -1);
|
1216 |
-
$this->uri .= $query;
|
1217 |
-
|
1218 |
-
if (array_key_exists('acl', $this->parameters) ||
|
1219 |
-
array_key_exists('location', $this->parameters) ||
|
1220 |
-
array_key_exists('torrent', $this->parameters) ||
|
1221 |
-
array_key_exists('logging', $this->parameters))
|
1222 |
-
$this->resource .= $query;
|
1223 |
-
}
|
1224 |
-
$url = ((S3::$useSSL && extension_loaded('openssl')) ?
|
1225 |
-
'https://':'http://').$this->headers['Host'].$this->uri;
|
1226 |
-
//var_dump($this->bucket, $this->uri, $this->resource, $url);
|
1227 |
-
|
1228 |
-
// Basic setup
|
1229 |
-
$curl = curl_init();
|
1230 |
-
curl_setopt($curl, CURLOPT_USERAGENT, 'S3/php');
|
1231 |
-
|
1232 |
-
if (S3::$useSSL) {
|
1233 |
-
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);
|
1234 |
-
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 1);
|
1235 |
-
}
|
1236 |
-
|
1237 |
-
curl_setopt($curl, CURLOPT_URL, $url);
|
1238 |
-
|
1239 |
-
// Headers
|
1240 |
-
$headers = array(); $amz = array();
|
1241 |
-
foreach ($this->amzHeaders as $header => $value)
|
1242 |
-
if (strlen($value) > 0) $headers[] = $header.': '.$value;
|
1243 |
-
foreach ($this->headers as $header => $value)
|
1244 |
-
if (strlen($value) > 0) $headers[] = $header.': '.$value;
|
1245 |
-
|
1246 |
-
// Collect AMZ headers for signature
|
1247 |
-
foreach ($this->amzHeaders as $header => $value)
|
1248 |
-
if (strlen($value) > 0) $amz[] = strtolower($header).':'.$value;
|
1249 |
-
|
1250 |
-
// AMZ headers must be sorted
|
1251 |
-
if (sizeof($amz) > 0) {
|
1252 |
-
sort($amz);
|
1253 |
-
$amz = "\n".implode("\n", $amz);
|
1254 |
-
} else $amz = '';
|
1255 |
-
|
1256 |
-
// Authorization string (CloudFront stringToSign should only contain a date)
|
1257 |
-
$headers[] = 'Authorization: ' . S3::__getSignature(
|
1258 |
-
$this->headers['Host'] == 'cloudfront.amazonaws.com' ? $this->headers['Date'] :
|
1259 |
-
$this->verb."\n".$this->headers['Content-MD5']."\n".
|
1260 |
-
$this->headers['Content-Type']."\n".$this->headers['Date'].$amz."\n".$this->resource
|
1261 |
-
);
|
1262 |
-
|
1263 |
-
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
1264 |
-
curl_setopt($curl, CURLOPT_HEADER, false);
|
1265 |
-
curl_setopt($curl, CURLOPT_RETURNTRANSFER, false);
|
1266 |
-
curl_setopt($curl, CURLOPT_WRITEFUNCTION, array(&$this, '__responseWriteCallback'));
|
1267 |
-
curl_setopt($curl, CURLOPT_HEADERFUNCTION, array(&$this, '__responseHeaderCallback'));
|
1268 |
-
//curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
|
1269 |
-
|
1270 |
-
// Request types
|
1271 |
-
switch ($this->verb) {
|
1272 |
-
case 'GET': break;
|
1273 |
-
case 'PUT': case 'POST': // POST only used for CloudFront
|
1274 |
-
if ($this->fp !== false) {
|
1275 |
-
curl_setopt($curl, CURLOPT_PUT, true);
|
1276 |
-
curl_setopt($curl, CURLOPT_INFILE, $this->fp);
|
1277 |
-
if ($this->size >= 0)
|
1278 |
-
curl_setopt($curl, CURLOPT_INFILESIZE, $this->size);
|
1279 |
-
} elseif ($this->data !== false) {
|
1280 |
-
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $this->verb);
|
1281 |
-
curl_setopt($curl, CURLOPT_POSTFIELDS, $this->data);
|
1282 |
-
if ($this->size >= 0)
|
1283 |
-
curl_setopt($curl, CURLOPT_BUFFERSIZE, $this->size);
|
1284 |
-
} else
|
1285 |
-
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $this->verb);
|
1286 |
-
break;
|
1287 |
-
case 'HEAD':
|
1288 |
-
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'HEAD');
|
1289 |
-
curl_setopt($curl, CURLOPT_NOBODY, true);
|
1290 |
-
break;
|
1291 |
-
case 'DELETE':
|
1292 |
-
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE');
|
1293 |
-
break;
|
1294 |
-
default: break;
|
1295 |
-
}
|
1296 |
-
|
1297 |
-
// Execute, grab errors
|
1298 |
-
if (curl_exec($curl))
|
1299 |
-
$this->response->code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
1300 |
-
else
|
1301 |
-
$this->response->error = array(
|
1302 |
-
'code' => curl_errno($curl),
|
1303 |
-
'message' => curl_error($curl),
|
1304 |
-
'resource' => $this->resource
|
1305 |
-
);
|
1306 |
-
|
1307 |
-
@curl_close($curl);
|
1308 |
-
|
1309 |
-
// Parse body into XML
|
1310 |
-
if ($this->response->error === false && isset($this->response->headers['type']) &&
|
1311 |
-
$this->response->headers['type'] == 'application/xml' && isset($this->response->body)) {
|
1312 |
-
$this->response->body = simplexml_load_string($this->response->body);
|
1313 |
-
|
1314 |
-
// Grab S3 errors
|
1315 |
-
if (!in_array($this->response->code, array(200, 204)) &&
|
1316 |
-
isset($this->response->body->Code, $this->response->body->Message)) {
|
1317 |
-
$this->response->error = array(
|
1318 |
-
'code' => (string)$this->response->body->Code,
|
1319 |
-
'message' => (string)$this->response->body->Message
|
1320 |
-
);
|
1321 |
-
if (isset($this->response->body->Resource))
|
1322 |
-
$this->response->error['resource'] = (string)$this->response->body->Resource;
|
1323 |
-
unset($this->response->body);
|
1324 |
-
}
|
1325 |
-
}
|
1326 |
-
|
1327 |
-
// Clean up file resources
|
1328 |
-
if ($this->fp !== false && is_resource($this->fp)) fclose($this->fp);
|
1329 |
-
|
1330 |
-
return $this->response;
|
1331 |
-
}
|
1332 |
-
|
1333 |
-
|
1334 |
-
/**
|
1335 |
-
* CURL write callback
|
1336 |
-
*
|
1337 |
-
* @param resource &$curl CURL resource
|
1338 |
-
* @param string &$data Data
|
1339 |
-
* @return integer
|
1340 |
-
*/
|
1341 |
-
private function __responseWriteCallback(&$curl, &$data) {
|
1342 |
-
if ($this->response->code == 200 && $this->fp !== false)
|
1343 |
-
return fwrite($this->fp, $data);
|
1344 |
-
else
|
1345 |
-
$this->response->body .= $data;
|
1346 |
-
return strlen($data);
|
1347 |
-
}
|
1348 |
-
|
1349 |
-
|
1350 |
-
/**
|
1351 |
-
* CURL header callback
|
1352 |
-
*
|
1353 |
-
* @param resource &$curl CURL resource
|
1354 |
-
* @param string &$data Data
|
1355 |
-
* @return integer
|
1356 |
-
*/
|
1357 |
-
private function __responseHeaderCallback(&$curl, &$data) {
|
1358 |
-
if (($strlen = strlen($data)) <= 2) return $strlen;
|
1359 |
-
if (substr($data, 0, 4) == 'HTTP')
|
1360 |
-
$this->response->code = (int)substr($data, 9, 3);
|
1361 |
-
else {
|
1362 |
-
list($header, $value) = explode(': ', trim($data), 2);
|
1363 |
-
if ($header == 'Last-Modified')
|
1364 |
-
$this->response->headers['time'] = strtotime($value);
|
1365 |
-
elseif ($header == 'Content-Length')
|
1366 |
-
$this->response->headers['size'] = (int)$value;
|
1367 |
-
elseif ($header == 'Content-Type')
|
1368 |
-
$this->response->headers['type'] = $value;
|
1369 |
-
elseif ($header == 'ETag')
|
1370 |
-
$this->response->headers['hash'] = $value{0} == '"' ? substr($value, 1, -1) : $value;
|
1371 |
-
elseif (preg_match('/^x-amz-meta-.*$/', $header))
|
1372 |
-
$this->response->headers[$header] = is_numeric($value) ? (int)$value : $value;
|
1373 |
-
}
|
1374 |
-
return $strlen;
|
1375 |
-
}
|
1376 |
-
|
1377 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/libs/aws/lib/cachecore/LICENSE
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Copyright (c) 2006-2010 Ryan Parman, Foleeo Inc., and contributors. All rights reserved.
|
2 |
+
|
3 |
+
Redistribution and use in source and binary forms, with or without modification, are
|
4 |
+
permitted provided that the following conditions are met:
|
5 |
+
|
6 |
+
* Redistributions of source code must retain the above copyright notice, this list of
|
7 |
+
conditions and the following disclaimer.
|
8 |
+
|
9 |
+
* Redistributions in binary form must reproduce the above copyright notice, this list
|
10 |
+
of conditions and the following disclaimer in the documentation and/or other materials
|
11 |
+
provided with the distribution.
|
12 |
+
|
13 |
+
* Neither the name of Ryan Parman, Foleeo Inc. nor the names of its contributors may be used to
|
14 |
+
endorse or promote products derived from this software without specific prior written
|
15 |
+
permission.
|
16 |
+
|
17 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
|
18 |
+
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
19 |
+
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
|
20 |
+
AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
21 |
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
22 |
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
23 |
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
24 |
+
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
25 |
+
POSSIBILITY OF SUCH DAMAGE.
|
app/libs/aws/lib/cachecore/README
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
A simple caching system for PHP5 that provides a single interface for a variety of storage types.
|
app/libs/aws/lib/cachecore/_sql/README
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
The .sql files in this directory contain the code to create the tables for database caching.
|
2 |
+
|
3 |
+
If you're not using database caching, you can safely ignore these.
|
4 |
+
|
5 |
+
If you ARE using database caching, simply load the correct *.sql file into your database to set up the required tables.
|
app/libs/aws/lib/cachecore/_sql/mysql.sql
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
CREATE TABLE `cache` (
|
2 |
+
`id` char(40) NOT NULL default '',
|
3 |
+
`expires` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
|
4 |
+
`data` longtext,
|
5 |
+
PRIMARY KEY (`id`),
|
6 |
+
UNIQUE KEY `id` (`id`)
|
7 |
+
) ENGINE=MyISAM DEFAULT CHARSET=utf8
|
app/libs/aws/lib/cachecore/_sql/pgsql.sql
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
CREATE TABLE "cache" (
|
2 |
+
expires timestamp without time zone NOT NULL,
|
3 |
+
id character(40) NOT NULL,
|
4 |
+
data text NOT NULL
|
5 |
+
)
|
6 |
+
WITH (OIDS=TRUE);
|
app/libs/aws/lib/cachecore/_sql/sqlite3.sql
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
CREATE TABLE cache (id TEXT, expires NUMERIC, data BLOB);
|
2 |
+
CREATE UNIQUE INDEX idx ON cache(id ASC);
|
app/libs/aws/lib/cachecore/cacheapc.class.php
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Container for all APC-based cache methods. Inherits additional methods from <CacheCore>. Adheres
|
4 |
+
* to the ICacheCore interface.
|
5 |
+
*
|
6 |
+
* @version 2009.10.10
|
7 |
+
* @copyright 2006-2010 Ryan Parman
|
8 |
+
* @copyright 2006-2010 Foleeo, Inc.
|
9 |
+
* @copyright 2008-2010 Contributors
|
10 |
+
* @license http://opensource.org/licenses/bsd-license.php Simplified BSD License
|
11 |
+
* @link http://github.com/skyzyx/cachecore CacheCore
|
12 |
+
* @link http://getcloudfusion.com CloudFusion
|
13 |
+
* @link http://php.net/apc APC
|
14 |
+
*/
|
15 |
+
class CacheAPC extends CacheCore implements ICacheCore
|
16 |
+
{
|
17 |
+
|
18 |
+
/*%******************************************************************************************%*/
|
19 |
+
// CONSTRUCTOR
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Constructs a new instance of this class.
|
23 |
+
*
|
24 |
+
* @param string $name (Required) A name to uniquely identify the cache object.
|
25 |
+
* @param string $location (Required) The location to store the cache object in. This may vary by cache method.
|
26 |
+
* @param integer $expires (Required) The number of seconds until a cache object is considered stale.
|
27 |
+
* @param boolean $gzip (Optional) Whether data should be gzipped before being stored. Defaults to true.
|
28 |
+
* @return object Reference to the cache object.
|
29 |
+
*/
|
30 |
+
public function __construct($name, $location, $expires, $gzip = true)
|
31 |
+
{
|
32 |
+
parent::__construct($name, null, $expires, $gzip);
|
33 |
+
$this->id = $this->name;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Creates a new cache.
|
38 |
+
*
|
39 |
+
* @param mixed $data (Required) The data to cache.
|
40 |
+
* @return boolean Whether the operation was successful.
|
41 |
+
*/
|
42 |
+
public function create($data)
|
43 |
+
{
|
44 |
+
$data = serialize($data);
|
45 |
+
$data = $this->gzip ? gzcompress($data) : $data;
|
46 |
+
|
47 |
+
return apc_add($this->id, $data, $this->expires);
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Reads a cache.
|
52 |
+
*
|
53 |
+
* @return mixed Either the content of the cache object, or boolean `false`.
|
54 |
+
*/
|
55 |
+
public function read()
|
56 |
+
{
|
57 |
+
if ($data = apc_fetch($this->id))
|
58 |
+
{
|
59 |
+
$data = $this->gzip ? gzuncompress($data) : $data;
|
60 |
+
return unserialize($data);
|
61 |
+
}
|
62 |
+
|
63 |
+
return false;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Updates an existing cache.
|
68 |
+
*
|
69 |
+
* @param mixed $data (Required) The data to cache.
|
70 |
+
* @return boolean Whether the operation was successful.
|
71 |
+
*/
|
72 |
+
public function update($data)
|
73 |
+
{
|
74 |
+
$data = serialize($data);
|
75 |
+
$data = $this->gzip ? gzcompress($data) : $data;
|
76 |
+
|
77 |
+
return apc_store($this->id, $data, $this->expires);
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Deletes a cache.
|
82 |
+
*
|
83 |
+
* @return boolean Whether the operation was successful.
|
84 |
+
*/
|
85 |
+
public function delete()
|
86 |
+
{
|
87 |
+
return apc_delete($this->id);
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Implemented here, but always returns `false`. APC manages its own expirations.
|
92 |
+
*
|
93 |
+
* @return boolean Whether the cache is expired or not.
|
94 |
+
*/
|
95 |
+
public function is_expired()
|
96 |
+
{
|
97 |
+
return false;
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Implemented here, but always returns `false`. APC manages its own expirations.
|
102 |
+
*
|
103 |
+
* @return mixed Either the Unix time stamp of the cache creation, or boolean `false`.
|
104 |
+
*/
|
105 |
+
public function timestamp()
|
106 |
+
{
|
107 |
+
return false;
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Implemented here, but always returns `false`. APC manages its own expirations.
|
112 |
+
*
|
113 |
+
* @return boolean Whether the operation was successful.
|
114 |
+
*/
|
115 |
+
public function reset()
|
116 |
+
{
|
117 |
+
return false;
|
118 |
+
}
|
119 |
+
}
|
app/libs/aws/lib/cachecore/cachecore.class.php
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Container for all shared caching methods. This is not intended to be instantiated directly, but is
|
4 |
+
* extended by the cache-specific classes.
|
5 |
+
*
|
6 |
+
* @version 2010.10.13
|
7 |
+
* @copyright 2006-2010 Ryan Parman
|
8 |
+
* @copyright 2006-2010 Foleeo, Inc.
|
9 |
+
* @copyright 2008-2010 Contributors
|
10 |
+
* @license http://opensource.org/licenses/bsd-license.php Simplified BSD License
|
11 |
+
* @link http://github.com/skyzyx/cachecore CacheCore
|
12 |
+
* @link http://getcloudfusion.com CloudFusion
|
13 |
+
*/
|
14 |
+
class CacheCore
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* A name to uniquely identify the cache object by.
|
18 |
+
*/
|
19 |
+
var $name;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Where to store the cache.
|
23 |
+
*/
|
24 |
+
var $location;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* The number of seconds before a cache object is considered stale.
|
28 |
+
*/
|
29 |
+
var $expires;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Used internally to uniquely identify the location + name of the cache object.
|
33 |
+
*/
|
34 |
+
var $id;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Stores the time when the cache object was created.
|
38 |
+
*/
|
39 |
+
var $timestamp;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Stores whether or not the content should be gzipped when stored
|
43 |
+
*/
|
44 |
+
var $gzip;
|
45 |
+
|
46 |
+
|
47 |
+
/*%******************************************************************************************%*/
|
48 |
+
// CONSTRUCTOR
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Constructs a new instance of this class.
|
52 |
+
*
|
53 |
+
* @param string $name (Required) A name to uniquely identify the cache object.
|
54 |
+
* @param string $location (Required) The location to store the cache object in. This may vary by cache method.
|
55 |
+
* @param integer $expires (Required) The number of seconds until a cache object is considered stale.
|
56 |
+
* @param boolean $gzip (Optional) Whether data should be gzipped before being stored. Defaults to true.
|
57 |
+
* @return object Reference to the cache object.
|
58 |
+
*/
|
59 |
+
public function __construct($name, $location, $expires, $gzip = true)
|
60 |
+
{
|
61 |
+
if (!extension_loaded('zlib'))
|
62 |
+
{
|
63 |
+
$gzip = false;
|
64 |
+
}
|
65 |
+
|
66 |
+
$this->name = $name;
|
67 |
+
$this->location = $location;
|
68 |
+
$this->expires = $expires;
|
69 |
+
$this->gzip = $gzip;
|
70 |
+
|
71 |
+
return $this;
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Allows for chaining from the constructor. Requires PHP 5.3 or newer.
|
76 |
+
*
|
77 |
+
* @param string $name (Required) A name to uniquely identify the cache object.
|
78 |
+
* @param string $location (Required) The location to store the cache object in. This may vary by cache method.
|
79 |
+
* @param integer $expires (Required) The number of seconds until a cache object is considered stale.
|
80 |
+
* @param boolean $gzip (Optional) Whether data should be gzipped before being stored. Defaults to true.
|
81 |
+
* @return object Reference to the cache object.
|
82 |
+
*/
|
83 |
+
public static function init($name, $location, $expires, $gzip = true)
|
84 |
+
{
|
85 |
+
if (version_compare(PHP_VERSION, '5.3.0', '<'))
|
86 |
+
{
|
87 |
+
throw new Exception('PHP 5.3 or newer is required to use CacheCore::init().');
|
88 |
+
}
|
89 |
+
|
90 |
+
$self = get_called_class();
|
91 |
+
return new $self($name, $location, $expires, $gzip);
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Provides a simple, straightforward cache-logic mechanism. Useful for non-complex response caches.
|
96 |
+
*
|
97 |
+
* @param string|function $callback (Required) The name of the function to fire when we need to fetch new data to cache.
|
98 |
+
* @param array params (Optional) Parameters to pass into the callback function, as an array.
|
99 |
+
* @return array The cached data being requested.
|
100 |
+
*/
|
101 |
+
public function response_manager($callback, $params = null)
|
102 |
+
{
|
103 |
+
// Automatically handle $params values.
|
104 |
+
$params = is_array($params) ? $params : array($params);
|
105 |
+
|
106 |
+
if ($data = $this->read())
|
107 |
+
{
|
108 |
+
if ($this->is_expired())
|
109 |
+
{
|
110 |
+
if ($data = call_user_func_array($callback, $params))
|
111 |
+
{
|
112 |
+
$this->update($data);
|
113 |
+
}
|
114 |
+
else
|
115 |
+
{
|
116 |
+
$this->reset();
|
117 |
+
$data = $this->read();
|
118 |
+
}
|
119 |
+
}
|
120 |
+
}
|
121 |
+
else
|
122 |
+
{
|
123 |
+
if ($data = call_user_func_array($callback, $params))
|
124 |
+
{
|
125 |
+
$this->create($data);
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
return $data;
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
|
134 |
+
/*%******************************************************************************************%*/
|
135 |
+
// CORE DEPENDENCIES
|
136 |
+
|
137 |
+
// Include the ICacheCore interface.
|
138 |
+
if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'icachecore.interface.php'))
|
139 |
+
{
|
140 |
+
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'icachecore.interface.php';
|
141 |
+
}
|
app/libs/aws/lib/cachecore/cachefile.class.php
ADDED
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Container for all file-based cache methods. Inherits additional methods from <CacheCore>. Adheres
|
4 |
+
* to the ICacheCore interface.
|
5 |
+
*
|
6 |
+
* @version 2009.10.10
|
7 |
+
* @copyright 2006-2010 Ryan Parman
|
8 |
+
* @copyright 2006-2010 Foleeo, Inc.
|
9 |
+
* @copyright 2008-2010 Contributors
|
10 |
+
* @license http://opensource.org/licenses/bsd-license.php Simplified BSD License
|
11 |
+
* @link http://github.com/skyzyx/cachecore CacheCore
|
12 |
+
* @link http://getcloudfusion.com CloudFusion
|
13 |
+
*/
|
14 |
+
class CacheFile extends CacheCore implements ICacheCore
|
15 |
+
{
|
16 |
+
|
17 |
+
/*%******************************************************************************************%*/
|
18 |
+
// CONSTRUCTOR
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Constructs a new instance of this class.
|
22 |
+
*
|
23 |
+
* @param string $name (Required) A name to uniquely identify the cache object.
|
24 |
+
* @param string $location (Required) The location to store the cache object in. This may vary by cache method.
|
25 |
+
* @param integer $expires (Required) The number of seconds until a cache object is considered stale.
|
26 |
+
* @param boolean $gzip (Optional) Whether data should be gzipped before being stored. Defaults to true.
|
27 |
+
* @return object Reference to the cache object.
|
28 |
+
*/
|
29 |
+
public function __construct($name, $location, $expires, $gzip = true)
|
30 |
+
{
|
31 |
+
parent::__construct($name, $location, $expires, $gzip);
|
32 |
+
$this->id = $this->location . '/' . $this->name . '.cache';
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Creates a new cache.
|
37 |
+
*
|
38 |
+
* @param mixed $data (Required) The data to cache.
|
39 |
+
* @return boolean Whether the operation was successful.
|
40 |
+
*/
|
41 |
+
public function create($data)
|
42 |
+
{
|
43 |
+
if (file_exists($this->id))
|
44 |
+
{
|
45 |
+
return false;
|
46 |
+
}
|
47 |
+
elseif (file_exists($this->location) && is_writeable($this->location))
|
48 |
+
{
|
49 |
+
$data = serialize($data);
|
50 |
+
$data = $this->gzip ? gzcompress($data) : $data;
|
51 |
+
|
52 |
+
return (bool) file_put_contents($this->id, $data);
|
53 |
+
}
|
54 |
+
|
55 |
+
return false;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Reads a cache.
|
60 |
+
*
|
61 |
+
* @return mixed Either the content of the cache object, or boolean `false`.
|
62 |
+
*/
|
63 |
+
public function read()
|
64 |
+
{
|
65 |
+
if (file_exists($this->id) && is_readable($this->id))
|
66 |
+
{
|
67 |
+
$data = file_get_contents($this->id);
|
68 |
+
$data = $this->gzip ? gzuncompress($data) : $data;
|
69 |
+
$data = unserialize($data);
|
70 |
+
|
71 |
+
if ($data === false)
|
72 |
+
{
|
73 |
+
/*
|
74 |
+
This should only happen when someone changes the gzip settings and there is
|
75 |
+
existing data or someone has been mucking about in the cache folder manually.
|
76 |
+
Delete the bad entry since the file cache doesn't clean up after itself and
|
77 |
+
then return false so fresh data will be retrieved.
|
78 |
+
*/
|
79 |
+
$this->delete();
|
80 |
+
return false;
|
81 |
+
}
|
82 |
+
|
83 |
+
return $data;
|
84 |
+
}
|
85 |
+
|
86 |
+
return false;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Updates an existing cache.
|
91 |
+
*
|
92 |
+
* @param mixed $data (Required) The data to cache.
|
93 |
+
* @return boolean Whether the operation was successful.
|
94 |
+
*/
|
95 |
+
public function update($data)
|
96 |
+
{
|
97 |
+
if (file_exists($this->id) && is_writeable($this->id))
|
98 |
+
{
|
99 |
+
$data = serialize($data);
|
100 |
+
$data = $this->gzip ? gzcompress($data) : $data;
|
101 |
+
|
102 |
+
return (bool) file_put_contents($this->id, $data);
|
103 |
+
}
|
104 |
+
|
105 |
+
return false;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Deletes a cache.
|
110 |
+
*
|
111 |
+
* @return boolean Whether the operation was successful.
|
112 |
+
*/
|
113 |
+
public function delete()
|
114 |
+
{
|
115 |
+
if (file_exists($this->id))
|
116 |
+
{
|
117 |
+
return unlink($this->id);
|
118 |
+
}
|
119 |
+
|
120 |
+
return false;
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Checks whether the cache object is expired or not.
|
125 |
+
*
|
126 |
+
* @return boolean Whether the cache is expired or not.
|
127 |
+
*/
|
128 |
+
public function is_expired()
|
129 |
+
{
|
130 |
+
if ($this->timestamp() + $this->expires < time())
|
131 |
+
{
|
132 |
+
return true;
|
133 |
+
}
|
134 |
+
|
135 |
+
return false;
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Retrieves the timestamp of the cache.
|
140 |
+
*
|
141 |
+
* @return mixed Either the Unix time stamp of the cache creation, or boolean `false`.
|
142 |
+
*/
|
143 |
+
public function timestamp()
|
144 |
+
{
|
145 |
+
clearstatcache();
|
146 |
+
|
147 |
+
if (file_exists($this->id))
|
148 |
+
{
|
149 |
+
$this->timestamp = filemtime($this->id);
|
150 |
+
return $this->timestamp;
|
151 |
+
}
|
152 |
+
|
153 |
+
return false;
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Resets the freshness of the cache.
|
158 |
+
*
|
159 |
+
* @return boolean Whether the operation was successful.
|
160 |
+
*/
|
161 |
+
public function reset()
|
162 |
+
{
|
163 |
+
if (file_exists($this->id))
|
164 |
+
{
|
165 |
+
return touch($this->id);
|
166 |
+
}
|
167 |
+
|
168 |
+
return false;
|
169 |
+
}
|
170 |
+
}
|
app/libs/aws/lib/cachecore/cachemc.class.php
ADDED
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Container for all Memcache-based cache methods. Inherits additional methods from <CacheCore>. Adheres
|
4 |
+
* to the ICacheCore interface.
|
5 |
+
*
|
6 |
+
* @version 2010.05.17
|
7 |
+
* @copyright 2006-2010 Ryan Parman
|
8 |
+
* @copyright 2006-2010 Foleeo, Inc.
|
9 |
+
* @copyright 2008-2010 Contributors
|
10 |
+
* @license http://opensource.org/licenses/bsd-license.php Simplified BSD License
|
11 |
+
* @link http://github.com/skyzyx/cachecore CacheCore
|
12 |
+
* @link http://getcloudfusion.com CloudFusion
|
13 |
+
* @link http://php.net/memcache Memcache
|
14 |
+
* @link http://php.net/memcached Memcached
|
15 |
+
*/
|
16 |
+
class CacheMC extends CacheCore implements ICacheCore
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Holds the Memcache object.
|
20 |
+
*/
|
21 |
+
var $memcache = null;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Whether the Memcached extension is being used (as opposed to Memcache).
|
25 |
+
*/
|
26 |
+
var $is_memcached = false;
|
27 |
+
|
28 |
+
|
29 |
+
/*%******************************************************************************************%*/
|
30 |
+
// CONSTRUCTOR
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Constructs a new instance of this class.
|
34 |
+
*
|
35 |
+
* @param string $name (Required) A name to uniquely identify the cache object.
|
36 |
+
* @param string $location (Required) The location to store the cache object in. This may vary by cache method.
|
37 |
+
* @param integer $expires (Required) The number of seconds until a cache object is considered stale.
|
38 |
+
* @param boolean $gzip (Optional) Whether data should be gzipped before being stored. Defaults to true.
|
39 |
+
* @return object Reference to the cache object.
|
40 |
+
*/
|
41 |
+
public function __construct($name, $location, $expires, $gzip = true)
|
42 |
+
{
|
43 |
+
parent::__construct($name, null, $expires, $gzip);
|
44 |
+
$this->id = $this->name;
|
45 |
+
|
46 |
+
// Prefer Memcached over Memcache.
|
47 |
+
if (class_exists('Memcached'))
|
48 |
+
{
|
49 |
+
$this->memcache = new Memcached();
|
50 |
+
$this->is_memcached = true;
|
51 |
+
}
|
52 |
+
elseif (class_exists('Memcache'))
|
53 |
+
{
|
54 |
+
$this->memcache = new Memcache();
|
55 |
+
}
|
56 |
+
else
|
57 |
+
{
|
58 |
+
return false;
|
59 |
+
}
|
60 |
+
|
61 |
+
// Enable compression, if available
|
62 |
+
if ($this->gzip)
|
63 |
+
{
|
64 |
+
if ($this->is_memcached)
|
65 |
+
{
|
66 |
+
$this->memcache->setOption(Memcached::OPT_COMPRESSION, true);
|
67 |
+
}
|
68 |
+
else
|
69 |
+
{
|
70 |
+
$this->gzip = MEMCACHE_COMPRESSED;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
// Process Memcached servers.
|
75 |
+
if (isset($location) && sizeof($location) > 0)
|
76 |
+
{
|
77 |
+
foreach ($location as $loc)
|
78 |
+
{
|
79 |
+
if (isset($loc['port']) && !empty($loc['port']))
|
80 |
+
{
|
81 |
+
$this->memcache->addServer($loc['host'], $loc['port']);
|
82 |
+
}
|
83 |
+
else
|
84 |
+
{
|
85 |
+
$this->memcache->addServer($loc['host'], 11211);
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
return $this;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Creates a new cache.
|
95 |
+
*
|
96 |
+
* @param mixed $data (Required) The data to cache.
|
97 |
+
* @return boolean Whether the operation was successful.
|
98 |
+
*/
|
99 |
+
public function create($data)
|
100 |
+
{
|
101 |
+
if ($this->is_memcached)
|
102 |
+
{
|
103 |
+
return $this->memcache->set($this->id, $data, $this->expires);
|
104 |
+
}
|
105 |
+
return $this->memcache->set($this->id, $data, $this->gzip, $this->expires);
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Reads a cache.
|
110 |
+
*
|
111 |
+
* @return mixed Either the content of the cache object, or boolean `false`.
|
112 |
+
*/
|
113 |
+
public function read()
|
114 |
+
{
|
115 |
+
if ($this->is_memcached)
|
116 |
+
{
|
117 |
+
return $this->memcache->get($this->id);
|
118 |
+
}
|
119 |
+
return $this->memcache->get($this->id, $this->gzip);
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Updates an existing cache.
|
124 |
+
*
|
125 |
+
* @param mixed $data (Required) The data to cache.
|
126 |
+
* @return boolean Whether the operation was successful.
|
127 |
+
*/
|
128 |
+
public function update($data)
|
129 |
+
{
|
130 |
+
if ($this->is_memcached)
|
131 |
+
{
|
132 |
+
return $this->memcache->replace($this->id, $data, $this->expires);
|
133 |
+
}
|
134 |
+
return $this->memcache->replace($this->id, $data, $this->gzip, $this->expires);
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Deletes a cache.
|
139 |
+
*
|
140 |
+
* @return boolean Whether the operation was successful.
|
141 |
+
*/
|
142 |
+
public function delete()
|
143 |
+
{
|
144 |
+
return $this->memcache->delete($this->id);
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Implemented here, but always returns `false`. Memcache manages its own expirations.
|
149 |
+
*
|
150 |
+
* @return boolean Whether the cache is expired or not.
|
151 |
+
*/
|
152 |
+
public function is_expired()
|
153 |
+
{
|
154 |
+
return false;
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Implemented here, but always returns `false`. Memcache manages its own expirations.
|
159 |
+
*
|
160 |
+
* @return mixed Either the Unix time stamp of the cache creation, or boolean `false`.
|
161 |
+
*/
|
162 |
+
public function timestamp()
|
163 |
+
{
|
164 |
+
return false;
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Implemented here, but always returns `false`. Memcache manages its own expirations.
|
169 |
+
*
|
170 |
+
* @return boolean Whether the operation was successful.
|
171 |
+
*/
|
172 |
+
public function reset()
|
173 |
+
{
|
174 |
+
return false;
|
175 |
+
}
|
176 |
+
}
|
app/libs/aws/lib/cachecore/cachepdo.class.php
ADDED
@@ -0,0 +1,290 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Container for all PDO-based cache methods. Inherits additional methods from <CacheCore>. Adheres
|
4 |
+
* to the ICacheCore interface.
|
5 |
+
*
|
6 |
+
* @version 2009.10.10
|
7 |
+
* @copyright 2006-2010 Ryan Parman
|
8 |
+
* @copyright 2006-2010 Foleeo, Inc.
|
9 |
+
* @copyright 2008-2010 Contributors
|
10 |
+
* @license http://opensource.org/licenses/bsd-license.php Simplified BSD License
|
11 |
+
* @link http://github.com/skyzyx/cachecore CacheCore
|
12 |
+
* @link http://getcloudfusion.com CloudFusion
|
13 |
+
* @link http://php.net/pdo PDO
|
14 |
+
*/
|
15 |
+
class CachePDO extends CacheCore implements ICacheCore
|
16 |
+
{
|
17 |
+
/**
|
18 |
+
* Reference to the PDO connection object.
|
19 |
+
*/
|
20 |
+
var $pdo = null;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Holds the parsed URL components.
|
24 |
+
*/
|
25 |
+
var $dsn = null;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Holds the PDO-friendly version of the connection string.
|
29 |
+
*/
|
30 |
+
var $dsn_string = null;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Holds the prepared statement for creating an entry.
|
34 |
+
*/
|
35 |
+
var $create = null;
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Holds the prepared statement for reading an entry.
|
39 |
+
*/
|
40 |
+
var $read = null;
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Holds the prepared statement for updating an entry.
|
44 |
+
*/
|
45 |
+
var $update = null;
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Holds the prepared statement for resetting the expiry of an entry.
|
49 |
+
*/
|
50 |
+
var $reset = null;
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Holds the prepared statement for deleting an entry.
|
54 |
+
*/
|
55 |
+
var $delete = null;
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Holds the response of the read so we only need to fetch it once instead of doing
|
59 |
+
* multiple queries.
|
60 |
+
*/
|
61 |
+
var $store_read = null;
|
62 |
+
|
63 |
+
|
64 |
+
/*%******************************************************************************************%*/
|
65 |
+
// CONSTRUCTOR
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Constructs a new instance of this class.
|
69 |
+
*
|
70 |
+
* Tested with [MySQL 5.0.x](http://mysql.com), [PostgreSQL](http://postgresql.com), and
|
71 |
+
* [SQLite 3.x](http://sqlite.org). SQLite 2.x is assumed to work. No other PDO-supported databases have
|
72 |
+
* been tested (e.g. Oracle, Microsoft SQL Server, IBM DB2, ODBC, Sybase, Firebird). Feel free to send
|
73 |
+
* patches for additional database support.
|
74 |
+
*
|
75 |
+
* See <http://php.net/pdo> for more information.
|
76 |
+
*
|
77 |
+
* @param string $name (Required) A name to uniquely identify the cache object.
|
78 |
+
* @param string $location (Required) The location to store the cache object in. This may vary by cache method.
|
79 |
+
* @param integer $expires (Required) The number of seconds until a cache object is considered stale.
|
80 |
+
* @param boolean $gzip (Optional) Whether data should be gzipped before being stored. Defaults to true.
|
81 |
+
* @return object Reference to the cache object.
|
82 |
+
*/
|
83 |
+
public function __construct($name, $location, $expires, $gzip = true)
|
84 |
+
{
|
85 |
+
// Make sure the name is no longer than 40 characters.
|
86 |
+
$name = sha1($name);
|
87 |
+
|
88 |
+
// Call parent constructor and set id.
|
89 |
+
parent::__construct($name, $location, $expires, $gzip);
|
90 |
+
$this->id = $this->name;
|
91 |
+
$options = array();
|
92 |
+
|
93 |
+
// Check if the location contains :// (e.g. mysql://user:pass@hostname:port/table)
|
94 |
+
if (stripos($location, '://') === false)
|
95 |
+
{
|
96 |
+
// No? Just pass it through.
|
97 |
+
$this->dsn = parse_url($location);
|
98 |
+
$this->dsn_string = $location;
|
99 |
+
}
|
100 |
+
else
|
101 |
+
{
|
102 |
+
// Yes? Parse and set the DSN
|
103 |
+
$this->dsn = parse_url($location);
|
104 |
+
$this->dsn_string = $this->dsn['scheme'] . ':host=' . $this->dsn['host'] . ((isset($this->dsn['port'])) ? ';port=' . $this->dsn['port'] : '') . ';dbname=' . substr($this->dsn['path'], 1);
|
105 |
+
}
|
106 |
+
|
107 |
+
// Make sure that user/pass are defined.
|
108 |
+
$user = isset($this->dsn['user']) ? $this->dsn['user'] : null;
|
109 |
+
$pass = isset($this->dsn['pass']) ? $this->dsn['pass'] : null;
|
110 |
+
|
111 |
+
// Set persistence for databases that support it.
|
112 |
+
switch ($this->dsn['scheme'])
|
113 |
+
{
|
114 |
+
case 'mysql': // MySQL
|
115 |
+
case 'pgsql': // PostgreSQL
|
116 |
+
$options[PDO::ATTR_PERSISTENT] = true;
|
117 |
+
break;
|
118 |
+
}
|
119 |
+
|
120 |
+
// Instantiate a new PDO object with a persistent connection.
|
121 |
+
$this->pdo = new PDO($this->dsn_string, $user, $pass, $options);
|
122 |
+
|
123 |
+
// Define prepared statements for improved performance.
|
124 |
+
$this->create = $this->pdo->prepare("INSERT INTO cache (id, expires, data) VALUES (:id, :expires, :data)");
|
125 |
+
$this->read = $this->pdo->prepare("SELECT id, expires, data FROM cache WHERE id = :id");
|
126 |
+
$this->reset = $this->pdo->prepare("UPDATE cache SET expires = :expires WHERE id = :id");
|
127 |
+
$this->delete = $this->pdo->prepare("DELETE FROM cache WHERE id = :id");
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Creates a new cache.
|
132 |
+
*
|
133 |
+
* @param mixed $data (Required) The data to cache.
|
134 |
+
* @return boolean Whether the operation was successful.
|
135 |
+
*/
|
136 |
+
public function create($data)
|
137 |
+
{
|
138 |
+
$data = serialize($data);
|
139 |
+
$data = $this->gzip ? gzcompress($data) : $data;
|
140 |
+
|
141 |
+
$this->create->bindParam(':id', $this->id);
|
142 |
+
$this->create->bindParam(':data', $data);
|
143 |
+
$this->create->bindParam(':expires', $this->generate_timestamp());
|
144 |
+
|
145 |
+
return (bool) $this->create->execute();
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Reads a cache.
|
150 |
+
*
|
151 |
+
* @return mixed Either the content of the cache object, or boolean `false`.
|
152 |
+
*/
|
153 |
+
public function read()
|
154 |
+
{
|
155 |
+
if (!$this->store_read)
|
156 |
+
{
|
157 |
+
$this->read->bindParam(':id', $this->id);
|
158 |
+
$this->read->execute();
|
159 |
+
$this->store_read = $this->read->fetch(PDO::FETCH_ASSOC);
|
160 |
+
}
|
161 |
+
|
162 |
+
if ($this->store_read)
|
163 |
+
{
|
164 |
+
$data = $this->store_read['data'];
|
165 |
+
$data = $this->gzip ? gzuncompress($data) : $data;
|
166 |
+
|
167 |
+
return unserialize($data);
|
168 |
+
}
|
169 |
+
|
170 |
+
return false;
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* Updates an existing cache.
|
175 |
+
*
|
176 |
+
* @param mixed $data (Required) The data to cache.
|
177 |
+
* @return boolean Whether the operation was successful.
|
178 |
+
*/
|
179 |
+
public function update($data)
|
180 |
+
{
|
181 |
+
$this->delete();
|
182 |
+
return $this->create($data);
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Deletes a cache.
|
187 |
+
*
|
188 |
+
* @return boolean Whether the operation was successful.
|
189 |
+
*/
|
190 |
+
public function delete()
|
191 |
+
{
|
192 |
+
$this->delete->bindParam(':id', $this->id);
|
193 |
+
return $this->delete->execute();
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Checks whether the cache object is expired or not.
|
198 |
+
*
|
199 |
+
* @return boolean Whether the cache is expired or not.
|
200 |
+
*/
|
201 |
+
public function is_expired()
|
202 |
+
{
|
203 |
+
if ($this->timestamp() + $this->expires < time())
|
204 |
+
{
|
205 |
+
return true;
|
206 |
+
}
|
207 |
+
|
208 |
+
return false;
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Retrieves the timestamp of the cache.
|
213 |
+
*
|
214 |
+
* @return mixed Either the Unix time stamp of the cache creation, or boolean `false`.
|
215 |
+
*/
|
216 |
+
public function timestamp()
|
217 |
+
{
|
218 |
+
if (!$this->store_read)
|
219 |
+
{
|
220 |
+
$this->read->bindParam(':id', $this->id);
|
221 |
+
$this->read->execute();
|
222 |
+
$this->store_read = $this->read->fetch(PDO::FETCH_ASSOC);
|
223 |
+
}
|
224 |
+
|
225 |
+
if ($this->store_read)
|
226 |
+
{
|
227 |
+
$value = $this->store_read['expires'];
|
228 |
+
|
229 |
+
// If 'expires' isn't yet an integer, convert it into one.
|
230 |
+
if (!is_numeric($value))
|
231 |
+
{
|
232 |
+
$value = strtotime($value);
|
233 |
+
}
|
234 |
+
|
235 |
+
$this->timestamp = date('U', $value);
|
236 |
+
return $this->timestamp;
|
237 |
+
}
|
238 |
+
|
239 |
+
return false;
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Resets the freshness of the cache.
|
244 |
+
*
|
245 |
+
* @return boolean Whether the operation was successful.
|
246 |
+
*/
|
247 |
+
public function reset()
|
248 |
+
{
|
249 |
+
$this->reset->bindParam(':id', $this->id);
|
250 |
+
$this->reset->bindParam(':expires', $this->generate_timestamp());
|
251 |
+
return (bool) $this->reset->execute();
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
* Returns a list of supported PDO database drivers. Identical to <PDO::getAvailableDrivers()>.
|
256 |
+
*
|
257 |
+
* @return array The list of supported database drivers.
|
258 |
+
* @link http://php.net/pdo.getavailabledrivers PHP Method
|
259 |
+
*/
|
260 |
+
public function get_drivers()
|
261 |
+
{
|
262 |
+
return PDO::getAvailableDrivers();
|
263 |
+
}
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Returns a timestamp value apropriate to the current database type.
|
267 |
+
*
|
268 |
+
* @return mixed Timestamp for MySQL and PostgreSQL, integer value for SQLite.
|
269 |
+
*/
|
270 |
+
protected function generate_timestamp()
|
271 |
+
{
|
272 |
+
// Define 'expires' settings differently.
|
273 |
+
switch ($this->dsn['scheme'])
|
274 |
+
{
|
275 |
+
// These support timestamps.
|
276 |
+
case 'mysql': // MySQL
|
277 |
+
case 'pgsql': // PostgreSQL
|
278 |
+
$expires = date(DATE_FORMAT_MYSQL, time());
|
279 |
+
break;
|
280 |
+
|
281 |
+
// These support integers.
|
282 |
+
case 'sqlite': // SQLite 3
|
283 |
+
case 'sqlite2': // SQLite 2
|
284 |
+
$expires = time();
|
285 |
+
break;
|
286 |
+
}
|
287 |
+
|
288 |
+
return $expires;
|
289 |
+
}
|
290 |
+
}
|
app/libs/aws/lib/cachecore/cachexcache.class.php
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Container for all XCache-based cache methods. Inherits additional methods from <CacheCore>. Adheres
|
4 |
+
* to the ICacheCore interface.
|
5 |
+
*
|
6 |
+
* @version 2009.10.10
|
7 |
+
* @copyright 2006-2010 Ryan Parman
|
8 |
+
* @copyright 2006-2010 Foleeo, Inc.
|
9 |
+
* @copyright 2008-2010 Contributors
|
10 |
+
* @license http://opensource.org/licenses/bsd-license.php Simplified BSD License
|
11 |
+
* @link http://github.com/skyzyx/cachecore CacheCore
|
12 |
+
* @link http://getcloudfusion.com CloudFusion
|
13 |
+
* @link http://xcache.lighttpd.net XCache
|
14 |
+
*/
|
15 |
+
class CacheXCache extends CacheCore implements ICacheCore
|
16 |
+
{
|
17 |
+
|
18 |
+
/*%******************************************************************************************%*/
|
19 |
+
// CONSTRUCTOR
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Constructs a new instance of this class.
|
23 |
+
*
|
24 |
+
* @param string $name (Required) A name to uniquely identify the cache object.
|
25 |
+
* @param string $location (Required) The location to store the cache object in. This may vary by cache method.
|
26 |
+
* @param integer $expires (Required) The number of seconds until a cache object is considered stale.
|
27 |
+
* @param boolean $gzip (Optional) Whether data should be gzipped before being stored. Defaults to true.
|
28 |
+
* @return object Reference to the cache object.
|
29 |
+
*/
|
30 |
+
public function __construct($name, $location, $expires, $gzip = true)
|
31 |
+
{
|
32 |
+
parent::__construct($name, null, $expires, $gzip);
|
33 |
+
$this->id = $this->name;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Creates a new cache.
|
38 |
+
*
|
39 |
+
* @param mixed $data (Required) The data to cache.
|
40 |
+
* @return boolean Whether the operation was successful.
|
41 |
+
*/
|
42 |
+
public function create($data)
|
43 |
+
{
|
44 |
+
$data = serialize($data);
|
45 |
+
$data = $this->gzip ? gzcompress($data) : $data;
|
46 |
+
|
47 |
+
return xcache_set($this->id, $data, $this->expires);
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Reads a cache.
|
52 |
+
*
|
53 |
+
* @return mixed Either the content of the cache object, or boolean `false`.
|
54 |
+
*/
|
55 |
+
public function read()
|
56 |
+
{
|
57 |
+
if ($data = xcache_get($this->id))
|
58 |
+
{
|
59 |
+
$data = $this->gzip ? gzuncompress($data) : $data;
|
60 |
+
return unserialize($data);
|
61 |
+
}
|
62 |
+
|
63 |
+
return false;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Updates an existing cache.
|
68 |
+
*
|
69 |
+
* @param mixed $data (Required) The data to cache.
|
70 |
+
* @return boolean Whether the operation was successful.
|
71 |
+
*/
|
72 |
+
public function update($data)
|
73 |
+
{
|
74 |
+
$data = serialize($data);
|
75 |
+
$data = $this->gzip ? gzcompress($data) : $data;
|
76 |
+
|
77 |
+
return xcache_set($this->id, $data, $this->expires);
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Deletes a cache.
|
82 |
+
*
|
83 |
+
* @return boolean Whether the operation was successful.
|
84 |
+
*/
|
85 |
+
public function delete()
|
86 |
+
{
|
87 |
+
return xcache_unset($this->id);
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Defined here, but always returns false. XCache manages it's own expirations. It's worth
|
92 |
+
* mentioning that if the server is configured for a long xcache.var_gc_interval then it IS
|
93 |
+
* possible for expired data to remain in the var cache, though it is not possible to access
|
94 |
+
* it.
|
95 |
+
*
|
96 |
+
* @return boolean Whether the cache is expired or not.
|
97 |
+
*/
|
98 |
+
public function is_expired()
|
99 |
+
{
|
100 |
+
return false;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Implemented here, but always returns `false`. XCache manages its own expirations.
|
105 |
+
*
|
106 |
+
* @return mixed Either the Unix time stamp of the cache creation, or boolean `false`.
|
107 |
+
*/
|
108 |
+
public function timestamp()
|
109 |
+
{
|
110 |
+
return false;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Implemented here, but always returns `false`. XCache manages its own expirations.
|
115 |
+
*
|
116 |
+
* @return boolean Whether the operation was successful.
|
117 |
+
*/
|
118 |
+
public function reset()
|
119 |
+
{
|
120 |
+
return false;
|
121 |
+
}
|
122 |
+
}
|
app/libs/aws/lib/cachecore/icachecore.interface.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Defines the methods that all implementing classes MUST have. Covers CRUD (create, read, update,
|
4 |
+
* delete) methods, as well as others that are used in the base <CacheCore> class.
|
5 |
+
*
|
6 |
+
* @version 2009.03.22
|
7 |
+
* @copyright 2006-2010 Ryan Parman
|
8 |
+
* @copyright 2006-2010 Foleeo, Inc.
|
9 |
+
* @copyright 2008-2010 Contributors
|
10 |
+
* @license http://opensource.org/licenses/bsd-license.php Simplified BSD License
|
11 |
+
* @link http://github.com/skyzyx/cachecore CacheCore
|
12 |
+
* @link http://getcloudfusion.com CloudFusion
|
13 |
+
*/
|
14 |
+
interface ICacheCore
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* Creates a new cache.
|
18 |
+
*
|
19 |
+
* @param mixed $data (Required) The data to cache.
|
20 |
+
* @return boolean Whether the operation was successful.
|
21 |
+
*/
|
22 |
+
public function create($data);
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Reads a cache.
|
26 |
+
*
|
27 |
+
* @return mixed Either the content of the cache object, or boolean `false`.
|
28 |
+
*/
|
29 |
+
public function read();
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Updates an existing cache.
|
33 |
+
*
|
34 |
+
* @param mixed $data (Required) The data to cache.
|
35 |
+
* @return boolean Whether the operation was successful.
|
36 |
+
*/
|
37 |
+
public function update($data);
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Deletes a cache.
|
41 |
+
*
|
42 |
+
* @return boolean Whether the operation was successful.
|
43 |
+
*/
|
44 |
+
public function delete();
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Checks whether the cache object is expired or not.
|
48 |
+
*
|
49 |
+
* @return boolean Whether the cache is expired or not.
|
50 |
+
*/
|
51 |
+
public function is_expired();
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Retrieves the timestamp of the cache.
|
55 |
+
*
|
56 |
+
* @return mixed Either the Unix time stamp of the cache creation, or boolean `false`.
|
57 |
+
*/
|
58 |
+
public function timestamp();
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Resets the freshness of the cache.
|
62 |
+
*
|
63 |
+
* @return boolean Whether the operation was successful.
|
64 |
+
*/
|
65 |
+
public function reset();
|
66 |
+
}
|
app/libs/aws/lib/requestcore/LICENSE
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Copyright (c) 2006-2010 Ryan Parman, Foleeo Inc., and contributors. All rights reserved.
|
2 |
+
|
3 |
+
Redistribution and use in source and binary forms, with or without modification, are
|
4 |
+
permitted provided that the following conditions are met:
|
5 |
+
|
6 |
+
* Redistributions of source code must retain the above copyright notice, this list of
|
7 |
+
conditions and the following disclaimer.
|
8 |
+
|
9 |
+
* Redistributions in binary form must reproduce the above copyright notice, this list
|
10 |
+
of conditions and the following disclaimer in the documentation and/or other materials
|
11 |
+
provided with the distribution.
|
12 |
+
|
13 |
+
* Neither the name of Ryan Parman, Foleeo Inc. nor the names of its contributors may be used to
|
14 |
+
endorse or promote products derived from this software without specific prior written
|
15 |
+
permission.
|
16 |
+
|
17 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
|
18 |
+
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
19 |
+
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
|
20 |
+
AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
21 |
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
22 |
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
23 |
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
24 |
+
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
25 |
+
POSSIBILITY OF SUCH DAMAGE.
|
app/libs/aws/lib/requestcore/README.md
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# RequestCore
|
2 |
+
|
3 |
+
RequestCore is a lightweight cURL-based HTTP request/response class that leverages MultiCurl for parallel requests.
|
4 |
+
|
5 |
+
### PEAR HTTP_Request?
|
6 |
+
|
7 |
+
RequestCore was written as a replacement for [PEAR HTTP_Request](http://pear.php.net/http_request/). While PEAR HTTP_Request is full-featured and heavy, RequestCore features only the essentials and is very lightweight. It also leverages the batch request support in cURL's `curl_multi_exec()` to enable multi-threaded requests that fire in parallel.
|
8 |
+
|
9 |
+
### Reference and Download
|
10 |
+
|
11 |
+
You can find the class reference at <http://skyzyx.github.com/requestcore/>. You can get the code from <http://github.com/skyzyx/requestcore>.
|
12 |
+
|
13 |
+
### License and Copyright
|
14 |
+
|
15 |
+
This code is Copyright (c) 2008-2010, Ryan Parman. However, I'm licensing this code for others to use under the [Simplified BSD license](http://www.opensource.org/licenses/bsd-license.php).
|
app/libs/aws/lib/requestcore/requestcore.class.php
ADDED
@@ -0,0 +1,910 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Handles all HTTP requests using cURL and manages the responses.
|
4 |
+
*
|
5 |
+
* @version 2011.01.11
|
6 |
+
* @copyright 2006-2011 Ryan Parman
|
7 |
+
* @copyright 2006-2010 Foleeo Inc.
|
8 |
+
* @copyright 2010-2011 Amazon.com, Inc. or its affiliates.
|
9 |
+
* @copyright 2008-2011 Contributors
|
10 |
+
* @license http://opensource.org/licenses/bsd-license.php Simplified BSD License
|
11 |
+
*/
|
12 |
+
class RequestCore
|
13 |
+
{
|
14 |
+
/**
|
15 |
+
* The URL being requested.
|
16 |
+
*/
|
17 |
+
public $request_url;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* The headers being sent in the request.
|
21 |
+
*/
|
22 |
+
public $request_headers;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* The body being sent in the request.
|
26 |
+
*/
|
27 |
+
public $request_body;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* The response returned by the request.
|
31 |
+
*/
|
32 |
+
public $response;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* The headers returned by the request.
|
36 |
+
*/
|
37 |
+
public $response_headers;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* The body returned by the request.
|
41 |
+
*/
|
42 |
+
public $response_body;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* The HTTP status code returned by the request.
|
46 |
+
*/
|
47 |
+
public $response_code;
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Additional response data.
|
51 |
+
*/
|
52 |
+
public $response_info;
|
53 |
+
|
54 |
+
/**
|
55 |
+
* The handle for the cURL object.
|
56 |
+
*/
|
57 |
+
public $curl_handle;
|
58 |
+
|
59 |
+
/**
|
60 |
+
* The method by which the request is being made.
|
61 |
+
*/
|
62 |
+
public $method;
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Stores the proxy settings to use for the request.
|
66 |
+
*/
|
67 |
+
public $proxy = null;
|
68 |
+
|
69 |
+
/**
|
70 |
+
* The username to use for the request.
|
71 |
+
*/
|
72 |
+
public $username = null;
|
73 |
+
|
74 |
+
/**
|
75 |
+
* The password to use for the request.
|
76 |
+
*/
|
77 |
+
public $password = null;
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Custom CURLOPT settings.
|
81 |
+
*/
|
82 |
+
public $curlopts = null;
|
83 |
+
|
84 |
+
/**
|
85 |
+
* The default class to use for HTTP Requests (defaults to <RequestCore>).
|
86 |
+
*/
|
87 |
+
public $request_class = 'RequestCore';
|
88 |
+
|
89 |
+
/**
|
90 |
+
* The default class to use for HTTP Responses (defaults to <ResponseCore>).
|
91 |
+
*/
|
92 |
+
public $response_class = 'ResponseCore';
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Default useragent string to use.
|
96 |
+
*/
|
97 |
+
public $useragent = 'RequestCore/1.4';
|
98 |
+
|
99 |
+
/**
|
100 |
+
* File to read from while streaming up.
|
101 |
+
*/
|
102 |
+
public $read_file = null;
|
103 |
+
|
104 |
+
/**
|
105 |
+
* The resource to read from while streaming up.
|
106 |
+
*/
|
107 |
+
public $read_stream = null;
|
108 |
+
|
109 |
+
/**
|
110 |
+
* The size of the stream to read from.
|
111 |
+
*/
|
112 |
+
public $read_stream_size = null;
|
113 |
+
|
114 |
+
/**
|
115 |
+
* The length already read from the stream.
|
116 |
+
*/
|
117 |
+
public $read_stream_read = 0;
|
118 |
+
|
119 |
+
/**
|
120 |
+
* File to write to while streaming down.
|
121 |
+
*/
|
122 |
+
public $write_file = null;
|
123 |
+
|
124 |
+
/**
|
125 |
+
* The resource to write to while streaming down.
|
126 |
+
*/
|
127 |
+
public $write_stream = null;
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Stores the intended starting seek position.
|
131 |
+
*/
|
132 |
+
public $seek_position = null;
|
133 |
+
|
134 |
+
|
135 |
+
/*%******************************************************************************************%*/
|
136 |
+
// CONSTANTS
|
137 |
+
|
138 |
+
/**
|
139 |
+
* GET HTTP Method
|
140 |
+
*/
|
141 |
+
const HTTP_GET = 'GET';
|
142 |
+
|
143 |
+
/**
|
144 |
+
* POST HTTP Method
|
145 |
+
*/
|
146 |
+
const HTTP_POST = 'POST';
|
147 |
+
|
148 |
+
/**
|
149 |
+
* PUT HTTP Method
|
150 |
+
*/
|
151 |
+
const HTTP_PUT = 'PUT';
|
152 |
+
|
153 |
+
/**
|
154 |
+
* DELETE HTTP Method
|
155 |
+
*/
|
156 |
+
const HTTP_DELETE = 'DELETE';
|
157 |
+
|
158 |
+
/**
|
159 |
+
* HEAD HTTP Method
|
160 |
+
*/
|
161 |
+
const HTTP_HEAD = 'HEAD';
|
162 |
+
|
163 |
+
|
164 |
+
/*%******************************************************************************************%*/
|
165 |
+
// CONSTRUCTOR/DESTRUCTOR
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Constructs a new instance of this class.
|
169 |
+
*
|
170 |
+
* @param string $url (Optional) The URL to request or service endpoint to query.
|
171 |
+
* @param string $proxy (Optional) The faux-url to use for proxy settings. Takes the following format: `proxy://user:pass@hostname:port`
|
172 |
+
* @param array $helpers (Optional) An associative array of classnames to use for request, and response functionality. Gets passed in automatically by the calling class.
|
173 |
+
* @return $this A reference to the current instance.
|
174 |
+
*/
|
175 |
+
public function __construct($url = null, $proxy = null, $helpers = null)
|
176 |
+
{
|
177 |
+
// Set some default values.
|
178 |
+
$this->request_url = $url;
|
179 |
+
$this->method = self::HTTP_GET;
|
180 |
+
$this->request_headers = array();
|
181 |
+
$this->request_body = '';
|
182 |
+
|
183 |
+
// Set a new Request class if one was set.
|
184 |
+
if (isset($helpers['request']) && !empty($helpers['request']))
|
185 |
+
{
|
186 |
+
$this->request_class = $helpers['request'];
|
187 |
+
}
|
188 |
+
|
189 |
+
// Set a new Request class if one was set.
|
190 |
+
if (isset($helpers['response']) && !empty($helpers['response']))
|
191 |
+
{
|
192 |
+
$this->response_class = $helpers['response'];
|
193 |
+
}
|
194 |
+
|
195 |
+
if ($proxy)
|
196 |
+
{
|
197 |
+
$this->set_proxy($proxy);
|
198 |
+
}
|
199 |
+
|
200 |
+
return $this;
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Destructs the instance. Closes opened file handles.
|
205 |
+
*
|
206 |
+
* @return $this A reference to the current instance.
|
207 |
+
*/
|
208 |
+
public function __destruct()
|
209 |
+
{
|
210 |
+
if (isset($this->read_file) && isset($this->read_stream))
|
211 |
+
{
|
212 |
+
fclose($this->read_stream);
|
213 |
+
}
|
214 |
+
|
215 |
+
if (isset($this->write_file) && isset($this->write_stream))
|
216 |
+
{
|
217 |
+
fclose($this->write_stream);
|
218 |
+
}
|
219 |
+
|
220 |
+
return $this;
|
221 |
+
}
|
222 |
+
|
223 |
+
|
224 |
+
/*%******************************************************************************************%*/
|
225 |
+
// REQUEST METHODS
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Sets the credentials to use for authentication.
|
229 |
+
*
|
230 |
+
* @param string $user (Required) The username to authenticate with.
|
231 |
+
* @param string $pass (Required) The password to authenticate with.
|
232 |
+
* @return $this A reference to the current instance.
|
233 |
+
*/
|
234 |
+
public function set_credentials($user, $pass)
|
235 |
+
{
|
236 |
+
$this->username = $user;
|
237 |
+
$this->password = $pass;
|
238 |
+
return $this;
|
239 |
+
}
|
240 |
+
|
241 |
+
/**
|
242 |
+
* Adds a custom HTTP header to the cURL request.
|
243 |
+
*
|
244 |
+
* @param string $key (Required) The custom HTTP header to set.
|
245 |
+
* @param mixed $value (Required) The value to assign to the custom HTTP header.
|
246 |
+
* @return $this A reference to the current instance.
|
247 |
+
*/
|
248 |
+
public function add_header($key, $value)
|
249 |
+
{
|
250 |
+
$this->request_headers[$key] = $value;
|
251 |
+
return $this;
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
* Removes an HTTP header from the cURL request.
|
256 |
+
*
|
257 |
+
* @param string $key (Required) The custom HTTP header to set.
|
258 |
+
* @return $this A reference to the current instance.
|
259 |
+
*/
|
260 |
+
public function remove_header($key)
|
261 |
+
{
|
262 |
+
if (isset($this->request_headers[$key]))
|
263 |
+
{
|
264 |
+
unset($this->request_headers[$key]);
|
265 |
+
}
|
266 |
+
return $this;
|
267 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Set the method type for the request.
|
271 |
+
*
|
272 |
+
* @param string $method (Required) One of the following constants: <HTTP_GET>, <HTTP_POST>, <HTTP_PUT>, <HTTP_HEAD>, <HTTP_DELETE>.
|
273 |
+
* @return $this A reference to the current instance.
|
274 |
+
*/
|
275 |
+
public function set_method($method)
|
276 |
+
{
|
277 |
+
$this->method = strtoupper($method);
|
278 |
+
return $this;
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Sets a custom useragent string for the class.
|
283 |
+
*
|
284 |
+
* @param string $ua (Required) The useragent string to use.
|
285 |
+
* @return $this A reference to the current instance.
|
286 |
+
*/
|
287 |
+
public function set_useragent($ua)
|
288 |
+
{
|
289 |
+
$this->useragent = $ua;
|
290 |
+
return $this;
|
291 |
+
}
|
292 |
+
|
293 |
+
/**
|
294 |
+
* Set the body to send in the request.
|
295 |
+
*
|
296 |
+
* @param string $body (Required) The textual content to send along in the body of the request.
|
297 |
+
* @return $this A reference to the current instance.
|
298 |
+
*/
|
299 |
+
public function set_body($body)
|
300 |
+
{
|
301 |
+
$this->request_body = $body;
|
302 |
+
return $this;
|
303 |
+
}
|
304 |
+
|
305 |
+
/**
|
306 |
+
* Set the URL to make the request to.
|
307 |
+
*
|
308 |
+
* @param string $url (Required) The URL to make the request to.
|
309 |
+
* @return $this A reference to the current instance.
|
310 |
+
*/
|
311 |
+
public function set_request_url($url)
|
312 |
+
{
|
313 |
+
$this->request_url = $url;
|
314 |
+
return $this;
|
315 |
+
}
|
316 |
+
|
317 |
+
/**
|
318 |
+
* Set additional CURLOPT settings. These will merge with the default settings, and override if
|
319 |
+
* there is a duplicate.
|
320 |
+
*
|
321 |
+
* @param array $curlopts (Optional) A set of key-value pairs that set `CURLOPT` options. These will merge with the existing CURLOPTs, and ones passed here will override the defaults. Keys should be the `CURLOPT_*` constants, not strings.
|
322 |
+
* @return $this A reference to the current instance.
|
323 |
+
*/
|
324 |
+
public function set_curlopts($curlopts)
|
325 |
+
{
|
326 |
+
$this->curlopts = $curlopts;
|
327 |
+
return $this;
|
328 |
+
}
|
329 |
+
|
330 |
+
/**
|
331 |
+
* Sets the length in bytes to read from the stream while streaming up.
|
332 |
+
*
|
333 |
+
* @param integer $size (Required) The length in bytes to read from the stream.
|
334 |
+
* @return $this A reference to the current instance.
|
335 |
+
*/
|
336 |
+
public function set_read_stream_size($size)
|
337 |
+
{
|
338 |
+
$this->read_stream_size = $size;
|
339 |
+
|
340 |
+
return $this;
|
341 |
+
}
|
342 |
+
|
343 |
+
/**
|
344 |
+
* Sets the resource to read from while streaming up. Reads the stream from its current position until
|
345 |
+
* EOF or `$size` bytes have been read. If `$size` is not given it will be determined by <php:fstat()> and
|
346 |
+
* <php:ftell()>.
|
347 |
+
*
|
348 |
+
* @param resource $resource (Required) The readable resource to read from.
|
349 |
+
* @param integer $size (Optional) The size of the stream to read.
|
350 |
+
* @return $this A reference to the current instance.
|
351 |
+
*/
|
352 |
+
public function set_read_stream($resource, $size = null)
|
353 |
+
{
|
354 |
+
if (!isset($size) || $size < 0)
|
355 |
+
{
|
356 |
+
$stats = fstat($resource);
|
357 |
+
|
358 |
+
if ($stats && $stats['size'] >= 0)
|
359 |
+
{
|
360 |
+
$position = ftell($resource);
|
361 |
+
|
362 |
+
if ($position !== false && $position >= 0)
|
363 |
+
{
|
364 |
+
$size = $stats['size'] - $position;
|
365 |
+
}
|
366 |
+
}
|
367 |
+
}
|
368 |
+
|
369 |
+
$this->read_stream = $resource;
|
370 |
+
|
371 |
+
return $this->set_read_stream_size($size);
|
372 |
+
}
|
373 |
+
|
374 |
+
/**
|
375 |
+
* Sets the file to read from while streaming up.
|
376 |
+
*
|
377 |
+
* @param string $location (Required) The readable location to read from.
|
378 |
+
* @return $this A reference to the current instance.
|
379 |
+
*/
|
380 |
+
public function set_read_file($location)
|
381 |
+
{
|
382 |
+
$this->read_file = $location;
|
383 |
+
$read_file_handle = fopen($location, 'r');
|
384 |
+
|
385 |
+
return $this->set_read_stream($read_file_handle);
|
386 |
+
}
|
387 |
+
|
388 |
+
/**
|
389 |
+
* Sets the resource to write to while streaming down.
|
390 |
+
*
|
391 |
+
* @param resource $resource (Required) The writeable resource to write to.
|
392 |
+
* @return $this A reference to the current instance.
|
393 |
+
*/
|
394 |
+
public function set_write_stream($resource)
|
395 |
+
{
|
396 |
+
$this->write_stream = $resource;
|
397 |
+
|
398 |
+
return $this;
|
399 |
+
}
|
400 |
+
|
401 |
+
/**
|
402 |
+
* Sets the file to write to while streaming down.
|
403 |
+
*
|
404 |
+
* @param string $location (Required) The writeable location to write to.
|
405 |
+
* @return $this A reference to the current instance.
|
406 |
+
*/
|
407 |
+
public function set_write_file($location)
|
408 |
+
{
|
409 |
+
$this->write_file = $location;
|
410 |
+
$write_file_handle = fopen($location, 'w');
|
411 |
+
|
412 |
+
return $this->set_write_stream($write_file_handle);
|
413 |
+
}
|
414 |
+
|
415 |
+
/**
|
416 |
+
* Set the proxy to use for making requests.
|
417 |
+
*
|
418 |
+
* @param string $proxy (Required) The faux-url to use for proxy settings. Takes the following format: `proxy://user:pass@hostname:port`
|
419 |
+
* @return $this A reference to the current instance.
|
420 |
+
*/
|
421 |
+
public function set_proxy($proxy)
|
422 |
+
{
|
423 |
+
$proxy = parse_url($proxy);
|
424 |
+
$proxy['user'] = isset($proxy['user']) ? $proxy['user'] : null;
|
425 |
+
$proxy['pass'] = isset($proxy['pass']) ? $proxy['pass'] : null;
|
426 |
+
$proxy['port'] = isset($proxy['port']) ? $proxy['port'] : null;
|
427 |
+
$this->proxy = $proxy;
|
428 |
+
return $this;
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* Set the intended starting seek position.
|
433 |
+
*
|
434 |
+
* @param integer $position (Required) The byte-position of the stream to begin reading from.
|
435 |
+
* @return $this A reference to the current instance.
|
436 |
+
*/
|
437 |
+
public function set_seek_position($position)
|
438 |
+
{
|
439 |
+
$this->seek_position = isset($position) ? (integer) $position : null;
|
440 |
+
|
441 |
+
return $this;
|
442 |
+
}
|
443 |
+
|
444 |
+
|
445 |
+
/*%******************************************************************************************%*/
|
446 |
+
// PREPARE, SEND, AND PROCESS REQUEST
|
447 |
+
|
448 |
+
/**
|
449 |
+
* A callback function that is invoked by cURL for streaming up.
|
450 |
+
*
|
451 |
+
* @param resource $curl_handle (Required) The cURL handle for the request.
|
452 |
+
* @param resource $file_handle (Required) The open file handle resource.
|
453 |
+
* @param integer $length (Required) The maximum number of bytes to read.
|
454 |
+
* @return binary Binary data from a stream.
|
455 |
+
*/
|
456 |
+
public function streaming_read_callback($curl_handle, $file_handle, $length)
|
457 |
+
{
|
458 |
+
// Once we've sent as much as we're supposed to send...
|
459 |
+
if ($this->read_stream_read >= $this->read_stream_size)
|
460 |
+
{
|
461 |
+
// Send EOF
|
462 |
+
return '';
|
463 |
+
}
|
464 |
+
|
465 |
+
// If we're at the beginning of an upload and need to seek...
|
466 |
+
if ($this->read_stream_read == 0 && isset($this->seek_position) && $this->seek_position !== ftell($this->read_stream))
|
467 |
+
{
|
468 |
+
if (fseek($this->read_stream, $this->seek_position) !== 0)
|
469 |
+
{
|
470 |
+
throw new RequestCore_Exception('The stream does not support seeking and is either not at the requested position or the position is unknown.');
|
471 |
+
}
|
472 |
+
}
|
473 |
+
|
474 |
+
$read = fread($this->read_stream, min($this->read_stream_size - $this->read_stream_read, $length)); // Remaining upload data or cURL's requested chunk size
|
475 |
+
$this->read_stream_read += strlen($read);
|
476 |
+
|
477 |
+
return $read === false ? '' : $read;
|
478 |
+
}
|
479 |
+
|
480 |
+
/**
|
481 |
+
* A callback function that is invoked by cURL for streaming down.
|
482 |
+
*
|
483 |
+
* @param resource $curl_handle (Required) The cURL handle for the request.
|
484 |
+
* @param binary $data (Required) The data to write.
|
485 |
+
* @return integer The number of bytes written.
|
486 |
+
*/
|
487 |
+
public function streaming_write_callback($curl_handle, $data)
|
488 |
+
{
|
489 |
+
$length = strlen($data);
|
490 |
+
$written_total = 0;
|
491 |
+
$written_last = 0;
|
492 |
+
|
493 |
+
while ($written_total < $length)
|
494 |
+
{
|
495 |
+
$written_last = fwrite($this->write_stream, substr($data, $written_total));
|
496 |
+
|
497 |
+
if ($written_last === false)
|
498 |
+
{
|
499 |
+
return $written_total;
|
500 |
+
}
|
501 |
+
|
502 |
+
$written_total += $written_last;
|
503 |
+
}
|
504 |
+
|
505 |
+
return $written_total;
|
506 |
+
}
|
507 |
+
|
508 |
+
/**
|
509 |
+
* Prepares and adds the details of the cURL request. This can be passed along to a <php:curl_multi_exec()>
|
510 |
+
* function.
|
511 |
+
*
|
512 |
+
* @return resource The handle for the cURL object.
|
513 |
+
*/
|
514 |
+
public function prep_request()
|
515 |
+
{
|
516 |
+
$curl_handle = curl_init();
|
517 |
+
|
518 |
+
// Set default options.
|
519 |
+
curl_setopt($curl_handle, CURLOPT_URL, $this->request_url);
|
520 |
+
curl_setopt($curl_handle, CURLOPT_FILETIME, true);
|
521 |
+
curl_setopt($curl_handle, CURLOPT_FRESH_CONNECT, false);
|
522 |
+
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false);
|
523 |
+
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, true);
|
524 |
+
curl_setopt($curl_handle, CURLOPT_CLOSEPOLICY, CURLCLOSEPOLICY_LEAST_RECENTLY_USED);
|
525 |
+
curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, true);
|
526 |
+
curl_setopt($curl_handle, CURLOPT_MAXREDIRS, 5);
|
527 |
+
curl_setopt($curl_handle, CURLOPT_HEADER, true);
|
528 |
+
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
|
529 |
+
curl_setopt($curl_handle, CURLOPT_TIMEOUT, 5184000);
|
530 |
+
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 120);
|
531 |
+
curl_setopt($curl_handle, CURLOPT_NOSIGNAL, true);
|
532 |
+
curl_setopt($curl_handle, CURLOPT_REFERER, $this->request_url);
|
533 |
+
curl_setopt($curl_handle, CURLOPT_USERAGENT, $this->useragent);
|
534 |
+
curl_setopt($curl_handle, CURLOPT_READFUNCTION, array($this, 'streaming_read_callback'));
|
535 |
+
|
536 |
+
// Enable a proxy connection if requested.
|
537 |
+
if ($this->proxy)
|
538 |
+
{
|
539 |
+
curl_setopt($curl_handle, CURLOPT_HTTPPROXYTUNNEL, true);
|
540 |
+
|
541 |
+
$host = $this->proxy['host'];
|
542 |
+
$host .= ($this->proxy['port']) ? ':' . $this->proxy['port'] : '';
|
543 |
+
curl_setopt($curl_handle, CURLOPT_PROXY, $host);
|
544 |
+
|
545 |
+
if (isset($this->proxy['user']) && isset($this->proxy['pass']))
|
546 |
+
{
|
547 |
+
curl_setopt($curl_handle, CURLOPT_PROXYUSERPWD, $this->proxy['user'] . ':' . $this->proxy['pass']);
|
548 |
+
}
|
549 |
+
}
|
550 |
+
|
551 |
+
// Set credentials for HTTP Basic/Digest Authentication.
|
552 |
+
if ($this->username && $this->password)
|
553 |
+
{
|
554 |
+
curl_setopt($curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
|
555 |
+
curl_setopt($curl_handle, CURLOPT_USERPWD, $this->username . ':' . $this->password);
|
556 |
+
}
|
557 |
+
|
558 |
+
// Handle the encoding if we can.
|
559 |
+
if (extension_loaded('zlib'))
|
560 |
+
{
|
561 |
+
curl_setopt($curl_handle, CURLOPT_ENCODING, '');
|
562 |
+
}
|
563 |
+
|
564 |
+
// Process custom headers
|
565 |
+
if (isset($this->request_headers) && count($this->request_headers))
|
566 |
+
{
|
567 |
+
$temp_headers = array();
|
568 |
+
|
569 |
+
foreach ($this->request_headers as $k => $v)
|
570 |
+
{
|
571 |
+
$temp_headers[] = $k . ': ' . $v;
|
572 |
+
}
|
573 |
+
|
574 |
+
curl_setopt($curl_handle, CURLOPT_HTTPHEADER, $temp_headers);
|
575 |
+
}
|
576 |
+
|
577 |
+
switch ($this->method)
|
578 |
+
{
|
579 |
+
case self::HTTP_PUT:
|
580 |
+
curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, 'PUT');
|
581 |
+
if (isset($this->read_stream))
|
582 |
+
{
|
583 |
+
if (!isset($this->read_stream_size) || $this->read_stream_size < 0)
|
584 |
+
{
|
585 |
+
throw new RequestCore_Exception('The stream size for the streaming upload cannot be determined.');
|
586 |
+
}
|
587 |
+
|
588 |
+
curl_setopt($curl_handle, CURLOPT_INFILESIZE, $this->read_stream_size);
|
589 |
+
curl_setopt($curl_handle, CURLOPT_UPLOAD, true);
|
590 |
+
}
|
591 |
+
else
|
592 |
+
{
|
593 |
+
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $this->request_body);
|
594 |
+
}
|
595 |
+
break;
|
596 |
+
|
597 |
+
case self::HTTP_POST:
|
598 |
+
curl_setopt($curl_handle, CURLOPT_POST, true);
|
599 |
+
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $this->request_body);
|
600 |
+
break;
|
601 |
+
|
602 |
+
case self::HTTP_HEAD:
|
603 |
+
curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, self::HTTP_HEAD);
|
604 |
+
curl_setopt($curl_handle, CURLOPT_NOBODY, 1);
|
605 |
+
break;
|
606 |
+
|
607 |
+
default: // Assumed GET
|
608 |
+
curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, $this->method);
|
609 |
+
if (isset($this->write_stream))
|
610 |
+
{
|
611 |
+
curl_setopt($curl_handle, CURLOPT_WRITEFUNCTION, array($this, 'streaming_write_callback'));
|
612 |
+
curl_setopt($curl_handle, CURLOPT_HEADER, false);
|
613 |
+
}
|
614 |
+
else
|
615 |
+
{
|
616 |
+
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $this->request_body);
|
617 |
+
}
|
618 |
+
break;
|
619 |
+
}
|
620 |
+
|
621 |
+
// Merge in the CURLOPTs
|
622 |
+
if (isset($this->curlopts) && sizeof($this->curlopts) > 0)
|
623 |
+
{
|
624 |
+
foreach ($this->curlopts as $k => $v)
|
625 |
+
{
|
626 |
+
curl_setopt($curl_handle, $k, $v);
|
627 |
+
}
|
628 |
+
}
|
629 |
+
|
630 |
+
return $curl_handle;
|
631 |
+
}
|
632 |
+
|
633 |
+
/**
|
634 |
+
* Take the post-processed cURL data and break it down into useful header/body/info chunks. Uses the
|
635 |
+
* data stored in the `curl_handle` and `response` properties unless replacement data is passed in via
|
636 |
+
* parameters.
|
637 |
+
*
|
638 |
+
* @param resource $curl_handle (Optional) The reference to the already executed cURL request.
|
639 |
+
* @param string $response (Optional) The actual response content itself that needs to be parsed.
|
640 |
+
* @return ResponseCore A <ResponseCore> object containing a parsed HTTP response.
|
641 |
+
*/
|
642 |
+
public function process_response($curl_handle = null, $response = null)
|
643 |
+
{
|
644 |
+
// Accept a custom one if it's passed.
|
645 |
+
if ($curl_handle && $response)
|
646 |
+
{
|
647 |
+
$this->curl_handle = $curl_handle;
|
648 |
+
$this->response = $response;
|
649 |
+
}
|
650 |
+
|
651 |
+
// As long as this came back as a valid resource...
|
652 |
+
if (is_resource($this->curl_handle))
|
653 |
+
{
|
654 |
+
// Determine what's what.
|
655 |
+
$header_size = curl_getinfo($this->curl_handle, CURLINFO_HEADER_SIZE);
|
656 |
+
$this->response_headers = substr($this->response, 0, $header_size);
|
657 |
+
$this->response_body = substr($this->response, $header_size);
|
658 |
+
$this->response_code = curl_getinfo($this->curl_handle, CURLINFO_HTTP_CODE);
|
659 |
+
$this->response_info = curl_getinfo($this->curl_handle);
|
660 |
+
|
661 |
+
// Parse out the headers
|
662 |
+
$this->response_headers = explode("\r\n\r\n", trim($this->response_headers));
|
663 |
+
$this->response_headers = array_pop($this->response_headers);
|
664 |
+
$this->response_headers = explode("\r\n", $this->response_headers);
|
665 |
+
array_shift($this->response_headers);
|
666 |
+
|
667 |
+
// Loop through and split up the headers.
|
668 |
+
$header_assoc = array();
|
669 |
+
foreach ($this->response_headers as $header)
|
670 |
+
{
|
671 |
+
$kv = explode(': ', $header);
|
672 |
+
$header_assoc[strtolower($kv[0])] = $kv[1];
|
673 |
+
}
|
674 |
+
|
675 |
+
// Reset the headers to the appropriate property.
|
676 |
+
$this->response_headers = $header_assoc;
|
677 |
+
$this->response_headers['_info'] = $this->response_info;
|
678 |
+
$this->response_headers['_info']['method'] = $this->method;
|
679 |
+
|
680 |
+
if ($curl_handle && $response)
|
681 |
+
{
|
682 |
+
return new $this->response_class($this->response_headers, $this->response_body, $this->response_code, $this->curl_handle);
|
683 |
+
}
|
684 |
+
}
|
685 |
+
|
686 |
+
// Return false
|
687 |
+
return false;
|
688 |
+
}
|
689 |
+
|
690 |
+
/**
|
691 |
+
* Sends the request, calling necessary utility functions to update built-in properties.
|
692 |
+
*
|
693 |
+
* @param boolean $parse (Optional) Whether to parse the response with ResponseCore or not.
|
694 |
+
* @return string The resulting unparsed data from the request.
|
695 |
+
*/
|
696 |
+
public function send_request($parse = false)
|
697 |
+
{
|
698 |
+
set_time_limit(0);
|
699 |
+
|
700 |
+
$curl_handle = $this->prep_request();
|
701 |
+
$this->response = curl_exec($curl_handle);
|
702 |
+
|
703 |
+
if ($this->response === false)
|
704 |
+
{
|
705 |
+
throw new RequestCore_Exception('cURL resource: ' . (string) $curl_handle . '; cURL error: ' . curl_error($curl_handle) . ' (' . curl_errno($curl_handle) . ')');
|
706 |
+
}
|
707 |
+
|
708 |
+
$parsed_response = $this->process_response($curl_handle, $this->response);
|
709 |
+
|
710 |
+
curl_close($curl_handle);
|
711 |
+
|
712 |
+
if ($parse)
|
713 |
+
{
|
714 |
+
return $parsed_response;
|
715 |
+
}
|
716 |
+
|
717 |
+
return $this->response;
|
718 |
+
}
|
719 |
+
|
720 |
+
/**
|
721 |
+
* Sends the request using <php:curl_multi_exec()>, enabling parallel requests. Uses the "rolling" method.
|
722 |
+
*
|
723 |
+
* @param array $handles (Required) An indexed array of cURL handles to process simultaneously.
|
724 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
725 |
+
* <li><code>callback</code> - <code>string|array</code> - Optional - The string name of a function to pass the response data to. If this is a method, pass an array where the <code>[0]</code> index is the class and the <code>[1]</code> index is the method name.</li>
|
726 |
+
* <li><code>limit</code> - <code>integer</code> - Optional - The number of simultaneous requests to make. This can be useful for scaling around slow server responses. Defaults to trusting cURLs judgement as to how many to use.</li></ul>
|
727 |
+
* @return array Post-processed cURL responses.
|
728 |
+
*/
|
729 |
+
public function send_multi_request($handles, $opt = null)
|
730 |
+
{
|
731 |
+
set_time_limit(0);
|
732 |
+
|
733 |
+
// Skip everything if there are no handles to process.
|
734 |
+
if (count($handles) === 0) return array();
|
735 |
+
|
736 |
+
if (!$opt) $opt = array();
|
737 |
+
|
738 |
+
// Initialize any missing options
|
739 |
+
$limit = isset($opt['limit']) ? $opt['limit'] : -1;
|
740 |
+
|
741 |
+
// Initialize
|
742 |
+
$handle_list = $handles;
|
743 |
+
$http = new $this->request_class();
|
744 |
+
$multi_handle = curl_multi_init();
|
745 |
+
$handles_post = array();
|
746 |
+
$added = count($handles);
|
747 |
+
$last_handle = null;
|
748 |
+
$count = 0;
|
749 |
+
$i = 0;
|
750 |
+
|
751 |
+
// Loop through the cURL handles and add as many as it set by the limit parameter.
|
752 |
+
while ($i < $added)
|
753 |
+
{
|
754 |
+
if ($limit > 0 && $i >= $limit) break;
|
755 |
+
curl_multi_add_handle($multi_handle, array_shift($handles));
|
756 |
+
$i++;
|
757 |
+
}
|
758 |
+
|
759 |
+
do
|
760 |
+
{
|
761 |
+
$active = false;
|
762 |
+
|
763 |
+
// Start executing and wait for a response.
|
764 |
+
while (($status = curl_multi_exec($multi_handle, $active)) === CURLM_CALL_MULTI_PERFORM)
|
765 |
+
{
|
766 |
+
// Start looking for possible responses immediately when we have to add more handles
|
767 |
+
if (count($handles) > 0) break;
|
768 |
+
}
|
769 |
+
|
770 |
+
// Figure out which requests finished.
|
771 |
+
$to_process = array();
|
772 |
+
|
773 |
+
while ($done = curl_multi_info_read($multi_handle))
|
774 |
+
{
|
775 |
+
// Since curl_errno() isn't reliable for handles that were in multirequests, we check the 'result' of the info read, which contains the curl error number, (listed here http://curl.haxx.se/libcurl/c/libcurl-errors.html )
|
776 |
+
if ($done['result'] > 0)
|
777 |
+
{
|
778 |
+
throw new RequestCore_Exception('cURL resource: ' . (string) $done['handle'] . '; cURL error: ' . curl_error($done['handle']) . ' (' . $done['result'] . ')');
|
779 |
+
}
|
780 |
+
|
781 |
+
// Because curl_multi_info_read() might return more than one message about a request, we check to see if this request is already in our array of completed requests
|
782 |
+
elseif (!isset($to_process[(int) $done['handle']]))
|
783 |
+
{
|
784 |
+
$to_process[(int) $done['handle']] = $done;
|
785 |
+
}
|
786 |
+
}
|
787 |
+
|
788 |
+
// Actually deal with the request
|
789 |
+
foreach ($to_process as $pkey => $done)
|
790 |
+
{
|
791 |
+
$response = $http->process_response($done['handle'], curl_multi_getcontent($done['handle']));
|
792 |
+
$key = array_search($done['handle'], $handle_list, true);
|
793 |
+
$handles_post[$key] = $response;
|
794 |
+
|
795 |
+
if (count($handles) > 0)
|
796 |
+
{
|
797 |
+
curl_multi_add_handle($multi_handle, array_shift($handles));
|
798 |
+
}
|
799 |
+
|
800 |
+
curl_multi_remove_handle($multi_handle, $done['handle']);
|
801 |
+
curl_close($done['handle']);
|
802 |
+
}
|
803 |
+
}
|
804 |
+
while ($active || count($handles_post) < $added);
|
805 |
+
|
806 |
+
curl_multi_close($multi_handle);
|
807 |
+
|
808 |
+
ksort($handles_post, SORT_NUMERIC);
|
809 |
+
return $handles_post;
|
810 |
+
}
|
811 |
+
|
812 |
+
|
813 |
+
/*%******************************************************************************************%*/
|
814 |
+
// RESPONSE METHODS
|
815 |
+
|
816 |
+
/**
|
817 |
+
* Get the HTTP response headers from the request.
|
818 |
+
*
|
819 |
+
* @param string $header (Optional) A specific header value to return. Defaults to all headers.
|
820 |
+
* @return string|array All or selected header values.
|
821 |
+
*/
|
822 |
+
public function get_response_header($header = null)
|
823 |
+
{
|
824 |
+
if ($header)
|
825 |
+
{
|
826 |
+
return $this->response_headers[strtolower($header)];
|
827 |
+
}
|
828 |
+
return $this->response_headers;
|
829 |
+
}
|
830 |
+
|
831 |
+
/**
|
832 |
+
* Get the HTTP response body from the request.
|
833 |
+
*
|
834 |
+
* @return string The response body.
|
835 |
+
*/
|
836 |
+
public function get_response_body()
|
837 |
+
{
|
838 |
+
return $this->response_body;
|
839 |
+
}
|
840 |
+
|
841 |
+
/**
|
842 |
+
* Get the HTTP response code from the request.
|
843 |
+
*
|
844 |
+
* @return string The HTTP response code.
|
845 |
+
*/
|
846 |
+
public function get_response_code()
|
847 |
+
{
|
848 |
+
return $this->response_code;
|
849 |
+
}
|
850 |
+
}
|
851 |
+
|
852 |
+
|
853 |
+
/**
|
854 |
+
* Container for all response-related methods.
|
855 |
+
*/
|
856 |
+
class ResponseCore
|
857 |
+
{
|
858 |
+
/**
|
859 |
+
* Stores the HTTP header information.
|
860 |
+
*/
|
861 |
+
public $header;
|
862 |
+
|
863 |
+
/**
|
864 |
+
* Stores the SimpleXML response.
|
865 |
+
*/
|
866 |
+
public $body;
|
867 |
+
|
868 |
+
/**
|
869 |
+
* Stores the HTTP response code.
|
870 |
+
*/
|
871 |
+
public $status;
|
872 |
+
|
873 |
+
/**
|
874 |
+
* Constructs a new instance of this class.
|
875 |
+
*
|
876 |
+
* @param array $header (Required) Associative array of HTTP headers (typically returned by <RequestCore::get_response_header()>).
|
877 |
+
* @param string $body (Required) XML-formatted response from AWS.
|
878 |
+
* @param integer $status (Optional) HTTP response status code from the request.
|
879 |
+
* @return object Contains an <php:array> `header` property (HTTP headers as an associative array), a <php:SimpleXMLElement> or <php:string> `body` property, and an <php:integer> `status` code.
|
880 |
+
*/
|
881 |
+
public function __construct($header, $body, $status = null)
|
882 |
+
{
|
883 |
+
$this->header = $header;
|
884 |
+
$this->body = $body;
|
885 |
+
$this->status = $status;
|
886 |
+
|
887 |
+
return $this;
|
888 |
+
}
|
889 |
+
|
890 |
+
/**
|
891 |
+
* Did we receive the status code we expected?
|
892 |
+
*
|
893 |
+
* @param integer|array $codes (Optional) The status code(s) to expect. Pass an <php:integer> for a single acceptable value, or an <php:array> of integers for multiple acceptable values.
|
894 |
+
* @return boolean Whether we received the expected status code or not.
|
895 |
+
*/
|
896 |
+
public function isOK($codes = array(200, 201, 204, 206))
|
897 |
+
{
|
898 |
+
if (is_array($codes))
|
899 |
+
{
|
900 |
+
return in_array($this->status, $codes);
|
901 |
+
}
|
902 |
+
|
903 |
+
return $this->status === $codes;
|
904 |
+
}
|
905 |
+
}
|
906 |
+
|
907 |
+
/**
|
908 |
+
* Default RequestCore Exception.
|
909 |
+
*/
|
910 |
+
class RequestCore_Exception extends Exception {}
|
app/libs/aws/lib/yaml/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Copyright (c) 2008-2009 Fabien Potencier
|
2 |
+
|
3 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4 |
+
of this software and associated documentation files (the "Software"), to deal
|
5 |
+
in the Software without restriction, including without limitation the rights
|
6 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7 |
+
copies of the Software, and to permit persons to whom the Software is furnished
|
8 |
+
to do so, subject to the following conditions:
|
9 |
+
|
10 |
+
The above copyright notice and this permission notice shall be included in all
|
11 |
+
copies or substantial portions of the Software.
|
12 |
+
|
13 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19 |
+
THE SOFTWARE.
|
app/libs/aws/lib/yaml/README.markdown
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Symfony YAML: A PHP library that speaks YAML
|
2 |
+
============================================
|
3 |
+
|
4 |
+
Symfony YAML is a PHP library that parses YAML strings and converts them to
|
5 |
+
PHP arrays. It can also converts PHP arrays to YAML strings. Its official
|
6 |
+
website is at http://components.symfony-project.org/yaml/.
|
7 |
+
|
8 |
+
The documentation is to be found in the `doc/` directory.
|
9 |
+
|
10 |
+
Symfony YAML is licensed under the MIT license (see LICENSE file).
|
11 |
+
|
12 |
+
The Symfony YAML library is developed and maintained by the
|
13 |
+
[symfony](http://www.symfony-project.org/) project team. It has been extracted
|
14 |
+
from symfony to be used as a standalone library. Symfony YAML is part of the
|
15 |
+
[symfony components project](http://components.symfony-project.org/).
|
app/libs/aws/lib/yaml/lib/sfYaml.php
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* This file is part of the symfony package.
|
5 |
+
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
6 |
+
*
|
7 |
+
* For the full copyright and license information, please view the LICENSE
|
8 |
+
* file that was distributed with this source code.
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* sfYaml offers convenience methods to load and dump YAML.
|
13 |
+
*
|
14 |
+
* @package symfony
|
15 |
+
* @subpackage yaml
|
16 |
+
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
17 |
+
* @version SVN: $Id: sfYaml.class.php 8988 2008-05-15 20:24:26Z fabien $
|
18 |
+
*/
|
19 |
+
class sfYaml
|
20 |
+
{
|
21 |
+
static protected
|
22 |
+
$spec = '1.2';
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Sets the YAML specification version to use.
|
26 |
+
*
|
27 |
+
* @param string $version The YAML specification version
|
28 |
+
*/
|
29 |
+
static public function setSpecVersion($version)
|
30 |
+
{
|
31 |
+
if (!in_array($version, array('1.1', '1.2')))
|
32 |
+
{
|
33 |
+
throw new InvalidArgumentException(sprintf('Version %s of the YAML specifications is not supported', $version));
|
34 |
+
}
|
35 |
+
|
36 |
+
self::$spec = $version;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Gets the YAML specification version to use.
|
41 |
+
*
|
42 |
+
* @return string The YAML specification version
|
43 |
+
*/
|
44 |
+
static public function getSpecVersion()
|
45 |
+
{
|
46 |
+
return self::$spec;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Loads YAML into a PHP array.
|
51 |
+
*
|
52 |
+
* The load method, when supplied with a YAML stream (string or file),
|
53 |
+
* will do its best to convert YAML in a file into a PHP array.
|
54 |
+
*
|
55 |
+
* Usage:
|
56 |
+
* <code>
|
57 |
+
* $array = sfYaml::load('config.yml');
|
58 |
+
* print_r($array);
|
59 |
+
* </code>
|
60 |
+
*
|
61 |
+
* @param string $input Path of YAML file or string containing YAML
|
62 |
+
*
|
63 |
+
* @return array The YAML converted to a PHP array
|
64 |
+
*
|
65 |
+
* @throws InvalidArgumentException If the YAML is not valid
|
66 |
+
*/
|
67 |
+
public static function load($input)
|
68 |
+
{
|
69 |
+
$file = '';
|
70 |
+
|
71 |
+
// if input is a file, process it
|
72 |
+
if (strpos($input, "\n") === false && is_file($input))
|
73 |
+
{
|
74 |
+
$file = $input;
|
75 |
+
|
76 |
+
ob_start();
|
77 |
+
$retval = include($input);
|
78 |
+
$content = ob_get_clean();
|
79 |
+
|
80 |
+
// if an array is returned by the config file assume it's in plain php form else in YAML
|
81 |
+
$input = is_array($retval) ? $retval : $content;
|
82 |
+
}
|
83 |
+
|
84 |
+
// if an array is returned by the config file assume it's in plain php form else in YAML
|
85 |
+
if (is_array($input))
|
86 |
+
{
|
87 |
+
return $input;
|
88 |
+
}
|
89 |
+
|
90 |
+
require_once dirname(__FILE__).'/sfYamlParser.php';
|
91 |
+
|
92 |
+
$yaml = new sfYamlParser();
|
93 |
+
|
94 |
+
try
|
95 |
+
{
|
96 |
+
$ret = $yaml->parse($input);
|
97 |
+
}
|
98 |
+
catch (Exception $e)
|
99 |
+
{
|
100 |
+
throw new InvalidArgumentException(sprintf('Unable to parse %s: %s', $file ? sprintf('file "%s"', $file) : 'string', $e->getMessage()));
|
101 |
+
}
|
102 |
+
|
103 |
+
return $ret;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Dumps a PHP array to a YAML string.
|
108 |
+
*
|
109 |
+
* The dump method, when supplied with an array, will do its best
|
110 |
+
* to convert the array into friendly YAML.
|
111 |
+
*
|
112 |
+
* @param array $array PHP array
|
113 |
+
* @param integer $inline The level where you switch to inline YAML
|
114 |
+
*
|
115 |
+
* @return string A YAML string representing the original PHP array
|
116 |
+
*/
|
117 |
+
public static function dump($array, $inline = 2)
|
118 |
+
{
|
119 |
+
require_once dirname(__FILE__).'/sfYamlDumper.php';
|
120 |
+
|
121 |
+
$yaml = new sfYamlDumper();
|
122 |
+
|
123 |
+
return $yaml->dump($array, $inline);
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Wraps echo to automatically provide a newline.
|
129 |
+
*
|
130 |
+
* @param string $string The string to echo with new line
|
131 |
+
*/
|
132 |
+
function echoln($string)
|
133 |
+
{
|
134 |
+
echo $string."\n";
|
135 |
+
}
|
app/libs/aws/lib/yaml/lib/sfYamlDumper.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* This file is part of the symfony package.
|
5 |
+
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
6 |
+
*
|
7 |
+
* For the full copyright and license information, please view the LICENSE
|
8 |
+
* file that was distributed with this source code.
|
9 |
+
*/
|
10 |
+
|
11 |
+
require_once(dirname(__FILE__).'/sfYamlInline.php');
|
12 |
+
|
13 |
+
/**
|
14 |
+
* sfYamlDumper dumps PHP variables to YAML strings.
|
15 |
+
*
|
16 |
+
* @package symfony
|
17 |
+
* @subpackage yaml
|
18 |
+
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
19 |
+
* @version SVN: $Id: sfYamlDumper.class.php 10575 2008-08-01 13:08:42Z nicolas $
|
20 |
+
*/
|
21 |
+
class sfYamlDumper
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* Dumps a PHP value to YAML.
|
25 |
+
*
|
26 |
+
* @param mixed $input The PHP value
|
27 |
+
* @param integer $inline The level where you switch to inline YAML
|
28 |
+
* @param integer $indent The level o indentation indentation (used internally)
|
29 |
+
*
|
30 |
+
* @return string The YAML representation of the PHP value
|
31 |
+
*/
|
32 |
+
public function dump($input, $inline = 0, $indent = 0)
|
33 |
+
{
|
34 |
+
$output = '';
|
35 |
+
$prefix = $indent ? str_repeat(' ', $indent) : '';
|
36 |
+
|
37 |
+
if ($inline <= 0 || !is_array($input) || empty($input))
|
38 |
+
{
|
39 |
+
$output .= $prefix.sfYamlInline::dump($input);
|
40 |
+
}
|
41 |
+
else
|
42 |
+
{
|
43 |
+
$isAHash = array_keys($input) !== range(0, count($input) - 1);
|
44 |
+
|
45 |
+
foreach ($input as $key => $value)
|
46 |
+
{
|
47 |
+
$willBeInlined = $inline - 1 <= 0 || !is_array($value) || empty($value);
|
48 |
+
|
49 |
+
$output .= sprintf('%s%s%s%s',
|
50 |
+
$prefix,
|
51 |
+
$isAHash ? sfYamlInline::dump($key).':' : '-',
|
52 |
+
$willBeInlined ? ' ' : "\n",
|
53 |
+
$this->dump($value, $inline - 1, $willBeInlined ? 0 : $indent + 2)
|
54 |
+
).($willBeInlined ? "\n" : '');
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
return $output;
|
59 |
+
}
|
60 |
+
}
|
app/libs/aws/lib/yaml/lib/sfYamlInline.php
ADDED
@@ -0,0 +1,442 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* This file is part of the symfony package.
|
5 |
+
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
6 |
+
*
|
7 |
+
* For the full copyright and license information, please view the LICENSE
|
8 |
+
* file that was distributed with this source code.
|
9 |
+
*/
|
10 |
+
|
11 |
+
require_once dirname(__FILE__).'/sfYaml.php';
|
12 |
+
|
13 |
+
/**
|
14 |
+
* sfYamlInline implements a YAML parser/dumper for the YAML inline syntax.
|
15 |
+
*
|
16 |
+
* @package symfony
|
17 |
+
* @subpackage yaml
|
18 |
+
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
19 |
+
* @version SVN: $Id: sfYamlInline.class.php 16177 2009-03-11 08:32:48Z fabien $
|
20 |
+
*/
|
21 |
+
class sfYamlInline
|
22 |
+
{
|
23 |
+
const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\']*(?:\'\'[^\']*)*)\')';
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Convert a YAML string to a PHP array.
|
27 |
+
*
|
28 |
+
* @param string $value A YAML string
|
29 |
+
*
|
30 |
+
* @return array A PHP array representing the YAML string
|
31 |
+
*/
|
32 |
+
static public function load($value)
|
33 |
+
{
|
34 |
+
$value = trim($value);
|
35 |
+
|
36 |
+
if (0 == strlen($value))
|
37 |
+
{
|
38 |
+
return '';
|
39 |
+
}
|
40 |
+
|
41 |
+
if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2)
|
42 |
+
{
|
43 |
+
$mbEncoding = mb_internal_encoding();
|
44 |
+
mb_internal_encoding('ASCII');
|
45 |
+
}
|
46 |
+
|
47 |
+
switch ($value[0])
|
48 |
+
{
|
49 |
+
case '[':
|
50 |
+
$result = self::parseSequence($value);
|
51 |
+
break;
|
52 |
+
case '{':
|
53 |
+
$result = self::parseMapping($value);
|
54 |
+
break;
|
55 |
+
default:
|
56 |
+
$result = self::parseScalar($value);
|
57 |
+
}
|
58 |
+
|
59 |
+
if (isset($mbEncoding))
|
60 |
+
{
|
61 |
+
mb_internal_encoding($mbEncoding);
|
62 |
+
}
|
63 |
+
|
64 |
+
return $result;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Dumps a given PHP variable to a YAML string.
|
69 |
+
*
|
70 |
+
* @param mixed $value The PHP variable to convert
|
71 |
+
*
|
72 |
+
* @return string The YAML string representing the PHP array
|
73 |
+
*/
|
74 |
+
static public function dump($value)
|
75 |
+
{
|
76 |
+
if ('1.1' === sfYaml::getSpecVersion())
|
77 |
+
{
|
78 |
+
$trueValues = array('true', 'on', '+', 'yes', 'y');
|
79 |
+
$falseValues = array('false', 'off', '-', 'no', 'n');
|
80 |
+
}
|
81 |
+
else
|
82 |
+
{
|
83 |
+
$trueValues = array('true');
|
84 |
+
$falseValues = array('false');
|
85 |
+
}
|
86 |
+
|
87 |
+
switch (true)
|
88 |
+
{
|
89 |
+
case is_resource($value):
|
90 |
+
throw new InvalidArgumentException('Unable to dump PHP resources in a YAML file.');
|
91 |
+
case is_object($value):
|
92 |
+
return '!!php/object:'.serialize($value);
|
93 |
+
case is_array($value):
|
94 |
+
return self::dumpArray($value);
|
95 |
+
case null === $value:
|
96 |
+
return 'null';
|
97 |
+
case true === $value:
|
98 |
+
return 'true';
|
99 |
+
case false === $value:
|
100 |
+
return 'false';
|
101 |
+
case ctype_digit($value):
|
102 |
+
return is_string($value) ? "'$value'" : (int) $value;
|
103 |
+
case is_numeric($value):
|
104 |
+
return is_infinite($value) ? str_ireplace('INF', '.Inf', strval($value)) : (is_string($value) ? "'$value'" : $value);
|
105 |
+
case false !== strpos($value, "\n") || false !== strpos($value, "\r"):
|
106 |
+
return sprintf('"%s"', str_replace(array('"', "\n", "\r"), array('\\"', '\n', '\r'), $value));
|
107 |
+
case preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ - ? | < > = ! % @ ` ]/x', $value):
|
108 |
+
return sprintf("'%s'", str_replace('\'', '\'\'', $value));
|
109 |
+
case '' == $value:
|
110 |
+
return "''";
|
111 |
+
case preg_match(self::getTimestampRegex(), $value):
|
112 |
+
return "'$value'";
|
113 |
+
case in_array(strtolower($value), $trueValues):
|
114 |
+
return "'$value'";
|
115 |
+
case in_array(strtolower($value), $falseValues):
|
116 |
+
return "'$value'";
|
117 |
+
case in_array(strtolower($value), array('null', '~')):
|
118 |
+
return "'$value'";
|
119 |
+
default:
|
120 |
+
return $value;
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Dumps a PHP array to a YAML string.
|
126 |
+
*
|
127 |
+
* @param array $value The PHP array to dump
|
128 |
+
*
|
129 |
+
* @return string The YAML string representing the PHP array
|
130 |
+
*/
|
131 |
+
static protected function dumpArray($value)
|
132 |
+
{
|
133 |
+
// array
|
134 |
+
$keys = array_keys($value);
|
135 |
+
if (
|
136 |
+
(1 == count($keys) && '0' == $keys[0])
|
137 |
+
||
|
138 |
+
(count($keys) > 1 && array_reduce($keys, create_function('$v,$w', 'return (integer) $v + $w;'), 0) == count($keys) * (count($keys) - 1) / 2))
|
139 |
+
{
|
140 |
+
$output = array();
|
141 |
+
foreach ($value as $val)
|
142 |
+
{
|
143 |
+
$output[] = self::dump($val);
|
144 |
+
}
|
145 |
+
|
146 |
+
return sprintf('[%s]', implode(', ', $output));
|
147 |
+
}
|
148 |
+
|
149 |
+
// mapping
|
150 |
+
$output = array();
|
151 |
+
foreach ($value as $key => $val)
|
152 |
+
{
|
153 |
+
$output[] = sprintf('%s: %s', self::dump($key), self::dump($val));
|
154 |
+
}
|
155 |
+
|
156 |
+
return sprintf('{ %s }', implode(', ', $output));
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Parses a scalar to a YAML string.
|
161 |
+
*
|
162 |
+
* @param scalar $scalar
|
163 |
+
* @param string $delimiters
|
164 |
+
* @param array $stringDelimiter
|
165 |
+
* @param integer $i
|
166 |
+
* @param boolean $evaluate
|
167 |
+
*
|
168 |
+
* @return string A YAML string
|
169 |
+
*/
|
170 |
+
static public function parseScalar($scalar, $delimiters = null, $stringDelimiters = array('"', "'"), &$i = 0, $evaluate = true)
|
171 |
+
{
|
172 |
+
if (in_array($scalar[$i], $stringDelimiters))
|
173 |
+
{
|
174 |
+
// quoted scalar
|
175 |
+
$output = self::parseQuotedScalar($scalar, $i);
|
176 |
+
}
|
177 |
+
else
|
178 |
+
{
|
179 |
+
// "normal" string
|
180 |
+
if (!$delimiters)
|
181 |
+
{
|
182 |
+
$output = substr($scalar, $i);
|
183 |
+
$i += strlen($output);
|
184 |
+
|
185 |
+
// remove comments
|
186 |
+
if (false !== $strpos = strpos($output, ' #'))
|
187 |
+
{
|
188 |
+
$output = rtrim(substr($output, 0, $strpos));
|
189 |
+
}
|
190 |
+
}
|
191 |
+
else if (preg_match('/^(.+?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match))
|
192 |
+
{
|
193 |
+
$output = $match[1];
|
194 |
+
$i += strlen($output);
|
195 |
+
}
|
196 |
+
else
|
197 |
+
{
|
198 |
+
throw new InvalidArgumentException(sprintf('Malformed inline YAML string (%s).', $scalar));
|
199 |
+
}
|
200 |
+
|
201 |
+
$output = $evaluate ? self::evaluateScalar($output) : $output;
|
202 |
+
}
|
203 |
+
|
204 |
+
return $output;
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Parses a quoted scalar to YAML.
|
209 |
+
*
|
210 |
+
* @param string $scalar
|
211 |
+
* @param integer $i
|
212 |
+
*
|
213 |
+
* @return string A YAML string
|
214 |
+
*/
|
215 |
+
static protected function parseQuotedScalar($scalar, &$i)
|
216 |
+
{
|
217 |
+
if (!preg_match('/'.self::REGEX_QUOTED_STRING.'/A', substr($scalar, $i), $match))
|
218 |
+
{
|
219 |
+
throw new InvalidArgumentException(sprintf('Malformed inline YAML string (%s).', substr($scalar, $i)));
|
220 |
+
}
|
221 |
+
|
222 |
+
$output = substr($match[0], 1, strlen($match[0]) - 2);
|
223 |
+
|
224 |
+
if ('"' == $scalar[$i])
|
225 |
+
{
|
226 |
+
// evaluate the string
|
227 |
+
$output = str_replace(array('\\"', '\\n', '\\r'), array('"', "\n", "\r"), $output);
|
228 |
+
}
|
229 |
+
else
|
230 |
+
{
|
231 |
+
// unescape '
|
232 |
+
$output = str_replace('\'\'', '\'', $output);
|
233 |
+
}
|
234 |
+
|
235 |
+
$i += strlen($match[0]);
|
236 |
+
|
237 |
+
return $output;
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Parses a sequence to a YAML string.
|
242 |
+
*
|
243 |
+
* @param string $sequence
|
244 |
+
* @param integer $i
|
245 |
+
*
|
246 |
+
* @return string A YAML string
|
247 |
+
*/
|
248 |
+
static protected function parseSequence($sequence, &$i = 0)
|
249 |
+
{
|
250 |
+
$output = array();
|
251 |
+
$len = strlen($sequence);
|
252 |
+
$i += 1;
|
253 |
+
|
254 |
+
// [foo, bar, ...]
|
255 |
+
while ($i < $len)
|
256 |
+
{
|
257 |
+
switch ($sequence[$i])
|
258 |
+
{
|
259 |
+
case '[':
|
260 |
+
// nested sequence
|
261 |
+
$output[] = self::parseSequence($sequence, $i);
|
262 |
+
break;
|
263 |
+
case '{':
|
264 |
+
// nested mapping
|
265 |
+
$output[] = self::parseMapping($sequence, $i);
|
266 |
+
break;
|
267 |
+
case ']':
|
268 |
+
return $output;
|
269 |
+
case ',':
|
270 |
+
case ' ':
|
271 |
+
break;
|
272 |
+
default:
|
273 |
+
$isQuoted = in_array($sequence[$i], array('"', "'"));
|
274 |
+
$value = self::parseScalar($sequence, array(',', ']'), array('"', "'"), $i);
|
275 |
+
|
276 |
+
if (!$isQuoted && false !== strpos($value, ': '))
|
277 |
+
{
|
278 |
+
// embedded mapping?
|
279 |
+
try
|
280 |
+
{
|
281 |
+
$value = self::parseMapping('{'.$value.'}');
|
282 |
+
}
|
283 |
+
catch (InvalidArgumentException $e)
|
284 |
+
{
|
285 |
+
// no, it's not
|
286 |
+
}
|
287 |
+
}
|
288 |
+
|
289 |
+
$output[] = $value;
|
290 |
+
|
291 |
+
--$i;
|
292 |
+
}
|
293 |
+
|
294 |
+
++$i;
|
295 |
+
}
|
296 |
+
|
297 |
+
throw new InvalidArgumentException(sprintf('Malformed inline YAML string %s', $sequence));
|
298 |
+
}
|
299 |
+
|
300 |
+
/**
|
301 |
+
* Parses a mapping to a YAML string.
|
302 |
+
*
|
303 |
+
* @param string $mapping
|
304 |
+
* @param integer $i
|
305 |
+
*
|
306 |
+
* @return string A YAML string
|
307 |
+
*/
|
308 |
+
static protected function parseMapping($mapping, &$i = 0)
|
309 |
+
{
|
310 |
+
$output = array();
|
311 |
+
$len = strlen($mapping);
|
312 |
+
$i += 1;
|
313 |
+
|
314 |
+
// {foo: bar, bar:foo, ...}
|
315 |
+
while ($i < $len)
|
316 |
+
{
|
317 |
+
switch ($mapping[$i])
|
318 |
+
{
|
319 |
+
case ' ':
|
320 |
+
case ',':
|
321 |
+
++$i;
|
322 |
+
continue 2;
|
323 |
+
case '}':
|
324 |
+
return $output;
|
325 |
+
}
|
326 |
+
|
327 |
+
// key
|
328 |
+
$key = self::parseScalar($mapping, array(':', ' '), array('"', "'"), $i, false);
|
329 |
+
|
330 |
+
// value
|
331 |
+
$done = false;
|
332 |
+
while ($i < $len)
|
333 |
+
{
|
334 |
+
switch ($mapping[$i])
|
335 |
+
{
|
336 |
+
case '[':
|
337 |
+
// nested sequence
|
338 |
+
$output[$key] = self::parseSequence($mapping, $i);
|
339 |
+
$done = true;
|
340 |
+
break;
|
341 |
+
case '{':
|
342 |
+
// nested mapping
|
343 |
+
$output[$key] = self::parseMapping($mapping, $i);
|
344 |
+
$done = true;
|
345 |
+
break;
|
346 |
+
case ':':
|
347 |
+
case ' ':
|
348 |
+
break;
|
349 |
+
default:
|
350 |
+
$output[$key] = self::parseScalar($mapping, array(',', '}'), array('"', "'"), $i);
|
351 |
+
$done = true;
|
352 |
+
--$i;
|
353 |
+
}
|
354 |
+
|
355 |
+
++$i;
|
356 |
+
|
357 |
+
if ($done)
|
358 |
+
{
|
359 |
+
continue 2;
|
360 |
+
}
|
361 |
+
}
|
362 |
+
}
|
363 |
+
|
364 |
+
throw new InvalidArgumentException(sprintf('Malformed inline YAML string %s', $mapping));
|
365 |
+
}
|
366 |
+
|
367 |
+
/**
|
368 |
+
* Evaluates scalars and replaces magic values.
|
369 |
+
*
|
370 |
+
* @param string $scalar
|
371 |
+
*
|
372 |
+
* @return string A YAML string
|
373 |
+
*/
|
374 |
+
static protected function evaluateScalar($scalar)
|
375 |
+
{
|
376 |
+
$scalar = trim($scalar);
|
377 |
+
|
378 |
+
if ('1.1' === sfYaml::getSpecVersion())
|
379 |
+
{
|
380 |
+
$trueValues = array('true', 'on', '+', 'yes', 'y');
|
381 |
+
$falseValues = array('false', 'off', '-', 'no', 'n');
|
382 |
+
}
|
383 |
+
else
|
384 |
+
{
|
385 |
+
$trueValues = array('true');
|
386 |
+
$falseValues = array('false');
|
387 |
+
}
|
388 |
+
|
389 |
+
switch (true)
|
390 |
+
{
|
391 |
+
case 'null' == strtolower($scalar):
|
392 |
+
case '' == $scalar:
|
393 |
+
case '~' == $scalar:
|
394 |
+
return null;
|
395 |
+
case 0 === strpos($scalar, '!str'):
|
396 |
+
return (string) substr($scalar, 5);
|
397 |
+
case 0 === strpos($scalar, '! '):
|
398 |
+
return intval(self::parseScalar(substr($scalar, 2)));
|
399 |
+
case 0 === strpos($scalar, '!!php/object:'):
|
400 |
+
return unserialize(substr($scalar, 13));
|
401 |
+
case ctype_digit($scalar):
|
402 |
+
$raw = $scalar;
|
403 |
+
$cast = intval($scalar);
|
404 |
+
return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
|
405 |
+
case in_array(strtolower($scalar), $trueValues):
|
406 |
+
return true;
|
407 |
+
case in_array(strtolower($scalar), $falseValues):
|
408 |
+
return false;
|
409 |
+
case is_numeric($scalar):
|
410 |
+
return '0x' == $scalar[0].$scalar[1] ? hexdec($scalar) : floatval($scalar);
|
411 |
+
case 0 == strcasecmp($scalar, '.inf'):
|
412 |
+
case 0 == strcasecmp($scalar, '.NaN'):
|
413 |
+
return -log(0);
|
414 |
+
case 0 == strcasecmp($scalar, '-.inf'):
|
415 |
+
return log(0);
|
416 |
+
case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar):
|
417 |
+
return floatval(str_replace(',', '', $scalar));
|
418 |
+
case preg_match(self::getTimestampRegex(), $scalar):
|
419 |
+
return strtotime($scalar);
|
420 |
+
default:
|
421 |
+
return (string) $scalar;
|
422 |
+
}
|
423 |
+
}
|
424 |
+
|
425 |
+
static protected function getTimestampRegex()
|
426 |
+
{
|
427 |
+
return <<<EOF
|
428 |
+
~^
|
429 |
+
(?P<year>[0-9][0-9][0-9][0-9])
|
430 |
+
-(?P<month>[0-9][0-9]?)
|
431 |
+
-(?P<day>[0-9][0-9]?)
|
432 |
+
(?:(?:[Tt]|[ \t]+)
|
433 |
+
(?P<hour>[0-9][0-9]?)
|
434 |
+
:(?P<minute>[0-9][0-9])
|
435 |
+
:(?P<second>[0-9][0-9])
|
436 |
+
(?:\.(?P<fraction>[0-9]*))?
|
437 |
+
(?:[ \t]*(?P<tz>Z|(?P<tz_sign>[-+])(?P<tz_hour>[0-9][0-9]?)
|
438 |
+
(?::(?P<tz_minute>[0-9][0-9]))?))?)?
|
439 |
+
$~x
|
440 |
+
EOF;
|
441 |
+
}
|
442 |
+
}
|
app/libs/aws/lib/yaml/lib/sfYamlParser.php
ADDED
@@ -0,0 +1,612 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* This file is part of the symfony package.
|
5 |
+
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
6 |
+
*
|
7 |
+
* For the full copyright and license information, please view the LICENSE
|
8 |
+
* file that was distributed with this source code.
|
9 |
+
*/
|
10 |
+
|
11 |
+
require_once(dirname(__FILE__).'/sfYamlInline.php');
|
12 |
+
|
13 |
+
if (!defined('PREG_BAD_UTF8_OFFSET_ERROR'))
|
14 |
+
{
|
15 |
+
define('PREG_BAD_UTF8_OFFSET_ERROR', 5);
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* sfYamlParser parses YAML strings to convert them to PHP arrays.
|
20 |
+
*
|
21 |
+
* @package symfony
|
22 |
+
* @subpackage yaml
|
23 |
+
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
24 |
+
* @version SVN: $Id: sfYamlParser.class.php 10832 2008-08-13 07:46:08Z fabien $
|
25 |
+
*/
|
26 |
+
class sfYamlParser
|
27 |
+
{
|
28 |
+
protected
|
29 |
+
$offset = 0,
|
30 |
+
$lines = array(),
|
31 |
+
$currentLineNb = -1,
|
32 |
+
$currentLine = '',
|
33 |
+
$refs = array();
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Constructor
|
37 |
+
*
|
38 |
+
* @param integer $offset The offset of YAML document (used for line numbers in error messages)
|
39 |
+
*/
|
40 |
+
public function __construct($offset = 0)
|
41 |
+
{
|
42 |
+
$this->offset = $offset;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Parses a YAML string to a PHP value.
|
47 |
+
*
|
48 |
+
* @param string $value A YAML string
|
49 |
+
*
|
50 |
+
* @return mixed A PHP value
|
51 |
+
*
|
52 |
+
* @throws InvalidArgumentException If the YAML is not valid
|
53 |
+
*/
|
54 |
+
public function parse($value)
|
55 |
+
{
|
56 |
+
$value = str_replace("\t", ' ', $value); // Convert tabs to spaces.
|
57 |
+
|
58 |
+
$this->currentLineNb = -1;
|
59 |
+
$this->currentLine = '';
|
60 |
+
$this->lines = explode("\n", $this->cleanup($value));
|
61 |
+
|
62 |
+
if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2)
|
63 |
+
{
|
64 |
+
$mbEncoding = mb_internal_encoding();
|
65 |
+
mb_internal_encoding('ASCII');
|
66 |
+
}
|
67 |
+
|
68 |
+
$data = array();
|
69 |
+
while ($this->moveToNextLine())
|
70 |
+
{
|
71 |
+
if ($this->isCurrentLineEmpty())
|
72 |
+
{
|
73 |
+
continue;
|
74 |
+
}
|
75 |
+
|
76 |
+
// tab?
|
77 |
+
if (preg_match('#^\t+#', $this->currentLine))
|
78 |
+
{
|
79 |
+
throw new InvalidArgumentException(sprintf('A YAML file cannot contain tabs as indentation at line %d (%s).', $this->getRealCurrentLineNb() + 1, $this->currentLine));
|
80 |
+
}
|
81 |
+
|
82 |
+
$isRef = $isInPlace = $isProcessed = false;
|
83 |
+
if (preg_match('#^\-((?P<leadspaces>\s+)(?P<value>.+?))?\s*$#', $this->currentLine, $values))
|
84 |
+
{
|
85 |
+
if (isset($values['value']) && preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#', $values['value'], $matches))
|
86 |
+
{
|
87 |
+
$isRef = $matches['ref'];
|
88 |
+
$values['value'] = $matches['value'];
|
89 |
+
}
|
90 |
+
|
91 |
+
// array
|
92 |
+
if (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#'))
|
93 |
+
{
|
94 |
+
$c = $this->getRealCurrentLineNb() + 1;
|
95 |
+
$parser = new sfYamlParser($c);
|
96 |
+
$parser->refs =& $this->refs;
|
97 |
+
$data[] = $parser->parse($this->getNextEmbedBlock());
|
98 |
+
}
|
99 |
+
else
|
100 |
+
{
|
101 |
+
if (isset($values['leadspaces'])
|
102 |
+
&& ' ' == $values['leadspaces']
|
103 |
+
&& preg_match('#^(?P<key>'.sfYamlInline::REGEX_QUOTED_STRING.'|[^ \'"\{].*?) *\:(\s+(?P<value>.+?))?\s*$#', $values['value'], $matches))
|
104 |
+
{
|
105 |
+
// this is a compact notation element, add to next block and parse
|
106 |
+
$c = $this->getRealCurrentLineNb();
|
107 |
+
$parser = new sfYamlParser($c);
|
108 |
+
$parser->refs =& $this->refs;
|
109 |
+
|
110 |
+
$block = $values['value'];
|
111 |
+
if (!$this->isNextLineIndented())
|
112 |
+
{
|
113 |
+
$block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + 2);
|
114 |
+
}
|
115 |
+
|
116 |
+
$data[] = $parser->parse($block);
|
117 |
+
}
|
118 |
+
else
|
119 |
+
{
|
120 |
+
$data[] = $this->parseValue($values['value']);
|
121 |
+
}
|
122 |
+
}
|
123 |
+
}
|
124 |
+
else if (preg_match('#^(?P<key>'.sfYamlInline::REGEX_QUOTED_STRING.'|[^ \'"].*?) *\:(\s+(?P<value>.+?))?\s*$#', $this->currentLine, $values))
|
125 |
+
{
|
126 |
+
$key = sfYamlInline::parseScalar($values['key']);
|
127 |
+
|
128 |
+
if ('<<' === $key)
|
129 |
+
{
|
130 |
+
if (isset($values['value']) && '*' === substr($values['value'], 0, 1))
|
131 |
+
{
|
132 |
+
$isInPlace = substr($values['value'], 1);
|
133 |
+
if (!array_key_exists($isInPlace, $this->refs))
|
134 |
+
{
|
135 |
+
throw new InvalidArgumentException(sprintf('Reference "%s" does not exist at line %s (%s).', $isInPlace, $this->getRealCurrentLineNb() + 1, $this->currentLine));
|
136 |
+
}
|
137 |
+
}
|
138 |
+
else
|
139 |
+
{
|
140 |
+
if (isset($values['value']) && $values['value'] !== '')
|
141 |
+
{
|
142 |
+
$value = $values['value'];
|
143 |
+
}
|
144 |
+
else
|
145 |
+
{
|
146 |
+
$value = $this->getNextEmbedBlock();
|
147 |
+
}
|
148 |
+
$c = $this->getRealCurrentLineNb() + 1;
|
149 |
+
$parser = new sfYamlParser($c);
|
150 |
+
$parser->refs =& $this->refs;
|
151 |
+
$parsed = $parser->parse($value);
|
152 |
+
|
153 |
+
$merged = array();
|
154 |
+
if (!is_array($parsed))
|
155 |
+
{
|
156 |
+
throw new InvalidArgumentException(sprintf("YAML merge keys used with a scalar value instead of an array at line %s (%s)", $this->getRealCurrentLineNb() + 1, $this->currentLine));
|
157 |
+
}
|
158 |
+
else if (isset($parsed[0]))
|
159 |
+
{
|
160 |
+
// Numeric array, merge individual elements
|
161 |
+
foreach (array_reverse($parsed) as $parsedItem)
|
162 |
+
{
|
163 |
+
if (!is_array($parsedItem))
|
164 |
+
{
|
165 |
+
throw new InvalidArgumentException(sprintf("Merge items must be arrays at line %s (%s).", $this->getRealCurrentLineNb() + 1, $parsedItem));
|
166 |
+
}
|
167 |
+
$merged = array_merge($parsedItem, $merged);
|
168 |
+
}
|
169 |
+
}
|
170 |
+
else
|
171 |
+
{
|
172 |
+
// Associative array, merge
|
173 |
+
$merged = array_merge($merge, $parsed);
|
174 |
+
}
|
175 |
+
|
176 |
+
$isProcessed = $merged;
|
177 |
+
}
|
178 |
+
}
|
179 |
+
else if (isset($values['value']) && preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#', $values['value'], $matches))
|
180 |
+
{
|
181 |
+
$isRef = $matches['ref'];
|
182 |
+
$values['value'] = $matches['value'];
|
183 |
+
}
|
184 |
+
|
185 |
+
if ($isProcessed)
|
186 |
+
{
|
187 |
+
// Merge keys
|
188 |
+
$data = $isProcessed;
|
189 |
+
}
|
190 |
+
// hash
|
191 |
+
else if (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#'))
|
192 |
+
{
|
193 |
+
// if next line is less indented or equal, then it means that the current value is null
|
194 |
+
if ($this->isNextLineIndented())
|
195 |
+
{
|
196 |
+
$data[$key] = null;
|
197 |
+
}
|
198 |
+
else
|
199 |
+
{
|
200 |
+
$c = $this->getRealCurrentLineNb() + 1;
|
201 |
+
$parser = new sfYamlParser($c);
|
202 |
+
$parser->refs =& $this->refs;
|
203 |
+
$data[$key] = $parser->parse($this->getNextEmbedBlock());
|
204 |
+
}
|
205 |
+
}
|
206 |
+
else
|
207 |
+
{
|
208 |
+
if ($isInPlace)
|
209 |
+
{
|
210 |
+
$data = $this->refs[$isInPlace];
|
211 |
+
}
|
212 |
+
else
|
213 |
+
{
|
214 |
+
$data[$key] = $this->parseValue($values['value']);
|
215 |
+
}
|
216 |
+
}
|
217 |
+
}
|
218 |
+
else
|
219 |
+
{
|
220 |
+
// 1-liner followed by newline
|
221 |
+
if (2 == count($this->lines) && empty($this->lines[1]))
|
222 |
+
{
|
223 |
+
$value = sfYamlInline::load($this->lines[0]);
|
224 |
+
if (is_array($value))
|
225 |
+
{
|
226 |
+
$first = reset($value);
|
227 |
+
if ('*' === substr($first, 0, 1))
|
228 |
+
{
|
229 |
+
$data = array();
|
230 |
+
foreach ($value as $alias)
|
231 |
+
{
|
232 |
+
$data[] = $this->refs[substr($alias, 1)];
|
233 |
+
}
|
234 |
+
$value = $data;
|
235 |
+
}
|
236 |
+
}
|
237 |
+
|
238 |
+
if (isset($mbEncoding))
|
239 |
+
{
|
240 |
+
mb_internal_encoding($mbEncoding);
|
241 |
+
}
|
242 |
+
|
243 |
+
return $value;
|
244 |
+
}
|
245 |
+
|
246 |
+
switch (preg_last_error())
|
247 |
+
{
|
248 |
+
case PREG_INTERNAL_ERROR:
|
249 |
+
$error = 'Internal PCRE error on line';
|
250 |
+
break;
|
251 |
+
case PREG_BACKTRACK_LIMIT_ERROR:
|
252 |
+
$error = 'pcre.backtrack_limit reached on line';
|
253 |
+
break;
|
254 |
+
case PREG_RECURSION_LIMIT_ERROR:
|
255 |
+
$error = 'pcre.recursion_limit reached on line';
|
256 |
+
break;
|
257 |
+
case PREG_BAD_UTF8_ERROR:
|
258 |
+
$error = 'Malformed UTF-8 data on line';
|
259 |
+
break;
|
260 |
+
case PREG_BAD_UTF8_OFFSET_ERROR:
|
261 |
+
$error = 'Offset doesn\'t correspond to the begin of a valid UTF-8 code point on line';
|
262 |
+
break;
|
263 |
+
default:
|
264 |
+
$error = 'Unable to parse line';
|
265 |
+
}
|
266 |
+
|
267 |
+
throw new InvalidArgumentException(sprintf('%s %d (%s).', $error, $this->getRealCurrentLineNb() + 1, $this->currentLine));
|
268 |
+
}
|
269 |
+
|
270 |
+
if ($isRef)
|
271 |
+
{
|
272 |
+
$this->refs[$isRef] = end($data);
|
273 |
+
}
|
274 |
+
}
|
275 |
+
|
276 |
+
if (isset($mbEncoding))
|
277 |
+
{
|
278 |
+
mb_internal_encoding($mbEncoding);
|
279 |
+
}
|
280 |
+
|
281 |
+
return empty($data) ? null : $data;
|
282 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
* Returns the current line number (takes the offset into account).
|
286 |
+
*
|
287 |
+
* @return integer The current line number
|
288 |
+
*/
|
289 |
+
protected function getRealCurrentLineNb()
|
290 |
+
{
|
291 |
+
return $this->currentLineNb + $this->offset;
|
292 |
+
}
|
293 |
+
|
294 |
+
/**
|
295 |
+
* Returns the current line indentation.
|
296 |
+
*
|
297 |
+
* @return integer The current line indentation
|
298 |
+
*/
|
299 |
+
protected function getCurrentLineIndentation()
|
300 |
+
{
|
301 |
+
return strlen($this->currentLine) - strlen(ltrim($this->currentLine, ' '));
|
302 |
+
}
|
303 |
+
|
304 |
+
/**
|
305 |
+
* Returns the next embed block of YAML.
|
306 |
+
*
|
307 |
+
* @param integer $indentation The indent level at which the block is to be read, or null for default
|
308 |
+
*
|
309 |
+
* @return string A YAML string
|
310 |
+
*/
|
311 |
+
protected function getNextEmbedBlock($indentation = null)
|
312 |
+
{
|
313 |
+
$this->moveToNextLine();
|
314 |
+
|
315 |
+
if (null === $indentation)
|
316 |
+
{
|
317 |
+
$newIndent = $this->getCurrentLineIndentation();
|
318 |
+
|
319 |
+
if (!$this->isCurrentLineEmpty() && 0 == $newIndent)
|
320 |
+
{
|
321 |
+
throw new InvalidArgumentException(sprintf('Indentation problem at line %d (%s)', $this->getRealCurrentLineNb() + 1, $this->currentLine));
|
322 |
+
}
|
323 |
+
}
|
324 |
+
else
|
325 |
+
{
|
326 |
+
$newIndent = $indentation;
|
327 |
+
}
|
328 |
+
|
329 |
+
$data = array(substr($this->currentLine, $newIndent));
|
330 |
+
|
331 |
+
while ($this->moveToNextLine())
|
332 |
+
{
|
333 |
+
if ($this->isCurrentLineEmpty())
|
334 |
+
{
|
335 |
+
if ($this->isCurrentLineBlank())
|
336 |
+
{
|
337 |
+
$data[] = substr($this->currentLine, $newIndent);
|
338 |
+
}
|
339 |
+
|
340 |
+
continue;
|
341 |
+
}
|
342 |
+
|
343 |
+
$indent = $this->getCurrentLineIndentation();
|
344 |
+
|
345 |
+
if (preg_match('#^(?P<text> *)$#', $this->currentLine, $match))
|
346 |
+
{
|
347 |
+
// empty line
|
348 |
+
$data[] = $match['text'];
|
349 |
+
}
|
350 |
+
else if ($indent >= $newIndent)
|
351 |
+
{
|
352 |
+
$data[] = substr($this->currentLine, $newIndent);
|
353 |
+
}
|
354 |
+
else if (0 == $indent)
|
355 |
+
{
|
356 |
+
$this->moveToPreviousLine();
|
357 |
+
|
358 |
+
break;
|
359 |
+
}
|
360 |
+
else
|
361 |
+
{
|
362 |
+
throw new InvalidArgumentException(sprintf('Indentation problem at line %d (%s)', $this->getRealCurrentLineNb() + 1, $this->currentLine));
|
363 |
+
}
|
364 |
+
}
|
365 |
+
|
366 |
+
return implode("\n", $data);
|
367 |
+
}
|
368 |
+
|
369 |
+
/**
|
370 |
+
* Moves the parser to the next line.
|
371 |
+
*/
|
372 |
+
protected function moveToNextLine()
|
373 |
+
{
|
374 |
+
if ($this->currentLineNb >= count($this->lines) - 1)
|
375 |
+
{
|
376 |
+
return false;
|
377 |
+
}
|
378 |
+
|
379 |
+
$this->currentLine = $this->lines[++$this->currentLineNb];
|
380 |
+
|
381 |
+
return true;
|
382 |
+
}
|
383 |
+
|
384 |
+
/**
|
385 |
+
* Moves the parser to the previous line.
|
386 |
+
*/
|
387 |
+
protected function moveToPreviousLine()
|
388 |
+
{
|
389 |
+
$this->currentLine = $this->lines[--$this->currentLineNb];
|
390 |
+
}
|
391 |
+
|
392 |
+
/**
|
393 |
+
* Parses a YAML value.
|
394 |
+
*
|
395 |
+
* @param string $value A YAML value
|
396 |
+
*
|
397 |
+
* @return mixed A PHP value
|
398 |
+
*/
|
399 |
+
protected function parseValue($value)
|
400 |
+
{
|
401 |
+
if ('*' === substr($value, 0, 1))
|
402 |
+
{
|
403 |
+
if (false !== $pos = strpos($value, '#'))
|
404 |
+
{
|
405 |
+
$value = substr($value, 1, $pos - 2);
|
406 |
+
}
|
407 |
+
else
|
408 |
+
{
|
409 |
+
$value = substr($value, 1);
|
410 |
+
}
|
411 |
+
|
412 |
+
if (!array_key_exists($value, $this->refs))
|
413 |
+
{
|
414 |
+
throw new InvalidArgumentException(sprintf('Reference "%s" does not exist (%s).', $value, $this->currentLine));
|
415 |
+
}
|
416 |
+
return $this->refs[$value];
|
417 |
+
}
|
418 |
+
|
419 |
+
if (preg_match('/^(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?$/', $value, $matches))
|
420 |
+
{
|
421 |
+
$modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : '';
|
422 |
+
|
423 |
+
return $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), intval(abs($modifiers)));
|
424 |
+
}
|
425 |
+
else
|
426 |
+
{
|
427 |
+
return sfYamlInline::load($value);
|
428 |
+
}
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* Parses a folded scalar.
|
433 |
+
*
|
434 |
+
* @param string $separator The separator that was used to begin this folded scalar (| or >)
|
435 |
+
* @param string $indicator The indicator that was used to begin this folded scalar (+ or -)
|
436 |
+
* @param integer $indentation The indentation that was used to begin this folded scalar
|
437 |
+
*
|
438 |
+
* @return string The text value
|
439 |
+
*/
|
440 |
+
protected function parseFoldedScalar($separator, $indicator = '', $indentation = 0)
|
441 |
+
{
|
442 |
+
$separator = '|' == $separator ? "\n" : ' ';
|
443 |
+
$text = '';
|
444 |
+
|
445 |
+
$notEOF = $this->moveToNextLine();
|
446 |
+
|
447 |
+
while ($notEOF && $this->isCurrentLineBlank())
|
448 |
+
{
|
449 |
+
$text .= "\n";
|
450 |
+
|
451 |
+
$notEOF = $this->moveToNextLine();
|
452 |
+
}
|
453 |
+
|
454 |
+
if (!$notEOF)
|
455 |
+
{
|
456 |
+
return '';
|
457 |
+
}
|
458 |
+
|
459 |
+
if (!preg_match('#^(?P<indent>'.($indentation ? str_repeat(' ', $indentation) : ' +').')(?P<text>.*)$#', $this->currentLine, $matches))
|
460 |
+
{
|
461 |
+
$this->moveToPreviousLine();
|
462 |
+
|
463 |
+
return '';
|
464 |
+
}
|
465 |
+
|
466 |
+
$textIndent = $matches['indent'];
|
467 |
+
$previousIndent = 0;
|
468 |
+
|
469 |
+
$text .= $matches['text'].$separator;
|
470 |
+
while ($this->currentLineNb + 1 < count($this->lines))
|
471 |
+
{
|
472 |
+
$this->moveToNextLine();
|
473 |
+
|
474 |
+
if (preg_match('#^(?P<indent> {'.strlen($textIndent).',})(?P<text>.+)$#', $this->currentLine, $matches))
|
475 |
+
{
|
476 |
+
if (' ' == $separator && $previousIndent != $matches['indent'])
|
477 |
+
{
|
478 |
+
$text = substr($text, 0, -1)."\n";
|
479 |
+
}
|
480 |
+
$previousIndent = $matches['indent'];
|
481 |
+
|
482 |
+
$text .= str_repeat(' ', $diff = strlen($matches['indent']) - strlen($textIndent)).$matches['text'].($diff ? "\n" : $separator);
|
483 |
+
}
|
484 |
+
else if (preg_match('#^(?P<text> *)$#', $this->currentLine, $matches))
|
485 |
+
{
|
486 |
+
$text .= preg_replace('#^ {1,'.strlen($textIndent).'}#', '', $matches['text'])."\n";
|
487 |
+
}
|
488 |
+
else
|
489 |
+
{
|
490 |
+
$this->moveToPreviousLine();
|
491 |
+
|
492 |
+
break;
|
493 |
+
}
|
494 |
+
}
|
495 |
+
|
496 |
+
if (' ' == $separator)
|
497 |
+
{
|
498 |
+
// replace last separator by a newline
|
499 |
+
$text = preg_replace('/ (\n*)$/', "\n$1", $text);
|
500 |
+
}
|
501 |
+
|
502 |
+
switch ($indicator)
|
503 |
+
{
|
504 |
+
case '':
|
505 |
+
$text = preg_replace('#\n+$#s', "\n", $text);
|
506 |
+
break;
|
507 |
+
case '+':
|
508 |
+
break;
|
509 |
+
case '-':
|
510 |
+
$text = preg_replace('#\n+$#s', '', $text);
|
511 |
+
break;
|
512 |
+
}
|
513 |
+
|
514 |
+
return $text;
|
515 |
+
}
|
516 |
+
|
517 |
+
/**
|
518 |
+
* Returns true if the next line is indented.
|
519 |
+
*
|
520 |
+
* @return Boolean Returns true if the next line is indented, false otherwise
|
521 |
+
*/
|
522 |
+
protected function isNextLineIndented()
|
523 |
+
{
|
524 |
+
$currentIndentation = $this->getCurrentLineIndentation();
|
525 |
+
$notEOF = $this->moveToNextLine();
|
526 |
+
|
527 |
+
while ($notEOF && $this->isCurrentLineEmpty())
|
528 |
+
{
|
529 |
+
$notEOF = $this->moveToNextLine();
|
530 |
+
}
|
531 |
+
|
532 |
+
if (false === $notEOF)
|
533 |
+
{
|
534 |
+
return false;
|
535 |
+
}
|
536 |
+
|
537 |
+
$ret = false;
|
538 |
+
if ($this->getCurrentLineIndentation() <= $currentIndentation)
|
539 |
+
{
|
540 |
+
$ret = true;
|
541 |
+
}
|
542 |
+
|
543 |
+
$this->moveToPreviousLine();
|
544 |
+
|
545 |
+
return $ret;
|
546 |
+
}
|
547 |
+
|
548 |
+
/**
|
549 |
+
* Returns true if the current line is blank or if it is a comment line.
|
550 |
+
*
|
551 |
+
* @return Boolean Returns true if the current line is empty or if it is a comment line, false otherwise
|
552 |
+
*/
|
553 |
+
protected function isCurrentLineEmpty()
|
554 |
+
{
|
555 |
+
return $this->isCurrentLineBlank() || $this->isCurrentLineComment();
|
556 |
+
}
|
557 |
+
|
558 |
+
/**
|
559 |
+
* Returns true if the current line is blank.
|
560 |
+
*
|
561 |
+
* @return Boolean Returns true if the current line is blank, false otherwise
|
562 |
+
*/
|
563 |
+
protected function isCurrentLineBlank()
|
564 |
+
{
|
565 |
+
return '' == trim($this->currentLine, ' ');
|
566 |
+
}
|
567 |
+
|
568 |
+
/**
|
569 |
+
* Returns true if the current line is a comment line.
|
570 |
+
*
|
571 |
+
* @return Boolean Returns true if the current line is a comment line, false otherwise
|
572 |
+
*/
|
573 |
+
protected function isCurrentLineComment()
|
574 |
+
{
|
575 |
+
//checking explicitly the first char of the trim is faster than loops or strpos
|
576 |
+
$ltrimmedLine = ltrim($this->currentLine, ' ');
|
577 |
+
return $ltrimmedLine[0] === '#';
|
578 |
+
}
|
579 |
+
|
580 |
+
/**
|
581 |
+
* Cleanups a YAML string to be parsed.
|
582 |
+
*
|
583 |
+
* @param string $value The input YAML string
|
584 |
+
*
|
585 |
+
* @return string A cleaned up YAML string
|
586 |
+
*/
|
587 |
+
protected function cleanup($value)
|
588 |
+
{
|
589 |
+
$value = str_replace(array("\r\n", "\r"), "\n", $value);
|
590 |
+
|
591 |
+
if (!preg_match("#\n$#", $value))
|
592 |
+
{
|
593 |
+
$value .= "\n";
|
594 |
+
}
|
595 |
+
|
596 |
+
// strip YAML header
|
597 |
+
$count = 0;
|
598 |
+
$value = preg_replace('#^\%YAML[: ][\d\.]+.*\n#s', '', $value, -1, $count);
|
599 |
+
$this->offset += $count;
|
600 |
+
|
601 |
+
// remove leading comments and/or ---
|
602 |
+
$trimmedValue = preg_replace('#^((\#.*?\n)|(\-\-\-.*?\n))*#s', '', $value, -1, $count);
|
603 |
+
if ($count == 1)
|
604 |
+
{
|
605 |
+
// items have been removed, update the offset
|
606 |
+
$this->offset += substr_count($value, "\n") - substr_count($trimmedValue, "\n");
|
607 |
+
$value = $trimmedValue;
|
608 |
+
}
|
609 |
+
|
610 |
+
return $value;
|
611 |
+
}
|
612 |
+
}
|
app/libs/aws/sdk.class.php
ADDED
@@ -0,0 +1,1192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
// CORE DEPENDENCIES
|
20 |
+
|
21 |
+
// Look for include file in the same directory (e.g. `./config.inc.php`).
|
22 |
+
if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.inc.php'))
|
23 |
+
{
|
24 |
+
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.inc.php';
|
25 |
+
}
|
26 |
+
// Fallback to `~/.aws/sdk/config.inc.php`
|
27 |
+
elseif (getenv('HOME') && file_exists(getenv('HOME') . DIRECTORY_SEPARATOR . '.aws' . DIRECTORY_SEPARATOR . 'sdk' . DIRECTORY_SEPARATOR . 'config.inc.php'))
|
28 |
+
{
|
29 |
+
include_once getenv('HOME') . DIRECTORY_SEPARATOR . '.aws' . DIRECTORY_SEPARATOR . 'sdk' . DIRECTORY_SEPARATOR . 'config.inc.php';
|
30 |
+
}
|
31 |
+
|
32 |
+
|
33 |
+
/*%******************************************************************************************%*/
|
34 |
+
// EXCEPTIONS
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Default CFRuntime Exception.
|
38 |
+
*/
|
39 |
+
class CFRuntime_Exception extends Exception {}
|
40 |
+
|
41 |
+
|
42 |
+
/*%******************************************************************************************%*/
|
43 |
+
// DETERMINE WHAT ENVIRONMENT DATA TO ADD TO THE USERAGENT FOR METRIC TRACKING
|
44 |
+
|
45 |
+
/*
|
46 |
+
Define a temporary callback function for this calculation. Get the PHP version and any
|
47 |
+
required/optional extensions that are leveraged.
|
48 |
+
|
49 |
+
Tracking this data gives Amazon better metrics about what configurations are being used
|
50 |
+
so that forward-looking plans for the code can be made with more certainty (e.g. What
|
51 |
+
version of PHP are most people running? Do they tend to have the latest PCRE?).
|
52 |
+
*/
|
53 |
+
function __aws_sdk_ua_callback()
|
54 |
+
{
|
55 |
+
$ua_append = '';
|
56 |
+
$extensions = get_loaded_extensions();
|
57 |
+
$sorted_extensions = array();
|
58 |
+
|
59 |
+
if ($extensions)
|
60 |
+
{
|
61 |
+
foreach ($extensions as $extension)
|
62 |
+
{
|
63 |
+
if ($extension === 'curl' && function_exists('curl_version'))
|
64 |
+
{
|
65 |
+
$curl_version = curl_version();
|
66 |
+
$sorted_extensions[strtolower($extension)] = $curl_version['version'];
|
67 |
+
}
|
68 |
+
elseif ($extension === 'pcre' && defined('PCRE_VERSION'))
|
69 |
+
{
|
70 |
+
$pcre_version = explode(' ', PCRE_VERSION);
|
71 |
+
$sorted_extensions[strtolower($extension)] = $pcre_version[0];
|
72 |
+
}
|
73 |
+
elseif ($extension === 'openssl' && defined('OPENSSL_VERSION_TEXT'))
|
74 |
+
{
|
75 |
+
$openssl_version = explode(' ', OPENSSL_VERSION_TEXT);
|
76 |
+
$sorted_extensions[strtolower($extension)] = $openssl_version[1];
|
77 |
+
}
|
78 |
+
else
|
79 |
+
{
|
80 |
+
$sorted_extensions[strtolower($extension)] = phpversion($extension);
|
81 |
+
}
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
+
foreach (array('simplexml', 'json', 'pcre', 'spl', 'curl', 'openssl', 'apc', 'xcache', 'memcache', 'memcached', 'pdo', 'pdo_sqlite', 'sqlite', 'sqlite3', 'zlib', 'xdebug') as $ua_ext)
|
86 |
+
{
|
87 |
+
if (isset($sorted_extensions[$ua_ext]) && $sorted_extensions[$ua_ext])
|
88 |
+
{
|
89 |
+
$ua_append .= ' ' . $ua_ext . '/' . $sorted_extensions[$ua_ext];
|
90 |
+
}
|
91 |
+
elseif (isset($sorted_extensions[$ua_ext]))
|
92 |
+
{
|
93 |
+
$ua_append .= ' ' . $ua_ext . '/0';
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
return $ua_append;
|
98 |
+
}
|
99 |
+
|
100 |
+
|
101 |
+
/*%******************************************************************************************%*/
|
102 |
+
// INTERMEDIARY CONSTANTS
|
103 |
+
|
104 |
+
define('CFRUNTIME_NAME', 'aws-sdk-php');
|
105 |
+
define('CFRUNTIME_VERSION', '1.2.4');
|
106 |
+
// define('CFRUNTIME_BUILD', gmdate('YmdHis', filemtime(__FILE__))); // @todo: Hardcode for release.
|
107 |
+
define('CFRUNTIME_BUILD', '20110216201555');
|
108 |
+
define('CFRUNTIME_USERAGENT', CFRUNTIME_NAME . '/' . CFRUNTIME_VERSION . ' PHP/' . PHP_VERSION . ' ' . php_uname('s') . '/' . php_uname('r') . ' Arch/' . php_uname('m') . ' SAPI/' . php_sapi_name() . ' Integer/' . PHP_INT_MAX . ' Build/' . CFRUNTIME_BUILD . __aws_sdk_ua_callback());
|
109 |
+
|
110 |
+
|
111 |
+
/*%******************************************************************************************%*/
|
112 |
+
// CLASS
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Core functionality and default settings shared across all SDK classes. All methods and properties in this
|
116 |
+
* class are inherited by the service-specific classes.
|
117 |
+
*
|
118 |
+
* @version 2011.01.14
|
119 |
+
* @license See the included NOTICE.md file for more information.
|
120 |
+
* @copyright See the included NOTICE.md file for more information.
|
121 |
+
* @link http://aws.amazon.com/php/ PHP Developer Center
|
122 |
+
*/
|
123 |
+
class CFRuntime
|
124 |
+
{
|
125 |
+
/*%******************************************************************************************%*/
|
126 |
+
// CONSTANTS
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Name of the software.
|
130 |
+
*/
|
131 |
+
const NAME = CFRUNTIME_NAME;
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Version of the software.
|
135 |
+
*/
|
136 |
+
const VERSION = CFRUNTIME_VERSION;
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Build ID of the software.
|
140 |
+
*/
|
141 |
+
const BUILD = CFRUNTIME_BUILD;
|
142 |
+
|
143 |
+
/**
|
144 |
+
* User agent string used to identify the software.
|
145 |
+
*/
|
146 |
+
const USERAGENT = CFRUNTIME_USERAGENT;
|
147 |
+
|
148 |
+
|
149 |
+
/*%******************************************************************************************%*/
|
150 |
+
// PROPERTIES
|
151 |
+
|
152 |
+
/**
|
153 |
+
* The Amazon API Key.
|
154 |
+
*/
|
155 |
+
public $key;
|
156 |
+
|
157 |
+
/**
|
158 |
+
* The Amazon API Secret Key.
|
159 |
+
*/
|
160 |
+
public $secret_key;
|
161 |
+
|
162 |
+
/**
|
163 |
+
* The Amazon Account ID, without hyphens.
|
164 |
+
*/
|
165 |
+
public $account_id;
|
166 |
+
|
167 |
+
/**
|
168 |
+
* The Amazon Associates ID.
|
169 |
+
*/
|
170 |
+
public $assoc_id;
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Handle for the utility functions.
|
174 |
+
*/
|
175 |
+
public $util;
|
176 |
+
|
177 |
+
/**
|
178 |
+
* An identifier for the current AWS service.
|
179 |
+
*/
|
180 |
+
public $service = null;
|
181 |
+
|
182 |
+
/**
|
183 |
+
* The supported API version.
|
184 |
+
*/
|
185 |
+
public $api_version = null;
|
186 |
+
|
187 |
+
/**
|
188 |
+
* The default class to use for utilities (defaults to <CFUtilities>).
|
189 |
+
*/
|
190 |
+
public $utilities_class = 'CFUtilities';
|
191 |
+
|
192 |
+
/**
|
193 |
+
* The default class to use for HTTP requests (defaults to <CFRequest>).
|
194 |
+
*/
|
195 |
+
public $request_class = 'CFRequest';
|
196 |
+
|
197 |
+
/**
|
198 |
+
* The default class to use for HTTP responses (defaults to <CFResponse>).
|
199 |
+
*/
|
200 |
+
public $response_class = 'CFResponse';
|
201 |
+
|
202 |
+
/**
|
203 |
+
* The default class to use for parsing XML (defaults to <CFSimpleXML>).
|
204 |
+
*/
|
205 |
+
public $parser_class = 'CFSimpleXML';
|
206 |
+
|
207 |
+
/**
|
208 |
+
* The default class to use for handling batch requests (defaults to <CFBatchRequest>).
|
209 |
+
*/
|
210 |
+
public $batch_class = 'CFBatchRequest';
|
211 |
+
|
212 |
+
/**
|
213 |
+
* The number of seconds to adjust the request timestamp by (defaults to 0).
|
214 |
+
*/
|
215 |
+
public $adjust_offset = 0;
|
216 |
+
|
217 |
+
/**
|
218 |
+
* The state of SSL/HTTPS use.
|
219 |
+
*/
|
220 |
+
public $use_ssl = true;
|
221 |
+
|
222 |
+
/**
|
223 |
+
* The proxy to use for connecting.
|
224 |
+
*/
|
225 |
+
public $proxy = null;
|
226 |
+
|
227 |
+
/**
|
228 |
+
* The alternate hostname to use, if any.
|
229 |
+
*/
|
230 |
+
public $hostname = null;
|
231 |
+
|
232 |
+
/**
|
233 |
+
* The state of the capability to override the hostname with <set_hostname()>.
|
234 |
+
*/
|
235 |
+
public $override_hostname = true;
|
236 |
+
|
237 |
+
/**
|
238 |
+
* The alternate port number to use, if any.
|
239 |
+
*/
|
240 |
+
public $port_number = null;
|
241 |
+
|
242 |
+
/**
|
243 |
+
* The alternate resource prefix to use, if any.
|
244 |
+
*/
|
245 |
+
public $resource_prefix = null;
|
246 |
+
|
247 |
+
/**
|
248 |
+
* The state of cache flow usage.
|
249 |
+
*/
|
250 |
+
public $use_cache_flow = false;
|
251 |
+
|
252 |
+
/**
|
253 |
+
* The caching class to use.
|
254 |
+
*/
|
255 |
+
public $cache_class = null;
|
256 |
+
|
257 |
+
/**
|
258 |
+
* The caching location to use.
|
259 |
+
*/
|
260 |
+
public $cache_location = null;
|
261 |
+
|
262 |
+
/**
|
263 |
+
* When the cache should be considered stale.
|
264 |
+
*/
|
265 |
+
public $cache_expires = null;
|
266 |
+
|
267 |
+
/**
|
268 |
+
* The state of cache compression.
|
269 |
+
*/
|
270 |
+
public $cache_compress = null;
|
271 |
+
|
272 |
+
/**
|
273 |
+
* The current instantiated cache object.
|
274 |
+
*/
|
275 |
+
public $cache_object = null;
|
276 |
+
|
277 |
+
/**
|
278 |
+
* The current instantiated batch request object.
|
279 |
+
*/
|
280 |
+
public $batch_object = null;
|
281 |
+
|
282 |
+
/**
|
283 |
+
* The internally instantiated batch request object.
|
284 |
+
*/
|
285 |
+
public $internal_batch_object = null;
|
286 |
+
|
287 |
+
/**
|
288 |
+
* The state of batch flow usage.
|
289 |
+
*/
|
290 |
+
public $use_batch_flow = false;
|
291 |
+
|
292 |
+
/**
|
293 |
+
* The state of the cache deletion setting.
|
294 |
+
*/
|
295 |
+
public $delete_cache = false;
|
296 |
+
|
297 |
+
/**
|
298 |
+
* The state of the debug mode setting.
|
299 |
+
*/
|
300 |
+
public $debug_mode = false;
|
301 |
+
|
302 |
+
/**
|
303 |
+
* The number of times to retry failed requests.
|
304 |
+
*/
|
305 |
+
public $max_retries = 3;
|
306 |
+
|
307 |
+
|
308 |
+
/*%******************************************************************************************%*/
|
309 |
+
// CONSTRUCTOR
|
310 |
+
|
311 |
+
/**
|
312 |
+
* The constructor. You would not normally instantiate this class directly. Rather, you would instantiate
|
313 |
+
* a service-specific class.
|
314 |
+
*
|
315 |
+
* @param string $key (Optional) Your Amazon API Key. If blank, it will look for the <AWS_KEY> constant.
|
316 |
+
* @param string $secret_key (Optional) Your Amazon API Secret Key. If blank, it will look for the <AWS_SECRET_KEY> constant.
|
317 |
+
* @param string $account_id (Optional) Your Amazon account ID without the hyphens. Required for EC2. If blank, it will look for the <AWS_ACCOUNT_ID> constant.
|
318 |
+
* @param string $assoc_id (Optional) Your Amazon Associates ID. Required for PAS. If blank, it will look for the <AWS_ASSOC_ID> constant.
|
319 |
+
* @return boolean A value of `false` if no valid values are set, otherwise `true`.
|
320 |
+
*/
|
321 |
+
public function __construct($key = null, $secret_key = null, $account_id = null, $assoc_id = null)
|
322 |
+
{
|
323 |
+
// Instantiate the utilities class.
|
324 |
+
$this->util = new $this->utilities_class();
|
325 |
+
|
326 |
+
// Determine the current service.
|
327 |
+
$this->service = get_class($this);
|
328 |
+
|
329 |
+
// Set default values
|
330 |
+
$this->key = null;
|
331 |
+
$this->secret_key = null;
|
332 |
+
$this->account_id = null;
|
333 |
+
$this->assoc_id = null;
|
334 |
+
|
335 |
+
// Set the Account ID
|
336 |
+
if ($account_id)
|
337 |
+
{
|
338 |
+
$this->account_id = $account_id;
|
339 |
+
}
|
340 |
+
elseif (defined('AWS_ACCOUNT_ID'))
|
341 |
+
{
|
342 |
+
$this->account_id = AWS_ACCOUNT_ID;
|
343 |
+
}
|
344 |
+
|
345 |
+
// Set the Associates ID
|
346 |
+
if ($assoc_id)
|
347 |
+
{
|
348 |
+
$this->assoc_id = $assoc_id;
|
349 |
+
}
|
350 |
+
elseif (defined('AWS_ASSOC_ID'))
|
351 |
+
{
|
352 |
+
$this->assoc_id = AWS_ASSOC_ID;
|
353 |
+
}
|
354 |
+
|
355 |
+
// If both a key and secret key are passed in, use those.
|
356 |
+
if ($key && $secret_key)
|
357 |
+
{
|
358 |
+
$this->key = $key;
|
359 |
+
$this->secret_key = $secret_key;
|
360 |
+
return true;
|
361 |
+
}
|
362 |
+
// If neither are passed in, look for the constants instead.
|
363 |
+
elseif (defined('AWS_KEY') && defined('AWS_SECRET_KEY'))
|
364 |
+
{
|
365 |
+
$this->key = AWS_KEY;
|
366 |
+
$this->secret_key = AWS_SECRET_KEY;
|
367 |
+
return true;
|
368 |
+
}
|
369 |
+
|
370 |
+
// Otherwise set the values to blank and return false.
|
371 |
+
else
|
372 |
+
{
|
373 |
+
throw new CFRuntime_Exception('No valid credentials were used to authenticate with AWS.');
|
374 |
+
}
|
375 |
+
}
|
376 |
+
|
377 |
+
/**
|
378 |
+
* Alternate approach to constructing a new instance. Supports chaining.
|
379 |
+
*
|
380 |
+
* @param string $key (Optional) Your Amazon API Key. If blank, it will look for the <AWS_KEY> constant.
|
381 |
+
* @param string $secret_key (Optional) Your Amazon API Secret Key. If blank, it will look for the <AWS_SECRET_KEY> constant.
|
382 |
+
* @param string $account_id (Optional) Your Amazon account ID without the hyphens. Required for EC2. If blank, it will look for the <AWS_ACCOUNT_ID> constant.
|
383 |
+
* @param string $assoc_id (Optional) Your Amazon Associates ID. Required for AAWS. If blank, it will look for the <AWS_ASSOC_ID> constant.
|
384 |
+
* @return boolean A value of `false` if no valid values are set, otherwise `true`.
|
385 |
+
*/
|
386 |
+
public static function init($key = null, $secret_key = null, $account_id = null, $assoc_id = null)
|
387 |
+
{
|
388 |
+
if (version_compare(PHP_VERSION, '5.3.0', '<'))
|
389 |
+
{
|
390 |
+
throw new Exception('PHP 5.3 or newer is required to instantiate a new class with CLASS::init().');
|
391 |
+
}
|
392 |
+
|
393 |
+
$self = get_called_class();
|
394 |
+
return new $self($key, $secret_key, $account_id, $assoc_id);
|
395 |
+
}
|
396 |
+
|
397 |
+
|
398 |
+
/*%******************************************************************************************%*/
|
399 |
+
// MAGIC METHODS
|
400 |
+
|
401 |
+
/**
|
402 |
+
* A magic method that allows `camelCase` method names to be translated into `snake_case` names.
|
403 |
+
*
|
404 |
+
* @param string $name (Required) The name of the method.
|
405 |
+
* @param array $arguments (Required) The arguments passed to the method.
|
406 |
+
* @return mixed The results of the intended method.
|
407 |
+
*/
|
408 |
+
public function __call($name, $arguments)
|
409 |
+
{
|
410 |
+
// Convert camelCase method calls to snake_case.
|
411 |
+
$method_name = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $name));
|
412 |
+
|
413 |
+
if (method_exists($this, $method_name))
|
414 |
+
{
|
415 |
+
return call_user_func_array(array($this, $method_name), $arguments);
|
416 |
+
}
|
417 |
+
|
418 |
+
throw new CFRuntime_Exception('The method ' . $name . '() is undefined. Attempted to map to ' . $method_name . '() which is also undefined. Error occurred');
|
419 |
+
}
|
420 |
+
|
421 |
+
|
422 |
+
/*%******************************************************************************************%*/
|
423 |
+
// SET CUSTOM SETTINGS
|
424 |
+
|
425 |
+
/**
|
426 |
+
* Adjusts the current time. Use this method for occasions when a server is out of sync with Amazon
|
427 |
+
* servers.
|
428 |
+
*
|
429 |
+
* @param integer $seconds (Required) The number of seconds to adjust the sent timestamp by.
|
430 |
+
* @return $this A reference to the current instance.
|
431 |
+
*/
|
432 |
+
public function adjust_offset($seconds)
|
433 |
+
{
|
434 |
+
$this->adjust_offset = $seconds;
|
435 |
+
return $this;
|
436 |
+
}
|
437 |
+
|
438 |
+
/**
|
439 |
+
* Set the proxy settings to use.
|
440 |
+
*
|
441 |
+
* @param string $proxy (Required) Accepts proxy credentials in the following format: `proxy://user:pass@hostname:port`
|
442 |
+
* @return $this A reference to the current instance.
|
443 |
+
*/
|
444 |
+
public function set_proxy($proxy)
|
445 |
+
{
|
446 |
+
$this->proxy = $proxy;
|
447 |
+
return $this;
|
448 |
+
}
|
449 |
+
|
450 |
+
/**
|
451 |
+
* Set the hostname to connect to. This is useful for alternate services that are API-compatible with
|
452 |
+
* AWS, but run from a different hostname.
|
453 |
+
*
|
454 |
+
* @param string $hostname (Required) The alternate hostname to use in place of the default one. Useful for mock or test applications living on different hostnames.
|
455 |
+
* @param integer $port_number (Optional) The alternate port number to use in place of the default one. Useful for mock or test applications living on different port numbers.
|
456 |
+
* @return $this A reference to the current instance.
|
457 |
+
*/
|
458 |
+
public function set_hostname($hostname, $port_number = null)
|
459 |
+
{
|
460 |
+
if ($this->override_hostname)
|
461 |
+
{
|
462 |
+
$this->hostname = $hostname;
|
463 |
+
|
464 |
+
if ($port_number)
|
465 |
+
{
|
466 |
+
$this->port_number = $port_number;
|
467 |
+
$this->hostname .= ':' . (string) $this->port_number;
|
468 |
+
}
|
469 |
+
}
|
470 |
+
|
471 |
+
return $this;
|
472 |
+
}
|
473 |
+
|
474 |
+
/**
|
475 |
+
* Set the resource prefix to use. This method is useful for alternate services that are API-compatible
|
476 |
+
* with AWS.
|
477 |
+
*
|
478 |
+
* @param string $prefix (Required) An alternate prefix to prepend to the resource path. Useful for mock or test applications.
|
479 |
+
* @return $this A reference to the current instance.
|
480 |
+
*/
|
481 |
+
public function set_resource_prefix($prefix)
|
482 |
+
{
|
483 |
+
$this->resource_prefix = $prefix;
|
484 |
+
return $this;
|
485 |
+
}
|
486 |
+
|
487 |
+
/**
|
488 |
+
* Disables any subsequent use of the <set_hostname()> method.
|
489 |
+
*
|
490 |
+
* @param boolean $override (Optional) Whether or not subsequent calls to <set_hostname()> should be obeyed. A `false` value disables the further effectiveness of <set_hostname()>. Defaults to `true`.
|
491 |
+
* @return $this A reference to the current instance.
|
492 |
+
*/
|
493 |
+
public function allow_hostname_override($override = true)
|
494 |
+
{
|
495 |
+
$this->override_hostname = $override;
|
496 |
+
return $this;
|
497 |
+
}
|
498 |
+
|
499 |
+
/**
|
500 |
+
* Disables SSL/HTTPS connections for hosts that don't support them. Some services, however, still
|
501 |
+
* require SSL support.
|
502 |
+
*
|
503 |
+
* @return $this A reference to the current instance.
|
504 |
+
*/
|
505 |
+
public function disable_ssl()
|
506 |
+
{
|
507 |
+
$this->use_ssl = false;
|
508 |
+
return $this;
|
509 |
+
}
|
510 |
+
|
511 |
+
/**
|
512 |
+
* Enables HTTP request/response header logging to `STDERR`.
|
513 |
+
*
|
514 |
+
* @param boolean $enabled (Optional) Whether or not to enable debug mode. Defaults to `true`.
|
515 |
+
* @return $this A reference to the current instance.
|
516 |
+
*/
|
517 |
+
public function enable_debug_mode($enabled = true)
|
518 |
+
{
|
519 |
+
$this->debug_mode = $enabled;
|
520 |
+
return $this;
|
521 |
+
}
|
522 |
+
|
523 |
+
/**
|
524 |
+
* Sets the maximum number of times to retry failed requests.
|
525 |
+
*
|
526 |
+
* @param integer $retries (Optional) The maximum number of times to retry failed requests. Defaults to `3`.
|
527 |
+
* @return $this A reference to the current instance.
|
528 |
+
*/
|
529 |
+
public function set_max_retries($retries = 3)
|
530 |
+
{
|
531 |
+
$this->max_retries = $retries;
|
532 |
+
return $this;
|
533 |
+
}
|
534 |
+
|
535 |
+
/**
|
536 |
+
* Set the caching configuration to use for response caching.
|
537 |
+
*
|
538 |
+
* @param string $location (Required) <p>The location to store the cache object in. This may vary by cache method.</p><ul><li>File - The local file system paths such as <code>./cache</code> (relative) or <code>/tmp/cache/</code> (absolute). The location must be server-writable.</li><li>APC - Pass in <code>apc</code> to use this lightweight cache. You must have the <a href="http://php.net/apc">APC extension</a> installed.</li><li>XCache - Pass in <code>xcache</code> to use this lightweight cache. You must have the <a href="http://xcache.lighttpd.net">XCache</a> extension installed.</li><li>Memcached - Pass in an indexed array of associative arrays. Each associative array should have a <code>host</code> and a <code>port</code> value representing a <a href="http://php.net/memcached">Memcached</a> server to connect to.</li><li>PDO - A URL-style string (e.g. <code>pdo.mysql://user:pass@localhost/cache</code>) or a standard DSN-style string (e.g. <code>pdo.sqlite:/sqlite/cache.db</code>). MUST be prefixed with <code>pdo.</code>. See <code>CachePDO</code> and <a href="http://php.net/pdo">PDO</a> for more details.</li></ul>
|
539 |
+
* @param boolean $gzip (Optional) Whether or not data should be gzipped before being stored. A value of `true` will compress the contents before caching them. A value of `false` will leave the contents uncompressed. Defaults to `true`.
|
540 |
+
* @return $this A reference to the current instance.
|
541 |
+
*/
|
542 |
+
public function set_cache_config($location, $gzip = true)
|
543 |
+
{
|
544 |
+
// If we have an array, we're probably passing in Memcached servers and ports.
|
545 |
+
if (is_array($location))
|
546 |
+
{
|
547 |
+
$this->cache_class = 'CacheMC';
|
548 |
+
}
|
549 |
+
else
|
550 |
+
{
|
551 |
+
// I would expect locations like `/tmp/cache`, `pdo.mysql://user:pass@hostname:port`, `pdo.sqlite:memory:`, and `apc`.
|
552 |
+
$type = strtolower(substr($location, 0, 3));
|
553 |
+
switch ($type)
|
554 |
+
{
|
555 |
+
case 'apc':
|
556 |
+
$this->cache_class = 'CacheAPC';
|
557 |
+
break;
|
558 |
+
|
559 |
+
case 'xca': // First three letters of `xcache`
|
560 |
+
$this->cache_class = 'CacheXCache';
|
561 |
+
break;
|
562 |
+
|
563 |
+
case 'pdo':
|
564 |
+
$this->cache_class = 'CachePDO';
|
565 |
+
$location = substr($location, 4);
|
566 |
+
break;
|
567 |
+
|
568 |
+
default:
|
569 |
+
$this->cache_class = 'CacheFile';
|
570 |
+
break;
|
571 |
+
}
|
572 |
+
}
|
573 |
+
|
574 |
+
// Set the remaining cache information.
|
575 |
+
$this->cache_location = $location;
|
576 |
+
$this->cache_compress = $gzip;
|
577 |
+
|
578 |
+
return $this;
|
579 |
+
}
|
580 |
+
|
581 |
+
|
582 |
+
/*%******************************************************************************************%*/
|
583 |
+
// SET CUSTOM CLASSES
|
584 |
+
|
585 |
+
/**
|
586 |
+
* Set a custom class for this functionality. Use this method when extending/overriding existing classes
|
587 |
+
* with new functionality.
|
588 |
+
*
|
589 |
+
* The replacement class must extend from <CFUtilities>.
|
590 |
+
*
|
591 |
+
* @param string $class (Optional) The name of the new class to use for this functionality.
|
592 |
+
* @return $this A reference to the current instance.
|
593 |
+
*/
|
594 |
+
public function set_utilities_class($class = 'CFUtilities')
|
595 |
+
{
|
596 |
+
$this->utilities_class = $class;
|
597 |
+
$this->util = new $this->utilities_class();
|
598 |
+
return $this;
|
599 |
+
}
|
600 |
+
|
601 |
+
/**
|
602 |
+
* Set a custom class for this functionality. Use this method when extending/overriding existing classes
|
603 |
+
* with new functionality.
|
604 |
+
*
|
605 |
+
* The replacement class must extend from <CFRequest>.
|
606 |
+
*
|
607 |
+
* @param string $class (Optional) The name of the new class to use for this functionality.
|
608 |
+
* @param $this A reference to the current instance.
|
609 |
+
*/
|
610 |
+
public function set_request_class($class = 'CFRequest')
|
611 |
+
{
|
612 |
+
$this->request_class = $class;
|
613 |
+
return $this;
|
614 |
+
}
|
615 |
+
|
616 |
+
/**
|
617 |
+
* Set a custom class for this functionality. Use this method when extending/overriding existing classes
|
618 |
+
* with new functionality.
|
619 |
+
*
|
620 |
+
* The replacement class must extend from <CFResponse>.
|
621 |
+
*
|
622 |
+
* @param string $class (Optional) The name of the new class to use for this functionality.
|
623 |
+
* @return $this A reference to the current instance.
|
624 |
+
*/
|
625 |
+
public function set_response_class($class = 'CFResponse')
|
626 |
+
{
|
627 |
+
$this->response_class = $class;
|
628 |
+
return $this;
|
629 |
+
}
|
630 |
+
|
631 |
+
/**
|
632 |
+
* Set a custom class for this functionality. Use this method when extending/overriding existing classes
|
633 |
+
* with new functionality.
|
634 |
+
*
|
635 |
+
* The replacement class must extend from <CFSimpleXML>.
|
636 |
+
*
|
637 |
+
* @param string $class (Optional) The name of the new class to use for this functionality.
|
638 |
+
* @return $this A reference to the current instance.
|
639 |
+
*/
|
640 |
+
public function set_parser_class($class = 'CFSimpleXML')
|
641 |
+
{
|
642 |
+
$this->parser_class = $class;
|
643 |
+
return $this;
|
644 |
+
}
|
645 |
+
|
646 |
+
/**
|
647 |
+
* Set a custom class for this functionality. Use this method when extending/overriding existing classes
|
648 |
+
* with new functionality.
|
649 |
+
*
|
650 |
+
* The replacement class must extend from <CFBatchRequest>.
|
651 |
+
*
|
652 |
+
* @param string $class (Optional) The name of the new class to use for this functionality.
|
653 |
+
* @return $this A reference to the current instance.
|
654 |
+
*/
|
655 |
+
public function set_batch_class($class = 'CFBatchRequest')
|
656 |
+
{
|
657 |
+
$this->batch_class = $class;
|
658 |
+
return $this;
|
659 |
+
}
|
660 |
+
|
661 |
+
|
662 |
+
/*%******************************************************************************************%*/
|
663 |
+
// AUTHENTICATION
|
664 |
+
|
665 |
+
/**
|
666 |
+
* Default, shared method for authenticating a connection to AWS. Overridden on a class-by-class basis
|
667 |
+
* as necessary.
|
668 |
+
*
|
669 |
+
* @param string $action (Required) Indicates the action to perform.
|
670 |
+
* @param array $opt (Optional) An associative array of parameters for authenticating. See the individual methods for allowed keys.
|
671 |
+
* @param string $domain (Optional) The URL of the queue to perform the action on.
|
672 |
+
* @param integer $signature_version (Optional) The signature version to use. Defaults to 2.
|
673 |
+
* @param integer $redirects (Do Not Use) Used internally by this function on occasions when Amazon S3 returns a redirect code and it needs to call itself recursively.
|
674 |
+
* @return CFResponse Object containing a parsed HTTP response.
|
675 |
+
*/
|
676 |
+
public function authenticate($action, $opt = null, $domain = null, $signature_version = 2, $redirects = 0)
|
677 |
+
{
|
678 |
+
// Handle nulls
|
679 |
+
if (is_null($signature_version))
|
680 |
+
{
|
681 |
+
$signature_version = 2;
|
682 |
+
}
|
683 |
+
|
684 |
+
$method_arguments = func_get_args();
|
685 |
+
|
686 |
+
// Use the caching flow to determine if we need to do a round-trip to the server.
|
687 |
+
if ($this->use_cache_flow)
|
688 |
+
{
|
689 |
+
// Generate an identifier specific to this particular set of arguments.
|
690 |
+
$cache_id = $this->key . '_' . get_class($this) . '_' . $action . '_' . sha1(serialize($method_arguments));
|
691 |
+
|
692 |
+
// Instantiate the appropriate caching object.
|
693 |
+
$this->cache_object = new $this->cache_class($cache_id, $this->cache_location, $this->cache_expires, $this->cache_compress);
|
694 |
+
|
695 |
+
if ($this->delete_cache)
|
696 |
+
{
|
697 |
+
$this->use_cache_flow = false;
|
698 |
+
$this->delete_cache = false;
|
699 |
+
return $this->cache_object->delete();
|
700 |
+
}
|
701 |
+
|
702 |
+
// Invoke the cache callback function to determine whether to pull data from the cache or make a fresh request.
|
703 |
+
$data = $this->cache_object->response_manager(array($this, 'cache_callback'), $method_arguments);
|
704 |
+
|
705 |
+
// Parse the XML body
|
706 |
+
$data = $this->parse_callback($data);
|
707 |
+
|
708 |
+
// End!
|
709 |
+
return $data;
|
710 |
+
}
|
711 |
+
|
712 |
+
$return_curl_handle = false;
|
713 |
+
|
714 |
+
// Do we have a custom resource prefix?
|
715 |
+
if ($this->resource_prefix)
|
716 |
+
{
|
717 |
+
$domain .= $this->resource_prefix;
|
718 |
+
}
|
719 |
+
|
720 |
+
// Determine signing values
|
721 |
+
$current_time = time() + $this->adjust_offset;
|
722 |
+
$date = gmdate($this->util->konst($this->util, 'DATE_FORMAT_RFC2616'), $current_time);
|
723 |
+
$timestamp = gmdate($this->util->konst($this->util, 'DATE_FORMAT_ISO8601'), $current_time);
|
724 |
+
$nonce = $this->util->generate_guid();
|
725 |
+
|
726 |
+
// Manage the key-value pairs that are used in the query.
|
727 |
+
$query['Action'] = $action;
|
728 |
+
$query['Version'] = $this->api_version;
|
729 |
+
|
730 |
+
// Only Signature v2
|
731 |
+
if ($signature_version === 2)
|
732 |
+
{
|
733 |
+
$query['AWSAccessKeyId'] = $this->key;
|
734 |
+
$query['SignatureMethod'] = 'HmacSHA256';
|
735 |
+
$query['SignatureVersion'] = 2;
|
736 |
+
$query['Timestamp'] = $timestamp;
|
737 |
+
}
|
738 |
+
|
739 |
+
// Merge in any options that were passed in
|
740 |
+
if (is_array($opt))
|
741 |
+
{
|
742 |
+
$query = array_merge($query, $opt);
|
743 |
+
}
|
744 |
+
|
745 |
+
$return_curl_handle = isset($query['returnCurlHandle']) ? $query['returnCurlHandle'] : false;
|
746 |
+
unset($query['returnCurlHandle']);
|
747 |
+
|
748 |
+
// Do a case-sensitive, natural order sort on the array keys.
|
749 |
+
uksort($query, 'strcmp');
|
750 |
+
|
751 |
+
// Create the string that needs to be hashed.
|
752 |
+
$canonical_query_string = $this->util->to_signable_string($query);
|
753 |
+
|
754 |
+
// Remove the default scheme from the domain.
|
755 |
+
$domain = str_replace(array('http://', 'https://'), '', $domain);
|
756 |
+
|
757 |
+
// Parse our request.
|
758 |
+
$parsed_url = parse_url('http://' . $domain);
|
759 |
+
|
760 |
+
// Set the proper host header.
|
761 |
+
if (isset($parsed_url['port']) && (integer) $parsed_url['port'] !== 80 && (integer) $parsed_url['port'] !== 443)
|
762 |
+
{
|
763 |
+
$host_header = strtolower($parsed_url['host']) . ':' . $parsed_url['port'];
|
764 |
+
}
|
765 |
+
else
|
766 |
+
{
|
767 |
+
$host_header = strtolower($parsed_url['host']);
|
768 |
+
}
|
769 |
+
|
770 |
+
// Set the proper request URI.
|
771 |
+
$request_uri = isset($parsed_url['path']) ? $parsed_url['path'] : '/';
|
772 |
+
|
773 |
+
// Handle signing differently between v2 and v3
|
774 |
+
if ($signature_version === 3)
|
775 |
+
{
|
776 |
+
// Prepare the string to sign
|
777 |
+
$string_to_sign = $date . $nonce;
|
778 |
+
|
779 |
+
// Hash the AWS secret key and generate a signature for the request.
|
780 |
+
$signature = base64_encode(hash_hmac('sha256', $string_to_sign, $this->secret_key, true));
|
781 |
+
}
|
782 |
+
elseif ($signature_version === 2)
|
783 |
+
{
|
784 |
+
// Prepare the string to sign
|
785 |
+
$string_to_sign = "POST\n$host_header\n$request_uri\n$canonical_query_string";
|
786 |
+
|
787 |
+
// Hash the AWS secret key and generate a signature for the request.
|
788 |
+
$query['Signature'] = base64_encode(hash_hmac('sha256', $string_to_sign, $this->secret_key, true));
|
789 |
+
}
|
790 |
+
|
791 |
+
// Generate the querystring from $query
|
792 |
+
$querystring = $this->util->to_query_string($query);
|
793 |
+
|
794 |
+
// Gather information to pass along to other classes.
|
795 |
+
$helpers = array(
|
796 |
+
'utilities' => $this->utilities_class,
|
797 |
+
'request' => $this->request_class,
|
798 |
+
'response' => $this->response_class,
|
799 |
+
);
|
800 |
+
|
801 |
+
// Compose the request.
|
802 |
+
$request_url = (($this->use_ssl) ? 'https://' : 'http://') . $domain;
|
803 |
+
$request_url .= !isset($parsed_url['path']) ? '/' : '';
|
804 |
+
|
805 |
+
// Instantiate the request class
|
806 |
+
$request = new $this->request_class($request_url, $this->proxy, $helpers);
|
807 |
+
$request->set_method('POST');
|
808 |
+
$request->add_header('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8');
|
809 |
+
$request->set_body($querystring);
|
810 |
+
|
811 |
+
// Add authentication headers
|
812 |
+
if ($signature_version === 3)
|
813 |
+
{
|
814 |
+
$request->add_header('Date', $date);
|
815 |
+
$request->add_header('Content-Length', strlen($querystring));
|
816 |
+
$request->add_header('Content-MD5', $this->util->hex_to_base64(md5($querystring)));
|
817 |
+
$request->add_header('x-amz-nonce', $nonce);
|
818 |
+
$request->add_header('X-Amzn-Authorization', 'AWS3-HTTPS AWSAccessKeyId=' . $this->key . ',Algorithm=HmacSHA256,Signature=' . $signature);
|
819 |
+
}
|
820 |
+
|
821 |
+
// Update RequestCore settings
|
822 |
+
$request->request_class = $this->request_class;
|
823 |
+
$request->response_class = $this->response_class;
|
824 |
+
|
825 |
+
$curlopts = array();
|
826 |
+
|
827 |
+
// Set custom CURLOPT settings
|
828 |
+
if (isset($opt['curlopts']))
|
829 |
+
{
|
830 |
+
$curlopts = $opt['curlopts'];
|
831 |
+
unset($opt['curlopts']);
|
832 |
+
}
|
833 |
+
|
834 |
+
// Debug mode
|
835 |
+
if ($this->debug_mode)
|
836 |
+
{
|
837 |
+
$curlopts[CURLOPT_VERBOSE] = true;
|
838 |
+
}
|
839 |
+
|
840 |
+
if (count($curlopts))
|
841 |
+
{
|
842 |
+
$request->set_curlopts($curlopts);
|
843 |
+
}
|
844 |
+
|
845 |
+
// Manage the (newer) batch request API or the (older) returnCurlHandle setting.
|
846 |
+
if ($this->use_batch_flow)
|
847 |
+
{
|
848 |
+
$handle = $request->prep_request();
|
849 |
+
$this->batch_object->add($handle);
|
850 |
+
$this->use_batch_flow = false;
|
851 |
+
|
852 |
+
return $handle;
|
853 |
+
}
|
854 |
+
elseif ($return_curl_handle)
|
855 |
+
{
|
856 |
+
return $request->prep_request();
|
857 |
+
}
|
858 |
+
|
859 |
+
// Send!
|
860 |
+
$request->send_request();
|
861 |
+
|
862 |
+
// Prepare the response.
|
863 |
+
$headers = $request->get_response_header();
|
864 |
+
$headers['x-aws-stringtosign'] = $string_to_sign;
|
865 |
+
$headers['x-aws-body'] = $querystring;
|
866 |
+
|
867 |
+
$data = new $this->response_class($headers, $this->parse_callback($request->get_response_body()), $request->get_response_code());
|
868 |
+
|
869 |
+
// Was it Amazon's fault the request failed? Retry the request until we reach $max_retries.
|
870 |
+
if ((integer) $request->get_response_code() === 500 || (integer) $request->get_response_code() === 503)
|
871 |
+
{
|
872 |
+
if ($redirects <= $this->max_retries)
|
873 |
+
{
|
874 |
+
// Exponential backoff
|
875 |
+
$delay = (integer) (pow(4, $redirects) * 100000);
|
876 |
+
usleep($delay);
|
877 |
+
$data = $this->authenticate($action, $opt, $domain, $signature_version, ++$redirects);
|
878 |
+
}
|
879 |
+
}
|
880 |
+
|
881 |
+
return $data;
|
882 |
+
}
|
883 |
+
|
884 |
+
|
885 |
+
/*%******************************************************************************************%*/
|
886 |
+
// BATCH REQUEST LAYER
|
887 |
+
|
888 |
+
/**
|
889 |
+
* Specifies that the intended request should be queued for a later batch request.
|
890 |
+
*
|
891 |
+
* @param CFBatchRequest $queue (Optional) The <CFBatchRequest> instance to use for managing batch requests. If not available, it generates a new instance of <CFBatchRequest>.
|
892 |
+
* @return $this A reference to the current instance.
|
893 |
+
*/
|
894 |
+
public function batch(CFBatchRequest &$queue = null)
|
895 |
+
{
|
896 |
+
if ($queue)
|
897 |
+
{
|
898 |
+
$this->batch_object = $queue;
|
899 |
+
}
|
900 |
+
elseif ($this->internal_batch_object)
|
901 |
+
{
|
902 |
+
$this->batch_object = &$this->internal_batch_object;
|
903 |
+
}
|
904 |
+
else
|
905 |
+
{
|
906 |
+
$this->internal_batch_object = new $this->batch_class();
|
907 |
+
$this->batch_object = &$this->internal_batch_object;
|
908 |
+
}
|
909 |
+
|
910 |
+
$this->use_batch_flow = true;
|
911 |
+
|
912 |
+
return $this;
|
913 |
+
}
|
914 |
+
|
915 |
+
/**
|
916 |
+
* Executes the batch request queue by sending all queued requests.
|
917 |
+
*
|
918 |
+
* @param boolean $clear_after_send (Optional) Whether or not to clear the batch queue after sending a request. Defaults to `true`. Set this to `false` if you are caching batch responses and want to retrieve results later.
|
919 |
+
* @return array An array of <CFResponse> objects.
|
920 |
+
*/
|
921 |
+
public function send($clear_after_send = true)
|
922 |
+
{
|
923 |
+
if ($this->use_batch_flow)
|
924 |
+
{
|
925 |
+
// When we send the request, disable batch flow.
|
926 |
+
$this->use_batch_flow = false;
|
927 |
+
|
928 |
+
// If we're not caching, simply send the request.
|
929 |
+
if (!$this->use_cache_flow)
|
930 |
+
{
|
931 |
+
$response = $this->batch_object->send();
|
932 |
+
$parsed_data = array_map(array($this, 'parse_callback'), $response);
|
933 |
+
$parsed_data = new CFArray($parsed_data);
|
934 |
+
|
935 |
+
// Clear the queue
|
936 |
+
if ($clear_after_send)
|
937 |
+
{
|
938 |
+
$this->batch_object->queue = array();
|
939 |
+
}
|
940 |
+
|
941 |
+
return $parsed_data;
|
942 |
+
}
|
943 |
+
|
944 |
+
// Generate an identifier specific to this particular set of arguments.
|
945 |
+
$cache_id = $this->key . '_' . get_class($this) . '_' . sha1(serialize($this->batch_object));
|
946 |
+
|
947 |
+
// Instantiate the appropriate caching object.
|
948 |
+
$this->cache_object = new $this->cache_class($cache_id, $this->cache_location, $this->cache_expires, $this->cache_compress);
|
949 |
+
|
950 |
+
if ($this->delete_cache)
|
951 |
+
{
|
952 |
+
$this->use_cache_flow = false;
|
953 |
+
$this->delete_cache = false;
|
954 |
+
return $this->cache_object->delete();
|
955 |
+
}
|
956 |
+
|
957 |
+
// Invoke the cache callback function to determine whether to pull data from the cache or make a fresh request.
|
958 |
+
$data_set = $this->cache_object->response_manager(array($this, 'cache_callback_batch'), array($this->batch_object));
|
959 |
+
$parsed_data = array_map(array($this, 'parse_callback'), $data_set);
|
960 |
+
$parsed_data = new CFArray($parsed_data);
|
961 |
+
|
962 |
+
// Clear the queue
|
963 |
+
if ($clear_after_send)
|
964 |
+
{
|
965 |
+
$this->batch_object->queue = array();
|
966 |
+
}
|
967 |
+
|
968 |
+
// End!
|
969 |
+
return $parsed_data;
|
970 |
+
}
|
971 |
+
|
972 |
+
// Load the class
|
973 |
+
$null = new CFBatchRequest();
|
974 |
+
unset($null);
|
975 |
+
|
976 |
+
throw new CFBatchRequest_Exception('You must use $object->batch()->send()');
|
977 |
+
}
|
978 |
+
|
979 |
+
/**
|
980 |
+
* Parses a response body into a PHP object if appropriate.
|
981 |
+
*
|
982 |
+
* @param CFResponse|string $response (Required) The <CFResponse> object to parse, or an XML string that would otherwise be a response body.
|
983 |
+
* @return CFResponse|string A parsed <CFResponse> object, or parsed XML.
|
984 |
+
*/
|
985 |
+
public function parse_callback($response)
|
986 |
+
{
|
987 |
+
// Shorten this so we have a (mostly) single code path
|
988 |
+
if (isset($response->body))
|
989 |
+
{
|
990 |
+
if (is_string($response->body))
|
991 |
+
{
|
992 |
+
$body = $response->body;
|
993 |
+
}
|
994 |
+
else
|
995 |
+
{
|
996 |
+
return $response;
|
997 |
+
}
|
998 |
+
}
|
999 |
+
elseif (is_string($response))
|
1000 |
+
{
|
1001 |
+
$body = $response;
|
1002 |
+
}
|
1003 |
+
else
|
1004 |
+
{
|
1005 |
+
return $response;
|
1006 |
+
}
|
1007 |
+
|
1008 |
+
// Look for XML cues
|
1009 |
+
if (
|
1010 |
+
(stripos($body, '<?xml') === 0 || strpos($body, '<Error>') === 0) ||
|
1011 |
+
preg_match('/^<(\w*) xmlns="http(s?):\/\/(\w*).amazon(aws)?.com/im', $body)
|
1012 |
+
)
|
1013 |
+
{
|
1014 |
+
// Strip the default XML namespace to simplify XPath expressions
|
1015 |
+
$body = str_replace("xmlns=", "ns=", $body);
|
1016 |
+
|
1017 |
+
// Parse the XML body
|
1018 |
+
$body = new $this->parser_class($body);
|
1019 |
+
}
|
1020 |
+
|
1021 |
+
// Put the parsed data back where it goes
|
1022 |
+
if (isset($response->body))
|
1023 |
+
{
|
1024 |
+
$response->body = $body;
|
1025 |
+
}
|
1026 |
+
else
|
1027 |
+
{
|
1028 |
+
$response = $body;
|
1029 |
+
}
|
1030 |
+
|
1031 |
+
return $response;
|
1032 |
+
}
|
1033 |
+
|
1034 |
+
|
1035 |
+
/*%******************************************************************************************%*/
|
1036 |
+
// CACHING LAYER
|
1037 |
+
|
1038 |
+
/**
|
1039 |
+
* Specifies that the resulting <CFResponse> object should be cached according to the settings from
|
1040 |
+
* <set_cache_config()>.
|
1041 |
+
*
|
1042 |
+
* @param string|integer $expires (Required) The time the cache is to expire. Accepts a number of seconds as an integer, or an amount of time, as a string, that is understood by <php:strtotime()> (e.g. "1 hour").
|
1043 |
+
* @param $this A reference to the current instance.
|
1044 |
+
* @return $this
|
1045 |
+
*/
|
1046 |
+
public function cache($expires)
|
1047 |
+
{
|
1048 |
+
// Die if they haven't used set_cache_config().
|
1049 |
+
if (!$this->cache_class)
|
1050 |
+
{
|
1051 |
+
throw new CFRuntime_Exception('Must call set_cache_config() before using cache()');
|
1052 |
+
}
|
1053 |
+
|
1054 |
+
if (is_string($expires))
|
1055 |
+
{
|
1056 |
+
$expires = strtotime($expires);
|
1057 |
+
$this->cache_expires = $expires - time();
|
1058 |
+
}
|
1059 |
+
elseif (is_int($expires))
|
1060 |
+
{
|
1061 |
+
$this->cache_expires = $expires;
|
1062 |
+
}
|
1063 |
+
|
1064 |
+
$this->use_cache_flow = true;
|
1065 |
+
|
1066 |
+
return $this;
|
1067 |
+
}
|
1068 |
+
|
1069 |
+
/**
|
1070 |
+
* The callback function that is executed when the cache doesn't exist or has expired. The response of
|
1071 |
+
* this method is cached. Accepts identical parameters as the <authenticate()> method. Never call this
|
1072 |
+
* method directly -- it is used internally by the caching system.
|
1073 |
+
*
|
1074 |
+
* @param string $action (Required) Indicates the action to perform.
|
1075 |
+
* @param array $opt (Optional) An associative array of parameters for authenticating. See the individual methods for allowed keys.
|
1076 |
+
* @param string $domain (Optional) The URL of the queue to perform the action on.
|
1077 |
+
* @param integer $signature_version (Optional) The signature version to use. Defaults to 2.
|
1078 |
+
* @return CFResponse A parsed HTTP response.
|
1079 |
+
*/
|
1080 |
+
public function cache_callback($action, $opt = null, $domain = null, $signature_version = 2)
|
1081 |
+
{
|
1082 |
+
// Disable the cache flow since it's already been handled.
|
1083 |
+
$this->use_cache_flow = false;
|
1084 |
+
|
1085 |
+
// Make the request
|
1086 |
+
$response = $this->authenticate($action, $opt, $domain, $signature_version);
|
1087 |
+
|
1088 |
+
// If this is an XML document, convert it back to a string.
|
1089 |
+
if (isset($response->body) && ($response->body instanceof SimpleXMLElement))
|
1090 |
+
{
|
1091 |
+
$response->body = $response->body->asXML();
|
1092 |
+
}
|
1093 |
+
|
1094 |
+
return $response;
|
1095 |
+
}
|
1096 |
+
|
1097 |
+
/**
|
1098 |
+
* Used for caching the results of a batch request. Never call this method directly; it is used
|
1099 |
+
* internally by the caching system.
|
1100 |
+
*
|
1101 |
+
* @param CFBatchRequest $batch (Required) The batch request object to send.
|
1102 |
+
* @return CFResponse A parsed HTTP response.
|
1103 |
+
*/
|
1104 |
+
public function cache_callback_batch(CFBatchRequest $batch)
|
1105 |
+
{
|
1106 |
+
return $batch->send();
|
1107 |
+
}
|
1108 |
+
|
1109 |
+
/**
|
1110 |
+
* Deletes a cached <CFResponse> object using the specified cache storage type.
|
1111 |
+
*
|
1112 |
+
* @return boolean A value of `true` if cached object exists and is successfully deleted, otherwise `false`.
|
1113 |
+
*/
|
1114 |
+
public function delete_cache()
|
1115 |
+
{
|
1116 |
+
$this->use_cache_flow = true;
|
1117 |
+
$this->delete_cache = true;
|
1118 |
+
|
1119 |
+
return $this;
|
1120 |
+
}
|
1121 |
+
}
|
1122 |
+
|
1123 |
+
|
1124 |
+
/**
|
1125 |
+
* Contains the functionality for auto-loading service classes.
|
1126 |
+
*/
|
1127 |
+
class CFLoader
|
1128 |
+
{
|
1129 |
+
|
1130 |
+
/*%******************************************************************************************%*/
|
1131 |
+
// AUTO-LOADER
|
1132 |
+
|
1133 |
+
/**
|
1134 |
+
* Automatically load classes that aren't included.
|
1135 |
+
*
|
1136 |
+
* @param string $class (Required) The classname to load.
|
1137 |
+
* @return void
|
1138 |
+
*/
|
1139 |
+
public static function autoloader($class)
|
1140 |
+
{
|
1141 |
+
$path = dirname(__FILE__) . DIRECTORY_SEPARATOR;
|
1142 |
+
|
1143 |
+
// Amazon SDK classes
|
1144 |
+
if (strstr($class, 'Amazon'))
|
1145 |
+
{
|
1146 |
+
$path .= 'services' . DIRECTORY_SEPARATOR . str_ireplace('Amazon', '', strtolower($class)) . '.class.php';
|
1147 |
+
}
|
1148 |
+
|
1149 |
+
// Utility classes
|
1150 |
+
elseif (strstr($class, 'CF'))
|
1151 |
+
{
|
1152 |
+
$path .= 'utilities' . DIRECTORY_SEPARATOR . str_ireplace('CF', '', strtolower($class)) . '.class.php';
|
1153 |
+
}
|
1154 |
+
|
1155 |
+
// Load CacheCore
|
1156 |
+
elseif (strstr($class, 'Cache'))
|
1157 |
+
{
|
1158 |
+
if (file_exists($ipath = 'lib' . DIRECTORY_SEPARATOR . 'cachecore' . DIRECTORY_SEPARATOR . 'icachecore.interface.php'))
|
1159 |
+
{
|
1160 |
+
require_once($ipath);
|
1161 |
+
}
|
1162 |
+
|
1163 |
+
$path .= 'lib' . DIRECTORY_SEPARATOR . 'cachecore' . DIRECTORY_SEPARATOR . strtolower($class) . '.class.php';
|
1164 |
+
}
|
1165 |
+
|
1166 |
+
// Load RequestCore
|
1167 |
+
elseif (strstr($class, 'RequestCore') || strstr($class, 'ResponseCore'))
|
1168 |
+
{
|
1169 |
+
$path .= 'lib' . DIRECTORY_SEPARATOR . 'requestcore' . DIRECTORY_SEPARATOR . 'requestcore.class.php';
|
1170 |
+
}
|
1171 |
+
|
1172 |
+
// Load Symfony YAML classes
|
1173 |
+
elseif (strstr($class, 'sfYaml'))
|
1174 |
+
{
|
1175 |
+
$path .= 'lib' . DIRECTORY_SEPARATOR . 'yaml' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'sfYaml.php';
|
1176 |
+
}
|
1177 |
+
|
1178 |
+
// Fall back to the 'extensions' directory.
|
1179 |
+
elseif (defined('AWS_ENABLE_EXTENSIONS') && AWS_ENABLE_EXTENSIONS)
|
1180 |
+
{
|
1181 |
+
$path .= 'extensions' . DIRECTORY_SEPARATOR . strtolower($class) . '.class.php';
|
1182 |
+
}
|
1183 |
+
|
1184 |
+
if (file_exists($path) && !is_dir($path))
|
1185 |
+
{
|
1186 |
+
require_once($path);
|
1187 |
+
}
|
1188 |
+
}
|
1189 |
+
}
|
1190 |
+
|
1191 |
+
// Register the autoloader.
|
1192 |
+
spl_autoload_register(array('CFLoader', 'autoloader'));
|
app/libs/aws/services/as.class.php
ADDED
@@ -0,0 +1,901 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
*
|
20 |
+
* Auto Scaling is a web service designed to automatically launch or terminate EC2 instances based on user-defined
|
21 |
+
* policies, schedules, and health checks. Auto Scaling responds automatically to changing conditions. All you need to do
|
22 |
+
* is specify how it should respond to those changes.
|
23 |
+
*
|
24 |
+
* Auto Scaling groups can work across multiple Availability Zones - distinct physical locations for the hosted Amazon EC2
|
25 |
+
* instances - so that if an Availability Zone becomes unavailable, Auto Scaling will automatically redistribute
|
26 |
+
* applications to a different Availability Zone.
|
27 |
+
*
|
28 |
+
* Every API call returns a response meta data object that contains a request identifier. Successful requests return an
|
29 |
+
* HTTP 200 status code. Unsuccessful requests return an error object and an HTTP status code of 400 or 500.
|
30 |
+
*
|
31 |
+
* The current WSDL is available at:
|
32 |
+
*
|
33 |
+
* <a
|
34 |
+
* ling.amazonaws.com/doc/2010-08-01/AutoScaling.wsdl">http://autoscaling.amazonaws.com/doc/2010-08-01/AutoScaling.wsdl</a>
|
35 |
+
*
|
36 |
+
* <b>Endpoints</b>
|
37 |
+
*
|
38 |
+
* Auto Scaling supports the following region-specific endpoints:
|
39 |
+
*
|
40 |
+
* <ul> <li>autoscaling.us-east-1.amazonaws.com</li>
|
41 |
+
*
|
42 |
+
* <li>autoscaling.us-west-1.amazonaws.com</li>
|
43 |
+
*
|
44 |
+
* <li>autoscaling.eu-west-1.amazonaws.com</li>
|
45 |
+
*
|
46 |
+
* <li>autoscaling.ap-southeast-1.amazonaws.com</li>
|
47 |
+
*
|
48 |
+
* </ul>
|
49 |
+
*
|
50 |
+
* @version Wed Feb 16 17:02:44 PST 2011
|
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/autoscaling/Amazon Auto-Scaling
|
54 |
+
* @link http://aws.amazon.com/documentation/autoscaling/Amazon Auto-Scaling documentation
|
55 |
+
*/
|
56 |
+
class AmazonAS extends CFRuntime
|
57 |
+
{
|
58 |
+
|
59 |
+
/*%******************************************************************************************%*/
|
60 |
+
// CLASS CONSTANTS
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Specify the default queue URL.
|
64 |
+
*/
|
65 |
+
const DEFAULT_URL = 'autoscaling.us-east-1.amazonaws.com';
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Specify the queue URL for the US-East (Northern Virginia) Region.
|
69 |
+
*/
|
70 |
+
const REGION_US_E1 = self::DEFAULT_URL;
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Specify the queue URL for the US-West (Northern California) Region.
|
74 |
+
*/
|
75 |
+
const REGION_US_W1 = 'autoscaling.us-west-1.amazonaws.com';
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Specify the queue URL for the EU (Ireland) Region.
|
79 |
+
*/
|
80 |
+
const REGION_EU_W1 = 'autoscaling.eu-west-1.amazonaws.com';
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Specify the queue URL for the Asia Pacific (Singapore) Region.
|
84 |
+
*/
|
85 |
+
const REGION_APAC_SE1 = 'autoscaling.ap-southeast-1.amazonaws.com';
|
86 |
+
|
87 |
+
|
88 |
+
/*%******************************************************************************************%*/
|
89 |
+
// SETTERS
|
90 |
+
|
91 |
+
/**
|
92 |
+
* This allows you to explicitly sets the region for the service to use.
|
93 |
+
*
|
94 |
+
* @param string $region (Required) The region to explicitly set. Available options are <REGION_US_E1>, <REGION_US_W1>, <REGION_EU_W1>, or <REGION_APAC_SE1>.
|
95 |
+
* @return $this A reference to the current instance.
|
96 |
+
*/
|
97 |
+
public function set_region($region)
|
98 |
+
{
|
99 |
+
$this->set_hostname($region);
|
100 |
+
return $this;
|
101 |
+
}
|
102 |
+
|
103 |
+
|
104 |
+
/*%******************************************************************************************%*/
|
105 |
+
// CONSTRUCTOR
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Constructs a new instance of <AmazonAS>.
|
109 |
+
*
|
110 |
+
* @param string $key (Optional) Your Amazon API Key. If blank, it will look for the <code>AWS_KEY</code> constant.
|
111 |
+
* @param string $secret_key (Optional) Your Amazon API Secret Key. If blank, it will look for the <code>AWS_SECRET_KEY</code> constant.
|
112 |
+
* @return boolean false if no valid values are set, otherwise true.
|
113 |
+
*/
|
114 |
+
public function __construct($key = null, $secret_key = null)
|
115 |
+
{
|
116 |
+
$this->api_version = '2010-08-01';
|
117 |
+
$this->hostname = self::DEFAULT_URL;
|
118 |
+
|
119 |
+
if (!$key && !defined('AWS_KEY'))
|
120 |
+
{
|
121 |
+
throw new AS_Exception('No account key was passed into the constructor, nor was it set in the AWS_KEY constant.');
|
122 |
+
}
|
123 |
+
|
124 |
+
if (!$secret_key && !defined('AWS_SECRET_KEY'))
|
125 |
+
{
|
126 |
+
throw new AS_Exception('No account secret was passed into the constructor, nor was it set in the AWS_SECRET_KEY constant.');
|
127 |
+
}
|
128 |
+
|
129 |
+
return parent::__construct($key, $secret_key);
|
130 |
+
}
|
131 |
+
|
132 |
+
|
133 |
+
/*%******************************************************************************************%*/
|
134 |
+
// SERVICE METHODS
|
135 |
+
|
136 |
+
/**
|
137 |
+
*
|
138 |
+
* Creates a scheduled scaling action for a Auto Scaling group. If you leave a parameter unspecified, the corresponding
|
139 |
+
* value remains unchanged in the affected Auto Scaling group.
|
140 |
+
*
|
141 |
+
* @param string $auto_scaling_group_name (Required) The name or ARN of the Auto Scaling Group.
|
142 |
+
* @param string $scheduled_action_name (Required) The name of this scaling action.
|
143 |
+
* @param string $time (Required) The time for this action to start. Accepts any value that <php:strtotime()> understands.
|
144 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
145 |
+
* <li><code>MinSize</code> - <code>integer</code> - Optional - The minimum size for the new Auto Scaling group. </li>
|
146 |
+
* <li><code>MaxSize</code> - <code>integer</code> - Optional - The maximum size for the Auto Scaling group. </li>
|
147 |
+
* <li><code>DesiredCapacity</code> - <code>integer</code> - Optional - The number of EC2 instances that should be running in the group. </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 put_scheduled_update_group_action($auto_scaling_group_name, $scheduled_action_name, $time, $opt = null)
|
152 |
+
{
|
153 |
+
if (!$opt) $opt = array();
|
154 |
+
$opt['AutoScalingGroupName'] = $auto_scaling_group_name;
|
155 |
+
$opt['ScheduledActionName'] = $scheduled_action_name;
|
156 |
+
$opt['Time'] = $this->util->convert_date_to_iso8601($time);
|
157 |
+
|
158 |
+
return $this->authenticate('PutScheduledUpdateGroupAction', $opt, $this->hostname);
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
*
|
163 |
+
* Adjusts the desired size of the AutoScalingGroup by initiating scaling activities. When reducing the size of the group,
|
164 |
+
* it is not possible to define which EC2 instances will be terminated. This applies to any auto-scaling decisions that
|
165 |
+
* might result in terminating instances.
|
166 |
+
*
|
167 |
+
* There are two common use cases for <code>SetDesiredCapacity</code>: one for users of the Auto Scaling triggering
|
168 |
+
* system, and another for developers who write their own triggering systems. Both use cases relate to the concept of
|
169 |
+
* cooldown.
|
170 |
+
*
|
171 |
+
* In the first case, if you use the Auto Scaling triggering system, <code>SetDesiredCapacity</code> changes the size of
|
172 |
+
* your Auto Scaling group without regard to the cooldown period. This could be useful, for example, if Auto Scaling did
|
173 |
+
* something unexpected for some reason. If your cooldown period is 10 minutes, Auto Scaling would normally reject requests
|
174 |
+
* to change the size of the group for that entire 10 minute period. The <code>SetDesiredCapacity</code> command allows you
|
175 |
+
* to circumvent this restriction and change the size of the group before the end of the cooldown period.
|
176 |
+
*
|
177 |
+
* In the second case, if you write your own triggering system, you can use <code>SetDesiredCapacity</code> to control the
|
178 |
+
* size of your Auto Scaling group. If you want the same cooldown functionality that Auto Scaling offers, you can configure
|
179 |
+
* <code>SetDesiredCapacity</code> to honor cooldown by setting the <code>HonorCooldown</code> parameter to
|
180 |
+
* <code>true</code>.
|
181 |
+
*
|
182 |
+
* @param string $auto_scaling_group_name (Required) The name of the AutoScalingGroup.
|
183 |
+
* @param integer $desired_capacity (Required) The new capacity setting for the AutoScalingGroup.
|
184 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
185 |
+
* <li><code>HonorCooldown</code> - <code>boolean</code> - Optional - By default, <code>SetDesiredCapacity</code> overrides any cooldown period. Set to True if you want Auto Scaling to reject this request if the Auto Scaling group is in cooldown. </li>
|
186 |
+
* <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>
|
187 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
188 |
+
*/
|
189 |
+
public function set_desired_capacity($auto_scaling_group_name, $desired_capacity, $opt = null)
|
190 |
+
{
|
191 |
+
if (!$opt) $opt = array();
|
192 |
+
$opt['AutoScalingGroupName'] = $auto_scaling_group_name;
|
193 |
+
$opt['DesiredCapacity'] = $desired_capacity;
|
194 |
+
|
195 |
+
return $this->authenticate('SetDesiredCapacity', $opt, $this->hostname);
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
*
|
200 |
+
* Deletes a policy created by PutScalingPolicy
|
201 |
+
*
|
202 |
+
* @param string $policy_name (Required) The name or PolicyARN of the policy you want to delete
|
203 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
204 |
+
* <li><code>AutoScalingGroupName</code> - <code>string</code> - Optional - The name of the Auto Scaling group. </li>
|
205 |
+
* <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>
|
206 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
207 |
+
*/
|
208 |
+
public function delete_policy($policy_name, $opt = null)
|
209 |
+
{
|
210 |
+
if (!$opt) $opt = array();
|
211 |
+
$opt['PolicyName'] = $policy_name;
|
212 |
+
|
213 |
+
return $this->authenticate('DeletePolicy', $opt, $this->hostname);
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
*
|
218 |
+
* Deletes a scheduled action previously created using the PutScheduledUpdateGroupAction.
|
219 |
+
*
|
220 |
+
* @param string $scheduled_action_name (Required) The name of the action you want to delete.
|
221 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
222 |
+
* <li><code>AutoScalingGroupName</code> - <code>string</code> - Optional - The name of the Auto Scaling group </li>
|
223 |
+
* <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>
|
224 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
225 |
+
*/
|
226 |
+
public function delete_scheduled_action($scheduled_action_name, $opt = null)
|
227 |
+
{
|
228 |
+
if (!$opt) $opt = array();
|
229 |
+
$opt['ScheduledActionName'] = $scheduled_action_name;
|
230 |
+
|
231 |
+
return $this->authenticate('DeleteScheduledAction', $opt, $this->hostname);
|
232 |
+
}
|
233 |
+
|
234 |
+
/**
|
235 |
+
*
|
236 |
+
* Returns a full description of the launch configurations given the specified names.
|
237 |
+
*
|
238 |
+
* If no names are specified, then the full details of all launch configurations are returned.
|
239 |
+
*
|
240 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
241 |
+
* <li><code>LaunchConfigurationNames</code> - <code>string|array</code> - Optional - A list of launch configuration names. Pass a string for a single value, or an indexed array for multiple values. </li>
|
242 |
+
* <li><code>NextToken</code> - <code>string</code> - Optional - A string that marks the start of the next batch of returned results. </li>
|
243 |
+
* <li><code>MaxRecords</code> - <code>integer</code> - Optional - The maximum number of launch configurations. </li>
|
244 |
+
* <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>
|
245 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
246 |
+
*/
|
247 |
+
public function describe_launch_configurations($opt = null)
|
248 |
+
{
|
249 |
+
if (!$opt) $opt = array();
|
250 |
+
|
251 |
+
// Optional parameter
|
252 |
+
if (isset($opt['LaunchConfigurationNames']))
|
253 |
+
{
|
254 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
255 |
+
'LaunchConfigurationNames' => (is_array($opt['LaunchConfigurationNames']) ? $opt['LaunchConfigurationNames'] : array($opt['LaunchConfigurationNames']))
|
256 |
+
), 'member'));
|
257 |
+
unset($opt['LaunchConfigurationNames']);
|
258 |
+
}
|
259 |
+
|
260 |
+
return $this->authenticate('DescribeLaunchConfigurations', $opt, $this->hostname);
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
*
|
265 |
+
* Returns scaling process types for use in the ResumeProcesses and SuspendProcesses actions.
|
266 |
+
*
|
267 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
268 |
+
* <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>
|
269 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
270 |
+
*/
|
271 |
+
public function describe_scaling_process_types($opt = null)
|
272 |
+
{
|
273 |
+
if (!$opt) $opt = array();
|
274 |
+
|
275 |
+
return $this->authenticate('DescribeScalingProcessTypes', $opt, $this->hostname);
|
276 |
+
}
|
277 |
+
|
278 |
+
/**
|
279 |
+
*
|
280 |
+
* Returns a full description of each Auto Scaling group in the given list. This includes all Amazon EC2 instances that
|
281 |
+
* are members of the group. If a list of names is not provided, the service returns the full details of all Auto Scaling
|
282 |
+
* groups.
|
283 |
+
*
|
284 |
+
* This action supports pagination by returning a token if there are more pages to retrieve. To get the next page, call
|
285 |
+
* this action again with the returned token as the NextToken parameter.
|
286 |
+
*
|
287 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
288 |
+
* <li><code>AutoScalingGroupNames</code> - <code>string|array</code> - Optional - A list of Auto Scaling group names. Pass a string for a single value, or an indexed array for multiple values. </li>
|
289 |
+
* <li><code>NextToken</code> - <code>string</code> - Optional - A string that marks the start of the next batch of returned results. </li>
|
290 |
+
* <li><code>MaxRecords</code> - <code>integer</code> - Optional - The maximum number of records to return. </li>
|
291 |
+
* <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>
|
292 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
293 |
+
*/
|
294 |
+
public function describe_auto_scaling_groups($opt = null)
|
295 |
+
{
|
296 |
+
if (!$opt) $opt = array();
|
297 |
+
|
298 |
+
// Optional parameter
|
299 |
+
if (isset($opt['AutoScalingGroupNames']))
|
300 |
+
{
|
301 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
302 |
+
'AutoScalingGroupNames' => (is_array($opt['AutoScalingGroupNames']) ? $opt['AutoScalingGroupNames'] : array($opt['AutoScalingGroupNames']))
|
303 |
+
), 'member'));
|
304 |
+
unset($opt['AutoScalingGroupNames']);
|
305 |
+
}
|
306 |
+
|
307 |
+
return $this->authenticate('DescribeAutoScalingGroups', $opt, $this->hostname);
|
308 |
+
}
|
309 |
+
|
310 |
+
/**
|
311 |
+
*
|
312 |
+
* Enables monitoring of group metrics for the Auto Scaling group specified in AutoScalingGroupName. You can specify the
|
313 |
+
* list of enabled metrics with the Metrics parameter.
|
314 |
+
*
|
315 |
+
* Auto scaling metrics collection can be turned on only if the <code>InstanceMonitoring.Enabled</code> flag, in the Auto
|
316 |
+
* Scaling group's launch configuration, is set to <code>true</code>.
|
317 |
+
*
|
318 |
+
* @param string $auto_scaling_group_name (Required) The name or ARN of the Auto Scaling Group.
|
319 |
+
* @param string $granularity (Required) The granularity to associate with the metrics to collect. Currently, the only legal granularity is "1Minute".
|
320 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
321 |
+
* <li><code>Metrics</code> - <code>string|array</code> - Optional - The list of metrics to collect. If no metrics are specified, all metrics are enabled. The following metrics are supported: <ul> <li>GroupMinSize</li><li>GroupMaxSize</li><li>GroupDesiredCapacity</li><li>GroupInServiceInstances</li><li>GroupPendingInstances</li><li>GroupTerminatingInstances</li><li>GroupTotalInstances</li> </ul> Pass a string for a single value, or an indexed array for multiple values. </li>
|
322 |
+
* <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>
|
323 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
324 |
+
*/
|
325 |
+
public function enable_metrics_collection($auto_scaling_group_name, $granularity, $opt = null)
|
326 |
+
{
|
327 |
+
if (!$opt) $opt = array();
|
328 |
+
$opt['AutoScalingGroupName'] = $auto_scaling_group_name;
|
329 |
+
|
330 |
+
// Optional parameter
|
331 |
+
if (isset($opt['Metrics']))
|
332 |
+
{
|
333 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
334 |
+
'Metrics' => (is_array($opt['Metrics']) ? $opt['Metrics'] : array($opt['Metrics']))
|
335 |
+
), 'member'));
|
336 |
+
unset($opt['Metrics']);
|
337 |
+
}
|
338 |
+
$opt['Granularity'] = $granularity;
|
339 |
+
|
340 |
+
return $this->authenticate('EnableMetricsCollection', $opt, $this->hostname);
|
341 |
+
}
|
342 |
+
|
343 |
+
/**
|
344 |
+
*
|
345 |
+
* Terminates the specified instance. Optionally, the desired group size can be adjusted.
|
346 |
+
*
|
347 |
+
* This call simply registers a termination request. The termination of the instance cannot happen immediately.
|
348 |
+
*
|
349 |
+
* @param string $instance_id (Required) The ID of the EC2 instance to be terminated.
|
350 |
+
* @param boolean $should_decrement_desired_capacity (Required) Specifies whether (<i>true</i>) or not (<i>false</i>) terminating this instance should also decrement the size of the AutoScalingGroup.
|
351 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
352 |
+
* <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>
|
353 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
354 |
+
*/
|
355 |
+
public function terminate_instance_in_auto_scaling_group($instance_id, $should_decrement_desired_capacity, $opt = null)
|
356 |
+
{
|
357 |
+
if (!$opt) $opt = array();
|
358 |
+
$opt['InstanceId'] = $instance_id;
|
359 |
+
$opt['ShouldDecrementDesiredCapacity'] = $should_decrement_desired_capacity;
|
360 |
+
|
361 |
+
return $this->authenticate('TerminateInstanceInAutoScalingGroup', $opt, $this->hostname);
|
362 |
+
}
|
363 |
+
|
364 |
+
/**
|
365 |
+
*
|
366 |
+
* Returns the scaling activities for the specified Auto Scaling group.
|
367 |
+
*
|
368 |
+
* If the specified <i>ActivityIds</i> list is empty, all the activities from the past six weeks are returned. Activities
|
369 |
+
* are sorted by completion time. Activities still in progress appear first on the list.
|
370 |
+
*
|
371 |
+
* This action supports pagination. If the response includes a token, there are more records available. To get the
|
372 |
+
* additional records, repeat the request with the response token as the NextToken parameter.
|
373 |
+
*
|
374 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
375 |
+
* <li><code>ActivityIds</code> - <code>string|array</code> - Optional - A list containing the activity IDs of the desired scaling activities. If this list is omitted, all activities are described. If an AutoScalingGroupName is provided, the results are limited to that group. The list of requested activities cannot contain more than 50 items. If unknown activities are requested, they are ignored with no error. Pass a string for a single value, or an indexed array for multiple values. </li>
|
376 |
+
* <li><code>AutoScalingGroupName</code> - <code>string</code> - Optional - The name of the AutoScalingGroup. </li>
|
377 |
+
* <li><code>MaxRecords</code> - <code>integer</code> - Optional - The maximum number of scaling activities to return. </li>
|
378 |
+
* <li><code>NextToken</code> - <code>string</code> - Optional - A string that marks the start of the next batch of returned results for pagination. </li>
|
379 |
+
* <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>
|
380 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
381 |
+
*/
|
382 |
+
public function describe_scaling_activities($opt = null)
|
383 |
+
{
|
384 |
+
if (!$opt) $opt = array();
|
385 |
+
|
386 |
+
// Optional parameter
|
387 |
+
if (isset($opt['ActivityIds']))
|
388 |
+
{
|
389 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
390 |
+
'ActivityIds' => (is_array($opt['ActivityIds']) ? $opt['ActivityIds'] : array($opt['ActivityIds']))
|
391 |
+
), 'member'));
|
392 |
+
unset($opt['ActivityIds']);
|
393 |
+
}
|
394 |
+
|
395 |
+
return $this->authenticate('DescribeScalingActivities', $opt, $this->hostname);
|
396 |
+
}
|
397 |
+
|
398 |
+
/**
|
399 |
+
*
|
400 |
+
* Runs the policy you create for your Auto Scaling group in PutScalingPolicy.
|
401 |
+
*
|
402 |
+
* @param string $policy_name (Required) The name or PolicyARN of the policy you want to run.
|
403 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
404 |
+
* <li><code>AutoScalingGroupName</code> - <code>string</code> - Optional - The name or ARN of the Auto Scaling Group. </li>
|
405 |
+
* <li><code>HonorCooldown</code> - <code>boolean</code> - Optional - Set to True if you want Auto Scaling to reject this request if the Auto Scaling group is in cooldown. </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 execute_policy($policy_name, $opt = null)
|
410 |
+
{
|
411 |
+
if (!$opt) $opt = array();
|
412 |
+
$opt['PolicyName'] = $policy_name;
|
413 |
+
|
414 |
+
return $this->authenticate('ExecutePolicy', $opt, $this->hostname);
|
415 |
+
}
|
416 |
+
|
417 |
+
/**
|
418 |
+
*
|
419 |
+
* Returns a list of metrics and a corresponding list of granularities for each metric.
|
420 |
+
*
|
421 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
422 |
+
* <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>
|
423 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
424 |
+
*/
|
425 |
+
public function describe_metric_collection_types($opt = null)
|
426 |
+
{
|
427 |
+
if (!$opt) $opt = array();
|
428 |
+
|
429 |
+
return $this->authenticate('DescribeMetricCollectionTypes', $opt, $this->hostname);
|
430 |
+
}
|
431 |
+
|
432 |
+
/**
|
433 |
+
*
|
434 |
+
* Returns descriptions of what each policy does. This action supports pagination. If the response includes a token, there
|
435 |
+
* are more records available. To get the additional records, repeat the request with the response token as the NextToken
|
436 |
+
* parameter.
|
437 |
+
*
|
438 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
439 |
+
* <li><code>AutoScalingGroupName</code> - <code>string</code> - Optional - The name of the Auto Scaling group. </li>
|
440 |
+
* <li><code>PolicyNames</code> - <code>string|array</code> - Optional - A list of policy names or policy ARNs to be described. If this list is omitted, all policy names are described. If an auto scaling group name is provided, the results are limited to that group.The list of requested policy names cannot contain more than 50 items. If unknown policy names are requested, they are ignored with no error. Pass a string for a single value, or an indexed array for multiple values. </li>
|
441 |
+
* <li><code>NextToken</code> - <code>string</code> - Optional - A string that is used to mark the start of the next batch of returned results for pagination. </li>
|
442 |
+
* <li><code>MaxRecords</code> - <code>integer</code> - Optional - The maximum number of policies that will be described with each call. </li>
|
443 |
+
* <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>
|
444 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
445 |
+
*/
|
446 |
+
public function describe_policies($opt = null)
|
447 |
+
{
|
448 |
+
if (!$opt) $opt = array();
|
449 |
+
|
450 |
+
// Optional parameter
|
451 |
+
if (isset($opt['PolicyNames']))
|
452 |
+
{
|
453 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
454 |
+
'PolicyNames' => (is_array($opt['PolicyNames']) ? $opt['PolicyNames'] : array($opt['PolicyNames']))
|
455 |
+
), 'member'));
|
456 |
+
unset($opt['PolicyNames']);
|
457 |
+
}
|
458 |
+
|
459 |
+
return $this->authenticate('DescribePolicies', $opt, $this->hostname);
|
460 |
+
}
|
461 |
+
|
462 |
+
/**
|
463 |
+
*
|
464 |
+
* Returns policy adjustment types for use in the PutScalingPolicy action.
|
465 |
+
*
|
466 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
467 |
+
* <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>
|
468 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
469 |
+
*/
|
470 |
+
public function describe_adjustment_types($opt = null)
|
471 |
+
{
|
472 |
+
if (!$opt) $opt = array();
|
473 |
+
|
474 |
+
return $this->authenticate('DescribeAdjustmentTypes', $opt, $this->hostname);
|
475 |
+
}
|
476 |
+
|
477 |
+
/**
|
478 |
+
*
|
479 |
+
* Deletes the specified auto scaling group if the group has no instances and no scaling activities in progress.
|
480 |
+
*
|
481 |
+
* To remove all instances before calling DeleteAutoScalingGroup, you can call UpdateAutoScalingGroup to set the minimum
|
482 |
+
* and maximum size of the AutoScalingGroup to zero.
|
483 |
+
*
|
484 |
+
* @param string $auto_scaling_group_name (Required) The name of the Auto Scaling group.
|
485 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
486 |
+
* <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>
|
487 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
488 |
+
*/
|
489 |
+
public function delete_auto_scaling_group($auto_scaling_group_name, $opt = null)
|
490 |
+
{
|
491 |
+
if (!$opt) $opt = array();
|
492 |
+
$opt['AutoScalingGroupName'] = $auto_scaling_group_name;
|
493 |
+
|
494 |
+
return $this->authenticate('DeleteAutoScalingGroup', $opt, $this->hostname);
|
495 |
+
}
|
496 |
+
|
497 |
+
/**
|
498 |
+
*
|
499 |
+
* Creates a new Auto Scaling group with the specified name. Once the creation request is completed, the AutoScalingGroup
|
500 |
+
* is ready to be used in other calls.
|
501 |
+
*
|
502 |
+
* The Auto Scaling group name must be unique within the scope of your AWS account, and under the quota of Auto Scaling
|
503 |
+
* groups allowed for your account.
|
504 |
+
*
|
505 |
+
* @param string $auto_scaling_group_name (Required) The name of the Auto Scaling group.
|
506 |
+
* @param string $launch_configuration_name (Required) The name of the launch configuration to use with the Auto Scaling group.
|
507 |
+
* @param integer $min_size (Required) The minimum size of the Auto Scaling group.
|
508 |
+
* @param integer $max_size (Required) The maximum size of the Auto Scaling group.
|
509 |
+
* @param string|array $availability_zones (Required) A list of availability zones for the Auto Scaling group. Pass a string for a single value, or an indexed array for multiple values.
|
510 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
511 |
+
* <li><code>DesiredCapacity</code> - <code>integer</code> - Optional - The number of EC2 instances that should be running in the group. </li>
|
512 |
+
* <li><code>DefaultCooldown</code> - <code>integer</code> - Optional - The amount of time, in seconds, after a scaling activity completes before any further trigger-related scaling activities can start. </li>
|
513 |
+
* <li><code>LoadBalancerNames</code> - <code>string|array</code> - Optional - A list of LoadBalancers to use. Pass a string for a single value, or an indexed array for multiple values. </li>
|
514 |
+
* <li><code>HealthCheckType</code> - <code>string</code> - Optional - The service you want the health status from, Amazon EC2 or Elastic Load Balancer. </li>
|
515 |
+
* <li><code>HealthCheckGracePeriod</code> - <code>integer</code> - Optional - Length of time in seconds after a new EC2 instance comes into service that Auto Scaling starts checking its health. </li>
|
516 |
+
* <li><code>PlacementGroup</code> - <code>string</code> - Optional - Physical location of your cluster placement group created in Amazon EC2. </li>
|
517 |
+
* <li><code>VPCZoneIdentifier</code> - <code>string</code> - Optional - The subnet identifier of the Virtual Private Cloud. </li>
|
518 |
+
* <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>
|
519 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
520 |
+
*/
|
521 |
+
public function create_auto_scaling_group($auto_scaling_group_name, $launch_configuration_name, $min_size, $max_size, $availability_zones, $opt = null)
|
522 |
+
{
|
523 |
+
if (!$opt) $opt = array();
|
524 |
+
$opt['AutoScalingGroupName'] = $auto_scaling_group_name;
|
525 |
+
$opt['LaunchConfigurationName'] = $launch_configuration_name;
|
526 |
+
$opt['MinSize'] = $min_size;
|
527 |
+
$opt['MaxSize'] = $max_size;
|
528 |
+
|
529 |
+
// Required parameter
|
530 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
531 |
+
'AvailabilityZones' => (is_array($availability_zones) ? $availability_zones : array($availability_zones))
|
532 |
+
), 'member'));
|
533 |
+
|
534 |
+
// Optional parameter
|
535 |
+
if (isset($opt['LoadBalancerNames']))
|
536 |
+
{
|
537 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
538 |
+
'LoadBalancerNames' => (is_array($opt['LoadBalancerNames']) ? $opt['LoadBalancerNames'] : array($opt['LoadBalancerNames']))
|
539 |
+
), 'member'));
|
540 |
+
unset($opt['LoadBalancerNames']);
|
541 |
+
}
|
542 |
+
|
543 |
+
return $this->authenticate('CreateAutoScalingGroup', $opt, $this->hostname);
|
544 |
+
}
|
545 |
+
|
546 |
+
/**
|
547 |
+
*
|
548 |
+
* Returns a description of each Auto Scaling instance in the InstanceIds list. If a list is not provided, the service
|
549 |
+
* returns the full details of all instances up to a maximum of fifty.
|
550 |
+
*
|
551 |
+
* This action supports pagination by returning a token if there are more pages to retrieve. To get the next page, call
|
552 |
+
* this action again with the returned token as the NextToken parameter.
|
553 |
+
*
|
554 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
555 |
+
* <li><code>InstanceIds</code> - <code>string|array</code> - Optional - The list of Auto Scaling instances to describe. If this list is omitted, all auto scaling instances are described. The list of requested instances cannot contain more than 50 items. If unknown instances are requested, they are ignored with no error. Pass a string for a single value, or an indexed array for multiple values. </li>
|
556 |
+
* <li><code>MaxRecords</code> - <code>integer</code> - Optional - The maximum number of Auto Scaling instances to be described with each call. </li>
|
557 |
+
* <li><code>NextToken</code> - <code>string</code> - Optional - The token returned by a previous call to indicate that there is more data available. </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 describe_auto_scaling_instances($opt = null)
|
562 |
+
{
|
563 |
+
if (!$opt) $opt = array();
|
564 |
+
|
565 |
+
// Optional parameter
|
566 |
+
if (isset($opt['InstanceIds']))
|
567 |
+
{
|
568 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
569 |
+
'InstanceIds' => (is_array($opt['InstanceIds']) ? $opt['InstanceIds'] : array($opt['InstanceIds']))
|
570 |
+
), 'member'));
|
571 |
+
unset($opt['InstanceIds']);
|
572 |
+
}
|
573 |
+
|
574 |
+
return $this->authenticate('DescribeAutoScalingInstances', $opt, $this->hostname);
|
575 |
+
}
|
576 |
+
|
577 |
+
/**
|
578 |
+
*
|
579 |
+
* Deletes the specified LaunchConfiguration.
|
580 |
+
*
|
581 |
+
* The specified launch configuration must not be attached to an Auto Scaling group. Once this call completes, the launch
|
582 |
+
* configuration is no longer available for use.
|
583 |
+
*
|
584 |
+
* @param string $launch_configuration_name (Required) The name of the launch configuration.
|
585 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
586 |
+
* <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>
|
587 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
588 |
+
*/
|
589 |
+
public function delete_launch_configuration($launch_configuration_name, $opt = null)
|
590 |
+
{
|
591 |
+
if (!$opt) $opt = array();
|
592 |
+
$opt['LaunchConfigurationName'] = $launch_configuration_name;
|
593 |
+
|
594 |
+
return $this->authenticate('DeleteLaunchConfiguration', $opt, $this->hostname);
|
595 |
+
}
|
596 |
+
|
597 |
+
/**
|
598 |
+
*
|
599 |
+
* Creates or updates a policy for an Auto Scaling group. To update an existing policy, use the existing policy name and
|
600 |
+
* set the parameter(s) you want to change. Any existing parameter not changed in an update to an existing policy is not
|
601 |
+
* changed in this update request.
|
602 |
+
*
|
603 |
+
* @param string $auto_scaling_group_name (Required) The name or ARN of the Auto Scaling Group.
|
604 |
+
* @param string $policy_name (Required) The name of the policy you want to create or update.
|
605 |
+
* @param integer $scaling_adjustment (Required) The number of instances by which to scale. AdjustmentType determines the interpretation of this number (e.g., as an absolute number or as a percentage of the existing Auto Scaling group size). A positive increment adds to the current capacity and a negative value removes from the current capacity.
|
606 |
+
* @param string $adjustment_type (Required) Specifies whether the <code>ScalingAdjustment</code> is an absolute number or a percentage of the current capacity. Valid values are <code>ChangeInCapacity</code>, <code>ExactCapacity</code>, and <code>PercentChangeInCapacity</code>.
|
607 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
608 |
+
* <li><code>Cooldown</code> - <code>integer</code> - Optional - The amount of time, in seconds, after a scaling activity completes before any further trigger-related scaling activities can start. </li>
|
609 |
+
* <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>
|
610 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
611 |
+
*/
|
612 |
+
public function put_scaling_policy($auto_scaling_group_name, $policy_name, $scaling_adjustment, $adjustment_type, $opt = null)
|
613 |
+
{
|
614 |
+
if (!$opt) $opt = array();
|
615 |
+
$opt['AutoScalingGroupName'] = $auto_scaling_group_name;
|
616 |
+
$opt['PolicyName'] = $policy_name;
|
617 |
+
$opt['ScalingAdjustment'] = $scaling_adjustment;
|
618 |
+
$opt['AdjustmentType'] = $adjustment_type;
|
619 |
+
|
620 |
+
return $this->authenticate('PutScalingPolicy', $opt, $this->hostname);
|
621 |
+
}
|
622 |
+
|
623 |
+
/**
|
624 |
+
*
|
625 |
+
* Sets the health status of an instance.
|
626 |
+
*
|
627 |
+
* @param string $instance_id (Required) The identifier of the EC2 instance.
|
628 |
+
* @param string $health_status (Required) The health status of the instance. "Healthy" means that the instance is healthy and should remain in service. "Unhealthy" means that the instance is unhealthy. Auto Scaling should terminate and replace it.
|
629 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
630 |
+
* <li><code>ShouldRespectGracePeriod</code> - <code>boolean</code> - Optional - If True, this call should respect the grace period associated with the group. </li>
|
631 |
+
* <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>
|
632 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
633 |
+
*/
|
634 |
+
public function set_instance_health($instance_id, $health_status, $opt = null)
|
635 |
+
{
|
636 |
+
if (!$opt) $opt = array();
|
637 |
+
$opt['InstanceId'] = $instance_id;
|
638 |
+
$opt['HealthStatus'] = $health_status;
|
639 |
+
|
640 |
+
return $this->authenticate('SetInstanceHealth', $opt, $this->hostname);
|
641 |
+
}
|
642 |
+
|
643 |
+
/**
|
644 |
+
*
|
645 |
+
* Updates the configuration for the specified AutoScalingGroup.
|
646 |
+
*
|
647 |
+
* To update an Auto Scaling group with a launch configuration that has the <code>InstanceMonitoring.enabled</code> flag
|
648 |
+
* set to <code>false</code>, you must first ensure that collection of group metrics is disabled. Otherwise, calls to
|
649 |
+
* UpdateAutoScalingGroup will fail. If you have previously enabled group metrics collection, you can disable collection of
|
650 |
+
* all group metrics by calling DisableMetricsCollection.
|
651 |
+
*
|
652 |
+
*
|
653 |
+
* The new settings are registered upon the completion of this call. Any launch configuration settings take effect on any
|
654 |
+
* triggers after this call returns. Triggers that are currently in progress aren't affected.
|
655 |
+
*
|
656 |
+
* If the new values are specified for the <i>MinSize</i> or <i>MaxSize</i> parameters, then there will be an implicit
|
657 |
+
* call to SetDesiredCapacity to set the group to the new <i>MaxSize</i>. All optional parameters are left unchanged if not
|
658 |
+
* passed in the request.
|
659 |
+
*
|
660 |
+
* @param string $auto_scaling_group_name (Required) The name of the Auto Scaling group.
|
661 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
662 |
+
* <li><code>LaunchConfigurationName</code> - <code>string</code> - Optional - The name of the launch configuration. </li>
|
663 |
+
* <li><code>MinSize</code> - <code>integer</code> - Optional - The minimum size of the Auto Scaling group. </li>
|
664 |
+
* <li><code>MaxSize</code> - <code>integer</code> - Optional - The maximum size of the Auto Scaling group. </li>
|
665 |
+
* <li><code>DesiredCapacity</code> - <code>integer</code> - Optional - The desired capacity for the Auto Scaling group. </li>
|
666 |
+
* <li><code>DefaultCooldown</code> - <code>integer</code> - Optional - The amount of time, in seconds, after a scaling activity completes before any further trigger-related scaling activities can start. </li>
|
667 |
+
* <li><code>AvailabilityZones</code> - <code>string|array</code> - Optional - Availability zones for the group. Pass a string for a single value, or an indexed array for multiple values. </li>
|
668 |
+
* <li><code>HealthCheckType</code> - <code>string</code> - Optional - The service of interest for the health status check, either "EC2" for Amazon EC2 or "ELB" for Elastic Load Balancing. </li>
|
669 |
+
* <li><code>HealthCheckGracePeriod</code> - <code>integer</code> - Optional - The length of time that Auto Scaling waits before checking an instance's health status. The grace period begins when an instance comes into service. </li>
|
670 |
+
* <li><code>PlacementGroup</code> - <code>string</code> - Optional - The name of the cluster placement group, if applicable. For more information, go to Using Cluster Instances in the Amazon EC2 User Guide. </li>
|
671 |
+
* <li><code>VPCZoneIdentifier</code> - <code>string</code> - Optional - The identifier for the VPC connection, if applicable. </li>
|
672 |
+
* <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>
|
673 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
674 |
+
*/
|
675 |
+
public function update_auto_scaling_group($auto_scaling_group_name, $opt = null)
|
676 |
+
{
|
677 |
+
if (!$opt) $opt = array();
|
678 |
+
$opt['AutoScalingGroupName'] = $auto_scaling_group_name;
|
679 |
+
|
680 |
+
// Optional parameter
|
681 |
+
if (isset($opt['AvailabilityZones']))
|
682 |
+
{
|
683 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
684 |
+
'AvailabilityZones' => (is_array($opt['AvailabilityZones']) ? $opt['AvailabilityZones'] : array($opt['AvailabilityZones']))
|
685 |
+
), 'member'));
|
686 |
+
unset($opt['AvailabilityZones']);
|
687 |
+
}
|
688 |
+
|
689 |
+
return $this->authenticate('UpdateAutoScalingGroup', $opt, $this->hostname);
|
690 |
+
}
|
691 |
+
|
692 |
+
/**
|
693 |
+
*
|
694 |
+
* Lists all the actions scheduled for your Auto Scaling group that haven't been executed. To see a list of action already
|
695 |
+
* executed, see the activity record returned in DescribeScalingActivities.
|
696 |
+
*
|
697 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
698 |
+
* <li><code>AutoScalingGroupName</code> - <code>string</code> - Optional - The name of the Auto Scaling group. </li>
|
699 |
+
* <li><code>ScheduledActionNames</code> - <code>string|array</code> - Optional - A list of scheduled actions to be described. If this list is omitted, all scheduled actions are described. The list of requested scheduled actions cannot contain more than 50 items. If an auto scaling group name is provided, the results are limited to that group. If unknown scheduled actions are requested, they are ignored with no error. Pass a string for a single value, or an indexed array for multiple values. </li>
|
700 |
+
* <li><code>StartTime</code> - <code>string</code> - Optional - The earliest scheduled start time to return. If scheduled action names are provided, this field will be ignored. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
701 |
+
* <li><code>EndTime</code> - <code>string</code> - Optional - The latest scheduled start time to return. If scheduled action names are provided, this field will be ignored. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
702 |
+
* <li><code>NextToken</code> - <code>string</code> - Optional - A string that marks the start of the next batch of returned results. </li>
|
703 |
+
* <li><code>MaxRecords</code> - <code>integer</code> - Optional - The maximum number of scheduled actions to return. </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 describe_scheduled_actions($opt = null)
|
708 |
+
{
|
709 |
+
if (!$opt) $opt = array();
|
710 |
+
|
711 |
+
// Optional parameter
|
712 |
+
if (isset($opt['ScheduledActionNames']))
|
713 |
+
{
|
714 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
715 |
+
'ScheduledActionNames' => (is_array($opt['ScheduledActionNames']) ? $opt['ScheduledActionNames'] : array($opt['ScheduledActionNames']))
|
716 |
+
), 'member'));
|
717 |
+
unset($opt['ScheduledActionNames']);
|
718 |
+
}
|
719 |
+
|
720 |
+
// Optional parameter
|
721 |
+
if (isset($opt['StartTime']))
|
722 |
+
{
|
723 |
+
$opt['StartTime'] = $this->util->convert_date_to_iso8601($opt['StartTime']);
|
724 |
+
}
|
725 |
+
|
726 |
+
// Optional parameter
|
727 |
+
if (isset($opt['EndTime']))
|
728 |
+
{
|
729 |
+
$opt['EndTime'] = $this->util->convert_date_to_iso8601($opt['EndTime']);
|
730 |
+
}
|
731 |
+
|
732 |
+
return $this->authenticate('DescribeScheduledActions', $opt, $this->hostname);
|
733 |
+
}
|
734 |
+
|
735 |
+
/**
|
736 |
+
*
|
737 |
+
* Suspends Auto Scaling processes for an Auto Scaling group. To suspend specific process types, specify them by name with
|
738 |
+
* the <code>ScalingProcesses.member.N</code> parameter. To suspend all process types, omit the
|
739 |
+
* <code>ScalingProcesses.member.N</code> parameter.
|
740 |
+
*
|
741 |
+
* Suspending either of the two primary process types, <code>Launch</code> or <code>Terminate</code>, can prevent other
|
742 |
+
* process types from functioning properly. For more information about processes and their dependencies, see ProcessType.
|
743 |
+
*
|
744 |
+
*
|
745 |
+
* To resume processes that have been suspended, use ResumeProcesses.
|
746 |
+
*
|
747 |
+
* @param string $auto_scaling_group_name (Required) The name or Amazon Resource Name (ARN) of the Auto Scaling group.
|
748 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
749 |
+
* <li><code>ScalingProcesses</code> - <code>string|array</code> - Optional - The processes that you want to suspend or resume, which can include one or more of the following: <ul> <li>Launch</li><li>Terminate</li><li>HealthCheck</li><li>ReplaceUnhealthy</li><li>AZRebalance</li><li>AlarmNotifications</li><li>ScheduledActions</li> </ul> To suspend all process types, omit this parameter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
750 |
+
* <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>
|
751 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
752 |
+
*/
|
753 |
+
public function suspend_processes($auto_scaling_group_name, $opt = null)
|
754 |
+
{
|
755 |
+
if (!$opt) $opt = array();
|
756 |
+
$opt['AutoScalingGroupName'] = $auto_scaling_group_name;
|
757 |
+
|
758 |
+
// Optional parameter
|
759 |
+
if (isset($opt['ScalingProcesses']))
|
760 |
+
{
|
761 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
762 |
+
'ScalingProcesses' => (is_array($opt['ScalingProcesses']) ? $opt['ScalingProcesses'] : array($opt['ScalingProcesses']))
|
763 |
+
), 'member'));
|
764 |
+
unset($opt['ScalingProcesses']);
|
765 |
+
}
|
766 |
+
|
767 |
+
return $this->authenticate('SuspendProcesses', $opt, $this->hostname);
|
768 |
+
}
|
769 |
+
|
770 |
+
/**
|
771 |
+
*
|
772 |
+
* Resumes Auto Scaling processes for an Auto Scaling group. For more information, see SuspendProcesses and ProcessType.
|
773 |
+
*
|
774 |
+
* @param string $auto_scaling_group_name (Required) The name or Amazon Resource Name (ARN) of the Auto Scaling group.
|
775 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
776 |
+
* <li><code>ScalingProcesses</code> - <code>string|array</code> - Optional - The processes that you want to suspend or resume, which can include one or more of the following: <ul> <li>Launch</li><li>Terminate</li><li>HealthCheck</li><li>ReplaceUnhealthy</li><li>AZRebalance</li><li>AlarmNotifications</li><li>ScheduledActions</li> </ul> To suspend all process types, omit this parameter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
777 |
+
* <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>
|
778 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
779 |
+
*/
|
780 |
+
public function resume_processes($auto_scaling_group_name, $opt = null)
|
781 |
+
{
|
782 |
+
if (!$opt) $opt = array();
|
783 |
+
$opt['AutoScalingGroupName'] = $auto_scaling_group_name;
|
784 |
+
|
785 |
+
// Optional parameter
|
786 |
+
if (isset($opt['ScalingProcesses']))
|
787 |
+
{
|
788 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
789 |
+
'ScalingProcesses' => (is_array($opt['ScalingProcesses']) ? $opt['ScalingProcesses'] : array($opt['ScalingProcesses']))
|
790 |
+
), 'member'));
|
791 |
+
unset($opt['ScalingProcesses']);
|
792 |
+
}
|
793 |
+
|
794 |
+
return $this->authenticate('ResumeProcesses', $opt, $this->hostname);
|
795 |
+
}
|
796 |
+
|
797 |
+
/**
|
798 |
+
*
|
799 |
+
* Creates a new launch configuration. Once created, the new launch configuration is available for immediate use.
|
800 |
+
*
|
801 |
+
* The launch configuration name used must be unique, within the scope of the client's AWS account, and the maximum limit
|
802 |
+
* of launch configurations must not yet have been met, or else the call will fail.
|
803 |
+
*
|
804 |
+
* @param string $launch_configuration_name (Required) The name of the launch configuration to create.
|
805 |
+
* @param string $image_id (Required) Unique ID of the <i>Amazon Machine Image</i> (AMI) which was assigned during registration. For more information about Amazon EC2 images, please see Amazon EC2 product documentation
|
806 |
+
* @param string $instance_type (Required) The instance type of the EC2 instance. For more information about Amazon EC2 instance types, please see Amazon EC2 product documentation
|
807 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
808 |
+
* <li><code>KeyName</code> - <code>string</code> - Optional - The name of the EC2 key pair. </li>
|
809 |
+
* <li><code>SecurityGroups</code> - <code>string|array</code> - Optional - The names of the security groups with which to associate EC2 instances. For more information about Amazon EC2 security groups, go to the Amazon EC2 product documentation. Pass a string for a single value, or an indexed array for multiple values. </li>
|
810 |
+
* <li><code>UserData</code> - <code>string</code> - Optional - The user data available to the launched EC2 instances. For more information about Amazon EC2 user data, please see Amazon EC2 product documentation. </li>
|
811 |
+
* <li><code>KernelId</code> - <code>string</code> - Optional - The ID of the kernel associated with the EC2 AMI. </li>
|
812 |
+
* <li><code>RamdiskId</code> - <code>string</code> - Optional - The ID of the RAM disk associated with the EC2 AMI. </li>
|
813 |
+
* <li><code>BlockDeviceMappings</code> - <code>array</code> - Optional - A list of mappings that specify how block devices are exposed to the instance. Each mapping is made up of a <i>VirtualName</i>, a <i>DeviceName</i>, and an <i>ebs</i> data structure that contains information about the associated Elastic Block Storage volume. For more information about Amazon EC2 BlockDeviceMappings, please go to Block Device Mapping in the Amazon EC2 product documentation. <ul>
|
814 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
815 |
+
* <li><code>VirtualName</code> - <code>string</code> - Optional - The virtual name associated with the device. </li>
|
816 |
+
* <li><code>DeviceName</code> - <code>string</code> - Required - The name of the device within Amazon EC2. </li>
|
817 |
+
* <li><code>Ebs</code> - <code>array</code> - Optional - The Elastic Block Storage volume information. Takes an associative array of parameters that can have the following keys: <ul>
|
818 |
+
* <li><code>SnapshotId</code> - <code>string</code> - Optional - The Snapshot ID. </li>
|
819 |
+
* <li><code>VolumeSize</code> - <code>integer</code> - Optional - The volume size, in GigaBytes. </li>
|
820 |
+
* </ul></li>
|
821 |
+
* </ul></li>
|
822 |
+
* </ul></li>
|
823 |
+
* <li><code>InstanceMonitoring</code> - <code>array</code> - Optional - Enables detailed monitoring. <ul>
|
824 |
+
* <li><code>Enabled</code> - <code>boolean</code> - Optional - If true, instance monitoring is enabled. </li></ul></li>
|
825 |
+
* <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>
|
826 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
827 |
+
*/
|
828 |
+
public function create_launch_configuration($launch_configuration_name, $image_id, $instance_type, $opt = null)
|
829 |
+
{
|
830 |
+
if (!$opt) $opt = array();
|
831 |
+
$opt['LaunchConfigurationName'] = $launch_configuration_name;
|
832 |
+
$opt['ImageId'] = $image_id;
|
833 |
+
|
834 |
+
// Optional parameter
|
835 |
+
if (isset($opt['SecurityGroups']))
|
836 |
+
{
|
837 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
838 |
+
'SecurityGroups' => (is_array($opt['SecurityGroups']) ? $opt['SecurityGroups'] : array($opt['SecurityGroups']))
|
839 |
+
), 'member'));
|
840 |
+
unset($opt['SecurityGroups']);
|
841 |
+
}
|
842 |
+
$opt['InstanceType'] = $instance_type;
|
843 |
+
|
844 |
+
// Optional parameter
|
845 |
+
if (isset($opt['BlockDeviceMappings']))
|
846 |
+
{
|
847 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
848 |
+
'BlockDeviceMappings' => $opt['BlockDeviceMappings']
|
849 |
+
), 'member'));
|
850 |
+
unset($opt['BlockDeviceMappings']);
|
851 |
+
}
|
852 |
+
|
853 |
+
// Optional parameter
|
854 |
+
if (isset($opt['InstanceMonitoring']))
|
855 |
+
{
|
856 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
857 |
+
'InstanceMonitoring' => $opt['InstanceMonitoring']
|
858 |
+
), 'member'));
|
859 |
+
unset($opt['InstanceMonitoring']);
|
860 |
+
}
|
861 |
+
|
862 |
+
return $this->authenticate('CreateLaunchConfiguration', $opt, $this->hostname);
|
863 |
+
}
|
864 |
+
|
865 |
+
/**
|
866 |
+
*
|
867 |
+
* Disables monitoring of group metrics for the Auto Scaling group specified in AutoScalingGroupName. You can specify the
|
868 |
+
* list of affected metrics with the Metrics parameter.
|
869 |
+
*
|
870 |
+
* @param string $auto_scaling_group_name (Required) The name or ARN of the Auto Scaling Group.
|
871 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
872 |
+
* <li><code>Metrics</code> - <code>string|array</code> - Optional - The list of metrics to disable. If no metrics are specified, all metrics are disabled. The following metrics are supported: <ul> <li>GroupMinSize</li><li>GroupMaxSize</li><li>GroupDesiredCapacity</li><li>GroupInServiceInstances</li><li>GroupPendingInstances</li><li>GroupTerminatingInstances</li><li>GroupTotalInstances</li> </ul> Pass a string for a single value, or an indexed array for multiple values. </li>
|
873 |
+
* <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>
|
874 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
875 |
+
*/
|
876 |
+
public function disable_metrics_collection($auto_scaling_group_name, $opt = null)
|
877 |
+
{
|
878 |
+
if (!$opt) $opt = array();
|
879 |
+
$opt['AutoScalingGroupName'] = $auto_scaling_group_name;
|
880 |
+
|
881 |
+
// Optional parameter
|
882 |
+
if (isset($opt['Metrics']))
|
883 |
+
{
|
884 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
885 |
+
'Metrics' => (is_array($opt['Metrics']) ? $opt['Metrics'] : array($opt['Metrics']))
|
886 |
+
), 'member'));
|
887 |
+
unset($opt['Metrics']);
|
888 |
+
}
|
889 |
+
|
890 |
+
return $this->authenticate('DisableMetricsCollection', $opt, $this->hostname);
|
891 |
+
}
|
892 |
+
}
|
893 |
+
|
894 |
+
|
895 |
+
/*%******************************************************************************************%*/
|
896 |
+
// EXCEPTIONS
|
897 |
+
|
898 |
+
/**
|
899 |
+
* Default AS Exception.
|
900 |
+
*/
|
901 |
+
class AS_Exception extends Exception {}
|
app/libs/aws/services/cloudfront.class.php
ADDED
@@ -0,0 +1,1391 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
// EXCEPTIONS
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Default CloudFront Exception.
|
23 |
+
*/
|
24 |
+
class CloudFront_Exception extends Exception {}
|
25 |
+
|
26 |
+
|
27 |
+
/*%******************************************************************************************%*/
|
28 |
+
// MAIN CLASS
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Amazon CloudFront is a web service for content delivery. It makes it easier for you to distribute content
|
32 |
+
* to end users quickly, with low latency and high data transfer speeds.
|
33 |
+
*
|
34 |
+
* CloudFront delivers your content through a worldwide network of edge locations. End users are routed to
|
35 |
+
* the nearest edge location, so content is delivered with the best possible performance. CloudFront works
|
36 |
+
* seamlessly with the Amazon Simple Storage Service, which durably stores the original, definitive versions
|
37 |
+
* of your files.
|
38 |
+
*
|
39 |
+
* @version 2010.11.24
|
40 |
+
* @license See the included NOTICE.md file for more information.
|
41 |
+
* @copyright See the included NOTICE.md file for more information.
|
42 |
+
* @link http://aws.amazon.com/cloudfront/ Amazon CloudFront
|
43 |
+
* @link http://aws.amazon.com/documentation/cloudfront/ Amazon CloudFront documentation
|
44 |
+
*/
|
45 |
+
class AmazonCloudFront extends CFRuntime
|
46 |
+
{
|
47 |
+
/**
|
48 |
+
* Specify the default queue URL.
|
49 |
+
*/
|
50 |
+
const DEFAULT_URL = 'cloudfront.amazonaws.com';
|
51 |
+
|
52 |
+
/**
|
53 |
+
* The InProgress state.
|
54 |
+
*/
|
55 |
+
const STATE_INPROGRESS = 'InProgress';
|
56 |
+
|
57 |
+
/**
|
58 |
+
* The Deployed state.
|
59 |
+
*/
|
60 |
+
const STATE_DEPLOYED = 'Deployed';
|
61 |
+
|
62 |
+
/**
|
63 |
+
* The base content to use for generating the DistributionConfig XML.
|
64 |
+
*/
|
65 |
+
var $base_xml;
|
66 |
+
|
67 |
+
/**
|
68 |
+
* The CloudFront distribution domain to use.
|
69 |
+
*/
|
70 |
+
var $domain;
|
71 |
+
|
72 |
+
/**
|
73 |
+
* The RSA key pair ID to use.
|
74 |
+
*/
|
75 |
+
var $key_pair_id;
|
76 |
+
|
77 |
+
/**
|
78 |
+
* The RSA private key resource locator.
|
79 |
+
*/
|
80 |
+
var $private_key;
|
81 |
+
|
82 |
+
|
83 |
+
/*%******************************************************************************************%*/
|
84 |
+
// CONSTRUCTOR
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Constructs a new instance of this class.
|
88 |
+
*
|
89 |
+
* @param string $key (Optional) Your Amazon API Key. If blank, it will look for the <AWS_KEY> constant.
|
90 |
+
* @param string $secret_key (Optional) Your Amazon API Secret Key. If blank, it will look for the <AWS_SECRET_KEY> constant.
|
91 |
+
* @return boolean A value of <code>false</code> if no valid values are set, otherwise <code>true</code>.
|
92 |
+
*/
|
93 |
+
public function __construct($key = null, $secret_key = null)
|
94 |
+
{
|
95 |
+
$this->api_version = '2010-11-01';
|
96 |
+
$this->hostname = self::DEFAULT_URL;
|
97 |
+
|
98 |
+
$this->base_xml = '<?xml version="1.0" encoding="UTF-8"?><%s xmlns="http://cloudfront.amazonaws.com/doc/' . $this->api_version . '/"></%1$s>';
|
99 |
+
|
100 |
+
if (!$key && !defined('AWS_KEY'))
|
101 |
+
{
|
102 |
+
throw new CloudFront_Exception('No account key was passed into the constructor, nor was it set in the AWS_KEY constant.');
|
103 |
+
}
|
104 |
+
|
105 |
+
if (!$secret_key && !defined('AWS_SECRET_KEY'))
|
106 |
+
{
|
107 |
+
throw new CloudFront_Exception('No account secret was passed into the constructor, nor was it set in the AWS_SECRET_KEY constant.');
|
108 |
+
}
|
109 |
+
|
110 |
+
// Set a default key pair ID
|
111 |
+
if (defined('AWS_CLOUDFRONT_KEYPAIR_ID'))
|
112 |
+
{
|
113 |
+
$this->key_pair_id = AWS_CLOUDFRONT_KEYPAIR_ID;
|
114 |
+
}
|
115 |
+
|
116 |
+
// Set a default private key
|
117 |
+
if (defined('AWS_CLOUDFRONT_PRIVATE_KEY_PEM'))
|
118 |
+
{
|
119 |
+
$this->private_key = AWS_CLOUDFRONT_PRIVATE_KEY_PEM;
|
120 |
+
}
|
121 |
+
|
122 |
+
return parent::__construct($key, $secret_key);
|
123 |
+
}
|
124 |
+
|
125 |
+
|
126 |
+
/*%******************************************************************************************%*/
|
127 |
+
// AUTHENTICATION
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Authenticates a connection to Amazon CloudFront. This method should not be used directly unless
|
131 |
+
* you're writing custom methods for this class.
|
132 |
+
*
|
133 |
+
* @param string $method (Required) The HTTP method to use to connect. Accepts <code>GET</code>, <code>POST</code>, <code>PUT</code>, <code>DELETE</code>, and <code>HEAD</code>.
|
134 |
+
* @param string $path (Optional) The endpoint path to make requests to.
|
135 |
+
* @param array $opt (Optional) An associative array of parameters for authenticating. See the individual methods for allowed keys.
|
136 |
+
* @param string $xml (Optional) The XML body content to send along in the request.
|
137 |
+
* @param string $etag (Optional) The ETag value to pass along with the If-Match HTTP header.
|
138 |
+
* @param integer $redirects (Do Not Use) Used internally by this function on occasions when Amazon S3 returns a redirect code and it needs to call itself recursively.
|
139 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
140 |
+
* @link http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/RESTAuthentication.html Authentication
|
141 |
+
*/
|
142 |
+
public function authenticate($method = 'GET', $path = null, $opt = null, $xml = null, $etag = null, $redirects = 0)
|
143 |
+
{
|
144 |
+
if (!$opt) $opt = array();
|
145 |
+
$querystring = null;
|
146 |
+
|
147 |
+
$method_arguments = func_get_args();
|
148 |
+
|
149 |
+
// Use the caching flow to determine if we need to do a round-trip to the server.
|
150 |
+
if ($this->use_cache_flow)
|
151 |
+
{
|
152 |
+
// Generate an identifier specific to this particular set of arguments.
|
153 |
+
$cache_id = $this->key . '_' . get_class($this) . '_' . $method . sha1($path) . '_' . sha1(serialize($method_arguments));
|
154 |
+
|
155 |
+
// Instantiate the appropriate caching object.
|
156 |
+
$this->cache_object = new $this->cache_class($cache_id, $this->cache_location, $this->cache_expires, $this->cache_compress);
|
157 |
+
|
158 |
+
if ($this->delete_cache)
|
159 |
+
{
|
160 |
+
$this->use_cache_flow = false;
|
161 |
+
$this->delete_cache = false;
|
162 |
+
return $this->cache_object->delete();
|
163 |
+
}
|
164 |
+
|
165 |
+
// Invoke the cache callback function to determine whether to pull data from the cache or make a fresh request.
|
166 |
+
$data = $this->cache_object->response_manager(array($this, 'cache_callback'), $method_arguments);
|
167 |
+
|
168 |
+
// Parse the XML body
|
169 |
+
$data = $this->parse_callback($data);
|
170 |
+
|
171 |
+
// End!
|
172 |
+
return $data;
|
173 |
+
}
|
174 |
+
|
175 |
+
// Generate query string
|
176 |
+
if (isset($opt['query_string']) && count($opt['query_string']))
|
177 |
+
{
|
178 |
+
$querystring = '?' . $this->util->to_query_string($opt['query_string']);
|
179 |
+
}
|
180 |
+
|
181 |
+
// Gather information to pass along to other classes.
|
182 |
+
$helpers = array(
|
183 |
+
'utilities' => $this->utilities_class,
|
184 |
+
'request' => $this->request_class,
|
185 |
+
'response' => $this->response_class,
|
186 |
+
);
|
187 |
+
|
188 |
+
// Compose the endpoint URL.
|
189 |
+
$request_url = 'https://' . $this->hostname . '/' . $this->api_version;
|
190 |
+
$request_url .= ($path) ? $path : '';
|
191 |
+
$request_url .= ($querystring) ? $querystring : '';
|
192 |
+
|
193 |
+
// Compose the request.
|
194 |
+
$request = new $this->request_class($request_url, $this->proxy, $helpers);
|
195 |
+
|
196 |
+
// Update RequestCore settings
|
197 |
+
$request->request_class = $this->request_class;
|
198 |
+
$request->response_class = $this->response_class;
|
199 |
+
|
200 |
+
// Generate required headers.
|
201 |
+
$request->set_method($method);
|
202 |
+
$canonical_date = gmdate($this->util->konst($this->util, 'DATE_FORMAT_RFC2616'));
|
203 |
+
$request->add_header('x-amz-date', $canonical_date);
|
204 |
+
$signature = base64_encode(hash_hmac('sha1', $canonical_date, $this->secret_key, true));
|
205 |
+
$request->add_header('Authorization', 'AWS ' . $this->key . ':' . $signature);
|
206 |
+
|
207 |
+
// Add configuration XML if we have it.
|
208 |
+
if ($xml)
|
209 |
+
{
|
210 |
+
$request->add_header('Content-Length', strlen($xml));
|
211 |
+
$request->add_header('Content-Type', 'application/xml');
|
212 |
+
$request->set_body($xml);
|
213 |
+
}
|
214 |
+
|
215 |
+
// Set If-Match: ETag header if we have one.
|
216 |
+
if ($etag)
|
217 |
+
{
|
218 |
+
$request->add_header('If-Match', $etag);
|
219 |
+
}
|
220 |
+
|
221 |
+
$curlopts = array();
|
222 |
+
|
223 |
+
// Set custom CURLOPT settings
|
224 |
+
if (isset($opt['curlopts']))
|
225 |
+
{
|
226 |
+
$curlopts = $opt['curlopts'];
|
227 |
+
unset($opt['curlopts']);
|
228 |
+
}
|
229 |
+
|
230 |
+
// Debug mode
|
231 |
+
if ($this->debug_mode)
|
232 |
+
{
|
233 |
+
$curlopts[CURLOPT_VERBOSE] = true;
|
234 |
+
}
|
235 |
+
|
236 |
+
if (count($curlopts))
|
237 |
+
{
|
238 |
+
$request->set_curlopts($curlopts);
|
239 |
+
}
|
240 |
+
|
241 |
+
// Manage the (newer) batch request API or the (older) returnCurlHandle setting.
|
242 |
+
if ($this->use_batch_flow)
|
243 |
+
{
|
244 |
+
$handle = $request->prep_request();
|
245 |
+
$this->batch_object->add($handle);
|
246 |
+
$this->use_batch_flow = false;
|
247 |
+
|
248 |
+
return $handle;
|
249 |
+
}
|
250 |
+
elseif (isset($opt['returnCurlHandle']) && $opt['returnCurlHandle'] == (bool) true)
|
251 |
+
{
|
252 |
+
return $request->prep_request();
|
253 |
+
}
|
254 |
+
|
255 |
+
// Send!
|
256 |
+
$request->send_request();
|
257 |
+
|
258 |
+
// Prepare the response.
|
259 |
+
$headers = $request->get_response_header();
|
260 |
+
if ($xml) $headers['x-aws-body'] = $xml;
|
261 |
+
|
262 |
+
$data = new $this->response_class($headers, $this->parse_callback($request->get_response_body()), $request->get_response_code());
|
263 |
+
|
264 |
+
// Was it Amazon's fault the request failed? Retry the request until we reach $max_retries.
|
265 |
+
if ((integer) $request->get_response_code() === 500 || (integer) $request->get_response_code() === 503)
|
266 |
+
{
|
267 |
+
if ($redirects <= $this->max_retries)
|
268 |
+
{
|
269 |
+
// Exponential backoff
|
270 |
+
$delay = (integer) (pow(4, $redirects) * 100000);
|
271 |
+
usleep($delay);
|
272 |
+
$data = $this->authenticate($method, $path, $opt, $xml, $etag, ++$redirects);
|
273 |
+
}
|
274 |
+
}
|
275 |
+
|
276 |
+
return $data;
|
277 |
+
}
|
278 |
+
|
279 |
+
/**
|
280 |
+
* When caching is enabled, this method fires the request to the server, and the response is cached.
|
281 |
+
* Accepts identical parameters as <authenticate()>. You should never call this method directly—it is
|
282 |
+
* used internally by the caching system.
|
283 |
+
*
|
284 |
+
* @param string $method (Required) The HTTP method to use to connect. Accepts <code>GET</code>, <code>POST</code>, <code>PUT</code>, <code>DELETE</code>, and <code>HEAD</code>.
|
285 |
+
* @param string $path (Optional) The endpoint path to make requests to.
|
286 |
+
* @param array $opt (Optional) An associative array of parameters for authenticating. See the individual methods for allowed keys.
|
287 |
+
* @param string $xml (Optional) The XML body content to send along in the request.
|
288 |
+
* @param string $etag (Optional) The ETag value to pass along with the If-Match HTTP header.
|
289 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
290 |
+
*/
|
291 |
+
public function cache_callback($method = 'GET', $path = null, $opt = null, $xml = null, $etag = null)
|
292 |
+
{
|
293 |
+
// Disable the cache flow since it's already been handled.
|
294 |
+
$this->use_cache_flow = false;
|
295 |
+
|
296 |
+
// Make the request
|
297 |
+
$response = $this->authenticate($method, $path, $opt, $xml, $etag);
|
298 |
+
|
299 |
+
if (isset($response->body) && ($response->body instanceof SimpleXMLElement))
|
300 |
+
{
|
301 |
+
$response->body = $response->body->asXML();
|
302 |
+
}
|
303 |
+
|
304 |
+
return $response;
|
305 |
+
}
|
306 |
+
|
307 |
+
|
308 |
+
/*%******************************************************************************************%*/
|
309 |
+
// SETTERS
|
310 |
+
|
311 |
+
/**
|
312 |
+
* Set the key ID of the RSA key pair being used.
|
313 |
+
*
|
314 |
+
* @param string $key_pair_id (Required) The ID of the RSA key pair being used.
|
315 |
+
* @return $this A reference to the current instance.
|
316 |
+
*/
|
317 |
+
public function set_keypair_id($key_pair_id)
|
318 |
+
{
|
319 |
+
$this->key_pair_id = $key_pair_id;
|
320 |
+
return $this;
|
321 |
+
}
|
322 |
+
|
323 |
+
/**
|
324 |
+
* Set the private key resource locator being used.
|
325 |
+
*
|
326 |
+
* @param string $private_key (Optional) The contents of the RSA private key used to sign requests.
|
327 |
+
* @return $this A reference to the current instance.
|
328 |
+
*/
|
329 |
+
public function set_private_key($private_key)
|
330 |
+
{
|
331 |
+
$this->private_key = $private_key;
|
332 |
+
return $this;
|
333 |
+
}
|
334 |
+
|
335 |
+
/**
|
336 |
+
* Overrides the <CFRuntime::disable_ssl()> method from the base class. SSL is required for CloudFront.
|
337 |
+
*
|
338 |
+
* @return void
|
339 |
+
*/
|
340 |
+
public function disable_ssl()
|
341 |
+
{
|
342 |
+
throw new CloudFront_Exception('SSL/HTTPS is REQUIRED for Amazon CloudFront and cannot be disabled.');
|
343 |
+
}
|
344 |
+
|
345 |
+
|
346 |
+
/*%******************************************************************************************%*/
|
347 |
+
// GENERATE CONFIG XML
|
348 |
+
|
349 |
+
/**
|
350 |
+
* Generates the distribution configuration XML used with <create_distribution()> and
|
351 |
+
* <set_distribution_config()>.
|
352 |
+
*
|
353 |
+
* @param string $origin (Required) The source to use for the Amazon CloudFront distribution. Use an Amazon S3 bucket name, or a fully-qualified non-S3 domain name prefixed with <code>http://</code> or <code>https://</code>.
|
354 |
+
* @param string $caller_reference (Required) A unique identifier for the request. A timestamp-appended string is recommended.
|
355 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
356 |
+
* <li><code>CNAME</code> - <code>string|array</code> - Optional - A DNS CNAME to use to map to the Amazon CloudFront distribution. If setting more than one, use an indexed array. Supports 1-10 CNAMEs.</li>
|
357 |
+
* <li><code>Comment</code> - <code>string</code> - Optional - A comment to apply to the distribution. Cannot exceed 128 characters.</li>
|
358 |
+
* <li><code>DefaultRootObject</code> - <code>string</code> - Optional - The file to load when someone accesses the root of your Amazon CloudFront domain (e.g., <code>index.html</code>).</li>
|
359 |
+
* <li><code>Enabled</code> - <code>string</code> - Optional - A value of <code>true</code> enables the distribution. A value of <code>false</code> disables it. The default value is <code>true</code>.</li>
|
360 |
+
* <li><code>Logging</code> - <code>array</code> - Optional - An array that contains two keys: <code>Bucket</code>, specifying where logs are written to, and <code>Prefix</code>, specifying a prefix to append to log file names.</li>
|
361 |
+
* <li><code>OriginAccessIdentity</code> - <code>string</code> - Optional - The origin access identity (OAI) associated with this distribution. Use the Identity ID from the OAI, not the <code>CanonicalId</code>. Requires an S3 origin.</li>
|
362 |
+
* <li><code>OriginProtocolPolicy</code> - <code>string</code> - Optional - The origin protocol policy to apply to your origin. If you specify <code>http-only</code>, CloudFront will use HTTP only to access the origin. If you specify <code>match-viewer</code>, CloudFront will fetch from your origin using HTTP or HTTPS, based on the protocol of the viewer request. It has a default value of <code>match-viewer</code>. [Allowed values: <code>http-only</code>, <code>match-viewer</code>]</li>
|
363 |
+
* <li><code>Streaming</code> - <code>boolean</code> - Optional - Whether or not this should be for a streaming distribution. A value of <code>true</code> will create a streaming distribution. A value of <code>false</code> will create a standard distribution. The default value is <code>false</code>.</li>
|
364 |
+
* <li><code>TrustedSigners</code> - <code>array</code> - Optional - An array of AWS account numbers for users who are trusted signers. Explicity add the value <code>Self</code> to the array to add your own account as a trusted signer.</li></ul>
|
365 |
+
* @return string An XML document to be used as the distribution configuration.
|
366 |
+
*/
|
367 |
+
public function generate_config_xml($origin, $caller_reference, $opt = null)
|
368 |
+
{
|
369 |
+
// Default, empty XML
|
370 |
+
$xml = simplexml_load_string(sprintf($this->base_xml, (
|
371 |
+
(isset($opt['Streaming']) && $opt['Streaming'] == (bool) true) ? 'StreamingDistributionConfig' : 'DistributionConfig')
|
372 |
+
));
|
373 |
+
|
374 |
+
if (substr($origin, 0, 7) === 'http://' || substr($origin, 0, 8) === 'https://')
|
375 |
+
{
|
376 |
+
// Custom Origin
|
377 |
+
$custom_origin = $xml->addChild('CustomOrigin');
|
378 |
+
$custom_origin->addChild('DNSName', str_replace(array('http://', 'https://'), '', $origin));
|
379 |
+
|
380 |
+
if (isset($opt['OriginProtocolPolicy']))
|
381 |
+
{
|
382 |
+
$custom_origin->addChild('OriginProtocolPolicy', $opt['OriginProtocolPolicy']);
|
383 |
+
}
|
384 |
+
else
|
385 |
+
{
|
386 |
+
$custom_origin->addChild('OriginProtocolPolicy', 'match-viewer');
|
387 |
+
}
|
388 |
+
}
|
389 |
+
else
|
390 |
+
{
|
391 |
+
// S3 Origin
|
392 |
+
$s3_origin = $xml->addChild('S3Origin');
|
393 |
+
$s3_origin->addChild('DNSName', $origin . ((stripos($origin, '.s3.amazonaws.com') === false) ? '.s3.amazonaws.com' : ''));
|
394 |
+
|
395 |
+
// Origin Access Identity
|
396 |
+
if (isset($opt['OriginAccessIdentity']))
|
397 |
+
{
|
398 |
+
$s3_origin->addChild('OriginAccessIdentity', 'origin-access-identity/cloudfront/' . $opt['OriginAccessIdentity']);
|
399 |
+
}
|
400 |
+
}
|
401 |
+
|
402 |
+
// CallerReference
|
403 |
+
$xml->addChild('CallerReference', $caller_reference);
|
404 |
+
|
405 |
+
// CNAME
|
406 |
+
if (isset($opt['CNAME']))
|
407 |
+
{
|
408 |
+
if (is_array($opt['CNAME']))
|
409 |
+
{
|
410 |
+
foreach ($opt['CNAME'] as $cname)
|
411 |
+
{
|
412 |
+
$xml->addChild('CNAME', $cname);
|
413 |
+
}
|
414 |
+
}
|
415 |
+
else
|
416 |
+
{
|
417 |
+
$xml->addChild('CNAME', $opt['CNAME']);
|
418 |
+
}
|
419 |
+
}
|
420 |
+
|
421 |
+
// Comment
|
422 |
+
if (isset($opt['Comment']))
|
423 |
+
{
|
424 |
+
$xml->addChild('Comment', $opt['Comment']);
|
425 |
+
}
|
426 |
+
|
427 |
+
// Enabled
|
428 |
+
if (isset($opt['Enabled']))
|
429 |
+
{
|
430 |
+
$xml->addChild('Enabled', $opt['Enabled'] ? 'true' : 'false');
|
431 |
+
}
|
432 |
+
else
|
433 |
+
{
|
434 |
+
$xml->addChild('Enabled', 'true');
|
435 |
+
}
|
436 |
+
|
437 |
+
// Logging
|
438 |
+
if (isset($opt['Logging']))
|
439 |
+
{
|
440 |
+
if (is_array($opt['Logging']))
|
441 |
+
{
|
442 |
+
$logging = $xml->addChild('Logging');
|
443 |
+
$bucket_name = $opt['Logging']['Bucket'];
|
444 |
+
|
445 |
+
// Origin
|
446 |
+
$logging->addChild('Bucket', $bucket_name . (
|
447 |
+
(stripos($bucket_name, '.s3.amazonaws.com') === false) ? '.s3.amazonaws.com' : ''
|
448 |
+
));
|
449 |
+
|
450 |
+
$logging->addChild('Prefix', $opt['Logging']['Prefix']);
|
451 |
+
}
|
452 |
+
}
|
453 |
+
|
454 |
+
// Required Protocols
|
455 |
+
if (isset($opt['RequiredProtocols']))
|
456 |
+
{
|
457 |
+
$required_protocols = $xml->addChild('RequiredProtocols');
|
458 |
+
$required_protocols->addChild('Protocol', $opt['RequiredProtocols']);
|
459 |
+
}
|
460 |
+
|
461 |
+
// Trusted Signers
|
462 |
+
if (isset($opt['TrustedSigners']))
|
463 |
+
{
|
464 |
+
$trusted_signers = $xml->addChild('TrustedSigners');
|
465 |
+
|
466 |
+
// Not an array? Convert to one.
|
467 |
+
if (!is_array($opt['TrustedSigners']))
|
468 |
+
{
|
469 |
+
$opt['TrustedSigners'] = array($opt['TrustedSigners']);
|
470 |
+
}
|
471 |
+
|
472 |
+
// Handle 'Self' vs. everything else
|
473 |
+
foreach ($opt['TrustedSigners'] as $signer)
|
474 |
+
{
|
475 |
+
if (strtolower($signer) === 'self')
|
476 |
+
{
|
477 |
+
$trusted_signers->addChild('Self');
|
478 |
+
}
|
479 |
+
else
|
480 |
+
{
|
481 |
+
$trusted_signers->addChild('AwsAccountNumber', $signer);
|
482 |
+
}
|
483 |
+
}
|
484 |
+
}
|
485 |
+
|
486 |
+
// DefaultRootObject
|
487 |
+
if (isset($opt['DefaultRootObject']))
|
488 |
+
{
|
489 |
+
$xml->addChild('DefaultRootObject', $opt['DefaultRootObject']);
|
490 |
+
}
|
491 |
+
|
492 |
+
return $xml->asXML();
|
493 |
+
}
|
494 |
+
|
495 |
+
/**
|
496 |
+
* Updates an existing configuration XML document.
|
497 |
+
*
|
498 |
+
* @param CFSimpleXML|CFResponse|string $xml (Required) The source configuration XML to make updates to. Can be the <CFSimpleXML> body of a <get_distribution_config()> response, the entire <CFResponse> of a <get_distribution_config()> response, or a string of XML generated by <generate_config_xml()> or <update_config_xml()>.
|
499 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
500 |
+
* <li><code>CNAME</code> - <code>string|array</code> - Optional - The value or values to add to the existing list of CNAME values. If setting more than one, use an indexed array. Supports up to 10 CNAMEs.</li>
|
501 |
+
* <li><code>Comment</code> - <code>string</code> - Optional - A comment to apply to the distribution. Cannot exceed 128 characters.</li>
|
502 |
+
* <li><code>DefaultRootObject</code> - <code>string</code> - Optional - The file to load when someone accesses the root of your Amazon CloudFront domain (e.g., <code>index.html</code>).</li>
|
503 |
+
* <li><code>Enabled</code> - <code>string</code> - Optional - A value of <code>true</code> enables the distribution. A value of <code>false</code> disables it. The default value is <code>true</code>.</li>
|
504 |
+
* <li><code>Logging</code> - <code>array</code> - Optional - An array that contains two keys: <code>Bucket</code>, specifying where logs are written to, and <code>Prefix</code>, specifying a prefix to append to log file names.</li>
|
505 |
+
* <li><code>OriginAccessIdentity</code> - <code>string</code> - Optional - The origin access identity (OAI) associated with this distribution. Use the Identity ID from the OAI, not the <code>CanonicalId</code>.</li>
|
506 |
+
* <li><code>TrustedSigners</code> - <code>array</code> - Optional - An array of AWS account numbers for users who are trusted signers. Explicity add the value <code>Self</code> to the array to add your own account as a trusted signer.</li></ul>
|
507 |
+
* @return string XML document.
|
508 |
+
*/
|
509 |
+
public function update_config_xml($xml, $opt = null)
|
510 |
+
{
|
511 |
+
// If we receive a full CFResponse object, only use the body.
|
512 |
+
if ($xml instanceof CFResponse)
|
513 |
+
{
|
514 |
+
$xml = $xml->body;
|
515 |
+
}
|
516 |
+
|
517 |
+
// If we received a string of XML, convert it into a CFSimpleXML object.
|
518 |
+
if (is_string($xml))
|
519 |
+
{
|
520 |
+
$xml = simplexml_load_string($xml, $this->parser_class);
|
521 |
+
}
|
522 |
+
|
523 |
+
// Default, empty XML
|
524 |
+
$update = simplexml_load_string(sprintf($this->base_xml, (
|
525 |
+
(isset($opt['Streaming']) && $opt['Streaming'] == (bool) true) ? 'StreamingDistributionConfig' : 'DistributionConfig')
|
526 |
+
), $this->parser_class);
|
527 |
+
|
528 |
+
// These can't change.
|
529 |
+
if (isset($xml->S3Origin))
|
530 |
+
{
|
531 |
+
$origin = $update->addChild('S3Origin');
|
532 |
+
$origin->addChild('DNSName', $xml->S3Origin->DNSName);
|
533 |
+
}
|
534 |
+
elseif (isset($xml->CustomOrigin))
|
535 |
+
{
|
536 |
+
$origin = $update->addChild('CustomOrigin');
|
537 |
+
$origin->addChild('DNSName', $xml->CustomOrigin->DNSName);
|
538 |
+
}
|
539 |
+
$update->addChild('CallerReference', $xml->CallerReference);
|
540 |
+
|
541 |
+
// Add existing CNAME values
|
542 |
+
if ($xml->CNAME)
|
543 |
+
{
|
544 |
+
$update->addChild('CNAME', $xml->CNAME);
|
545 |
+
}
|
546 |
+
|
547 |
+
// Add new CNAME values
|
548 |
+
if (isset($opt['CNAME']))
|
549 |
+
{
|
550 |
+
if (is_array($opt['CNAME']))
|
551 |
+
{
|
552 |
+
foreach ($opt['CNAME'] as $cname)
|
553 |
+
{
|
554 |
+
$update->addChild('CNAME', $cname);
|
555 |
+
}
|
556 |
+
}
|
557 |
+
else
|
558 |
+
{
|
559 |
+
$update->addChild('CNAME', $opt['CNAME']);
|
560 |
+
}
|
561 |
+
}
|
562 |
+
|
563 |
+
// Comment
|
564 |
+
if (isset($opt['Comment']))
|
565 |
+
{
|
566 |
+
$update->addChild('Comment', $opt['Comment']);
|
567 |
+
}
|
568 |
+
elseif (isset($xml->Comment))
|
569 |
+
{
|
570 |
+
$update->addChild('Comment', $xml->Comment);
|
571 |
+
}
|
572 |
+
|
573 |
+
// DefaultRootObject
|
574 |
+
if (isset($opt['DefaultRootObject']))
|
575 |
+
{
|
576 |
+
$update->addChild('DefaultRootObject', $opt['DefaultRootObject']);
|
577 |
+
}
|
578 |
+
elseif (isset($xml->DefaultRootObject))
|
579 |
+
{
|
580 |
+
$update->addChild('DefaultRootObject', $xml->DefaultRootObject);
|
581 |
+
}
|
582 |
+
|
583 |
+
// Enabled
|
584 |
+
if (isset($opt['Enabled']))
|
585 |
+
{
|
586 |
+
$update->addChild('Enabled', $opt['Enabled'] ? 'true' : 'false');
|
587 |
+
}
|
588 |
+
elseif (isset($xml->Enabled))
|
589 |
+
{
|
590 |
+
$update->addChild('Enabled', $xml->Enabled);
|
591 |
+
}
|
592 |
+
|
593 |
+
// Logging
|
594 |
+
if (isset($opt['Logging']))
|
595 |
+
{
|
596 |
+
if (is_array($opt['Logging']))
|
597 |
+
{
|
598 |
+
$logging = $update->addChild('Logging');
|
599 |
+
$bucket_name = $opt['Logging']['Bucket'];
|
600 |
+
|
601 |
+
// Origin
|
602 |
+
$logging->addChild('Bucket', $bucket_name . ((stripos($bucket_name, '.s3.amazonaws.com') === false) ? '.s3.amazonaws.com' : ''));
|
603 |
+
|
604 |
+
$logging->addChild('Prefix', $opt['Logging']['Prefix']);
|
605 |
+
}
|
606 |
+
}
|
607 |
+
elseif (isset($xml->Logging))
|
608 |
+
{
|
609 |
+
$logging = $update->addChild('Logging');
|
610 |
+
$logging->addChild('Bucket', $xml->Logging->Bucket);
|
611 |
+
$logging->addChild('Prefix', $xml->Logging->Prefix);
|
612 |
+
}
|
613 |
+
|
614 |
+
// origin access identity
|
615 |
+
if (isset($opt['OriginAccessIdentity']))
|
616 |
+
{
|
617 |
+
$update->addChild('OriginAccessIdentity', 'origin-access-identity/cloudfront/' . $opt['OriginAccessIdentity']);
|
618 |
+
}
|
619 |
+
elseif (isset($xml->OriginAccessIdentity))
|
620 |
+
{
|
621 |
+
$update->addChild('OriginAccessIdentity', $xml->OriginAccessIdentity);
|
622 |
+
}
|
623 |
+
|
624 |
+
// Trusted Signers
|
625 |
+
if (isset($opt['TrustedSigners']))
|
626 |
+
{
|
627 |
+
$trusted_signers = $update->addChild('TrustedSigners');
|
628 |
+
|
629 |
+
// Not an array? Convert to one.
|
630 |
+
if (!is_array($opt['TrustedSigners']))
|
631 |
+
{
|
632 |
+
$opt['TrustedSigners'] = array($opt['TrustedSigners']);
|
633 |
+
}
|
634 |
+
|
635 |
+
// Handle 'Self' vs. everything else
|
636 |
+
foreach ($opt['TrustedSigners'] as $signer)
|
637 |
+
{
|
638 |
+
if (strtolower($signer) === 'self')
|
639 |
+
{
|
640 |
+
$trusted_signers->addChild('Self');
|
641 |
+
}
|
642 |
+
else
|
643 |
+
{
|
644 |
+
$trusted_signers->addChild('AwsAccountNumber', $signer);
|
645 |
+
}
|
646 |
+
}
|
647 |
+
}
|
648 |
+
elseif (isset($xml->TrustedSigners) && $xml->TrustedSigners->count())
|
649 |
+
{
|
650 |
+
$trusted_signers = $update->addChild('TrustedSigners');
|
651 |
+
|
652 |
+
// Handle 'Self' vs. everything else
|
653 |
+
foreach ($xml->TrustedSigners->children() as $signer_key => $signer_value)
|
654 |
+
{
|
655 |
+
if (strtolower((string) $signer_key) === 'self')
|
656 |
+
{
|
657 |
+
$trusted_signers->addChild('Self');
|
658 |
+
}
|
659 |
+
else
|
660 |
+
{
|
661 |
+
$trusted_signers->addChild('AwsAccountNumber', (string) $signer_value);
|
662 |
+
}
|
663 |
+
}
|
664 |
+
}
|
665 |
+
|
666 |
+
// Output
|
667 |
+
return $update->asXML();
|
668 |
+
}
|
669 |
+
|
670 |
+
/**
|
671 |
+
* Removes one or more CNAMEs from a <code>DistibutionConfig</code> XML document.
|
672 |
+
*
|
673 |
+
* @param CFSimpleXML|CFResponse|string $xml (Required) The source DistributionConfig XML to make updates to. Can be the <CFSimpleXML> body of a <get_distribution_config()> response, the entire <CFResponse> of a <get_distribution_config()> response, or a string of XML generated by <generate_config_xml()> or <update_config_xml()>.
|
674 |
+
* @param string|array $cname (Optional) The value or values to remove from the existing list of CNAME values. To add a CNAME value, see <update_config_xml()>.
|
675 |
+
* @return string XML document.
|
676 |
+
*/
|
677 |
+
public function remove_cname($xml, $cname)
|
678 |
+
{
|
679 |
+
// If we receive a full CFResponse object, only use the body.
|
680 |
+
if ($xml instanceof CFResponse)
|
681 |
+
{
|
682 |
+
$xml = $xml->body;
|
683 |
+
}
|
684 |
+
|
685 |
+
// If we received a string of XML, convert it into a CFSimpleXML object.
|
686 |
+
if (is_string($xml))
|
687 |
+
{
|
688 |
+
$xml = simplexml_load_string($xml);
|
689 |
+
}
|
690 |
+
|
691 |
+
// Let's make sure that we have CNAMEs to remove in the first place.
|
692 |
+
if (isset($xml->CNAME))
|
693 |
+
{
|
694 |
+
// If we have an array of CNAME values...
|
695 |
+
if (is_array($cname))
|
696 |
+
{
|
697 |
+
foreach ($cname as $cn)
|
698 |
+
{
|
699 |
+
for ($i = 0, $length = sizeof($xml->CNAME); $i < $length; $i++)
|
700 |
+
{
|
701 |
+
if ((string) $xml->CNAME[$i] == $cn)
|
702 |
+
{
|
703 |
+
unset($xml->CNAME[$i]);
|
704 |
+
break;
|
705 |
+
}
|
706 |
+
}
|
707 |
+
}
|
708 |
+
}
|
709 |
+
|
710 |
+
// If we only have one CNAME value...
|
711 |
+
else
|
712 |
+
{
|
713 |
+
for ($i = 0, $length = sizeof($xml->CNAME); $i < $length; $i++)
|
714 |
+
{
|
715 |
+
if ((string) $xml->CNAME[$i] == $cname)
|
716 |
+
{
|
717 |
+
unset($xml->CNAME[$i]);
|
718 |
+
break;
|
719 |
+
}
|
720 |
+
}
|
721 |
+
}
|
722 |
+
}
|
723 |
+
|
724 |
+
return $xml->asXML();
|
725 |
+
}
|
726 |
+
|
727 |
+
/**
|
728 |
+
* Used to generate the origin access identity (OAI) Config XML used in <create_oai()>.
|
729 |
+
*
|
730 |
+
* @param string $caller_reference (Required) A unique identifier for the request. A timestamp-appended string is recommended.
|
731 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
732 |
+
* <li><code>Comment</code> - <code>string</code> - Optional - Replaces the existing value for "Comment". Cannot exceed 128 characters.</li></ul>
|
733 |
+
* @return string An XML document to be used as the OAI configuration.
|
734 |
+
*/
|
735 |
+
public function generate_oai_xml($caller_reference, $opt = null)
|
736 |
+
{
|
737 |
+
// Default, empty XML
|
738 |
+
$xml = simplexml_load_string(sprintf($this->base_xml, 'CloudFrontOriginAccessIdentityConfig'));
|
739 |
+
|
740 |
+
// CallerReference
|
741 |
+
$xml->addChild('CallerReference', $caller_reference);
|
742 |
+
|
743 |
+
// Comment
|
744 |
+
if (isset($opt['Comment']))
|
745 |
+
{
|
746 |
+
$xml->addChild('Comment', $opt['Comment']);
|
747 |
+
}
|
748 |
+
|
749 |
+
return $xml->asXML();
|
750 |
+
}
|
751 |
+
|
752 |
+
/**
|
753 |
+
* Updates the origin access identity (OAI) configureation XML used in <create_oai()>.
|
754 |
+
*
|
755 |
+
* @param CFSimpleXML|CFResponse|string $xml (Required) The source configuration XML to make updates to. Can be the <CFSimpleXML> body of a <get_oai_config()> response, the entire <CFResponse> of a <get_oai_config()> response, or a string of XML generated by <generate_oai_xml()> or <update_oai_xml()>.
|
756 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
757 |
+
* <li><code>Comment</code> - <code>string</code> - Optional - Replaces the existing value for "Comment". Cannot exceed 128 characters.</li></ul>
|
758 |
+
* @return string XML document.
|
759 |
+
*/
|
760 |
+
public function update_oai_xml($xml, $opt = null)
|
761 |
+
{
|
762 |
+
// If we receive a full CFResponse object, only use the body.
|
763 |
+
if ($xml instanceof CFResponse)
|
764 |
+
{
|
765 |
+
$xml = $xml->body;
|
766 |
+
}
|
767 |
+
|
768 |
+
// If we received a string of XML, convert it into a CFSimpleXML object.
|
769 |
+
if (is_string($xml))
|
770 |
+
{
|
771 |
+
$xml = simplexml_load_string($xml, $this->parser_class);
|
772 |
+
}
|
773 |
+
|
774 |
+
// Update the comment, if we have one.
|
775 |
+
if (isset($opt['Comment']) && isset($xml->Comment))
|
776 |
+
{
|
777 |
+
$xml->Comment = $opt['Comment'];
|
778 |
+
}
|
779 |
+
elseif (isset($opt['Comment']))
|
780 |
+
{
|
781 |
+
$xml->addChild('Comment', $opt['Comment']);
|
782 |
+
}
|
783 |
+
|
784 |
+
return $xml->asXML();
|
785 |
+
}
|
786 |
+
|
787 |
+
/**
|
788 |
+
* Generates the Invalidation Config XML used in <create_invalidation()>.
|
789 |
+
*
|
790 |
+
* @param string $caller_reference (Required) A unique identifier for the request. A timestamp-appended string is recommended.
|
791 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
792 |
+
* <li><code>Paths</code> - <code>string|array</code> - Optional - One or more paths to set for invalidation. Pass a string for a single value, or an indexed array for multiple values.</li></ul>
|
793 |
+
* @return string An XML document to be used as the Invalidation configuration.
|
794 |
+
*/
|
795 |
+
public function generate_invalidation_xml($caller_reference, $opt = null)
|
796 |
+
{
|
797 |
+
// Default, empty XML
|
798 |
+
$xml = simplexml_load_string(sprintf($this->base_xml, 'InvalidationBatch'));
|
799 |
+
|
800 |
+
// CallerReference
|
801 |
+
$xml->addChild('CallerReference', $caller_reference);
|
802 |
+
|
803 |
+
// Paths
|
804 |
+
if (isset($opt['Paths']))
|
805 |
+
{
|
806 |
+
$paths = is_array($opt['Paths']) ? $opt['Paths'] : array($opt['Paths']);
|
807 |
+
|
808 |
+
foreach ($paths as $path)
|
809 |
+
{
|
810 |
+
$path = str_replace('%2F', '/', rawurlencode($path));
|
811 |
+
$path = (substr($path, 0, 1) === '/') ? $path : ('/' . $path);
|
812 |
+
$xml->addChild('Path', $path);
|
813 |
+
}
|
814 |
+
}
|
815 |
+
|
816 |
+
return $xml->asXML();
|
817 |
+
}
|
818 |
+
|
819 |
+
|
820 |
+
/*%******************************************************************************************%*/
|
821 |
+
// DISTRIBUTIONS
|
822 |
+
|
823 |
+
/**
|
824 |
+
* Creates an Amazon CloudFront distribution. You can have up to 100 distributions in the Amazon
|
825 |
+
* CloudFront system.
|
826 |
+
*
|
827 |
+
* For an Adobe Real-Time Messaging Protocol (RTMP) streaming distribution, set the <code>Streaming</code> option
|
828 |
+
* to true.
|
829 |
+
*
|
830 |
+
* @param string $origin (Required) The source to use for the Amazon CloudFront distribution. Use an Amazon S3 bucket name, or a fully-qualified non-S3 domain name prefixed with <code>http://</code> or <code>https://</code>.
|
831 |
+
* @param string $caller_reference (Required) A unique identifier for the request. A timestamp-appended string is recommended.
|
832 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
833 |
+
* <li><code>CNAME</code> - <code>string|array</code> - Optional - A DNS CNAME to use to map to the Amazon CloudFront distribution. If setting more than one, use an indexed array. Supports 1-10 CNAMEs.</li>
|
834 |
+
* <li><code>Comment</code> - <code>string</code> - Optional - A comment to apply to the distribution. Cannot exceed 128 characters.</li>
|
835 |
+
* <li><code>DefaultRootObject</code> - <code>string</code> - Optional - The file to load when someone accesses the root of the Amazon CloudFront domain (e.g., <code>index.html</code>).</li>
|
836 |
+
* <li><code>Enabled</code> - <code>string</code> - Optional - A value of <code>true</code> will enable the distribution. A value of <code>false</code> will disable it. The default value is <code>true</code>.</li>
|
837 |
+
* <li><code>OriginAccessIdentity</code> - <code>string</code> - Optional - The origin access identity (OAI) associated with this distribution. Use the Identity ID from the OAI, not the <code>CanonicalId</code>. Requires an S3 origin.</li>
|
838 |
+
* <li><code>OriginProtocolPolicy</code> - <code>string</code> - Optional - The origin protocol policy to apply to your origin. If you specify <code>http-only</code>, CloudFront will use HTTP only to access the origin. If you specify <code>match-viewer</code>, CloudFront will fetch from your origin using HTTP or HTTPS, based on the protocol of the viewer request. [Allowed values: <code>http-only</code>, <code>match-viewer</code>]. The default value is <code>match-viewer</code>. Requires a non-S3 origin.</li>
|
839 |
+
* <li><code>Streaming</code> - <code>boolean</code> - Optional - Whether or not this should be for a streaming distribution. A value of <code>true</code> creates a streaming distribution. A value of <code>false</code> creates a standard distribution. The default value is <code>false</code>.</li>
|
840 |
+
* <li><code>TrustedSigners</code> - <code>array</code> - Optional - An array of AWS account numbers for users who are trusted signers. Explicity add the value <code>Self</code> to the array to add your own account as a trusted signer.</li>
|
841 |
+
* <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>
|
842 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
843 |
+
* @link http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/CreateDistribution.html POST Distribution
|
844 |
+
* @link http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/CreateStreamingDistribution.html POST Streaming Distribution
|
845 |
+
*/
|
846 |
+
public function create_distribution($origin, $caller_reference, $opt = null)
|
847 |
+
{
|
848 |
+
if (!$opt) $opt = array();
|
849 |
+
|
850 |
+
$xml = $this->generate_config_xml($origin, $caller_reference, $opt);
|
851 |
+
$path = '/' . ((isset($opt['Streaming']) && $opt['Streaming'] == (bool) true) ? 'streaming-distribution' : 'distribution');
|
852 |
+
|
853 |
+
return $this->authenticate('POST', $path, $opt, $xml, null);
|
854 |
+
}
|
855 |
+
|
856 |
+
/**
|
857 |
+
* Gets a list of distributions. By default, the list is returned as one result. If needed, paginate the
|
858 |
+
* list by specifying values for the <code>MaxItems</code> and <code>Marker</code> parameters.
|
859 |
+
*
|
860 |
+
* Standard distributions are listed separately from streaming distributions. For streaming distributions,
|
861 |
+
* set the <code>Streaming</code> option to true.
|
862 |
+
*
|
863 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
864 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - Use this setting when paginating results to indicate where in your list of distributions to begin. The results include distributions in the list that occur after the marker. To get the next page of results, set the <code>Marker</code> to the value of the <code>NextMarker</code> from the current page's response (which is also the ID of the last distribution on that page).</li>
|
865 |
+
* <li><code>MaxItems</code> - <code>integer</code> - Optional - The maximum number of distributions you want in the response body. Maximum of 100.</li>
|
866 |
+
* <li><code>Streaming</code> - <code>boolean</code> - Optional - Whether or not this should be for a streaming distribution. A value of <code>true</code> will create a streaming distribution. A value of <code>false</code> will create a standard distribution. The default value is <code>false</code>.</li>
|
867 |
+
* <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>
|
868 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
869 |
+
* @link http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/ListDistributions.html GET Distribution List
|
870 |
+
* @link http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/ListStreamingDistributions.html GET Streaming Distribution List
|
871 |
+
*/
|
872 |
+
public function list_distributions($opt = null)
|
873 |
+
{
|
874 |
+
if (!$opt) $opt = array();
|
875 |
+
$opt['query_string'] = array();
|
876 |
+
|
877 |
+
// Pass these to the query string
|
878 |
+
foreach (array('Marker', 'MaxItems') as $option)
|
879 |
+
{
|
880 |
+
if (isset($opt[$option]))
|
881 |
+
{
|
882 |
+
$opt['query_string'][$option] = $opt[$option];
|
883 |
+
}
|
884 |
+
}
|
885 |
+
|
886 |
+
$path = '/' . ((isset($opt['Streaming']) && $opt['Streaming'] == (bool) true) ? 'streaming-distribution' : 'distribution');
|
887 |
+
|
888 |
+
return $this->authenticate('GET', $path, $opt, null, null);
|
889 |
+
}
|
890 |
+
|
891 |
+
/**
|
892 |
+
* Gets distribution information for the specified distribution ID.
|
893 |
+
*
|
894 |
+
* Standard distributions are handled separately from streaming distributions. For streaming
|
895 |
+
* distributions, set the <code>Streaming</code> option to true.
|
896 |
+
*
|
897 |
+
* @param string $distribution_id (Required) The distribution ID returned from <create_distribution()> or <list_distributions()>.
|
898 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
899 |
+
* <li><code>Streaming</code> - <code>boolean</code> - Optional - Whether or not this should be for a streaming distribution. A value of <code>true</code> will create a streaming distribution. A value of <code>false</code> will create a standard distribution. The default value is <code>false</code>.</li>
|
900 |
+
* <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>
|
901 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
902 |
+
* @link http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/GetDistribution.html GET Distribution
|
903 |
+
* @link http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/GetStreamingDistribution.html GET Streaming Distribution
|
904 |
+
*/
|
905 |
+
public function get_distribution_info($distribution_id, $opt = null)
|
906 |
+
{
|
907 |
+
if (!$opt) $opt = array();
|
908 |
+
|
909 |
+
$path = '/' . ((isset($opt['Streaming']) && $opt['Streaming'] == (bool) true) ? 'streaming-distribution' : 'distribution');
|
910 |
+
$path .= '/' . $distribution_id;
|
911 |
+
|
912 |
+
return $this->authenticate('GET', $path, $opt, null, null);
|
913 |
+
}
|
914 |
+
|
915 |
+
/**
|
916 |
+
* Deletes a disabled distribution. If distribution hasn't been disabled, Amazon CloudFront returns a
|
917 |
+
* <code>DistributionNotDisabled</code> error. Use <set_distribution_config()> to disable a distribution before
|
918 |
+
* attempting to delete.
|
919 |
+
*
|
920 |
+
* For an Adobe Real-Time Messaging Protocol (RTMP) streaming distribution, set the <code>Streaming</code> option
|
921 |
+
* to be <code>true</code>.
|
922 |
+
*
|
923 |
+
* @param string $distribution_id (Required) The distribution ID returned from <create_distribution()> or <list_distributions()>.
|
924 |
+
* @param string $etag (Required) The <code>ETag</code> header value retrieved from <get_distribution_config()>.
|
925 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
926 |
+
* <li><code>Streaming</code> - <code>boolean</code> - Optional - Whether or not this should be for a streaming distribution. A value of <code>true</code> will create a streaming distribution. A value of <code>false</code> will create a standard distribution. The default value is <code>false</code>.</li>
|
927 |
+
* <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>
|
928 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
929 |
+
* @link http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/DeleteDistribution.html DELETE Distribution
|
930 |
+
* @link http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/DeleteStreamingDistribution.html DELETE Streaming Distribution
|
931 |
+
*/
|
932 |
+
public function delete_distribution($distribution_id, $etag, $opt = null)
|
933 |
+
{
|
934 |
+
if (!$opt) $opt = array();
|
935 |
+
|
936 |
+
$path = '/' . ((isset($opt['Streaming']) && $opt['Streaming'] == (bool) true) ? 'streaming-distribution' : 'distribution');
|
937 |
+
$path .= '/' . $distribution_id;
|
938 |
+
|
939 |
+
return $this->authenticate('DELETE', $path, $opt, null, $etag);
|
940 |
+
}
|
941 |
+
|
942 |
+
/**
|
943 |
+
* Gets the current distribution configuration for the specified distribution ID.
|
944 |
+
*
|
945 |
+
* Standard distributions are handled separately from streaming distributions. For streaming
|
946 |
+
* distributions, set the <code>Streaming</code> option to true.
|
947 |
+
*
|
948 |
+
* @param string $distribution_id (Required) The distribution ID returned from <create_distribution()> or <list_distributions()>.
|
949 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
950 |
+
* <li><code>Streaming</code> - <code>boolean</code> - Optional - Whether or not this should be for a streaming distribution. A value of <code>true</code> will create a streaming distribution. A value of <code>false</code> will create a standard distribution. The default value is <code>false</code>.</li>
|
951 |
+
* <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>
|
952 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
953 |
+
* @link http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/GetConfig.html GET Distribution Config
|
954 |
+
* @link http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/GetStreamingDistConfig.html GET Streaming Distribution Config
|
955 |
+
*/
|
956 |
+
public function get_distribution_config($distribution_id, $opt = null)
|
957 |
+
{
|
958 |
+
if (!$opt) $opt = array();
|
959 |
+
|
960 |
+
$path = '/' . ((isset($opt['Streaming']) && $opt['Streaming'] == (bool) true) ? 'streaming-distribution' : 'distribution');
|
961 |
+
$path .= '/' . $distribution_id . '/config';
|
962 |
+
|
963 |
+
return $this->authenticate('GET', $path, $opt, null, null);
|
964 |
+
}
|
965 |
+
|
966 |
+
/**
|
967 |
+
* Sets a new distribution configuration for the specified distribution ID.
|
968 |
+
*
|
969 |
+
* Standard distributions are handled separately from streaming distributions. For streaming
|
970 |
+
* distributions, set the <code>Streaming</code> option to true.
|
971 |
+
*
|
972 |
+
* @param string $distribution_id (Required) The distribution ID returned from <create_distribution()> or <list_distributions()>.
|
973 |
+
* @param string $xml (Required) The DistributionConfig XML generated by <generate_config_xml()> or <update_config_xml()>.
|
974 |
+
* @param string $etag (Required) The ETag header value retrieved from <get_distribution_config()>.
|
975 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
976 |
+
* <li><code>Streaming</code> - <code>boolean</code> - Optional - Whether or not this should be for a streaming distribution. A value of <code>true</code> will create a streaming distribution. A value of <code>false</code> will create a standard distribution. The default value is <code>false</code>.</li>
|
977 |
+
* <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>
|
978 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
979 |
+
* @link http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/PutConfig.html PUT Distribution Config
|
980 |
+
* @link http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/PutStreamingDistConfig.html PUT Streaming Distribution Config
|
981 |
+
*/
|
982 |
+
public function set_distribution_config($distribution_id, $xml, $etag, $opt = null)
|
983 |
+
{
|
984 |
+
if (!$opt) $opt = array();
|
985 |
+
|
986 |
+
$path = '/' . ((isset($opt['Streaming']) && $opt['Streaming'] == (bool) true) ? 'streaming-distribution' : 'distribution');
|
987 |
+
$path .= '/' . $distribution_id . '/config';
|
988 |
+
|
989 |
+
return $this->authenticate('PUT', $path, $opt, $xml, $etag);
|
990 |
+
}
|
991 |
+
|
992 |
+
|
993 |
+
/*%******************************************************************************************%*/
|
994 |
+
// Origin Access Identity
|
995 |
+
|
996 |
+
/**
|
997 |
+
* Creates a new Amazon CloudFront origin access identity (OAI). You can create up to 100 OAIs per AWS
|
998 |
+
* account. For more information, see the Amazon CloudFront Developer Guide.
|
999 |
+
*
|
1000 |
+
* @param string $caller_reference (Required) A unique identifier for the request. A timestamp-appended string is recommended.
|
1001 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1002 |
+
* <li><code>Comment</code> - <code>string</code> - Optional - A comment about the OAI.</li>
|
1003 |
+
* <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>
|
1004 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1005 |
+
* @link http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/CreateOAI.html POST Origin Access Identity
|
1006 |
+
*/
|
1007 |
+
public function create_oai($caller_reference, $opt = null)
|
1008 |
+
{
|
1009 |
+
if (!$opt) $opt = array();
|
1010 |
+
|
1011 |
+
$path = '/origin-access-identity/cloudfront';
|
1012 |
+
$xml = $this->generate_oai_xml($caller_reference, $opt);
|
1013 |
+
|
1014 |
+
return $this->authenticate('POST', $path, $opt, $xml, null);
|
1015 |
+
}
|
1016 |
+
|
1017 |
+
/**
|
1018 |
+
* Gets a list of origin access identity (OAI) summaries. By default, the list is returned as one result.
|
1019 |
+
* If needed, paginate the list by specifying values for the <code>MaxItems</code> and <code>Marker</code>
|
1020 |
+
* parameters.
|
1021 |
+
*
|
1022 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1023 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - Use this when paginating results to indicate where in your list of distributions to begin. The results include distributions in the list that occur after the marker. To get the next page of results, set the Marker to the value of the NextMarker from the current page's response (which is also the ID of the last distribution on that page).</li>
|
1024 |
+
* <li><code>MaxItems</code> - <code>integer</code> - Optional - The maximum number of distributions you want in the response body. Maximum of 100.</li>
|
1025 |
+
* <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>
|
1026 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1027 |
+
* @link http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/ListOAIs.html GET Origin Access Identity List
|
1028 |
+
*/
|
1029 |
+
public function list_oais($opt = null)
|
1030 |
+
{
|
1031 |
+
if (!$opt) $opt = array();
|
1032 |
+
$opt['query_string'] = array();
|
1033 |
+
|
1034 |
+
// Pass these to the query string
|
1035 |
+
foreach (array('Marker', 'MaxItems') as $option)
|
1036 |
+
{
|
1037 |
+
if (isset($opt[$option]))
|
1038 |
+
{
|
1039 |
+
$opt['query_string'][$option] = $opt[$option];
|
1040 |
+
}
|
1041 |
+
}
|
1042 |
+
|
1043 |
+
$path = '/origin-access-identity/cloudfront';
|
1044 |
+
|
1045 |
+
return $this->authenticate('GET', $path, $opt, null, null);
|
1046 |
+
}
|
1047 |
+
|
1048 |
+
/**
|
1049 |
+
* Gets information about an origin access identity (OAI).
|
1050 |
+
*
|
1051 |
+
* @param string $identity_id (Required) The Identity ID for an existing OAI.
|
1052 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1053 |
+
* <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>
|
1054 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1055 |
+
* @link http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/GetOAI.html GET Origin Access Identity
|
1056 |
+
*/
|
1057 |
+
public function get_oai($identity_id, $opt = null)
|
1058 |
+
{
|
1059 |
+
if (!$opt) $opt = array();
|
1060 |
+
|
1061 |
+
$path = '/origin-access-identity/cloudfront/' . $identity_id;
|
1062 |
+
|
1063 |
+
return $this->authenticate('GET', $path, $opt, null, null);
|
1064 |
+
}
|
1065 |
+
|
1066 |
+
/**
|
1067 |
+
* Deletes an Amazon CloudFront origin access identity (OAI). To delete an OAI, the identity must first
|
1068 |
+
* be disassociated from all distributions (by updating each distribution's configuration to omit the
|
1069 |
+
* <code>OriginAccessIdentity</code> element). Wait until each distribution's state is <code>Deployed</code>
|
1070 |
+
* before deleting the OAI.
|
1071 |
+
*
|
1072 |
+
* @param string $identity_id (Required) An Identity ID for an existing OAI.
|
1073 |
+
* @param string $etag (Required) The <code>ETag</code> header value retrieved from a call to <get_oai()>.
|
1074 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1075 |
+
* <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>
|
1076 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1077 |
+
* @link http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/DeleteOAI.html DELETE Origin Access Identity
|
1078 |
+
*/
|
1079 |
+
public function delete_oai($identity_id, $etag, $opt = null)
|
1080 |
+
{
|
1081 |
+
if (!$opt) $opt = array();
|
1082 |
+
|
1083 |
+
$path = '/origin-access-identity/cloudfront/' . $identity_id;
|
1084 |
+
|
1085 |
+
return $this->authenticate('DELETE', $path, $opt, null, $etag);
|
1086 |
+
}
|
1087 |
+
|
1088 |
+
/**
|
1089 |
+
* Gets the configuration of the origin access identity (OAI) for the specified identity ID.
|
1090 |
+
*
|
1091 |
+
* @param string $identity_id (Required) An Identity ID for an existing OAI.
|
1092 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1093 |
+
* <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>
|
1094 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1095 |
+
* @link http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/GetOAIConfig.html GET Origin Access Identity Config
|
1096 |
+
*/
|
1097 |
+
public function get_oai_config($identity_id, $opt = null)
|
1098 |
+
{
|
1099 |
+
if (!$opt) $opt = array();
|
1100 |
+
|
1101 |
+
$path = '/origin-access-identity/cloudfront/' . $identity_id . '/config';
|
1102 |
+
|
1103 |
+
return $this->authenticate('GET', $path, $opt, null, null);
|
1104 |
+
}
|
1105 |
+
|
1106 |
+
/**
|
1107 |
+
* Sets the configuration for an Amazon CloudFront origin access identity (OAI). Use this when updating
|
1108 |
+
* the configuration. Currently, only comments may be updated. Follow the same process as when updating
|
1109 |
+
* an identity's configuration as you do when updating a distribution's configuration. For more
|
1110 |
+
* information, go to Updating a Distribution's Configuration in the Amazon CloudFront Developer Guide.
|
1111 |
+
*
|
1112 |
+
* When attempting to change configuration items that are not allowed to be updated, Amazon CloudFront
|
1113 |
+
* returns an <code>IllegalUpdate</code> error.
|
1114 |
+
*
|
1115 |
+
* @param string $identity_id (Required) An Identity ID for an existing OAI.
|
1116 |
+
* @param string $xml (Required) The configuration XML generated by <generate_oai_xml()>.
|
1117 |
+
* @param string $etag (Required) The ETag header value retrieved from a call to <get_distribution_config()>.
|
1118 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1119 |
+
* <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>
|
1120 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1121 |
+
* @link http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/PutOAIConfig.html PUT Origin Access Identity Config
|
1122 |
+
*/
|
1123 |
+
public function set_oai_config($identity_id, $xml, $etag, $opt = null)
|
1124 |
+
{
|
1125 |
+
if (!$opt) $opt = array();
|
1126 |
+
|
1127 |
+
$path = '/origin-access-identity/cloudfront/' . $identity_id . '/config';
|
1128 |
+
|
1129 |
+
return $this->authenticate('PUT', $path, $opt, $xml, $etag);
|
1130 |
+
}
|
1131 |
+
|
1132 |
+
|
1133 |
+
/*%******************************************************************************************%*/
|
1134 |
+
// INVALIDATION
|
1135 |
+
|
1136 |
+
/**
|
1137 |
+
* Creates a new invalidation request.
|
1138 |
+
*
|
1139 |
+
* @param string $distribution_id (Required) The distribution ID returned from <create_distribution()> or <list_distributions()>.
|
1140 |
+
* @param string $caller_reference (Required) A unique identifier for the request. A timestamp-appended string is recommended.
|
1141 |
+
* @param string|array $paths (Required) One or more paths to set for invalidation. Pass a string for a single value, or an indexed array for multiple values. values.
|
1142 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1143 |
+
* <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>
|
1144 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1145 |
+
* @link http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/CreateInvalidation.html POST Invalidation
|
1146 |
+
*/
|
1147 |
+
public function create_invalidation($distribution_id, $caller_reference, $paths, $opt = null)
|
1148 |
+
{
|
1149 |
+
if (!$opt) $opt = array();
|
1150 |
+
$opt['Paths'] = $paths;
|
1151 |
+
|
1152 |
+
$path = '/distribution/' . $distribution_id . '/invalidation';
|
1153 |
+
$xml = $this->generate_invalidation_xml($caller_reference, $opt);
|
1154 |
+
|
1155 |
+
return $this->authenticate('POST', $path, $opt, $xml, null);
|
1156 |
+
}
|
1157 |
+
|
1158 |
+
/**
|
1159 |
+
* Gets a list of invalidations. By default, the list is returned as one result. If needed, paginate the
|
1160 |
+
* list by specifying values for the <code>MaxItems</code> and <code>Marker</code> parameters.
|
1161 |
+
*
|
1162 |
+
* @param string $distribution_id (Required) The distribution ID returned from <create_distribution()> or <list_distributions()>.
|
1163 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1164 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - Use this when paginating results to indicate where in the list of invalidations to begin. The results include invalidations in the list that occur after the marker. To get the next page of results, set the <code>Marker</code> parameter to the value of the <code>NextMarker</code> parameter from the current page's response, which is also the ID of the last invalidation on that page.</li>
|
1165 |
+
* <li><code>MaxItems</code> - <code>integer</code> - Optional - The maximum number of invalidations you want in the response body. A maximum value of 100 can be used.</li>
|
1166 |
+
* <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>
|
1167 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1168 |
+
* @link http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/ListInvalidation.html GET Invalidation List
|
1169 |
+
*/
|
1170 |
+
public function list_invalidations($distribution_id, $opt = null)
|
1171 |
+
{
|
1172 |
+
if (!$opt) $opt = array();
|
1173 |
+
$opt['query_string'] = array();
|
1174 |
+
|
1175 |
+
// Pass these to the query string
|
1176 |
+
foreach (array('Marker', 'MaxItems') as $option)
|
1177 |
+
{
|
1178 |
+
if (isset($opt[$option]))
|
1179 |
+
{
|
1180 |
+
$opt['query_string'][$option] = $opt[$option];
|
1181 |
+
}
|
1182 |
+
}
|
1183 |
+
|
1184 |
+
$path = '/distribution/' . $distribution_id . '/invalidation';
|
1185 |
+
|
1186 |
+
return $this->authenticate('GET', $path, $opt, null, null);
|
1187 |
+
}
|
1188 |
+
|
1189 |
+
/**
|
1190 |
+
* Gets information about an invalidation.
|
1191 |
+
*
|
1192 |
+
* @param string $distribution_id (Required) The distribution ID returned from <create_distribution()> or <list_distributions()>.
|
1193 |
+
* @param string $invalidation_id (Required) The invalidation ID returned from <create_invalidation()> or <list_invalidations()>.
|
1194 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1195 |
+
* <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>
|
1196 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1197 |
+
* @link http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/GetInvalidation.html GET Invalidation
|
1198 |
+
*/
|
1199 |
+
public function get_invalidation($distribution_id, $invalidation_id, $opt = null)
|
1200 |
+
{
|
1201 |
+
if (!$opt) $opt = array();
|
1202 |
+
|
1203 |
+
$path = '/distribution/' . $distribution_id . '/invalidation/' . $invalidation_id;
|
1204 |
+
|
1205 |
+
return $this->authenticate('GET', $path, $opt, null, null);
|
1206 |
+
}
|
1207 |
+
|
1208 |
+
|
1209 |
+
/*%******************************************************************************************%*/
|
1210 |
+
// CONVENIENCE METHODS
|
1211 |
+
|
1212 |
+
/**
|
1213 |
+
* Gets a simplified list of standard distribution IDs.
|
1214 |
+
*
|
1215 |
+
* @param string $pcre (Optional) A Perl-Compatible Regular Expression (PCRE) to filter the distribution caller references against.
|
1216 |
+
* @return array A list of standard distribution IDs.
|
1217 |
+
*/
|
1218 |
+
public function get_distribution_list($pcre = null)
|
1219 |
+
{
|
1220 |
+
if ($this->use_batch_flow)
|
1221 |
+
{
|
1222 |
+
throw new CloudFront_Exception(__FUNCTION__ . '() cannot be batch requested');
|
1223 |
+
}
|
1224 |
+
|
1225 |
+
$list = $this->list_distributions();
|
1226 |
+
if ($list = $list->body->Id())
|
1227 |
+
{
|
1228 |
+
$list = $list->map_string($pcre);
|
1229 |
+
return $list;
|
1230 |
+
}
|
1231 |
+
|
1232 |
+
return array();
|
1233 |
+
}
|
1234 |
+
|
1235 |
+
/**
|
1236 |
+
* Gets a simplified list of streaming distribution IDs.
|
1237 |
+
*
|
1238 |
+
* @param string $pcre (Optional) A Perl-Compatible Regular Expression (PCRE) to filter the distribution caller references against.
|
1239 |
+
* @return array A list of streaming distribution IDs.
|
1240 |
+
*/
|
1241 |
+
public function get_streaming_distribution_list($pcre = null)
|
1242 |
+
{
|
1243 |
+
if ($this->use_batch_flow)
|
1244 |
+
{
|
1245 |
+
throw new CloudFront_Exception(__FUNCTION__ . '() cannot be batch requested');
|
1246 |
+
}
|
1247 |
+
|
1248 |
+
$list = $this->list_distributions(array(
|
1249 |
+
'Streaming' => true
|
1250 |
+
));
|
1251 |
+
if ($list = $list->body->Id())
|
1252 |
+
{
|
1253 |
+
$list = $list->map_string($pcre);
|
1254 |
+
return $list;
|
1255 |
+
}
|
1256 |
+
|
1257 |
+
return array();
|
1258 |
+
}
|
1259 |
+
|
1260 |
+
/**
|
1261 |
+
* Gets a simplified list of origin access identity (OAI) IDs.
|
1262 |
+
*
|
1263 |
+
* @param string $pcre (Optional) A Perl-Compatible Regular Expression (PCRE) to filter the OAI caller references against.
|
1264 |
+
* @return array A list of OAI IDs.
|
1265 |
+
*/
|
1266 |
+
public function get_oai_list($pcre = null)
|
1267 |
+
{
|
1268 |
+
if ($this->use_batch_flow)
|
1269 |
+
{
|
1270 |
+
throw new CloudFront_Exception(__FUNCTION__ . '() cannot be batch requested');
|
1271 |
+
}
|
1272 |
+
|
1273 |
+
$list = $this->list_oais();
|
1274 |
+
if ($list = $list->body->Id())
|
1275 |
+
{
|
1276 |
+
$list = $list->map_string($pcre);
|
1277 |
+
return $list;
|
1278 |
+
}
|
1279 |
+
|
1280 |
+
return array();
|
1281 |
+
}
|
1282 |
+
|
1283 |
+
|
1284 |
+
/*%******************************************************************************************%*/
|
1285 |
+
// URLS
|
1286 |
+
|
1287 |
+
/**
|
1288 |
+
* Generates a time-limited and/or query signed request for a private file with additional optional
|
1289 |
+
* restrictions.
|
1290 |
+
*
|
1291 |
+
* @param string $distribution_hostname (Required) The hostname of the distribution. Obtained from <create_distribution()> or <get_distribution_info()>.
|
1292 |
+
* @param string $filename (Required) The file name of the object. Query parameters can be included. You can use multicharacter match wild cards () or a single-character match wild card (?) anywhere in the string.
|
1293 |
+
* @param integer|string $expires (Required) The expiration time expressed either as a number of seconds since UNIX Epoch, or any string that <php:strtotime()> can understand.
|
1294 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1295 |
+
* <li><code>BecomeAvailable</code> - <code>integer|string</code> - Optional - The time when the private URL becomes active. Can be expressed either as a number of seconds since UNIX Epoch, or any string that <code>strtotime()</code> can understand.</li>
|
1296 |
+
* <li><code>IPAddress</code> - <code>string</code> - Optional - A single IP address to restrict the access to.</li>
|
1297 |
+
* <li><code>Secure</code> - <code>boolean</code> - Optional - Whether or not to use HTTPS as the protocol scheme. A value of <code>true</code> uses <code>https</code>. A value of <code>false</code> uses <code>http</code>. The default value is <code>false</code>.</li></ul>
|
1298 |
+
* @return string The file URL with authentication parameters.
|
1299 |
+
* @link http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html Serving Private Content
|
1300 |
+
*/
|
1301 |
+
public function get_private_object_url($distribution_hostname, $filename, $expires, $opt = null)
|
1302 |
+
{
|
1303 |
+
if (!$this->key_pair_id || !$this->private_key)
|
1304 |
+
{
|
1305 |
+
throw new CloudFront_Exception('You must set both a Amazon CloudFront keypair ID and an RSA private key for that keypair before using ' . __FUNCTION__ . '()');
|
1306 |
+
}
|
1307 |
+
if (!function_exists('openssl_sign'))
|
1308 |
+
{
|
1309 |
+
throw new CloudFront_Exception(__FUNCTION__ . '() uses functions from the OpenSSL PHP Extension <http://php.net/openssl>, which is not installed in this PHP installation');
|
1310 |
+
}
|
1311 |
+
|
1312 |
+
if (!$opt) $opt = array();
|
1313 |
+
|
1314 |
+
$resource = '';
|
1315 |
+
$expiration_key = 'Expires';
|
1316 |
+
$expires = strtotime($expires);
|
1317 |
+
$conjunction = (strpos($filename, '?') === false ? '?' : '&');
|
1318 |
+
|
1319 |
+
// Determine the protocol scheme
|
1320 |
+
switch (substr($distribution_hostname, 0, 1) === 's')
|
1321 |
+
{
|
1322 |
+
// Streaming
|
1323 |
+
case 's':
|
1324 |
+
$scheme = 'rtmp';
|
1325 |
+
$resource = str_replace(array('%3F', '%3D', '%26', '%2F'), array('?', '=', '&', '/'), rawurlencode($filename));
|
1326 |
+
break;
|
1327 |
+
|
1328 |
+
// Default
|
1329 |
+
case 'd':
|
1330 |
+
default:
|
1331 |
+
$scheme = 'http';
|
1332 |
+
$scheme .= (isset($opt['Secure']) && $opt['Secure'] === true ? 's' : '');
|
1333 |
+
$resource = $scheme . '://' . $distribution_hostname . '/' . str_replace(array('%3F', '%3D', '%26', '%2F'), array('?', '=', '&', '/'), rawurlencode($filename));
|
1334 |
+
break;
|
1335 |
+
}
|
1336 |
+
|
1337 |
+
// Generate default policy
|
1338 |
+
$raw_policy = array(
|
1339 |
+
'Statement' => array(
|
1340 |
+
array(
|
1341 |
+
'Resource' => $resource,
|
1342 |
+
'Condition' => array(
|
1343 |
+
'DateLessThan' => array(
|
1344 |
+
'AWS:EpochTime' => $expires
|
1345 |
+
)
|
1346 |
+
)
|
1347 |
+
)
|
1348 |
+
)
|
1349 |
+
);
|
1350 |
+
|
1351 |
+
// Become Available
|
1352 |
+
if (isset($opt['BecomeAvailable']))
|
1353 |
+
{
|
1354 |
+
// Switch to 'Policy' instead
|
1355 |
+
$expiration_key = 'Policy';
|
1356 |
+
|
1357 |
+
// Update the policy
|
1358 |
+
$raw_policy['Statement'][0]['Condition']['DateGreaterThan'] = array(
|
1359 |
+
'AWS:EpochTime' => strtotime($opt['BecomeAvailable'])
|
1360 |
+
);
|
1361 |
+
}
|
1362 |
+
|
1363 |
+
// IP Address
|
1364 |
+
if (isset($opt['IPAddress']))
|
1365 |
+
{
|
1366 |
+
// Switch to 'Policy' instead
|
1367 |
+
$expiration_key = 'Policy';
|
1368 |
+
|
1369 |
+
// Update the policy
|
1370 |
+
$raw_policy['Statement'][0]['Condition']['IpAddress'] = array(
|
1371 |
+
'AWS:SourceIp' => $opt['IPAddress']
|
1372 |
+
);
|
1373 |
+
}
|
1374 |
+
|
1375 |
+
// Munge the policy
|
1376 |
+
$json_policy = str_replace('\/', '/', json_encode($raw_policy));
|
1377 |
+
$json_policy = $this->util->decode_uhex($json_policy);
|
1378 |
+
$encoded_policy = strtr(base64_encode($json_policy), '+=/', '-_~');
|
1379 |
+
|
1380 |
+
// Generate the signature
|
1381 |
+
openssl_sign($json_policy, $signature, $this->private_key);
|
1382 |
+
$signature = strtr(base64_encode($signature), '+=/', '-_~');
|
1383 |
+
|
1384 |
+
return $scheme . '://' . $distribution_hostname . '/'
|
1385 |
+
. str_replace(array('%3F', '%3D', '%26', '%2F'), array('?', '=', '&', '/'), rawurlencode($filename))
|
1386 |
+
. $conjunction
|
1387 |
+
. ($expiration_key === 'Expires' ? ($expiration_key . '=' . $expires) : ($expiration_key . '=' . $encoded_policy))
|
1388 |
+
. '&Key-Pair-Id=' . $this->key_pair_id
|
1389 |
+
. '&Signature=' . $signature;
|
1390 |
+
}
|
1391 |
+
}
|
app/libs/aws/services/cloudwatch.class.php
ADDED
@@ -0,0 +1,497 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
*
|
20 |
+
* Amazon CloudWatch is a web service that enables you to monitor and manage various metrics, as well as configure alarm
|
21 |
+
* actions based on data from metrics.
|
22 |
+
*
|
23 |
+
* Amazon CloudWatch monitoring enables you to collect, analyze, and view system and application metrics so that you can
|
24 |
+
* make operational and business decisions more quickly and with greater confidence. You can use Amazon CloudWatch to
|
25 |
+
* collect metrics about your AWS resources, such as the performance of your Amazon EC2 instances.
|
26 |
+
*
|
27 |
+
* If you are registered for an AWS product that supports Amazon CloudWatch, the service automatically pushes basic metrics
|
28 |
+
* to CloudWatch for you. Once Amazon CloudWatch contains metrics, you can calculate statistics based on that data.
|
29 |
+
*
|
30 |
+
* Amazon CloudWatch alarms help you implement decisions more easily by enabling you do things like send notifications or
|
31 |
+
* automatically make changes to the resources you are monitoring, based on rules that you define. For example, you can
|
32 |
+
* create alarms that initiate Auto Scaling and Simple Notification Service actions on your behalf.
|
33 |
+
*
|
34 |
+
* @version Wed Feb 16 17:04:07 PST 2011
|
35 |
+
* @license See the included NOTICE.md file for complete information.
|
36 |
+
* @copyright See the included NOTICE.md file for complete information.
|
37 |
+
* @link http://aws.amazon.com/cloudwatch/Amazon CloudWatch
|
38 |
+
* @link http://aws.amazon.com/documentation/cloudwatch/Amazon CloudWatch documentation
|
39 |
+
*/
|
40 |
+
class AmazonCloudWatch extends CFRuntime
|
41 |
+
{
|
42 |
+
|
43 |
+
/*%******************************************************************************************%*/
|
44 |
+
// CLASS CONSTANTS
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Specify the default queue URL.
|
48 |
+
*/
|
49 |
+
const DEFAULT_URL = 'monitoring.amazonaws.com';
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Specify the queue URL for the US-East (Northern Virginia) Region.
|
53 |
+
*/
|
54 |
+
const REGION_US_E1 = 'us-east-1';
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Specify the queue URL for the US-West (Northern California) Region.
|
58 |
+
*/
|
59 |
+
const REGION_US_W1 = 'us-west-1';
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Specify the queue URL for the EU (Ireland) Region.
|
63 |
+
*/
|
64 |
+
const REGION_EU_W1 = 'eu-west-1';
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Specify the queue URL for the Asia Pacific (Singapore) Region.
|
68 |
+
*/
|
69 |
+
const REGION_APAC_SE1 = 'ap-southeast-1';
|
70 |
+
|
71 |
+
|
72 |
+
/*%******************************************************************************************%*/
|
73 |
+
// SETTERS
|
74 |
+
|
75 |
+
/**
|
76 |
+
* This allows you to explicitly sets the region for the service to use.
|
77 |
+
*
|
78 |
+
* @param string $region (Required) The region to explicitly set. Available options are <REGION_US_E1>, <REGION_US_W1>, <REGION_EU_W1>, or <REGION_APAC_SE1>.
|
79 |
+
* @return $this A reference to the current instance.
|
80 |
+
*/
|
81 |
+
public function set_region($region)
|
82 |
+
{
|
83 |
+
$this->set_hostname('http://monitoring.'. $region .'.amazonaws.com');
|
84 |
+
return $this;
|
85 |
+
}
|
86 |
+
|
87 |
+
|
88 |
+
/*%******************************************************************************************%*/
|
89 |
+
// CONSTRUCTOR
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Constructs a new instance of <AmazonCloudWatch>.
|
93 |
+
*
|
94 |
+
* @param string $key (Optional) Your Amazon API Key. If blank, it will look for the <code>AWS_KEY</code> constant.
|
95 |
+
* @param string $secret_key (Optional) Your Amazon API Secret Key. If blank, it will look for the <code>AWS_SECRET_KEY</code> constant.
|
96 |
+
* @return boolean false if no valid values are set, otherwise true.
|
97 |
+
*/
|
98 |
+
public function __construct($key = null, $secret_key = null)
|
99 |
+
{
|
100 |
+
$this->api_version = '2010-08-01';
|
101 |
+
$this->hostname = self::DEFAULT_URL;
|
102 |
+
|
103 |
+
if (!$key && !defined('AWS_KEY'))
|
104 |
+
{
|
105 |
+
throw new CW_Exception('No account key was passed into the constructor, nor was it set in the AWS_KEY constant.');
|
106 |
+
}
|
107 |
+
|
108 |
+
if (!$secret_key && !defined('AWS_SECRET_KEY'))
|
109 |
+
{
|
110 |
+
throw new CW_Exception('No account secret was passed into the constructor, nor was it set in the AWS_SECRET_KEY constant.');
|
111 |
+
}
|
112 |
+
|
113 |
+
return parent::__construct($key, $secret_key);
|
114 |
+
}
|
115 |
+
|
116 |
+
|
117 |
+
/*%******************************************************************************************%*/
|
118 |
+
// SERVICE METHODS
|
119 |
+
|
120 |
+
/**
|
121 |
+
*
|
122 |
+
* Creates or updates an alarm and associates it with the specified Amazon CloudWatch metric. Optionally, this operation
|
123 |
+
* can associate one or more Amazon Simple Notification Service resources with the alarm.
|
124 |
+
*
|
125 |
+
* When this operation creates an alarm, the alarm state is immediately set to <code>UNKNOWN</code>. The alarm is
|
126 |
+
* evaluated and its <code>StateValue</code> is set appropriately. Any actions associated with the <code>StateValue</code>
|
127 |
+
* is then executed.
|
128 |
+
*
|
129 |
+
* When updating an existing alarm, its <code>StateValue</code> is left unchanged.
|
130 |
+
*
|
131 |
+
* @param string $alarm_name (Required) The descriptive name for the alarm. This name must be unique within the user's AWS account
|
132 |
+
* @param string $metric_name (Required) The name for the alarm's associated metric.
|
133 |
+
* @param string $namespace (Required) The namespace for the alarm's associated metric.
|
134 |
+
* @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>]
|
135 |
+
* @param integer $period (Required) The period in seconds over which the specified statistic is applied.
|
136 |
+
* @param integer $evaluation_periods (Required) The number of periods over which data is compared to the specified threshold.
|
137 |
+
* @param double $threshold (Required) The value against which the specified statistic is compared.
|
138 |
+
* @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>]
|
139 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
140 |
+
* <li><code>AlarmDescription</code> - <code>string</code> - Optional - The description for the alarm. </li>
|
141 |
+
* <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>
|
142 |
+
* <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>
|
143 |
+
* <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>
|
144 |
+
* <li><code>InsufficientDataActions</code> - <code>string|array</code> - Optional - The list of actions to execute when this alarm transitions into an <code>UNKNOWN</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>
|
145 |
+
* <li><code>Dimensions</code> - <code>array</code> - Optional - The dimensions for the alarm's associated metric. <ul>
|
146 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
147 |
+
* <li><code>Name</code> - <code>string</code> - Required - The name of the dimension. </li>
|
148 |
+
* <li><code>Value</code> - <code>string</code> - Required - The value representing the dimension measurement </li>
|
149 |
+
* </ul></li>
|
150 |
+
* </ul></li>
|
151 |
+
* <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>
|
152 |
+
* <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>
|
153 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
154 |
+
*/
|
155 |
+
public function put_metric_alarm($alarm_name, $metric_name, $namespace, $statistic, $period, $evaluation_periods, $threshold, $comparison_operator, $opt = null)
|
156 |
+
{
|
157 |
+
if (!$opt) $opt = array();
|
158 |
+
$opt['AlarmName'] = $alarm_name;
|
159 |
+
|
160 |
+
// Optional parameter
|
161 |
+
if (isset($opt['OKActions']))
|
162 |
+
{
|
163 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
164 |
+
'OKActions' => (is_array($opt['OKActions']) ? $opt['OKActions'] : array($opt['OKActions']))
|
165 |
+
), 'member'));
|
166 |
+
unset($opt['OKActions']);
|
167 |
+
}
|
168 |
+
|
169 |
+
// Optional parameter
|
170 |
+
if (isset($opt['AlarmActions']))
|
171 |
+
{
|
172 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
173 |
+
'AlarmActions' => (is_array($opt['AlarmActions']) ? $opt['AlarmActions'] : array($opt['AlarmActions']))
|
174 |
+
), 'member'));
|
175 |
+
unset($opt['AlarmActions']);
|
176 |
+
}
|
177 |
+
|
178 |
+
// Optional parameter
|
179 |
+
if (isset($opt['InsufficientDataActions']))
|
180 |
+
{
|
181 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
182 |
+
'InsufficientDataActions' => (is_array($opt['InsufficientDataActions']) ? $opt['InsufficientDataActions'] : array($opt['InsufficientDataActions']))
|
183 |
+
), 'member'));
|
184 |
+
unset($opt['InsufficientDataActions']);
|
185 |
+
}
|
186 |
+
$opt['MetricName'] = $metric_name;
|
187 |
+
$opt['Namespace'] = $namespace;
|
188 |
+
$opt['Statistic'] = $statistic;
|
189 |
+
|
190 |
+
// Optional parameter
|
191 |
+
if (isset($opt['Dimensions']))
|
192 |
+
{
|
193 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
194 |
+
'Dimensions' => $opt['Dimensions']
|
195 |
+
), 'member'));
|
196 |
+
unset($opt['Dimensions']);
|
197 |
+
}
|
198 |
+
$opt['Period'] = $period;
|
199 |
+
$opt['EvaluationPeriods'] = $evaluation_periods;
|
200 |
+
$opt['Threshold'] = $threshold;
|
201 |
+
$opt['ComparisonOperator'] = $comparison_operator;
|
202 |
+
|
203 |
+
return $this->authenticate('PutMetricAlarm', $opt, $this->hostname);
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
*
|
208 |
+
* Returns a list of valid metrics stored for the AWS account owner. Returned metrics can be used with
|
209 |
+
* <code>GetMetricStatistics</code> to obtain statistical data for a given metric.
|
210 |
+
*
|
211 |
+
* Up to 500 results are returned for any one call. To retrieve further results, use returned <code>NextToken</code>
|
212 |
+
* values with subsequent <code>ListMetrics</code> operations.
|
213 |
+
*
|
214 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
215 |
+
* <li><code>Namespace</code> - <code>string</code> - Optional - The namespace to filter against. </li>
|
216 |
+
* <li><code>MetricName</code> - <code>string</code> - Optional - The name of the metric to filter against. </li>
|
217 |
+
* <li><code>Dimensions</code> - <code>array</code> - Optional - A list of dimensions to filter against. <ul>
|
218 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
219 |
+
* <li><code>Name</code> - <code>string</code> - Required - The dimension name to be matched. </li>
|
220 |
+
* <li><code>Value</code> - <code>string</code> - Optional - The value of the dimension to be matched. Specifying a <code>Name</code> without specifying a <code>Value</code> is equivalent to "wildcarding" the <code>Name</code> for all values. </li>
|
221 |
+
* </ul></li>
|
222 |
+
* </ul></li>
|
223 |
+
* <li><code>NextToken</code> - <code>string</code> - Optional - The token returned by a previous call to indicate that there is more data available. </li>
|
224 |
+
* <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>
|
225 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
226 |
+
*/
|
227 |
+
public function list_metrics($opt = null)
|
228 |
+
{
|
229 |
+
if (!$opt) $opt = array();
|
230 |
+
|
231 |
+
// Optional parameter
|
232 |
+
if (isset($opt['Dimensions']))
|
233 |
+
{
|
234 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
235 |
+
'Dimensions' => $opt['Dimensions']
|
236 |
+
), 'member'));
|
237 |
+
unset($opt['Dimensions']);
|
238 |
+
}
|
239 |
+
|
240 |
+
return $this->authenticate('ListMetrics', $opt, $this->hostname);
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
*
|
245 |
+
* Gets statistics for the specified metric.
|
246 |
+
*
|
247 |
+
* The maximum number of datapoints returned from a single <code>GetMetricStatistics</code> request is 1,440. If a request
|
248 |
+
* is made that generates more than 1,440 datapoints, Amazon CloudWatch returns an error. In such a case, alter the request
|
249 |
+
* by narrowing the specified time range or increasing the specified period. Alternatively, make multiple requests across
|
250 |
+
* adjacent time ranges.
|
251 |
+
*
|
252 |
+
* @param string $namespace (Required) The namespace of the metric.
|
253 |
+
* @param string $metric_name (Required) The name of the metric.
|
254 |
+
* @param string $start_time (Required) The timestamp to use for determining the first datapoint to return. The value specified is inclusive; results include datapoints with the timestamp specified. 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. Accepts any value that <php:strtotime()> understands.
|
255 |
+
* @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. Accepts any value that <php:strtotime()> understands.
|
256 |
+
* @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.
|
257 |
+
* @param string|array $statistics (Required) The metric statistics to return. Pass a string for a single value, or an indexed array for multiple values.
|
258 |
+
* @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>]
|
259 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
260 |
+
* <li><code>Dimensions</code> - <code>array</code> - Optional - A list of dimensions describing qualities of the metric. <ul>
|
261 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
262 |
+
* <li><code>Name</code> - <code>string</code> - Required - The name of the dimension. </li>
|
263 |
+
* <li><code>Value</code> - <code>string</code> - Required - The value representing the dimension measurement </li>
|
264 |
+
* </ul></li>
|
265 |
+
* </ul></li>
|
266 |
+
* <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>
|
267 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
268 |
+
*/
|
269 |
+
public function get_metric_statistics($namespace, $metric_name, $start_time, $end_time, $period, $statistics, $unit, $opt = null)
|
270 |
+
{
|
271 |
+
if (!$opt) $opt = array();
|
272 |
+
$opt['Namespace'] = $namespace;
|
273 |
+
$opt['MetricName'] = $metric_name;
|
274 |
+
|
275 |
+
// Optional parameter
|
276 |
+
if (isset($opt['Dimensions']))
|
277 |
+
{
|
278 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
279 |
+
'Dimensions' => $opt['Dimensions']
|
280 |
+
), 'member'));
|
281 |
+
unset($opt['Dimensions']);
|
282 |
+
}
|
283 |
+
$opt['StartTime'] = $this->util->convert_date_to_iso8601($start_time);
|
284 |
+
$opt['EndTime'] = $this->util->convert_date_to_iso8601($end_time);
|
285 |
+
$opt['Period'] = $period;
|
286 |
+
|
287 |
+
// Required parameter
|
288 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
289 |
+
'Statistics' => (is_array($statistics) ? $statistics : array($statistics))
|
290 |
+
), 'member'));
|
291 |
+
$opt['Unit'] = $unit;
|
292 |
+
|
293 |
+
return $this->authenticate('GetMetricStatistics', $opt, $this->hostname);
|
294 |
+
}
|
295 |
+
|
296 |
+
/**
|
297 |
+
*
|
298 |
+
* Disables actions for the specified alarms. When an alarm's actions are disabled the alarm's state may change, but none
|
299 |
+
* of the alarm's actions will execute.
|
300 |
+
*
|
301 |
+
* @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.
|
302 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
303 |
+
* <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>
|
304 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
305 |
+
*/
|
306 |
+
public function disable_alarm_actions($alarm_names, $opt = null)
|
307 |
+
{
|
308 |
+
if (!$opt) $opt = array();
|
309 |
+
|
310 |
+
// Required parameter
|
311 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
312 |
+
'AlarmNames' => (is_array($alarm_names) ? $alarm_names : array($alarm_names))
|
313 |
+
), 'member'));
|
314 |
+
|
315 |
+
return $this->authenticate('DisableAlarmActions', $opt, $this->hostname);
|
316 |
+
}
|
317 |
+
|
318 |
+
/**
|
319 |
+
*
|
320 |
+
* Retrieves alarms with the specified names. If no name is specified, all alarms for the user are returned. Alarms can be
|
321 |
+
* retrieved by using only a prefix for the alarm name, the alarm state, or a prefix for any action.
|
322 |
+
*
|
323 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
324 |
+
* <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>
|
325 |
+
* <li><code>AlarmNamePrefix</code> - <code>string</code> - Optional - The alarm name prefix. <code>AlarmNames</code> cannot be specified if this parameter is specified. </li>
|
326 |
+
* <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>
|
327 |
+
* <li><code>ActionPrefix</code> - <code>string</code> - Optional - The action name prefix. </li>
|
328 |
+
* <li><code>MaxRecords</code> - <code>integer</code> - Optional - The maximum number of alarm descriptions to retrieve. </li>
|
329 |
+
* <li><code>NextToken</code> - <code>string</code> - Optional - The token returned by a previous call to indicate that there is more data available. </li>
|
330 |
+
* <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>
|
331 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
332 |
+
*/
|
333 |
+
public function describe_alarms($opt = null)
|
334 |
+
{
|
335 |
+
if (!$opt) $opt = array();
|
336 |
+
|
337 |
+
// Optional parameter
|
338 |
+
if (isset($opt['AlarmNames']))
|
339 |
+
{
|
340 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
341 |
+
'AlarmNames' => (is_array($opt['AlarmNames']) ? $opt['AlarmNames'] : array($opt['AlarmNames']))
|
342 |
+
), 'member'));
|
343 |
+
unset($opt['AlarmNames']);
|
344 |
+
}
|
345 |
+
|
346 |
+
return $this->authenticate('DescribeAlarms', $opt, $this->hostname);
|
347 |
+
}
|
348 |
+
|
349 |
+
/**
|
350 |
+
*
|
351 |
+
* Retrieves all alarms for a single metric. Specify a statistic, period, or unit to filter the set of alarms further.
|
352 |
+
*
|
353 |
+
* @param string $metric_name (Required) The name of the metric.
|
354 |
+
* @param string $namespace (Required) The namespace of the metric.
|
355 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
356 |
+
* <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>
|
357 |
+
* <li><code>Dimensions</code> - <code>array</code> - Optional - The list of dimensions associated with the metric. <ul>
|
358 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
359 |
+
* <li><code>Name</code> - <code>string</code> - Required - The name of the dimension. </li>
|
360 |
+
* <li><code>Value</code> - <code>string</code> - Required - The value representing the dimension measurement </li>
|
361 |
+
* </ul></li>
|
362 |
+
* </ul></li>
|
363 |
+
* <li><code>Period</code> - <code>integer</code> - Optional - The period in seconds over which the statistic is applied. </li>
|
364 |
+
* <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>
|
365 |
+
* <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>
|
366 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
367 |
+
*/
|
368 |
+
public function describe_alarms_for_metric($metric_name, $namespace, $opt = null)
|
369 |
+
{
|
370 |
+
if (!$opt) $opt = array();
|
371 |
+
$opt['MetricName'] = $metric_name;
|
372 |
+
$opt['Namespace'] = $namespace;
|
373 |
+
|
374 |
+
// Optional parameter
|
375 |
+
if (isset($opt['Dimensions']))
|
376 |
+
{
|
377 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
378 |
+
'Dimensions' => $opt['Dimensions']
|
379 |
+
), 'member'));
|
380 |
+
unset($opt['Dimensions']);
|
381 |
+
}
|
382 |
+
|
383 |
+
return $this->authenticate('DescribeAlarmsForMetric', $opt, $this->hostname);
|
384 |
+
}
|
385 |
+
|
386 |
+
/**
|
387 |
+
*
|
388 |
+
* Retrieves history for the specified alarm. Filter alarms by date range or item type. If an alarm name is not specified,
|
389 |
+
* Amazon CloudWatch returns histories for all of the owner's alarms.
|
390 |
+
*
|
391 |
+
* Amazon CloudWatch retains the history of deleted alarms for a period of six weeks. If an alarm has been deleted, its
|
392 |
+
* history can still be queried.
|
393 |
+
*
|
394 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
395 |
+
* <li><code>AlarmName</code> - <code>string</code> - Optional - The name of the alarm. </li>
|
396 |
+
* <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>
|
397 |
+
* <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>
|
398 |
+
* <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>
|
399 |
+
* <li><code>MaxRecords</code> - <code>integer</code> - Optional - The maximum number of alarm history records to retrieve. </li>
|
400 |
+
* <li><code>NextToken</code> - <code>string</code> - Optional - The token returned by a previous call to indicate that there is more data available. </li>
|
401 |
+
* <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>
|
402 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
403 |
+
*/
|
404 |
+
public function describe_alarm_history($opt = null)
|
405 |
+
{
|
406 |
+
if (!$opt) $opt = array();
|
407 |
+
|
408 |
+
// Optional parameter
|
409 |
+
if (isset($opt['StartDate']))
|
410 |
+
{
|
411 |
+
$opt['StartDate'] = $this->util->convert_date_to_iso8601($opt['StartDate']);
|
412 |
+
}
|
413 |
+
|
414 |
+
// Optional parameter
|
415 |
+
if (isset($opt['EndDate']))
|
416 |
+
{
|
417 |
+
$opt['EndDate'] = $this->util->convert_date_to_iso8601($opt['EndDate']);
|
418 |
+
}
|
419 |
+
|
420 |
+
return $this->authenticate('DescribeAlarmHistory', $opt, $this->hostname);
|
421 |
+
}
|
422 |
+
|
423 |
+
/**
|
424 |
+
*
|
425 |
+
* Enables actions for the specified alarms.
|
426 |
+
*
|
427 |
+
* @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.
|
428 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
429 |
+
* <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>
|
430 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
431 |
+
*/
|
432 |
+
public function enable_alarm_actions($alarm_names, $opt = null)
|
433 |
+
{
|
434 |
+
if (!$opt) $opt = array();
|
435 |
+
|
436 |
+
// Required parameter
|
437 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
438 |
+
'AlarmNames' => (is_array($alarm_names) ? $alarm_names : array($alarm_names))
|
439 |
+
), 'member'));
|
440 |
+
|
441 |
+
return $this->authenticate('EnableAlarmActions', $opt, $this->hostname);
|
442 |
+
}
|
443 |
+
|
444 |
+
/**
|
445 |
+
*
|
446 |
+
* Deletes all specified alarms. In the event of an error, no alarms are deleted.
|
447 |
+
*
|
448 |
+
* @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.
|
449 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
450 |
+
* <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>
|
451 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
452 |
+
*/
|
453 |
+
public function delete_alarms($alarm_names, $opt = null)
|
454 |
+
{
|
455 |
+
if (!$opt) $opt = array();
|
456 |
+
|
457 |
+
// Required parameter
|
458 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
459 |
+
'AlarmNames' => (is_array($alarm_names) ? $alarm_names : array($alarm_names))
|
460 |
+
), 'member'));
|
461 |
+
|
462 |
+
return $this->authenticate('DeleteAlarms', $opt, $this->hostname);
|
463 |
+
}
|
464 |
+
|
465 |
+
/**
|
466 |
+
*
|
467 |
+
* Temporarily sets the state of an alarm. When the updated <code>StateValue</code> differs from the previous value, the
|
468 |
+
* action configured for the appropriate state is invoked. This is not a permanent change. The next periodic alarm check
|
469 |
+
* (in about a minute) will set the alarm to its actual state.
|
470 |
+
*
|
471 |
+
* @param string $alarm_name (Required) The descriptive name for the alarm. This name must be unique within the user's AWS account
|
472 |
+
* @param string $state_value (Required) The value of the state. [Allowed values: <code>OK</code>, <code>ALARM</code>, <code>INSUFFICIENT_DATA</code>]
|
473 |
+
* @param string $state_reason (Required) The reason that this alarm is set to this specific state (in human-readable text format)
|
474 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
475 |
+
* <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>
|
476 |
+
* <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>
|
477 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
478 |
+
*/
|
479 |
+
public function set_alarm_state($alarm_name, $state_value, $state_reason, $opt = null)
|
480 |
+
{
|
481 |
+
if (!$opt) $opt = array();
|
482 |
+
$opt['AlarmName'] = $alarm_name;
|
483 |
+
$opt['StateValue'] = $state_value;
|
484 |
+
$opt['StateReason'] = $state_reason;
|
485 |
+
|
486 |
+
return $this->authenticate('SetAlarmState', $opt, $this->hostname);
|
487 |
+
}
|
488 |
+
}
|
489 |
+
|
490 |
+
|
491 |
+
/*%******************************************************************************************%*/
|
492 |
+
// EXCEPTIONS
|
493 |
+
|
494 |
+
/**
|
495 |
+
* Default CloudWatch Exception.
|
496 |
+
*/
|
497 |
+
class CloudWatch_Exception extends Exception {}
|
app/libs/aws/services/ec2.class.php
ADDED
@@ -0,0 +1,3108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides resizable compute capacity in the cloud. It is
|
20 |
+
* designed to make web-scale computing easier for developers.
|
21 |
+
*
|
22 |
+
* Amazon EC2's simple web service interface allows you to obtain and configure capacity with minimal friction. It
|
23 |
+
* provides you with complete control of your computing resources and lets you run on Amazon's proven computing
|
24 |
+
* environment. Amazon EC2 reduces the time required to obtain and boot new server instances to minutes, allowing you to
|
25 |
+
* quickly scale capacity, both up and down, as your computing requirements change. Amazon EC2 changes the economics of
|
26 |
+
* computing by allowing you to pay only for capacity that you actually use. Amazon EC2 provides developers the tools to
|
27 |
+
* build failure resilient applications and isolate themselves from common failure scenarios.
|
28 |
+
*
|
29 |
+
* Visit <a href="http://aws.amazon.com/ec2/">http://aws.amazon.com/ec2/</a> for more information.
|
30 |
+
*
|
31 |
+
* @version Wed Feb 16 17:05:26 PST 2011
|
32 |
+
* @license See the included NOTICE.md file for complete information.
|
33 |
+
* @copyright See the included NOTICE.md file for complete information.
|
34 |
+
* @link http://aws.amazon.com/ec2/Amazon Elastic Compute Cloud
|
35 |
+
* @link http://aws.amazon.com/documentation/ec2/Amazon Elastic Compute Cloud documentation
|
36 |
+
*/
|
37 |
+
class AmazonEC2 extends CFRuntime
|
38 |
+
{
|
39 |
+
|
40 |
+
/*%******************************************************************************************%*/
|
41 |
+
// CLASS CONSTANTS
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Specify the default queue URL.
|
45 |
+
*/
|
46 |
+
const DEFAULT_URL = 'ec2.amazonaws.com';
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Specify the queue URL for the US-East (Northern Virginia) Region.
|
50 |
+
*/
|
51 |
+
const REGION_US_E1 = 'us-east-1';
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Specify the queue URL for the US-West (Northern California) Region.
|
55 |
+
*/
|
56 |
+
const REGION_US_W1 = 'us-west-1';
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Specify the queue URL for the EU (Ireland) Region.
|
60 |
+
*/
|
61 |
+
const REGION_EU_W1 = 'eu-west-1';
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Specify the queue URL for the Asia Pacific (Singapore) Region.
|
65 |
+
*/
|
66 |
+
const REGION_APAC_SE1 = 'ap-southeast-1';
|
67 |
+
|
68 |
+
/**
|
69 |
+
* The "pending" state code of an EC2 instance. Useful for conditionals.
|
70 |
+
*/
|
71 |
+
const STATE_PENDING = 0;
|
72 |
+
|
73 |
+
/**
|
74 |
+
* The "running" state code of an EC2 instance. Useful for conditionals.
|
75 |
+
*/
|
76 |
+
const STATE_RUNNING = 16;
|
77 |
+
|
78 |
+
/**
|
79 |
+
* The "shutting-down" state code of an EC2 instance. Useful for conditionals.
|
80 |
+
*/
|
81 |
+
const STATE_SHUTTING_DOWN = 32;
|
82 |
+
|
83 |
+
/**
|
84 |
+
* The "terminated" state code of an EC2 instance. Useful for conditionals.
|
85 |
+
*/
|
86 |
+
const STATE_TERMINATED = 48;
|
87 |
+
|
88 |
+
/**
|
89 |
+
* The "stopping" state code of an EC2 instance. Useful for conditionals.
|
90 |
+
*/
|
91 |
+
const STATE_STOPPING = 64;
|
92 |
+
|
93 |
+
/**
|
94 |
+
* The "stopped" state code of an EC2 instance. Useful for conditionals.
|
95 |
+
*/
|
96 |
+
const STATE_STOPPED = 80;
|
97 |
+
|
98 |
+
|
99 |
+
/*%******************************************************************************************%*/
|
100 |
+
// SETTERS
|
101 |
+
|
102 |
+
/**
|
103 |
+
* This allows you to explicitly sets the region for the service to use.
|
104 |
+
*
|
105 |
+
* @param string $region (Required) The region to explicitly set. Available options are <REGION_US_E1>, <REGION_US_W1>, <REGION_EU_W1>, or <REGION_APAC_SE1>.
|
106 |
+
* @return $this A reference to the current instance.
|
107 |
+
*/
|
108 |
+
public function set_region($region)
|
109 |
+
{
|
110 |
+
$this->set_hostname('http://ec2.'. $region .'.amazonaws.com');
|
111 |
+
return $this;
|
112 |
+
}
|
113 |
+
|
114 |
+
|
115 |
+
/*%******************************************************************************************%*/
|
116 |
+
// CONSTRUCTOR
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Constructs a new instance of <AmazonEC2>.
|
120 |
+
*
|
121 |
+
* @param string $key (Optional) Your Amazon API Key. If blank, it will look for the <code>AWS_KEY</code> constant.
|
122 |
+
* @param string $secret_key (Optional) Your Amazon API Secret Key. If blank, it will look for the <code>AWS_SECRET_KEY</code> constant.
|
123 |
+
* @return boolean false if no valid values are set, otherwise true.
|
124 |
+
*/
|
125 |
+
public function __construct($key = null, $secret_key = null)
|
126 |
+
{
|
127 |
+
$this->api_version = '2010-08-31';
|
128 |
+
$this->hostname = self::DEFAULT_URL;
|
129 |
+
|
130 |
+
if (!$key && !defined('AWS_KEY'))
|
131 |
+
{
|
132 |
+
throw new EC2_Exception('No account key was passed into the constructor, nor was it set in the AWS_KEY constant.');
|
133 |
+
}
|
134 |
+
|
135 |
+
if (!$secret_key && !defined('AWS_SECRET_KEY'))
|
136 |
+
{
|
137 |
+
throw new EC2_Exception('No account secret was passed into the constructor, nor was it set in the AWS_SECRET_KEY constant.');
|
138 |
+
}
|
139 |
+
|
140 |
+
return parent::__construct($key, $secret_key);
|
141 |
+
}
|
142 |
+
|
143 |
+
|
144 |
+
/*%******************************************************************************************%*/
|
145 |
+
// SERVICE METHODS
|
146 |
+
|
147 |
+
/**
|
148 |
+
*
|
149 |
+
* The RebootInstances operation requests a reboot of one or more instances. This operation is asynchronous; it only
|
150 |
+
* queues a request to reboot the specified instance(s). The operation will succeed if the instances are valid and belong
|
151 |
+
* to the user. Requests to reboot terminated instances are ignored.
|
152 |
+
*
|
153 |
+
* @param string|array $instance_id (Required) The list of instances to terminate. Pass a string for a single value, or an indexed array for multiple values.
|
154 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
155 |
+
* <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>
|
156 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
157 |
+
*/
|
158 |
+
public function reboot_instances($instance_id, $opt = null)
|
159 |
+
{
|
160 |
+
if (!$opt) $opt = array();
|
161 |
+
|
162 |
+
// Required parameter
|
163 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
164 |
+
'InstanceId' => (is_array($instance_id) ? $instance_id : array($instance_id))
|
165 |
+
)));
|
166 |
+
|
167 |
+
return $this->authenticate('RebootInstances', $opt, $this->hostname);
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
*
|
172 |
+
* Returns information about one or more PlacementGroup instances in a user's account.
|
173 |
+
*
|
174 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
175 |
+
* <li><code>GroupName</code> - <code>string|array</code> - Optional - The name of the <code>PlacementGroup</code>. Pass a string for a single value, or an indexed array for multiple values. </li>
|
176 |
+
* <li><code>Filter</code> - <code>array</code> - Optional - <ul>
|
177 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
178 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Specifies the name of the filter. </li>
|
179 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
180 |
+
* </ul></li>
|
181 |
+
* </ul></li>
|
182 |
+
* <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>
|
183 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
184 |
+
*/
|
185 |
+
public function describe_placement_groups($opt = null)
|
186 |
+
{
|
187 |
+
if (!$opt) $opt = array();
|
188 |
+
|
189 |
+
// Optional parameter
|
190 |
+
if (isset($opt['GroupName']))
|
191 |
+
{
|
192 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
193 |
+
'GroupName' => (is_array($opt['GroupName']) ? $opt['GroupName'] : array($opt['GroupName']))
|
194 |
+
)));
|
195 |
+
unset($opt['GroupName']);
|
196 |
+
}
|
197 |
+
|
198 |
+
// Optional parameter
|
199 |
+
if (isset($opt['Filter']))
|
200 |
+
{
|
201 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
202 |
+
'Filter' => $opt['Filter']
|
203 |
+
)));
|
204 |
+
unset($opt['Filter']);
|
205 |
+
}
|
206 |
+
|
207 |
+
return $this->authenticate('DescribePlacementGroups', $opt, $this->hostname);
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
*
|
212 |
+
* The RunInstances operation launches a specified number of instances.
|
213 |
+
*
|
214 |
+
* If Amazon EC2 cannot launch the minimum number AMIs you request, no instances launch. If there is insufficient capacity
|
215 |
+
* to launch the maximum number of AMIs you request, Amazon EC2 launches as many as possible to satisfy the requested
|
216 |
+
* maximum values.
|
217 |
+
*
|
218 |
+
* Every instance is launched in a security group. If you do not specify a security group at launch, the instances start
|
219 |
+
* in your default security group. For more information on creating security groups, see CreateSecurityGroup.
|
220 |
+
*
|
221 |
+
* An optional instance type can be specified. For information about instance types, see Instance Types.
|
222 |
+
*
|
223 |
+
* You can provide an optional key pair ID for each image in the launch request (for more information, see CreateKeyPair).
|
224 |
+
* All instances that are created from images that use this key pair will have access to the associated public key at boot.
|
225 |
+
* You can use this key to provide secure access to an instance of an image on a per-instance basis. Amazon EC2 public
|
226 |
+
* images use this feature to provide secure access without passwords.
|
227 |
+
*
|
228 |
+
* Launching public images without a key pair ID will leave them inaccessible.
|
229 |
+
*
|
230 |
+
* The public key material is made available to the instance at boot time by placing it in the openssh_id.pub file on a
|
231 |
+
* logical device that is exposed to the instance as /dev/sda2 (the ephemeral store). The format of this file is suitable
|
232 |
+
* for use as an entry within ~/.ssh/authorized_keys (the OpenSSH format). This can be done at boot (e.g., as part of
|
233 |
+
* rc.local) allowing for secure access without passwords.
|
234 |
+
*
|
235 |
+
* Optional user data can be provided in the launch request. All instances that collectively comprise the launch request
|
236 |
+
* have access to this data For more information, see Instance Metadata.
|
237 |
+
*
|
238 |
+
*
|
239 |
+
* If any of the AMIs have a product code attached for which the user has not subscribed, the RunInstances call will fail.
|
240 |
+
*
|
241 |
+
* We strongly recommend using the 2.6.18 Xen stock kernel with the c1.medium and c1.xlarge instances. Although the
|
242 |
+
* default Amazon EC2 kernels will work, the new kernels provide greater stability and performance for these instance
|
243 |
+
* types. For more information about kernels, see Kernels, RAM Disks, and Block Device Mappings.
|
244 |
+
*
|
245 |
+
* @param string $image_id (Required) Unique ID of a machine image, returned by a call to DescribeImages.
|
246 |
+
* @param integer $min_count (Required) Minimum number of instances to launch. If the value is more than Amazon EC2 can launch, no instances are launched at all.
|
247 |
+
* @param integer $max_count (Required) Maximum number of instances to launch. If the value is more than Amazon EC2 can launch, the largest possible number above minCount will be launched instead. Between 1 and the maximum number allowed for your account (default: 20).
|
248 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
249 |
+
* <li><code>KeyName</code> - <code>string</code> - Optional - The name of the key pair. </li>
|
250 |
+
* <li><code>SecurityGroup</code> - <code>string|array</code> - Optional - The names of the security groups into which the instances will be launched. Pass a string for a single value, or an indexed array for multiple values. </li>
|
251 |
+
* <li><code>UserData</code> - <code>string</code> - Optional - Specifies additional information to make available to the instance(s). </li>
|
252 |
+
* <li><code>InstanceType</code> - <code>string</code> - Optional - Specifies the instance type for the launched instances. [Allowed values: <code>t1.micro</code>, <code>m1.small</code>, <code>m1.large</code>, <code>m1.xlarge</code>, <code>m2.xlarge</code>, <code>m2.2xlarge</code>, <code>m2.4xlarge</code>, <code>c1.medium</code>, <code>c1.xlarge</code>, <code>cc1.4xlarge</code>, <code>cg1.4xlarge</code>]</li>
|
253 |
+
* <li><code>Placement</code> - <code>array</code> - Optional - Specifies the placement constraints (Availability Zones) for launching the instances. <ul>
|
254 |
+
* <li><code>AvailabilityZone</code> - <code>string</code> - Optional - The availability zone in which an Amazon EC2 instance runs. </li>
|
255 |
+
* <li><code>GroupName</code> - <code>string</code> - Optional - The name of a PlacementGroup. </li></ul></li>
|
256 |
+
* <li><code>KernelId</code> - <code>string</code> - Optional - The ID of the kernel with which to launch the instance. </li>
|
257 |
+
* <li><code>RamdiskId</code> - <code>string</code> - Optional - The ID of the RAM disk with which to launch the instance. Some kernels require additional drivers at launch. Check the kernel requirements for information on whether you need to specify a RAM disk. To find kernel requirements, go to the Resource Center and search for the kernel ID. </li>
|
258 |
+
* <li><code>BlockDeviceMapping</code> - <code>array</code> - Optional - <ul>
|
259 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
260 |
+
* <li><code>VirtualName</code> - <code>string</code> - Optional - Specifies the virtual device name. </li>
|
261 |
+
* <li><code>DeviceName</code> - <code>string</code> - Optional - Specifies the device name (e.g., /dev/sdh). </li>
|
262 |
+
* <li><code>Ebs</code> - <code>array</code> - Optional - Specifies parameters used to automatically setup Amazon EBS volumes when the instance is launched. Takes an associative array of parameters that can have the following keys: <ul>
|
263 |
+
* <li><code>SnapshotId</code> - <code>string</code> - Optional - The ID of the snapshot from which the volume will be created. </li>
|
264 |
+
* <li><code>VolumeSize</code> - <code>integer</code> - Optional - The size of the volume, in gigabytes. </li>
|
265 |
+
* <li><code>DeleteOnTermination</code> - <code>boolean</code> - Optional - Specifies whether the Amazon EBS volume is deleted on instance termination. </li>
|
266 |
+
* </ul></li>
|
267 |
+
* <li><code>NoDevice</code> - <code>string</code> - Optional - Specifies the device name to suppress during instance launch. </li>
|
268 |
+
* </ul></li>
|
269 |
+
* </ul></li>
|
270 |
+
* <li><code>Monitoring.Enabled</code> - <code>boolean</code> - Optional - Enables monitoring for the instance. </li>
|
271 |
+
* <li><code>SubnetId</code> - <code>string</code> - Optional - Specifies the subnet ID within which to launch the instance(s) for Amazon Virtual Private Cloud. </li>
|
272 |
+
* <li><code>DisableApiTermination</code> - <code>boolean</code> - Optional - Specifies whether the instance can be terminated using the APIs. You must modify this attribute before you can terminate any "locked" instances from the APIs. </li>
|
273 |
+
* <li><code>InstanceInitiatedShutdownBehavior</code> - <code>string</code> - Optional - Specifies whether the instance's Amazon EBS volumes are stopped or terminated when the instance is shut down. </li>
|
274 |
+
* <li><code>License</code> - <code>array</code> - Optional - Specifies active licenses in use and attached to an Amazon EC2 instance. <ul>
|
275 |
+
* <li><code>Pool</code> - <code>string</code> - Optional - The license pool from which to take a license when starting Amazon EC2 instances in the associated <code>RunInstances</code> request. </li></ul></li>
|
276 |
+
* <li><code>PrivateIpAddress</code> - <code>string</code> - Optional - If you're using Amazon Virtual Private Cloud, you can optionally use this parameter to assign the instance a specific available IP address from the subnet. </li>
|
277 |
+
* <li><code>ClientToken</code> - <code>string</code> - Optional - Unique, case-sensitive identifier you provide to ensure idempotency of the request. For more information, go to How to Ensure Idempotency in the Amazon Elastic Compute Cloud User Guide. </li>
|
278 |
+
* <li><code>AdditionalInfo</code> - <code>string</code> - Optional - For internal use only. </li>
|
279 |
+
* <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>
|
280 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
281 |
+
*/
|
282 |
+
public function run_instances($image_id, $min_count, $max_count, $opt = null)
|
283 |
+
{
|
284 |
+
if (!$opt) $opt = array();
|
285 |
+
$opt['ImageId'] = $image_id;
|
286 |
+
$opt['MinCount'] = $min_count;
|
287 |
+
$opt['MaxCount'] = $max_count;
|
288 |
+
|
289 |
+
// Optional parameter
|
290 |
+
if (isset($opt['SecurityGroup']))
|
291 |
+
{
|
292 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
293 |
+
'SecurityGroup' => (is_array($opt['SecurityGroup']) ? $opt['SecurityGroup'] : array($opt['SecurityGroup']))
|
294 |
+
)));
|
295 |
+
unset($opt['SecurityGroup']);
|
296 |
+
}
|
297 |
+
|
298 |
+
// Optional parameter
|
299 |
+
if (isset($opt['Placement']))
|
300 |
+
{
|
301 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
302 |
+
'Placement' => $opt['Placement']
|
303 |
+
)));
|
304 |
+
unset($opt['Placement']);
|
305 |
+
}
|
306 |
+
|
307 |
+
// Optional parameter
|
308 |
+
if (isset($opt['BlockDeviceMapping']))
|
309 |
+
{
|
310 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
311 |
+
'BlockDeviceMapping' => $opt['BlockDeviceMapping']
|
312 |
+
)));
|
313 |
+
unset($opt['BlockDeviceMapping']);
|
314 |
+
}
|
315 |
+
|
316 |
+
// Optional parameter
|
317 |
+
if (isset($opt['License']))
|
318 |
+
{
|
319 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
320 |
+
'License' => $opt['License']
|
321 |
+
)));
|
322 |
+
unset($opt['License']);
|
323 |
+
}
|
324 |
+
|
325 |
+
return $this->authenticate('RunInstances', $opt, $this->hostname);
|
326 |
+
}
|
327 |
+
|
328 |
+
/**
|
329 |
+
*
|
330 |
+
* The DescribeReservedInstances operation describes Reserved Instances that were purchased for use with your account.
|
331 |
+
*
|
332 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
333 |
+
* <li><code>ReservedInstancesId</code> - <code>string|array</code> - Optional - The optional list of Reserved Instance IDs to describe. Pass a string for a single value, or an indexed array for multiple values. </li>
|
334 |
+
* <li><code>Filter</code> - <code>array</code> - Optional - A list of filters used to match properties for ReservedInstances. For a complete reference to the available filter keys for this operation, see the Amazon EC2 API reference. <ul>
|
335 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
336 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Specifies the name of the filter. </li>
|
337 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
338 |
+
* </ul></li>
|
339 |
+
* </ul></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 describe_reserved_instances($opt = null)
|
344 |
+
{
|
345 |
+
if (!$opt) $opt = array();
|
346 |
+
|
347 |
+
// Optional parameter
|
348 |
+
if (isset($opt['ReservedInstancesId']))
|
349 |
+
{
|
350 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
351 |
+
'ReservedInstancesId' => (is_array($opt['ReservedInstancesId']) ? $opt['ReservedInstancesId'] : array($opt['ReservedInstancesId']))
|
352 |
+
)));
|
353 |
+
unset($opt['ReservedInstancesId']);
|
354 |
+
}
|
355 |
+
|
356 |
+
// Optional parameter
|
357 |
+
if (isset($opt['Filter']))
|
358 |
+
{
|
359 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
360 |
+
'Filter' => $opt['Filter']
|
361 |
+
)));
|
362 |
+
unset($opt['Filter']);
|
363 |
+
}
|
364 |
+
|
365 |
+
return $this->authenticate('DescribeReservedInstances', $opt, $this->hostname);
|
366 |
+
}
|
367 |
+
|
368 |
+
/**
|
369 |
+
*
|
370 |
+
* Gives you information about your subnets. You can filter the results to return information only about subnets that
|
371 |
+
* match criteria you specify. For example, you could ask to get information about a particular subnet (or all) only if the
|
372 |
+
* subnet's state is available. You can specify multiple filters (e.g., the subnet is in a particular VPC, and the subnet's
|
373 |
+
* state is available). The result includes information for a particular subnet only if the subnet matches all your
|
374 |
+
* filters. If there's no match, no special message is returned; the response is simply empty. The following table shows
|
375 |
+
* the available filters.
|
376 |
+
*
|
377 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
378 |
+
* <li><code>SubnetId</code> - <code>string|array</code> - Optional - A set of one or more subnet IDs. Pass a string for a single value, or an indexed array for multiple values. </li>
|
379 |
+
* <li><code>Filter</code> - <code>array</code> - Optional - <ul>
|
380 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
381 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Specifies the name of the filter. </li>
|
382 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
383 |
+
* </ul></li>
|
384 |
+
* </ul></li>
|
385 |
+
* <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>
|
386 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
387 |
+
*/
|
388 |
+
public function describe_subnets($opt = null)
|
389 |
+
{
|
390 |
+
if (!$opt) $opt = array();
|
391 |
+
|
392 |
+
// Optional parameter
|
393 |
+
if (isset($opt['SubnetId']))
|
394 |
+
{
|
395 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
396 |
+
'SubnetId' => (is_array($opt['SubnetId']) ? $opt['SubnetId'] : array($opt['SubnetId']))
|
397 |
+
)));
|
398 |
+
unset($opt['SubnetId']);
|
399 |
+
}
|
400 |
+
|
401 |
+
// Optional parameter
|
402 |
+
if (isset($opt['Filter']))
|
403 |
+
{
|
404 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
405 |
+
'Filter' => $opt['Filter']
|
406 |
+
)));
|
407 |
+
unset($opt['Filter']);
|
408 |
+
}
|
409 |
+
|
410 |
+
return $this->authenticate('DescribeSubnets', $opt, $this->hostname);
|
411 |
+
}
|
412 |
+
|
413 |
+
/**
|
414 |
+
*
|
415 |
+
* The DescribeAvailabilityZones operation describes availability zones that are currently available to the account and
|
416 |
+
* their states.
|
417 |
+
*
|
418 |
+
* Availability zones are not the same across accounts. The availability zone us-east-1a for account A is not necessarily
|
419 |
+
* the same as us-east-1a for account B. Zone assignments are mapped independently for each account.
|
420 |
+
*
|
421 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
422 |
+
* <li><code>ZoneName</code> - <code>string|array</code> - Optional - A list of the availability zone names to describe. Pass a string for a single value, or an indexed array for multiple values. </li>
|
423 |
+
* <li><code>Filter</code> - <code>array</code> - Optional - A list of filters used to match properties for AvailabilityZones. For a complete reference to the available filter keys for this operation, see the Amazon EC2 API reference. <ul>
|
424 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
425 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Specifies the name of the filter. </li>
|
426 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
427 |
+
* </ul></li>
|
428 |
+
* </ul></li>
|
429 |
+
* <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>
|
430 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
431 |
+
*/
|
432 |
+
public function describe_availability_zones($opt = null)
|
433 |
+
{
|
434 |
+
if (!$opt) $opt = array();
|
435 |
+
|
436 |
+
// Optional parameter
|
437 |
+
if (isset($opt['ZoneName']))
|
438 |
+
{
|
439 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
440 |
+
'ZoneName' => (is_array($opt['ZoneName']) ? $opt['ZoneName'] : array($opt['ZoneName']))
|
441 |
+
)));
|
442 |
+
unset($opt['ZoneName']);
|
443 |
+
}
|
444 |
+
|
445 |
+
// Optional parameter
|
446 |
+
if (isset($opt['Filter']))
|
447 |
+
{
|
448 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
449 |
+
'Filter' => $opt['Filter']
|
450 |
+
)));
|
451 |
+
unset($opt['Filter']);
|
452 |
+
}
|
453 |
+
|
454 |
+
return $this->authenticate('DescribeAvailabilityZones', $opt, $this->hostname);
|
455 |
+
}
|
456 |
+
|
457 |
+
/**
|
458 |
+
*
|
459 |
+
* Detach a previously attached volume from a running instance.
|
460 |
+
*
|
461 |
+
* @param string $volume_id (Required) The ID of the volume to detach.
|
462 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
463 |
+
* <li><code>InstanceId</code> - <code>string</code> - Optional - The ID of the instance from which to detach the the specified volume. </li>
|
464 |
+
* <li><code>Device</code> - <code>string</code> - Optional - The device name to which the volume is attached on the specified instance. </li>
|
465 |
+
* <li><code>Force</code> - <code>boolean</code> - Optional - Forces detachment if the previous detachment attempt did not occur cleanly (logging into an instance, unmounting the volume, and detaching normally). This option can lead to data loss or a corrupted file system. Use this option only as a last resort to detach a volume from a failed instance. The instance will not have an opportunity to flush file system caches nor file system meta data. If you use this option, you must perform file system check and repair procedures. </li>
|
466 |
+
* <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>
|
467 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
468 |
+
*/
|
469 |
+
public function detach_volume($volume_id, $opt = null)
|
470 |
+
{
|
471 |
+
if (!$opt) $opt = array();
|
472 |
+
$opt['VolumeId'] = $volume_id;
|
473 |
+
|
474 |
+
return $this->authenticate('DetachVolume', $opt, $this->hostname);
|
475 |
+
}
|
476 |
+
|
477 |
+
/**
|
478 |
+
*
|
479 |
+
* The DeleteKeyPair operation deletes a key pair.
|
480 |
+
*
|
481 |
+
* @param string $key_name (Required) The name of the Amazon EC2 key pair to delete.
|
482 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
483 |
+
* <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>
|
484 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
485 |
+
*/
|
486 |
+
public function delete_key_pair($key_name, $opt = null)
|
487 |
+
{
|
488 |
+
if (!$opt) $opt = array();
|
489 |
+
$opt['KeyName'] = $key_name;
|
490 |
+
|
491 |
+
return $this->authenticate('DeleteKeyPair', $opt, $this->hostname);
|
492 |
+
}
|
493 |
+
|
494 |
+
/**
|
495 |
+
*
|
496 |
+
* The DescribeInstances operation returns information about instances that you own.
|
497 |
+
*
|
498 |
+
* If you specify one or more instance IDs, Amazon EC2 returns information for those instances. If you do not specify
|
499 |
+
* instance IDs, Amazon EC2 returns information for all relevant instances. If you specify an invalid instance ID, a fault
|
500 |
+
* is returned. If you specify an instance that you do not own, it will not be included in the returned results.
|
501 |
+
*
|
502 |
+
* Recently terminated instances might appear in the returned results. This interval is usually less than one hour.
|
503 |
+
*
|
504 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
505 |
+
* <li><code>InstanceId</code> - <code>string|array</code> - Optional - An optional list of the instances to describe. Pass a string for a single value, or an indexed array for multiple values. </li>
|
506 |
+
* <li><code>Filter</code> - <code>array</code> - Optional - A list of filters used to match properties for Instances. For a complete reference to the available filter keys for this operation, see the Amazon EC2 API reference. <ul>
|
507 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
508 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Specifies the name of the filter. </li>
|
509 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
510 |
+
* </ul></li>
|
511 |
+
* </ul></li>
|
512 |
+
* <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>
|
513 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
514 |
+
*/
|
515 |
+
public function describe_instances($opt = null)
|
516 |
+
{
|
517 |
+
if (!$opt) $opt = array();
|
518 |
+
|
519 |
+
// Optional parameter
|
520 |
+
if (isset($opt['InstanceId']))
|
521 |
+
{
|
522 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
523 |
+
'InstanceId' => (is_array($opt['InstanceId']) ? $opt['InstanceId'] : array($opt['InstanceId']))
|
524 |
+
)));
|
525 |
+
unset($opt['InstanceId']);
|
526 |
+
}
|
527 |
+
|
528 |
+
// Optional parameter
|
529 |
+
if (isset($opt['Filter']))
|
530 |
+
{
|
531 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
532 |
+
'Filter' => $opt['Filter']
|
533 |
+
)));
|
534 |
+
unset($opt['Filter']);
|
535 |
+
}
|
536 |
+
|
537 |
+
return $this->authenticate('DescribeInstances', $opt, $this->hostname);
|
538 |
+
}
|
539 |
+
|
540 |
+
/**
|
541 |
+
*
|
542 |
+
* The DescribeImages operation returns information about AMIs, AKIs, and ARIs available to the user. Information returned
|
543 |
+
* includes image type, product codes, architecture, and kernel and RAM disk IDs. Images available to the user include
|
544 |
+
* public images available for any user to launch, private images owned by the user making the request, and private images
|
545 |
+
* owned by other users for which the user has explicit launch permissions.
|
546 |
+
*
|
547 |
+
* Launch permissions fall into three categories:
|
548 |
+
*
|
549 |
+
* <ul> <li> Public: The owner of the AMI granted launch permissions for the AMI to the all group. All users have launch
|
550 |
+
* permissions for these AMIs. </li>
|
551 |
+
*
|
552 |
+
* <li> Explicit: The owner of the AMI granted launch permissions to a specific user. </li>
|
553 |
+
*
|
554 |
+
* <li> Implicit: A user has implicit launch permissions for all AMIs he or she owns. </li>
|
555 |
+
*
|
556 |
+
* </ul>
|
557 |
+
*
|
558 |
+
* The list of AMIs returned can be modified by specifying AMI IDs, AMI owners, or users with launch permissions. If no
|
559 |
+
* options are specified, Amazon EC2 returns all AMIs for which the user has launch permissions.
|
560 |
+
*
|
561 |
+
* If you specify one or more AMI IDs, only AMIs that have the specified IDs are returned. If you specify an invalid AMI
|
562 |
+
* ID, a fault is returned. If you specify an AMI ID for which you do not have access, it will not be included in the
|
563 |
+
* returned results.
|
564 |
+
*
|
565 |
+
* If you specify one or more AMI owners, only AMIs from the specified owners and for which you have access are returned.
|
566 |
+
* The results can include the account IDs of the specified owners, amazon for AMIs owned by Amazon or self for AMIs that
|
567 |
+
* you own.
|
568 |
+
*
|
569 |
+
* If you specify a list of executable users, only users that have launch permissions for the AMIs are returned. You can
|
570 |
+
* specify account IDs (if you own the AMI(s)), self for AMIs for which you own or have explicit permissions, or all for
|
571 |
+
* public AMIs.
|
572 |
+
*
|
573 |
+
* Deregistered images are included in the returned results for an unspecified interval after deregistration.
|
574 |
+
*
|
575 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
576 |
+
* <li><code>ImageId</code> - <code>string|array</code> - Optional - An optional list of the AMI IDs to describe. If not specified, all AMIs will be described. Pass a string for a single value, or an indexed array for multiple values. </li>
|
577 |
+
* <li><code>Owner</code> - <code>string|array</code> - Optional - The optional list of owners for the described AMIs. The IDs amazon, self, and explicit can be used to include AMIs owned by Amazon, AMIs owned by the user, and AMIs for which the user has explicit launch permissions, respectively. Pass a string for a single value, or an indexed array for multiple values. </li>
|
578 |
+
* <li><code>ExecutableBy</code> - <code>string|array</code> - Optional - The optional list of users with explicit launch permissions for the described AMIs. The user ID can be a user's account ID, 'self' to return AMIs for which the sender of the request has explicit launch permissions, or 'all' to return AMIs with public launch permissions. Pass a string for a single value, or an indexed array for multiple values. </li>
|
579 |
+
* <li><code>Filter</code> - <code>array</code> - Optional - A list of filters used to match properties for Images. For a complete reference to the available filter keys for this operation, see the Amazon EC2 API reference. <ul>
|
580 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
581 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Specifies the name of the filter. </li>
|
582 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
583 |
+
* </ul></li>
|
584 |
+
* </ul></li>
|
585 |
+
* <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>
|
586 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
587 |
+
*/
|
588 |
+
public function describe_images($opt = null)
|
589 |
+
{
|
590 |
+
if (!$opt) $opt = array();
|
591 |
+
|
592 |
+
// Optional parameter
|
593 |
+
if (isset($opt['ImageId']))
|
594 |
+
{
|
595 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
596 |
+
'ImageId' => (is_array($opt['ImageId']) ? $opt['ImageId'] : array($opt['ImageId']))
|
597 |
+
)));
|
598 |
+
unset($opt['ImageId']);
|
599 |
+
}
|
600 |
+
|
601 |
+
// Optional parameter
|
602 |
+
if (isset($opt['Owner']))
|
603 |
+
{
|
604 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
605 |
+
'Owner' => (is_array($opt['Owner']) ? $opt['Owner'] : array($opt['Owner']))
|
606 |
+
)));
|
607 |
+
unset($opt['Owner']);
|
608 |
+
}
|
609 |
+
|
610 |
+
// Optional parameter
|
611 |
+
if (isset($opt['ExecutableBy']))
|
612 |
+
{
|
613 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
614 |
+
'ExecutableBy' => (is_array($opt['ExecutableBy']) ? $opt['ExecutableBy'] : array($opt['ExecutableBy']))
|
615 |
+
)));
|
616 |
+
unset($opt['ExecutableBy']);
|
617 |
+
}
|
618 |
+
|
619 |
+
// Optional parameter
|
620 |
+
if (isset($opt['Filter']))
|
621 |
+
{
|
622 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
623 |
+
'Filter' => $opt['Filter']
|
624 |
+
)));
|
625 |
+
unset($opt['Filter']);
|
626 |
+
}
|
627 |
+
|
628 |
+
return $this->authenticate('DescribeImages', $opt, $this->hostname);
|
629 |
+
}
|
630 |
+
|
631 |
+
/**
|
632 |
+
*
|
633 |
+
* Starts an instance that uses an Amazon EBS volume as its root device. Instances that use Amazon EBS volumes as their
|
634 |
+
* root devices can be quickly stopped and started. When an instance is stopped, the compute resources are released and you
|
635 |
+
* are not billed for hourly instance usage. However, your root partition Amazon EBS volume remains, continues to persist
|
636 |
+
* your data, and you are charged for Amazon EBS volume usage. You can restart your instance at any time.
|
637 |
+
*
|
638 |
+
* Performing this operation on an instance that uses an instance store as its root device returns an error.
|
639 |
+
*
|
640 |
+
* @param string|array $instance_id (Required) The list of Amazon EC2 instances to start. Pass a string for a single value, or an indexed array for multiple values.
|
641 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
642 |
+
* <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>
|
643 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
644 |
+
*/
|
645 |
+
public function start_instances($instance_id, $opt = null)
|
646 |
+
{
|
647 |
+
if (!$opt) $opt = array();
|
648 |
+
|
649 |
+
// Required parameter
|
650 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
651 |
+
'InstanceId' => (is_array($instance_id) ? $instance_id : array($instance_id))
|
652 |
+
)));
|
653 |
+
|
654 |
+
return $this->authenticate('StartInstances', $opt, $this->hostname);
|
655 |
+
}
|
656 |
+
|
657 |
+
/**
|
658 |
+
*
|
659 |
+
* Disables monitoring for a running instance.
|
660 |
+
*
|
661 |
+
* @param string|array $instance_id (Required) The list of Amazon EC2 instances on which to disable monitoring. Pass a string for a single value, or an indexed array for multiple values.
|
662 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
663 |
+
* <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>
|
664 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
665 |
+
*/
|
666 |
+
public function unmonitor_instances($instance_id, $opt = null)
|
667 |
+
{
|
668 |
+
if (!$opt) $opt = array();
|
669 |
+
|
670 |
+
// Required parameter
|
671 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
672 |
+
'InstanceId' => (is_array($instance_id) ? $instance_id : array($instance_id))
|
673 |
+
)));
|
674 |
+
|
675 |
+
return $this->authenticate('UnmonitorInstances', $opt, $this->hostname);
|
676 |
+
}
|
677 |
+
|
678 |
+
/**
|
679 |
+
*
|
680 |
+
* Attaches a VPN gateway to a VPC. This is the last step required to get your VPC fully connected to your data center
|
681 |
+
* before launching instances in it. For more information, go to Process for Using Amazon VPC in the Amazon Virtual Private
|
682 |
+
* Cloud Developer Guide.
|
683 |
+
*
|
684 |
+
* @param string $vpn_gateway_id (Required) The ID of the VPN gateway to attach to the VPC.
|
685 |
+
* @param string $vpc_id (Required) The ID of the VPC to attach to the VPN gateway.
|
686 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
687 |
+
* <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>
|
688 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
689 |
+
*/
|
690 |
+
public function attach_vpn_gateway($vpn_gateway_id, $vpc_id, $opt = null)
|
691 |
+
{
|
692 |
+
if (!$opt) $opt = array();
|
693 |
+
$opt['VpnGatewayId'] = $vpn_gateway_id;
|
694 |
+
$opt['VpcId'] = $vpc_id;
|
695 |
+
|
696 |
+
return $this->authenticate('AttachVpnGateway', $opt, $this->hostname);
|
697 |
+
}
|
698 |
+
|
699 |
+
/**
|
700 |
+
*
|
701 |
+
* Modifies an attribute of an instance.
|
702 |
+
*
|
703 |
+
* @param string $instance_id (Required) The ID of the instance whose attribute is being modified.
|
704 |
+
* @param string $attribute (Required) The name of the attribute being modified. Available attribute names: instanceType, kernel, ramdisk, userData, disableApiTermination, instanceInitiatedShutdownBehavior, rootDevice, blockDeviceMapping
|
705 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
706 |
+
* <li><code>Value</code> - <code>string</code> - Optional - The new value of the instance attribute being modified. Only valid when kernel, ramdisk, userData disableApiTermination, or instanceInitiateShutdownBehavior is specified as the attribute being modified. </li>
|
707 |
+
* <li><code>BlockDeviceMapping</code> - <code>array</code> - Optional - The new block device mappings for the instance whose attributes are being modified. Only valid when blockDeviceMapping is specified as the attribute being modified. <ul>
|
708 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
709 |
+
* <li><code>DeviceName</code> - <code>string</code> - Optional - The device name (e.g., /dev/sdh) at which the block device is exposed on the instance. </li>
|
710 |
+
* <li><code>Ebs</code> - <code>array</code> - Optional - The EBS instance block device specification describing the EBS block device to map to the specified device name on a running instance. Takes an associative array of parameters that can have the following keys: <ul>
|
711 |
+
* <li><code>VolumeId</code> - <code>string</code> - Optional - The ID of the EBS volume that should be mounted as a block device on an Amazon EC2 instance. </li>
|
712 |
+
* <li><code>DeleteOnTermination</code> - <code>boolean</code> - Optional - Specifies whether the Amazon EBS volume is deleted on instance termination. </li>
|
713 |
+
* </ul></li>
|
714 |
+
* <li><code>VirtualName</code> - <code>string</code> - Optional - The virtual device name. </li>
|
715 |
+
* <li><code>NoDevice</code> - <code>string</code> - Optional - When set to the empty string, specifies that the device name in this object should not be mapped to any real device. </li>
|
716 |
+
* </ul></li>
|
717 |
+
* </ul></li>
|
718 |
+
* <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>
|
719 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
720 |
+
*/
|
721 |
+
public function modify_instance_attribute($instance_id, $attribute, $opt = null)
|
722 |
+
{
|
723 |
+
if (!$opt) $opt = array();
|
724 |
+
$opt['InstanceId'] = $instance_id;
|
725 |
+
$opt['Attribute'] = $attribute;
|
726 |
+
|
727 |
+
// Optional parameter
|
728 |
+
if (isset($opt['BlockDeviceMapping']))
|
729 |
+
{
|
730 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
731 |
+
'BlockDeviceMapping' => $opt['BlockDeviceMapping']
|
732 |
+
)));
|
733 |
+
unset($opt['BlockDeviceMapping']);
|
734 |
+
}
|
735 |
+
|
736 |
+
return $this->authenticate('ModifyInstanceAttribute', $opt, $this->hostname);
|
737 |
+
}
|
738 |
+
|
739 |
+
/**
|
740 |
+
*
|
741 |
+
* Deletes a set of DHCP options that you specify. Amazon VPC returns an error if the set of options you specify is
|
742 |
+
* currently associated with a VPC. You can disassociate the set of options by associating either a new set of options or
|
743 |
+
* the default options with the VPC.
|
744 |
+
*
|
745 |
+
* @param string $dhcp_options_id (Required) The ID of the DHCP options set to delete.
|
746 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
747 |
+
* <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>
|
748 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
749 |
+
*/
|
750 |
+
public function delete_dhcp_options($dhcp_options_id, $opt = null)
|
751 |
+
{
|
752 |
+
if (!$opt) $opt = array();
|
753 |
+
$opt['DhcpOptionsId'] = $dhcp_options_id;
|
754 |
+
|
755 |
+
return $this->authenticate('DeleteDhcpOptions', $opt, $this->hostname);
|
756 |
+
}
|
757 |
+
|
758 |
+
/**
|
759 |
+
*
|
760 |
+
* The DeleteSecurityGroup operation deletes a security group.
|
761 |
+
*
|
762 |
+
* If you attempt to delete a security group that contains instances, a fault is returned.
|
763 |
+
*
|
764 |
+
* If you attempt to delete a security group that is referenced by another security group, a fault is returned. For
|
765 |
+
* example, if security group B has a rule that allows access from security group A, security group A cannot be deleted
|
766 |
+
* until the allow rule is removed.
|
767 |
+
*
|
768 |
+
* @param string $group_name (Required) The name of the Amazon EC2 security group to delete.
|
769 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
770 |
+
* <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>
|
771 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
772 |
+
*/
|
773 |
+
public function delete_security_group($group_name, $opt = null)
|
774 |
+
{
|
775 |
+
if (!$opt) $opt = array();
|
776 |
+
$opt['GroupName'] = $group_name;
|
777 |
+
|
778 |
+
return $this->authenticate('DeleteSecurityGroup', $opt, $this->hostname);
|
779 |
+
}
|
780 |
+
|
781 |
+
/**
|
782 |
+
*
|
783 |
+
* Creates an Amazon EBS-backed AMI from a "running" or "stopped" instance. AMIs that use an Amazon EBS root device boot
|
784 |
+
* faster than AMIs that use instance stores. They can be up to 1 TiB in size, use storage that persists on instance
|
785 |
+
* failure, and can be stopped and started.
|
786 |
+
*
|
787 |
+
* @param string $instance_id (Required) The ID of the instance from which to create the new image.
|
788 |
+
* @param string $name (Required) The name for the new AMI being created.
|
789 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
790 |
+
* <li><code>Description</code> - <code>string</code> - Optional - The description for the new AMI being created. </li>
|
791 |
+
* <li><code>NoReboot</code> - <code>boolean</code> - Optional - By default this property is set to <code>false</code>, which means Amazon EC2 attempts to cleanly shut down the instance before image creation and reboots the instance afterwards. When set to true, Amazon EC2 will not shut down the instance before creating the image. When this option is used, file system integrity on the created image cannot be guaranteed. </li>
|
792 |
+
* <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>
|
793 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
794 |
+
*/
|
795 |
+
public function create_image($instance_id, $name, $opt = null)
|
796 |
+
{
|
797 |
+
if (!$opt) $opt = array();
|
798 |
+
$opt['InstanceId'] = $instance_id;
|
799 |
+
$opt['Name'] = $name;
|
800 |
+
|
801 |
+
return $this->authenticate('CreateImage', $opt, $this->hostname);
|
802 |
+
}
|
803 |
+
|
804 |
+
/**
|
805 |
+
*
|
806 |
+
* The AuthorizeSecurityGroupIngress operation adds permissions to a security group.
|
807 |
+
*
|
808 |
+
* Permissions are specified by the IP protocol (TCP, UDP or ICMP), the source of the request (by IP range or an Amazon
|
809 |
+
* EC2 user-group pair), the source and destination port ranges (for TCP and UDP), and the ICMP codes and types (for ICMP).
|
810 |
+
* When authorizing ICMP, -1 can be used as a wildcard in the type and code fields.
|
811 |
+
*
|
812 |
+
* Permission changes are propagated to instances within the security group as quickly as possible. However, depending on
|
813 |
+
* the number of instances, a small delay might occur.
|
814 |
+
*
|
815 |
+
* @param string $group_name (Required) Name of the group to modify. The name must be valid and belong to the account.
|
816 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
817 |
+
* <li><code>SourceSecurityGroupName</code> - <code>string</code> - Optional - Deprecated - use the list of IP permissions to specify this information instead. Name of the security group. Cannot be used when specifying a CIDR IP address. </li>
|
818 |
+
* <li><code>SourceSecurityGroupOwnerId</code> - <code>string</code> - Optional - Deprecated - use the list of IP permissions to specify this information instead. AWS user ID of an account. Cannot be used when specifying a CIDR IP address. </li>
|
819 |
+
* <li><code>IpProtocol</code> - <code>string</code> - Optional - Deprecated - use the list of IP permissions to specify this information instead. IP protocol. </li>
|
820 |
+
* <li><code>FromPort</code> - <code>integer</code> - Optional - Deprecated - use the list of IP permissions to specify this information instead. Start of port range for the TCP and UDP protocols, or an ICMP type number. An ICMP type number of -1 indicates a wildcard (i.e., any ICMP type number). </li>
|
821 |
+
* <li><code>ToPort</code> - <code>integer</code> - Optional - Deprecated - use the list of IP permissions to specify this information instead. End of port range for the TCP and UDP protocols, or an ICMP code. An ICMP code of -1 indicates a wildcard (i.e., any ICMP code). </li>
|
822 |
+
* <li><code>CidrIp</code> - <code>string</code> - Optional - Deprecated - use the list of IP permissions to specify this information instead. CIDR range. </li>
|
823 |
+
* <li><code>IpPermissions</code> - <code>array</code> - Optional - List of IP permissions to authorize on the specified security group. Specifying permissions through IP permissions is the preferred way of authorizing permissions since it offers more flexibility and control. <ul>
|
824 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
825 |
+
* <li><code>IpProtocol</code> - <code>string</code> - Optional - The IP protocol of this permission. Valid protocol values: tpc, upd, icmp </li>
|
826 |
+
* <li><code>FromPort</code> - <code>integer</code> - Optional - Start of port range for the TCP and UDP protocols, or an ICMP type number. An ICMP type number of -1 indicates a wildcard (i.e., any ICMP type number). </li>
|
827 |
+
* <li><code>ToPort</code> - <code>integer</code> - Optional - End of port range for the TCP and UDP protocols, or an ICMP code. An ICMP code of -1 indicates a wildcard (i.e., any ICMP code). </li>
|
828 |
+
* <li><code>Groups</code> - <code>array</code> - Optional - The list of AWS user IDs and groups included in this permission. <ul>
|
829 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
830 |
+
* <li><code>UserId</code> - <code>string</code> - Optional - The AWS user ID of an account. </li>
|
831 |
+
* <li><code>GroupName</code> - <code>string</code> - Optional - The name of the security group in the specified user's account. </li>
|
832 |
+
* </ul></li>
|
833 |
+
* </ul></li>
|
834 |
+
* <li><code>IpRanges</code> - <code>string|array</code> - Optional - The list of CIDR IP ranges included in this permission. Pass a string for a single value, or an indexed array for multiple values. </li>
|
835 |
+
* </ul></li>
|
836 |
+
* </ul></li>
|
837 |
+
* <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>
|
838 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
839 |
+
*/
|
840 |
+
public function authorize_security_group_ingress($group_name, $opt = null)
|
841 |
+
{
|
842 |
+
if (!$opt) $opt = array();
|
843 |
+
$opt['GroupName'] = $group_name;
|
844 |
+
|
845 |
+
// Optional parameter
|
846 |
+
if (isset($opt['IpPermissions']))
|
847 |
+
{
|
848 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
849 |
+
'IpPermissions' => $opt['IpPermissions']
|
850 |
+
)));
|
851 |
+
unset($opt['IpPermissions']);
|
852 |
+
}
|
853 |
+
|
854 |
+
return $this->authenticate('AuthorizeSecurityGroupIngress', $opt, $this->hostname);
|
855 |
+
}
|
856 |
+
|
857 |
+
/**
|
858 |
+
*
|
859 |
+
* Describes Spot Instance requests. Spot Instances are instances that Amazon EC2 starts on your behalf when the maximum
|
860 |
+
* price that you specify exceeds the current Spot Price. Amazon EC2 periodically sets the Spot Price based on available
|
861 |
+
* Spot Instance capacity and current spot instance requests. For conceptual information about Spot Instances, refer to the
|
862 |
+
* <a href="http://docs.amazonwebservices.com/AWSEC2/2010-08-31/DeveloperGuide/">Amazon Elastic Compute Cloud Developer
|
863 |
+
* Guide</a> or <a href="http://docs.amazonwebservices.com/AWSEC2/2010-08-31/UserGuide/">Amazon Elastic Compute Cloud User
|
864 |
+
* Guide</a>.
|
865 |
+
*
|
866 |
+
* You can filter the results to return information only about Spot Instance requests that match criteria you specify. For
|
867 |
+
* example, you could get information about requests where the Spot Price you specified is a certain value (you can't use
|
868 |
+
* greater than or less than comparison, but you can use <code>*</code> and <code>?</code> wildcards). You can specify
|
869 |
+
* multiple values for a filter. A Spot Instance request must match at least one of the specified values for it to be
|
870 |
+
* included in the results.
|
871 |
+
*
|
872 |
+
* You can specify multiple filters (e.g., the Spot Price is equal to a particular value, and the instance type is
|
873 |
+
* m1.small). The result includes information for a particular request only if it matches all your filters. If there's no
|
874 |
+
* match, no special message is returned; the response is simply empty.
|
875 |
+
*
|
876 |
+
* You can use wildcards with the filter values: <code>*</code> matches zero or more characters, and <code>?</code>
|
877 |
+
* matches exactly one character. You can escape special characters using a backslash before the character. For example, a
|
878 |
+
* value of <code>\*amazon\?\\</code> searches for the literal string <code>*amazon?\</code>.
|
879 |
+
*
|
880 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
881 |
+
* <li><code>SpotInstanceRequestId</code> - <code>string|array</code> - Optional - The ID of the request. Pass a string for a single value, or an indexed array for multiple values. </li>
|
882 |
+
* <li><code>Filter</code> - <code>array</code> - Optional - A list of filters used to match properties for SpotInstances. For a complete reference to the available filter keys for this operation, see the Amazon EC2 API reference. <ul>
|
883 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
884 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Specifies the name of the filter. </li>
|
885 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
886 |
+
* </ul></li>
|
887 |
+
* </ul></li>
|
888 |
+
* <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>
|
889 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
890 |
+
*/
|
891 |
+
public function describe_spot_instance_requests($opt = null)
|
892 |
+
{
|
893 |
+
if (!$opt) $opt = array();
|
894 |
+
|
895 |
+
// Optional parameter
|
896 |
+
if (isset($opt['SpotInstanceRequestId']))
|
897 |
+
{
|
898 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
899 |
+
'SpotInstanceRequestId' => (is_array($opt['SpotInstanceRequestId']) ? $opt['SpotInstanceRequestId'] : array($opt['SpotInstanceRequestId']))
|
900 |
+
)));
|
901 |
+
unset($opt['SpotInstanceRequestId']);
|
902 |
+
}
|
903 |
+
|
904 |
+
// Optional parameter
|
905 |
+
if (isset($opt['Filter']))
|
906 |
+
{
|
907 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
908 |
+
'Filter' => $opt['Filter']
|
909 |
+
)));
|
910 |
+
unset($opt['Filter']);
|
911 |
+
}
|
912 |
+
|
913 |
+
return $this->authenticate('DescribeSpotInstanceRequests', $opt, $this->hostname);
|
914 |
+
}
|
915 |
+
|
916 |
+
/**
|
917 |
+
*
|
918 |
+
* Associates a set of DHCP options (that you've previously created) with the specified VPC. Or, associates the default
|
919 |
+
* DHCP options with the VPC. The default set consists of the standard EC2 host name, no domain name, no DNS server, no NTP
|
920 |
+
* server, and no NetBIOS server or node type. After you associate the options with the VPC, any existing instances and all
|
921 |
+
* new instances that you launch in that VPC use the options. For more information about the supported DHCP options and
|
922 |
+
* using them with Amazon VPC, go to Using DHCP Options in the Amazon Virtual Private Cloud Developer Guide.
|
923 |
+
*
|
924 |
+
* @param string $dhcp_options_id (Required) The ID of the DHCP options to associate with the VPC. Specify "default" to associate the default DHCP options with the VPC.
|
925 |
+
* @param string $vpc_id (Required) The ID of the VPC to associate the DHCP options with.
|
926 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
927 |
+
* <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>
|
928 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
929 |
+
*/
|
930 |
+
public function associate_dhcp_options($dhcp_options_id, $vpc_id, $opt = null)
|
931 |
+
{
|
932 |
+
if (!$opt) $opt = array();
|
933 |
+
$opt['DhcpOptionsId'] = $dhcp_options_id;
|
934 |
+
$opt['VpcId'] = $vpc_id;
|
935 |
+
|
936 |
+
return $this->authenticate('AssociateDhcpOptions', $opt, $this->hostname);
|
937 |
+
}
|
938 |
+
|
939 |
+
/**
|
940 |
+
* Retrieves the encrypted administrator password for the instances running Windows.
|
941 |
+
*
|
942 |
+
* The Windows password is only generated the first time an AMI is launched. It is not generated for
|
943 |
+
* rebundled AMIs or after the password is changed on an instance. The password is encrypted using the
|
944 |
+
* key pair that you provided.
|
945 |
+
*
|
946 |
+
* @param string $instance_id (Required) The ID of the instance for which you want the Windows administrator password.
|
947 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
948 |
+
* <li><code>DecryptPasswordWithKey</code> - <code>string</code> - Optional - Enables the decryption of the Administrator password for the given Microsoft Windows instance. Specifies the RSA private key that is associated with the keypair ID which was used to launch the Microsoft Windows instance.</li>
|
949 |
+
* <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 is useful for manually-managed batch requests.</li></ul>
|
950 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
951 |
+
*/
|
952 |
+
public function get_password_data($instance_id, $opt = null)
|
953 |
+
{
|
954 |
+
if (!$opt) $opt = array();
|
955 |
+
$opt['InstanceId'] = $instance_id;
|
956 |
+
|
957 |
+
// Unless DecryptPasswordWithKey is set, simply return the response.
|
958 |
+
if (!isset($opt['DecryptPasswordWithKey']))
|
959 |
+
{
|
960 |
+
return $this->authenticate('GetPasswordData', $opt, $this->hostname);
|
961 |
+
}
|
962 |
+
|
963 |
+
// Otherwise, decrypt the password.
|
964 |
+
else
|
965 |
+
{
|
966 |
+
// Get a resource representing the private key.
|
967 |
+
$private_key = openssl_pkey_get_private($opt['DecryptPasswordWithKey']);
|
968 |
+
unset($opt['DecryptPasswordWithKey']);
|
969 |
+
|
970 |
+
// Fetch the encrypted password.
|
971 |
+
$response = $this->authenticate('GetPasswordData', $opt, $this->hostname);
|
972 |
+
$data = trim((string) $response->body->passwordData);
|
973 |
+
|
974 |
+
// If it's Base64-encoded...
|
975 |
+
if ($this->util->is_base64($data))
|
976 |
+
{
|
977 |
+
// Base64-decode it, and decrypt it with the private key.
|
978 |
+
if (openssl_private_decrypt(base64_decode($data), $decrypted, $private_key))
|
979 |
+
{
|
980 |
+
// Replace the previous password data with the decrypted value.
|
981 |
+
$response->body->passwordData = $decrypted;
|
982 |
+
}
|
983 |
+
}
|
984 |
+
|
985 |
+
return $response;
|
986 |
+
}
|
987 |
+
}
|
988 |
+
|
989 |
+
/**
|
990 |
+
*
|
991 |
+
* Creates a VPC with the CIDR block you specify. The smallest VPC you can create uses a /28 netmask (16 IP addresses),
|
992 |
+
* and the largest uses a /18 netmask (16,384 IP addresses). To help you decide how big to make your VPC, go to the topic
|
993 |
+
* about creating VPCs in the Amazon Virtual Private Cloud Developer Guide.
|
994 |
+
*
|
995 |
+
* By default, each instance you launch in the VPC has the default DHCP options (the standard EC2 host name, no domain
|
996 |
+
* name, no DNS server, no NTP server, and no NetBIOS server or node type).
|
997 |
+
*
|
998 |
+
* @param string $cidr_block (Required) A valid CIDR block.
|
999 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1000 |
+
* <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>
|
1001 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1002 |
+
*/
|
1003 |
+
public function create_vpc($cidr_block, $opt = null)
|
1004 |
+
{
|
1005 |
+
if (!$opt) $opt = array();
|
1006 |
+
$opt['CidrBlock'] = $cidr_block;
|
1007 |
+
|
1008 |
+
return $this->authenticate('CreateVpc', $opt, $this->hostname);
|
1009 |
+
}
|
1010 |
+
|
1011 |
+
/**
|
1012 |
+
*
|
1013 |
+
* Stops an instance that uses an Amazon EBS volume as its root device. Instances that use Amazon EBS volumes as their
|
1014 |
+
* root devices can be quickly stopped and started. When an instance is stopped, the compute resources are released and you
|
1015 |
+
* are not billed for hourly instance usage. However, your root partition Amazon EBS volume remains, continues to persist
|
1016 |
+
* your data, and you are charged for Amazon EBS volume usage. You can restart your instance at any time.
|
1017 |
+
*
|
1018 |
+
* Before stopping an instance, make sure it is in a state from which it can be restarted. Stopping an instance does not
|
1019 |
+
* preserve data stored in RAM.
|
1020 |
+
*
|
1021 |
+
* Performing this operation on an instance that uses an instance store as its root device returns an error.
|
1022 |
+
*
|
1023 |
+
* @param string|array $instance_id (Required) The list of Amazon EC2 instances to stop. Pass a string for a single value, or an indexed array for multiple values.
|
1024 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1025 |
+
* <li><code>Force</code> - <code>boolean</code> - Optional - Forces the instance to stop. The instance will not have an opportunity to flush file system caches nor file system meta data. If you use this option, you must perform file system check and repair procedures. This option is not recommended for Windows instances. </li>
|
1026 |
+
* <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>
|
1027 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1028 |
+
*/
|
1029 |
+
public function stop_instances($instance_id, $opt = null)
|
1030 |
+
{
|
1031 |
+
if (!$opt) $opt = array();
|
1032 |
+
|
1033 |
+
// Required parameter
|
1034 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1035 |
+
'InstanceId' => (is_array($instance_id) ? $instance_id : array($instance_id))
|
1036 |
+
)));
|
1037 |
+
|
1038 |
+
return $this->authenticate('StopInstances', $opt, $this->hostname);
|
1039 |
+
}
|
1040 |
+
|
1041 |
+
/**
|
1042 |
+
*
|
1043 |
+
* Gives you information about your customer gateways. You can filter the results to return information only about
|
1044 |
+
* customer gateways that match criteria you specify. For example, you could ask to get information about a particular
|
1045 |
+
* customer gateway (or all) only if the gateway's state is pending or available. You can specify multiple filters (e.g.,
|
1046 |
+
* the customer gateway has a particular IP address for the Internet-routable external interface, and the gateway's state
|
1047 |
+
* is pending or available). The result includes information for a particular customer gateway only if the gateway matches
|
1048 |
+
* all your filters. If there's no match, no special message is returned; the response is simply empty. The following table
|
1049 |
+
* shows the available filters.
|
1050 |
+
*
|
1051 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1052 |
+
* <li><code>CustomerGatewayId</code> - <code>string|array</code> - Optional - A set of one or more customer gateway IDs. Pass a string for a single value, or an indexed array for multiple values. </li>
|
1053 |
+
* <li><code>Filter</code> - <code>array</code> - Optional - <ul>
|
1054 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
1055 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Specifies the name of the filter. </li>
|
1056 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
1057 |
+
* </ul></li>
|
1058 |
+
* </ul></li>
|
1059 |
+
* <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>
|
1060 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1061 |
+
*/
|
1062 |
+
public function describe_customer_gateways($opt = null)
|
1063 |
+
{
|
1064 |
+
if (!$opt) $opt = array();
|
1065 |
+
|
1066 |
+
// Optional parameter
|
1067 |
+
if (isset($opt['CustomerGatewayId']))
|
1068 |
+
{
|
1069 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1070 |
+
'CustomerGatewayId' => (is_array($opt['CustomerGatewayId']) ? $opt['CustomerGatewayId'] : array($opt['CustomerGatewayId']))
|
1071 |
+
)));
|
1072 |
+
unset($opt['CustomerGatewayId']);
|
1073 |
+
}
|
1074 |
+
|
1075 |
+
// Optional parameter
|
1076 |
+
if (isset($opt['Filter']))
|
1077 |
+
{
|
1078 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1079 |
+
'Filter' => $opt['Filter']
|
1080 |
+
)));
|
1081 |
+
unset($opt['Filter']);
|
1082 |
+
}
|
1083 |
+
|
1084 |
+
return $this->authenticate('DescribeCustomerGateways', $opt, $this->hostname);
|
1085 |
+
}
|
1086 |
+
|
1087 |
+
/**
|
1088 |
+
* Imports the public key from an RSA key pair created with a third-party tool. This operation differs
|
1089 |
+
* from CreateKeyPair as the private key is never transferred between the caller and AWS servers.
|
1090 |
+
*
|
1091 |
+
* RSA key pairs are easily created on Microsoft Windows and Linux OS systems using the <code>ssh-keygen</code>
|
1092 |
+
* command line tool provided with the standard OpenSSH installation. Standard library support for RSA
|
1093 |
+
* key pair creation is also available for Java, Ruby, Python, and many other programming languages.
|
1094 |
+
*
|
1095 |
+
* The following formats are supported:
|
1096 |
+
*
|
1097 |
+
* <ul>
|
1098 |
+
* <li>OpenSSH public key format.</li>
|
1099 |
+
* <li>Base64 encoded DER format.</li>
|
1100 |
+
* <li>SSH public key file format as specified in <a href="http://tools.ietf.org/html/rfc4716">RFC 4716</a>.</li>
|
1101 |
+
* </ul>
|
1102 |
+
*
|
1103 |
+
* @param string $key_name (Required) The unique name for the key pair.
|
1104 |
+
* @param string $public_key_material (Required) The public key portion of the key pair being imported.
|
1105 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1106 |
+
* <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 is useful for manually-managed batch requests.</li></ul>
|
1107 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1108 |
+
*/
|
1109 |
+
public function import_key_pair($key_name, $public_key_material, $opt = null)
|
1110 |
+
{
|
1111 |
+
if (!$opt) $opt = array();
|
1112 |
+
$opt['KeyName'] = $key_name;
|
1113 |
+
$opt['PublicKeyMaterial'] = $this->util->is_base64($public_key_material) ? $public_key_material : base64_encode($public_key_material);
|
1114 |
+
|
1115 |
+
return $this->authenticate('ImportKeyPair', $opt, $this->hostname);
|
1116 |
+
}
|
1117 |
+
|
1118 |
+
/**
|
1119 |
+
*
|
1120 |
+
* Describes the Spot Price history.
|
1121 |
+
*
|
1122 |
+
* Spot Instances are instances that Amazon EC2 starts on your behalf when the maximum price that you specify exceeds the
|
1123 |
+
* current Spot Price. Amazon EC2 periodically sets the Spot Price based on available Spot Instance capacity and current
|
1124 |
+
* spot instance requests.
|
1125 |
+
*
|
1126 |
+
* For conceptual information about Spot Instances, refer to the Amazon Elastic Compute Cloud Developer Guide or Amazon
|
1127 |
+
* Elastic Compute Cloud User Guide.
|
1128 |
+
*
|
1129 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1130 |
+
* <li><code>StartTime</code> - <code>string</code> - Optional - The start date and time of the Spot Instance price history data. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
1131 |
+
* <li><code>EndTime</code> - <code>string</code> - Optional - The end date and time of the Spot Instance price history data. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
1132 |
+
* <li><code>InstanceType</code> - <code>string|array</code> - Optional - Specifies the instance type to return. Pass a string for a single value, or an indexed array for multiple values. </li>
|
1133 |
+
* <li><code>ProductDescription</code> - <code>string|array</code> - Optional - The description of the AMI. Pass a string for a single value, or an indexed array for multiple values. </li>
|
1134 |
+
* <li><code>Filter</code> - <code>array</code> - Optional - A list of filters used to match properties for SpotPriceHistory. For a complete reference to the available filter keys for this operation, see the Amazon EC2 API reference. <ul>
|
1135 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
1136 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Specifies the name of the filter. </li>
|
1137 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
1138 |
+
* </ul></li>
|
1139 |
+
* </ul></li>
|
1140 |
+
* <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>
|
1141 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1142 |
+
*/
|
1143 |
+
public function describe_spot_price_history($opt = null)
|
1144 |
+
{
|
1145 |
+
if (!$opt) $opt = array();
|
1146 |
+
|
1147 |
+
// Optional parameter
|
1148 |
+
if (isset($opt['StartTime']))
|
1149 |
+
{
|
1150 |
+
$opt['StartTime'] = $this->util->convert_date_to_iso8601($opt['StartTime']);
|
1151 |
+
}
|
1152 |
+
|
1153 |
+
// Optional parameter
|
1154 |
+
if (isset($opt['EndTime']))
|
1155 |
+
{
|
1156 |
+
$opt['EndTime'] = $this->util->convert_date_to_iso8601($opt['EndTime']);
|
1157 |
+
}
|
1158 |
+
|
1159 |
+
// Optional parameter
|
1160 |
+
if (isset($opt['InstanceType']))
|
1161 |
+
{
|
1162 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1163 |
+
'InstanceType' => (is_array($opt['InstanceType']) ? $opt['InstanceType'] : array($opt['InstanceType']))
|
1164 |
+
)));
|
1165 |
+
unset($opt['InstanceType']);
|
1166 |
+
}
|
1167 |
+
|
1168 |
+
// Optional parameter
|
1169 |
+
if (isset($opt['ProductDescription']))
|
1170 |
+
{
|
1171 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1172 |
+
'ProductDescription' => (is_array($opt['ProductDescription']) ? $opt['ProductDescription'] : array($opt['ProductDescription']))
|
1173 |
+
)));
|
1174 |
+
unset($opt['ProductDescription']);
|
1175 |
+
}
|
1176 |
+
|
1177 |
+
// Optional parameter
|
1178 |
+
if (isset($opt['Filter']))
|
1179 |
+
{
|
1180 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1181 |
+
'Filter' => $opt['Filter']
|
1182 |
+
)));
|
1183 |
+
unset($opt['Filter']);
|
1184 |
+
}
|
1185 |
+
|
1186 |
+
return $this->authenticate('DescribeSpotPriceHistory', $opt, $this->hostname);
|
1187 |
+
}
|
1188 |
+
|
1189 |
+
/**
|
1190 |
+
*
|
1191 |
+
* The CreateSecurityGroup operation creates a new security group.
|
1192 |
+
*
|
1193 |
+
* Every instance is launched in a security group. If no security group is specified during launch, the instances are
|
1194 |
+
* launched in the default security group. Instances within the same security group have unrestricted network access to
|
1195 |
+
* each other. Instances will reject network access attempts from other instances in a different security group. As the
|
1196 |
+
* owner of instances you can grant or revoke specific permissions using the AuthorizeSecurityGroupIngress and
|
1197 |
+
* RevokeSecurityGroupIngress operations.
|
1198 |
+
*
|
1199 |
+
* @param string $group_name (Required) Name of the security group.
|
1200 |
+
* @param string $group_description (Required) Description of the group. This is informational only.
|
1201 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1202 |
+
* <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>
|
1203 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1204 |
+
*/
|
1205 |
+
public function create_security_group($group_name, $group_description, $opt = null)
|
1206 |
+
{
|
1207 |
+
if (!$opt) $opt = array();
|
1208 |
+
$opt['GroupName'] = $group_name;
|
1209 |
+
$opt['GroupDescription'] = $group_description;
|
1210 |
+
|
1211 |
+
return $this->authenticate('CreateSecurityGroup', $opt, $this->hostname);
|
1212 |
+
}
|
1213 |
+
|
1214 |
+
/**
|
1215 |
+
*
|
1216 |
+
* The DescribeRegions operation describes regions zones that are currently available to the account.
|
1217 |
+
*
|
1218 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1219 |
+
* <li><code>RegionName</code> - <code>string|array</code> - Optional - The optional list of regions to describe. Pass a string for a single value, or an indexed array for multiple values. </li>
|
1220 |
+
* <li><code>Filter</code> - <code>array</code> - Optional - A list of filters used to match properties for Regions. For a complete reference to the available filter keys for this operation, see the Amazon EC2 API reference. <ul>
|
1221 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
1222 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Specifies the name of the filter. </li>
|
1223 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
1224 |
+
* </ul></li>
|
1225 |
+
* </ul></li>
|
1226 |
+
* <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>
|
1227 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1228 |
+
*/
|
1229 |
+
public function describe_regions($opt = null)
|
1230 |
+
{
|
1231 |
+
if (!$opt) $opt = array();
|
1232 |
+
|
1233 |
+
// Optional parameter
|
1234 |
+
if (isset($opt['RegionName']))
|
1235 |
+
{
|
1236 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1237 |
+
'RegionName' => (is_array($opt['RegionName']) ? $opt['RegionName'] : array($opt['RegionName']))
|
1238 |
+
)));
|
1239 |
+
unset($opt['RegionName']);
|
1240 |
+
}
|
1241 |
+
|
1242 |
+
// Optional parameter
|
1243 |
+
if (isset($opt['Filter']))
|
1244 |
+
{
|
1245 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1246 |
+
'Filter' => $opt['Filter']
|
1247 |
+
)));
|
1248 |
+
unset($opt['Filter']);
|
1249 |
+
}
|
1250 |
+
|
1251 |
+
return $this->authenticate('DescribeRegions', $opt, $this->hostname);
|
1252 |
+
}
|
1253 |
+
|
1254 |
+
/**
|
1255 |
+
*
|
1256 |
+
* Creates a set of DHCP options that you can then associate with one or more VPCs, causing all existing and new instances
|
1257 |
+
* that you launch in those VPCs to use the set of DHCP options. The following table lists the individual DHCP options you
|
1258 |
+
* can specify. For more information about the options, go to http://www.ietf.org/rfc/rfc2132.txt
|
1259 |
+
*
|
1260 |
+
* @param array $dhcp_configuration (Required) A set of one or more DHCP configurations. <ul>
|
1261 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
1262 |
+
* <li><code>Key</code> - <code>string</code> - Optional - Contains the name of a DHCP option. </li>
|
1263 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains a set of values for a DHCP option. Pass a string for a single value, or an indexed array for multiple values. </li>
|
1264 |
+
* </ul></li>
|
1265 |
+
* </ul>
|
1266 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1267 |
+
* <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>
|
1268 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1269 |
+
*/
|
1270 |
+
public function create_dhcp_options($dhcp_configuration, $opt = null)
|
1271 |
+
{
|
1272 |
+
if (!$opt) $opt = array();
|
1273 |
+
|
1274 |
+
// Required parameter
|
1275 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1276 |
+
'DhcpConfiguration' => (is_array($dhcp_configuration) ? $dhcp_configuration : array($dhcp_configuration))
|
1277 |
+
)));
|
1278 |
+
|
1279 |
+
return $this->authenticate('CreateDhcpOptions', $opt, $this->hostname);
|
1280 |
+
}
|
1281 |
+
|
1282 |
+
/**
|
1283 |
+
*
|
1284 |
+
* Resets permission settings for the specified snapshot.
|
1285 |
+
*
|
1286 |
+
* @param string $snapshot_id (Required) The ID of the snapshot whose attribute is being reset.
|
1287 |
+
* @param string $attribute (Required) The name of the attribute being reset. Available attribute names: createVolumePermission
|
1288 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1289 |
+
* <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>
|
1290 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1291 |
+
*/
|
1292 |
+
public function reset_snapshot_attribute($snapshot_id, $attribute, $opt = null)
|
1293 |
+
{
|
1294 |
+
if (!$opt) $opt = array();
|
1295 |
+
$opt['SnapshotId'] = $snapshot_id;
|
1296 |
+
$opt['Attribute'] = $attribute;
|
1297 |
+
|
1298 |
+
return $this->authenticate('ResetSnapshotAttribute', $opt, $this->hostname);
|
1299 |
+
}
|
1300 |
+
|
1301 |
+
/**
|
1302 |
+
*
|
1303 |
+
* The DescribeSecurityGroups operation returns information about security groups that you own.
|
1304 |
+
*
|
1305 |
+
* If you specify security group names, information about those security group is returned. Otherwise, information for all
|
1306 |
+
* security group is returned. If you specify a group that does not exist, a fault is returned.
|
1307 |
+
*
|
1308 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1309 |
+
* <li><code>GroupName</code> - <code>string|array</code> - Optional - The optional list of Amazon EC2 security groups to describe. Pass a string for a single value, or an indexed array for multiple values. </li>
|
1310 |
+
* <li><code>Filter</code> - <code>array</code> - Optional - A list of filters used to match properties for SecurityGroups. For a complete reference to the available filter keys for this operation, see the Amazon EC2 API reference. <ul>
|
1311 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
1312 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Specifies the name of the filter. </li>
|
1313 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
1314 |
+
* </ul></li>
|
1315 |
+
* </ul></li>
|
1316 |
+
* <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>
|
1317 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1318 |
+
*/
|
1319 |
+
public function describe_security_groups($opt = null)
|
1320 |
+
{
|
1321 |
+
if (!$opt) $opt = array();
|
1322 |
+
|
1323 |
+
// Optional parameter
|
1324 |
+
if (isset($opt['GroupName']))
|
1325 |
+
{
|
1326 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1327 |
+
'GroupName' => (is_array($opt['GroupName']) ? $opt['GroupName'] : array($opt['GroupName']))
|
1328 |
+
)));
|
1329 |
+
unset($opt['GroupName']);
|
1330 |
+
}
|
1331 |
+
|
1332 |
+
// Optional parameter
|
1333 |
+
if (isset($opt['Filter']))
|
1334 |
+
{
|
1335 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1336 |
+
'Filter' => $opt['Filter']
|
1337 |
+
)));
|
1338 |
+
unset($opt['Filter']);
|
1339 |
+
}
|
1340 |
+
|
1341 |
+
return $this->authenticate('DescribeSecurityGroups', $opt, $this->hostname);
|
1342 |
+
}
|
1343 |
+
|
1344 |
+
/**
|
1345 |
+
*
|
1346 |
+
* Creates a Spot Instance request.
|
1347 |
+
*
|
1348 |
+
* Spot Instances are instances that Amazon EC2 starts on your behalf when the maximum price that you specify exceeds the
|
1349 |
+
* current Spot Price. Amazon EC2 periodically sets the Spot Price based on available Spot Instance capacity and current
|
1350 |
+
* spot instance requests.
|
1351 |
+
*
|
1352 |
+
* For conceptual information about Spot Instances, refer to the Amazon Elastic Compute Cloud Developer Guide or Amazon
|
1353 |
+
* Elastic Compute Cloud User Guide.
|
1354 |
+
*
|
1355 |
+
* @param string $spot_price (Required) Specifies the maximum hourly price for any Spot Instance launched to fulfill the request.
|
1356 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1357 |
+
* <li><code>InstanceCount</code> - <code>integer</code> - Optional - Specifies the maximum number of Spot Instances to launch. </li>
|
1358 |
+
* <li><code>Type</code> - <code>string</code> - Optional - Specifies the Spot Instance type. [Allowed values: <code>one-time</code>, <code>persistent</code>]</li>
|
1359 |
+
* <li><code>ValidFrom</code> - <code>string</code> - Optional - Defines the start date of the request. If this is a one-time request, the request becomes active at this date and time and remains active until all instances launch, the request expires, or the request is canceled. If the request is persistent, the request becomes active at this date and time and remains active until it expires or is canceled. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
1360 |
+
* <li><code>ValidUntil</code> - <code>string</code> - Optional - End date of the request. If this is a one-time request, the request remains active until all instances launch, the request is canceled, or this date is reached. If the request is persistent, it remains active until it is canceled or this date and time is reached. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
1361 |
+
* <li><code>LaunchGroup</code> - <code>string</code> - Optional - Specifies the instance launch group. Launch groups are Spot Instances that launch and terminate together. </li>
|
1362 |
+
* <li><code>AvailabilityZoneGroup</code> - <code>string</code> - Optional - Specifies the Availability Zone group. When specifying the same Availability Zone group for all Spot Instance requests, all Spot Instances are launched in the same Availability Zone. </li>
|
1363 |
+
* <li><code>LaunchSpecification</code> - <code>array</code> - Optional - Specifies additional launch instance information. <ul>
|
1364 |
+
* <li><code>ImageId</code> - <code>string</code> - Optional - The AMI ID. </li>
|
1365 |
+
* <li><code>KeyName</code> - <code>string</code> - Optional - The name of the key pair. </li>
|
1366 |
+
* <li><code>GroupSet</code> - <code>array</code> - Optional - <ul>
|
1367 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
1368 |
+
* <li><code>GroupId</code> - <code>string</code> - Optional - </li>
|
1369 |
+
* </ul></li>
|
1370 |
+
* </ul></li>
|
1371 |
+
* <li><code>SecurityGroup</code> - <code>string|array</code> - Optional - Pass a string for a single value, or an indexed array for multiple values. </li>
|
1372 |
+
* <li><code>UserData</code> - <code>string</code> - Optional - Optional data, specific to a user's application, to provide in the launch request. All instances that collectively comprise the launch request have access to this data. User data is never returned through API responses. </li>
|
1373 |
+
* <li><code>AddressingType</code> - <code>string</code> - Optional - Deprecated. </li>
|
1374 |
+
* <li><code>InstanceType</code> - <code>string</code> - Optional - Specifies the instance type. [Allowed values: <code>t1.micro</code>, <code>m1.small</code>, <code>m1.large</code>, <code>m1.xlarge</code>, <code>m2.xlarge</code>, <code>m2.2xlarge</code>, <code>m2.4xlarge</code>, <code>c1.medium</code>, <code>c1.xlarge</code>, <code>cc1.4xlarge</code>, <code>cg1.4xlarge</code>]</li>
|
1375 |
+
* <li><code>Placement</code> - <code>array</code> - Optional - Defines a placement item. Takes an associative array of parameters that can have the following keys: <ul>
|
1376 |
+
* <li><code>AvailabilityZone</code> - <code>string</code> - Optional - The availability zone in which an Amazon EC2 instance runs. </li>
|
1377 |
+
* <li><code>GroupName</code> - <code>string</code> - Optional - The name of a PlacementGroup. </li>
|
1378 |
+
* </ul></li>
|
1379 |
+
* <li><code>KernelId</code> - <code>string</code> - Optional - Specifies the ID of the kernel to select. </li>
|
1380 |
+
* <li><code>RamdiskId</code> - <code>string</code> - Optional - Specifies the ID of the RAM disk to select. Some kernels require additional drivers at launch. Check the kernel requirements for information on whether or not you need to specify a RAM disk and search for the kernel ID. </li>
|
1381 |
+
* <li><code>BlockDeviceMapping</code> - <code>array</code> - Optional - Specifies how block devices are exposed to the instance. Each mapping is made up of a virtualName and a deviceName. <ul>
|
1382 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
1383 |
+
* <li><code>VirtualName</code> - <code>string</code> - Optional - Specifies the virtual device name. </li>
|
1384 |
+
* <li><code>DeviceName</code> - <code>string</code> - Optional - Specifies the device name (e.g., /dev/sdh). </li>
|
1385 |
+
* <li><code>Ebs</code> - <code>array</code> - Optional - Specifies parameters used to automatically setup Amazon EBS volumes when the instance is launched. Takes an associative array of parameters that can have the following keys: <ul>
|
1386 |
+
* <li><code>SnapshotId</code> - <code>string</code> - Optional - The ID of the snapshot from which the volume will be created. </li>
|
1387 |
+
* <li><code>VolumeSize</code> - <code>integer</code> - Optional - The size of the volume, in gigabytes. </li>
|
1388 |
+
* <li><code>DeleteOnTermination</code> - <code>boolean</code> - Optional - Specifies whether the Amazon EBS volume is deleted on instance termination. </li>
|
1389 |
+
* </ul></li>
|
1390 |
+
* <li><code>NoDevice</code> - <code>string</code> - Optional - Specifies the device name to suppress during instance launch. </li>
|
1391 |
+
* </ul></li>
|
1392 |
+
* </ul></li>
|
1393 |
+
* <li><code>Monitoring.Enabled</code> - <code>boolean</code> - Optional - </li>
|
1394 |
+
* <li><code>SubnetId</code> - <code>string</code> - Optional - Specifies the Amazon VPC subnet ID within which to launch the instance(s) for Amazon Virtual Private Cloud. </li></ul></li>
|
1395 |
+
* <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>
|
1396 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1397 |
+
*/
|
1398 |
+
public function request_spot_instances($spot_price, $opt = null)
|
1399 |
+
{
|
1400 |
+
if (!$opt) $opt = array();
|
1401 |
+
$opt['SpotPrice'] = $spot_price;
|
1402 |
+
|
1403 |
+
// Optional parameter
|
1404 |
+
if (isset($opt['ValidFrom']))
|
1405 |
+
{
|
1406 |
+
$opt['ValidFrom'] = $this->util->convert_date_to_iso8601($opt['ValidFrom']);
|
1407 |
+
}
|
1408 |
+
|
1409 |
+
// Optional parameter
|
1410 |
+
if (isset($opt['ValidUntil']))
|
1411 |
+
{
|
1412 |
+
$opt['ValidUntil'] = $this->util->convert_date_to_iso8601($opt['ValidUntil']);
|
1413 |
+
}
|
1414 |
+
|
1415 |
+
// Optional parameter
|
1416 |
+
if (isset($opt['LaunchSpecification']))
|
1417 |
+
{
|
1418 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1419 |
+
'LaunchSpecification' => $opt['LaunchSpecification']
|
1420 |
+
)));
|
1421 |
+
unset($opt['LaunchSpecification']);
|
1422 |
+
}
|
1423 |
+
|
1424 |
+
return $this->authenticate('RequestSpotInstances', $opt, $this->hostname);
|
1425 |
+
}
|
1426 |
+
|
1427 |
+
/**
|
1428 |
+
*
|
1429 |
+
* Adds or overwrites tags for the specified resources. Each resource can have a maximum of 10 tags. Each tag consists of
|
1430 |
+
* a key-value pair. Tag keys must be unique per resource.
|
1431 |
+
*
|
1432 |
+
* @param string|array $resource_id (Required) One or more IDs of resources to tag. This could be the ID of an AMI, an instance, an EBS volume, or snapshot, etc. Pass a string for a single value, or an indexed array for multiple values.
|
1433 |
+
* @param array $tag (Required) The tags to add or overwrite for the specified resources. Each tag item consists of a key-value pair. <ul>
|
1434 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
1435 |
+
* <li><code>Key</code> - <code>string</code> - Optional - The tag's key. </li>
|
1436 |
+
* <li><code>Value</code> - <code>string</code> - Optional - The tag's value. </li>
|
1437 |
+
* </ul></li>
|
1438 |
+
* </ul>
|
1439 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1440 |
+
* <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>
|
1441 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1442 |
+
*/
|
1443 |
+
public function create_tags($resource_id, $tag, $opt = null)
|
1444 |
+
{
|
1445 |
+
if (!$opt) $opt = array();
|
1446 |
+
|
1447 |
+
// Required parameter
|
1448 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1449 |
+
'ResourceId' => (is_array($resource_id) ? $resource_id : array($resource_id))
|
1450 |
+
)));
|
1451 |
+
|
1452 |
+
// Required parameter
|
1453 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1454 |
+
'Tag' => (is_array($tag) ? $tag : array($tag))
|
1455 |
+
)));
|
1456 |
+
|
1457 |
+
return $this->authenticate('CreateTags', $opt, $this->hostname);
|
1458 |
+
}
|
1459 |
+
|
1460 |
+
/**
|
1461 |
+
*
|
1462 |
+
* Detaches a VPN gateway from a VPC. You do this if you're planning to turn off the VPC and not use it anymore. You can
|
1463 |
+
* confirm a VPN gateway has been completely detached from a VPC by describing the VPN gateway (any attachments to the VPN
|
1464 |
+
* gateway are also described).
|
1465 |
+
*
|
1466 |
+
* You must wait for the attachment's state to switch to detached before you can delete the VPC or attach a different VPC
|
1467 |
+
* to the VPN gateway.
|
1468 |
+
*
|
1469 |
+
* @param string $vpn_gateway_id (Required) The ID of the VPN gateway to detach from the VPC.
|
1470 |
+
* @param string $vpc_id (Required) The ID of the VPC to detach the VPN gateway from.
|
1471 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1472 |
+
* <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>
|
1473 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1474 |
+
*/
|
1475 |
+
public function detach_vpn_gateway($vpn_gateway_id, $vpc_id, $opt = null)
|
1476 |
+
{
|
1477 |
+
if (!$opt) $opt = array();
|
1478 |
+
$opt['VpnGatewayId'] = $vpn_gateway_id;
|
1479 |
+
$opt['VpcId'] = $vpc_id;
|
1480 |
+
|
1481 |
+
return $this->authenticate('DetachVpnGateway', $opt, $this->hostname);
|
1482 |
+
}
|
1483 |
+
|
1484 |
+
/**
|
1485 |
+
*
|
1486 |
+
* The DeregisterImage operation deregisters an AMI. Once deregistered, instances of the AMI can no longer be launched.
|
1487 |
+
*
|
1488 |
+
* @param string $image_id (Required) The ID of the AMI to deregister.
|
1489 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1490 |
+
* <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>
|
1491 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1492 |
+
*/
|
1493 |
+
public function deregister_image($image_id, $opt = null)
|
1494 |
+
{
|
1495 |
+
if (!$opt) $opt = array();
|
1496 |
+
$opt['ImageId'] = $image_id;
|
1497 |
+
|
1498 |
+
return $this->authenticate('DeregisterImage', $opt, $this->hostname);
|
1499 |
+
}
|
1500 |
+
|
1501 |
+
/**
|
1502 |
+
*
|
1503 |
+
* Describes the data feed for Spot Instances.
|
1504 |
+
*
|
1505 |
+
* For conceptual information about Spot Instances, refer to the Amazon Elastic Compute Cloud Developer Guide or Amazon
|
1506 |
+
* Elastic Compute Cloud User Guide.
|
1507 |
+
*
|
1508 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1509 |
+
* <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>
|
1510 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1511 |
+
*/
|
1512 |
+
public function describe_spot_datafeed_subscription($opt = null)
|
1513 |
+
{
|
1514 |
+
if (!$opt) $opt = array();
|
1515 |
+
|
1516 |
+
return $this->authenticate('DescribeSpotDatafeedSubscription', $opt, $this->hostname);
|
1517 |
+
}
|
1518 |
+
|
1519 |
+
/**
|
1520 |
+
*
|
1521 |
+
* Deletes tags from the specified Amazon EC2 resources.
|
1522 |
+
*
|
1523 |
+
* @param string|array $resource_id (Required) A list of one or more resource IDs. This could be the ID of an AMI, an instance, an EBS volume, or snapshot, etc. Pass a string for a single value, or an indexed array for multiple values.
|
1524 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1525 |
+
* <li><code>Tag</code> - <code>array</code> - Optional - The tags to delete from the specified resources. Each tag item consists of a key-value pair. If a tag is specified without a value, the tag and all of its values are deleted. <ul>
|
1526 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
1527 |
+
* <li><code>Key</code> - <code>string</code> - Optional - The tag's key. </li>
|
1528 |
+
* <li><code>Value</code> - <code>string</code> - Optional - The tag's value. </li>
|
1529 |
+
* </ul></li>
|
1530 |
+
* </ul></li>
|
1531 |
+
* <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>
|
1532 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1533 |
+
*/
|
1534 |
+
public function delete_tags($resource_id, $opt = null)
|
1535 |
+
{
|
1536 |
+
if (!$opt) $opt = array();
|
1537 |
+
|
1538 |
+
// Required parameter
|
1539 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1540 |
+
'ResourceId' => (is_array($resource_id) ? $resource_id : array($resource_id))
|
1541 |
+
)));
|
1542 |
+
|
1543 |
+
// Optional parameter
|
1544 |
+
if (isset($opt['Tag']))
|
1545 |
+
{
|
1546 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1547 |
+
'Tag' => $opt['Tag']
|
1548 |
+
)));
|
1549 |
+
unset($opt['Tag']);
|
1550 |
+
}
|
1551 |
+
|
1552 |
+
return $this->authenticate('DeleteTags', $opt, $this->hostname);
|
1553 |
+
}
|
1554 |
+
|
1555 |
+
/**
|
1556 |
+
*
|
1557 |
+
* Describes the tags for the specified resources.
|
1558 |
+
*
|
1559 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1560 |
+
* <li><code>Filter</code> - <code>array</code> - Optional - A list of filters used to match properties for tags. <ul>
|
1561 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
1562 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Specifies the name of the filter. </li>
|
1563 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
1564 |
+
* </ul></li>
|
1565 |
+
* </ul></li>
|
1566 |
+
* <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>
|
1567 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1568 |
+
*/
|
1569 |
+
public function describe_tags($opt = null)
|
1570 |
+
{
|
1571 |
+
if (!$opt) $opt = array();
|
1572 |
+
|
1573 |
+
// Optional parameter
|
1574 |
+
if (isset($opt['Filter']))
|
1575 |
+
{
|
1576 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1577 |
+
'Filter' => $opt['Filter']
|
1578 |
+
)));
|
1579 |
+
unset($opt['Filter']);
|
1580 |
+
}
|
1581 |
+
|
1582 |
+
return $this->authenticate('DescribeTags', $opt, $this->hostname);
|
1583 |
+
}
|
1584 |
+
|
1585 |
+
/**
|
1586 |
+
*
|
1587 |
+
* Deletes a subnet from a VPC. You must terminate all running instances in the subnet before deleting it, otherwise
|
1588 |
+
* Amazon VPC returns an error.
|
1589 |
+
*
|
1590 |
+
* @param string $subnet_id (Required) The ID of the subnet you want to delete.
|
1591 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1592 |
+
* <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>
|
1593 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1594 |
+
*/
|
1595 |
+
public function delete_subnet($subnet_id, $opt = null)
|
1596 |
+
{
|
1597 |
+
if (!$opt) $opt = array();
|
1598 |
+
$opt['SubnetId'] = $subnet_id;
|
1599 |
+
|
1600 |
+
return $this->authenticate('DeleteSubnet', $opt, $this->hostname);
|
1601 |
+
}
|
1602 |
+
|
1603 |
+
/**
|
1604 |
+
*
|
1605 |
+
* Creates a new VPN gateway. A VPN gateway is the VPC-side endpoint for your VPN connection. You can create a VPN gateway
|
1606 |
+
* before creating the VPC itself.
|
1607 |
+
*
|
1608 |
+
* @param string $type (Required) The type of VPN connection this VPN gateway supports.
|
1609 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1610 |
+
* <li><code>AvailabilityZone</code> - <code>string</code> - Optional - The Availability Zone in which to create the VPN gateway. </li>
|
1611 |
+
* <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>
|
1612 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1613 |
+
*/
|
1614 |
+
public function create_vpn_gateway($type, $opt = null)
|
1615 |
+
{
|
1616 |
+
if (!$opt) $opt = array();
|
1617 |
+
$opt['Type'] = $type;
|
1618 |
+
|
1619 |
+
return $this->authenticate('CreateVpnGateway', $opt, $this->hostname);
|
1620 |
+
}
|
1621 |
+
|
1622 |
+
/**
|
1623 |
+
*
|
1624 |
+
* CancelBundleTask operation cancels a pending or in-progress bundling task. This is an asynchronous call and it make
|
1625 |
+
* take a while for the task to be canceled. If a task is canceled while it is storing items, there may be parts of the
|
1626 |
+
* incomplete AMI stored in S3. It is up to the caller to clean up these parts from S3.
|
1627 |
+
*
|
1628 |
+
* @param string $bundle_id (Required) The ID of the bundle task to cancel.
|
1629 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1630 |
+
* <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>
|
1631 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1632 |
+
*/
|
1633 |
+
public function cancel_bundle_task($bundle_id, $opt = null)
|
1634 |
+
{
|
1635 |
+
if (!$opt) $opt = array();
|
1636 |
+
$opt['BundleId'] = $bundle_id;
|
1637 |
+
|
1638 |
+
return $this->authenticate('CancelBundleTask', $opt, $this->hostname);
|
1639 |
+
}
|
1640 |
+
|
1641 |
+
/**
|
1642 |
+
*
|
1643 |
+
* Deletes a VPN gateway. Use this when you want to delete a VPC and all its associated components because you no longer
|
1644 |
+
* need them. We recommend that before you delete a VPN gateway, you detach it from the VPC and delete the VPN connection.
|
1645 |
+
* Note that you don't need to delete the VPN gateway if you just want to delete and re-create the VPN connection between
|
1646 |
+
* your VPC and data center.
|
1647 |
+
*
|
1648 |
+
* @param string $vpn_gateway_id (Required) The ID of the VPN gateway to delete.
|
1649 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1650 |
+
* <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>
|
1651 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1652 |
+
*/
|
1653 |
+
public function delete_vpn_gateway($vpn_gateway_id, $opt = null)
|
1654 |
+
{
|
1655 |
+
if (!$opt) $opt = array();
|
1656 |
+
$opt['VpnGatewayId'] = $vpn_gateway_id;
|
1657 |
+
|
1658 |
+
return $this->authenticate('DeleteVpnGateway', $opt, $this->hostname);
|
1659 |
+
}
|
1660 |
+
|
1661 |
+
/**
|
1662 |
+
*
|
1663 |
+
* Cancels one or more Spot Instance requests.
|
1664 |
+
*
|
1665 |
+
* Spot Instances are instances that Amazon EC2 starts on your behalf when the maximum price that you specify exceeds the
|
1666 |
+
* current Spot Price. Amazon EC2 periodically sets the Spot Price based on available Spot Instance capacity and current
|
1667 |
+
* spot instance requests.
|
1668 |
+
*
|
1669 |
+
* For conceptual information about Spot Instances, refer to the Amazon Elastic Compute Cloud Developer Guide or Amazon
|
1670 |
+
* Elastic Compute Cloud User Guide.
|
1671 |
+
*
|
1672 |
+
* @param string|array $spot_instance_request_id (Required) Specifies the ID of the Spot Instance request. Pass a string for a single value, or an indexed array for multiple values.
|
1673 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1674 |
+
* <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>
|
1675 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1676 |
+
*/
|
1677 |
+
public function cancel_spot_instance_requests($spot_instance_request_id, $opt = null)
|
1678 |
+
{
|
1679 |
+
if (!$opt) $opt = array();
|
1680 |
+
|
1681 |
+
// Required parameter
|
1682 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1683 |
+
'SpotInstanceRequestId' => (is_array($spot_instance_request_id) ? $spot_instance_request_id : array($spot_instance_request_id))
|
1684 |
+
)));
|
1685 |
+
|
1686 |
+
return $this->authenticate('CancelSpotInstanceRequests', $opt, $this->hostname);
|
1687 |
+
}
|
1688 |
+
|
1689 |
+
/**
|
1690 |
+
*
|
1691 |
+
* Attach a previously created volume to a running instance.
|
1692 |
+
*
|
1693 |
+
* @param string $volume_id (Required) The ID of the Amazon EBS volume. The volume and instance must be within the same Availability Zone and the instance must be running.
|
1694 |
+
* @param string $instance_id (Required) The ID of the instance to which the volume attaches. The volume and instance must be within the same Availability Zone and the instance must be running.
|
1695 |
+
* @param string $device (Required) Specifies how the device is exposed to the instance (e.g., /dev/sdh).
|
1696 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1697 |
+
* <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>
|
1698 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1699 |
+
*/
|
1700 |
+
public function attach_volume($volume_id, $instance_id, $device, $opt = null)
|
1701 |
+
{
|
1702 |
+
if (!$opt) $opt = array();
|
1703 |
+
$opt['VolumeId'] = $volume_id;
|
1704 |
+
$opt['InstanceId'] = $instance_id;
|
1705 |
+
$opt['Device'] = $device;
|
1706 |
+
|
1707 |
+
return $this->authenticate('AttachVolume', $opt, $this->hostname);
|
1708 |
+
}
|
1709 |
+
|
1710 |
+
/**
|
1711 |
+
*
|
1712 |
+
* Provides details of a user's registered licenses. Zero or more IDs may be specified on the call. When one or more
|
1713 |
+
* license IDs are specified, only data for the specified IDs are returned.
|
1714 |
+
*
|
1715 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1716 |
+
* <li><code>LicenseId</code> - <code>string|array</code> - Optional - Specifies the license registration for which details are to be returned. Pass a string for a single value, or an indexed array for multiple values. </li>
|
1717 |
+
* <li><code>Filter</code> - <code>array</code> - Optional - A list of filters used to match properties for Licenses. For a complete reference to the available filter keys for this operation, see the Amazon EC2 API reference. <ul>
|
1718 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
1719 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Specifies the name of the filter. </li>
|
1720 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
1721 |
+
* </ul></li>
|
1722 |
+
* </ul></li>
|
1723 |
+
* <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>
|
1724 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1725 |
+
*/
|
1726 |
+
public function describe_licenses($opt = null)
|
1727 |
+
{
|
1728 |
+
if (!$opt) $opt = array();
|
1729 |
+
|
1730 |
+
// Optional parameter
|
1731 |
+
if (isset($opt['LicenseId']))
|
1732 |
+
{
|
1733 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1734 |
+
'LicenseId' => (is_array($opt['LicenseId']) ? $opt['LicenseId'] : array($opt['LicenseId']))
|
1735 |
+
)));
|
1736 |
+
unset($opt['LicenseId']);
|
1737 |
+
}
|
1738 |
+
|
1739 |
+
// Optional parameter
|
1740 |
+
if (isset($opt['Filter']))
|
1741 |
+
{
|
1742 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1743 |
+
'Filter' => $opt['Filter']
|
1744 |
+
)));
|
1745 |
+
unset($opt['Filter']);
|
1746 |
+
}
|
1747 |
+
|
1748 |
+
return $this->authenticate('DescribeLicenses', $opt, $this->hostname);
|
1749 |
+
}
|
1750 |
+
|
1751 |
+
/**
|
1752 |
+
*
|
1753 |
+
* The PurchaseReservedInstancesOffering operation purchases a Reserved Instance for use with your account. With Amazon
|
1754 |
+
* EC2 Reserved Instances, you purchase the right to launch Amazon EC2 instances for a period of time (without getting
|
1755 |
+
* insufficient capacity errors) and pay a lower usage rate for the actual time used.
|
1756 |
+
*
|
1757 |
+
* @param string $reserved_instances_offering_id (Required) The unique ID of the Reserved Instances offering being purchased.
|
1758 |
+
* @param integer $instance_count (Required) The number of Reserved Instances to purchase.
|
1759 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1760 |
+
* <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>
|
1761 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1762 |
+
*/
|
1763 |
+
public function purchase_reserved_instances_offering($reserved_instances_offering_id, $instance_count, $opt = null)
|
1764 |
+
{
|
1765 |
+
if (!$opt) $opt = array();
|
1766 |
+
$opt['ReservedInstancesOfferingId'] = $reserved_instances_offering_id;
|
1767 |
+
$opt['InstanceCount'] = $instance_count;
|
1768 |
+
|
1769 |
+
return $this->authenticate('PurchaseReservedInstancesOffering', $opt, $this->hostname);
|
1770 |
+
}
|
1771 |
+
|
1772 |
+
/**
|
1773 |
+
*
|
1774 |
+
* Activates a specific number of licenses for a 90-day period. Activations can be done against a specific license ID.
|
1775 |
+
*
|
1776 |
+
* @param string $license_id (Required) Specifies the ID for the specific license to activate against.
|
1777 |
+
* @param integer $capacity (Required) Specifies the additional number of licenses to activate.
|
1778 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1779 |
+
* <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>
|
1780 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1781 |
+
*/
|
1782 |
+
public function activate_license($license_id, $capacity, $opt = null)
|
1783 |
+
{
|
1784 |
+
if (!$opt) $opt = array();
|
1785 |
+
$opt['LicenseId'] = $license_id;
|
1786 |
+
$opt['Capacity'] = $capacity;
|
1787 |
+
|
1788 |
+
return $this->authenticate('ActivateLicense', $opt, $this->hostname);
|
1789 |
+
}
|
1790 |
+
|
1791 |
+
/**
|
1792 |
+
*
|
1793 |
+
* The ResetImageAttribute operation resets an attribute of an AMI to its default value.
|
1794 |
+
*
|
1795 |
+
* The productCodes attribute cannot be reset.
|
1796 |
+
*
|
1797 |
+
* @param string $image_id (Required) The ID of the AMI whose attribute is being reset.
|
1798 |
+
* @param string $attribute (Required) The name of the attribute being reset. Available attribute names: launchPermission
|
1799 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1800 |
+
* <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>
|
1801 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1802 |
+
*/
|
1803 |
+
public function reset_image_attribute($image_id, $attribute, $opt = null)
|
1804 |
+
{
|
1805 |
+
if (!$opt) $opt = array();
|
1806 |
+
$opt['ImageId'] = $image_id;
|
1807 |
+
$opt['Attribute'] = $attribute;
|
1808 |
+
|
1809 |
+
return $this->authenticate('ResetImageAttribute', $opt, $this->hostname);
|
1810 |
+
}
|
1811 |
+
|
1812 |
+
/**
|
1813 |
+
*
|
1814 |
+
* Gives you information about your VPN connections.
|
1815 |
+
*
|
1816 |
+
* We strongly recommend you use HTTPS when calling this operation because the response contains sensitive cryptographic
|
1817 |
+
* information for configuring your customer gateway.
|
1818 |
+
*
|
1819 |
+
* You can filter the results to return information only about VPN connections that match criteria you specify. For
|
1820 |
+
* example, you could ask to get information about a particular VPN connection (or all) only if the VPN's state is pending
|
1821 |
+
* or available. You can specify multiple filters (e.g., the VPN connection is associated with a particular VPN gateway,
|
1822 |
+
* and the gateway's state is pending or available). The result includes information for a particular VPN connection only
|
1823 |
+
* if the VPN connection matches all your filters. If there's no match, no special message is returned; the response is
|
1824 |
+
* simply empty. The following table shows the available filters.
|
1825 |
+
*
|
1826 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1827 |
+
* <li><code>VpnConnectionId</code> - <code>string|array</code> - Optional - A VPN connection ID. More than one may be specified per request. Pass a string for a single value, or an indexed array for multiple values. </li>
|
1828 |
+
* <li><code>Filter</code> - <code>array</code> - Optional - <ul>
|
1829 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
1830 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Specifies the name of the filter. </li>
|
1831 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
1832 |
+
* </ul></li>
|
1833 |
+
* </ul></li>
|
1834 |
+
* <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>
|
1835 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1836 |
+
*/
|
1837 |
+
public function describe_vpn_connections($opt = null)
|
1838 |
+
{
|
1839 |
+
if (!$opt) $opt = array();
|
1840 |
+
|
1841 |
+
// Optional parameter
|
1842 |
+
if (isset($opt['VpnConnectionId']))
|
1843 |
+
{
|
1844 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1845 |
+
'VpnConnectionId' => (is_array($opt['VpnConnectionId']) ? $opt['VpnConnectionId'] : array($opt['VpnConnectionId']))
|
1846 |
+
)));
|
1847 |
+
unset($opt['VpnConnectionId']);
|
1848 |
+
}
|
1849 |
+
|
1850 |
+
// Optional parameter
|
1851 |
+
if (isset($opt['Filter']))
|
1852 |
+
{
|
1853 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1854 |
+
'Filter' => $opt['Filter']
|
1855 |
+
)));
|
1856 |
+
unset($opt['Filter']);
|
1857 |
+
}
|
1858 |
+
|
1859 |
+
return $this->authenticate('DescribeVpnConnections', $opt, $this->hostname);
|
1860 |
+
}
|
1861 |
+
|
1862 |
+
/**
|
1863 |
+
*
|
1864 |
+
* Create a snapshot of the volume identified by volume ID. A volume does not have to be detached at the time the snapshot
|
1865 |
+
* is taken.
|
1866 |
+
*
|
1867 |
+
* Snapshot creation requires that the system is in a consistent state. For instance, this means that if taking a snapshot
|
1868 |
+
* of a database, the tables must be read-only locked to ensure that the snapshot will not contain a corrupted version of
|
1869 |
+
* the database. Therefore, be careful when using this API to ensure that the system remains in the consistent state until
|
1870 |
+
* the create snapshot status has returned.
|
1871 |
+
*
|
1872 |
+
* @param string $volume_id (Required) The ID of the volume from which to create the snapshot.
|
1873 |
+
* @param string $description (Required) The description for the new snapshot.
|
1874 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1875 |
+
* <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>
|
1876 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1877 |
+
*/
|
1878 |
+
public function create_snapshot($volume_id, $description, $opt = null)
|
1879 |
+
{
|
1880 |
+
if (!$opt) $opt = array();
|
1881 |
+
$opt['VolumeId'] = $volume_id;
|
1882 |
+
$opt['Description'] = $description;
|
1883 |
+
|
1884 |
+
return $this->authenticate('CreateSnapshot', $opt, $this->hostname);
|
1885 |
+
}
|
1886 |
+
|
1887 |
+
/**
|
1888 |
+
*
|
1889 |
+
* Deletes a previously created volume. Once successfully deleted, a new volume can be created with the same name.
|
1890 |
+
*
|
1891 |
+
* @param string $volume_id (Required) The ID of the EBS volume to delete.
|
1892 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1893 |
+
* <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>
|
1894 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1895 |
+
*/
|
1896 |
+
public function delete_volume($volume_id, $opt = null)
|
1897 |
+
{
|
1898 |
+
if (!$opt) $opt = array();
|
1899 |
+
$opt['VolumeId'] = $volume_id;
|
1900 |
+
|
1901 |
+
return $this->authenticate('DeleteVolume', $opt, $this->hostname);
|
1902 |
+
}
|
1903 |
+
|
1904 |
+
/**
|
1905 |
+
*
|
1906 |
+
* Adds or remove permission settings for the specified snapshot.
|
1907 |
+
*
|
1908 |
+
* @param string $snapshot_id (Required) The ID of the EBS snapshot whose attributes are being modified.
|
1909 |
+
* @param string $attribute (Required) The name of the attribute being modified. Available attribute names: createVolumePermission
|
1910 |
+
* @param string $operation_type (Required) The operation to perform on the attribute. Available operation names: add, remove
|
1911 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1912 |
+
* <li><code>UserId</code> - <code>string|array</code> - Optional - The AWS user IDs to add to or remove from the list of users that have permission to create EBS volumes from the specified snapshot. Currently supports "all". Only valid when the createVolumePermission attribute is being modified. Pass a string for a single value, or an indexed array for multiple values. </li>
|
1913 |
+
* <li><code>UserGroup</code> - <code>string|array</code> - Optional - The AWS group names to add to or remove from the list of groups that have permission to create EBS volumes from the specified snapshot. Currently supports "all". Only valid when the <code>createVolumePermission</code> attribute is being modified. Pass a string for a single value, or an indexed array for multiple values. </li>
|
1914 |
+
* <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>
|
1915 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1916 |
+
*/
|
1917 |
+
public function modify_snapshot_attribute($snapshot_id, $attribute, $operation_type, $opt = null)
|
1918 |
+
{
|
1919 |
+
if (!$opt) $opt = array();
|
1920 |
+
$opt['SnapshotId'] = $snapshot_id;
|
1921 |
+
$opt['Attribute'] = $attribute;
|
1922 |
+
$opt['OperationType'] = $operation_type;
|
1923 |
+
|
1924 |
+
// Optional parameter
|
1925 |
+
if (isset($opt['UserId']))
|
1926 |
+
{
|
1927 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1928 |
+
'UserId' => (is_array($opt['UserId']) ? $opt['UserId'] : array($opt['UserId']))
|
1929 |
+
)));
|
1930 |
+
unset($opt['UserId']);
|
1931 |
+
}
|
1932 |
+
|
1933 |
+
// Optional parameter
|
1934 |
+
if (isset($opt['UserGroup']))
|
1935 |
+
{
|
1936 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1937 |
+
'UserGroup' => (is_array($opt['UserGroup']) ? $opt['UserGroup'] : array($opt['UserGroup']))
|
1938 |
+
)));
|
1939 |
+
unset($opt['UserGroup']);
|
1940 |
+
}
|
1941 |
+
|
1942 |
+
return $this->authenticate('ModifySnapshotAttribute', $opt, $this->hostname);
|
1943 |
+
}
|
1944 |
+
|
1945 |
+
/**
|
1946 |
+
*
|
1947 |
+
* The TerminateInstances operation shuts down one or more instances. This operation is idempotent; if you terminate an
|
1948 |
+
* instance more than once, each call will succeed.
|
1949 |
+
*
|
1950 |
+
* Terminated instances will remain visible after termination (approximately one hour).
|
1951 |
+
*
|
1952 |
+
* @param string|array $instance_id (Required) The list of instances to terminate. Pass a string for a single value, or an indexed array for multiple values.
|
1953 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1954 |
+
* <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>
|
1955 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1956 |
+
*/
|
1957 |
+
public function terminate_instances($instance_id, $opt = null)
|
1958 |
+
{
|
1959 |
+
if (!$opt) $opt = array();
|
1960 |
+
|
1961 |
+
// Required parameter
|
1962 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1963 |
+
'InstanceId' => (is_array($instance_id) ? $instance_id : array($instance_id))
|
1964 |
+
)));
|
1965 |
+
|
1966 |
+
return $this->authenticate('TerminateInstances', $opt, $this->hostname);
|
1967 |
+
}
|
1968 |
+
|
1969 |
+
/**
|
1970 |
+
*
|
1971 |
+
* Deletes the data feed for Spot Instances.
|
1972 |
+
*
|
1973 |
+
* For conceptual information about Spot Instances, refer to the Amazon Elastic Compute Cloud Developer Guide or Amazon
|
1974 |
+
* Elastic Compute Cloud User Guide.
|
1975 |
+
*
|
1976 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1977 |
+
* <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>
|
1978 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1979 |
+
*/
|
1980 |
+
public function delete_spot_datafeed_subscription($opt = null)
|
1981 |
+
{
|
1982 |
+
if (!$opt) $opt = array();
|
1983 |
+
|
1984 |
+
return $this->authenticate('DeleteSpotDatafeedSubscription', $opt, $this->hostname);
|
1985 |
+
}
|
1986 |
+
|
1987 |
+
/**
|
1988 |
+
*
|
1989 |
+
* Gives you information about your VPCs. You can filter the results to return information only about VPCs that match
|
1990 |
+
* criteria you specify. For example, you could ask to get information about a particular VPC or VPCs (or all your VPCs)
|
1991 |
+
* only if the VPC's state is available. You can specify multiple filters (e.g., the VPC uses one of several sets of DHCP
|
1992 |
+
* options, and the VPC's state is available). The result includes information for a particular VPC only if the VPC matches
|
1993 |
+
* all your filters. If there's no match, no special message is returned; the response is simply empty. The following table
|
1994 |
+
* shows the available filters.
|
1995 |
+
*
|
1996 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1997 |
+
* <li><code>VpcId</code> - <code>string|array</code> - Optional - A set of one or more IDs of VPCs to describe. Pass a string for a single value, or an indexed array for multiple values. </li>
|
1998 |
+
* <li><code>Filter</code> - <code>array</code> - Optional - <ul>
|
1999 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
2000 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Specifies the name of the filter. </li>
|
2001 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
2002 |
+
* </ul></li>
|
2003 |
+
* </ul></li>
|
2004 |
+
* <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>
|
2005 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2006 |
+
*/
|
2007 |
+
public function describe_vpcs($opt = null)
|
2008 |
+
{
|
2009 |
+
if (!$opt) $opt = array();
|
2010 |
+
|
2011 |
+
// Optional parameter
|
2012 |
+
if (isset($opt['VpcId']))
|
2013 |
+
{
|
2014 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2015 |
+
'VpcId' => (is_array($opt['VpcId']) ? $opt['VpcId'] : array($opt['VpcId']))
|
2016 |
+
)));
|
2017 |
+
unset($opt['VpcId']);
|
2018 |
+
}
|
2019 |
+
|
2020 |
+
// Optional parameter
|
2021 |
+
if (isset($opt['Filter']))
|
2022 |
+
{
|
2023 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2024 |
+
'Filter' => $opt['Filter']
|
2025 |
+
)));
|
2026 |
+
unset($opt['Filter']);
|
2027 |
+
}
|
2028 |
+
|
2029 |
+
return $this->authenticate('DescribeVpcs', $opt, $this->hostname);
|
2030 |
+
}
|
2031 |
+
|
2032 |
+
/**
|
2033 |
+
*
|
2034 |
+
* The AssociateAddress operation associates an elastic IP address with an instance.
|
2035 |
+
*
|
2036 |
+
* If the IP address is currently assigned to another instance, the IP address is assigned to the new instance. This is an
|
2037 |
+
* idempotent operation. If you enter it more than once, Amazon EC2 does not return an error.
|
2038 |
+
*
|
2039 |
+
* @param string $instance_id (Required) The instance to associate with the IP address.
|
2040 |
+
* @param string $public_ip (Required) IP address that you are assigning to the instance.
|
2041 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2042 |
+
* <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>
|
2043 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2044 |
+
*/
|
2045 |
+
public function associate_address($instance_id, $public_ip, $opt = null)
|
2046 |
+
{
|
2047 |
+
if (!$opt) $opt = array();
|
2048 |
+
$opt['InstanceId'] = $instance_id;
|
2049 |
+
$opt['PublicIp'] = $public_ip;
|
2050 |
+
|
2051 |
+
return $this->authenticate('AssociateAddress', $opt, $this->hostname);
|
2052 |
+
}
|
2053 |
+
|
2054 |
+
/**
|
2055 |
+
*
|
2056 |
+
* Deactivates a specific number of licenses. Deactivations can be done against a specific license ID after they have
|
2057 |
+
* persisted for at least a 90-day period.
|
2058 |
+
*
|
2059 |
+
* @param string $license_id (Required) Specifies the ID for the specific license to deactivate against.
|
2060 |
+
* @param integer $capacity (Required) Specifies the amount of capacity to deactivate against the license.
|
2061 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2062 |
+
* <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>
|
2063 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2064 |
+
*/
|
2065 |
+
public function deactivate_license($license_id, $capacity, $opt = null)
|
2066 |
+
{
|
2067 |
+
if (!$opt) $opt = array();
|
2068 |
+
$opt['LicenseId'] = $license_id;
|
2069 |
+
$opt['Capacity'] = $capacity;
|
2070 |
+
|
2071 |
+
return $this->authenticate('DeactivateLicense', $opt, $this->hostname);
|
2072 |
+
}
|
2073 |
+
|
2074 |
+
/**
|
2075 |
+
*
|
2076 |
+
* Returns information about an attribute of a snapshot. Only one attribute can be specified per call.
|
2077 |
+
*
|
2078 |
+
* @param string $snapshot_id (Required) The ID of the EBS snapshot whose attribute is being described.
|
2079 |
+
* @param string $attribute (Required) The name of the EBS attribute to describe. Available attribute names: createVolumePermission
|
2080 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2081 |
+
* <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>
|
2082 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2083 |
+
*/
|
2084 |
+
public function describe_snapshot_attribute($snapshot_id, $attribute, $opt = null)
|
2085 |
+
{
|
2086 |
+
if (!$opt) $opt = array();
|
2087 |
+
$opt['SnapshotId'] = $snapshot_id;
|
2088 |
+
$opt['Attribute'] = $attribute;
|
2089 |
+
|
2090 |
+
return $this->authenticate('DescribeSnapshotAttribute', $opt, $this->hostname);
|
2091 |
+
}
|
2092 |
+
|
2093 |
+
/**
|
2094 |
+
*
|
2095 |
+
* Deletes a customer gateway. You must delete the VPN connection before deleting the customer gateway.
|
2096 |
+
*
|
2097 |
+
* You can have a single active customer gateway per AWS account (active means that you've created a VPN connection with
|
2098 |
+
* that customer gateway). AWS might delete any customer gateway you leave inactive for an extended period of time.
|
2099 |
+
*
|
2100 |
+
* @param string $customer_gateway_id (Required) The ID of the customer gateway to delete.
|
2101 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2102 |
+
* <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>
|
2103 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2104 |
+
*/
|
2105 |
+
public function delete_customer_gateway($customer_gateway_id, $opt = null)
|
2106 |
+
{
|
2107 |
+
if (!$opt) $opt = array();
|
2108 |
+
$opt['CustomerGatewayId'] = $customer_gateway_id;
|
2109 |
+
|
2110 |
+
return $this->authenticate('DeleteCustomerGateway', $opt, $this->hostname);
|
2111 |
+
}
|
2112 |
+
|
2113 |
+
/**
|
2114 |
+
*
|
2115 |
+
* The DescribeAddresses operation lists elastic IP addresses assigned to your account.
|
2116 |
+
*
|
2117 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2118 |
+
* <li><code>PublicIp</code> - <code>string|array</code> - Optional - The optional list of Elastic IP addresses to describe. Pass a string for a single value, or an indexed array for multiple values. </li>
|
2119 |
+
* <li><code>Filter</code> - <code>array</code> - Optional - A list of filters used to match properties for Addresses. For a complete reference to the available filter keys for this operation, see the Amazon EC2 API reference. <ul>
|
2120 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
2121 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Specifies the name of the filter. </li>
|
2122 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
2123 |
+
* </ul></li>
|
2124 |
+
* </ul></li>
|
2125 |
+
* <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>
|
2126 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2127 |
+
*/
|
2128 |
+
public function describe_addresses($opt = null)
|
2129 |
+
{
|
2130 |
+
if (!$opt) $opt = array();
|
2131 |
+
|
2132 |
+
// Optional parameter
|
2133 |
+
if (isset($opt['PublicIp']))
|
2134 |
+
{
|
2135 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2136 |
+
'PublicIp' => (is_array($opt['PublicIp']) ? $opt['PublicIp'] : array($opt['PublicIp']))
|
2137 |
+
)));
|
2138 |
+
unset($opt['PublicIp']);
|
2139 |
+
}
|
2140 |
+
|
2141 |
+
// Optional parameter
|
2142 |
+
if (isset($opt['Filter']))
|
2143 |
+
{
|
2144 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2145 |
+
'Filter' => $opt['Filter']
|
2146 |
+
)));
|
2147 |
+
unset($opt['Filter']);
|
2148 |
+
}
|
2149 |
+
|
2150 |
+
return $this->authenticate('DescribeAddresses', $opt, $this->hostname);
|
2151 |
+
}
|
2152 |
+
|
2153 |
+
/**
|
2154 |
+
*
|
2155 |
+
* The DescribeKeyPairs operation returns information about key pairs available to you. If you specify key pairs,
|
2156 |
+
* information about those key pairs is returned. Otherwise, information for all registered key pairs is returned.
|
2157 |
+
*
|
2158 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2159 |
+
* <li><code>KeyName</code> - <code>string|array</code> - Optional - The optional list of key pair names to describe. Pass a string for a single value, or an indexed array for multiple values. </li>
|
2160 |
+
* <li><code>Filter</code> - <code>array</code> - Optional - A list of filters used to match properties for KeyPairs. For a complete reference to the available filter keys for this operation, see the Amazon EC2 API reference. <ul>
|
2161 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
2162 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Specifies the name of the filter. </li>
|
2163 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
2164 |
+
* </ul></li>
|
2165 |
+
* </ul></li>
|
2166 |
+
* <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>
|
2167 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2168 |
+
*/
|
2169 |
+
public function describe_key_pairs($opt = null)
|
2170 |
+
{
|
2171 |
+
if (!$opt) $opt = array();
|
2172 |
+
|
2173 |
+
// Optional parameter
|
2174 |
+
if (isset($opt['KeyName']))
|
2175 |
+
{
|
2176 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2177 |
+
'KeyName' => (is_array($opt['KeyName']) ? $opt['KeyName'] : array($opt['KeyName']))
|
2178 |
+
)));
|
2179 |
+
unset($opt['KeyName']);
|
2180 |
+
}
|
2181 |
+
|
2182 |
+
// Optional parameter
|
2183 |
+
if (isset($opt['Filter']))
|
2184 |
+
{
|
2185 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2186 |
+
'Filter' => $opt['Filter']
|
2187 |
+
)));
|
2188 |
+
unset($opt['Filter']);
|
2189 |
+
}
|
2190 |
+
|
2191 |
+
return $this->authenticate('DescribeKeyPairs', $opt, $this->hostname);
|
2192 |
+
}
|
2193 |
+
|
2194 |
+
/**
|
2195 |
+
*
|
2196 |
+
* The DescribeImageAttribute operation returns information about an attribute of an AMI. Only one attribute can be
|
2197 |
+
* specified per call.
|
2198 |
+
*
|
2199 |
+
* @param string $image_id (Required) The ID of the AMI whose attribute is to be described.
|
2200 |
+
* @param string $attribute (Required) The name of the attribute to describe. Available attribute names: productCodes, kernel, ramdisk, launchPermisson, blockDeviceMapping
|
2201 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2202 |
+
* <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>
|
2203 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2204 |
+
*/
|
2205 |
+
public function describe_image_attribute($image_id, $attribute, $opt = null)
|
2206 |
+
{
|
2207 |
+
if (!$opt) $opt = array();
|
2208 |
+
$opt['ImageId'] = $image_id;
|
2209 |
+
$opt['Attribute'] = $attribute;
|
2210 |
+
|
2211 |
+
return $this->authenticate('DescribeImageAttribute', $opt, $this->hostname);
|
2212 |
+
}
|
2213 |
+
|
2214 |
+
/**
|
2215 |
+
*
|
2216 |
+
* The ConfirmProductInstance operation returns true if the specified product code is attached to the specified instance.
|
2217 |
+
* The operation returns false if the product code is not attached to the instance.
|
2218 |
+
*
|
2219 |
+
* The ConfirmProductInstance operation can only be executed by the owner of the AMI. This feature is useful when an AMI
|
2220 |
+
* owner is providing support and wants to verify whether a user's instance is eligible.
|
2221 |
+
*
|
2222 |
+
* @param string $product_code (Required) The product code to confirm.
|
2223 |
+
* @param string $instance_id (Required) The ID of the instance to confirm.
|
2224 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2225 |
+
* <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>
|
2226 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2227 |
+
*/
|
2228 |
+
public function confirm_product_instance($product_code, $instance_id, $opt = null)
|
2229 |
+
{
|
2230 |
+
if (!$opt) $opt = array();
|
2231 |
+
$opt['ProductCode'] = $product_code;
|
2232 |
+
$opt['InstanceId'] = $instance_id;
|
2233 |
+
|
2234 |
+
return $this->authenticate('ConfirmProductInstance', $opt, $this->hostname);
|
2235 |
+
}
|
2236 |
+
|
2237 |
+
/**
|
2238 |
+
*
|
2239 |
+
* Initializes an empty volume of a given size.
|
2240 |
+
*
|
2241 |
+
* @param string $availability_zone (Required) The Availability Zone in which to create the new volume.
|
2242 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2243 |
+
* <li><code>Size</code> - <code>integer</code> - Optional - The size of the volume, in gigabytes. Required if you are not creating a volume from a snapshot. </li>
|
2244 |
+
* <li><code>SnapshotId</code> - <code>string</code> - Optional - The ID of the snapshot from which to create the new volume. </li>
|
2245 |
+
* <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>
|
2246 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2247 |
+
*/
|
2248 |
+
public function create_volume($availability_zone, $opt = null)
|
2249 |
+
{
|
2250 |
+
if (!$opt) $opt = array();
|
2251 |
+
$opt['AvailabilityZone'] = $availability_zone;
|
2252 |
+
|
2253 |
+
return $this->authenticate('CreateVolume', $opt, $this->hostname);
|
2254 |
+
}
|
2255 |
+
|
2256 |
+
/**
|
2257 |
+
*
|
2258 |
+
* Gives you information about your VPN gateways. You can filter the results to return information only about VPN gateways
|
2259 |
+
* that match criteria you specify. For example, you could ask to get information about a particular VPN gateway (or all)
|
2260 |
+
* only if the gateway's state is pending or available. You can specify multiple filters (e.g., the VPN gateway is in a
|
2261 |
+
* particular Availability Zone and the gateway's state is pending or available). The result includes information for a
|
2262 |
+
* particular VPN gateway only if the gateway matches all your filters. If there's no match, no special message is
|
2263 |
+
* returned; the response is simply empty. The following table shows the available filters.
|
2264 |
+
*
|
2265 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2266 |
+
* <li><code>VpnGatewayId</code> - <code>string|array</code> - Optional - A set of one or more VPN Gateway IDs. Pass a string for a single value, or an indexed array for multiple values. </li>
|
2267 |
+
* <li><code>Filter</code> - <code>array</code> - Optional - <ul>
|
2268 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
2269 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Specifies the name of the filter. </li>
|
2270 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
2271 |
+
* </ul></li>
|
2272 |
+
* </ul></li>
|
2273 |
+
* <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>
|
2274 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2275 |
+
*/
|
2276 |
+
public function describe_vpn_gateways($opt = null)
|
2277 |
+
{
|
2278 |
+
if (!$opt) $opt = array();
|
2279 |
+
|
2280 |
+
// Optional parameter
|
2281 |
+
if (isset($opt['VpnGatewayId']))
|
2282 |
+
{
|
2283 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2284 |
+
'VpnGatewayId' => (is_array($opt['VpnGatewayId']) ? $opt['VpnGatewayId'] : array($opt['VpnGatewayId']))
|
2285 |
+
)));
|
2286 |
+
unset($opt['VpnGatewayId']);
|
2287 |
+
}
|
2288 |
+
|
2289 |
+
// Optional parameter
|
2290 |
+
if (isset($opt['Filter']))
|
2291 |
+
{
|
2292 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2293 |
+
'Filter' => $opt['Filter']
|
2294 |
+
)));
|
2295 |
+
unset($opt['Filter']);
|
2296 |
+
}
|
2297 |
+
|
2298 |
+
return $this->authenticate('DescribeVpnGateways', $opt, $this->hostname);
|
2299 |
+
}
|
2300 |
+
|
2301 |
+
/**
|
2302 |
+
*
|
2303 |
+
* Creates a subnet in an existing VPC. You can create up to 20 subnets in a VPC. If you add more than one subnet to a
|
2304 |
+
* VPC, they're set up in a star topology with a logical router in the middle. When you create each subnet, you provide the
|
2305 |
+
* VPC ID and the CIDR block you want for the subnet. Once you create a subnet, you can't change its CIDR block. The
|
2306 |
+
* subnet's CIDR block can be the same as the VPC's CIDR block (assuming you want only a single subnet in the VPC), or a
|
2307 |
+
* subset of the VPC's CIDR block. If you create more than one subnet in a VPC, the subnets' CIDR blocks must not overlap.
|
2308 |
+
* The smallest subnet (and VPC) you can create uses a /28 netmask (16 IP addresses), and the largest uses a /18 netmask
|
2309 |
+
* (16,384 IP addresses).
|
2310 |
+
*
|
2311 |
+
* AWS reserves both the first four and the last IP address in each subnet's CIDR block. They're not available for use.
|
2312 |
+
*
|
2313 |
+
* @param string $vpc_id (Required) The ID of the VPC to create the subnet in.
|
2314 |
+
* @param string $cidr_block (Required) The CIDR block the subnet is to cover.
|
2315 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2316 |
+
* <li><code>AvailabilityZone</code> - <code>string</code> - Optional - The Availability Zone to create the subnet in. </li>
|
2317 |
+
* <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>
|
2318 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2319 |
+
*/
|
2320 |
+
public function create_subnet($vpc_id, $cidr_block, $opt = null)
|
2321 |
+
{
|
2322 |
+
if (!$opt) $opt = array();
|
2323 |
+
$opt['VpcId'] = $vpc_id;
|
2324 |
+
$opt['CidrBlock'] = $cidr_block;
|
2325 |
+
|
2326 |
+
return $this->authenticate('CreateSubnet', $opt, $this->hostname);
|
2327 |
+
}
|
2328 |
+
|
2329 |
+
/**
|
2330 |
+
*
|
2331 |
+
* The DescribeReservedInstancesOfferings operation describes Reserved Instance offerings that are available for purchase.
|
2332 |
+
* With Amazon EC2 Reserved Instances, you purchase the right to launch Amazon EC2 instances for a period of time (without
|
2333 |
+
* getting insufficient capacity errors) and pay a lower usage rate for the actual time used.
|
2334 |
+
*
|
2335 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2336 |
+
* <li><code>ReservedInstancesOfferingId</code> - <code>string|array</code> - Optional - An optional list of the unique IDs of the Reserved Instance offerings to describe. Pass a string for a single value, or an indexed array for multiple values. </li>
|
2337 |
+
* <li><code>InstanceType</code> - <code>string</code> - Optional - The instance type on which the Reserved Instance can be used. [Allowed values: <code>t1.micro</code>, <code>m1.small</code>, <code>m1.large</code>, <code>m1.xlarge</code>, <code>m2.xlarge</code>, <code>m2.2xlarge</code>, <code>m2.4xlarge</code>, <code>c1.medium</code>, <code>c1.xlarge</code>, <code>cc1.4xlarge</code>, <code>cg1.4xlarge</code>]</li>
|
2338 |
+
* <li><code>AvailabilityZone</code> - <code>string</code> - Optional - The Availability Zone in which the Reserved Instance can be used. </li>
|
2339 |
+
* <li><code>ProductDescription</code> - <code>string</code> - Optional - The Reserved Instance product description. </li>
|
2340 |
+
* <li><code>Filter</code> - <code>array</code> - Optional - A list of filters used to match properties for ReservedInstancesOfferings. For a complete reference to the available filter keys for this operation, see the Amazon EC2 API reference. <ul>
|
2341 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
2342 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Specifies the name of the filter. </li>
|
2343 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
2344 |
+
* </ul></li>
|
2345 |
+
* </ul></li>
|
2346 |
+
* <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>
|
2347 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2348 |
+
*/
|
2349 |
+
public function describe_reserved_instances_offerings($opt = null)
|
2350 |
+
{
|
2351 |
+
if (!$opt) $opt = array();
|
2352 |
+
|
2353 |
+
// Optional parameter
|
2354 |
+
if (isset($opt['ReservedInstancesOfferingId']))
|
2355 |
+
{
|
2356 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2357 |
+
'ReservedInstancesOfferingId' => (is_array($opt['ReservedInstancesOfferingId']) ? $opt['ReservedInstancesOfferingId'] : array($opt['ReservedInstancesOfferingId']))
|
2358 |
+
)));
|
2359 |
+
unset($opt['ReservedInstancesOfferingId']);
|
2360 |
+
}
|
2361 |
+
|
2362 |
+
// Optional parameter
|
2363 |
+
if (isset($opt['Filter']))
|
2364 |
+
{
|
2365 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2366 |
+
'Filter' => $opt['Filter']
|
2367 |
+
)));
|
2368 |
+
unset($opt['Filter']);
|
2369 |
+
}
|
2370 |
+
|
2371 |
+
return $this->authenticate('DescribeReservedInstancesOfferings', $opt, $this->hostname);
|
2372 |
+
}
|
2373 |
+
|
2374 |
+
/**
|
2375 |
+
*
|
2376 |
+
* Describes the status of the indicated or, in lieu of any specified, all volumes belonging to the caller. Volumes that
|
2377 |
+
* have been deleted are not described.
|
2378 |
+
*
|
2379 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2380 |
+
* <li><code>VolumeId</code> - <code>string|array</code> - Optional - The optional list of EBS volumes to describe. Pass a string for a single value, or an indexed array for multiple values. </li>
|
2381 |
+
* <li><code>Filter</code> - <code>array</code> - Optional - A list of filters used to match properties for Volumes. For a complete reference to the available filter keys for this operation, see the Amazon EC2 API reference. <ul>
|
2382 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
2383 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Specifies the name of the filter. </li>
|
2384 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
2385 |
+
* </ul></li>
|
2386 |
+
* </ul></li>
|
2387 |
+
* <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>
|
2388 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2389 |
+
*/
|
2390 |
+
public function describe_volumes($opt = null)
|
2391 |
+
{
|
2392 |
+
if (!$opt) $opt = array();
|
2393 |
+
|
2394 |
+
// Optional parameter
|
2395 |
+
if (isset($opt['VolumeId']))
|
2396 |
+
{
|
2397 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2398 |
+
'VolumeId' => (is_array($opt['VolumeId']) ? $opt['VolumeId'] : array($opt['VolumeId']))
|
2399 |
+
)));
|
2400 |
+
unset($opt['VolumeId']);
|
2401 |
+
}
|
2402 |
+
|
2403 |
+
// Optional parameter
|
2404 |
+
if (isset($opt['Filter']))
|
2405 |
+
{
|
2406 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2407 |
+
'Filter' => $opt['Filter']
|
2408 |
+
)));
|
2409 |
+
unset($opt['Filter']);
|
2410 |
+
}
|
2411 |
+
|
2412 |
+
return $this->authenticate('DescribeVolumes', $opt, $this->hostname);
|
2413 |
+
}
|
2414 |
+
|
2415 |
+
/**
|
2416 |
+
*
|
2417 |
+
* Deletes the snapshot identified by snapshotId.
|
2418 |
+
*
|
2419 |
+
* @param string $snapshot_id (Required) The ID of the snapshot to delete.
|
2420 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2421 |
+
* <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>
|
2422 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2423 |
+
*/
|
2424 |
+
public function delete_snapshot($snapshot_id, $opt = null)
|
2425 |
+
{
|
2426 |
+
if (!$opt) $opt = array();
|
2427 |
+
$opt['SnapshotId'] = $snapshot_id;
|
2428 |
+
|
2429 |
+
return $this->authenticate('DeleteSnapshot', $opt, $this->hostname);
|
2430 |
+
}
|
2431 |
+
|
2432 |
+
/**
|
2433 |
+
*
|
2434 |
+
* Gives you information about one or more sets of DHCP options. You can specify one or more DHCP options set IDs, or no
|
2435 |
+
* IDs (to describe all your sets of DHCP options). The returned information consists of:
|
2436 |
+
*
|
2437 |
+
* <ul> <li> The DHCP options set ID </li>
|
2438 |
+
*
|
2439 |
+
* <li> The options </li>
|
2440 |
+
*
|
2441 |
+
* </ul>
|
2442 |
+
*
|
2443 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2444 |
+
* <li><code>DhcpOptionsId</code> - <code>string|array</code> - Optional - Pass a string for a single value, or an indexed array for multiple values. </li>
|
2445 |
+
* <li><code>Filter</code> - <code>array</code> - Optional - A list of filters used to match properties for DhcpOptions. For a complete reference to the available filter keys for this operation, see the Amazon EC2 API reference. <ul>
|
2446 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
2447 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Specifies the name of the filter. </li>
|
2448 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
2449 |
+
* </ul></li>
|
2450 |
+
* </ul></li>
|
2451 |
+
* <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>
|
2452 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2453 |
+
*/
|
2454 |
+
public function describe_dhcp_options($opt = null)
|
2455 |
+
{
|
2456 |
+
if (!$opt) $opt = array();
|
2457 |
+
|
2458 |
+
// Optional parameter
|
2459 |
+
if (isset($opt['DhcpOptionsId']))
|
2460 |
+
{
|
2461 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2462 |
+
'DhcpOptionsId' => (is_array($opt['DhcpOptionsId']) ? $opt['DhcpOptionsId'] : array($opt['DhcpOptionsId']))
|
2463 |
+
)));
|
2464 |
+
unset($opt['DhcpOptionsId']);
|
2465 |
+
}
|
2466 |
+
|
2467 |
+
// Optional parameter
|
2468 |
+
if (isset($opt['Filter']))
|
2469 |
+
{
|
2470 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2471 |
+
'Filter' => $opt['Filter']
|
2472 |
+
)));
|
2473 |
+
unset($opt['Filter']);
|
2474 |
+
}
|
2475 |
+
|
2476 |
+
return $this->authenticate('DescribeDhcpOptions', $opt, $this->hostname);
|
2477 |
+
}
|
2478 |
+
|
2479 |
+
/**
|
2480 |
+
*
|
2481 |
+
* Enables monitoring for a running instance.
|
2482 |
+
*
|
2483 |
+
* @param string|array $instance_id (Required) The list of Amazon EC2 instances on which to enable monitoring. Pass a string for a single value, or an indexed array for multiple values.
|
2484 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2485 |
+
* <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>
|
2486 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2487 |
+
*/
|
2488 |
+
public function monitor_instances($instance_id, $opt = null)
|
2489 |
+
{
|
2490 |
+
if (!$opt) $opt = array();
|
2491 |
+
|
2492 |
+
// Required parameter
|
2493 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2494 |
+
'InstanceId' => (is_array($instance_id) ? $instance_id : array($instance_id))
|
2495 |
+
)));
|
2496 |
+
|
2497 |
+
return $this->authenticate('MonitorInstances', $opt, $this->hostname);
|
2498 |
+
}
|
2499 |
+
|
2500 |
+
/**
|
2501 |
+
*
|
2502 |
+
* The DisassociateAddress operation disassociates the specified elastic IP address from the instance to which it is
|
2503 |
+
* assigned. This is an idempotent operation. If you enter it more than once, Amazon EC2 does not return an error.
|
2504 |
+
*
|
2505 |
+
* @param string $public_ip (Required) The elastic IP address that you are disassociating from the instance.
|
2506 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2507 |
+
* <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>
|
2508 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2509 |
+
*/
|
2510 |
+
public function disassociate_address($public_ip, $opt = null)
|
2511 |
+
{
|
2512 |
+
if (!$opt) $opt = array();
|
2513 |
+
$opt['PublicIp'] = $public_ip;
|
2514 |
+
|
2515 |
+
return $this->authenticate('DisassociateAddress', $opt, $this->hostname);
|
2516 |
+
}
|
2517 |
+
|
2518 |
+
/**
|
2519 |
+
*
|
2520 |
+
* Creates a PlacementGroup into which multiple Amazon EC2 instances can be launched. Users must give the group a name
|
2521 |
+
* unique within the scope of the user account.
|
2522 |
+
*
|
2523 |
+
* @param string $group_name (Required) The name of the <code>PlacementGroup</code>.
|
2524 |
+
* @param string $strategy (Required) The <code>PlacementGroup</code> strategy. [Allowed values: <code>cluster</code>]
|
2525 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2526 |
+
* <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>
|
2527 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2528 |
+
*/
|
2529 |
+
public function create_placement_group($group_name, $strategy, $opt = null)
|
2530 |
+
{
|
2531 |
+
if (!$opt) $opt = array();
|
2532 |
+
$opt['GroupName'] = $group_name;
|
2533 |
+
$opt['Strategy'] = $strategy;
|
2534 |
+
|
2535 |
+
return $this->authenticate('CreatePlacementGroup', $opt, $this->hostname);
|
2536 |
+
}
|
2537 |
+
|
2538 |
+
/**
|
2539 |
+
*
|
2540 |
+
* The DescribeBundleTasks operation describes in-progress and recent bundle tasks. Complete and failed tasks are removed
|
2541 |
+
* from the list a short time after completion. If no bundle ids are given, all bundle tasks are returned.
|
2542 |
+
*
|
2543 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2544 |
+
* <li><code>BundleId</code> - <code>string|array</code> - Optional - The list of bundle task IDs to describe. Pass a string for a single value, or an indexed array for multiple values. </li>
|
2545 |
+
* <li><code>Filter</code> - <code>array</code> - Optional - A list of filters used to match properties for BundleTasks. For a complete reference to the available filter keys for this operation, see the Amazon EC2 API reference. <ul>
|
2546 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
2547 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Specifies the name of the filter. </li>
|
2548 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
2549 |
+
* </ul></li>
|
2550 |
+
* </ul></li>
|
2551 |
+
* <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>
|
2552 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2553 |
+
*/
|
2554 |
+
public function describe_bundle_tasks($opt = null)
|
2555 |
+
{
|
2556 |
+
if (!$opt) $opt = array();
|
2557 |
+
|
2558 |
+
// Optional parameter
|
2559 |
+
if (isset($opt['BundleId']))
|
2560 |
+
{
|
2561 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2562 |
+
'BundleId' => (is_array($opt['BundleId']) ? $opt['BundleId'] : array($opt['BundleId']))
|
2563 |
+
)));
|
2564 |
+
unset($opt['BundleId']);
|
2565 |
+
}
|
2566 |
+
|
2567 |
+
// Optional parameter
|
2568 |
+
if (isset($opt['Filter']))
|
2569 |
+
{
|
2570 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2571 |
+
'Filter' => $opt['Filter']
|
2572 |
+
)));
|
2573 |
+
unset($opt['Filter']);
|
2574 |
+
}
|
2575 |
+
|
2576 |
+
return $this->authenticate('DescribeBundleTasks', $opt, $this->hostname);
|
2577 |
+
}
|
2578 |
+
|
2579 |
+
/**
|
2580 |
+
* The BundleInstance operation request that an instance is bundled the next time it boots. The
|
2581 |
+
* bundling process creates a new image from a running instance and stores the AMI data in S3. Once
|
2582 |
+
* bundled, the image must be registered in the normal way using the RegisterImage API.
|
2583 |
+
*
|
2584 |
+
* @param string $instance_id (Required) The ID of the instance to bundle.
|
2585 |
+
* @param array $policy (Required) The details of S3 storage for bundling a Windows instance. Takes an associative array of parameters that can have the following keys: <ul>
|
2586 |
+
* <li><code>Bucket</code> - <code>string</code> - Optional - The bucket in which to store the AMI. You can specify a bucket that you already own or a new bucket that Amazon EC2 creates on your behalf. If you specify a bucket that belongs to someone else, Amazon EC2 returns an error.</li>
|
2587 |
+
* <li><code>Prefix</code> - <code>string</code> - Optional - The prefix to use when storing the AMI in S3.</li>
|
2588 |
+
* <li><code>AWSAccessKeyId</code> - <code>string</code> - Optional - The Access Key ID of the owner of the Amazon S3 bucket. Use the <CFPolicy::get_key()> method of a <CFPolicy> instance.</li>
|
2589 |
+
* <li><code>UploadPolicy</code> - <code>string</code> - Optional - A Base64-encoded Amazon S3 upload policy that gives Amazon EC2 permission to upload items into Amazon S3 on the user's behalf. Use the <CFPolicy::get_policy()> method of a <CFPolicy> instance.</li>
|
2590 |
+
* <li><code>UploadPolicySignature</code> - <code>string</code> - Optional - The signature of the Base64 encoded JSON document. Use the <CFPolicy::get_policy_signature()> method of a <CFPolicy> instance.</li></ul>
|
2591 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2592 |
+
* <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 is useful for manually-managed batch requests.</li></ul>
|
2593 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2594 |
+
*/
|
2595 |
+
public function bundle_instance($instance_id, $policy, $opt = null)
|
2596 |
+
{
|
2597 |
+
if (!$opt) $opt = array();
|
2598 |
+
$opt['InstanceId'] = $instance_id;
|
2599 |
+
|
2600 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2601 |
+
'Storage.S3' => $policy
|
2602 |
+
)));
|
2603 |
+
|
2604 |
+
return $this->authenticate('BundleInstance', $opt, $this->hostname);
|
2605 |
+
}
|
2606 |
+
|
2607 |
+
/**
|
2608 |
+
*
|
2609 |
+
* Deletes a PlacementGroup from a user's account. Terminate all Amazon EC2 instances in the placement group before
|
2610 |
+
* deletion.
|
2611 |
+
*
|
2612 |
+
* @param string $group_name (Required) The name of the <code>PlacementGroup</code> to delete.
|
2613 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2614 |
+
* <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>
|
2615 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2616 |
+
*/
|
2617 |
+
public function delete_placement_group($group_name, $opt = null)
|
2618 |
+
{
|
2619 |
+
if (!$opt) $opt = array();
|
2620 |
+
$opt['GroupName'] = $group_name;
|
2621 |
+
|
2622 |
+
return $this->authenticate('DeletePlacementGroup', $opt, $this->hostname);
|
2623 |
+
}
|
2624 |
+
|
2625 |
+
/**
|
2626 |
+
*
|
2627 |
+
* The RevokeSecurityGroupIngress operation revokes permissions from a security group. The permissions used to revoke must
|
2628 |
+
* be specified using the same values used to grant the permissions.
|
2629 |
+
*
|
2630 |
+
* Permissions are specified by IP protocol (TCP, UDP, or ICMP), the source of the request (by IP range or an Amazon EC2
|
2631 |
+
* user-group pair), the source and destination port ranges (for TCP and UDP), and the ICMP codes and types (for ICMP).
|
2632 |
+
*
|
2633 |
+
* Permission changes are quickly propagated to instances within the security group. However, depending on the number of
|
2634 |
+
* instances in the group, a small delay might occur.
|
2635 |
+
*
|
2636 |
+
* @param string $group_name (Required) The name of the security group from which to remove permissions.
|
2637 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2638 |
+
* <li><code>SourceSecurityGroupName</code> - <code>string</code> - Optional - Deprecated - use the list of IP permissions to specify this information instead. Name of the source security group. Cannot be used when specifying a CIDR IP address. </li>
|
2639 |
+
* <li><code>SourceSecurityGroupOwnerId</code> - <code>string</code> - Optional - Deprecated - use the list of IP permissions to specify this information instead. AWS user ID of an account. Cannot be used when specifying a CIDR IP address. </li>
|
2640 |
+
* <li><code>IpProtocol</code> - <code>string</code> - Optional - Deprecated - use the list of IP permissions to specify this information instead. IP protocol. Valid values: tcp, udp, icmp </li>
|
2641 |
+
* <li><code>FromPort</code> - <code>integer</code> - Optional - Deprecated - use the list of IP permissions to specify this information instead. Start of port range for the TCP and UDP protocols, or an ICMP type number. An ICMP type number of -1 indicates a wildcard (i.e., any ICMP type number). </li>
|
2642 |
+
* <li><code>ToPort</code> - <code>integer</code> - Optional - Deprecated - use the list of IP permissions to specify this information instead. End of port range for the TCP and UDP protocols, or an ICMP code. An ICMP code of -1 indicates a wildcard (i.e., any ICMP code). </li>
|
2643 |
+
* <li><code>CidrIp</code> - <code>string</code> - Optional - Deprecated - use the list of IP permissions to specify this information instead. CIDR range. </li>
|
2644 |
+
* <li><code>IpPermissions</code> - <code>array</code> - Optional - List of IP permissions to revoke on the specified security group. For an IP permission to be removed, it must exactly match one of the IP permissions you specify in this list. Specifying permissions through IP permissions is the preferred way of revoking permissions since it offers more flexibility and control. <ul>
|
2645 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
2646 |
+
* <li><code>IpProtocol</code> - <code>string</code> - Optional - The IP protocol of this permission. Valid protocol values: tpc, upd, icmp </li>
|
2647 |
+
* <li><code>FromPort</code> - <code>integer</code> - Optional - Start of port range for the TCP and UDP protocols, or an ICMP type number. An ICMP type number of -1 indicates a wildcard (i.e., any ICMP type number). </li>
|
2648 |
+
* <li><code>ToPort</code> - <code>integer</code> - Optional - End of port range for the TCP and UDP protocols, or an ICMP code. An ICMP code of -1 indicates a wildcard (i.e., any ICMP code). </li>
|
2649 |
+
* <li><code>Groups</code> - <code>array</code> - Optional - The list of AWS user IDs and groups included in this permission. <ul>
|
2650 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
2651 |
+
* <li><code>UserId</code> - <code>string</code> - Optional - The AWS user ID of an account. </li>
|
2652 |
+
* <li><code>GroupName</code> - <code>string</code> - Optional - The name of the security group in the specified user's account. </li>
|
2653 |
+
* </ul></li>
|
2654 |
+
* </ul></li>
|
2655 |
+
* <li><code>IpRanges</code> - <code>string|array</code> - Optional - The list of CIDR IP ranges included in this permission. Pass a string for a single value, or an indexed array for multiple values. </li>
|
2656 |
+
* </ul></li>
|
2657 |
+
* </ul></li>
|
2658 |
+
* <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>
|
2659 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2660 |
+
*/
|
2661 |
+
public function revoke_security_group_ingress($group_name, $opt = null)
|
2662 |
+
{
|
2663 |
+
if (!$opt) $opt = array();
|
2664 |
+
$opt['GroupName'] = $group_name;
|
2665 |
+
|
2666 |
+
// Optional parameter
|
2667 |
+
if (isset($opt['IpPermissions']))
|
2668 |
+
{
|
2669 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2670 |
+
'IpPermissions' => $opt['IpPermissions']
|
2671 |
+
)));
|
2672 |
+
unset($opt['IpPermissions']);
|
2673 |
+
}
|
2674 |
+
|
2675 |
+
return $this->authenticate('RevokeSecurityGroupIngress', $opt, $this->hostname);
|
2676 |
+
}
|
2677 |
+
|
2678 |
+
/**
|
2679 |
+
*
|
2680 |
+
* Deletes a VPC. You must terminate all running instances and delete all subnets before deleting the VPC, otherwise
|
2681 |
+
* Amazon VPC returns an error.
|
2682 |
+
*
|
2683 |
+
* @param string $vpc_id (Required)
|
2684 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2685 |
+
* <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>
|
2686 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2687 |
+
*/
|
2688 |
+
public function delete_vpc($vpc_id, $opt = null)
|
2689 |
+
{
|
2690 |
+
if (!$opt) $opt = array();
|
2691 |
+
$opt['VpcId'] = $vpc_id;
|
2692 |
+
|
2693 |
+
return $this->authenticate('DeleteVpc', $opt, $this->hostname);
|
2694 |
+
}
|
2695 |
+
|
2696 |
+
/**
|
2697 |
+
* The GetConsoleOutput operation retrieves console output for the specified instance.
|
2698 |
+
*
|
2699 |
+
* Instance console output is buffered and posted shortly after instance boot, reboot, and
|
2700 |
+
* termination. Amazon EC2 preserves the most recent 64 KB output which will be available for at least
|
2701 |
+
* one hour after the most recent post.
|
2702 |
+
*
|
2703 |
+
* @param string $instance_id (Required) The ID of the instance for which you want console output.
|
2704 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2705 |
+
* <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 is useful for manually-managed batch requests.</li></ul>
|
2706 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response. The value of <code>output</code> is automatically Base64-decoded.
|
2707 |
+
*/
|
2708 |
+
public function get_console_output($instance_id, $opt = null)
|
2709 |
+
{
|
2710 |
+
if (!$opt) $opt = array();
|
2711 |
+
$opt['InstanceId'] = $instance_id;
|
2712 |
+
|
2713 |
+
$response = $this->authenticate('GetConsoleOutput', $opt, $this->hostname);
|
2714 |
+
|
2715 |
+
// Automatically Base64-decode the <output> value.
|
2716 |
+
if ($this->util->is_base64((string) $response->body->output))
|
2717 |
+
{
|
2718 |
+
$response->body->output = base64_decode($response->body->output);
|
2719 |
+
}
|
2720 |
+
|
2721 |
+
return $response;
|
2722 |
+
}
|
2723 |
+
|
2724 |
+
/**
|
2725 |
+
*
|
2726 |
+
* The AllocateAddress operation acquires an elastic IP address for use with your account.
|
2727 |
+
*
|
2728 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2729 |
+
* <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>
|
2730 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2731 |
+
*/
|
2732 |
+
public function allocate_address($opt = null)
|
2733 |
+
{
|
2734 |
+
if (!$opt) $opt = array();
|
2735 |
+
|
2736 |
+
return $this->authenticate('AllocateAddress', $opt, $this->hostname);
|
2737 |
+
}
|
2738 |
+
|
2739 |
+
/**
|
2740 |
+
*
|
2741 |
+
* The ModifyImageAttribute operation modifies an attribute of an AMI.
|
2742 |
+
*
|
2743 |
+
* @param string $image_id (Required) The ID of the AMI whose attribute you want to modify.
|
2744 |
+
* @param string $attribute (Required) The name of the AMI attribute you want to modify. Available attributes: launchPermission, productCodes
|
2745 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2746 |
+
* <li><code>OperationType</code> - <code>string</code> - Optional - The type of operation being requested. Available operation types: add, remove </li>
|
2747 |
+
* <li><code>UserId</code> - <code>string|array</code> - Optional - The AWS user ID being added to or removed from the list of users with launch permissions for this AMI. Only valid when the launchPermission attribute is being modified. Pass a string for a single value, or an indexed array for multiple values. </li>
|
2748 |
+
* <li><code>UserGroup</code> - <code>string|array</code> - Optional - The user group being added to or removed from the list of user groups with launch permissions for this AMI. Only valid when the launchPermission attribute is being modified. Available user groups: all Pass a string for a single value, or an indexed array for multiple values. </li>
|
2749 |
+
* <li><code>ProductCode</code> - <code>string|array</code> - Optional - The list of product codes being added to or removed from the specified AMI. Only valid when the productCodes attribute is being modified. Pass a string for a single value, or an indexed array for multiple values. </li>
|
2750 |
+
* <li><code>Value</code> - <code>string</code> - Optional - The value of the attribute being modified. Only valid when the description attribute is being modified. </li>
|
2751 |
+
* <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>
|
2752 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2753 |
+
*/
|
2754 |
+
public function modify_image_attribute($image_id, $attribute, $opt = null)
|
2755 |
+
{
|
2756 |
+
if (!$opt) $opt = array();
|
2757 |
+
$opt['ImageId'] = $image_id;
|
2758 |
+
$opt['Attribute'] = $attribute;
|
2759 |
+
|
2760 |
+
// Optional parameter
|
2761 |
+
if (isset($opt['UserId']))
|
2762 |
+
{
|
2763 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2764 |
+
'UserId' => (is_array($opt['UserId']) ? $opt['UserId'] : array($opt['UserId']))
|
2765 |
+
)));
|
2766 |
+
unset($opt['UserId']);
|
2767 |
+
}
|
2768 |
+
|
2769 |
+
// Optional parameter
|
2770 |
+
if (isset($opt['UserGroup']))
|
2771 |
+
{
|
2772 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2773 |
+
'UserGroup' => (is_array($opt['UserGroup']) ? $opt['UserGroup'] : array($opt['UserGroup']))
|
2774 |
+
)));
|
2775 |
+
unset($opt['UserGroup']);
|
2776 |
+
}
|
2777 |
+
|
2778 |
+
// Optional parameter
|
2779 |
+
if (isset($opt['ProductCode']))
|
2780 |
+
{
|
2781 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2782 |
+
'ProductCode' => (is_array($opt['ProductCode']) ? $opt['ProductCode'] : array($opt['ProductCode']))
|
2783 |
+
)));
|
2784 |
+
unset($opt['ProductCode']);
|
2785 |
+
}
|
2786 |
+
|
2787 |
+
return $this->authenticate('ModifyImageAttribute', $opt, $this->hostname);
|
2788 |
+
}
|
2789 |
+
|
2790 |
+
/**
|
2791 |
+
*
|
2792 |
+
* The ReleaseAddress operation releases an elastic IP address associated with your account.
|
2793 |
+
*
|
2794 |
+
* Releasing an IP address automatically disassociates it from any instance with which it is associated. For more
|
2795 |
+
* information, see DisassociateAddress.
|
2796 |
+
*
|
2797 |
+
* After releasing an elastic IP address, it is released to the IP address pool and might no longer be available to your
|
2798 |
+
* account. Make sure to update your DNS records and any servers or devices that communicate with the address.
|
2799 |
+
*
|
2800 |
+
* If you run this operation on an elastic IP address that is already released, the address might be assigned to another
|
2801 |
+
* account which will cause Amazon EC2 to return an error.
|
2802 |
+
*
|
2803 |
+
* @param string $public_ip (Required) The elastic IP address that you are releasing from your account.
|
2804 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2805 |
+
* <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>
|
2806 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2807 |
+
*/
|
2808 |
+
public function release_address($public_ip, $opt = null)
|
2809 |
+
{
|
2810 |
+
if (!$opt) $opt = array();
|
2811 |
+
$opt['PublicIp'] = $public_ip;
|
2812 |
+
|
2813 |
+
return $this->authenticate('ReleaseAddress', $opt, $this->hostname);
|
2814 |
+
}
|
2815 |
+
|
2816 |
+
/**
|
2817 |
+
*
|
2818 |
+
* Provides information to AWS about your customer gateway device. The customer gateway is the appliance at your end of
|
2819 |
+
* the VPN connection (compared to the VPN gateway, which is the device at the AWS side of the VPN connection). You can
|
2820 |
+
* have a single active customer gateway per AWS account (active means that you've created a VPN connection to use with the
|
2821 |
+
* customer gateway). AWS might delete any customer gateway that you create with this operation if you leave it inactive
|
2822 |
+
* for an extended period of time.
|
2823 |
+
*
|
2824 |
+
* You must provide the Internet-routable IP address of the customer gateway's external interface. The IP address must be
|
2825 |
+
* static.
|
2826 |
+
*
|
2827 |
+
* You must also provide the device's Border Gateway Protocol (BGP) Autonomous System Number (ASN). You can use an
|
2828 |
+
* existing ASN assigned to your network. If you don't have an ASN already, you can use a private ASN (in the 64512 - 65534
|
2829 |
+
* range). For more information about ASNs, go to <a
|
2830 |
+
* .wikipedia.org/wiki/Autonomous_system_%28Internet%29">http://en.wikipedia.org/wiki/Autonomous_system_%28Internet%29</a>.
|
2831 |
+
*
|
2832 |
+
* @param string $type (Required) The type of VPN connection this customer gateway supports.
|
2833 |
+
* @param string $ip_address (Required) The Internet-routable IP address for the customer gateway's outside interface. The address must be static
|
2834 |
+
* @param integer $bgp_asn (Required) The customer gateway's Border Gateway Protocol (BGP) Autonomous System Number (ASN).
|
2835 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2836 |
+
* <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>
|
2837 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2838 |
+
*/
|
2839 |
+
public function create_customer_gateway($type, $ip_address, $bgp_asn, $opt = null)
|
2840 |
+
{
|
2841 |
+
if (!$opt) $opt = array();
|
2842 |
+
$opt['Type'] = $type;
|
2843 |
+
$opt['IpAddress'] = $ip_address;
|
2844 |
+
$opt['BgpAsn'] = $bgp_asn;
|
2845 |
+
|
2846 |
+
return $this->authenticate('CreateCustomerGateway', $opt, $this->hostname);
|
2847 |
+
}
|
2848 |
+
|
2849 |
+
/**
|
2850 |
+
*
|
2851 |
+
* Resets an attribute of an instance to its default value.
|
2852 |
+
*
|
2853 |
+
* @param string $instance_id (Required) The ID of the Amazon EC2 instance whose attribute is being reset.
|
2854 |
+
* @param string $attribute (Required) The name of the attribute being reset. Available attribute names: kernel, ramdisk
|
2855 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2856 |
+
* <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>
|
2857 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2858 |
+
*/
|
2859 |
+
public function reset_instance_attribute($instance_id, $attribute, $opt = null)
|
2860 |
+
{
|
2861 |
+
if (!$opt) $opt = array();
|
2862 |
+
$opt['InstanceId'] = $instance_id;
|
2863 |
+
$opt['Attribute'] = $attribute;
|
2864 |
+
|
2865 |
+
return $this->authenticate('ResetInstanceAttribute', $opt, $this->hostname);
|
2866 |
+
}
|
2867 |
+
|
2868 |
+
/**
|
2869 |
+
*
|
2870 |
+
* Creates the data feed for Spot Instances, enabling you to view Spot Instance usage logs. You can create one data feed
|
2871 |
+
* per account.
|
2872 |
+
*
|
2873 |
+
* For conceptual information about Spot Instances, refer to the Amazon Elastic Compute Cloud Developer Guide or Amazon
|
2874 |
+
* Elastic Compute Cloud User Guide.
|
2875 |
+
*
|
2876 |
+
* @param string $bucket (Required) The Amazon S3 bucket in which to store the Spot Instance datafeed.
|
2877 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2878 |
+
* <li><code>Prefix</code> - <code>string</code> - Optional - The prefix that is prepended to datafeed files. </li>
|
2879 |
+
* <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>
|
2880 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2881 |
+
*/
|
2882 |
+
public function create_spot_datafeed_subscription($bucket, $opt = null)
|
2883 |
+
{
|
2884 |
+
if (!$opt) $opt = array();
|
2885 |
+
$opt['Bucket'] = $bucket;
|
2886 |
+
|
2887 |
+
return $this->authenticate('CreateSpotDatafeedSubscription', $opt, $this->hostname);
|
2888 |
+
}
|
2889 |
+
|
2890 |
+
/**
|
2891 |
+
*
|
2892 |
+
* The CreateKeyPair operation creates a new 2048 bit RSA key pair and returns a unique ID that can be used to reference
|
2893 |
+
* this key pair when launching new instances. For more information, see RunInstances.
|
2894 |
+
*
|
2895 |
+
* @param string $key_name (Required) The unique name for the new key pair.
|
2896 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2897 |
+
* <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>
|
2898 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2899 |
+
*/
|
2900 |
+
public function create_key_pair($key_name, $opt = null)
|
2901 |
+
{
|
2902 |
+
if (!$opt) $opt = array();
|
2903 |
+
$opt['KeyName'] = $key_name;
|
2904 |
+
|
2905 |
+
return $this->authenticate('CreateKeyPair', $opt, $this->hostname);
|
2906 |
+
}
|
2907 |
+
|
2908 |
+
/**
|
2909 |
+
*
|
2910 |
+
* Returns information about the Amazon EBS snapshots available to you. Snapshots available to you include public
|
2911 |
+
* snapshots available for any AWS account to launch, private snapshots you own, and private snapshots owned by another AWS
|
2912 |
+
* account but for which you've been given explicit create volume permissions.
|
2913 |
+
*
|
2914 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2915 |
+
* <li><code>SnapshotId</code> - <code>string|array</code> - Optional - The optional list of EBS snapshot IDs to describe. Pass a string for a single value, or an indexed array for multiple values. </li>
|
2916 |
+
* <li><code>Owner</code> - <code>string|array</code> - Optional - The optional list of EBS snapshot owners. Pass a string for a single value, or an indexed array for multiple values. </li>
|
2917 |
+
* <li><code>RestorableBy</code> - <code>string|array</code> - Optional - The optional list of users who have permission to create volumes from the described EBS snapshots. Pass a string for a single value, or an indexed array for multiple values. </li>
|
2918 |
+
* <li><code>Filter</code> - <code>array</code> - Optional - A list of filters used to match properties for Snapshots. For a complete reference to the available filter keys for this operation, see the Amazon EC2 API reference. <ul>
|
2919 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
2920 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Specifies the name of the filter. </li>
|
2921 |
+
* <li><code>Value</code> - <code>string|array</code> - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values. </li>
|
2922 |
+
* </ul></li>
|
2923 |
+
* </ul></li>
|
2924 |
+
* <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>
|
2925 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2926 |
+
*/
|
2927 |
+
public function describe_snapshots($opt = null)
|
2928 |
+
{
|
2929 |
+
if (!$opt) $opt = array();
|
2930 |
+
|
2931 |
+
// Optional parameter
|
2932 |
+
if (isset($opt['SnapshotId']))
|
2933 |
+
{
|
2934 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2935 |
+
'SnapshotId' => (is_array($opt['SnapshotId']) ? $opt['SnapshotId'] : array($opt['SnapshotId']))
|
2936 |
+
)));
|
2937 |
+
unset($opt['SnapshotId']);
|
2938 |
+
}
|
2939 |
+
|
2940 |
+
// Optional parameter
|
2941 |
+
if (isset($opt['Owner']))
|
2942 |
+
{
|
2943 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2944 |
+
'Owner' => (is_array($opt['Owner']) ? $opt['Owner'] : array($opt['Owner']))
|
2945 |
+
)));
|
2946 |
+
unset($opt['Owner']);
|
2947 |
+
}
|
2948 |
+
|
2949 |
+
// Optional parameter
|
2950 |
+
if (isset($opt['RestorableBy']))
|
2951 |
+
{
|
2952 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2953 |
+
'RestorableBy' => (is_array($opt['RestorableBy']) ? $opt['RestorableBy'] : array($opt['RestorableBy']))
|
2954 |
+
)));
|
2955 |
+
unset($opt['RestorableBy']);
|
2956 |
+
}
|
2957 |
+
|
2958 |
+
// Optional parameter
|
2959 |
+
if (isset($opt['Filter']))
|
2960 |
+
{
|
2961 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
2962 |
+
'Filter' => $opt['Filter']
|
2963 |
+
)));
|
2964 |
+
unset($opt['Filter']);
|
2965 |
+
}
|
2966 |
+
|
2967 |
+
return $this->authenticate('DescribeSnapshots', $opt, $this->hostname);
|
2968 |
+
}
|
2969 |
+
|
2970 |
+
/**
|
2971 |
+
*
|
2972 |
+
* The RegisterImage operation registers an AMI with Amazon EC2. Images must be registered before they can be launched.
|
2973 |
+
* For more information, see RunInstances.
|
2974 |
+
*
|
2975 |
+
* Each AMI is associated with an unique ID which is provided by the Amazon EC2 service through the RegisterImage
|
2976 |
+
* operation. During registration, Amazon EC2 retrieves the specified image manifest from Amazon S3 and verifies that the
|
2977 |
+
* image is owned by the user registering the image.
|
2978 |
+
*
|
2979 |
+
* The image manifest is retrieved once and stored within the Amazon EC2. Any modifications to an image in Amazon S3
|
2980 |
+
* invalidates this registration. If you make changes to an image, deregister the previous image and register the new
|
2981 |
+
* image. For more information, see DeregisterImage.
|
2982 |
+
*
|
2983 |
+
* @param string $image_location (Required) The full path to your AMI manifest in Amazon S3 storage.
|
2984 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2985 |
+
* <li><code>Name</code> - <code>string</code> - Optional - The name to give the new Amazon Machine Image. Constraints: 3-128 alphanumeric characters, parenthesis (()), commas (,), slashes (/), dashes (-), or underscores(_) </li>
|
2986 |
+
* <li><code>Description</code> - <code>string</code> - Optional - The description describing the new AMI. </li>
|
2987 |
+
* <li><code>Architecture</code> - <code>string</code> - Optional - The architecture of the image. Valid Values: i386, x86_64 </li>
|
2988 |
+
* <li><code>KernelId</code> - <code>string</code> - Optional - The optional ID of a specific kernel to register with the new AMI. </li>
|
2989 |
+
* <li><code>RamdiskId</code> - <code>string</code> - Optional - The optional ID of a specific ramdisk to register with the new AMI. Some kernels require additional drivers at launch. Check the kernel requirements for information on whether you need to specify a RAM disk. </li>
|
2990 |
+
* <li><code>RootDeviceName</code> - <code>string</code> - Optional - The root device name (e.g., /dev/sda1). </li>
|
2991 |
+
* <li><code>BlockDeviceMapping</code> - <code>array</code> - Optional - The block device mappings for the new AMI, which specify how different block devices (ex: EBS volumes and ephemeral drives) will be exposed on instances launched from the new image. <ul>
|
2992 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
2993 |
+
* <li><code>VirtualName</code> - <code>string</code> - Optional - Specifies the virtual device name. </li>
|
2994 |
+
* <li><code>DeviceName</code> - <code>string</code> - Optional - Specifies the device name (e.g., /dev/sdh). </li>
|
2995 |
+
* <li><code>Ebs</code> - <code>array</code> - Optional - Specifies parameters used to automatically setup Amazon EBS volumes when the instance is launched. Takes an associative array of parameters that can have the following keys: <ul>
|
2996 |
+
* <li><code>SnapshotId</code> - <code>string</code> - Optional - The ID of the snapshot from which the volume will be created. </li>
|
2997 |
+
* <li><code>VolumeSize</code> - <code>integer</code> - Optional - The size of the volume, in gigabytes. </li>
|
2998 |
+
* <li><code>DeleteOnTermination</code> - <code>boolean</code> - Optional - Specifies whether the Amazon EBS volume is deleted on instance termination. </li>
|
2999 |
+
* </ul></li>
|
3000 |
+
* <li><code>NoDevice</code> - <code>string</code> - Optional - Specifies the device name to suppress during instance launch. </li>
|
3001 |
+
* </ul></li>
|
3002 |
+
* </ul></li>
|
3003 |
+
* <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>
|
3004 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
3005 |
+
*/
|
3006 |
+
public function register_image($image_location, $opt = null)
|
3007 |
+
{
|
3008 |
+
if (!$opt) $opt = array();
|
3009 |
+
$opt['ImageLocation'] = $image_location;
|
3010 |
+
|
3011 |
+
// Optional parameter
|
3012 |
+
if (isset($opt['BlockDeviceMapping']))
|
3013 |
+
{
|
3014 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
3015 |
+
'BlockDeviceMapping' => $opt['BlockDeviceMapping']
|
3016 |
+
)));
|
3017 |
+
unset($opt['BlockDeviceMapping']);
|
3018 |
+
}
|
3019 |
+
|
3020 |
+
return $this->authenticate('RegisterImage', $opt, $this->hostname);
|
3021 |
+
}
|
3022 |
+
|
3023 |
+
/**
|
3024 |
+
*
|
3025 |
+
* Deletes a VPN connection. Use this if you want to delete a VPC and all its associated components. Another reason to use
|
3026 |
+
* this operation is if you believe the tunnel credentials for your VPN connection have been compromised. In that
|
3027 |
+
* situation, you can delete the VPN connection and create a new one that has new keys, without needing to delete the VPC
|
3028 |
+
* or VPN gateway. If you create a new VPN connection, you must reconfigure the customer gateway using the new
|
3029 |
+
* configuration information returned with the new VPN connection ID.
|
3030 |
+
*
|
3031 |
+
* If you're deleting the VPC and all its associated parts, we recommend you detach the VPN gateway from the VPC and
|
3032 |
+
* delete the VPC before deleting the VPN connection.
|
3033 |
+
*
|
3034 |
+
* @param string $vpn_connection_id (Required) The ID of the VPN connection to delete
|
3035 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
3036 |
+
* <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>
|
3037 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
3038 |
+
*/
|
3039 |
+
public function delete_vpn_connection($vpn_connection_id, $opt = null)
|
3040 |
+
{
|
3041 |
+
if (!$opt) $opt = array();
|
3042 |
+
$opt['VpnConnectionId'] = $vpn_connection_id;
|
3043 |
+
|
3044 |
+
return $this->authenticate('DeleteVpnConnection', $opt, $this->hostname);
|
3045 |
+
}
|
3046 |
+
|
3047 |
+
/**
|
3048 |
+
*
|
3049 |
+
* Creates a new VPN connection between an existing VPN gateway and customer gateway. The only supported connection type
|
3050 |
+
* is ipsec.1.
|
3051 |
+
*
|
3052 |
+
* The response includes information that you need to configure your customer gateway, in XML format. We recommend you use
|
3053 |
+
* the command line version of this operation (ec2-create-vpn-connection), which takes an -f option (for format) and
|
3054 |
+
* returns configuration information formatted as expected by the vendor you specified, or in a generic, human readable
|
3055 |
+
* format. For information about the command, go to ec2-create-vpn-connection in the Amazon Virtual Private Cloud Command
|
3056 |
+
* Line Reference.
|
3057 |
+
*
|
3058 |
+
* We strongly recommend you use HTTPS when calling this operation because the response contains sensitive cryptographic
|
3059 |
+
* information for configuring your customer gateway.
|
3060 |
+
*
|
3061 |
+
* If you decide to shut down your VPN connection for any reason and then create a new one, you must re-configure your
|
3062 |
+
* customer gateway with the new information returned from this call.
|
3063 |
+
*
|
3064 |
+
* @param string $type (Required) The type of VPN connection.
|
3065 |
+
* @param string $customer_gateway_id (Required) The ID of the customer gateway.
|
3066 |
+
* @param string $vpn_gateway_id (Required) The ID of the VPN gateway.
|
3067 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
3068 |
+
* <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>
|
3069 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
3070 |
+
*/
|
3071 |
+
public function create_vpn_connection($type, $customer_gateway_id, $vpn_gateway_id, $opt = null)
|
3072 |
+
{
|
3073 |
+
if (!$opt) $opt = array();
|
3074 |
+
$opt['Type'] = $type;
|
3075 |
+
$opt['CustomerGatewayId'] = $customer_gateway_id;
|
3076 |
+
$opt['VpnGatewayId'] = $vpn_gateway_id;
|
3077 |
+
|
3078 |
+
return $this->authenticate('CreateVpnConnection', $opt, $this->hostname);
|
3079 |
+
}
|
3080 |
+
|
3081 |
+
/**
|
3082 |
+
*
|
3083 |
+
* Returns information about an attribute of an instance. Only one attribute can be specified per call.
|
3084 |
+
*
|
3085 |
+
* @param string $instance_id (Required) The ID of the instance whose instance attribute is being described.
|
3086 |
+
* @param string $attribute (Required) The name of the attribute to describe. Available attribute names: instanceType, kernel, ramdisk, userData, disableApiTermination, instanceInitiatedShutdownBehavior, rootDeviceName, blockDeviceMapping
|
3087 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
3088 |
+
* <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>
|
3089 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
3090 |
+
*/
|
3091 |
+
public function describe_instance_attribute($instance_id, $attribute, $opt = null)
|
3092 |
+
{
|
3093 |
+
if (!$opt) $opt = array();
|
3094 |
+
$opt['InstanceId'] = $instance_id;
|
3095 |
+
$opt['Attribute'] = $attribute;
|
3096 |
+
|
3097 |
+
return $this->authenticate('DescribeInstanceAttribute', $opt, $this->hostname);
|
3098 |
+
}
|
3099 |
+
}
|
3100 |
+
|
3101 |
+
|
3102 |
+
/*%******************************************************************************************%*/
|
3103 |
+
// EXCEPTIONS
|
3104 |
+
|
3105 |
+
/**
|
3106 |
+
* Default EC2 Exception.
|
3107 |
+
*/
|
3108 |
+
class EC2_Exception extends Exception {}
|
app/libs/aws/services/elasticbeanstalk.class.php
ADDED
@@ -0,0 +1,955 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
*
|
20 |
+
* This is the AWS Elastic Beanstalk API Reference. This guide provides detailed information about AWS Elastic Beanstalk
|
21 |
+
* actions, data types, parameters, and errors.
|
22 |
+
*
|
23 |
+
* AWS Elastic Beanstalk is a tool that makes it easy for you to create, deploy, and manage scalable, fault-tolerant
|
24 |
+
* applications running on Amazon Web Services cloud resources.
|
25 |
+
*
|
26 |
+
* For more information about this product, go to the <a href="http://aws.amazon.com/elasticbeanstalk/">AWS Elastic
|
27 |
+
* Beanstalk</a> details page. For specific information about setting up signatures and authorization through the API, go
|
28 |
+
* to the <a href="http://docs.amazonwebservices.com/elasticbeanstalk/latest/ug/available-apis.html">AWS Elastic Beanstalk
|
29 |
+
* User Guide</a>.
|
30 |
+
*
|
31 |
+
* <b>Endpoints</b>
|
32 |
+
*
|
33 |
+
* AWS Elastic Beanstalk supports the following region-specific endpoint:
|
34 |
+
*
|
35 |
+
* <ul> <li> https://elasticbeanstalk.us-east-1.amazonaws.com </li>
|
36 |
+
*
|
37 |
+
* </ul>
|
38 |
+
*
|
39 |
+
* @version Wed Feb 16 17:04:46 PST 2011
|
40 |
+
* @license See the included NOTICE.md file for complete information.
|
41 |
+
* @copyright See the included NOTICE.md file for complete information.
|
42 |
+
* @link http://aws.amazon.com/elasticbeanstalk/AWS Elastic Beanstalk
|
43 |
+
* @link http://aws.amazon.com/documentation/elasticbeanstalk/AWS Elastic Beanstalk documentation
|
44 |
+
*/
|
45 |
+
class AmazonElasticBeanstalk extends CFRuntime
|
46 |
+
{
|
47 |
+
|
48 |
+
/*%******************************************************************************************%*/
|
49 |
+
// CLASS CONSTANTS
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Specify the default queue URL.
|
53 |
+
*/
|
54 |
+
const DEFAULT_URL = 'elasticbeanstalk.us-east-1.amazonaws.com';
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Specify the queue URL for the US-East (Northern Virginia) Region.
|
58 |
+
*/
|
59 |
+
const REGION_US_E1 = 'us-east-1';
|
60 |
+
|
61 |
+
|
62 |
+
/*%******************************************************************************************%*/
|
63 |
+
// SETTERS
|
64 |
+
|
65 |
+
/**
|
66 |
+
* This allows you to explicitly sets the region for the service to use.
|
67 |
+
*
|
68 |
+
* @param string $region (Required) The region to explicitly set. Available options are <REGION_US_E1>.
|
69 |
+
* @return $this A reference to the current instance.
|
70 |
+
*/
|
71 |
+
public function set_region($region)
|
72 |
+
{
|
73 |
+
$this->set_hostname('http://elasticbeanstalk.'. $region .'.amazonaws.com');
|
74 |
+
return $this;
|
75 |
+
}
|
76 |
+
|
77 |
+
|
78 |
+
/*%******************************************************************************************%*/
|
79 |
+
// CONSTRUCTOR
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Constructs a new instance of <AmazonClearBox>.
|
83 |
+
*
|
84 |
+
* @param string $key (Optional) Your Amazon API Key. If blank, it will look for the <code>AWS_KEY</code> constant.
|
85 |
+
* @param string $secret_key (Optional) Your Amazon API Secret Key. If blank, it will look for the <code>AWS_SECRET_KEY</code> constant.
|
86 |
+
* @return boolean false if no valid values are set, otherwise true.
|
87 |
+
*/
|
88 |
+
public function __construct($key = null, $secret_key = null)
|
89 |
+
{
|
90 |
+
$this->api_version = '2010-12-01';
|
91 |
+
$this->hostname = self::DEFAULT_URL;
|
92 |
+
|
93 |
+
if (!$key && !defined('AWS_KEY'))
|
94 |
+
{
|
95 |
+
throw new Beanstalk_Exception('No account key was passed into the constructor, nor was it set in the AWS_KEY constant.');
|
96 |
+
}
|
97 |
+
|
98 |
+
if (!$secret_key && !defined('AWS_SECRET_KEY'))
|
99 |
+
{
|
100 |
+
throw new Beanstalk_Exception('No account secret was passed into the constructor, nor was it set in the AWS_SECRET_KEY constant.');
|
101 |
+
}
|
102 |
+
|
103 |
+
return parent::__construct($key, $secret_key);
|
104 |
+
}
|
105 |
+
|
106 |
+
|
107 |
+
/*%******************************************************************************************%*/
|
108 |
+
// SERVICE METHODS
|
109 |
+
|
110 |
+
/**
|
111 |
+
*
|
112 |
+
* Checks if the specified CNAME is available.
|
113 |
+
*
|
114 |
+
* @param string $cname_prefix (Required) The prefix used when this CNAME is reserved.
|
115 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
116 |
+
* <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>
|
117 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
118 |
+
*/
|
119 |
+
public function check_dns_availability($cname_prefix, $opt = null)
|
120 |
+
{
|
121 |
+
if (!$opt) $opt = array();
|
122 |
+
$opt['CNAMEPrefix'] = $cname_prefix;
|
123 |
+
|
124 |
+
return $this->authenticate('CheckDNSAvailability', $opt, $this->hostname);
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
*
|
129 |
+
* Describes the configuration options that are used in a particular configuration template or environment, or that a
|
130 |
+
* specified solution stack defines. The description includes the values the options, their default values, and an
|
131 |
+
* indication of the required action on a running environment if an option value is changed.
|
132 |
+
*
|
133 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
134 |
+
* <li><code>ApplicationName</code> - <code>string</code> - Optional - The name of the application associated with the configuration template or environment. Only needed if you want to describe the configuration options associated with either the configuration template or environment. </li>
|
135 |
+
* <li><code>TemplateName</code> - <code>string</code> - Optional - The name of the configuration template whose configuration options you want to describe. </li>
|
136 |
+
* <li><code>EnvironmentName</code> - <code>string</code> - Optional - The name of the environment whose configuration options you want to describe. </li>
|
137 |
+
* <li><code>SolutionStackName</code> - <code>string</code> - Optional - The name of the solution stack whose configuration options you want to describe. </li>
|
138 |
+
* <li><code>Options</code> - <code>array</code> - Optional - If specified, restricts the descriptions to only the specified options. <ul>
|
139 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
140 |
+
* <li><code>Namespace</code> - <code>string</code> - Optional - A unique namespace identifying the option's associated AWS resource. </li>
|
141 |
+
* <li><code>OptionName</code> - <code>string</code> - Optional - The name of the configuration option. </li>
|
142 |
+
* </ul></li>
|
143 |
+
* </ul></li>
|
144 |
+
* <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>
|
145 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
146 |
+
*/
|
147 |
+
public function describe_configuration_options($opt = null)
|
148 |
+
{
|
149 |
+
if (!$opt) $opt = array();
|
150 |
+
|
151 |
+
// Optional parameter
|
152 |
+
if (isset($opt['Options']))
|
153 |
+
{
|
154 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
155 |
+
'Options' => $opt['Options']
|
156 |
+
), 'member'));
|
157 |
+
unset($opt['Options']);
|
158 |
+
}
|
159 |
+
|
160 |
+
return $this->authenticate('DescribeConfigurationOptions', $opt, $this->hostname);
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
*
|
165 |
+
* Deletes the specified configuration template.
|
166 |
+
*
|
167 |
+
* When you launch an environment using a configuration template, the environment gets a copy of the template. You can
|
168 |
+
* delete or modify the environment's copy of the template without affecting the running environment.
|
169 |
+
*
|
170 |
+
* @param string $application_name (Required) The name of the application to delete the configuration template from.
|
171 |
+
* @param string $template_name (Required) The name of the configuration template to delete.
|
172 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
173 |
+
* <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>
|
174 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
175 |
+
*/
|
176 |
+
public function delete_configuration_template($application_name, $template_name, $opt = null)
|
177 |
+
{
|
178 |
+
if (!$opt) $opt = array();
|
179 |
+
$opt['ApplicationName'] = $application_name;
|
180 |
+
$opt['TemplateName'] = $template_name;
|
181 |
+
|
182 |
+
return $this->authenticate('DeleteConfigurationTemplate', $opt, $this->hostname);
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
*
|
187 |
+
* Launches an environment for the specified application using the specified configuration.
|
188 |
+
*
|
189 |
+
* @param string $application_name (Required) The name of the application that contains the version to be deployed. If no application is found with this name, <code>CreateEnvironment</code> returns an <code>InvalidParameterValue</code> error.
|
190 |
+
* @param string $environment_name (Required) A unique name for the deployment environment. Used in the application URL. Constraint: Must be from 4 to 23 characters in length. The name can contain only letters, numbers, and hyphens. It cannot start or end with a hyphen. This name must be unique in your account. If the specified name already exists, AWS Elastic Beanstalk returns an <code>InvalidParameterValue</code> error. Default: If the CNAME parameter is not specified, the environment name becomes part of the CNAME, and therefore part of the visible URL for your application.
|
191 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
192 |
+
* <li><code>VersionLabel</code> - <code>string</code> - Optional - The name of the application version to deploy. If the specified application has no associated application versions, AWS Elastic Beanstalk <code>UpdateEnvironment</code> returns an <code>InvalidParameterValue</code> error. Default: If not specified, AWS Elastic Beanstalk attempts to launch the most recently created application version. </li>
|
193 |
+
* <li><code>TemplateName</code> - <code>string</code> - Optional - The name of the configuration template to use in deployment. If no configuration template is found with this name, AWS Elastic Beanstalk returns an <code>InvalidParameterValue</code> error. Conditional: You must specify either this parameter or a <code>SolutionStackName</code>, but not both. If you specify both, AWS Elastic Beanstalk returns an <code>InvalidParameterCombination</code> error. If you do not specify either, AWS Elastic Beanstalk returns a <code>MissingRequiredParameter</code> error. </li>
|
194 |
+
* <li><code>SolutionStackName</code> - <code>string</code> - Optional - This is an alternative to specifying a configuration name. If specified, AWS Elastic Beanstalk sets the configuration values to the default values associated with the specified solution stack. Condition: You must specify either this or a <code>TemplateName</code>, but not both. If you specify both, AWS Elastic Beanstalk returns an <code>InvalidParameterCombination</code> error. If you do not specify either, AWS Elastic Beanstalk returns a <code>MissingRequiredParameter</code> error. </li>
|
195 |
+
* <li><code>CNAMEPrefix</code> - <code>string</code> - Optional - If specified, the environment attempts to use this value as the prefix for the CNAME. If not specified, the environment uses the environment name. </li>
|
196 |
+
* <li><code>Description</code> - <code>string</code> - Optional - Describes this environment. </li>
|
197 |
+
* <li><code>OptionSettings</code> - <code>array</code> - Optional - If specified, AWS Elastic Beanstalk sets the specified configuration options to the requested value in the configuration set for the new environment. These override the values obtained from the solution stack or the configuration template. <ul>
|
198 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
199 |
+
* <li><code>Namespace</code> - <code>string</code> - Optional - A unique namespace identifying the option's associated AWS resource. </li>
|
200 |
+
* <li><code>OptionName</code> - <code>string</code> - Optional - The name of the configuration option. </li>
|
201 |
+
* <li><code>Value</code> - <code>string</code> - Optional - The current value for the configuration option. </li>
|
202 |
+
* </ul></li>
|
203 |
+
* </ul></li>
|
204 |
+
* <li><code>OptionsToRemove</code> - <code>array</code> - Optional - A list of custom user-defined configuration options to remove from the configuration set for this new environment. <ul>
|
205 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
206 |
+
* <li><code>Namespace</code> - <code>string</code> - Optional - A unique namespace identifying the option's associated AWS resource. </li>
|
207 |
+
* <li><code>OptionName</code> - <code>string</code> - Optional - The name of the configuration option. </li>
|
208 |
+
* </ul></li>
|
209 |
+
* </ul></li>
|
210 |
+
* <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>
|
211 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
212 |
+
*/
|
213 |
+
public function create_environment($application_name, $environment_name, $opt = null)
|
214 |
+
{
|
215 |
+
if (!$opt) $opt = array();
|
216 |
+
$opt['ApplicationName'] = $application_name;
|
217 |
+
$opt['EnvironmentName'] = $environment_name;
|
218 |
+
|
219 |
+
// Optional parameter
|
220 |
+
if (isset($opt['OptionSettings']))
|
221 |
+
{
|
222 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
223 |
+
'OptionSettings' => $opt['OptionSettings']
|
224 |
+
), 'member'));
|
225 |
+
unset($opt['OptionSettings']);
|
226 |
+
}
|
227 |
+
|
228 |
+
// Optional parameter
|
229 |
+
if (isset($opt['OptionsToRemove']))
|
230 |
+
{
|
231 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
232 |
+
'OptionsToRemove' => $opt['OptionsToRemove']
|
233 |
+
), 'member'));
|
234 |
+
unset($opt['OptionsToRemove']);
|
235 |
+
}
|
236 |
+
|
237 |
+
return $this->authenticate('CreateEnvironment', $opt, $this->hostname);
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
*
|
242 |
+
* Creates the Amazon S3 storage location for the account.
|
243 |
+
*
|
244 |
+
* This location is used to store user log files.
|
245 |
+
*
|
246 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
247 |
+
* <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>
|
248 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
249 |
+
*/
|
250 |
+
public function create_storage_location($opt = null)
|
251 |
+
{
|
252 |
+
if (!$opt) $opt = array();
|
253 |
+
|
254 |
+
return $this->authenticate('CreateStorageLocation', $opt, $this->hostname);
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
*
|
259 |
+
* Initiates a request to compile the specified type of information of the deployed environment.
|
260 |
+
*
|
261 |
+
* Setting the <code>InfoType</code> to <code>tail</code> compiles the last lines from the application server log files of
|
262 |
+
* every Amazon EC2 instance in your environment. Use RetrieveEnvironmentInfo to access the compiled information.
|
263 |
+
*
|
264 |
+
* Related Topics
|
265 |
+
*
|
266 |
+
* <ul>
|
267 |
+
*
|
268 |
+
* <li> RetrieveEnvironmentInfo </li>
|
269 |
+
*
|
270 |
+
* </ul>
|
271 |
+
*
|
272 |
+
* @param string $info_type (Required) The type of information to request. [Allowed values: <code>tail</code>]
|
273 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
274 |
+
* <li><code>EnvironmentId</code> - <code>string</code> - Optional - The ID of the environment of the requested data. If no such environment is found, <code>RequestEnvironmentInfo</code> returns an <code>InvalidParameterValue</code> error. </li>
|
275 |
+
* <li><code>EnvironmentName</code> - <code>string</code> - Optional - The name of the environment of the requested data. If no such environment is found, <code>RequestEnvironmentInfo</code> returns an <code>InvalidParameterValue</code> error. </li>
|
276 |
+
* <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>
|
277 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
278 |
+
*/
|
279 |
+
public function request_environment_info($info_type, $opt = null)
|
280 |
+
{
|
281 |
+
if (!$opt) $opt = array();
|
282 |
+
$opt['InfoType'] = $info_type;
|
283 |
+
|
284 |
+
return $this->authenticate('RequestEnvironmentInfo', $opt, $this->hostname);
|
285 |
+
}
|
286 |
+
|
287 |
+
/**
|
288 |
+
*
|
289 |
+
* Creates an application version for the specified application.
|
290 |
+
*
|
291 |
+
* Once you create an application version with a specified Amazon S3 bucket and key location, you cannot change that Amazon
|
292 |
+
* S3 location. If you change the Amazon S3 location, you receive an exception when you attempt to launch an environment
|
293 |
+
* from the application version.
|
294 |
+
*
|
295 |
+
* @param string $application_name (Required) The name of the application. If no application is found with this name, and <code>AutoCreateApplication</code> is <code>false</code>, returns an <code>InvalidParameterValue</code> error.
|
296 |
+
* @param string $version_label (Required) A label identifying this version. Constraint: Must be unique per application. If an application version already exists with this label for the specified application, AWS Elastic Beanstalk returns an <code>InvalidParameterValue</code> error.
|
297 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
298 |
+
* <li><code>Description</code> - <code>string</code> - Optional - Describes this version. </li>
|
299 |
+
* <li><code>SourceBundle</code> - <code>array</code> - Optional - The Amazon S3 bucket and key that identify the location of the source bundle for this version. If data found at the Amazon S3 location exceeds the maximum allowed source bundle size, AWS Elastic Beanstalk returns an <code>InvalidParameterValue</code> error. Default: If not specified, AWS Elastic Beanstalk uses a sample application. If only partially specified (for example, a bucket is provided but not the key) or if no data is found at the Amazon S3 location, AWS Elastic Beanstalk returns an <code>InvalidParameterCombination</code> error. <ul>
|
300 |
+
* <li><code>S3Bucket</code> - <code>string</code> - Optional - The Amazon S3 bucket where the data is located. </li>
|
301 |
+
* <li><code>S3Key</code> - <code>string</code> - Optional - The Amazon S3 key where the data is located. </li></ul></li>
|
302 |
+
* <li><code>AutoCreateApplication</code> - <code>boolean</code> - Optional - Determines how the system behaves if the specified application for this version does not already exist: <enumValues> <value name="true"> <code>true</code>: Automatically creates the specified application for this version if it does not already exist. </value> <value name="false"> <code>false</code>: Returns an <code>InvalidParameterValue</code> if the specified application for this version does not already exist. </value> </enumValues> <ul> <li> <code>true</code> : Automatically creates the specified application for this release if it does not already exist. </li><li> <code>false</code> : Throws an <code>InvalidParameterValue</code> if the specified application for this release does not already exist. </li> </ul> Default: <code>false</code> Valid Values: <code>true</code> | <code>false</code> </li>
|
303 |
+
* <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>
|
304 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
305 |
+
*/
|
306 |
+
public function create_application_version($application_name, $version_label, $opt = null)
|
307 |
+
{
|
308 |
+
if (!$opt) $opt = array();
|
309 |
+
$opt['ApplicationName'] = $application_name;
|
310 |
+
$opt['VersionLabel'] = $version_label;
|
311 |
+
|
312 |
+
// Optional parameter
|
313 |
+
if (isset($opt['SourceBundle']))
|
314 |
+
{
|
315 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
316 |
+
'SourceBundle' => $opt['SourceBundle']
|
317 |
+
), 'member'));
|
318 |
+
unset($opt['SourceBundle']);
|
319 |
+
}
|
320 |
+
|
321 |
+
return $this->authenticate('CreateApplicationVersion', $opt, $this->hostname);
|
322 |
+
}
|
323 |
+
|
324 |
+
/**
|
325 |
+
*
|
326 |
+
* Deletes the specified version from the specified application.
|
327 |
+
*
|
328 |
+
* You cannot delete an application version that is associated with a running environment.
|
329 |
+
*
|
330 |
+
* @param string $application_name (Required) The name of the application to delete releases from.
|
331 |
+
* @param string $version_label (Required) The label of the version to delete.
|
332 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
333 |
+
* <li><code>DeleteSourceBundle</code> - <code>boolean</code> - Optional - Indicates whether to delete the associated source bundle from Amazon S3: <ul> <li> <code>true</code>: An attempt is made to delete the associated Amazon S3 source bundle specified at time of creation. </li><li> <code>false</code>: No action is taken on the Amazon S3 source bundle specified at time of creation. </li> </ul> Valid Values: <code>true</code> | <code>false</code> </li>
|
334 |
+
* <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>
|
335 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
336 |
+
*/
|
337 |
+
public function delete_application_version($application_name, $version_label, $opt = null)
|
338 |
+
{
|
339 |
+
if (!$opt) $opt = array();
|
340 |
+
$opt['ApplicationName'] = $application_name;
|
341 |
+
$opt['VersionLabel'] = $version_label;
|
342 |
+
|
343 |
+
return $this->authenticate('DeleteApplicationVersion', $opt, $this->hostname);
|
344 |
+
}
|
345 |
+
|
346 |
+
/**
|
347 |
+
*
|
348 |
+
* Returns descriptions for existing application versions.
|
349 |
+
*
|
350 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
351 |
+
* <li><code>ApplicationName</code> - <code>string</code> - Optional - If specified, AWS Elastic Beanstalk restricts the returned descriptions to only include ones that are associated with the specified application. </li>
|
352 |
+
* <li><code>VersionLabels</code> - <code>string|array</code> - Optional - If specified, restricts the returned descriptions to only include ones that have the specified version labels. Pass a string for a single value, or an indexed array for multiple values. </li>
|
353 |
+
* <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>
|
354 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
355 |
+
*/
|
356 |
+
public function describe_application_versions($opt = null)
|
357 |
+
{
|
358 |
+
if (!$opt) $opt = array();
|
359 |
+
|
360 |
+
// Optional parameter
|
361 |
+
if (isset($opt['VersionLabels']))
|
362 |
+
{
|
363 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
364 |
+
'VersionLabels' => (is_array($opt['VersionLabels']) ? $opt['VersionLabels'] : array($opt['VersionLabels']))
|
365 |
+
), 'member'));
|
366 |
+
unset($opt['VersionLabels']);
|
367 |
+
}
|
368 |
+
|
369 |
+
return $this->authenticate('DescribeApplicationVersions', $opt, $this->hostname);
|
370 |
+
}
|
371 |
+
|
372 |
+
/**
|
373 |
+
*
|
374 |
+
* Deletes the specified application along with all associated versions and configurations.
|
375 |
+
*
|
376 |
+
* You cannot delete an application that has a running environment.
|
377 |
+
*
|
378 |
+
* @param string $application_name (Required) The name of the application to delete.
|
379 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
380 |
+
* <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>
|
381 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
382 |
+
*/
|
383 |
+
public function delete_application($application_name, $opt = null)
|
384 |
+
{
|
385 |
+
if (!$opt) $opt = array();
|
386 |
+
$opt['ApplicationName'] = $application_name;
|
387 |
+
|
388 |
+
return $this->authenticate('DeleteApplication', $opt, $this->hostname);
|
389 |
+
}
|
390 |
+
|
391 |
+
/**
|
392 |
+
*
|
393 |
+
* Updates the specified application version to have the specified properties.
|
394 |
+
*
|
395 |
+
* If a property (for example, <code>description</code>) is not provided, the value remains unchanged. To clear
|
396 |
+
* properties, specify an empty string.
|
397 |
+
*
|
398 |
+
* @param string $application_name (Required) The name of the application associated with this version. If no application is found with this name, <code>UpdateApplication</code> returns an <code>InvalidParameterValue</code> error.
|
399 |
+
* @param string $version_label (Required) The name of the version to update. If no application version is found with this label, <code>UpdateApplication</code> returns an <code>InvalidParameterValue</code> error.
|
400 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
401 |
+
* <li><code>Description</code> - <code>string</code> - Optional - A new description for this release. </li>
|
402 |
+
* <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>
|
403 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
404 |
+
*/
|
405 |
+
public function update_application_version($application_name, $version_label, $opt = null)
|
406 |
+
{
|
407 |
+
if (!$opt) $opt = array();
|
408 |
+
$opt['ApplicationName'] = $application_name;
|
409 |
+
$opt['VersionLabel'] = $version_label;
|
410 |
+
|
411 |
+
return $this->authenticate('UpdateApplicationVersion', $opt, $this->hostname);
|
412 |
+
}
|
413 |
+
|
414 |
+
/**
|
415 |
+
*
|
416 |
+
* Creates an application that has one configuration template named <code>default</code> and no application versions.
|
417 |
+
*
|
418 |
+
* The <code>default</code> configuration template is for a 32-bit version of the Amazon Linux operating system running
|
419 |
+
* the Tomcat 6 application container.
|
420 |
+
*
|
421 |
+
* @param string $application_name (Required) The name of the application. Constraint: This name must be unique within your account. If the specified name already exists, the action returns an <code>InvalidParameterValue</code> error.
|
422 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
423 |
+
* <li><code>Description</code> - <code>string</code> - Optional - Describes the application. </li>
|
424 |
+
* <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>
|
425 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
426 |
+
*/
|
427 |
+
public function create_application($application_name, $opt = null)
|
428 |
+
{
|
429 |
+
if (!$opt) $opt = array();
|
430 |
+
$opt['ApplicationName'] = $application_name;
|
431 |
+
|
432 |
+
return $this->authenticate('CreateApplication', $opt, $this->hostname);
|
433 |
+
}
|
434 |
+
|
435 |
+
/**
|
436 |
+
*
|
437 |
+
* Updates the specified configuration template to have the specified properties or configuration option values.
|
438 |
+
*
|
439 |
+
* If a property (for example, <code>ApplicationName</code>) is not provided, its value remains unchanged. To clear such
|
440 |
+
* properties, specify an empty string.
|
441 |
+
*
|
442 |
+
* Related Topics
|
443 |
+
*
|
444 |
+
* <ul> <li> DescribeConfigurationOptions </li>
|
445 |
+
*
|
446 |
+
* </ul>
|
447 |
+
*
|
448 |
+
* @param string $application_name (Required) The name of the application associated with the configuration template to update. If no application is found with this name, <code>UpdateConfigurationTemplate</code> returns an <code>InvalidParameterValue</code> error.
|
449 |
+
* @param string $template_name (Required) The name of the configuration template to update. If no configuration template is found with this name, <code>UpdateConfigurationTemplate</code> returns an <code>InvalidParameterValue</code> error.
|
450 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
451 |
+
* <li><code>Description</code> - <code>string</code> - Optional - A new description for the configuration. </li>
|
452 |
+
* <li><code>OptionSettings</code> - <code>array</code> - Optional - A list of configuration option settings to update with the new specified option value. <ul>
|
453 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
454 |
+
* <li><code>Namespace</code> - <code>string</code> - Optional - A unique namespace identifying the option's associated AWS resource. </li>
|
455 |
+
* <li><code>OptionName</code> - <code>string</code> - Optional - The name of the configuration option. </li>
|
456 |
+
* <li><code>Value</code> - <code>string</code> - Optional - The current value for the configuration option. </li>
|
457 |
+
* </ul></li>
|
458 |
+
* </ul></li>
|
459 |
+
* <li><code>OptionsToRemove</code> - <code>array</code> - Optional - A list of configuration options to remove from the configuration set. Constraint: You can remove only <code>UserDefined</code> configuration options. <ul>
|
460 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
461 |
+
* <li><code>Namespace</code> - <code>string</code> - Optional - A unique namespace identifying the option's associated AWS resource. </li>
|
462 |
+
* <li><code>OptionName</code> - <code>string</code> - Optional - The name of the configuration option. </li>
|
463 |
+
* </ul></li>
|
464 |
+
* </ul></li>
|
465 |
+
* <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>
|
466 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
467 |
+
*/
|
468 |
+
public function update_configuration_template($application_name, $template_name, $opt = null)
|
469 |
+
{
|
470 |
+
if (!$opt) $opt = array();
|
471 |
+
$opt['ApplicationName'] = $application_name;
|
472 |
+
$opt['TemplateName'] = $template_name;
|
473 |
+
|
474 |
+
// Optional parameter
|
475 |
+
if (isset($opt['OptionSettings']))
|
476 |
+
{
|
477 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
478 |
+
'OptionSettings' => $opt['OptionSettings']
|
479 |
+
), 'member'));
|
480 |
+
unset($opt['OptionSettings']);
|
481 |
+
}
|
482 |
+
|
483 |
+
// Optional parameter
|
484 |
+
if (isset($opt['OptionsToRemove']))
|
485 |
+
{
|
486 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
487 |
+
'OptionsToRemove' => $opt['OptionsToRemove']
|
488 |
+
), 'member'));
|
489 |
+
unset($opt['OptionsToRemove']);
|
490 |
+
}
|
491 |
+
|
492 |
+
return $this->authenticate('UpdateConfigurationTemplate', $opt, $this->hostname);
|
493 |
+
}
|
494 |
+
|
495 |
+
/**
|
496 |
+
*
|
497 |
+
* Retrieves the compiled information from a RequestEnvironmentInfo request.
|
498 |
+
*
|
499 |
+
* Related Topics
|
500 |
+
*
|
501 |
+
* <ul>
|
502 |
+
*
|
503 |
+
* <li> RequestEnvironmentInfo </li>
|
504 |
+
*
|
505 |
+
* </ul>
|
506 |
+
*
|
507 |
+
* @param string $info_type (Required) The type of information to retrieve. [Allowed values: <code>tail</code>]
|
508 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
509 |
+
* <li><code>EnvironmentId</code> - <code>string</code> - Optional - The ID of the data's environment. If no such environment is found, returns an <code>InvalidParameterValue</code> error. </li>
|
510 |
+
* <li><code>EnvironmentName</code> - <code>string</code> - Optional - The name of the data's environment. If no such environment is found, returns an <code>InvalidParameterValue</code> error. </li>
|
511 |
+
* <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>
|
512 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
513 |
+
*/
|
514 |
+
public function retrieve_environment_info($info_type, $opt = null)
|
515 |
+
{
|
516 |
+
if (!$opt) $opt = array();
|
517 |
+
$opt['InfoType'] = $info_type;
|
518 |
+
|
519 |
+
return $this->authenticate('RetrieveEnvironmentInfo', $opt, $this->hostname);
|
520 |
+
}
|
521 |
+
|
522 |
+
/**
|
523 |
+
*
|
524 |
+
* Returns a list of the available solution stack names.
|
525 |
+
*
|
526 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
527 |
+
* <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>
|
528 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
529 |
+
*/
|
530 |
+
public function list_available_solution_stacks($opt = null)
|
531 |
+
{
|
532 |
+
if (!$opt) $opt = array();
|
533 |
+
|
534 |
+
return $this->authenticate('ListAvailableSolutionStacks', $opt, $this->hostname);
|
535 |
+
}
|
536 |
+
|
537 |
+
/**
|
538 |
+
*
|
539 |
+
* Updates the specified application to have the specified properties.
|
540 |
+
*
|
541 |
+
* If a property (for example, <code>description</code>) is not provided, the value remains unchanged. To clear these
|
542 |
+
* properties, specify an empty string.
|
543 |
+
*
|
544 |
+
* @param string $application_name (Required) The name of the application to update. If no such application is found, <code>UpdateApplication</code> returns an <code>InvalidParameterValue</code> error.
|
545 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
546 |
+
* <li><code>Description</code> - <code>string</code> - Optional - A new description for the application. Default: If not specified, AWS Elastic Beanstalk does not update the description. </li>
|
547 |
+
* <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>
|
548 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
549 |
+
*/
|
550 |
+
public function update_application($application_name, $opt = null)
|
551 |
+
{
|
552 |
+
if (!$opt) $opt = array();
|
553 |
+
$opt['ApplicationName'] = $application_name;
|
554 |
+
|
555 |
+
return $this->authenticate('UpdateApplication', $opt, $this->hostname);
|
556 |
+
}
|
557 |
+
|
558 |
+
/**
|
559 |
+
*
|
560 |
+
* Returns descriptions for existing environments.
|
561 |
+
*
|
562 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
563 |
+
* <li><code>ApplicationName</code> - <code>string</code> - Optional - If specified, AWS Elastic Beanstalk restricts the returned descriptions to include only those that are associated with this application. </li>
|
564 |
+
* <li><code>VersionLabel</code> - <code>string</code> - Optional - If specified, AWS Elastic Beanstalk restricts the returned descriptions to include only those that are associated with this application version. </li>
|
565 |
+
* <li><code>EnvironmentIds</code> - <code>string|array</code> - Optional - If specified, AWS Elastic Beanstalk restricts the returned descriptions to include only those that have the specified IDs. Pass a string for a single value, or an indexed array for multiple values. </li>
|
566 |
+
* <li><code>EnvironmentNames</code> - <code>string|array</code> - Optional - If specified, AWS Elastic Beanstalk restricts the returned descriptions to include only those that have the specified names. Pass a string for a single value, or an indexed array for multiple values. </li>
|
567 |
+
* <li><code>IncludeDeleted</code> - <code>boolean</code> - Optional - Indicates whether to include deleted environments: <code>true</code>: Environments that have been deleted after <code>IncludedDeletedBackTo</code> are displayed. <code>false</code>: Do not include deleted environments. </li>
|
568 |
+
* <li><code>IncludedDeletedBackTo</code> - <code>string</code> - Optional - If specified when <code>IncludeDeleted</code> is set to <code>true</code>, then environments deleted after this date are displayed. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
569 |
+
* <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>
|
570 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
571 |
+
*/
|
572 |
+
public function describe_environments($opt = null)
|
573 |
+
{
|
574 |
+
if (!$opt) $opt = array();
|
575 |
+
|
576 |
+
// Optional parameter
|
577 |
+
if (isset($opt['EnvironmentIds']))
|
578 |
+
{
|
579 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
580 |
+
'EnvironmentIds' => (is_array($opt['EnvironmentIds']) ? $opt['EnvironmentIds'] : array($opt['EnvironmentIds']))
|
581 |
+
), 'member'));
|
582 |
+
unset($opt['EnvironmentIds']);
|
583 |
+
}
|
584 |
+
|
585 |
+
// Optional parameter
|
586 |
+
if (isset($opt['EnvironmentNames']))
|
587 |
+
{
|
588 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
589 |
+
'EnvironmentNames' => (is_array($opt['EnvironmentNames']) ? $opt['EnvironmentNames'] : array($opt['EnvironmentNames']))
|
590 |
+
), 'member'));
|
591 |
+
unset($opt['EnvironmentNames']);
|
592 |
+
}
|
593 |
+
|
594 |
+
// Optional parameter
|
595 |
+
if (isset($opt['IncludedDeletedBackTo']))
|
596 |
+
{
|
597 |
+
$opt['IncludedDeletedBackTo'] = $this->util->convert_date_to_iso8601($opt['IncludedDeletedBackTo']);
|
598 |
+
}
|
599 |
+
|
600 |
+
return $this->authenticate('DescribeEnvironments', $opt, $this->hostname);
|
601 |
+
}
|
602 |
+
|
603 |
+
/**
|
604 |
+
*
|
605 |
+
* Returns AWS resources for this environment.
|
606 |
+
*
|
607 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
608 |
+
* <li><code>EnvironmentId</code> - <code>string</code> - Optional - The ID of the environment to retrieve AWS resource usage data. </li>
|
609 |
+
* <li><code>EnvironmentName</code> - <code>string</code> - Optional - The name of the environment to retrieve AWS resource usage data. </li>
|
610 |
+
* <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>
|
611 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
612 |
+
*/
|
613 |
+
public function describe_environment_resources($opt = null)
|
614 |
+
{
|
615 |
+
if (!$opt) $opt = array();
|
616 |
+
|
617 |
+
return $this->authenticate('DescribeEnvironmentResources', $opt, $this->hostname);
|
618 |
+
}
|
619 |
+
|
620 |
+
/**
|
621 |
+
*
|
622 |
+
* Terminates the specified environment.
|
623 |
+
*
|
624 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
625 |
+
* <li><code>EnvironmentId</code> - <code>string</code> - Optional - The ID of the environment to terminate. </li>
|
626 |
+
* <li><code>EnvironmentName</code> - <code>string</code> - Optional - The name of the environment to terminate. </li>
|
627 |
+
* <li><code>TerminateResources</code> - <code>boolean</code> - Optional - Indicates whether the associated AWS resources should shut down when the environment is terminated: <enumValues> <value name="true"> <code>true</code>: (default) The user AWS resources (for example, the Auto Scaling group, LoadBalancer, etc.) are terminated along with the environment. </value> <value name="false"> <code>false</code>: The environment is removed from the AWS Elastic Beanstalk but the AWS resources continue to operate. </value> </enumValues> <ul> <li> <code>true</code>: The specified environment as well as the associated AWS resources, such as Auto Scaling group and LoadBalancer, are terminated. </li><li> <code>false</code>: AWS Elastic Beanstalk resource management is removed from the environment, but the AWS resources continue to operate. </li> </ul> For more information, see the AWS Elastic Beanstalk User Guide. Default: <code>true</code> Valid Values: <code>true</code> | <code>false</code> </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 terminate_environment($opt = null)
|
632 |
+
{
|
633 |
+
if (!$opt) $opt = array();
|
634 |
+
|
635 |
+
return $this->authenticate('TerminateEnvironment', $opt, $this->hostname);
|
636 |
+
}
|
637 |
+
|
638 |
+
/**
|
639 |
+
*
|
640 |
+
* Takes a set of configuration settings and either a configuration template or environment, and determines whether those
|
641 |
+
* values are valid.
|
642 |
+
*
|
643 |
+
* This action returns a list of messages indicating any errors or warnings associated with the selection of option
|
644 |
+
* values.
|
645 |
+
*
|
646 |
+
* @param string $application_name (Required) The name of the application that the configuration template or environment belongs to.
|
647 |
+
* @param array $option_settings (Required) A list of the options and desired values to evaluate. <ul>
|
648 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
649 |
+
* <li><code>Namespace</code> - <code>string</code> - Optional - A unique namespace identifying the option's associated AWS resource. </li>
|
650 |
+
* <li><code>OptionName</code> - <code>string</code> - Optional - The name of the configuration option. </li>
|
651 |
+
* <li><code>Value</code> - <code>string</code> - Optional - The current value for the configuration option. </li>
|
652 |
+
* </ul></li>
|
653 |
+
* </ul>
|
654 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
655 |
+
* <li><code>TemplateName</code> - <code>string</code> - Optional - The name of the configuration template to validate the settings against. Condition: You cannot specify both this and an environment name. </li>
|
656 |
+
* <li><code>EnvironmentName</code> - <code>string</code> - Optional - The name of the environment to validate the settings against. Condition: You cannot specify both this and a configuration template name. </li>
|
657 |
+
* <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>
|
658 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
659 |
+
*/
|
660 |
+
public function validate_configuration_settings($application_name, $option_settings, $opt = null)
|
661 |
+
{
|
662 |
+
if (!$opt) $opt = array();
|
663 |
+
$opt['ApplicationName'] = $application_name;
|
664 |
+
|
665 |
+
// Required parameter
|
666 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
667 |
+
'OptionSettings' => (is_array($option_settings) ? $option_settings : array($option_settings))
|
668 |
+
), 'member'));
|
669 |
+
|
670 |
+
return $this->authenticate('ValidateConfigurationSettings', $opt, $this->hostname);
|
671 |
+
}
|
672 |
+
|
673 |
+
/**
|
674 |
+
*
|
675 |
+
* Causes the environment to restart the application container server running on each Amazon EC2 instance.
|
676 |
+
*
|
677 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
678 |
+
* <li><code>EnvironmentId</code> - <code>string</code> - Optional - The ID of the environment to restart the server for. </li>
|
679 |
+
* <li><code>EnvironmentName</code> - <code>string</code> - Optional - The name of the environment to restart the server for. </li>
|
680 |
+
* <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>
|
681 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
682 |
+
*/
|
683 |
+
public function restart_app_server($opt = null)
|
684 |
+
{
|
685 |
+
if (!$opt) $opt = array();
|
686 |
+
|
687 |
+
return $this->authenticate('RestartAppServer', $opt, $this->hostname);
|
688 |
+
}
|
689 |
+
|
690 |
+
/**
|
691 |
+
*
|
692 |
+
* Deletes the draft configuration associated with the running environment.
|
693 |
+
*
|
694 |
+
* Updating a running environment with any configuration changes creates a draft configuration set. You can get the draft
|
695 |
+
* configuration using DescribeConfigurationSettings while the update is in progress or if the update fails. The
|
696 |
+
* <code>DeploymentStatus</code> for the draft configuration indicates whether the deployment is in process or has failed.
|
697 |
+
* The draft configuration remains in existence until it is deleted with this action.
|
698 |
+
*
|
699 |
+
* @param string $application_name (Required) The name of the application the environment is associated with.
|
700 |
+
* @param string $environment_name (Required) The name of the environment to delete the draft configuration from.
|
701 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
702 |
+
* <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>
|
703 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
704 |
+
*/
|
705 |
+
public function delete_environment_configuration($application_name, $environment_name, $opt = null)
|
706 |
+
{
|
707 |
+
if (!$opt) $opt = array();
|
708 |
+
$opt['ApplicationName'] = $application_name;
|
709 |
+
$opt['EnvironmentName'] = $environment_name;
|
710 |
+
|
711 |
+
return $this->authenticate('DeleteEnvironmentConfiguration', $opt, $this->hostname);
|
712 |
+
}
|
713 |
+
|
714 |
+
/**
|
715 |
+
*
|
716 |
+
* Updates the environment description, deploys a new application version, updates the configuration settings to an
|
717 |
+
* entirely new configuration template, or updates select configuration option values in the running environment.
|
718 |
+
*
|
719 |
+
* Attempting to update both the release and configuration is not allowed and AWS Elastic Beanstalk returns an
|
720 |
+
* <code>InvalidParameterCombination</code> error.
|
721 |
+
*
|
722 |
+
* When updating the configuration settings to a new template or individual settings, a draft configuration is created and
|
723 |
+
* DescribeConfigurationSettings for this environment returns two setting descriptions with different
|
724 |
+
* <code>DeploymentStatus</code> values.
|
725 |
+
*
|
726 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
727 |
+
* <li><code>EnvironmentId</code> - <code>string</code> - Optional - The ID of the environment to update. If no environment with this ID exists, AWS Elastic Beanstalk returns an <code>InvalidParameterValue</code> error. </li>
|
728 |
+
* <li><code>EnvironmentName</code> - <code>string</code> - Optional - The name of the environment to update. If no environment with this name exists, AWS Elastic Beanstalk returns an <code>InvalidParameterValue</code> error. </li>
|
729 |
+
* <li><code>VersionLabel</code> - <code>string</code> - Optional - If this parameter is specified, AWS Elastic Beanstalk deploys the named application version to the environment. If no such application version is found, returns an <code>InvalidParameterValue</code> error. </li>
|
730 |
+
* <li><code>TemplateName</code> - <code>string</code> - Optional - If this parameter is specified, AWS Elastic Beanstalk deploys this configuration template to the environment. If no such configuration template is found, AWS Elastic Beanstalk returns an <code>InvalidParameterValue</code> error. </li>
|
731 |
+
* <li><code>Description</code> - <code>string</code> - Optional - If this parameter is specified, AWS Elastic Beanstalk updates the description of this environment. </li>
|
732 |
+
* <li><code>OptionSettings</code> - <code>array</code> - Optional - If specified, AWS Elastic Beanstalk updates the configuration set associated with the running environment and sets the specified configuration options to the requested value. <ul>
|
733 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
734 |
+
* <li><code>Namespace</code> - <code>string</code> - Optional - A unique namespace identifying the option's associated AWS resource. </li>
|
735 |
+
* <li><code>OptionName</code> - <code>string</code> - Optional - The name of the configuration option. </li>
|
736 |
+
* <li><code>Value</code> - <code>string</code> - Optional - The current value for the configuration option. </li>
|
737 |
+
* </ul></li>
|
738 |
+
* </ul></li>
|
739 |
+
* <li><code>OptionsToRemove</code> - <code>array</code> - Optional - A list of custom user-defined configuration options to remove from the configuration set for this environment. <ul>
|
740 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
741 |
+
* <li><code>Namespace</code> - <code>string</code> - Optional - A unique namespace identifying the option's associated AWS resource. </li>
|
742 |
+
* <li><code>OptionName</code> - <code>string</code> - Optional - The name of the configuration option. </li>
|
743 |
+
* </ul></li>
|
744 |
+
* </ul></li>
|
745 |
+
* <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>
|
746 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
747 |
+
*/
|
748 |
+
public function update_environment($opt = null)
|
749 |
+
{
|
750 |
+
if (!$opt) $opt = array();
|
751 |
+
|
752 |
+
// Optional parameter
|
753 |
+
if (isset($opt['OptionSettings']))
|
754 |
+
{
|
755 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
756 |
+
'OptionSettings' => $opt['OptionSettings']
|
757 |
+
), 'member'));
|
758 |
+
unset($opt['OptionSettings']);
|
759 |
+
}
|
760 |
+
|
761 |
+
// Optional parameter
|
762 |
+
if (isset($opt['OptionsToRemove']))
|
763 |
+
{
|
764 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
765 |
+
'OptionsToRemove' => $opt['OptionsToRemove']
|
766 |
+
), 'member'));
|
767 |
+
unset($opt['OptionsToRemove']);
|
768 |
+
}
|
769 |
+
|
770 |
+
return $this->authenticate('UpdateEnvironment', $opt, $this->hostname);
|
771 |
+
}
|
772 |
+
|
773 |
+
/**
|
774 |
+
*
|
775 |
+
* Creates a configuration template. Templates are associated with a specific application and are used to deploy different
|
776 |
+
* versions of the application with the same configuration settings.
|
777 |
+
*
|
778 |
+
* Related Topics
|
779 |
+
*
|
780 |
+
* <ul>
|
781 |
+
*
|
782 |
+
* <li> DescribeConfigurationOptions </li>
|
783 |
+
*
|
784 |
+
* <li> DescribeConfigurationSettings </li>
|
785 |
+
*
|
786 |
+
* <li> ListAvailableSolutionStacks </li>
|
787 |
+
*
|
788 |
+
* </ul>
|
789 |
+
*
|
790 |
+
* @param string $application_name (Required) The name of the application to associate with this configuration template. If no application is found with this name, AWS Elastic Beanstalk returns an <code>InvalidParameterValue</code> error.
|
791 |
+
* @param string $template_name (Required) The name of the configuration template. Constraint: This name must be unique per application. Default: If a configuration template already exists with this name, AWS Elastic Beanstalk returns an <code>InvalidParameterValue</code> error.
|
792 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
793 |
+
* <li><code>SolutionStackName</code> - <code>string</code> - Optional - The name of the solution stack used by this configuration. The solution stack specifies the operating system, architecture, and application server for a configuration template. It determines the set of configuration options as well as the possible and default values. Use ListAvailableSolutionStacks to obtain a list of available solution stacks. Default: If the <code>SolutionStackName</code> is not specified and the source configuration parameter is blank, AWS Elastic Beanstalk uses the default solution stack. If not specified and the source configuration parameter is specified, AWS Elastic Beanstalk uses the same solution stack as the source configuration template. </li>
|
794 |
+
* <li><code>SourceConfiguration</code> - <code>array</code> - Optional - If specified, AWS Elastic Beanstalk uses the configuration values from the specified configuration template to create a new configuration. Values specified in the <code>OptionSettings</code> parameter of this call overrides any values obtained from the <code>SourceConfiguration</code>. If no configuration template is found, returns an <code>InvalidParameterValue</code> error. Constraint: If both the solution stack name parameter and the source configuration parameters are specified, the solution stack of the source configuration template must match the specified solution stack name or else AWS Elastic Beanstalk returns an <code>InvalidParameterCombination</code> error. <ul>
|
795 |
+
* <li><code>ApplicationName</code> - <code>string</code> - Optional - The name of the application associated with the configuration. </li>
|
796 |
+
* <li><code>TemplateName</code> - <code>string</code> - Optional - The name of the configuration template. </li></ul></li>
|
797 |
+
* <li><code>Description</code> - <code>string</code> - Optional - Describes this configuration. </li>
|
798 |
+
* <li><code>OptionSettings</code> - <code>array</code> - Optional - If specified, AWS Elastic Beanstalk sets the specified configuration option to the requested value. The new value overrides the value obtained from the solution stack or the source configuration template. <ul>
|
799 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
800 |
+
* <li><code>Namespace</code> - <code>string</code> - Optional - A unique namespace identifying the option's associated AWS resource. </li>
|
801 |
+
* <li><code>OptionName</code> - <code>string</code> - Optional - The name of the configuration option. </li>
|
802 |
+
* <li><code>Value</code> - <code>string</code> - Optional - The current value for the configuration option. </li>
|
803 |
+
* </ul></li>
|
804 |
+
* </ul></li>
|
805 |
+
* <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>
|
806 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
807 |
+
*/
|
808 |
+
public function create_configuration_template($application_name, $template_name, $opt = null)
|
809 |
+
{
|
810 |
+
if (!$opt) $opt = array();
|
811 |
+
$opt['ApplicationName'] = $application_name;
|
812 |
+
$opt['TemplateName'] = $template_name;
|
813 |
+
|
814 |
+
// Optional parameter
|
815 |
+
if (isset($opt['SourceConfiguration']))
|
816 |
+
{
|
817 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
818 |
+
'SourceConfiguration' => $opt['SourceConfiguration']
|
819 |
+
), 'member'));
|
820 |
+
unset($opt['SourceConfiguration']);
|
821 |
+
}
|
822 |
+
|
823 |
+
// Optional parameter
|
824 |
+
if (isset($opt['OptionSettings']))
|
825 |
+
{
|
826 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
827 |
+
'OptionSettings' => $opt['OptionSettings']
|
828 |
+
), 'member'));
|
829 |
+
unset($opt['OptionSettings']);
|
830 |
+
}
|
831 |
+
|
832 |
+
return $this->authenticate('CreateConfigurationTemplate', $opt, $this->hostname);
|
833 |
+
}
|
834 |
+
|
835 |
+
/**
|
836 |
+
*
|
837 |
+
* Returns a description of the settings for the specified configuration set, that is, either a configuration template or
|
838 |
+
* the configuration set associated with a running environment.
|
839 |
+
*
|
840 |
+
* When describing the settings for the configuration set associated with a running environment, it is possible to receive
|
841 |
+
* two sets of setting descriptions. One is the deployed configuration set, and the other is a draft configuration of an
|
842 |
+
* environment that is either in the process of deployment or that failed to deploy.
|
843 |
+
*
|
844 |
+
* Related Topics
|
845 |
+
*
|
846 |
+
* <ul> <li> DeleteEnvironmentConfiguration </li>
|
847 |
+
*
|
848 |
+
* </ul>
|
849 |
+
*
|
850 |
+
* @param string $application_name (Required) The application for the environment or configuration template.
|
851 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
852 |
+
* <li><code>TemplateName</code> - <code>string</code> - Optional - The name of the configuration template to describe. </li>
|
853 |
+
* <li><code>EnvironmentName</code> - <code>string</code> - Optional - The name of the environment to describe. </li>
|
854 |
+
* <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>
|
855 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
856 |
+
*/
|
857 |
+
public function describe_configuration_settings($application_name, $opt = null)
|
858 |
+
{
|
859 |
+
if (!$opt) $opt = array();
|
860 |
+
$opt['ApplicationName'] = $application_name;
|
861 |
+
|
862 |
+
return $this->authenticate('DescribeConfigurationSettings', $opt, $this->hostname);
|
863 |
+
}
|
864 |
+
|
865 |
+
/**
|
866 |
+
*
|
867 |
+
* Returns the descriptions of existing applications.
|
868 |
+
*
|
869 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
870 |
+
* <li><code>ApplicationNames</code> - <code>string|array</code> - Optional - If specified, AWS Elastic Beanstalk restricts the returned descriptions to only include those with the specified names. Pass a string for a single value, or an indexed array for multiple values. </li>
|
871 |
+
* <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>
|
872 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
873 |
+
*/
|
874 |
+
public function describe_applications($opt = null)
|
875 |
+
{
|
876 |
+
if (!$opt) $opt = array();
|
877 |
+
|
878 |
+
// Optional parameter
|
879 |
+
if (isset($opt['ApplicationNames']))
|
880 |
+
{
|
881 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
882 |
+
'ApplicationNames' => (is_array($opt['ApplicationNames']) ? $opt['ApplicationNames'] : array($opt['ApplicationNames']))
|
883 |
+
), 'member'));
|
884 |
+
unset($opt['ApplicationNames']);
|
885 |
+
}
|
886 |
+
|
887 |
+
return $this->authenticate('DescribeApplications', $opt, $this->hostname);
|
888 |
+
}
|
889 |
+
|
890 |
+
/**
|
891 |
+
*
|
892 |
+
* Deletes and recreates all of the AWS resources (for example: the Auto Scaling group, load balancer, etc.) for a
|
893 |
+
* specified environment and forces a restart.
|
894 |
+
*
|
895 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
896 |
+
* <li><code>EnvironmentId</code> - <code>string</code> - Optional - The ID of the environment to rebuild. </li>
|
897 |
+
* <li><code>EnvironmentName</code> - <code>string</code> - Optional - The name of the environment to rebuild. </li>
|
898 |
+
* <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>
|
899 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
900 |
+
*/
|
901 |
+
public function rebuild_environment($opt = null)
|
902 |
+
{
|
903 |
+
if (!$opt) $opt = array();
|
904 |
+
|
905 |
+
return $this->authenticate('RebuildEnvironment', $opt, $this->hostname);
|
906 |
+
}
|
907 |
+
|
908 |
+
/**
|
909 |
+
*
|
910 |
+
* Returns list of event descriptions matching criteria.
|
911 |
+
*
|
912 |
+
* This action returns the most recent 1,000 events from the specified <code>NextToken</code>.
|
913 |
+
*
|
914 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
915 |
+
* <li><code>ApplicationName</code> - <code>string</code> - Optional - If specified, AWS Elastic Beanstalk restricts the returned descriptions to include only those associated with this application. </li>
|
916 |
+
* <li><code>VersionLabel</code> - <code>string</code> - Optional - If specified, AWS Elastic Beanstalk restricts the returned descriptions to those associated with this application version. </li>
|
917 |
+
* <li><code>TemplateName</code> - <code>string</code> - Optional - If specified, AWS Elastic Beanstalk restricts the returned descriptions to those that are associated with this environment configuration. </li>
|
918 |
+
* <li><code>EnvironmentId</code> - <code>string</code> - Optional - If specified, AWS Elastic Beanstalk restricts the returned descriptions to those associated with this environment. </li>
|
919 |
+
* <li><code>EnvironmentName</code> - <code>string</code> - Optional - If specified, AWS Elastic Beanstalk restricts the returned descriptions to those associated with this environment. </li>
|
920 |
+
* <li><code>RequestId</code> - <code>string</code> - Optional - If specified, AWS Elastic Beanstalk restricts the described events to include only those associated with this request ID. </li>
|
921 |
+
* <li><code>Severity</code> - <code>string</code> - Optional - If specified, limits the events returned from this call to include only those with the specified severity or higher. [Allowed values: <code>TRACE</code>, <code>DEBUG</code>, <code>INFO</code>, <code>WARN</code>, <code>ERROR</code>, <code>FATAL</code>]</li>
|
922 |
+
* <li><code>StartTime</code> - <code>string</code> - Optional - If specified, AWS Elastic Beanstalk restricts the returned descriptions to those that occur on or after this time. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
923 |
+
* <li><code>EndTime</code> - <code>string</code> - Optional - If specified, AWS Elastic Beanstalk restricts the returned descriptions to those that occur up to, but not including, the <code>EndTime</code>. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
924 |
+
* <li><code>NextToken</code> - <code>string</code> - Optional - Pagination token. If specified, the events return the next batch of results. </li>
|
925 |
+
* <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>
|
926 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
927 |
+
*/
|
928 |
+
public function describe_events($opt = null)
|
929 |
+
{
|
930 |
+
if (!$opt) $opt = array();
|
931 |
+
|
932 |
+
// Optional parameter
|
933 |
+
if (isset($opt['StartTime']))
|
934 |
+
{
|
935 |
+
$opt['StartTime'] = $this->util->convert_date_to_iso8601($opt['StartTime']);
|
936 |
+
}
|
937 |
+
|
938 |
+
// Optional parameter
|
939 |
+
if (isset($opt['EndTime']))
|
940 |
+
{
|
941 |
+
$opt['EndTime'] = $this->util->convert_date_to_iso8601($opt['EndTime']);
|
942 |
+
}
|
943 |
+
|
944 |
+
return $this->authenticate('DescribeEvents', $opt, $this->hostname);
|
945 |
+
}
|
946 |
+
}
|
947 |
+
|
948 |
+
|
949 |
+
/*%******************************************************************************************%*/
|
950 |
+
// EXCEPTIONS
|
951 |
+
|
952 |
+
/**
|
953 |
+
* Default Elastic Beanstalk Exception.
|
954 |
+
*/
|
955 |
+
class ElasticBeanstalk_Exception extends Exception {}
|
app/libs/aws/services/elb.class.php
ADDED
@@ -0,0 +1,605 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* Elastic Load Balancing is a cost-effective and easy to use web service to help you improve availability and scalability
|
20 |
+
* of your application. It makes it easy for you to distribute application loads between two or more EC2 instances. Elastic
|
21 |
+
* Load Balancing enables availability through redundancy and supports traffic growth of your application.
|
22 |
+
*
|
23 |
+
* @version Wed Feb 16 17:06:11 PST 2011
|
24 |
+
* @license See the included NOTICE.md file for complete information.
|
25 |
+
* @copyright See the included NOTICE.md file for complete information.
|
26 |
+
* @link http://aws.amazon.com/elasticloadbalancing/Amazon Elastic Load Balancing
|
27 |
+
* @link http://aws.amazon.com/documentation/elasticloadbalancing/Amazon Elastic Load Balancing documentation
|
28 |
+
*/
|
29 |
+
class AmazonELB extends CFRuntime
|
30 |
+
{
|
31 |
+
|
32 |
+
/*%******************************************************************************************%*/
|
33 |
+
// CLASS CONSTANTS
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Specify the default queue URL.
|
37 |
+
*/
|
38 |
+
const DEFAULT_URL = 'elasticloadbalancing.us-east-1.amazonaws.com';
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Specify the queue URL for the US-East (Northern Virginia) Region.
|
42 |
+
*/
|
43 |
+
const REGION_US_E1 = self::DEFAULT_URL;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Specify the queue URL for the US-West (Northern California) Region.
|
47 |
+
*/
|
48 |
+
const REGION_US_W1 = 'elasticloadbalancing.us-west-1.amazonaws.com';
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Specify the queue URL for the EU (Ireland) Region.
|
52 |
+
*/
|
53 |
+
const REGION_EU_W1 = 'elasticloadbalancing.eu-west-1.amazonaws.com';
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Specify the queue URL for the Asia Pacific (Singapore) Region.
|
57 |
+
*/
|
58 |
+
const REGION_APAC_SE1 = 'elasticloadbalancing.ap-southeast-1.amazonaws.com';
|
59 |
+
|
60 |
+
|
61 |
+
/*%******************************************************************************************%*/
|
62 |
+
// SETTERS
|
63 |
+
|
64 |
+
/**
|
65 |
+
* This allows you to explicitly sets the region for the service to use.
|
66 |
+
*
|
67 |
+
* @param string $region (Required) The region to explicitly set. Available options are <REGION_US_E1>, <REGION_US_W1>, <REGION_EU_W1>, or <REGION_APAC_SE1>.
|
68 |
+
* @return $this A reference to the current instance.
|
69 |
+
*/
|
70 |
+
public function set_region($region)
|
71 |
+
{
|
72 |
+
$this->set_hostname($region);
|
73 |
+
return $this;
|
74 |
+
}
|
75 |
+
|
76 |
+
|
77 |
+
/*%******************************************************************************************%*/
|
78 |
+
// CONSTRUCTOR
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Constructs a new instance of <AmazonELB>.
|
82 |
+
*
|
83 |
+
* @param string $key (Optional) Your Amazon API Key. If blank, it will look for the <code>AWS_KEY</code> constant.
|
84 |
+
* @param string $secret_key (Optional) Your Amazon API Secret Key. If blank, it will look for the <code>AWS_SECRET_KEY</code> constant.
|
85 |
+
* @return boolean false if no valid values are set, otherwise true.
|
86 |
+
*/
|
87 |
+
public function __construct($key = null, $secret_key = null)
|
88 |
+
{
|
89 |
+
$this->api_version = '2010-07-01';
|
90 |
+
$this->hostname = self::DEFAULT_URL;
|
91 |
+
|
92 |
+
if (!$key && !defined('AWS_KEY'))
|
93 |
+
{
|
94 |
+
throw new ELB_Exception('No account key was passed into the constructor, nor was it set in the AWS_KEY constant.');
|
95 |
+
}
|
96 |
+
|
97 |
+
if (!$secret_key && !defined('AWS_SECRET_KEY'))
|
98 |
+
{
|
99 |
+
throw new ELB_Exception('No account secret was passed into the constructor, nor was it set in the AWS_SECRET_KEY constant.');
|
100 |
+
}
|
101 |
+
|
102 |
+
return parent::__construct($key, $secret_key);
|
103 |
+
}
|
104 |
+
|
105 |
+
|
106 |
+
/*%******************************************************************************************%*/
|
107 |
+
// SERVICE METHODS
|
108 |
+
|
109 |
+
/**
|
110 |
+
*
|
111 |
+
* Creates one or more listeners on a LoadBalancer for the specified port. If a listener with the given port does not
|
112 |
+
* already exist, it will be created; otherwise, the properties of the new listener must match the properties of the
|
113 |
+
* existing listener.
|
114 |
+
*
|
115 |
+
* @param string $load_balancer_name (Required) The name of the new LoadBalancer. The name must be unique within your AWS account.
|
116 |
+
* @param array $listeners (Required) A list of LoadBalancerPort, <code>InstancePort</code>, <code>Protocol</code>, and <code>SSLCertificateID</code> items. <ul>
|
117 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
118 |
+
* <li><code>Protocol</code> - <code>string</code> - Required - Specifies the LoadBalancer transport protocol to use for routing - TCP or HTTP. This property cannot be modified for the life of the LoadBalancer. </li>
|
119 |
+
* <li><code>LoadBalancerPort</code> - <code>integer</code> - Required - Specifies the LoadBalancer transport protocol to use for routing - TCP or HTTP. This property cannot be modified for the life of the LoadBalancer. </li>
|
120 |
+
* <li><code>InstancePort</code> - <code>integer</code> - Required - Specifies the TCP port on which the instance server is listening. This property cannot be modified for the life of the LoadBalancer. </li>
|
121 |
+
* <li><code>SSLCertificateId</code> - <code>string</code> - Optional - The ID of the SSL certificate chain to use. For more information on SSL certificates, see Managing Keys and Certificates in the AWS Identity and Access Management documentation. </li>
|
122 |
+
* </ul></li>
|
123 |
+
* </ul>
|
124 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
125 |
+
* <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>
|
126 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
127 |
+
*/
|
128 |
+
public function create_load_balancer_listeners($load_balancer_name, $listeners, $opt = null)
|
129 |
+
{
|
130 |
+
if (!$opt) $opt = array();
|
131 |
+
$opt['LoadBalancerName'] = $load_balancer_name;
|
132 |
+
|
133 |
+
// Required parameter
|
134 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
135 |
+
'Listeners' => (is_array($listeners) ? $listeners : array($listeners))
|
136 |
+
), 'member'));
|
137 |
+
|
138 |
+
return $this->authenticate('CreateLoadBalancerListeners', $opt, $this->hostname);
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
*
|
143 |
+
* Generates a stickiness policy with sticky session lifetimes controlled by the lifetime of the browser (user-agent) or a
|
144 |
+
* specified expiration period. This policy can only be associated only with HTTP listeners.
|
145 |
+
*
|
146 |
+
* When a load balancer implements this policy, the load balancer uses a special cookie to track the backend server
|
147 |
+
* instance for each request. When the load balancer receives a request, it first checks to see if this cookie is present
|
148 |
+
* in the request. If so, the load balancer sends the request to the application server specified in the cookie. If not,
|
149 |
+
* the load balancer sends the request to a server that is chosen based on the existing load balancing algorithm.
|
150 |
+
*
|
151 |
+
* A cookie is inserted into the response for binding subsequent requests from the same user to that server. The validity
|
152 |
+
* of the cookie is based on the cookie expiration time, which is specified in the policy configuration.
|
153 |
+
*
|
154 |
+
* @param string $load_balancer_name (Required) The name associated with the LoadBalancer. The name must be unique within the client AWS account.
|
155 |
+
* @param string $policy_name (Required) The name of the policy being created. The name must be unique within the set of policies for this Load Balancer.
|
156 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
157 |
+
* <li><code>CookieExpirationPeriod</code> - <code>long</code> - Optional - The time period in seconds after which the cookie should be considered stale. Not specifying this parameter indicates that the sticky session will last for the duration of the browser session. </li>
|
158 |
+
* <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>
|
159 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
160 |
+
*/
|
161 |
+
public function create_lb_cookie_stickiness_policy($load_balancer_name, $policy_name, $opt = null)
|
162 |
+
{
|
163 |
+
if (!$opt) $opt = array();
|
164 |
+
$opt['LoadBalancerName'] = $load_balancer_name;
|
165 |
+
$opt['PolicyName'] = $policy_name;
|
166 |
+
|
167 |
+
return $this->authenticate('CreateLBCookieStickinessPolicy', $opt, $this->hostname);
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
*
|
172 |
+
* Enables the client to define an application healthcheck for the instances.
|
173 |
+
*
|
174 |
+
* @param string $load_balancer_name (Required) The mnemonic name associated with the LoadBalancer. This name must be unique within the client AWS account.
|
175 |
+
* @param array $health_check (Required) A structure containing the configuration information for the new healthcheck. <ul>
|
176 |
+
* <li><code>Target</code> - <code>string</code> - Required - Specifies the instance being checked. The protocol is either TCP or HTTP. The range of valid ports is one (1) through 65535. TCP is the default, specified as a TCP: port pair, for example "TCP:5000". In this case a healthcheck simply attempts to open a TCP connection to the instance on the specified port. Failure to connect within the configured timeout is considered unhealthy. For HTTP, the situation is different. HTTP is specified as a HTTP:port;/;PathToPing; grouping, for example "HTTP:80/weather/us/wa/seattle". In this case, a HTTP GET request is issued to the instance on the given port and path. Any answer other than "200 OK" within the timeout period is considered unhealthy. The total length of the HTTP ping target needs to be 1024 16-bit Unicode characters or less. </li>
|
177 |
+
* <li><code>Interval</code> - <code>integer</code> - Required - Specifies the approximate interval, in seconds, between health checks of an individual instance. </li>
|
178 |
+
* <li><code>Timeout</code> - <code>integer</code> - Required - Specifies the amount of time, in seconds, during which no response means a failed health probe. This value must be less than the <i>Interval</i> value. </li>
|
179 |
+
* <li><code>UnhealthyThreshold</code> - <code>integer</code> - Required - Specifies the number of consecutive health probe failures required before moving the instance to the <i>Unhealthy</i> state. </li>
|
180 |
+
* <li><code>HealthyThreshold</code> - <code>integer</code> - Required - Specifies the number of consecutive health probe successes required before moving the instance to the <i>Healthy</i> state. </li>
|
181 |
+
* </ul>
|
182 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
183 |
+
* <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>
|
184 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
185 |
+
*/
|
186 |
+
public function configure_health_check($load_balancer_name, $health_check, $opt = null)
|
187 |
+
{
|
188 |
+
if (!$opt) $opt = array();
|
189 |
+
$opt['LoadBalancerName'] = $load_balancer_name;
|
190 |
+
|
191 |
+
// Required parameter
|
192 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
193 |
+
'HealthCheck' => (is_array($health_check) ? $health_check : array($health_check))
|
194 |
+
), 'member'));
|
195 |
+
|
196 |
+
return $this->authenticate('ConfigureHealthCheck', $opt, $this->hostname);
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
*
|
201 |
+
* Returns detailed configuration information for the specified LoadBalancers. If no LoadBalancers are specified, the
|
202 |
+
* operation returns configuration information for all LoadBalancers created by the caller.
|
203 |
+
*
|
204 |
+
* The client must have created the specified input LoadBalancers in order to retrieve this information; the client must
|
205 |
+
* provide the same account credentials as those that were used to create the LoadBalancer.
|
206 |
+
*
|
207 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
208 |
+
* <li><code>LoadBalancerNames</code> - <code>string|array</code> - Optional - A list of names associated with the LoadBalancers at creation time. Pass a string for a single value, or an indexed array for multiple values. </li>
|
209 |
+
* <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>
|
210 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
211 |
+
*/
|
212 |
+
public function describe_load_balancers($opt = null)
|
213 |
+
{
|
214 |
+
if (!$opt) $opt = array();
|
215 |
+
|
216 |
+
// Optional parameter
|
217 |
+
if (isset($opt['LoadBalancerNames']))
|
218 |
+
{
|
219 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
220 |
+
'LoadBalancerNames' => (is_array($opt['LoadBalancerNames']) ? $opt['LoadBalancerNames'] : array($opt['LoadBalancerNames']))
|
221 |
+
), 'member'));
|
222 |
+
unset($opt['LoadBalancerNames']);
|
223 |
+
}
|
224 |
+
|
225 |
+
return $this->authenticate('DescribeLoadBalancers', $opt, $this->hostname);
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
*
|
230 |
+
* Sets the certificate that terminates the specified listener's SSL connections. The specified certificate replaces any
|
231 |
+
* prior certificate that was used on the same LoadBalancer and port.
|
232 |
+
*
|
233 |
+
* @param string $load_balancer_name (Required) The name of the the LoadBalancer.
|
234 |
+
* @param integer $load_balancer_port (Required) The port that uses the specified SSL certificate.
|
235 |
+
* @param string $ssl_certificate_id (Required) The ID of the SSL certificate chain to use. For more information on SSL certificates, see Managing Server Certificates in the AWS Identity and Access Management documentation.
|
236 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
237 |
+
* <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>
|
238 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
239 |
+
*/
|
240 |
+
public function set_load_balancer_listener_ssl_certificate($load_balancer_name, $load_balancer_port, $ssl_certificate_id, $opt = null)
|
241 |
+
{
|
242 |
+
if (!$opt) $opt = array();
|
243 |
+
$opt['LoadBalancerName'] = $load_balancer_name;
|
244 |
+
$opt['LoadBalancerPort'] = $load_balancer_port;
|
245 |
+
$opt['SSLCertificateId'] = $ssl_certificate_id;
|
246 |
+
|
247 |
+
return $this->authenticate('SetLoadBalancerListenerSSLCertificate', $opt, $this->hostname);
|
248 |
+
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
*
|
252 |
+
* Creates a new LoadBalancer.
|
253 |
+
*
|
254 |
+
* Once the call has completed successfully, a new LoadBalancer is created; however, it will not be usable until at least
|
255 |
+
* one instance has been registered. When the LoadBalancer creation is completed, the client can check whether or not it is
|
256 |
+
* usable by using the DescribeInstanceHealth API. The LoadBalancer is usable as soon as any registered instance is
|
257 |
+
* <i>InService</i>.
|
258 |
+
*
|
259 |
+
* Currently, the client's quota of LoadBalancers is limited to five per Region.
|
260 |
+
*
|
261 |
+
* Load balancer DNS names vary depending on the Region they're created in. For load balancers created in the United
|
262 |
+
* States, the DNS name ends with:
|
263 |
+
*
|
264 |
+
* <ul> <li> <i>us-east-1.elb.amazonaws.com</i> (for the US Standard Region) </li>
|
265 |
+
*
|
266 |
+
* <li> <i>us-west-1.elb.amazonaws.com</i> (for the Northern California Region) </li>
|
267 |
+
*
|
268 |
+
* </ul>
|
269 |
+
*
|
270 |
+
* For load balancers created in the EU (Ireland) Region, the DNS name ends with:
|
271 |
+
*
|
272 |
+
* <ul> <li> <i>eu-west-1.elb.amazonaws.com</i> </li>
|
273 |
+
*
|
274 |
+
* </ul>
|
275 |
+
*
|
276 |
+
* @param string $load_balancer_name (Required) The name associated with the LoadBalancer. The name must be unique within your set of LoadBalancers requests on the specified protocol and received by Elastic Load Balancing on the LoadBalancerPort are load balanced across the registered instances and sent to port InstancePort.
|
277 |
+
* @param array $listeners (Required) A list of the following tuples: LoadBalancerPort, InstancePort, and Protocol. <ul>
|
278 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
279 |
+
* <li><code>Protocol</code> - <code>string</code> - Required - Specifies the LoadBalancer transport protocol to use for routing - TCP or HTTP. This property cannot be modified for the life of the LoadBalancer. </li>
|
280 |
+
* <li><code>LoadBalancerPort</code> - <code>integer</code> - Required - Specifies the LoadBalancer transport protocol to use for routing - TCP or HTTP. This property cannot be modified for the life of the LoadBalancer. </li>
|
281 |
+
* <li><code>InstancePort</code> - <code>integer</code> - Required - Specifies the TCP port on which the instance server is listening. This property cannot be modified for the life of the LoadBalancer. </li>
|
282 |
+
* <li><code>SSLCertificateId</code> - <code>string</code> - Optional - The ID of the SSL certificate chain to use. For more information on SSL certificates, see Managing Keys and Certificates in the AWS Identity and Access Management documentation. </li>
|
283 |
+
* </ul></li>
|
284 |
+
* </ul>
|
285 |
+
* @param string|array $availability_zones (Required) A list of Availability Zones. At least one Availability Zone must be specified. Specified Availability Zones must be in the same EC2 Region as the LoadBalancer. Traffic will be equally distributed across all zones. This list can be modified after the creation of the LoadBalancer. Pass a string for a single value, or an indexed array for multiple values.
|
286 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
287 |
+
* <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>
|
288 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
289 |
+
*/
|
290 |
+
public function create_load_balancer($load_balancer_name, $listeners, $availability_zones, $opt = null)
|
291 |
+
{
|
292 |
+
if (!$opt) $opt = array();
|
293 |
+
$opt['LoadBalancerName'] = $load_balancer_name;
|
294 |
+
|
295 |
+
// Required parameter
|
296 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
297 |
+
'Listeners' => (is_array($listeners) ? $listeners : array($listeners))
|
298 |
+
), 'member'));
|
299 |
+
|
300 |
+
// Required parameter
|
301 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
302 |
+
'AvailabilityZones' => (is_array($availability_zones) ? $availability_zones : array($availability_zones))
|
303 |
+
), 'member'));
|
304 |
+
|
305 |
+
return $this->authenticate('CreateLoadBalancer', $opt, $this->hostname);
|
306 |
+
}
|
307 |
+
|
308 |
+
/**
|
309 |
+
*
|
310 |
+
* Adds one or more EC2 Availability Zones to the LoadBalancer.
|
311 |
+
*
|
312 |
+
* The LoadBalancer evenly distributes requests across all its registered Availability Zones that contain instances. As a
|
313 |
+
* result, the client must ensure that its LoadBalancer is appropriately scaled for each registered Availability Zone.
|
314 |
+
*
|
315 |
+
* The new EC2 Availability Zones to be added must be in the same EC2 Region as the Availability Zones for which the
|
316 |
+
* LoadBalancer was created.
|
317 |
+
*
|
318 |
+
* @param string $load_balancer_name (Required) The name associated with the LoadBalancer. The name must be unique within the client AWS account.
|
319 |
+
* @param string|array $availability_zones (Required) A list of new Availability Zones for the LoadBalancer. Each Availability Zone must be in the same Region as the LoadBalancer. Pass a string for a single value, or an indexed array for multiple values.
|
320 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
321 |
+
* <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>
|
322 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
323 |
+
*/
|
324 |
+
public function enable_availability_zones_for_load_balancer($load_balancer_name, $availability_zones, $opt = null)
|
325 |
+
{
|
326 |
+
if (!$opt) $opt = array();
|
327 |
+
$opt['LoadBalancerName'] = $load_balancer_name;
|
328 |
+
|
329 |
+
// Required parameter
|
330 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
331 |
+
'AvailabilityZones' => (is_array($availability_zones) ? $availability_zones : array($availability_zones))
|
332 |
+
), 'member'));
|
333 |
+
|
334 |
+
return $this->authenticate('EnableAvailabilityZonesForLoadBalancer', $opt, $this->hostname);
|
335 |
+
}
|
336 |
+
|
337 |
+
/**
|
338 |
+
*
|
339 |
+
* Returns the current state of the instances of the specified LoadBalancer. If no instances are specified, the state of
|
340 |
+
* all the instances for the LoadBalancer is returned.
|
341 |
+
*
|
342 |
+
* The client must have created the specified input LoadBalancer in order to retrieve this information; the client must
|
343 |
+
* provide the same account credentials as those that were used to create the LoadBalancer.
|
344 |
+
*
|
345 |
+
* @param string $load_balancer_name (Required) The name associated with the LoadBalancer. The name must be unique within the client AWS account.
|
346 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
347 |
+
* <li><code>Instances</code> - <code>array</code> - Optional - A list of instance IDs whose states are being queried. <ul>
|
348 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
349 |
+
* <li><code>InstanceId</code> - <code>string</code> - Optional - Provides an EC2 instance ID. </li>
|
350 |
+
* </ul></li>
|
351 |
+
* </ul></li>
|
352 |
+
* <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>
|
353 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
354 |
+
*/
|
355 |
+
public function describe_instance_health($load_balancer_name, $opt = null)
|
356 |
+
{
|
357 |
+
if (!$opt) $opt = array();
|
358 |
+
$opt['LoadBalancerName'] = $load_balancer_name;
|
359 |
+
|
360 |
+
// Optional parameter
|
361 |
+
if (isset($opt['Instances']))
|
362 |
+
{
|
363 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
364 |
+
'Instances' => $opt['Instances']
|
365 |
+
), 'member'));
|
366 |
+
unset($opt['Instances']);
|
367 |
+
}
|
368 |
+
|
369 |
+
return $this->authenticate('DescribeInstanceHealth', $opt, $this->hostname);
|
370 |
+
}
|
371 |
+
|
372 |
+
/**
|
373 |
+
*
|
374 |
+
* Deletes a policy from the LoadBalancer. The specified policy must not be enabled for any listeners.
|
375 |
+
*
|
376 |
+
* @param string $load_balancer_name (Required) The mnemonic name associated with the LoadBalancer. The name must be unique within your AWS account.
|
377 |
+
* @param string $policy_name (Required) The mnemonic name for the policy being deleted.
|
378 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
379 |
+
* <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>
|
380 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
381 |
+
*/
|
382 |
+
public function delete_load_balancer_policy($load_balancer_name, $policy_name, $opt = null)
|
383 |
+
{
|
384 |
+
if (!$opt) $opt = array();
|
385 |
+
$opt['LoadBalancerName'] = $load_balancer_name;
|
386 |
+
$opt['PolicyName'] = $policy_name;
|
387 |
+
|
388 |
+
return $this->authenticate('DeleteLoadBalancerPolicy', $opt, $this->hostname);
|
389 |
+
}
|
390 |
+
|
391 |
+
/**
|
392 |
+
*
|
393 |
+
* Removes the specified EC2 Availability Zones from the set of configured Availability Zones for the LoadBalancer.
|
394 |
+
*
|
395 |
+
* There must be at least one Availability Zone registered with a LoadBalancer at all times. A client cannot remove all
|
396 |
+
* the Availability Zones from a LoadBalancer. Once an Availability Zone is removed, all the instances registered with the
|
397 |
+
* LoadBalancer that are in the removed Availability Zone go into the OutOfService state. Upon Availability Zone removal,
|
398 |
+
* the LoadBalancer attempts to equally balance the traffic among its remaining usable Availability Zones. Trying to remove
|
399 |
+
* an Availability Zone that was not associated with the LoadBalancer does nothing.
|
400 |
+
*
|
401 |
+
* In order for this call to be successful, the client must have created the LoadBalancer. The client must provide the
|
402 |
+
* same account credentials as those that were used to create the LoadBalancer.
|
403 |
+
*
|
404 |
+
* @param string $load_balancer_name (Required) The name associated with the LoadBalancer. The name must be unique within the client AWS account.
|
405 |
+
* @param string|array $availability_zones (Required) A list of Availability Zones to be removed from the LoadBalancer. There must be at least one Availability Zone registered with a LoadBalancer at all times. The client cannot remove all the Availability Zones from a LoadBalancer. Specified Availability Zones must be in the same Region. Pass a string for a single value, or an indexed array for multiple values.
|
406 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
407 |
+
* <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>
|
408 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
409 |
+
*/
|
410 |
+
public function disable_availability_zones_for_load_balancer($load_balancer_name, $availability_zones, $opt = null)
|
411 |
+
{
|
412 |
+
if (!$opt) $opt = array();
|
413 |
+
$opt['LoadBalancerName'] = $load_balancer_name;
|
414 |
+
|
415 |
+
// Required parameter
|
416 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
417 |
+
'AvailabilityZones' => (is_array($availability_zones) ? $availability_zones : array($availability_zones))
|
418 |
+
), 'member'));
|
419 |
+
|
420 |
+
return $this->authenticate('DisableAvailabilityZonesForLoadBalancer', $opt, $this->hostname);
|
421 |
+
}
|
422 |
+
|
423 |
+
/**
|
424 |
+
*
|
425 |
+
* Deregisters instances from the LoadBalancer. Once the instance is deregistered, it will stop receiving traffic from the
|
426 |
+
* LoadBalancer.
|
427 |
+
*
|
428 |
+
* In order to successfully call this API, the same account credentials as those used to create the LoadBalancer must be
|
429 |
+
* provided.
|
430 |
+
*
|
431 |
+
* @param string $load_balancer_name (Required) The name associated with the LoadBalancer. The name must be unique within the client AWS account.
|
432 |
+
* @param array $instances (Required) A list of EC2 instance IDs consisting of all instances to be deregistered. <ul>
|
433 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
434 |
+
* <li><code>InstanceId</code> - <code>string</code> - Optional - Provides an EC2 instance ID. </li>
|
435 |
+
* </ul></li>
|
436 |
+
* </ul>
|
437 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
438 |
+
* <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>
|
439 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
440 |
+
*/
|
441 |
+
public function deregister_instances_from_load_balancer($load_balancer_name, $instances, $opt = null)
|
442 |
+
{
|
443 |
+
if (!$opt) $opt = array();
|
444 |
+
$opt['LoadBalancerName'] = $load_balancer_name;
|
445 |
+
|
446 |
+
// Required parameter
|
447 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
448 |
+
'Instances' => (is_array($instances) ? $instances : array($instances))
|
449 |
+
), 'member'));
|
450 |
+
|
451 |
+
return $this->authenticate('DeregisterInstancesFromLoadBalancer', $opt, $this->hostname);
|
452 |
+
}
|
453 |
+
|
454 |
+
/**
|
455 |
+
*
|
456 |
+
* Deletes listeners from the LoadBalancer for the specified port.
|
457 |
+
*
|
458 |
+
* @param string $load_balancer_name (Required) The mnemonic name associated with the LoadBalancer.
|
459 |
+
* @param integer LoadBalancerPorts (Required) The client port number(s) of the LoadBalancerListener(s) to be removed.
|
460 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
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_load_balancer_listeners($load_balancer_name, $load_balancer_ports, $opt = null)
|
465 |
+
{
|
466 |
+
if (!$opt) $opt = array();
|
467 |
+
$opt['LoadBalancerName'] = $load_balancer_name;
|
468 |
+
|
469 |
+
// Required parameter
|
470 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
471 |
+
'LoadBalancerPorts' => (is_array($load_balancer_ports) ? $load_balancer_ports : array($load_balancer_ports))
|
472 |
+
), 'member'));
|
473 |
+
|
474 |
+
return $this->authenticate('DeleteLoadBalancerListeners', $opt, $this->hostname);
|
475 |
+
}
|
476 |
+
|
477 |
+
/**
|
478 |
+
*
|
479 |
+
* Deletes the specified LoadBalancer.
|
480 |
+
*
|
481 |
+
* If attempting to recreate the LoadBalancer, the client must reconfigure all the settings. The DNS name associated with
|
482 |
+
* a deleted LoadBalancer will no longer be usable. Once deleted, the name and associated DNS record of the LoadBalancer no
|
483 |
+
* longer exist and traffic sent to any of its IP addresses will no longer be delivered to client instances. The client
|
484 |
+
* will not receive the same DNS name even if a new LoadBalancer with same LoadBalancerName is created.
|
485 |
+
*
|
486 |
+
* To successfully call this API, the client must provide the same account credentials as were used to create the
|
487 |
+
* LoadBalancer.
|
488 |
+
*
|
489 |
+
* By design, if the LoadBalancer does not exist or has already been deleted, DeleteLoadBalancer still succeeds.
|
490 |
+
*
|
491 |
+
* @param string $load_balancer_name (Required) The name associated with the LoadBalancer. The name must be unique within the client AWS account.
|
492 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
493 |
+
* <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>
|
494 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
495 |
+
*/
|
496 |
+
public function delete_load_balancer($load_balancer_name, $opt = null)
|
497 |
+
{
|
498 |
+
if (!$opt) $opt = array();
|
499 |
+
$opt['LoadBalancerName'] = $load_balancer_name;
|
500 |
+
|
501 |
+
return $this->authenticate('DeleteLoadBalancer', $opt, $this->hostname);
|
502 |
+
}
|
503 |
+
|
504 |
+
/**
|
505 |
+
*
|
506 |
+
* Generates a stickiness policy with sticky session lifetimes that follow that of an application-generated cookie. This
|
507 |
+
* policy can only be associated with HTTP listeners.
|
508 |
+
*
|
509 |
+
* This policy is similar to the policy created by CreateLBCookieStickinessPolicy, except that the lifetime of the special
|
510 |
+
* Elastic Load Balancing cookie follows the lifetime of the application-generated cookie specified in the policy
|
511 |
+
* configuration. The load balancer only inserts a new stickiness cookie when the application response includes a new
|
512 |
+
* application cookie.
|
513 |
+
*
|
514 |
+
* If the application cookie is explicitly removed or expires, the session stops being sticky until a new application
|
515 |
+
* cookie is issued.
|
516 |
+
*
|
517 |
+
* @param string $load_balancer_name (Required) The name associated with the LoadBalancer. The name must be unique within the client AWS account.
|
518 |
+
* @param string $policy_name (Required) The name of the policy being created. The name must be unique within the set of policies for this Load Balancer.
|
519 |
+
* @param string $cookie_name (Required) Name of the application cookie used for stickiness.
|
520 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
521 |
+
* <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>
|
522 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
523 |
+
*/
|
524 |
+
public function create_app_cookie_stickiness_policy($load_balancer_name, $policy_name, $cookie_name, $opt = null)
|
525 |
+
{
|
526 |
+
if (!$opt) $opt = array();
|
527 |
+
$opt['LoadBalancerName'] = $load_balancer_name;
|
528 |
+
$opt['PolicyName'] = $policy_name;
|
529 |
+
$opt['CookieName'] = $cookie_name;
|
530 |
+
|
531 |
+
return $this->authenticate('CreateAppCookieStickinessPolicy', $opt, $this->hostname);
|
532 |
+
}
|
533 |
+
|
534 |
+
/**
|
535 |
+
*
|
536 |
+
* Adds new instances to the LoadBalancer.
|
537 |
+
*
|
538 |
+
* Once the instance is registered, it starts receiving traffic and requests from the LoadBalancer. Any instance that is
|
539 |
+
* not in any of the Availability Zones registered for the LoadBalancer will be moved to the <i>OutOfService</i> state. It
|
540 |
+
* will move to the <i>InService</i> state when the Availability Zone is added to the LoadBalancer.
|
541 |
+
*
|
542 |
+
* In order for this call to be successful, the client must have created the LoadBalancer. The client must provide the
|
543 |
+
* same account credentials as those that were used to create the LoadBalancer.
|
544 |
+
*
|
545 |
+
* Completion of this API does not guarantee that operation has completed. Rather, it means that the request has been
|
546 |
+
* registered and the changes will happen shortly.
|
547 |
+
*
|
548 |
+
* @param string $load_balancer_name (Required) The name associated with the LoadBalancer. The name must be unique within the client AWS account.
|
549 |
+
* @param array $instances (Required) A list of instances IDs that should be registered with the LoadBalancer. <ul>
|
550 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
551 |
+
* <li><code>InstanceId</code> - <code>string</code> - Optional - Provides an EC2 instance ID. </li>
|
552 |
+
* </ul></li>
|
553 |
+
* </ul>
|
554 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
555 |
+
* <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>
|
556 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
557 |
+
*/
|
558 |
+
public function register_instances_with_load_balancer($load_balancer_name, $instances, $opt = null)
|
559 |
+
{
|
560 |
+
if (!$opt) $opt = array();
|
561 |
+
$opt['LoadBalancerName'] = $load_balancer_name;
|
562 |
+
|
563 |
+
// Required parameter
|
564 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
565 |
+
'Instances' => (is_array($instances) ? $instances : array($instances))
|
566 |
+
), 'member'));
|
567 |
+
|
568 |
+
return $this->authenticate('RegisterInstancesWithLoadBalancer', $opt, $this->hostname);
|
569 |
+
}
|
570 |
+
|
571 |
+
/**
|
572 |
+
*
|
573 |
+
* Associates, updates, or disables a policy with a listener on the load balancer. Currently only zero (0) or one (1)
|
574 |
+
* policy can be associated with a listener.
|
575 |
+
*
|
576 |
+
* @param string $load_balancer_name (Required) The name associated with the LoadBalancer. The name must be unique within the client AWS account.
|
577 |
+
* @param integer $load_balancer_port (Required) The external port of the LoadBalancer with which this policy has to be associated.
|
578 |
+
* @param string|array $policy_names (Required) List of policies to be associated with the listener. Currently this list can have at most one policy. If the list is empty, the current policy is removed from the listener. Pass a string for a single value, or an indexed array for multiple values.
|
579 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
580 |
+
* <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>
|
581 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
582 |
+
*/
|
583 |
+
public function set_load_balancer_policies_of_listener($load_balancer_name, $load_balancer_port, $policy_names, $opt = null)
|
584 |
+
{
|
585 |
+
if (!$opt) $opt = array();
|
586 |
+
$opt['LoadBalancerName'] = $load_balancer_name;
|
587 |
+
$opt['LoadBalancerPort'] = $load_balancer_port;
|
588 |
+
|
589 |
+
// Required parameter
|
590 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
591 |
+
'PolicyNames' => (is_array($policy_names) ? $policy_names : array($policy_names))
|
592 |
+
), 'member'));
|
593 |
+
|
594 |
+
return $this->authenticate('SetLoadBalancerPoliciesOfListener', $opt, $this->hostname);
|
595 |
+
}
|
596 |
+
}
|
597 |
+
|
598 |
+
|
599 |
+
/*%******************************************************************************************%*/
|
600 |
+
// EXCEPTIONS
|
601 |
+
|
602 |
+
/**
|
603 |
+
* Default ELB Exception.
|
604 |
+
*/
|
605 |
+
class ELB_Exception extends Exception {}
|
app/libs/aws/services/emr.class.php
ADDED
@@ -0,0 +1,415 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* This is the Amazon Elastic MapReduce API Reference Guide. This guide is for programmers who need detailed information
|
20 |
+
* about the Amazon Elastic MapReduce APIs.
|
21 |
+
*
|
22 |
+
* @version Wed Feb 16 17:07:23 PST 2011
|
23 |
+
* @license See the included NOTICE.md file for complete information.
|
24 |
+
* @copyright See the included NOTICE.md file for complete information.
|
25 |
+
* @link http://aws.amazon.com/elasticmapreduce/Amazon Elastic MapReduce
|
26 |
+
* @link http://aws.amazon.com/documentation/elasticmapreduce/Amazon Elastic MapReduce documentation
|
27 |
+
*/
|
28 |
+
class AmazonEMR extends CFRuntime
|
29 |
+
{
|
30 |
+
|
31 |
+
/*%******************************************************************************************%*/
|
32 |
+
// CLASS CONSTANTS
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Specify the default queue URL.
|
36 |
+
*/
|
37 |
+
const DEFAULT_URL = 'us-east-1.elasticmapreduce.amazonaws.com';
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Specify the queue URL for the US-East (Northern Virginia) Region.
|
41 |
+
*/
|
42 |
+
const REGION_US_E1 = self::DEFAULT_URL;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Specify the queue URL for the US-West (Northern California) Region.
|
46 |
+
*/
|
47 |
+
const REGION_US_W1 = 'us-west-1.elasticmapreduce.amazonaws.com';
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Specify the queue URL for the EU (Ireland) Region.
|
51 |
+
*/
|
52 |
+
const REGION_EU_W1 = 'eu-west-1.elasticmapreduce.amazonaws.com';
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Specify the queue URL for the Asia Pacific (Singapore) Region.
|
56 |
+
*/
|
57 |
+
const REGION_APAC_SE1 = 'ap-southeast-1.elasticmapreduce.amazonaws.com';
|
58 |
+
|
59 |
+
|
60 |
+
/*%******************************************************************************************%*/
|
61 |
+
// SETTERS
|
62 |
+
|
63 |
+
/**
|
64 |
+
* This allows you to explicitly sets the region for the service to use.
|
65 |
+
*
|
66 |
+
* @param string $region (Required) The region to explicitly set. Available options are <REGION_US_E1>, <REGION_US_W1>, <REGION_EU_W1>, or <REGION_APAC_SE1>.
|
67 |
+
* @return $this A reference to the current instance.
|
68 |
+
*/
|
69 |
+
public function set_region($region)
|
70 |
+
{
|
71 |
+
$this->set_hostname($region);
|
72 |
+
return $this;
|
73 |
+
}
|
74 |
+
|
75 |
+
|
76 |
+
/*%******************************************************************************************%*/
|
77 |
+
// CONSTRUCTOR
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Constructs a new instance of <AmazonEMR>.
|
81 |
+
*
|
82 |
+
* @param string $key (Optional) Your Amazon API Key. If blank, it will look for the <code>AWS_KEY</code> constant.
|
83 |
+
* @param string $secret_key (Optional) Your Amazon API Secret Key. If blank, it will look for the <code>AWS_SECRET_KEY</code> constant.
|
84 |
+
* @return boolean false if no valid values are set, otherwise true.
|
85 |
+
*/
|
86 |
+
public function __construct($key = null, $secret_key = null)
|
87 |
+
{
|
88 |
+
$this->api_version = '2009-03-31';
|
89 |
+
$this->hostname = self::DEFAULT_URL;
|
90 |
+
|
91 |
+
if (!$key && !defined('AWS_KEY'))
|
92 |
+
{
|
93 |
+
throw new EMR_Exception('No account key was passed into the constructor, nor was it set in the AWS_KEY constant.');
|
94 |
+
}
|
95 |
+
|
96 |
+
if (!$secret_key && !defined('AWS_SECRET_KEY'))
|
97 |
+
{
|
98 |
+
throw new EMR_Exception('No account secret was passed into the constructor, nor was it set in the AWS_SECRET_KEY constant.');
|
99 |
+
}
|
100 |
+
|
101 |
+
return parent::__construct($key, $secret_key);
|
102 |
+
}
|
103 |
+
|
104 |
+
|
105 |
+
/*%******************************************************************************************%*/
|
106 |
+
// SERVICE METHODS
|
107 |
+
|
108 |
+
/**
|
109 |
+
* AddInstanceGroups adds an instance group to a running cluster.
|
110 |
+
*
|
111 |
+
* @param string $job_flow_id (Required) Job flow in which to add the instance groups.
|
112 |
+
* @param array $instance_groups (Required) Instance Groups to add. Takes an indexed array of associative arrays of parameters. Each associative array can have the following keys: <ul>
|
113 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Friendly name given to the instance group.</li>
|
114 |
+
* <li><code>Market</code> - <code>string</code> - Required - Market type of the Amazon EC2 instances used to create a cluster node. [Allowed values: <code>ON_DEMAND</code>]</li>
|
115 |
+
* <li><code>InstanceRole</code> - <code>string</code> - Required - The role of the instance group in the cluster. [Allowed values: <code>MASTER</code>, <code>CORE</code>, <code>TASK</code>]</li>
|
116 |
+
* <li><code>InstanceType</code> - <code>string</code> - Required - The Amazon EC2 instance type for all instances in the instance group.</li>
|
117 |
+
* <li><code>InstanceCount</code> - <code>integer</code> - Required - Target number of instances for the instance group.</li></ul>
|
118 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
119 |
+
* <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 is useful for manually-managed batch requests.</li></ul>
|
120 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
121 |
+
*/
|
122 |
+
public function add_instance_groups($job_flow_id, $instance_groups, $opt = null)
|
123 |
+
{
|
124 |
+
if (!$opt) $opt = array();
|
125 |
+
$opt['JobFlowId'] = $job_flow_id;
|
126 |
+
|
127 |
+
// Required parameter
|
128 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
129 |
+
'InstanceGroups' => (is_array($instance_groups) ? $instance_groups : array($instance_groups))
|
130 |
+
), 'member'));
|
131 |
+
|
132 |
+
return $this->authenticate('AddInstanceGroups', $opt, $this->hostname);
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
*
|
137 |
+
* AddJobFlowSteps adds new steps to a running job flow. A maximum of 256 steps are allowed in each job flow.
|
138 |
+
*
|
139 |
+
* A step specifies the location of a JAR file stored either on the master node of the job flow or in Amazon S3. Each step
|
140 |
+
* is performed by the main function of the main class of the JAR file. The main class can be specified either in the
|
141 |
+
* manifest of the JAR or by using the MainFunction parameter of the step.
|
142 |
+
*
|
143 |
+
* Elastic MapReduce executes each step in the order listed. For a step to be considered complete, the main function must
|
144 |
+
* exit with a zero exit code and all Hadoop jobs started while the step was running must have completed and run
|
145 |
+
* successfully.
|
146 |
+
*
|
147 |
+
* You can only add steps to a job flow that is in one of the following states: STARTING, BOOTSTAPPING, RUNNING, or
|
148 |
+
* WAITING.
|
149 |
+
*
|
150 |
+
* @param string $job_flow_id (Required) A string that uniquely identifies the job flow. This identifier is returned by RunJobFlow and can also be obtained from DescribeJobFlows .
|
151 |
+
* @param array $steps (Required) A list of StepConfig to be executed by the job flow. <ul>
|
152 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
153 |
+
* <li><code>Name</code> - <code>string</code> - Required - The name of the job flow step. </li>
|
154 |
+
* <li><code>ActionOnFailure</code> - <code>string</code> - Optional - Specifies the action to take if the job flow step fails. [Allowed values: <code>TERMINATE_JOB_FLOW</code>, <code>CANCEL_AND_WAIT</code>, <code>CONTINUE</code>]</li>
|
155 |
+
* <li><code>HadoopJarStep</code> - <code>array</code> - Required - Specifies the JAR file used for the job flow step. Takes an associative array of parameters that can have the following keys: <ul>
|
156 |
+
* <li><code>Properties</code> - <code>array</code> - Optional - A list of Java properties that are set when the step runs. You can use these properties to pass key value pairs to your main function. <ul>
|
157 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
158 |
+
* <li><code>Key</code> - <code>string</code> - Optional - The unique identifier of a key value pair. </li>
|
159 |
+
* <li><code>Value</code> - <code>string</code> - Optional - The value part of the identified key. </li>
|
160 |
+
* </ul></li>
|
161 |
+
* </ul></li>
|
162 |
+
* <li><code>Jar</code> - <code>string</code> - Required - A path to a JAR file run during the step. </li>
|
163 |
+
* <li><code>MainClass</code> - <code>string</code> - Optional - The name of the main class in the specified Java file. If not specified, the JAR file should specify a Main-Class in its manifest file. </li>
|
164 |
+
* <li><code>Args</code> - <code>string|array</code> - Optional - A list of command line arguments passed to the JAR file's main function when executed. Pass a string for a single value, or an indexed array for multiple values. </li>
|
165 |
+
* </ul></li>
|
166 |
+
* </ul></li>
|
167 |
+
* </ul>
|
168 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
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 add_job_flow_steps($job_flow_id, $steps, $opt = null)
|
173 |
+
{
|
174 |
+
if (!$opt) $opt = array();
|
175 |
+
$opt['JobFlowId'] = $job_flow_id;
|
176 |
+
|
177 |
+
// Required parameter
|
178 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
179 |
+
'Steps' => (is_array($steps) ? $steps : array($steps))
|
180 |
+
), 'member'));
|
181 |
+
|
182 |
+
return $this->authenticate('AddJobFlowSteps', $opt, $this->hostname);
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
*
|
187 |
+
* TerminateJobFlows shuts a list of job flows down. When a job flow is shut down, any step not yet completed is canceled
|
188 |
+
* and the EC2 instances on which the job flow is running are stopped. Any log files not already saved are uploaded to
|
189 |
+
* Amazon S3 if a LogUri was specified when the job flow was created.
|
190 |
+
*
|
191 |
+
* @param string|array $job_flow_ids (Required) A list of job flows to be shutdown. 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>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>
|
194 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
195 |
+
*/
|
196 |
+
public function terminate_job_flows($job_flow_ids, $opt = null)
|
197 |
+
{
|
198 |
+
if (!$opt) $opt = array();
|
199 |
+
|
200 |
+
// Required parameter
|
201 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
202 |
+
'JobFlowIds' => (is_array($job_flow_ids) ? $job_flow_ids : array($job_flow_ids))
|
203 |
+
), 'member'));
|
204 |
+
|
205 |
+
return $this->authenticate('TerminateJobFlows', $opt, $this->hostname);
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
*
|
210 |
+
* DescribeJobFlows returns a list of job flows that match all of the supplied parameters. The parameters can include a
|
211 |
+
* list of job flow IDs, job flow states, and restrictions on job flow creation date and time.
|
212 |
+
*
|
213 |
+
* Regardless of supplied parameters, only job flows created within the last two months are returned.
|
214 |
+
*
|
215 |
+
* If no parameters are supplied, then job flows matching either of the following criteria are returned:
|
216 |
+
*
|
217 |
+
* <ul> <li>Job flows created and completed in the last two weeks</li>
|
218 |
+
*
|
219 |
+
* <li> Job flows created within the last two months that are in one of the following states: <code>RUNNING</code> ,
|
220 |
+
* <code>WAITING</code> , <code>SHUTTING_DOWN</code> , <code>STARTING</code> </li>
|
221 |
+
*
|
222 |
+
* </ul>
|
223 |
+
*
|
224 |
+
* Amazon Elastic MapReduce can return a maximum of 512 job flow descriptions.
|
225 |
+
*
|
226 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
227 |
+
* <li><code>CreatedAfter</code> - <code>string</code> - Optional - Return only job flows created after this date and time. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
228 |
+
* <li><code>CreatedBefore</code> - <code>string</code> - Optional - Return only job flows created before this date and time. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
229 |
+
* <li><code>JobFlowIds</code> - <code>string|array</code> - Optional - Return only job flows whose job flow ID is contained in this list. Pass a string for a single value, or an indexed array for multiple values. </li>
|
230 |
+
* <li><code>JobFlowStates</code> - <code>string|array</code> - Optional - Return only job flows whose state is contained in this list. Pass a string for a single value, or an indexed array for multiple values. </li>
|
231 |
+
* <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>
|
232 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
233 |
+
*/
|
234 |
+
public function describe_job_flows($opt = null)
|
235 |
+
{
|
236 |
+
if (!$opt) $opt = array();
|
237 |
+
|
238 |
+
// Optional parameter
|
239 |
+
if (isset($opt['CreatedAfter']))
|
240 |
+
{
|
241 |
+
$opt['CreatedAfter'] = $this->util->convert_date_to_iso8601($opt['CreatedAfter']);
|
242 |
+
}
|
243 |
+
|
244 |
+
// Optional parameter
|
245 |
+
if (isset($opt['CreatedBefore']))
|
246 |
+
{
|
247 |
+
$opt['CreatedBefore'] = $this->util->convert_date_to_iso8601($opt['CreatedBefore']);
|
248 |
+
}
|
249 |
+
|
250 |
+
// Optional parameter
|
251 |
+
if (isset($opt['JobFlowIds']))
|
252 |
+
{
|
253 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
254 |
+
'JobFlowIds' => (is_array($opt['JobFlowIds']) ? $opt['JobFlowIds'] : array($opt['JobFlowIds']))
|
255 |
+
), 'member'));
|
256 |
+
unset($opt['JobFlowIds']);
|
257 |
+
}
|
258 |
+
|
259 |
+
// Optional parameter
|
260 |
+
if (isset($opt['JobFlowStates']))
|
261 |
+
{
|
262 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
263 |
+
'JobFlowStates' => (is_array($opt['JobFlowStates']) ? $opt['JobFlowStates'] : array($opt['JobFlowStates']))
|
264 |
+
), 'member'));
|
265 |
+
unset($opt['JobFlowStates']);
|
266 |
+
}
|
267 |
+
|
268 |
+
return $this->authenticate('DescribeJobFlows', $opt, $this->hostname);
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
*
|
273 |
+
* RunJobFlow creates and starts running a new job flow. The job flow will run the steps specified. Once the job flow
|
274 |
+
* completes, the cluster is stopped and the HDFS partition is lost. To prevent loss of data, configure the last step of
|
275 |
+
* the job flow to store results in Amazon S3. If the JobFlowInstancesDetail : KeepJobFlowAliveWhenNoSteps parameter is set
|
276 |
+
* to <code>TRUE</code>, the job flow will transition to the WAITING state rather than shutting down once the steps have
|
277 |
+
* completed.
|
278 |
+
*
|
279 |
+
* A maximum of 256 steps are allowed in each job flow.
|
280 |
+
*
|
281 |
+
* For long running job flows, we recommended that you periodically store your results.
|
282 |
+
*
|
283 |
+
* @param string $name (Required) The name of the job flow.
|
284 |
+
* @param array $instances (Required) A specification of the number and type of Amazon EC2 instances on which to run the job flow. <ul>
|
285 |
+
* <li><code>MasterInstanceType</code> - <code>string</code> - Optional - The EC2 instance type of the master node. </li>
|
286 |
+
* <li><code>SlaveInstanceType</code> - <code>string</code> - Optional - The EC2 instance type of the slave nodes. </li>
|
287 |
+
* <li><code>InstanceCount</code> - <code>integer</code> - Optional - The number of Amazon EC2 instances used to execute the job flow. </li>
|
288 |
+
* <li><code>InstanceGroups</code> - <code>array</code> - Optional - Configuration for the job flow's instance groups. <ul>
|
289 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
290 |
+
* <li><code>Name</code> - <code>string</code> - Optional - Friendly name given to the instance group. </li>
|
291 |
+
* <li><code>Market</code> - <code>string</code> - Required - Market type of the Amazon EC2 instances used to create a cluster node. [Allowed values: <code>ON_DEMAND</code>]</li>
|
292 |
+
* <li><code>InstanceRole</code> - <code>string</code> - Required - The role of the instance group in the cluster. [Allowed values: <code>MASTER</code>, <code>CORE</code>, <code>TASK</code>]</li>
|
293 |
+
* <li><code>InstanceType</code> - <code>string</code> - Required - The Amazon EC2 instance type for all instances in the instance group. </li>
|
294 |
+
* <li><code>InstanceCount</code> - <code>integer</code> - Required - Target number of instances for the instance group. </li>
|
295 |
+
* </ul></li>
|
296 |
+
* </ul></li>
|
297 |
+
* <li><code>Ec2KeyName</code> - <code>string</code> - Optional - Specifies the name of the Amazon EC2 key pair that can be used to ssh to the master node as the user called "hadoop." </li>
|
298 |
+
* <li><code>Placement</code> - <code>array</code> - Optional - Specifies the Availability Zone the job flow will run in. Takes an associative array of parameters that can have the following keys: <ul>
|
299 |
+
* <li><code>AvailabilityZone</code> - <code>string</code> - Required - The Amazon EC2 Availability Zone for the job flow. </li>
|
300 |
+
* </ul></li>
|
301 |
+
* <li><code>KeepJobFlowAliveWhenNoSteps</code> - <code>boolean</code> - Optional - Specifies whether the job flow should terminate after completing all steps. </li>
|
302 |
+
* <li><code>HadoopVersion</code> - <code>string</code> - Optional - Specifies the Hadoop version for the job flow. Valid inputs are "0.18" or "0.20". </li>
|
303 |
+
* </ul>
|
304 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
305 |
+
* <li><code>LogUri</code> - <code>string</code> - Optional - Specifies the location in Amazon S3 to write the log files of the job flow. If a value is not provided, logs are not created. </li>
|
306 |
+
* <li><code>AdditionalInfo</code> - <code>string</code> - Optional - A JSON string for selecting additional features. </li>
|
307 |
+
* <li><code>Steps</code> - <code>array</code> - Optional - A list of steps to be executed by the job flow. <ul>
|
308 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
309 |
+
* <li><code>Name</code> - <code>string</code> - Required - The name of the job flow step. </li>
|
310 |
+
* <li><code>ActionOnFailure</code> - <code>string</code> - Optional - Specifies the action to take if the job flow step fails. [Allowed values: <code>TERMINATE_JOB_FLOW</code>, <code>CANCEL_AND_WAIT</code>, <code>CONTINUE</code>]</li>
|
311 |
+
* <li><code>HadoopJarStep</code> - <code>array</code> - Required - Specifies the JAR file used for the job flow step. Takes an associative array of parameters that can have the following keys: <ul>
|
312 |
+
* <li><code>Properties</code> - <code>array</code> - Optional - A list of Java properties that are set when the step runs. You can use these properties to pass key value pairs to your main function. <ul>
|
313 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
314 |
+
* <li><code>Key</code> - <code>string</code> - Optional - The unique identifier of a key value pair. </li>
|
315 |
+
* <li><code>Value</code> - <code>string</code> - Optional - The value part of the identified key. </li>
|
316 |
+
* </ul></li>
|
317 |
+
* </ul></li>
|
318 |
+
* <li><code>Jar</code> - <code>string</code> - Required - A path to a JAR file run during the step. </li>
|
319 |
+
* <li><code>MainClass</code> - <code>string</code> - Optional - The name of the main class in the specified Java file. If not specified, the JAR file should specify a Main-Class in its manifest file. </li>
|
320 |
+
* <li><code>Args</code> - <code>string|array</code> - Optional - A list of command line arguments passed to the JAR file's main function when executed. Pass a string for a single value, or an indexed array for multiple values. </li>
|
321 |
+
* </ul></li>
|
322 |
+
* </ul></li>
|
323 |
+
* </ul></li>
|
324 |
+
* <li><code>BootstrapActions</code> - <code>array</code> - Optional - A list of bootstrap actions that will be run before Hadoop is started on the cluster nodes. <ul>
|
325 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
326 |
+
* <li><code>Name</code> - <code>string</code> - Required - The name of the bootstrap action. </li>
|
327 |
+
* <li><code>ScriptBootstrapAction</code> - <code>array</code> - Required - The script run by the bootstrap action. Takes an associative array of parameters that can have the following keys: <ul>
|
328 |
+
* <li><code>Path</code> - <code>string</code> - Optional - Location of the script to run during a bootstrap action. Can be either a location in Amazon S3 or on a local file system. </li>
|
329 |
+
* <li><code>Args</code> - <code>string|array</code> - Optional - A list of command line arguments to pass to the bootstrap action script. Pass a string for a single value, or an indexed array for multiple values. </li>
|
330 |
+
* </ul></li>
|
331 |
+
* </ul></li>
|
332 |
+
* </ul></li>
|
333 |
+
* <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>
|
334 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
335 |
+
*/
|
336 |
+
public function run_job_flow($name, $instances, $opt = null)
|
337 |
+
{
|
338 |
+
if (!$opt) $opt = array();
|
339 |
+
$opt['Name'] = $name;
|
340 |
+
|
341 |
+
// Collapse these list values for the required parameter
|
342 |
+
if (isset($instances['InstanceGroups']))
|
343 |
+
{
|
344 |
+
$instances['InstanceGroups'] = CFComplexType::map(array(
|
345 |
+
'member' => (is_array($instances['InstanceGroups']) ? $instances['InstanceGroups'] : array($instances['InstanceGroups']))
|
346 |
+
));
|
347 |
+
}
|
348 |
+
|
349 |
+
// Required parameter
|
350 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
351 |
+
'Instances' => (is_array($instances) ? $instances : array($instances))
|
352 |
+
), 'member'));
|
353 |
+
|
354 |
+
// Optional parameter
|
355 |
+
if (isset($opt['Steps']))
|
356 |
+
{
|
357 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
358 |
+
'Steps' => $opt['Steps']
|
359 |
+
), 'member'));
|
360 |
+
unset($opt['Steps']);
|
361 |
+
}
|
362 |
+
|
363 |
+
// Optional parameter
|
364 |
+
if (isset($opt['BootstrapActions']))
|
365 |
+
{
|
366 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
367 |
+
'BootstrapActions' => $opt['BootstrapActions']
|
368 |
+
), 'member'));
|
369 |
+
unset($opt['BootstrapActions']);
|
370 |
+
}
|
371 |
+
|
372 |
+
return $this->authenticate('RunJobFlow', $opt, $this->hostname);
|
373 |
+
}
|
374 |
+
|
375 |
+
/**
|
376 |
+
*
|
377 |
+
* ModifyInstanceGroups modifies the number of nodes and configuration settings of an instance group. The input parameters
|
378 |
+
* include the new target instance count for the group and the instance group ID. The call will either succeed or fail
|
379 |
+
* atomically.
|
380 |
+
*
|
381 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
382 |
+
* <li><code>InstanceGroups</code> - <code>array</code> - Optional - Instance groups to change. <ul>
|
383 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
384 |
+
* <li><code>InstanceGroupId</code> - <code>string</code> - Required - Unique ID of the instance group to expand or shrink. </li>
|
385 |
+
* <li><code>InstanceCount</code> - <code>integer</code> - Required - Target size for the instance group. </li>
|
386 |
+
* </ul></li>
|
387 |
+
* </ul></li>
|
388 |
+
* <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>
|
389 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
390 |
+
*/
|
391 |
+
public function modify_instance_groups($opt = null)
|
392 |
+
{
|
393 |
+
if (!$opt) $opt = array();
|
394 |
+
|
395 |
+
// Optional parameter
|
396 |
+
if (isset($opt['InstanceGroups']))
|
397 |
+
{
|
398 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
399 |
+
'InstanceGroups' => $opt['InstanceGroups']
|
400 |
+
), 'member'));
|
401 |
+
unset($opt['InstanceGroups']);
|
402 |
+
}
|
403 |
+
|
404 |
+
return $this->authenticate('ModifyInstanceGroups', $opt, $this->hostname);
|
405 |
+
}
|
406 |
+
}
|
407 |
+
|
408 |
+
|
409 |
+
/*%******************************************************************************************%*/
|
410 |
+
// EXCEPTIONS
|
411 |
+
|
412 |
+
/**
|
413 |
+
* Default EMR Exception.
|
414 |
+
*/
|
415 |
+
class EMR_Exception extends Exception {}
|
app/libs/aws/services/iam.class.php
ADDED
@@ -0,0 +1,1155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
*
|
20 |
+
* AWS Identity and Access Management (IAM) is a web service that enables Amazon Web Services (AWS) customers to manage
|
21 |
+
* Users and User permissions under their AWS Account.
|
22 |
+
*
|
23 |
+
* This is the AWS Identity and Access Management API Reference. This guide describes who should read this guide and other
|
24 |
+
* resources related to IAM.
|
25 |
+
*
|
26 |
+
* Use of this guide assumes you are familiar with the following:
|
27 |
+
*
|
28 |
+
* <ul> <li>Basic understanding of web services (for information, go to W3 Schools Web Services Tutorial at <a
|
29 |
+
* href="http://www.w3schools.com/webservices/default.asp">http://www.w3schools.com/webservices/default.asp</a>).</li>
|
30 |
+
*
|
31 |
+
* <li>XML (for information, go to W3 Schools XML Tutorial at <a
|
32 |
+
* href="http://www.w3schools.com/xml/default.asp">http://www.w3schools.com/xml/default.asp</a>).</li>
|
33 |
+
*
|
34 |
+
* <li>JSON (for information, go to <a href="http://json.org">http://json.org</a>)</li>
|
35 |
+
*
|
36 |
+
* <li>The specific AWS products you are using or plan to use (e.g., Amazon Elastic Compute Cloud (Amazon EC2), Amazon
|
37 |
+
* Simple Storage Service (Amazon S3), and so on.)</li>
|
38 |
+
*
|
39 |
+
* </ul>
|
40 |
+
*
|
41 |
+
* If you're new to AWS and need additional technical information about a specific AWS product, you can find the product's
|
42 |
+
* technical documentation at <a href="http://aws.amazon.com/documentation/">http://aws.amazon.com/documentation/</a>.
|
43 |
+
*
|
44 |
+
* We will refer to Amazon AWS Identity and Access Management using the abbreviated form IAM. All copyrights and legal
|
45 |
+
* protections still apply.
|
46 |
+
*
|
47 |
+
* @version Wed Feb 16 17:08:01 PST 2011
|
48 |
+
* @license See the included NOTICE.md file for complete information.
|
49 |
+
* @copyright See the included NOTICE.md file for complete information.
|
50 |
+
* @link http://aws.amazon.com/iam/Amazon Identity and Access Management Service
|
51 |
+
* @link http://aws.amazon.com/documentation/iam/Amazon Identity and Access Management Service documentation
|
52 |
+
*/
|
53 |
+
class AmazonIAM extends CFRuntime
|
54 |
+
{
|
55 |
+
|
56 |
+
/*%******************************************************************************************%*/
|
57 |
+
// CLASS CONSTANTS
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Specify the default queue URL.
|
61 |
+
*/
|
62 |
+
const DEFAULT_URL = 'iam.amazonaws.com';
|
63 |
+
|
64 |
+
|
65 |
+
|
66 |
+
/*%******************************************************************************************%*/
|
67 |
+
// CONSTRUCTOR
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Constructs a new instance of <AmazonIAM>.
|
71 |
+
*
|
72 |
+
* @param string $key (Optional) Your Amazon API Key. If blank, it will look for the <code>AWS_KEY</code> constant.
|
73 |
+
* @param string $secret_key (Optional) Your Amazon API Secret Key. If blank, it will look for the <code>AWS_SECRET_KEY</code> constant.
|
74 |
+
* @return boolean false if no valid values are set, otherwise true.
|
75 |
+
*/
|
76 |
+
public function __construct($key = null, $secret_key = null)
|
77 |
+
{
|
78 |
+
$this->api_version = '2010-05-08';
|
79 |
+
$this->hostname = self::DEFAULT_URL;
|
80 |
+
|
81 |
+
if (!$key && !defined('AWS_KEY'))
|
82 |
+
{
|
83 |
+
throw new IAM_Exception('No account key was passed into the constructor, nor was it set in the AWS_KEY constant.');
|
84 |
+
}
|
85 |
+
|
86 |
+
if (!$secret_key && !defined('AWS_SECRET_KEY'))
|
87 |
+
{
|
88 |
+
throw new IAM_Exception('No account secret was passed into the constructor, nor was it set in the AWS_SECRET_KEY constant.');
|
89 |
+
}
|
90 |
+
|
91 |
+
return parent::__construct($key, $secret_key);
|
92 |
+
}
|
93 |
+
|
94 |
+
|
95 |
+
/*%******************************************************************************************%*/
|
96 |
+
// SERVICE METHODS
|
97 |
+
|
98 |
+
/**
|
99 |
+
*
|
100 |
+
* Lists the groups that have the specified path prefix.
|
101 |
+
*
|
102 |
+
* You can paginate the results using the <code>MaxItems</code> and <code>Marker</code> parameters.
|
103 |
+
*
|
104 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
105 |
+
* <li><code>PathPrefix</code> - <code>string</code> - Optional - The path prefix for filtering the results. For example: <code>/division_abc/subdivision_xyz/</code>, which would get all groups whose path starts with <code>/division_abc/subdivision_xyz/</code>. This parameter is optional. If it is not included, it defaults to a slash (/), listing all groups. </li>
|
106 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - Use this only when paginating results, and only in a subsequent request after you've received a response where the results are truncated. Set it to the value of the <code>Marker</code> element in the response you just received. </li>
|
107 |
+
* <li><code>MaxItems</code> - <code>integer</code> - Optional - Use this only when paginating results to indicate the maximum number of groups you want in the response. If there are additional groups beyond the maximum you specify, the <code>IsTruncated</code> response element is <code>true</code>. </li>
|
108 |
+
* <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>
|
109 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
110 |
+
*/
|
111 |
+
public function list_groups($opt = null)
|
112 |
+
{
|
113 |
+
if (!$opt) $opt = array();
|
114 |
+
|
115 |
+
return $this->authenticate('ListGroups', $opt, $this->hostname);
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
*
|
120 |
+
* Deletes the access key associated with the specified User.
|
121 |
+
*
|
122 |
+
* If you do not specify a User name, IAM determines the User name implicitly based on the AWS Access Key ID signing the
|
123 |
+
* request. Because this action works for access keys under the AWS Account, you can use this API to manage root
|
124 |
+
* credentials even if the AWS Account has no associated Users.
|
125 |
+
*
|
126 |
+
* @param string $access_key_id (Required) The Access Key ID for the Access Key ID and Secret Access Key you want to delete.
|
127 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
128 |
+
* <li><code>UserName</code> - <code>string</code> - Optional - Name of the User whose key you want to delete. </li>
|
129 |
+
* <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>
|
130 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
131 |
+
*/
|
132 |
+
public function delete_access_key($access_key_id, $opt = null)
|
133 |
+
{
|
134 |
+
if (!$opt) $opt = array();
|
135 |
+
$opt['AccessKeyId'] = $access_key_id;
|
136 |
+
|
137 |
+
return $this->authenticate('DeleteAccessKey', $opt, $this->hostname);
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
*
|
142 |
+
* Deletes the specified account alias.
|
143 |
+
*
|
144 |
+
* @param string $account_alias (Required) Name of the account alias to delete.
|
145 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
146 |
+
* <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>
|
147 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
148 |
+
*/
|
149 |
+
public function delete_account_alias($account_alias, $opt = null)
|
150 |
+
{
|
151 |
+
if (!$opt) $opt = array();
|
152 |
+
$opt['AccountAlias'] = $account_alias;
|
153 |
+
|
154 |
+
return $this->authenticate('DeleteAccountAlias', $opt, $this->hostname);
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
*
|
159 |
+
* Returns information about the signing certificates associated with the specified User. If there are none, the action
|
160 |
+
* returns an empty list.
|
161 |
+
*
|
162 |
+
* Although each User is limited to a small number of signing certificates, you can still paginate the results using the
|
163 |
+
* <code>MaxItems</code> and <code>Marker</code> parameters.
|
164 |
+
*
|
165 |
+
* If the <code>UserName</code> field is not specified, the UserName is determined implicitly based on the AWS Access Key
|
166 |
+
* ID used to sign the request. Because this action works for access keys under the AWS Account, this API can be used to
|
167 |
+
* manage root credentials even if the AWS Account has no associated Users.
|
168 |
+
*
|
169 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
170 |
+
* <li><code>UserName</code> - <code>string</code> - Optional - The name of the User. </li>
|
171 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - Use this only when paginating results, and only in a subsequent request after you've received a response where the results are truncated. Set it to the value of the <code>Marker</code> element in the response you just received. </li>
|
172 |
+
* <li><code>MaxItems</code> - <code>integer</code> - Optional - Use this only when paginating results to indicate the maximum number of certificate IDs you want in the response. If there are additional certificate IDs beyond the maximum you specify, the <code>IsTruncated</code> response element is <code>true</code>. </li>
|
173 |
+
* <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>
|
174 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
175 |
+
*/
|
176 |
+
public function list_signing_certificates($opt = null)
|
177 |
+
{
|
178 |
+
if (!$opt) $opt = array();
|
179 |
+
|
180 |
+
return $this->authenticate('ListSigningCertificates', $opt, $this->hostname);
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
*
|
185 |
+
* Uploads an X.509 signing certificate and associates it with the specified User. Some AWS services use X.509 signing
|
186 |
+
* certificates to validate requests that are signed with a corresponding private key. When you upload the certificate, its
|
187 |
+
* default status is <code>Active</code>.
|
188 |
+
*
|
189 |
+
* If the <code>UserName</code> field is not specified, the User name is determined implicitly based on the AWS Access Key
|
190 |
+
* ID used to sign the request. Because this action works for access keys under the AWS Account, this API can be used to
|
191 |
+
* manage root credentials even if the AWS Account has no associated Users.
|
192 |
+
*
|
193 |
+
* Because the body of a X.509 certificate can be large, you should use POST rather than GET when calling
|
194 |
+
* <code>UploadSigningCertificate</code>. For more information, see <a
|
195 |
+
* href="http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?IAM_UsingQueryAPI.html">Making Query
|
196 |
+
* Requests</a> in <i>Using AWS Identity and Access Management</i>.
|
197 |
+
*
|
198 |
+
* @param string $certificate_body (Required) The contents of the signing certificate.
|
199 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
200 |
+
* <li><code>UserName</code> - <code>string</code> - Optional - Name of the User the signing certificate is for. </li>
|
201 |
+
* <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>
|
202 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
203 |
+
*/
|
204 |
+
public function upload_signing_certificate($certificate_body, $opt = null)
|
205 |
+
{
|
206 |
+
if (!$opt) $opt = array();
|
207 |
+
$opt['CertificateBody'] = $certificate_body;
|
208 |
+
|
209 |
+
return $this->authenticate('UploadSigningCertificate', $opt, $this->hostname);
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
*
|
214 |
+
* Deletes the specified policy associated with the specified User.
|
215 |
+
*
|
216 |
+
* @param string $user_name (Required) Name of the User the policy is associated with.
|
217 |
+
* @param string $policy_name (Required) Name of the policy document to delete.
|
218 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
219 |
+
* <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>
|
220 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
221 |
+
*/
|
222 |
+
public function delete_user_policy($user_name, $policy_name, $opt = null)
|
223 |
+
{
|
224 |
+
if (!$opt) $opt = array();
|
225 |
+
$opt['UserName'] = $user_name;
|
226 |
+
$opt['PolicyName'] = $policy_name;
|
227 |
+
|
228 |
+
return $this->authenticate('DeleteUserPolicy', $opt, $this->hostname);
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
*
|
233 |
+
* Adds (or updates) a policy document associated with the specified User. For information about policies, refer to <a
|
234 |
+
* href="http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?PoliciesOverview.html">Overview of Policies</a>
|
235 |
+
* in <i>Using AWS Identity and Access Management</i>.
|
236 |
+
*
|
237 |
+
* For information about limits on the number of policies you can associate with a User, see <a
|
238 |
+
* href="http://docs.amazonwebservices.com/IAM/2010-05-08/UserGuide/index.html?LimitationsOnEntities.html">Limitations on
|
239 |
+
* IAM Entities</a> in <i>Using AWS Identity and Access Management</i>.
|
240 |
+
*
|
241 |
+
* Because policy documents can be large, you should use POST rather than GET when calling <code>PutUserPolicy</code>. For
|
242 |
+
* more information, see <a
|
243 |
+
* href="http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?IAM_UsingQueryAPI.html">Making Query
|
244 |
+
* Requests</a> in <i>Using AWS Identity and Access Management</i>.
|
245 |
+
*
|
246 |
+
* @param string $user_name (Required) Name of the User to associate the policy with.
|
247 |
+
* @param string $policy_name (Required) Name of the policy document.
|
248 |
+
* @param string $policy_document (Required) The policy document.
|
249 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
250 |
+
* <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>
|
251 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
252 |
+
*/
|
253 |
+
public function put_user_policy($user_name, $policy_name, $policy_document, $opt = null)
|
254 |
+
{
|
255 |
+
if (!$opt) $opt = array();
|
256 |
+
$opt['UserName'] = $user_name;
|
257 |
+
$opt['PolicyName'] = $policy_name;
|
258 |
+
$opt['PolicyDocument'] = $policy_document;
|
259 |
+
|
260 |
+
return $this->authenticate('PutUserPolicy', $opt, $this->hostname);
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
*
|
265 |
+
* Lists the server certificates that have the specified path prefix. If none exist, the action returns an empty list.
|
266 |
+
*
|
267 |
+
* You can paginate the results using the <code>MaxItems</code> and <code>Marker</code> parameters.
|
268 |
+
*
|
269 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
270 |
+
* <li><code>PathPrefix</code> - <code>string</code> - Optional - The path prefix for filtering the results. For example: <code>/company/servercerts</code> would get all server certificates for which the path starts with <code>/company/servercerts</code>. This parameter is optional. If it is not included, it defaults to a slash (/), listing all server certificates. </li>
|
271 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - Use this only when paginating results, and only in a subsequent request after you've received a response where the results are truncated. Set it to the value of the <code>Marker</code> element in the response you just received. </li>
|
272 |
+
* <li><code>MaxItems</code> - <code>integer</code> - Optional - Use this only when paginating results to indicate the maximum number of server certificates you want in the response. If there are additional server certificates beyond the maximum you specify, the <code>IsTruncated</code> response element will be set to <code>true</code>. </li>
|
273 |
+
* <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>
|
274 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
275 |
+
*/
|
276 |
+
public function list_server_certificates($opt = null)
|
277 |
+
{
|
278 |
+
if (!$opt) $opt = array();
|
279 |
+
|
280 |
+
return $this->authenticate('ListServerCertificates', $opt, $this->hostname);
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
*
|
285 |
+
* Retrieves the specified policy document for the specified User. The returned policy is URL-encoded according to RFC
|
286 |
+
* 3986. For more information about RFC 3986, go to <a
|
287 |
+
* href="http://www.faqs.org/rfcs/rfc3986.html">http://www.faqs.org/rfcs/rfc3986.html</a>.
|
288 |
+
*
|
289 |
+
* @param string $user_name (Required) Name of the User who the policy is associated with.
|
290 |
+
* @param string $policy_name (Required) Name of the policy document to get.
|
291 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
292 |
+
* <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>
|
293 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
294 |
+
*/
|
295 |
+
public function get_user_policy($user_name, $policy_name, $opt = null)
|
296 |
+
{
|
297 |
+
if (!$opt) $opt = array();
|
298 |
+
$opt['UserName'] = $user_name;
|
299 |
+
$opt['PolicyName'] = $policy_name;
|
300 |
+
|
301 |
+
return $this->authenticate('GetUserPolicy', $opt, $this->hostname);
|
302 |
+
}
|
303 |
+
|
304 |
+
/**
|
305 |
+
*
|
306 |
+
* Updates the login profile for the specified User. Use this API to change the User's password.
|
307 |
+
*
|
308 |
+
* In the full release you will be able to use IAM to access your services through the AWS Management Console. Although
|
309 |
+
* this feature is not currently available, you can create login profiles for your Users now. Then, when this feature is
|
310 |
+
* implemented, your Users can use IAM to access your services through the AWS Management Console.
|
311 |
+
*
|
312 |
+
* @param string $user_name (Required) Name of the User whose login profile you want to update.
|
313 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
314 |
+
* <li><code>Password</code> - <code>string</code> - Optional - The new password for the User name. </li>
|
315 |
+
* <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>
|
316 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
317 |
+
*/
|
318 |
+
public function update_login_profile($user_name, $opt = null)
|
319 |
+
{
|
320 |
+
if (!$opt) $opt = array();
|
321 |
+
$opt['UserName'] = $user_name;
|
322 |
+
|
323 |
+
return $this->authenticate('UpdateLoginProfile', $opt, $this->hostname);
|
324 |
+
}
|
325 |
+
|
326 |
+
/**
|
327 |
+
*
|
328 |
+
* Updates the name and/or the path of the specified server certificate.
|
329 |
+
*
|
330 |
+
* You should understand the implications of changing a server certificate's path or name. For more information, see <a
|
331 |
+
* href="http://docs.amazonwebservices.com/IAM/latest/UserGuide/ManagingServerCerts.html">Managing Server Certificates</a>
|
332 |
+
* in <i>Using AWS Identity and Access Management</i>.
|
333 |
+
*
|
334 |
+
* To change a server certificate name the requester must have appropriate permissions on both the source object and the
|
335 |
+
* target object. For example, to change the name from ProductionCert to ProdCert, the entity making the request must have
|
336 |
+
* permission on ProductionCert and ProdCert, or must have permission on all (*). For more information about permissions,
|
337 |
+
* see <a href="http://docs.amazonwebservices.com/IAM/2010-05-08/UserGuide/PermissionsAndPolicies.html">Permissions and
|
338 |
+
* Policies</a>.
|
339 |
+
*
|
340 |
+
* @param string $server_certificate_name (Required) The name of the server certificate that you want to update.
|
341 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
342 |
+
* <li><code>NewPath</code> - <code>string</code> - Optional - The new path for the server certificate. Include this only if you are updating the server certificate's path. </li>
|
343 |
+
* <li><code>NewServerCertificateName</code> - <code>string</code> - Optional - The new name for the server certificate. Include this only if you are updating the server certificate's name. </li>
|
344 |
+
* <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>
|
345 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
346 |
+
*/
|
347 |
+
public function update_server_certificate($server_certificate_name, $opt = null)
|
348 |
+
{
|
349 |
+
if (!$opt) $opt = array();
|
350 |
+
$opt['ServerCertificateName'] = $server_certificate_name;
|
351 |
+
|
352 |
+
return $this->authenticate('UpdateServerCertificate', $opt, $this->hostname);
|
353 |
+
}
|
354 |
+
|
355 |
+
/**
|
356 |
+
*
|
357 |
+
* Updates the name and/or the path of the specified User.
|
358 |
+
*
|
359 |
+
* You should understand the implications of changing a User's path or name. For more information, see <a
|
360 |
+
* href="http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?Using_Renaming.html">Renaming Users and
|
361 |
+
* Groups</a> in <i>Using AWS Identity and Access Management</i>.
|
362 |
+
*
|
363 |
+
* To change a User name the requester must have appropriate permissions on both the source object and the target object.
|
364 |
+
* For example, to change Bob to Robert, the entity making the request must have permission on Bob and Robert, or must have
|
365 |
+
* permission on all (*). For more information about permissions, see <a
|
366 |
+
* href="http://docs.amazonwebservices.com/IAM/2010-05-08/UserGuide/PermissionsAndPolicies.html">Permissions and
|
367 |
+
* Policies</a>.
|
368 |
+
*
|
369 |
+
* @param string $user_name (Required) Name of the User to update. If you're changing the name of the User, this is the original User name.
|
370 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
371 |
+
* <li><code>NewPath</code> - <code>string</code> - Optional - New path for the User. Include this parameter only if you're changing the User's path. </li>
|
372 |
+
* <li><code>NewUserName</code> - <code>string</code> - Optional - New name for the User. Include this parameter only if you're changing the User's name. </li>
|
373 |
+
* <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>
|
374 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
375 |
+
*/
|
376 |
+
public function update_user($user_name, $opt = null)
|
377 |
+
{
|
378 |
+
if (!$opt) $opt = array();
|
379 |
+
$opt['UserName'] = $user_name;
|
380 |
+
|
381 |
+
return $this->authenticate('UpdateUser', $opt, $this->hostname);
|
382 |
+
}
|
383 |
+
|
384 |
+
/**
|
385 |
+
*
|
386 |
+
* Deletes the login profile for the specified User, which terminates the User's ability to access AWS services through the
|
387 |
+
* IAM login page.
|
388 |
+
*
|
389 |
+
* Deleting a User's login profile does not prevent a User from accessing IAM through the command line interface or the
|
390 |
+
* API. To prevent all User access you must also either make the access key inactive or delete it. For more information
|
391 |
+
* about making keys inactive or deleting them, see UpdateAccessKey and DeleteAccessKey.
|
392 |
+
*
|
393 |
+
* In the full release you will be able to use IAM to access your services through the AWS Management Console. Although
|
394 |
+
* this feature is not currently available, you can create login profiles for your Users now. Then, when this feature is
|
395 |
+
* implemented, your Users can use IAM to access your services through the AWS Management Console.
|
396 |
+
*
|
397 |
+
* @param string $user_name (Required) Name of the User whose login profile you want to delete.
|
398 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
399 |
+
* <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>
|
400 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
401 |
+
*/
|
402 |
+
public function delete_login_profile($user_name, $opt = null)
|
403 |
+
{
|
404 |
+
if (!$opt) $opt = array();
|
405 |
+
$opt['UserName'] = $user_name;
|
406 |
+
|
407 |
+
return $this->authenticate('DeleteLoginProfile', $opt, $this->hostname);
|
408 |
+
}
|
409 |
+
|
410 |
+
/**
|
411 |
+
*
|
412 |
+
* Changes the status of the specified signing certificate from active to disabled, or vice versa. This action can be used
|
413 |
+
* to disable a User's signing certificate as part of a certificate rotation workflow.
|
414 |
+
*
|
415 |
+
* If the <code>UserName</code> field is not specified, the UserName is determined implicitly based on the AWS Access Key
|
416 |
+
* ID used to sign the request. Because this action works for access keys under the AWS Account, this API can be used to
|
417 |
+
* manage root credentials even if the AWS Account has no associated Users.
|
418 |
+
*
|
419 |
+
* For information about rotating certificates, see <a
|
420 |
+
* href="http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?ManagingCredentials.html">Managing Keys and
|
421 |
+
* Certificates</a> in <i>Using AWS Identity and Access Management</i>.
|
422 |
+
*
|
423 |
+
* @param string $certificate_id (Required) The ID of the signing certificate you want to update.
|
424 |
+
* @param string $status (Required) The status you want to assign to the certificate. <code>Active</code> means the certificate can be used for API calls to AWS, while <code>Inactive</code> means the certificate cannot be used. [Allowed values: <code>Active</code>, <code>Inactive</code>]
|
425 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
426 |
+
* <li><code>UserName</code> - <code>string</code> - Optional - Name of the User the signing certificate belongs to. </li>
|
427 |
+
* <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>
|
428 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
429 |
+
*/
|
430 |
+
public function update_signing_certificate($certificate_id, $status, $opt = null)
|
431 |
+
{
|
432 |
+
if (!$opt) $opt = array();
|
433 |
+
$opt['CertificateId'] = $certificate_id;
|
434 |
+
$opt['Status'] = $status;
|
435 |
+
|
436 |
+
return $this->authenticate('UpdateSigningCertificate', $opt, $this->hostname);
|
437 |
+
}
|
438 |
+
|
439 |
+
/**
|
440 |
+
*
|
441 |
+
* Deletes the specified policy that is associated with the specified group.
|
442 |
+
*
|
443 |
+
* @param string $group_name (Required) Name of the group the policy is associated with.
|
444 |
+
* @param string $policy_name (Required) Name of the policy document to delete.
|
445 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
446 |
+
* <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>
|
447 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
448 |
+
*/
|
449 |
+
public function delete_group_policy($group_name, $policy_name, $opt = null)
|
450 |
+
{
|
451 |
+
if (!$opt) $opt = array();
|
452 |
+
$opt['GroupName'] = $group_name;
|
453 |
+
$opt['PolicyName'] = $policy_name;
|
454 |
+
|
455 |
+
return $this->authenticate('DeleteGroupPolicy', $opt, $this->hostname);
|
456 |
+
}
|
457 |
+
|
458 |
+
/**
|
459 |
+
*
|
460 |
+
* Lists the Users that have the specified path prefix. If there are none, the action returns an empty list.
|
461 |
+
*
|
462 |
+
* You can paginate the results using the <code>MaxItems</code> and <code>Marker</code> parameters.
|
463 |
+
*
|
464 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
465 |
+
* <li><code>PathPrefix</code> - <code>string</code> - Optional - The path prefix for filtering the results. For example: <code>/division_abc/subdivision_xyz/</code>, which would get all User names whose path starts with <code>/division_abc/subdivision_xyz/</code>. This parameter is optional. If it is not included, it defaults to a slash (/), listing all User names. </li>
|
466 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - Use this parameter only when paginating results, and only in a subsequent request after you've received a response where the results are truncated. Set it to the value of the <code>Marker</code> element in the response you just received. </li>
|
467 |
+
* <li><code>MaxItems</code> - <code>integer</code> - Optional - Use this parameter only when paginating results to indicate the maximum number of User names you want in the response. If there are additional User names beyond the maximum you specify, the <code>IsTruncated</code> response element is <code>true</code>. </li>
|
468 |
+
* <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>
|
469 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
470 |
+
*/
|
471 |
+
public function list_users($opt = null)
|
472 |
+
{
|
473 |
+
if (!$opt) $opt = array();
|
474 |
+
|
475 |
+
return $this->authenticate('ListUsers', $opt, $this->hostname);
|
476 |
+
}
|
477 |
+
|
478 |
+
/**
|
479 |
+
*
|
480 |
+
* Updates the name and/or the path of the specified group.
|
481 |
+
*
|
482 |
+
* You should understand the implications of changing a group's path or name. For more information, see <a
|
483 |
+
* href="http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?Using_Renaming.html">Renaming Users and
|
484 |
+
* Groups</a> in <i>Using AWS Identity and Access Management</i>.
|
485 |
+
*
|
486 |
+
* To change a group name the requester must have appropriate permissions on both the source object and the target object.
|
487 |
+
* For example, to change Managers to MGRs, the entity making the request must have permission on Managers and MGRs, or
|
488 |
+
* must have permission on all (*). For more information about permissions, see <a
|
489 |
+
* href="http://docs.amazonwebservices.com/IAM/2010-05-08/UserGuide/PermissionsAndPolicies.html">Permissions and
|
490 |
+
* Policies</a>.
|
491 |
+
*
|
492 |
+
* @param string $group_name (Required) Name of the group to update. If you're changing the name of the group, this is the original name.
|
493 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
494 |
+
* <li><code>NewPath</code> - <code>string</code> - Optional - New path for the group. Only include this if changing the group's path. </li>
|
495 |
+
* <li><code>NewGroupName</code> - <code>string</code> - Optional - New name for the group. Only include this if changing the group's name. </li>
|
496 |
+
* <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>
|
497 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
498 |
+
*/
|
499 |
+
public function update_group($group_name, $opt = null)
|
500 |
+
{
|
501 |
+
if (!$opt) $opt = array();
|
502 |
+
$opt['GroupName'] = $group_name;
|
503 |
+
|
504 |
+
return $this->authenticate('UpdateGroup', $opt, $this->hostname);
|
505 |
+
}
|
506 |
+
|
507 |
+
/**
|
508 |
+
*
|
509 |
+
* Retrieves information about the specified server certificate.
|
510 |
+
*
|
511 |
+
* @param string $server_certificate_name (Required) The name of the server certificate you want to retrieve information about.
|
512 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
513 |
+
* <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>
|
514 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
515 |
+
*/
|
516 |
+
public function get_server_certificate($server_certificate_name, $opt = null)
|
517 |
+
{
|
518 |
+
if (!$opt) $opt = array();
|
519 |
+
$opt['ServerCertificateName'] = $server_certificate_name;
|
520 |
+
|
521 |
+
return $this->authenticate('GetServerCertificate', $opt, $this->hostname);
|
522 |
+
}
|
523 |
+
|
524 |
+
/**
|
525 |
+
*
|
526 |
+
* Adds (or updates) a policy document associated with the specified group. For information about policies, refer to <a
|
527 |
+
* href="http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?PoliciesOverview.html">Overview of Policies</a>
|
528 |
+
* in <i>Using AWS Identity and Access Management</i>.
|
529 |
+
*
|
530 |
+
* For information about limits on the number of policies you can associate with a group, see <a
|
531 |
+
* href="http://docs.amazonwebservices.com/IAM/2010-05-08/UserGuide/index.html?LimitationsOnEntities.html">Limitations on
|
532 |
+
* IAM Entities</a> in <i>Using AWS Identity and Access Management</i>.
|
533 |
+
*
|
534 |
+
* Because policy documents can be large, you should use POST rather than GET when calling <code>PutGroupPolicy</code>. For
|
535 |
+
* more information, see <a
|
536 |
+
* href="http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?IAM_UsingQueryAPI.html">Making Query
|
537 |
+
* Requests</a> in <i>Using AWS Identity and Access Management</i>.
|
538 |
+
*
|
539 |
+
* @param string $group_name (Required) Name of the group to associate the policy with.
|
540 |
+
* @param string $policy_name (Required) Name of the policy document.
|
541 |
+
* @param string $policy_document (Required) The policy document.
|
542 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
543 |
+
* <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>
|
544 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
545 |
+
*/
|
546 |
+
public function put_group_policy($group_name, $policy_name, $policy_document, $opt = null)
|
547 |
+
{
|
548 |
+
if (!$opt) $opt = array();
|
549 |
+
$opt['GroupName'] = $group_name;
|
550 |
+
$opt['PolicyName'] = $policy_name;
|
551 |
+
$opt['PolicyDocument'] = $policy_document;
|
552 |
+
|
553 |
+
return $this->authenticate('PutGroupPolicy', $opt, $this->hostname);
|
554 |
+
}
|
555 |
+
|
556 |
+
/**
|
557 |
+
*
|
558 |
+
* Creates a new User for your AWS Account.
|
559 |
+
*
|
560 |
+
* For information about limitations on the number of Users you can create, see <a
|
561 |
+
* href="http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?LimitationsOnEntities.html">Limitations on IAM
|
562 |
+
* Entities</a> in <i>Using AWS Identity and Access Management</i>.
|
563 |
+
*
|
564 |
+
* @param string $user_name (Required) Name of the User to create.
|
565 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
566 |
+
* <li><code>Path</code> - <code>string</code> - Optional - The path for the User name. For more information about paths, see Identifiers for IAM Entities in <i>Using AWS Identity and Access Management</i>. This parameter is optional. If it is not included, it defaults to a slash (/). </li>
|
567 |
+
* <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>
|
568 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
569 |
+
*/
|
570 |
+
public function create_user($user_name, $opt = null)
|
571 |
+
{
|
572 |
+
if (!$opt) $opt = array();
|
573 |
+
$opt['UserName'] = $user_name;
|
574 |
+
|
575 |
+
return $this->authenticate('CreateUser', $opt, $this->hostname);
|
576 |
+
}
|
577 |
+
|
578 |
+
/**
|
579 |
+
*
|
580 |
+
* Deletes the specified signing certificate associated with the specified User.
|
581 |
+
*
|
582 |
+
* If you do not specify a User name, IAM determines the User name implicitly based on the AWS Access Key ID signing the
|
583 |
+
* request. Because this action works for access keys under the AWS Account, you can use this API to manage root
|
584 |
+
* credentials even if the AWS Account has no associated Users.
|
585 |
+
*
|
586 |
+
* @param string $certificate_id (Required) ID of the signing certificate to delete.
|
587 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
588 |
+
* <li><code>UserName</code> - <code>string</code> - Optional - Name of the User the signing certificate belongs to. </li>
|
589 |
+
* <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>
|
590 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
591 |
+
*/
|
592 |
+
public function delete_signing_certificate($certificate_id, $opt = null)
|
593 |
+
{
|
594 |
+
if (!$opt) $opt = array();
|
595 |
+
$opt['CertificateId'] = $certificate_id;
|
596 |
+
|
597 |
+
return $this->authenticate('DeleteSigningCertificate', $opt, $this->hostname);
|
598 |
+
}
|
599 |
+
|
600 |
+
/**
|
601 |
+
*
|
602 |
+
* Enables the specified MFA device and associates it with the specified User name. Once enabled, the MFA device is
|
603 |
+
* required for every subsequent login by the User name associated with the device.
|
604 |
+
*
|
605 |
+
* @param string $user_name (Required) Name of the User for whom you want to enable the MFA device.
|
606 |
+
* @param string $serial_number (Required) The serial number that uniquely identifies the MFA device.
|
607 |
+
* @param string $authentication_code1 (Required) An authentication code emitted by the device.
|
608 |
+
* @param string $authentication_code2 (Required) A subsequent authentication code emitted by the device.
|
609 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
610 |
+
* <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>
|
611 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
612 |
+
*/
|
613 |
+
public function enable_mfa_device($user_name, $serial_number, $authentication_code1, $authentication_code2, $opt = null)
|
614 |
+
{
|
615 |
+
if (!$opt) $opt = array();
|
616 |
+
$opt['UserName'] = $user_name;
|
617 |
+
$opt['SerialNumber'] = $serial_number;
|
618 |
+
$opt['AuthenticationCode1'] = $authentication_code1;
|
619 |
+
$opt['AuthenticationCode2'] = $authentication_code2;
|
620 |
+
|
621 |
+
return $this->authenticate('EnableMFADevice', $opt, $this->hostname);
|
622 |
+
}
|
623 |
+
|
624 |
+
/**
|
625 |
+
*
|
626 |
+
* Lists the names of the policies associated with the specified User. If there are none, the action returns an empty list.
|
627 |
+
*
|
628 |
+
* You can paginate the results using the <code>MaxItems</code> and <code>Marker</code> parameters.
|
629 |
+
*
|
630 |
+
* @param string $user_name (Required) The name of the User to list policies for.
|
631 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
632 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - Use this only when paginating results, and only in a subsequent request after you've received a response where the results are truncated. Set it to the value of the <code>Marker</code> element in the response you just received. </li>
|
633 |
+
* <li><code>MaxItems</code> - <code>integer</code> - Optional - Use this only when paginating results to indicate the maximum number of policy names you want in the response. If there are additional policy names beyond the maximum you specify, the <code>IsTruncated</code> response element is <code>true</code>. </li>
|
634 |
+
* <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>
|
635 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
636 |
+
*/
|
637 |
+
public function list_user_policies($user_name, $opt = null)
|
638 |
+
{
|
639 |
+
if (!$opt) $opt = array();
|
640 |
+
$opt['UserName'] = $user_name;
|
641 |
+
|
642 |
+
return $this->authenticate('ListUserPolicies', $opt, $this->hostname);
|
643 |
+
}
|
644 |
+
|
645 |
+
/**
|
646 |
+
*
|
647 |
+
* Returns information about the Access Key IDs associated with the specified User. If there are none, the action returns
|
648 |
+
* an empty list.
|
649 |
+
*
|
650 |
+
* Although each User is limited to a small number of keys, you can still paginate the results using the
|
651 |
+
* <code>MaxItems</code> and <code>Marker</code> parameters.
|
652 |
+
*
|
653 |
+
* If the <code>UserName</code> field is not specified, the UserName is determined implicitly based on the AWS Access Key
|
654 |
+
* ID used to sign the request. Because this action works for access keys under the AWS Account, this API can be used to
|
655 |
+
* manage root credentials even if the AWS Account has no associated Users.
|
656 |
+
*
|
657 |
+
* To ensure the security of your AWS Account, the secret access key is accessible only during key and User creation.
|
658 |
+
*
|
659 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
660 |
+
* <li><code>UserName</code> - <code>string</code> - Optional - Name of the User. </li>
|
661 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - Use this only when paginating results, and only in a subsequent request after you've received a response where the results are truncated. Set it to the value of the <code>Marker</code> element in the response you just received. </li>
|
662 |
+
* <li><code>MaxItems</code> - <code>integer</code> - Optional - Use this only when paginating results to indicate the maximum number of keys you want in the response. If there are additional keys beyond the maximum you specify, the <code>IsTruncated</code> response element is <code>true</code>. </li>
|
663 |
+
* <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>
|
664 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
665 |
+
*/
|
666 |
+
public function list_access_keys($opt = null)
|
667 |
+
{
|
668 |
+
if (!$opt) $opt = array();
|
669 |
+
|
670 |
+
return $this->authenticate('ListAccessKeys', $opt, $this->hostname);
|
671 |
+
}
|
672 |
+
|
673 |
+
/**
|
674 |
+
*
|
675 |
+
* Retrieves the login profile for the specified User.
|
676 |
+
*
|
677 |
+
* In the full release you will be able to use IAM to access your services through the AWS Management Console. Although
|
678 |
+
* this feature is not currently available, you can create login profiles for your Users now. Then, when this feature is
|
679 |
+
* implemented, your Users can use IAM to access your services through the AWS Management Console.
|
680 |
+
*
|
681 |
+
* @param string $user_name (Required) Name of the User whose login profile you want to retrieve.
|
682 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
683 |
+
* <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>
|
684 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
685 |
+
*/
|
686 |
+
public function get_login_profile($user_name, $opt = null)
|
687 |
+
{
|
688 |
+
if (!$opt) $opt = array();
|
689 |
+
$opt['UserName'] = $user_name;
|
690 |
+
|
691 |
+
return $this->authenticate('GetLoginProfile', $opt, $this->hostname);
|
692 |
+
}
|
693 |
+
|
694 |
+
/**
|
695 |
+
*
|
696 |
+
* Lists the groups the specified User belongs to.
|
697 |
+
*
|
698 |
+
* You can paginate the results using the <code>MaxItems</code> and <code>Marker</code> parameters.
|
699 |
+
*
|
700 |
+
* @param string $user_name (Required) The name of the User to list groups for.
|
701 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
702 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - Use this only when paginating results, and only in a subsequent request after you've received a response where the results are truncated. Set it to the value of the <code>Marker</code> element in the response you just received. </li>
|
703 |
+
* <li><code>MaxItems</code> - <code>integer</code> - Optional - Use this only when paginating results to indicate the maximum number of groups you want in the response. If there are additional groups beyond the maximum you specify, the <code>IsTruncated</code> response element is <code>true</code>. </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 list_groups_for_user($user_name, $opt = null)
|
708 |
+
{
|
709 |
+
if (!$opt) $opt = array();
|
710 |
+
$opt['UserName'] = $user_name;
|
711 |
+
|
712 |
+
return $this->authenticate('ListGroupsForUser', $opt, $this->hostname);
|
713 |
+
}
|
714 |
+
|
715 |
+
/**
|
716 |
+
*
|
717 |
+
* Creates a new group.
|
718 |
+
*
|
719 |
+
* For information about the number of groups you can create, see <a
|
720 |
+
* href="http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?LimitationsOnEntities.html">Limitations on IAM
|
721 |
+
* Entities</a> in <i>Using AWS Identity and Access Management</i>.
|
722 |
+
*
|
723 |
+
* @param string $group_name (Required) Name of the group to create. Do not include the path in this value.
|
724 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
725 |
+
* <li><code>Path</code> - <code>string</code> - Optional - The path to the group. For more information about paths, see Identifiers for IAM Entities in <i>Using AWS Identity and Access Management</i>. This parameter is optional. If it is not included, it defaults to a slash (/). </li>
|
726 |
+
* <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>
|
727 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
728 |
+
*/
|
729 |
+
public function create_group($group_name, $opt = null)
|
730 |
+
{
|
731 |
+
if (!$opt) $opt = array();
|
732 |
+
$opt['GroupName'] = $group_name;
|
733 |
+
|
734 |
+
return $this->authenticate('CreateGroup', $opt, $this->hostname);
|
735 |
+
}
|
736 |
+
|
737 |
+
/**
|
738 |
+
*
|
739 |
+
* Uploads a server certificate entity for the AWS Account. The server certificate entity includes a public key
|
740 |
+
* certificate, a private key, and an optional certificate chain, which should all be PEM-encoded.
|
741 |
+
*
|
742 |
+
* For information about the number of server certificates you can upload, see <a
|
743 |
+
* href="http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?LimitationsOnEntities.html">Limitations on IAM
|
744 |
+
* Entities</a> in <i>Using AWS Identity and Access Management</i>.
|
745 |
+
*
|
746 |
+
* Because the body of the public key certificate, private key, and the certificate chain can be large, you should use POST
|
747 |
+
* rather than GET when calling <code>UploadServerCertificate</code>. For more information, see <a
|
748 |
+
* href="http://docs.amazonwebservices.com/IAM/latest/UserGuide/IAM_UsingQueryAPI.html">Making Query Requests</a> in
|
749 |
+
* <i>Using AWS Identity and Access Management</i>.
|
750 |
+
*
|
751 |
+
* @param string $server_certificate_name (Required) The name for the server certificate. Do not include the path in this value.
|
752 |
+
* @param string $certificate_body (Required) The contents of the public key certificate in PEM-encoded format.
|
753 |
+
* @param string $private_key (Required) The contents of the private key in PEM-encoded format.
|
754 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
755 |
+
* <li><code>Path</code> - <code>string</code> - Optional - The path for the server certificate. For more information about paths, see Identifiers for IAM Entities in <i>Using AWS Identity and Access Management</i>. This parameter is optional. If it is not included, it defaults to a slash (/). </li>
|
756 |
+
* <li><code>CertificateChain</code> - <code>string</code> - Optional - The contents of the certificate chain. This is typically a concatenation of the PEM-encoded public key certificates of the chain. </li>
|
757 |
+
* <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>
|
758 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
759 |
+
*/
|
760 |
+
public function upload_server_certificate($server_certificate_name, $certificate_body, $private_key, $opt = null)
|
761 |
+
{
|
762 |
+
if (!$opt) $opt = array();
|
763 |
+
$opt['ServerCertificateName'] = $server_certificate_name;
|
764 |
+
$opt['CertificateBody'] = $certificate_body;
|
765 |
+
$opt['PrivateKey'] = $private_key;
|
766 |
+
|
767 |
+
return $this->authenticate('UploadServerCertificate', $opt, $this->hostname);
|
768 |
+
}
|
769 |
+
|
770 |
+
/**
|
771 |
+
*
|
772 |
+
* Creates an account alias.
|
773 |
+
*
|
774 |
+
* @param string $account_alias (Required) Name of the account alias to create
|
775 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
776 |
+
* <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>
|
777 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
778 |
+
*/
|
779 |
+
public function create_account_alias($account_alias, $opt = null)
|
780 |
+
{
|
781 |
+
if (!$opt) $opt = array();
|
782 |
+
$opt['AccountAlias'] = $account_alias;
|
783 |
+
|
784 |
+
return $this->authenticate('CreateAccountAlias', $opt, $this->hostname);
|
785 |
+
}
|
786 |
+
|
787 |
+
/**
|
788 |
+
*
|
789 |
+
* Retrieves the specified policy document for the specified group. The returned policy is URL-encoded according to RFC
|
790 |
+
* 3986. For more information about RFC 3986, go to <a
|
791 |
+
* href="http://www.faqs.org/rfcs/rfc3986.html">http://www.faqs.org/rfcs/rfc3986.html</a>.
|
792 |
+
*
|
793 |
+
* @param string $group_name (Required) Name of the group the policy is associated with.
|
794 |
+
* @param string $policy_name (Required) Name of the policy document to get.
|
795 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
796 |
+
* <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>
|
797 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
798 |
+
*/
|
799 |
+
public function get_group_policy($group_name, $policy_name, $opt = null)
|
800 |
+
{
|
801 |
+
if (!$opt) $opt = array();
|
802 |
+
$opt['GroupName'] = $group_name;
|
803 |
+
$opt['PolicyName'] = $policy_name;
|
804 |
+
|
805 |
+
return $this->authenticate('GetGroupPolicy', $opt, $this->hostname);
|
806 |
+
}
|
807 |
+
|
808 |
+
/**
|
809 |
+
*
|
810 |
+
* Deletes the specified User. The User must not belong to any groups, have any keys or signing certificates, or have any
|
811 |
+
* attached policies.
|
812 |
+
*
|
813 |
+
* @param string $user_name (Required) Name of the User to delete.
|
814 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
815 |
+
* <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>
|
816 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
817 |
+
*/
|
818 |
+
public function delete_user($user_name, $opt = null)
|
819 |
+
{
|
820 |
+
if (!$opt) $opt = array();
|
821 |
+
$opt['UserName'] = $user_name;
|
822 |
+
|
823 |
+
return $this->authenticate('DeleteUser', $opt, $this->hostname);
|
824 |
+
}
|
825 |
+
|
826 |
+
/**
|
827 |
+
*
|
828 |
+
* Deactivates the specified MFA device and removes it from association with the User name for which it was originally
|
829 |
+
* enabled.
|
830 |
+
*
|
831 |
+
* @param string $user_name (Required) Name of the User whose MFA device you want to deactivate.
|
832 |
+
* @param string $serial_number (Required) The serial number that uniquely identifies the MFA device.
|
833 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
834 |
+
* <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>
|
835 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
836 |
+
*/
|
837 |
+
public function deactivate_mfa_device($user_name, $serial_number, $opt = null)
|
838 |
+
{
|
839 |
+
if (!$opt) $opt = array();
|
840 |
+
$opt['UserName'] = $user_name;
|
841 |
+
$opt['SerialNumber'] = $serial_number;
|
842 |
+
|
843 |
+
return $this->authenticate('DeactivateMFADevice', $opt, $this->hostname);
|
844 |
+
}
|
845 |
+
|
846 |
+
/**
|
847 |
+
*
|
848 |
+
* Removes the specified User from the specified group.
|
849 |
+
*
|
850 |
+
* @param string $group_name (Required) Name of the group to update.
|
851 |
+
* @param string $user_name (Required) Name of the User to remove.
|
852 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
853 |
+
* <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>
|
854 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
855 |
+
*/
|
856 |
+
public function remove_user_from_group($group_name, $user_name, $opt = null)
|
857 |
+
{
|
858 |
+
if (!$opt) $opt = array();
|
859 |
+
$opt['GroupName'] = $group_name;
|
860 |
+
$opt['UserName'] = $user_name;
|
861 |
+
|
862 |
+
return $this->authenticate('RemoveUserFromGroup', $opt, $this->hostname);
|
863 |
+
}
|
864 |
+
|
865 |
+
/**
|
866 |
+
*
|
867 |
+
* Deletes the specified server certificate.
|
868 |
+
*
|
869 |
+
* If your Elastic Load Balancing instances are using a server certificate, deleting the certificate could have
|
870 |
+
* implications for your application. If your Elastic Load Balancing instances do not detect the deletion of bound
|
871 |
+
* certificates, they may continue to use the certificates. This could cause them to stop accepting traffic. We recommend
|
872 |
+
* that you remove the reference to the certificate from your Elastic Load Balancing instances before using this command to
|
873 |
+
* delete the certificate.
|
874 |
+
*
|
875 |
+
* @param string $server_certificate_name (Required) The name of the server certificate you want to delete.
|
876 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
877 |
+
* <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>
|
878 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
879 |
+
*/
|
880 |
+
public function delete_server_certificate($server_certificate_name, $opt = null)
|
881 |
+
{
|
882 |
+
if (!$opt) $opt = array();
|
883 |
+
$opt['ServerCertificateName'] = $server_certificate_name;
|
884 |
+
|
885 |
+
return $this->authenticate('DeleteServerCertificate', $opt, $this->hostname);
|
886 |
+
}
|
887 |
+
|
888 |
+
/**
|
889 |
+
*
|
890 |
+
* Lists the names of the policies associated with the specified group. If there are none, the action returns an empty
|
891 |
+
* list.
|
892 |
+
*
|
893 |
+
* You can paginate the results using the <code>MaxItems</code> and <code>Marker</code> parameters.
|
894 |
+
*
|
895 |
+
* @param string $group_name (Required) The name of the group to list policies for.
|
896 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
897 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - Use this only when paginating results, and only in a subsequent request after you've received a response where the results are truncated. Set it to the value of the <code>Marker</code> element in the response you just received. </li>
|
898 |
+
* <li><code>MaxItems</code> - <code>integer</code> - Optional - Use this only when paginating results to indicate the maximum number of policy names you want in the response. If there are additional policy names beyond the maximum you specify, the <code>IsTruncated</code> response element is <code>true</code>. </li>
|
899 |
+
* <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>
|
900 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
901 |
+
*/
|
902 |
+
public function list_group_policies($group_name, $opt = null)
|
903 |
+
{
|
904 |
+
if (!$opt) $opt = array();
|
905 |
+
$opt['GroupName'] = $group_name;
|
906 |
+
|
907 |
+
return $this->authenticate('ListGroupPolicies', $opt, $this->hostname);
|
908 |
+
}
|
909 |
+
|
910 |
+
/**
|
911 |
+
*
|
912 |
+
* Creates a login profile for the specified User, giving the User the ability to access AWS services such as the AWS
|
913 |
+
* Management Console. For more information about login profiles, see <a
|
914 |
+
* href="http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?Using_ManagingLoginsAndMFA.html">Managing Login
|
915 |
+
* Profiles and MFA Devices</a> in <i>Using AWS Identity and Access Management</i>.
|
916 |
+
*
|
917 |
+
* In the full release you will be able to use IAM to access your services through the AWS Management Console. Although
|
918 |
+
* this feature is not currently available, you can create login profiles for your Users now. Then, when this feature is
|
919 |
+
* implemented, your Users can use IAM to access your services through the AWS Management Console.
|
920 |
+
*
|
921 |
+
* @param string $user_name (Required) Name of the User to create a login profile for.
|
922 |
+
* @param string $password (Required) The new password for the User name.
|
923 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
924 |
+
* <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>
|
925 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
926 |
+
*/
|
927 |
+
public function create_login_profile($user_name, $password, $opt = null)
|
928 |
+
{
|
929 |
+
if (!$opt) $opt = array();
|
930 |
+
$opt['UserName'] = $user_name;
|
931 |
+
$opt['Password'] = $password;
|
932 |
+
|
933 |
+
return $this->authenticate('CreateLoginProfile', $opt, $this->hostname);
|
934 |
+
}
|
935 |
+
|
936 |
+
/**
|
937 |
+
*
|
938 |
+
* Creates a new AWS Secret Access Key and corresponding AWS Access Key ID for the specified User. The default status for
|
939 |
+
* new keys is <code>Active</code>.
|
940 |
+
*
|
941 |
+
* If you do not specify a User name, IAM determines the User name implicitly based on the AWS Access Key ID signing the
|
942 |
+
* request. Because this action works for access keys under the AWS Account, you can use this API to manage root
|
943 |
+
* credentials even if the AWS Account has no associated Users.
|
944 |
+
*
|
945 |
+
* For information about limits on the number of keys you can create, see <a
|
946 |
+
* href="http://docs.amazonwebservices.com/IAM/2010-05-08/UserGuide/index.html?LimitationsOnEntities.html">Limitations on
|
947 |
+
* IAM Entities</a> in <i>Using AWS Identity and Access Management</i>.
|
948 |
+
*
|
949 |
+
* To ensure the security of your AWS Account, the Secret Access Key is accessible only during key and User creation. You
|
950 |
+
* must save the key (for example, in a text file) if you want to be able to access it again. If a secret key is lost, you
|
951 |
+
* can delete the access keys for the associated User and then create new keys.
|
952 |
+
*
|
953 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
954 |
+
* <li><code>UserName</code> - <code>string</code> - Optional - The User name that the new key will belong to. </li>
|
955 |
+
* <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>
|
956 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
957 |
+
*/
|
958 |
+
public function create_access_key($opt = null)
|
959 |
+
{
|
960 |
+
if (!$opt) $opt = array();
|
961 |
+
|
962 |
+
return $this->authenticate('CreateAccessKey', $opt, $this->hostname);
|
963 |
+
}
|
964 |
+
|
965 |
+
/**
|
966 |
+
*
|
967 |
+
* Retrieves information about the specified User, including the User's path, GUID, and ARN.
|
968 |
+
*
|
969 |
+
* If you do not specify a User name, IAM determines the User name implicitly based on the AWS Access Key ID signing the
|
970 |
+
* request.
|
971 |
+
*
|
972 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
973 |
+
* <li><code>UserName</code> - <code>string</code> - Optional - Name of the User to get information about. This parameter is optional. If it is not included, it defaults to the User making the request. </li>
|
974 |
+
* <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>
|
975 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
976 |
+
*/
|
977 |
+
public function get_user($opt = null)
|
978 |
+
{
|
979 |
+
if (!$opt) $opt = array();
|
980 |
+
|
981 |
+
return $this->authenticate('GetUser', $opt, $this->hostname);
|
982 |
+
}
|
983 |
+
|
984 |
+
/**
|
985 |
+
*
|
986 |
+
* Synchronizes the specified MFA device with AWS servers.
|
987 |
+
*
|
988 |
+
* @param string $user_name (Required) Name of the User whose MFA device you want to resynchronize.
|
989 |
+
* @param string $serial_number (Required) Serial number that uniquely identifies the MFA device.
|
990 |
+
* @param string $authentication_code1 (Required) An authentication code emitted by the device.
|
991 |
+
* @param string $authentication_code2 (Required) A subsequent authentication code emitted by the device.
|
992 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
993 |
+
* <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>
|
994 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
995 |
+
*/
|
996 |
+
public function resync_mfa_device($user_name, $serial_number, $authentication_code1, $authentication_code2, $opt = null)
|
997 |
+
{
|
998 |
+
if (!$opt) $opt = array();
|
999 |
+
$opt['UserName'] = $user_name;
|
1000 |
+
$opt['SerialNumber'] = $serial_number;
|
1001 |
+
$opt['AuthenticationCode1'] = $authentication_code1;
|
1002 |
+
$opt['AuthenticationCode2'] = $authentication_code2;
|
1003 |
+
|
1004 |
+
return $this->authenticate('ResyncMFADevice', $opt, $this->hostname);
|
1005 |
+
}
|
1006 |
+
|
1007 |
+
/**
|
1008 |
+
*
|
1009 |
+
* Lists the MFA devices associated with the specified User name.
|
1010 |
+
*
|
1011 |
+
* You can paginate the results using the <code>MaxItems</code> and <code>Marker</code> parameters.
|
1012 |
+
*
|
1013 |
+
* @param string $user_name (Required) Name of the User whose MFA devices you want to list.
|
1014 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1015 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - Use this only when paginating results, and only in a subsequent request after you've received a response where the results are truncated. Set it to the value of the <code>Marker</code> element in the response you just received. </li>
|
1016 |
+
* <li><code>MaxItems</code> - <code>integer</code> - Optional - Use this only when paginating results to indicate the maximum number of keys you want in the response. If there are additional keys beyond the maximum you specify, the <code>IsTruncated</code> response element is <code>true</code>. </li>
|
1017 |
+
* <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>
|
1018 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1019 |
+
*/
|
1020 |
+
public function list_mfa_devices($user_name, $opt = null)
|
1021 |
+
{
|
1022 |
+
if (!$opt) $opt = array();
|
1023 |
+
$opt['UserName'] = $user_name;
|
1024 |
+
|
1025 |
+
return $this->authenticate('ListMFADevices', $opt, $this->hostname);
|
1026 |
+
}
|
1027 |
+
|
1028 |
+
/**
|
1029 |
+
*
|
1030 |
+
* Changes the status of the specified access key from Active to Inactive, or vice versa. This action can be used to
|
1031 |
+
* disable a User's key as part of a key rotation workflow.
|
1032 |
+
*
|
1033 |
+
* If the <code>UserName</code> field is not specified, the UserName is determined implicitly based on the AWS Access Key
|
1034 |
+
* ID used to sign the request. Because this action works for access keys under the AWS Account, this API can be used to
|
1035 |
+
* manage root credentials even if the AWS Account has no associated Users.
|
1036 |
+
*
|
1037 |
+
* For information about rotating keys, see <a
|
1038 |
+
* href="http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?ManagingCredentials.html">Managing Keys and
|
1039 |
+
* Certificates</a> in <i>Using AWS Identity and Access Management</i>.
|
1040 |
+
*
|
1041 |
+
* @param string $access_key_id (Required) The Access Key ID of the Secret Access Key you want to update.
|
1042 |
+
* @param string $status (Required) The status you want to assign to the Secret Access Key. <code>Active</code> means the key can be used for API calls to AWS, while <code>Inactive</code> means the key cannot be used. [Allowed values: <code>Active</code>, <code>Inactive</code>]
|
1043 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1044 |
+
* <li><code>UserName</code> - <code>string</code> - Optional - Name of the User whose key you want to update. </li>
|
1045 |
+
* <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>
|
1046 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1047 |
+
*/
|
1048 |
+
public function update_access_key($access_key_id, $status, $opt = null)
|
1049 |
+
{
|
1050 |
+
if (!$opt) $opt = array();
|
1051 |
+
$opt['AccessKeyId'] = $access_key_id;
|
1052 |
+
$opt['Status'] = $status;
|
1053 |
+
|
1054 |
+
return $this->authenticate('UpdateAccessKey', $opt, $this->hostname);
|
1055 |
+
}
|
1056 |
+
|
1057 |
+
/**
|
1058 |
+
*
|
1059 |
+
* Retrieves account level information about usage and quota.
|
1060 |
+
*
|
1061 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1062 |
+
* <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>
|
1063 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1064 |
+
*/
|
1065 |
+
public function get_account_summary($opt = null)
|
1066 |
+
{
|
1067 |
+
if (!$opt) $opt = array();
|
1068 |
+
|
1069 |
+
return $this->authenticate('GetAccountSummary', $opt, $this->hostname);
|
1070 |
+
}
|
1071 |
+
|
1072 |
+
/**
|
1073 |
+
*
|
1074 |
+
* Adds the specified User to the specified group.
|
1075 |
+
*
|
1076 |
+
* @param string $group_name (Required) Name of the group to update.
|
1077 |
+
* @param string $user_name (Required) Name of the User to add.
|
1078 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1079 |
+
* <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>
|
1080 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1081 |
+
*/
|
1082 |
+
public function add_user_to_group($group_name, $user_name, $opt = null)
|
1083 |
+
{
|
1084 |
+
if (!$opt) $opt = array();
|
1085 |
+
$opt['GroupName'] = $group_name;
|
1086 |
+
$opt['UserName'] = $user_name;
|
1087 |
+
|
1088 |
+
return $this->authenticate('AddUserToGroup', $opt, $this->hostname);
|
1089 |
+
}
|
1090 |
+
|
1091 |
+
/**
|
1092 |
+
*
|
1093 |
+
* Returns a list of Users that are in the specified group. You can paginate the results using the <code>MaxItems</code>
|
1094 |
+
* and <code>Marker</code> parameters.
|
1095 |
+
*
|
1096 |
+
* @param string $group_name (Required) Name of the group.
|
1097 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1098 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - Use this only when paginating results, and only in a subsequent request after you've received a response where the results are truncated. Set it to the value of the <code>Marker</code> element in the response you just received. </li>
|
1099 |
+
* <li><code>MaxItems</code> - <code>integer</code> - Optional - Use this only when paginating results to indicate the maximum number of User names you want in the response. If there are additional User names beyond the maximum you specify, the <code>IsTruncated</code> response element is <code>true</code>. </li>
|
1100 |
+
* <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>
|
1101 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1102 |
+
*/
|
1103 |
+
public function get_group($group_name, $opt = null)
|
1104 |
+
{
|
1105 |
+
if (!$opt) $opt = array();
|
1106 |
+
$opt['GroupName'] = $group_name;
|
1107 |
+
|
1108 |
+
return $this->authenticate('GetGroup', $opt, $this->hostname);
|
1109 |
+
}
|
1110 |
+
|
1111 |
+
/**
|
1112 |
+
*
|
1113 |
+
* Lists the account aliases associated with the account.
|
1114 |
+
*
|
1115 |
+
* You can paginate the results using the <code>MaxItems</code> and <code>Marker</code> parameters.
|
1116 |
+
*
|
1117 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1118 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - Use this only when paginating results, and only in a subsequent request after you've received a response where the results are truncated. Set it to the value of the <code>Marker</code> element in the response you just received. </li>
|
1119 |
+
* <li><code>MaxItems</code> - <code>integer</code> - Optional - Use this only when paginating results to indicate the maximum number of account aliases you want in the response. If there are additional account aliases beyond the maximum you specify, the <code>IsTruncated</code> response element is <code>true</code>. </li>
|
1120 |
+
* <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>
|
1121 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1122 |
+
*/
|
1123 |
+
public function list_account_aliases($opt = null)
|
1124 |
+
{
|
1125 |
+
if (!$opt) $opt = array();
|
1126 |
+
|
1127 |
+
return $this->authenticate('ListAccountAliases', $opt, $this->hostname);
|
1128 |
+
}
|
1129 |
+
|
1130 |
+
/**
|
1131 |
+
*
|
1132 |
+
* Deletes the specified group. The group must not contain any Users or have any attached policies.
|
1133 |
+
*
|
1134 |
+
* @param string $group_name (Required) Name of the group to delete.
|
1135 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1136 |
+
* <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>
|
1137 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1138 |
+
*/
|
1139 |
+
public function delete_group($group_name, $opt = null)
|
1140 |
+
{
|
1141 |
+
if (!$opt) $opt = array();
|
1142 |
+
$opt['GroupName'] = $group_name;
|
1143 |
+
|
1144 |
+
return $this->authenticate('DeleteGroup', $opt, $this->hostname);
|
1145 |
+
}
|
1146 |
+
}
|
1147 |
+
|
1148 |
+
|
1149 |
+
/*%******************************************************************************************%*/
|
1150 |
+
// EXCEPTIONS
|
1151 |
+
|
1152 |
+
/**
|
1153 |
+
* Default IAM Exception.
|
1154 |
+
*/
|
1155 |
+
class IAM_Exception extends Exception {}
|
app/libs/aws/services/importexport.class.php
ADDED
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
*
|
20 |
+
* AWS Import/Export accelerates transferring large amounts of data between the AWS cloud and portable storage devices
|
21 |
+
* that you mail to us. AWS Import/Export transfers data directly onto and off of your storage devices using Amazon's
|
22 |
+
* high-speed internal network and bypassing the Internet. For large data sets, AWS Import/Export is often faster than
|
23 |
+
* Internet transfer and more cost effective than upgrading your connectivity.
|
24 |
+
*
|
25 |
+
* @version Wed Feb 16 17:08:43 PST 2011
|
26 |
+
* @license See the included NOTICE.md file for complete information.
|
27 |
+
* @copyright See the included NOTICE.md file for complete information.
|
28 |
+
* @link http://aws.amazon.com/importexport/Amazon Import/Export Service
|
29 |
+
* @link http://aws.amazon.com/documentation/importexport/Amazon Import/Export Service documentation
|
30 |
+
*/
|
31 |
+
class AmazonImportExport extends CFRuntime
|
32 |
+
{
|
33 |
+
|
34 |
+
/*%******************************************************************************************%*/
|
35 |
+
// CLASS CONSTANTS
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Specify the default queue URL.
|
39 |
+
*/
|
40 |
+
const DEFAULT_URL = 'importexport.amazonaws.com';
|
41 |
+
|
42 |
+
|
43 |
+
|
44 |
+
/*%******************************************************************************************%*/
|
45 |
+
// CONSTRUCTOR
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Constructs a new instance of <AmazonImportExport>.
|
49 |
+
*
|
50 |
+
* @param string $key (Optional) Your Amazon API Key. If blank, it will look for the <code>AWS_KEY</code> constant.
|
51 |
+
* @param string $secret_key (Optional) Your Amazon API Secret Key. If blank, it will look for the <code>AWS_SECRET_KEY</code> constant.
|
52 |
+
* @return boolean false if no valid values are set, otherwise true.
|
53 |
+
*/
|
54 |
+
public function __construct($key = null, $secret_key = null)
|
55 |
+
{
|
56 |
+
$this->api_version = '2010-06-01';
|
57 |
+
$this->hostname = self::DEFAULT_URL;
|
58 |
+
|
59 |
+
if (!$key && !defined('AWS_KEY'))
|
60 |
+
{
|
61 |
+
throw new ImportExport_Exception('No account key was passed into the constructor, nor was it set in the AWS_KEY constant.');
|
62 |
+
}
|
63 |
+
|
64 |
+
if (!$secret_key && !defined('AWS_SECRET_KEY'))
|
65 |
+
{
|
66 |
+
throw new ImportExport_Exception('No account secret was passed into the constructor, nor was it set in the AWS_SECRET_KEY constant.');
|
67 |
+
}
|
68 |
+
|
69 |
+
return parent::__construct($key, $secret_key);
|
70 |
+
}
|
71 |
+
|
72 |
+
|
73 |
+
/*%******************************************************************************************%*/
|
74 |
+
// SERVICE METHODS
|
75 |
+
|
76 |
+
/**
|
77 |
+
*
|
78 |
+
* This operation initiates the process of scheduling an upload or download of your data. You include in the request a
|
79 |
+
* manifest that describes the data transfer specifics. The response to the request includes a job ID, which you can use in
|
80 |
+
* other operations, a signature that you use to identify your storage device, and the address where you should ship your
|
81 |
+
* storage device.
|
82 |
+
*
|
83 |
+
* @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>]
|
84 |
+
* @param string $manifest (Required) The UTF-8 encoded text of the manifest file.
|
85 |
+
* @param boolean $validate_only (Required) Validate the manifest and parameter values in the request but do not actually create a job.
|
86 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
87 |
+
* <li><code>ManifestAddendum</code> - <code>string</code> - Optional - For internal use only. </li>
|
88 |
+
* <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>
|
89 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
90 |
+
*/
|
91 |
+
public function create_job($job_type, $manifest, $validate_only, $opt = null)
|
92 |
+
{
|
93 |
+
if (!$opt) $opt = array();
|
94 |
+
$opt['JobType'] = $job_type;
|
95 |
+
$opt['Manifest'] = $manifest;
|
96 |
+
$opt['ValidateOnly'] = $validate_only;
|
97 |
+
|
98 |
+
return $this->authenticate('CreateJob', $opt, $this->hostname);
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
*
|
103 |
+
* This operation cancels a specified job. Only the job owner can cancel it. The operation fails if the job has already
|
104 |
+
* started or is complete.
|
105 |
+
*
|
106 |
+
* @param string $job_id (Required) A unique identifier which refers to a particular job.
|
107 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
108 |
+
* <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>
|
109 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
110 |
+
*/
|
111 |
+
public function cancel_job($job_id, $opt = null)
|
112 |
+
{
|
113 |
+
if (!$opt) $opt = array();
|
114 |
+
$opt['JobId'] = $job_id;
|
115 |
+
|
116 |
+
return $this->authenticate('CancelJob', $opt, $this->hostname);
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
*
|
121 |
+
* This operation returns information about a job, including where the job is in the processing pipeline, the status of
|
122 |
+
* the results, and the signature value associated with the job. You can only return information about jobs you own.
|
123 |
+
*
|
124 |
+
* @param string $job_id (Required) A unique identifier which refers to a particular job.
|
125 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
126 |
+
* <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>
|
127 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
128 |
+
*/
|
129 |
+
public function get_status($job_id, $opt = null)
|
130 |
+
{
|
131 |
+
if (!$opt) $opt = array();
|
132 |
+
$opt['JobId'] = $job_id;
|
133 |
+
|
134 |
+
return $this->authenticate('GetStatus', $opt, $this->hostname);
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
*
|
139 |
+
* This operation returns the jobs associated with the requester. AWS Import/Export lists the jobs in reverse
|
140 |
+
* chronological order based on the date of creation. For example if Job Test1 was created 2009Dec30 and Test2 was created
|
141 |
+
* 2010Feb05, the ListJobs operation would return Test2 followed by Test1.
|
142 |
+
*
|
143 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
144 |
+
* <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>
|
145 |
+
* <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>
|
146 |
+
* <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>
|
147 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
148 |
+
*/
|
149 |
+
public function list_jobs($opt = null)
|
150 |
+
{
|
151 |
+
if (!$opt) $opt = array();
|
152 |
+
|
153 |
+
return $this->authenticate('ListJobs', $opt, $this->hostname);
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
*
|
158 |
+
* You use this operation to change the parameters specified in the original manifest file by supplying a new manifest
|
159 |
+
* file. The manifest file attached to this request replaces the original manifest file. You can only use the operation
|
160 |
+
* after a CreateJob request but before the data transfer starts and you can only use it on jobs you own.
|
161 |
+
*
|
162 |
+
* @param string $job_id (Required) A unique identifier which refers to a particular job.
|
163 |
+
* @param string $manifest (Required) The UTF-8 encoded text of the manifest file.
|
164 |
+
* @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>]
|
165 |
+
* @param boolean $validate_only (Required) Validate the manifest and parameter values in the request but do not actually create a job.
|
166 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
167 |
+
* <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>
|
168 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
169 |
+
*/
|
170 |
+
public function update_job($job_id, $manifest, $job_type, $validate_only, $opt = null)
|
171 |
+
{
|
172 |
+
if (!$opt) $opt = array();
|
173 |
+
$opt['JobId'] = $job_id;
|
174 |
+
$opt['Manifest'] = $manifest;
|
175 |
+
$opt['JobType'] = $job_type;
|
176 |
+
$opt['ValidateOnly'] = $validate_only;
|
177 |
+
|
178 |
+
return $this->authenticate('UpdateJob', $opt, $this->hostname);
|
179 |
+
}
|
180 |
+
}
|
181 |
+
|
182 |
+
|
183 |
+
/*%******************************************************************************************%*/
|
184 |
+
// EXCEPTIONS
|
185 |
+
|
186 |
+
/**
|
187 |
+
* Default ImportExport Exception.
|
188 |
+
*/
|
189 |
+
class ImportExport_Exception extends Exception {}
|
app/libs/aws/services/rds.class.php
ADDED
@@ -0,0 +1,831 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
*
|
20 |
+
* Amazon Relational Database Service (Amazon RDS) is a web service that makes it easier to set up, operate, and scale a
|
21 |
+
* relational database in the cloud. It provides cost-efficient, resizable capacity for an industry-standard relational
|
22 |
+
* database and manages common database administration tasks, freeing up developers to focus on what makes their
|
23 |
+
* applications and businesses unique.
|
24 |
+
*
|
25 |
+
* Amazon RDS gives you access to the capabilities of a familiar MySQL database server. This means the code, applications,
|
26 |
+
* and tools you already use today with your existing MySQL databases work with Amazon RDS without modification. Amazon RDS
|
27 |
+
* automatically backs up your database and maintains the database software that powers your DB Instance. Amazon RDS is
|
28 |
+
* flexible: you can scale your database instance's compute resources and storage capacity to meet your application's
|
29 |
+
* demand. As with all Amazon Web Services, there are no up-front investments, and you pay only for the resources you use.
|
30 |
+
*
|
31 |
+
* @version Wed Feb 16 17:09:20 PST 2011
|
32 |
+
* @license See the included NOTICE.md file for complete information.
|
33 |
+
* @copyright See the included NOTICE.md file for complete information.
|
34 |
+
* @link http://aws.amazon.com/rds/Amazon Relational Database Service
|
35 |
+
* @link http://aws.amazon.com/documentation/rds/Amazon Relational Database Service documentation
|
36 |
+
*/
|
37 |
+
class AmazonRDS extends CFRuntime
|
38 |
+
{
|
39 |
+
|
40 |
+
/*%******************************************************************************************%*/
|
41 |
+
// CLASS CONSTANTS
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Specify the default queue URL.
|
45 |
+
*/
|
46 |
+
const DEFAULT_URL = 'rds.us-east-1.amazonaws.com';
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Specify the queue URL for the US-East (Northern Virginia) Region.
|
50 |
+
*/
|
51 |
+
const REGION_US_E1 = self::DEFAULT_URL;
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Specify the queue URL for the US-West (Northern California) Region.
|
55 |
+
*/
|
56 |
+
const REGION_US_W1 = 'rds.us-west-1.amazonaws.com';
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Specify the queue URL for the EU (Ireland) Region.
|
60 |
+
*/
|
61 |
+
const REGION_EU_W1 = 'rds.eu-west-1.amazonaws.com';
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Specify the queue URL for the Asia Pacific (Singapore) Region.
|
65 |
+
*/
|
66 |
+
const REGION_APAC_SE1 = 'rds.ap-southeast-1.amazonaws.com';
|
67 |
+
|
68 |
+
|
69 |
+
/*%******************************************************************************************%*/
|
70 |
+
// SETTERS
|
71 |
+
|
72 |
+
/**
|
73 |
+
* This allows you to explicitly sets the region for the service to use.
|
74 |
+
*
|
75 |
+
* @param string $region (Required) The region to explicitly set. Available options are <REGION_US_E1>, <REGION_US_W1>, <REGION_EU_W1>, or <REGION_APAC_SE1>.
|
76 |
+
* @return $this A reference to the current instance.
|
77 |
+
*/
|
78 |
+
public function set_region($region)
|
79 |
+
{
|
80 |
+
$this->set_hostname($region);
|
81 |
+
return $this;
|
82 |
+
}
|
83 |
+
|
84 |
+
|
85 |
+
/*%******************************************************************************************%*/
|
86 |
+
// CONSTRUCTOR
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Constructs a new instance of <AmazonRDS>.
|
90 |
+
*
|
91 |
+
* @param string $key (Optional) Your Amazon API Key. If blank, it will look for the <code>AWS_KEY</code> constant.
|
92 |
+
* @param string $secret_key (Optional) Your Amazon API Secret Key. If blank, it will look for the <code>AWS_SECRET_KEY</code> constant.
|
93 |
+
* @return boolean false if no valid values are set, otherwise true.
|
94 |
+
*/
|
95 |
+
public function __construct($key = null, $secret_key = null)
|
96 |
+
{
|
97 |
+
$this->api_version = '2010-07-28';
|
98 |
+
$this->hostname = self::DEFAULT_URL;
|
99 |
+
|
100 |
+
if (!$key && !defined('AWS_KEY'))
|
101 |
+
{
|
102 |
+
throw new RDS_Exception('No account key was passed into the constructor, nor was it set in the AWS_KEY constant.');
|
103 |
+
}
|
104 |
+
|
105 |
+
if (!$secret_key && !defined('AWS_SECRET_KEY'))
|
106 |
+
{
|
107 |
+
throw new RDS_Exception('No account secret was passed into the constructor, nor was it set in the AWS_SECRET_KEY constant.');
|
108 |
+
}
|
109 |
+
|
110 |
+
return parent::__construct($key, $secret_key);
|
111 |
+
}
|
112 |
+
|
113 |
+
|
114 |
+
/*%******************************************************************************************%*/
|
115 |
+
// SERVICE METHODS
|
116 |
+
|
117 |
+
/**
|
118 |
+
*
|
119 |
+
* This API deletes a particular DBParameterGroup. The DBParameterGroup cannot be associated with any RDS instances to be
|
120 |
+
* deleted.
|
121 |
+
*
|
122 |
+
* The specified database parameter group cannot be associated with any DB Instances.
|
123 |
+
*
|
124 |
+
* @param string $db_parameter_group_name (Required) The name of the DB Parameter Group. Constraints: <ul> <li>Must be the name of an existing DB Parameter Group</li><li>You cannot delete a default DB Parameter Group</li> </ul>
|
125 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
126 |
+
* <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>
|
127 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
128 |
+
*/
|
129 |
+
public function delete_db_parameter_group($db_parameter_group_name, $opt = null)
|
130 |
+
{
|
131 |
+
if (!$opt) $opt = array();
|
132 |
+
$opt['DBParameterGroupName'] = $db_parameter_group_name;
|
133 |
+
|
134 |
+
return $this->authenticate('DeleteDBParameterGroup', $opt, $this->hostname);
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
*
|
139 |
+
* This API is used to delete a DBSnapshot.
|
140 |
+
*
|
141 |
+
* The DBSnapshot must be in the <code>available</code> state to be deleted.
|
142 |
+
*
|
143 |
+
* @param string $db_snapshot_identifier (Required) The DBSnapshot identifier. Constraints: Must be the name of an existing DB Snapshot in the <code>available</code> state.
|
144 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
145 |
+
* <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>
|
146 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
147 |
+
*/
|
148 |
+
public function delete_db_snapshot($db_snapshot_identifier, $opt = null)
|
149 |
+
{
|
150 |
+
if (!$opt) $opt = array();
|
151 |
+
$opt['DBSnapshotIdentifier'] = $db_snapshot_identifier;
|
152 |
+
|
153 |
+
return $this->authenticate('DeleteDBSnapshot', $opt, $this->hostname);
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
*
|
158 |
+
* This API modifies the parameters of a DBParameterGroup. To modify more than one parameter submit a list of the
|
159 |
+
* following: ParameterName, ParameterValue, and ApplyMethod. A maximum of 20 parameters can be modified in a single
|
160 |
+
* request.
|
161 |
+
*
|
162 |
+
* @param string $db_parameter_group_name (Required) The name of the database parameter group. Constraints: <ul> <li>Must be 1 to 255 alphanumeric characters</li><li>First character must be a letter</li><li>Cannot end with a hyphen or contain two consecutive hyphens</li> </ul>
|
163 |
+
* @param array $parameters (Required) An array of parameter names, values, and the apply method for the parameter update. At least one parameter name, value, and apply method must be supplied; subsequent arguments are optional. A maximum of 20 parameters may be modified in a single request. Valid Values (for the application method): <code>immediate | pending-reboot</code> You can use the immediate value with dynamic parameters only. You can use the pending-reboot value for both dynamic and static parameters, and changes are applied when DB Instance reboots. <ul>
|
164 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
165 |
+
* <li><code>ParameterName</code> - <code>string</code> - Optional - Specifies the name of the parameter. </li>
|
166 |
+
* <li><code>ParameterValue</code> - <code>string</code> - Optional - Specifies the value of the parameter. </li>
|
167 |
+
* <li><code>Description</code> - <code>string</code> - Optional - Provides a description of the parameter. </li>
|
168 |
+
* <li><code>Source</code> - <code>string</code> - Optional - Indicates the source of the parameter value. </li>
|
169 |
+
* <li><code>ApplyType</code> - <code>string</code> - Optional - Specifies the engine specific parameters type. </li>
|
170 |
+
* <li><code>DataType</code> - <code>string</code> - Optional - Specifies the valid data type for the parameter. </li>
|
171 |
+
* <li><code>AllowedValues</code> - <code>string</code> - Optional - Specifies the valid range of values for the parameter. </li>
|
172 |
+
* <li><code>IsModifiable</code> - <code>boolean</code> - Optional - Indicates whether (<code>true</code>) or not (<code>false</code>) the parameter can be modified. Some parameters have security or operational implications that prevent them from being changed. </li>
|
173 |
+
* <li><code>MinimumEngineVersion</code> - <code>string</code> - Optional - The earliest engine version to which the parameter can apply. </li>
|
174 |
+
* <li><code>ApplyMethod</code> - <code>string</code> - Optional - Indicates when to apply parameter updates. [Allowed values: <code>immediate</code>, <code>pending-reboot</code>]</li>
|
175 |
+
* </ul></li>
|
176 |
+
* </ul>
|
177 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
178 |
+
* <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>
|
179 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
180 |
+
*/
|
181 |
+
public function modify_db_parameter_group($db_parameter_group_name, $parameters, $opt = null)
|
182 |
+
{
|
183 |
+
if (!$opt) $opt = array();
|
184 |
+
$opt['DBParameterGroupName'] = $db_parameter_group_name;
|
185 |
+
|
186 |
+
// Required parameter
|
187 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
188 |
+
'Parameters' => (is_array($parameters) ? $parameters : array($parameters))
|
189 |
+
), 'member'));
|
190 |
+
|
191 |
+
return $this->authenticate('ModifyDBParameterGroup', $opt, $this->hostname);
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
*
|
196 |
+
* This API revokes ingress from a DBSecurityGroup for previously authorized IP ranges or EC2 Security Groups. Required
|
197 |
+
* parameters for this API are one of CIDRIP or (EC2SecurityGroupName AND EC2SecurityGroupOwnerId).
|
198 |
+
*
|
199 |
+
* @param string $db_security_group_name (Required) The name of the DB Security Group to revoke ingress from.
|
200 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
201 |
+
* <li><code>CIDRIP</code> - <code>string</code> - Optional - The IP range to revoke access from. Must be a valid CIDR range. If <code>CIDRIP</code> is specified, <code>EC2SecurityGroupName</code> and <code>EC2SecurityGroupOwnerId</code> cannot be provided. </li>
|
202 |
+
* <li><code>EC2SecurityGroupName</code> - <code>string</code> - Optional - The name of the EC2 Security Group to revoke access from. If <code>EC2SecurityGroupName</code> is specified, <code>EC2SecurityGroupOwnerId</code> must also be provided and <code>CIDRIP</code> cannot be provided. </li>
|
203 |
+
* <li><code>EC2SecurityGroupOwnerId</code> - <code>string</code> - Optional - The AWS Account Number of the owner of the security group specified in the <code>EC2SecurityGroupName</code> parameter. The AWS Access Key ID is not an acceptable value. If <code>EC2SecurityGroupOwnerId</code> is specified <code>EC2SecurityGroupName</code> must also be provided and <code>CIDRIP</code> cannot be provided. </li>
|
204 |
+
* <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>
|
205 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
206 |
+
*/
|
207 |
+
public function revoke_db_security_group_ingress($db_security_group_name, $opt = null)
|
208 |
+
{
|
209 |
+
if (!$opt) $opt = array();
|
210 |
+
$opt['DBSecurityGroupName'] = $db_security_group_name;
|
211 |
+
|
212 |
+
return $this->authenticate('RevokeDBSecurityGroupIngress', $opt, $this->hostname);
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
*
|
217 |
+
* This API returns the detailed parameter list for a particular DBParameterGroup.
|
218 |
+
*
|
219 |
+
* @param string $db_parameter_group_name (Required) The name of a specific database parameter group to return details for. Constraints: <ul> <li>Must be 1 to 255 alphanumeric characters</li><li>First character must be a letter</li><li>Cannot end with a hyphen or contain two consecutive hyphens</li> </ul>
|
220 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
221 |
+
* <li><code>Source</code> - <code>string</code> - Optional - The parameter types to return. Default: All parameter types returned Valid Values: <code>user | system | engine-default</code> </li>
|
222 |
+
* <li><code>MaxRecords</code> - <code>integer</code> - Optional - The maximum number of records to include in the response. If more records exist than the specified <code>MaxRecords</code> value, a marker is included in the response so that the remaining results may be retrieved. Default: 100 Constraints: minimum 20, maximum 100 </li>
|
223 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - An optional marker provided in the previous DescribeDBInstances request. If this parameter is specified, the response includes only records beyond the marker, up to the value specified by <code>MaxRecords</code>. </li>
|
224 |
+
* <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>
|
225 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
226 |
+
*/
|
227 |
+
public function describe_db_parameters($db_parameter_group_name, $opt = null)
|
228 |
+
{
|
229 |
+
if (!$opt) $opt = array();
|
230 |
+
$opt['DBParameterGroupName'] = $db_parameter_group_name;
|
231 |
+
|
232 |
+
return $this->authenticate('DescribeDBParameters', $opt, $this->hostname);
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
*
|
237 |
+
* This API returns events related to DB Instances, DB Security Groups, DB Snapshots and DB Parameter Groups for the past
|
238 |
+
* 14 das. Events specific to a particular DB Instance, database security group, database snapshot or database parameter
|
239 |
+
* group can be obtained by providing the name as a parameter. By default, the past hour of events are returned.
|
240 |
+
*
|
241 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
242 |
+
* <li><code>SourceIdentifier</code> - <code>string</code> - Optional - The identifier of the event source for which events will be returned. If not specified, then all sources are included in the response. Constraints: <ul> <li>If SourceIdentifier is supplied, SourceType must also be provided.</li><li>If the source type is DBInstance, then a DBInstanceIdentifier must be supplied.</li><li>If the source type is DBSecurityGroup, a DBSecurityGroupName must be supplied.</li><li>If the source type is DBParameterGroup, a DBParameterGroupName must be supplied.</li><li>If the source type is DBSnapshot, a DBSnapshotIdentifier must be supplied.</li><li>Cannot end with a hyphen or contain two consecutive hyphens.</li> </ul> </li>
|
243 |
+
* <li><code>SourceType</code> - <code>string</code> - Optional - The event source to retrieve events for. If no value is specified, all events are returned. Valid Values: <code>db-instance | db-security-group | db-parameter-group | db-snapshot</code> [Allowed values: <code>db-instance</code>, <code>db-parameter-group</code>, <code>db-security-group</code>, <code>db-snapshot</code>]</li>
|
244 |
+
* <li><code>StartTime</code> - <code>string</code> - Optional - The beginning of the time interval to retrieve events for, specified in ISO 8601 format. For more information about ISO 8601, go to the ISO8601 Wikipedia page. Example: 2009-07-08T18:00Z May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
245 |
+
* <li><code>EndTime</code> - <code>string</code> - Optional - The end of the time interval for which to retrieve events, specified in ISO 8601 format. For more information about ISO 8601, go to the ISO8601 Wikipedia page. Example: 2009-07-08T18:00Z May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
246 |
+
* <li><code>Duration</code> - <code>integer</code> - Optional - The number of minutes to retrieve events for. Default: 60 </li>
|
247 |
+
* <li><code>MaxRecords</code> - <code>integer</code> - Optional - The maximum number of records to include in the response. If more records exist than the specified <code>MaxRecords</code> value, a marker is included in the response so that the remaining results may be retrieved. Default: 100 Constraints: minimum 20, maximum 100 </li>
|
248 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - An optional marker provided in the previous DescribeDBInstances request. If this parameter is specified, the response includes only records beyond the marker, up to the value specified by <code>MaxRecords</code>. </li>
|
249 |
+
* <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>
|
250 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
251 |
+
*/
|
252 |
+
public function describe_events($opt = null)
|
253 |
+
{
|
254 |
+
if (!$opt) $opt = array();
|
255 |
+
|
256 |
+
// Optional parameter
|
257 |
+
if (isset($opt['StartTime']))
|
258 |
+
{
|
259 |
+
$opt['StartTime'] = $this->util->convert_date_to_iso8601($opt['StartTime']);
|
260 |
+
}
|
261 |
+
|
262 |
+
// Optional parameter
|
263 |
+
if (isset($opt['EndTime']))
|
264 |
+
{
|
265 |
+
$opt['EndTime'] = $this->util->convert_date_to_iso8601($opt['EndTime']);
|
266 |
+
}
|
267 |
+
|
268 |
+
return $this->authenticate('DescribeEvents', $opt, $this->hostname);
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
*
|
273 |
+
* This API creates a new database security group. Database Security groups control access to a database instance.
|
274 |
+
*
|
275 |
+
* @param string $db_security_group_name (Required) The name for the DB Security Group. This value is stored as a lowercase string. Constraints: Must contain no more than 255 alphanumeric characters or hyphens. Must not be "Default". Example: <code>mysecuritygroup</code>
|
276 |
+
* @param string $db_security_group_description (Required) The description for the DB Security Group.
|
277 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
278 |
+
* <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>
|
279 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
280 |
+
*/
|
281 |
+
public function create_db_security_group($db_security_group_name, $db_security_group_description, $opt = null)
|
282 |
+
{
|
283 |
+
if (!$opt) $opt = array();
|
284 |
+
$opt['DBSecurityGroupName'] = $db_security_group_name;
|
285 |
+
$opt['DBSecurityGroupDescription'] = $db_security_group_description;
|
286 |
+
|
287 |
+
return $this->authenticate('CreateDBSecurityGroup', $opt, $this->hostname);
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
*
|
292 |
+
* This API is used to retrieve information about provisioned RDS instances. DescribeDBInstances supports pagination.
|
293 |
+
*
|
294 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
295 |
+
* <li><code>DBInstanceIdentifier</code> - <code>string</code> - Optional - The user-supplied instance identifier. If this parameter is specified, information from only the specific DB Instance is returned. This parameter isn't case sensitive. Constraints: <ul> <li>Must contain from 1 to 63 alphanumeric characters or hyphens</li><li>First character must be a letter</li><li>Cannot end with a hyphen or contain two consecutive hyphens</li> </ul> </li>
|
296 |
+
* <li><code>MaxRecords</code> - <code>integer</code> - Optional - The maximum number of records to include in the response. If more records exist than the specified <code>MaxRecords</code> value, a marker is included in the response so that the remaining results may be retrieved. Default: 100 Constraints: minimum 20, maximum 100 </li>
|
297 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - An optional marker provided in the previous DescribeDBInstances request. If this parameter is specified, the response includes only records beyond the marker, up to the value specified by <code>MaxRecords</code> . </li>
|
298 |
+
* <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>
|
299 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
300 |
+
*/
|
301 |
+
public function describe_db_instances($opt = null)
|
302 |
+
{
|
303 |
+
if (!$opt) $opt = array();
|
304 |
+
|
305 |
+
return $this->authenticate('DescribeDBInstances', $opt, $this->hostname);
|
306 |
+
}
|
307 |
+
|
308 |
+
/**
|
309 |
+
*
|
310 |
+
* This API returns a list of DBParameterGroup descriptions. If a DBParameterGroupName is specified, the list will contain
|
311 |
+
* only the descriptions of the specified DBParameterGroup.
|
312 |
+
*
|
313 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
314 |
+
* <li><code>DBParameterGroupName</code> - <code>string</code> - Optional - The name of a specific database parameter group to return details for. Constraints: <ul> <li>Must be 1 to 255 alphanumeric characters</li><li>First character must be a letter</li><li>Cannot end with a hyphen or contain two consecutive hyphens</li> </ul> </li>
|
315 |
+
* <li><code>MaxRecords</code> - <code>integer</code> - Optional - The maximum number of records to include in the response. If more records exist than the specified <code>MaxRecords</code> value, a marker is included in the response so that the remaining results may be retrieved. Default: 100 Constraints: minimum 20, maximum 100 </li>
|
316 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - An optional marker provided in the previous DescribeDBInstances request. If this parameter is specified, the response includes only records beyond the marker, up to the value specified by <code>MaxRecords</code>. </li>
|
317 |
+
* <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>
|
318 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
319 |
+
*/
|
320 |
+
public function describe_db_parameter_groups($opt = null)
|
321 |
+
{
|
322 |
+
if (!$opt) $opt = array();
|
323 |
+
|
324 |
+
return $this->authenticate('DescribeDBParameterGroups', $opt, $this->hostname);
|
325 |
+
}
|
326 |
+
|
327 |
+
/**
|
328 |
+
*
|
329 |
+
* This API is used to create a DBSnapshot. The source DBInstance must be in "available" state.
|
330 |
+
*
|
331 |
+
* @param string $db_snapshot_identifier (Required) The identifier for the DB Snapshot. Constraints: <ul> <li>Cannot be null, empty, or blank</li><li>Must contain from 1 to 255 alphanumeric characters or hyphens</li><li>First character must be a letter</li><li>Cannot end with a hyphen or contain two consecutive hyphens</li> </ul> Example: <code>my-snapshot-id</code>
|
332 |
+
* @param string $db_instance_identifier (Required) The DB Instance identifier. This is the unique key that identifies a DB Instance. This parameter isn't case sensitive. Constraints: <ul> <li>Must contain from 1 to 63 alphanumeric characters or hyphens</li><li>First character must be a letter</li><li>Cannot end with a hyphen or contain two consecutive hyphens</li> </ul>
|
333 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
334 |
+
* <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>
|
335 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
336 |
+
*/
|
337 |
+
public function create_db_snapshot($db_snapshot_identifier, $db_instance_identifier, $opt = null)
|
338 |
+
{
|
339 |
+
if (!$opt) $opt = array();
|
340 |
+
$opt['DBSnapshotIdentifier'] = $db_snapshot_identifier;
|
341 |
+
$opt['DBInstanceIdentifier'] = $db_instance_identifier;
|
342 |
+
|
343 |
+
return $this->authenticate('CreateDBSnapshot', $opt, $this->hostname);
|
344 |
+
}
|
345 |
+
|
346 |
+
/**
|
347 |
+
*
|
348 |
+
* Returns a list of the available DB engines.
|
349 |
+
*
|
350 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
351 |
+
* <li><code>Engine</code> - <code>string</code> - Optional - The database engine to return. </li>
|
352 |
+
* <li><code>EngineVersion</code> - <code>string</code> - Optional - The database engine version to return. Valid Values: <code>5.1.45 | 5.1.49</code> </li>
|
353 |
+
* <li><code>DBParameterGroupFamily</code> - <code>string</code> - Optional - The name of a specific database parameter group family to return details for. Constraints: <ul> <li>Must be 1 to 255 alphanumeric characters</li><li>First character must be a letter</li><li>Cannot end with a hyphen or contain two consecutive hyphens</li> </ul> </li>
|
354 |
+
* <li><code>MaxRecords</code> - <code>integer</code> - Optional - The maximum number of records to include in the response. If more than the <code>MaxRecords</code> value is available, a marker is included in the response so that the following results can be retrieved. Default: 100 Constraints: minimum 20, maximum 100 </li>
|
355 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - The marker provided in the previous request. If this parameter is specified, the response includes records beyond the marker only, up to <code>MaxRecords</code>. </li>
|
356 |
+
* <li><code>DefaultOnly</code> - <code>boolean</code> - Optional - Indicates that only the default version of the specified engine or engine and major version combination is returned. </li>
|
357 |
+
* <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>
|
358 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
359 |
+
*/
|
360 |
+
public function describe_db_engine_versions($opt = null)
|
361 |
+
{
|
362 |
+
if (!$opt) $opt = array();
|
363 |
+
|
364 |
+
return $this->authenticate('DescribeDBEngineVersions', $opt, $this->hostname);
|
365 |
+
}
|
366 |
+
|
367 |
+
/**
|
368 |
+
*
|
369 |
+
* The RebootDBInstance API reboots a previously provisioned RDS instance. This API results in the application of modified
|
370 |
+
* DBParameterGroup parameters with ApplyStatus of pending-reboot to the RDS instance. This action is taken as soon as
|
371 |
+
* possible, and results in a momentary outage to the RDS instance during which the RDS instance status is set to
|
372 |
+
* rebooting. A DBInstance event is created when the reboot is completed.
|
373 |
+
*
|
374 |
+
* @param string $db_instance_identifier (Required) The DB Instance identifier. This parameter is stored as a lowercase string. Constraints: <ul> <li>Must contain from 1 to 63 alphanumeric characters or hyphens</li><li>First character must be a letter</li><li>Cannot end with a hyphen or contain two consecutive hyphens</li> </ul>
|
375 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
376 |
+
* <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>
|
377 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
378 |
+
*/
|
379 |
+
public function reboot_db_instance($db_instance_identifier, $opt = null)
|
380 |
+
{
|
381 |
+
if (!$opt) $opt = array();
|
382 |
+
$opt['DBInstanceIdentifier'] = $db_instance_identifier;
|
383 |
+
|
384 |
+
return $this->authenticate('RebootDBInstance', $opt, $this->hostname);
|
385 |
+
}
|
386 |
+
|
387 |
+
/**
|
388 |
+
*
|
389 |
+
* This API allows for ingress to a DBSecurityGroup using one of two forms of authorization. First, EC2 Security Groups
|
390 |
+
* can be added to the DBSecurityGroup if the application using the database is running on EC2 instances. Second, IP ranges
|
391 |
+
* are available if the application accessing your database is running on the Internet. Required parameters for this API
|
392 |
+
* are one of CIDR range or (EC2SecurityGroupName AND EC2SecurityGroupOwnerId).
|
393 |
+
*
|
394 |
+
* You cannot authorize ingress from an EC2 security group in one Region to an Amazon RDS DB Instance in another.
|
395 |
+
*
|
396 |
+
* For an overview of CIDR ranges, go to the <a
|
397 |
+
* href="http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing">Wikipedia Tutorial</a>.
|
398 |
+
*
|
399 |
+
* @param string $db_security_group_name (Required) The name of the DB Security Group to authorize.
|
400 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
401 |
+
* <li><code>CIDRIP</code> - <code>string</code> - Optional - The IP range to authorize. </li>
|
402 |
+
* <li><code>EC2SecurityGroupName</code> - <code>string</code> - Optional - Name of the EC2 Security Group to authorize. </li>
|
403 |
+
* <li><code>EC2SecurityGroupOwnerId</code> - <code>string</code> - Optional - AWS Account Number of the owner of the security group specified in the EC2SecurityGroupName parameter. The AWS Access Key ID is not an acceptable value. </li>
|
404 |
+
* <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>
|
405 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
406 |
+
*/
|
407 |
+
public function authorize_db_security_group_ingress($db_security_group_name, $opt = null)
|
408 |
+
{
|
409 |
+
if (!$opt) $opt = array();
|
410 |
+
$opt['DBSecurityGroupName'] = $db_security_group_name;
|
411 |
+
|
412 |
+
return $this->authenticate('AuthorizeDBSecurityGroupIngress', $opt, $this->hostname);
|
413 |
+
}
|
414 |
+
|
415 |
+
/**
|
416 |
+
*
|
417 |
+
* This API creates a new RDS instance from a point-in-time system snapshot. The target database is created from the
|
418 |
+
* source database restore point with the same configuration as the original source database, except that the new RDS
|
419 |
+
* instance is created with the default security group.
|
420 |
+
*
|
421 |
+
* @param string $source_db_instance_identifier (Required) The identifier of the source DB Instance from which to restore. Constraints: <ul> <li>Must contain from 1 to 63 alphanumeric characters or hyphens</li><li>First character must be a letter</li><li>Cannot end with a hyphen or contain two consecutive hyphens</li> </ul>
|
422 |
+
* @param string $target_db_instance_identifier (Required) The name of the new database instance to be created. Constraints: <ul> <li>Must contain from 1 to 63 alphanumeric characters or hyphens</li><li>First character must be a letter</li><li>Cannot end with a hyphen or contain two consecutive hyphens</li> </ul>
|
423 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
424 |
+
* <li><code>RestoreTime</code> - <code>string</code> - Optional - The date and time from to restore from. Valid Values: Value must be a UTC time Constraints: <ul> <li>Must be after the latest restorable time for the DB Instance</li><li>Cannot be specified if UseLatestRestorableTime parameter is true</li> </ul> Example: <code>2009-09-07T23:45:00Z</code> May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
425 |
+
* <li><code>UseLatestRestorableTime</code> - <code>boolean</code> - Optional - Specifies whether (<code>true</code>) or not (<code>false</code>) the DB Instance is restored from the latest backup time. Default: <code>false</code> Constraints: Cannot be specified if RestoreTime parameter is provided. </li>
|
426 |
+
* <li><code>DBInstanceClass</code> - <code>string</code> - Optional - The compute and memory capacity of the Amazon RDS DB instance. Valid Values: <code>db.m1.small | db.m1.large | db.m1.xlarge | db.m2.2xlarge | db.m2.4xlarge</code> Default: The same DBInstanceClass as the original DB Instance. </li>
|
427 |
+
* <li><code>Port</code> - <code>integer</code> - Optional - The port number on which the database accepts connections. Constraints: Value must be <code>1115-65535</code> Default: The same port as the original DB Instance. </li>
|
428 |
+
* <li><code>AvailabilityZone</code> - <code>string</code> - Optional - The EC2 Availability Zone that the database instance will be created in. Default: A random, system-chosen Availability Zone. Constraint: You cannot specify the AvailabilityZone parameter if the MultiAZ parameter is set to true. Example: <code>us-east-1a</code> </li>
|
429 |
+
* <li><code>MultiAZ</code> - <code>boolean</code> - Optional - Specifies if the DB Instance is a Multi-AZ deployment. Constraint: You cannot specify the AvailabilityZone parameter if the MultiAZ parameter is set to <code>true</code>. </li>
|
430 |
+
* <li><code>AutoMinorVersionUpgrade</code> - <code>boolean</code> - Optional - Indicates that minor version upgrades will be applied automatically to the DB Instance during the maintenance window. </li>
|
431 |
+
* <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>
|
432 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
433 |
+
*/
|
434 |
+
public function restore_db_instance_to_point_in_time($source_db_instance_identifier, $target_db_instance_identifier, $opt = null)
|
435 |
+
{
|
436 |
+
if (!$opt) $opt = array();
|
437 |
+
$opt['SourceDBInstanceIdentifier'] = $source_db_instance_identifier;
|
438 |
+
$opt['TargetDBInstanceIdentifier'] = $target_db_instance_identifier;
|
439 |
+
|
440 |
+
// Optional parameter
|
441 |
+
if (isset($opt['RestoreTime']))
|
442 |
+
{
|
443 |
+
$opt['RestoreTime'] = $this->util->convert_date_to_iso8601($opt['RestoreTime']);
|
444 |
+
}
|
445 |
+
|
446 |
+
return $this->authenticate('RestoreDBInstanceToPointInTime', $opt, $this->hostname);
|
447 |
+
}
|
448 |
+
|
449 |
+
/**
|
450 |
+
*
|
451 |
+
* This API is used to retrieve information about DBSnapshots. This API supports pagination.
|
452 |
+
*
|
453 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
454 |
+
* <li><code>DBInstanceIdentifier</code> - <code>string</code> - Optional - The unique identifier for the Amazon RDS DB snapshot. This value is stored as a lowercase string. Constraints: <ul> <li>Must contain from 1 to 63 alphanumeric characters or hyphens</li><li>First character must be a letter</li><li>Cannot end with a hyphen or contain two consecutive hyphens</li> </ul> </li>
|
455 |
+
* <li><code>DBSnapshotIdentifier</code> - <code>string</code> - Optional - The DB Instance identifier. This parameter isn't case sensitive. Constraints: <ul> <li>Must be 1 to 255 alphanumeric characters</li><li>First character must be a letter</li><li>Cannot end with a hyphen or contain two consecutive hyphens</li> </ul> </li>
|
456 |
+
* <li><code>MaxRecords</code> - <code>integer</code> - Optional - The maximum number of records to include in the response. If more records exist than the specified <code>MaxRecords</code> value, a marker is included in the response so that the remaining results may be retrieved. Default: 100 Constraints: minimum 20, maximum 100 </li>
|
457 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - An optional marker provided in the previous DescribeDBInstances request. If this parameter is specified, the response includes only records beyond the marker, up to the value specified by <code>MaxRecords</code>. </li>
|
458 |
+
* <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>
|
459 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
460 |
+
*/
|
461 |
+
public function describe_db_snapshots($opt = null)
|
462 |
+
{
|
463 |
+
if (!$opt) $opt = array();
|
464 |
+
|
465 |
+
return $this->authenticate('DescribeDBSnapshots', $opt, $this->hostname);
|
466 |
+
}
|
467 |
+
|
468 |
+
/**
|
469 |
+
*
|
470 |
+
* Lists available reserved DB Instance offerings.
|
471 |
+
*
|
472 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
473 |
+
* <li><code>ReservedDBInstancesOfferingId</code> - <code>string</code> - Optional - The offering identifier filter value. Specify this parameter to show only the available offering that matches the specified reservation identifier. Example: <code>438012d3-4052-4cc7-b2e3-8d3372e0e706</code> </li>
|
474 |
+
* <li><code>DBInstanceClass</code> - <code>string</code> - Optional - The DB Instance class filter value. Specify this parameter to show only the available offerings matching the specified DB Instance class. </li>
|
475 |
+
* <li><code>Duration</code> - <code>string</code> - Optional - Duration filter value, specified in years or seconds. Specify this parameter to show only reservations for this duration. Valid Values: <code>1 | 3 | 31536000 | 94608000</code> </li>
|
476 |
+
* <li><code>ProductDescription</code> - <code>string</code> - Optional - Product description filter value. Specify this parameter to show only the available offerings matching the specified product description. </li>
|
477 |
+
* <li><code>MultiAZ</code> - <code>boolean</code> - Optional - The Multi-AZ filter value. Specify this parameter to show only the available offerings matching the specified Multi-AZ parameter. </li>
|
478 |
+
* <li><code>MaxRecords</code> - <code>integer</code> - Optional - The maximum number of records to include in the response. If more than the <code>MaxRecords</code> value is available, a marker is included in the response so that the following results can be retrieved. Default: 100 Constraints: minimum 20, maximum 100 </li>
|
479 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - The marker provided in the previous request. If this parameter is specified, the response includes records beyond the marker only, up to <code>MaxRecords</code>. </li>
|
480 |
+
* <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>
|
481 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
482 |
+
*/
|
483 |
+
public function describe_reserved_db_instances_offerings($opt = null)
|
484 |
+
{
|
485 |
+
if (!$opt) $opt = array();
|
486 |
+
|
487 |
+
return $this->authenticate('DescribeReservedDBInstancesOfferings', $opt, $this->hostname);
|
488 |
+
}
|
489 |
+
|
490 |
+
/**
|
491 |
+
*
|
492 |
+
* This API returns the default engine and system parameter information for the specified database engine.
|
493 |
+
*
|
494 |
+
* @param string $db_parameter_group_family (Required) The name of the DB Parameter Group Family. Valid Values: <code>MySQL5.1</code> | <code>MySQL5.5</code>
|
495 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
496 |
+
* <li><code>MaxRecords</code> - <code>integer</code> - Optional - The maximum number of records to include in the response. If more records exist than the specified <code>MaxRecords</code> value, a marker is included in the response so that the remaining results may be retrieved. Default: 100 Constraints: minimum 20, maximum 100 </li>
|
497 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - An optional marker provided in the previous DescribeDBInstances request. If this parameter is specified, the response includes only records beyond the marker, up to the value specified by <code>MaxRecords</code>. </li>
|
498 |
+
* <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>
|
499 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
500 |
+
*/
|
501 |
+
public function describe_engine_default_parameters($db_parameter_group_family, $opt = null)
|
502 |
+
{
|
503 |
+
if (!$opt) $opt = array();
|
504 |
+
$opt['DBParameterGroupFamily'] = $db_parameter_group_family;
|
505 |
+
|
506 |
+
return $this->authenticate('DescribeEngineDefaultParameters', $opt, $this->hostname);
|
507 |
+
}
|
508 |
+
|
509 |
+
/**
|
510 |
+
*
|
511 |
+
* The DeleteDBInstance API deletes a previously provisioned RDS instance. A successful response from the web service
|
512 |
+
* indicates the request was received correctly. If a final DBSnapshot is requested the status of the RDS instance will be
|
513 |
+
* "deleting" until the DBSnapshot is created. DescribeDBInstance is used to monitor the status of this operation. This
|
514 |
+
* cannot be canceled or reverted once submitted.
|
515 |
+
*
|
516 |
+
* @param string $db_instance_identifier (Required) The DB Instance identifier for the DB Instance to be deleted. This parameter isn't case sensitive. Constraints: <ul> <li>Must contain from 1 to 63 alphanumeric characters or hyphens</li><li>First character must be a letter</li><li>Cannot end with a hyphen or contain two consecutive hyphens</li> </ul>
|
517 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
518 |
+
* <li><code>SkipFinalSnapshot</code> - <code>boolean</code> - Optional - Determines whether a final DB Snapshot is created before the DB Instance is deleted. If <code>true</code> is specified, no DBSnapshot is created. If false is specified, a DB Snapshot is created before the DB Instance is deleted. The FinalDBSnapshotIdentifier parameter must be specified if SkipFinalSnapshot is <code>false</code>. Default: <code>false</code> </li>
|
519 |
+
* <li><code>FinalDBSnapshotIdentifier</code> - <code>string</code> - Optional - The DBSnapshotIdentifier of the new DBSnapshot created when SkipFinalSnapshot is set to <code>false</code>. Specifying this parameter and also setting the SkipFinalShapshot parameter to true results in an error. Constraints: <ul> <li>Must be 1 to 255 alphanumeric characters</li><li>First character must be a letter</li><li>Cannot end with a hyphen or contain two consecutive hyphens</li> </ul> </li>
|
520 |
+
* <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>
|
521 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
522 |
+
*/
|
523 |
+
public function delete_db_instance($db_instance_identifier, $opt = null)
|
524 |
+
{
|
525 |
+
if (!$opt) $opt = array();
|
526 |
+
$opt['DBInstanceIdentifier'] = $db_instance_identifier;
|
527 |
+
|
528 |
+
return $this->authenticate('DeleteDBInstance', $opt, $this->hostname);
|
529 |
+
}
|
530 |
+
|
531 |
+
/**
|
532 |
+
*
|
533 |
+
* This API returns a list of DBSecurityGroup descriptions. If a DBSecurityGroupName is specified, the list will contain
|
534 |
+
* only the descriptions of the specified DBSecurityGroup.
|
535 |
+
*
|
536 |
+
* For an overview of CIDR ranges, go to the <a
|
537 |
+
* href="http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing">Wikipedia Tutorial</a>.
|
538 |
+
*
|
539 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
540 |
+
* <li><code>DBSecurityGroupName</code> - <code>string</code> - Optional - The name of the DB Security Group to return details for. </li>
|
541 |
+
* <li><code>MaxRecords</code> - <code>integer</code> - Optional - The maximum number of records to include in the response. If more records exist than the specified <code>MaxRecords</code> value, a marker is included in the response so that the remaining results may be retrieved. Default: 100 Constraints: minimum 20, maximum 100 </li>
|
542 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - An optional marker provided in the previous DescribeDBInstances request. If this parameter is specified, the response includes only records beyond the marker, up to the value specified by <code>MaxRecords</code>. </li>
|
543 |
+
* <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>
|
544 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
545 |
+
*/
|
546 |
+
public function describe_db_security_groups($opt = null)
|
547 |
+
{
|
548 |
+
if (!$opt) $opt = array();
|
549 |
+
|
550 |
+
return $this->authenticate('DescribeDBSecurityGroups', $opt, $this->hostname);
|
551 |
+
}
|
552 |
+
|
553 |
+
/**
|
554 |
+
*
|
555 |
+
* This API creates a new DB instance.
|
556 |
+
*
|
557 |
+
* @param string $db_instance_identifier (Required) The DB Instance identifier. This parameter is stored as a lowercase string. Constraints: <ul> <li>Must contain from 1 to 63 alphanumeric characters or hyphens.</li><li>First character must be a letter.</li><li>Cannot end with a hyphen or contain two consecutive hyphens.</li> </ul> Example: <code>mydbinstance</code>
|
558 |
+
* @param integer $allocated_storage (Required) The amount of storage (in gigabytes) to be initially allocated for the database instance. Must be an integer from 5 to 1024.
|
559 |
+
* @param string $db_instance_class (Required) The compute and memory capacity of the DB Instance. Valid Values: <code>db.m1.small | db.m1.large | db.m1.xlarge | db.m2.xlarge |db.m2.2xlarge | db.m2.4xlarge</code>
|
560 |
+
* @param string $engine (Required) The name of the database engine to be used for this instance. Valid Values: <code>MySQL</code>
|
561 |
+
* @param string $master_username (Required) The name of master user for the client DB Instance. Constraints: <ul> <li>Must be 1 to 16 alphanumeric characters.</li><li>First character must be a letter.</li><li>Cannot be a reserved word for the chosen database engine.</li> </ul>
|
562 |
+
* @param string $master_user_password (Required) The password for the master DB Instance user. Constraints: Must contain 4 to 41 alphanumeric characters.
|
563 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
564 |
+
* <li><code>DBName</code> - <code>string</code> - Optional - The name of the database to create when the DB Instance is created. If this parameter is not specified, no database is created in the DB Instance. Constraints: <ul> <li>Must contain 1 to 64 alphanumeric characters</li><li>Cannot be a word reserved by the specified database engine</li> </ul> </li>
|
565 |
+
* <li><code>DBSecurityGroups</code> - <code>string|array</code> - Optional - A list of DB Security Groups to associate with this DB Instance. Default: The default DB Security Group for the database engine. Pass a string for a single value, or an indexed array for multiple values. </li>
|
566 |
+
* <li><code>AvailabilityZone</code> - <code>string</code> - Optional - The EC2 Availability Zone that the database instance will be created in. Default: A random, system-chosen Availability Zone in the endpoint's region. Example: <code>us-east-1d</code> Constraint: The AvailabilityZone parameter cannot be specified if the MultiAZ parameter is set to <code>true</code>. The specified Availability Zone must be in the same region as the current endpoint. </li>
|
567 |
+
* <li><code>PreferredMaintenanceWindow</code> - <code>string</code> - Optional - The weekly time range (in UTC) during which system maintenance can occur. Format: ddd:hh24:mi-ddd:hh24:mi Default: Depends on the Region the database was created in. These are the default maintenance windows for each Region: <ul> <li><b>US-East (Northern Virginia) Region:</b> Sun:05:00-Sun:09:00 UTC</li><li><b>US-West (Northern California) Region:</b> Sun:08:00-Sun:12:00 UTC</li><li><b>EU (Ireland) Region:</b> Sun:00:00-Sun:04:00 UTC</li><li><b>Asia Pacific (Singapore) Region:</b> Sat:16:00-Sat:20:00 UTC</li> </ul> Valid Days: Mon, Tue, Wed, Thu, Fri, Sat, Sun Constraints: Minimum four-hour period. </li>
|
568 |
+
* <li><code>DBParameterGroupName</code> - <code>string</code> - Optional - The name of the database parameter group to associate with this DB instance. If this argument is omitted, the default DBParameterGroup for the specified engine will be used. Constraints: <ul> <li>Must be 1 to 255 alphanumeric characters</li><li>First character must be a letter</li><li>Cannot end with a hyphen or contain two consecutive hyphens</li> </ul> </li>
|
569 |
+
* <li><code>BackupRetentionPeriod</code> - <code>integer</code> - Optional - The number of days for which automated backups are retained. Setting this parameter to a positive number enables backups. Setting this parameter to 0 disables automated backups. Default: 1 Constraints: <ul> <li>Must be a value from 0 to 8</li><li>Cannot be set to 0 if the DB Instance is a master instance with read replicas</li> </ul> </li>
|
570 |
+
* <li><code>PreferredBackupWindow</code> - <code>string</code> - Optional - The daily time range during which automated backups are created if automated backups are enabled, as determined by the <code>BackupRetentionPeriod</code>. Default: Depends on the Region the database was created in. These are the default backup windows for each Region: <ul> <li><b>US-East (Northern Virginia) Region:</b> 03:00-05:00 UTC</li><li><b>US-West (Northern California) Region:</b> 06:00-08:00 UTC</li><li><b>EU (Ireland) Region:</b> 22:00-00:00 UTC</li><li><b>Asia Pacific (Singapore) Region:</b> 14:00-16:00 UTC</li> </ul> Constraints: Must be in the format hh24:mi-hh24:mi. Times should be Universal Time Coordinated (UTC). Must not conflict with the preferred maintenance window. Must be at least two hours. </li>
|
571 |
+
* <li><code>Port</code> - <code>integer</code> - Optional - The port number on which the database accepts connections. Default: <code>3306</code> Valid Values: <code>1150-65535</code> </li>
|
572 |
+
* <li><code>MultiAZ</code> - <code>boolean</code> - Optional - Specifies if the DB Instance is a Multi-AZ deployment. You cannot set the AvailabilityZone parameter if the MultiAZ parameter is set to true. </li>
|
573 |
+
* <li><code>EngineVersion</code> - <code>string</code> - Optional - The version number of the database engine to use. Example: <code>5.1.42</code> </li>
|
574 |
+
* <li><code>AutoMinorVersionUpgrade</code> - <code>boolean</code> - Optional - Indicates that minor engine upgrades will be applied automatically to the DB Instance during the maintenance window. Default: <code>true</code> </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 create_db_instance($db_instance_identifier, $allocated_storage, $db_instance_class, $engine, $master_username, $master_user_password, $opt = null)
|
579 |
+
{
|
580 |
+
if (!$opt) $opt = array();
|
581 |
+
$opt['DBInstanceIdentifier'] = $db_instance_identifier;
|
582 |
+
$opt['AllocatedStorage'] = $allocated_storage;
|
583 |
+
$opt['DBInstanceClass'] = $db_instance_class;
|
584 |
+
$opt['Engine'] = $engine;
|
585 |
+
$opt['MasterUsername'] = $master_username;
|
586 |
+
$opt['MasterUserPassword'] = $master_user_password;
|
587 |
+
|
588 |
+
// Optional parameter
|
589 |
+
if (isset($opt['DBSecurityGroups']))
|
590 |
+
{
|
591 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
592 |
+
'DBSecurityGroups' => (is_array($opt['DBSecurityGroups']) ? $opt['DBSecurityGroups'] : array($opt['DBSecurityGroups']))
|
593 |
+
), 'member'));
|
594 |
+
unset($opt['DBSecurityGroups']);
|
595 |
+
}
|
596 |
+
|
597 |
+
return $this->authenticate('CreateDBInstance', $opt, $this->hostname);
|
598 |
+
}
|
599 |
+
|
600 |
+
/**
|
601 |
+
*
|
602 |
+
* This API modifies the parameters of a DBParameterGroup to the engine/system default value. To reset specific parameters
|
603 |
+
* submit a list of the following: ParameterName and ApplyMethod. To reset the entire DBParameterGroup specify the
|
604 |
+
* DBParameterGroup name and ResetAllParameters parameters. When resetting the entire group, dynamic parameters are updated
|
605 |
+
* immediately and static parameters are set to pending-reboot to take effect on the next MySQL reboot or RebootDBInstance
|
606 |
+
* request.
|
607 |
+
*
|
608 |
+
* @param string $db_parameter_group_name (Required) The name of the DB Parameter Group. Constraints: <ul> <li>Must be 1 to 255 alphanumeric characters</li><li>First character must be a letter</li><li>Cannot end with a hyphen or contain two consecutive hyphens</li> </ul>
|
609 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
610 |
+
* <li><code>ResetAllParameters</code> - <code>boolean</code> - Optional - Specifies whether (<code>true</code>) or not (<code>false</code>) to reset all parameters in the DB Parameter Group to default values. Default: <code>true</code> </li>
|
611 |
+
* <li><code>Parameters</code> - <code>array</code> - Optional - An array of parameter names, values, and the apply method for the parameter update. At least one parameter name, value, and apply method must be supplied; subsequent arguments are optional. A maximum of 20 parameters may be modified in a single request. Valid Values (for Apply method): <code>immediate | pending-reboot</code> You can use the immediate value with dynamic parameters only. You can use the <code>pending-reboot</code> value for both dynamic and static parameters, and changes are applied when DB Instance reboots. <ul>
|
612 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
613 |
+
* <li><code>ParameterName</code> - <code>string</code> - Optional - Specifies the name of the parameter. </li>
|
614 |
+
* <li><code>ParameterValue</code> - <code>string</code> - Optional - Specifies the value of the parameter. </li>
|
615 |
+
* <li><code>Description</code> - <code>string</code> - Optional - Provides a description of the parameter. </li>
|
616 |
+
* <li><code>Source</code> - <code>string</code> - Optional - Indicates the source of the parameter value. </li>
|
617 |
+
* <li><code>ApplyType</code> - <code>string</code> - Optional - Specifies the engine specific parameters type. </li>
|
618 |
+
* <li><code>DataType</code> - <code>string</code> - Optional - Specifies the valid data type for the parameter. </li>
|
619 |
+
* <li><code>AllowedValues</code> - <code>string</code> - Optional - Specifies the valid range of values for the parameter. </li>
|
620 |
+
* <li><code>IsModifiable</code> - <code>boolean</code> - Optional - Indicates whether (<code>true</code>) or not (<code>false</code>) the parameter can be modified. Some parameters have security or operational implications that prevent them from being changed. </li>
|
621 |
+
* <li><code>MinimumEngineVersion</code> - <code>string</code> - Optional - The earliest engine version to which the parameter can apply. </li>
|
622 |
+
* <li><code>ApplyMethod</code> - <code>string</code> - Optional - Indicates when to apply parameter updates. [Allowed values: <code>immediate</code>, <code>pending-reboot</code>]</li>
|
623 |
+
* </ul></li>
|
624 |
+
* </ul></li>
|
625 |
+
* <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>
|
626 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
627 |
+
*/
|
628 |
+
public function reset_db_parameter_group($db_parameter_group_name, $opt = null)
|
629 |
+
{
|
630 |
+
if (!$opt) $opt = array();
|
631 |
+
$opt['DBParameterGroupName'] = $db_parameter_group_name;
|
632 |
+
|
633 |
+
// Optional parameter
|
634 |
+
if (isset($opt['Parameters']))
|
635 |
+
{
|
636 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
637 |
+
'Parameters' => $opt['Parameters']
|
638 |
+
), 'member'));
|
639 |
+
unset($opt['Parameters']);
|
640 |
+
}
|
641 |
+
|
642 |
+
return $this->authenticate('ResetDBParameterGroup', $opt, $this->hostname);
|
643 |
+
}
|
644 |
+
|
645 |
+
/**
|
646 |
+
*
|
647 |
+
* This API is used to change RDS Instance settings. Users call the ModifyDBInstance API to change one or more database
|
648 |
+
* configuration parameters by specifying these parameters and the new values in the request.
|
649 |
+
*
|
650 |
+
* @param string $db_instance_identifier (Required) The DB Instance identifier. This value is stored as a lowercase string. Constraints: <ul> <li>Must contain from 1 to 63 alphanumeric characters or hyphens</li><li>First character must be a letter</li><li>Cannot end with a hyphen or contain two consecutive hyphens</li> </ul> Example: <copy>mydbinstance</copy>
|
651 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
652 |
+
* <li><code>AllocatedStorage</code> - <code>integer</code> - Optional - The new storage capacity of the RDS instance. This change does not result in an outage and is applied during the next maintenance window unless the <code>ApplyImmediately</code> parameter is specified as <code>true</code> for this request. Default: Uses existing setting Valid Values: 5-1024 Constraints: Value supplied must be at least 10% greater than the current value. Values that are not at least 10% greater than the existing value are rounded up so that they are 10% greater than the current value. </li>
|
653 |
+
* <li><code>DBInstanceClass</code> - <code>string</code> - Optional - The new compute and memory capacity of the DB Instance. Passing a value for this parameter causes an outage during the change and is applied during the next maintenance window, unless the <code>ApplyImmediately</code> parameter is specified as <code>true</code> for this request. Default: Uses existing setting Valid Values: <code>db.m1.small | db.m1.large | db.m1.xlarge | db.m2.xlarge | db.m2.2xlarge | db.m2.4xlarge</code> </li>
|
654 |
+
* <li><code>DBSecurityGroups</code> - <code>string|array</code> - Optional - A list of DB Security Groups to authorize on this DB Instance. This change is asynchronously applied as soon as possible. Constraints: <ul> <li>Must be 1 to 255 alphanumeric characters</li><li>First character must be a letter</li><li>Cannot end with a hyphen or contain two consecutive hyphens</li> </ul> Pass a string for a single value, or an indexed array for multiple values. </li>
|
655 |
+
* <li><code>ApplyImmediately</code> - <code>boolean</code> - Optional - Specifies whether or not the modifications in this request and any pending modifications are asynchronously applied as soon as possible, regardless of the <code>PreferredMaintenanceWindow</code> setting for the DB Instance. If this parameter is passed as <code>false</code>, changes to the DB Instance are applied on the next call to RebootDBInstance, the next maintenance reboot, or the next failure reboot, whichever occurs first. Default: <code>false</code> </li>
|
656 |
+
* <li><code>MasterUserPassword</code> - <code>string</code> - Optional - The new password for the DB Instance master user. This change is asynchronously applied as soon as possible. Between the time of the request and the completion of the request, the <code>MasterUserPassword</code> element exists in the <code>PendingModifiedValues</code> element of the operation response. Default: Uses existing setting Constraints: Must be 4 to 41 alphanumeric characters (engine specific) Amazon RDS APIs never return the password, so this API provides a way to regain access to a master instance user if the password is lost. </li>
|
657 |
+
* <li><code>DBParameterGroupName</code> - <code>string</code> - Optional - The name of the DB Parameter Group to apply to this DB Instance. This change is asynchronously applied as soon as possible for parameters when the <i>ApplyImmediately</i> parameter is specified as <code>true</code> for this request. Default: Uses existing setting Constraints: The DB Parameter Group must be in the same DB Parameter Group family as this DB Instance. </li>
|
658 |
+
* <li><code>BackupRetentionPeriod</code> - <code>integer</code> - Optional - The number of days to retain automated backups. Setting this parameter to a positive number enables backups. Setting this parameter to 0 disables automated backups. Default: Uses existing setting Constraints: <ul> <li>Must be a value from 0 to 8</li><li>Cannot be set to 0 if the DB Instance is a master instance with read replicas or of the DB Instance is a read replica</li> </ul> </li>
|
659 |
+
* <li><code>PreferredBackupWindow</code> - <code>string</code> - Optional - The daily time range during which automated backups are created if automated backups are enabled, as determined by the <code>BackupRetentionPeriod</code>. Constraints: <ul> <li>Must be in the format hh24:mi-hh24:mi</li><li>Times should be Universal Time Coordinated (UTC)</li><li>Must not conflict with the preferred maintenance window</li><li>Must be at least 2 hours</li> </ul> </li>
|
660 |
+
* <li><code>PreferredMaintenanceWindow</code> - <code>string</code> - Optional - The weekly time range (in UTC) during which system maintenance can occur, which may result in an outage. This change is made immediately. If moving this window to the current time, there must be at least 120 minutes between the current time and end of the window to ensure pending changes are applied. Default: Uses existing setting Format: ddd:hh24:mi-ddd:hh24:mi Valid Days: Mon | Tue | Wed | Thu | Fri | Sat | Sun Constraints: Minimum four-hour period </li>
|
661 |
+
* <li><code>MultiAZ</code> - <code>boolean</code> - Optional - Specifies if the DB Instance is a Multi-AZ deployment. Constraints: Cannot be specified if the DB Instance is a read replica. </li>
|
662 |
+
* <li><code>EngineVersion</code> - <code>string</code> - Optional - The version number of the database engine to upgrade to. For major version upgrades, if a nondefault DB Parameter Group is currently in use, a new DB Parameter Group in the DB Parameter Group Family for the new engine version must be specified. The new DB Parameter Group can be the default for that DB Parameter Group Family. Example: <code>5.1.42</code> </li>
|
663 |
+
* <li><code>AllowMajorVersionUpgrade</code> - <code>boolean</code> - Optional - Indicates that major version upgrades are allowed. Constraints: This parameter must be set to true when specifying a value for the EngineVersion parameter that is a different major version than the DB Instance's current version. </li>
|
664 |
+
* <li><code>AutoMinorVersionUpgrade</code> - <code>boolean</code> - Optional - Indicates that minor version upgrades will be applied automatically to the DB Instance during the maintenance window. </li>
|
665 |
+
* <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>
|
666 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
667 |
+
*/
|
668 |
+
public function modify_db_instance($db_instance_identifier, $opt = null)
|
669 |
+
{
|
670 |
+
if (!$opt) $opt = array();
|
671 |
+
$opt['DBInstanceIdentifier'] = $db_instance_identifier;
|
672 |
+
|
673 |
+
// Optional parameter
|
674 |
+
if (isset($opt['DBSecurityGroups']))
|
675 |
+
{
|
676 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
677 |
+
'DBSecurityGroups' => (is_array($opt['DBSecurityGroups']) ? $opt['DBSecurityGroups'] : array($opt['DBSecurityGroups']))
|
678 |
+
), 'member'));
|
679 |
+
unset($opt['DBSecurityGroups']);
|
680 |
+
}
|
681 |
+
|
682 |
+
return $this->authenticate('ModifyDBInstance', $opt, $this->hostname);
|
683 |
+
}
|
684 |
+
|
685 |
+
/**
|
686 |
+
*
|
687 |
+
* This API creates a new DB Instance to an arbitrary point-in-time. Users can restore to any point in time before the
|
688 |
+
* latestRestorableTime for up to backupRetentionPeriod days. The target database is created from the source database with
|
689 |
+
* the same configuration as the original database except that the DB instance is created with the default DB security
|
690 |
+
* group.
|
691 |
+
*
|
692 |
+
* @param string $db_instance_identifier (Required) The identifier for the DB Snapshot to restore from. Constraints: <ul> <li>Must contain from 1 to 63 alphanumeric characters or hyphens</li><li>First character must be a letter</li><li>Cannot end with a hyphen or contain two consecutive hyphens</li> </ul>
|
693 |
+
* @param string $db_snapshot_identifier (Required) Name of the DB Instance to create from the DB Snapshot. This parameter isn't case sensitive. Constraints: <ul> <li>Must contain from 1 to 255 alphanumeric characters or hyphens</li><li>First character must be a letter</li><li>Cannot end with a hyphen or contain two consecutive hyphens</li> </ul> Example: <code>my-snapshot-id</code>
|
694 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
695 |
+
* <li><code>DBInstanceClass</code> - <code>string</code> - Optional - The compute and memory capacity of the Amazon RDS DB instance. Valid Values: <code>db.m1.small | db.m1.large | db.m1.xlarge | db.m2.2xlarge | db.m2.4xlarge</code> </li>
|
696 |
+
* <li><code>Port</code> - <code>integer</code> - Optional - The port number on which the database accepts connections. Default: The same port as the original DB Instance Constraints: Value must be <code>1115-65535</code> </li>
|
697 |
+
* <li><code>AvailabilityZone</code> - <code>string</code> - Optional - The EC2 Availability Zone that the database instance will be created in. Default: A random, system-chosen Availability Zone. Constraint: You cannot specify the AvailabilityZone parameter if the MultiAZ parameter is set to <code>true</code>. Example: <code>us-east-1a</code> </li>
|
698 |
+
* <li><code>MultiAZ</code> - <code>boolean</code> - Optional - Specifies if the DB Instance is a Multi-AZ deployment. Constraint: You cannot specify the AvailabilityZone parameter if the MultiAZ parameter is set to <code>true</code>. </li>
|
699 |
+
* <li><code>AutoMinorVersionUpgrade</code> - <code>boolean</code> - Optional - Indicates that minor version upgrades will be applied automatically to the DB Instance during the maintenance window. </li>
|
700 |
+
* <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>
|
701 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
702 |
+
*/
|
703 |
+
public function restore_db_instance_from_db_snapshot($db_instance_identifier, $db_snapshot_identifier, $opt = null)
|
704 |
+
{
|
705 |
+
if (!$opt) $opt = array();
|
706 |
+
$opt['DBInstanceIdentifier'] = $db_instance_identifier;
|
707 |
+
$opt['DBSnapshotIdentifier'] = $db_snapshot_identifier;
|
708 |
+
|
709 |
+
return $this->authenticate('RestoreDBInstanceFromDBSnapshot', $opt, $this->hostname);
|
710 |
+
}
|
711 |
+
|
712 |
+
/**
|
713 |
+
*
|
714 |
+
* Returns information about reserved DB Instances for this account, or about a specified reserved DB Instance.
|
715 |
+
*
|
716 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
717 |
+
* <li><code>ReservedDBInstanceId</code> - <code>string</code> - Optional - The reserved DB Instance identifier filter value. Specify this parameter to show only the reservation that matches the specified reservation ID. </li>
|
718 |
+
* <li><code>ReservedDBInstancesOfferingId</code> - <code>string</code> - Optional - The offering identifier filter value. Specify this parameter to show only purchased reservations matching the specified offering identifier. </li>
|
719 |
+
* <li><code>DBInstanceClass</code> - <code>string</code> - Optional - The DB Instance class filter value. Specify this parameter to show only those reservations matching the specified DB Instances class. </li>
|
720 |
+
* <li><code>Duration</code> - <code>string</code> - Optional - The duration filter value, specified in years or seconds. Specify this parameter to show only reservations for this duration. Valid Values: <code>1 | 3 | 31536000 | 94608000</code> </li>
|
721 |
+
* <li><code>ProductDescription</code> - <code>string</code> - Optional - The product description filter value. Specify this parameter to show only those reservations matching the specified product description. </li>
|
722 |
+
* <li><code>MultiAZ</code> - <code>boolean</code> - Optional - The Multi-AZ filter value. Specify this parameter to show only those reservations matching the specified Multi-AZ parameter. </li>
|
723 |
+
* <li><code>MaxRecords</code> - <code>integer</code> - Optional - The maximum number of records to include in the response. If more than the <code>MaxRecords</code> value is available, a marker is included in the response so that the following results can be retrieved. Default: 100 Constraints: minimum 20, maximum 100 </li>
|
724 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - The marker provided in the previous request. If this parameter is specified, the response includes records beyond the marker only, up to <code>MaxRecords</code>. </li>
|
725 |
+
* <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>
|
726 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
727 |
+
*/
|
728 |
+
public function describe_reserved_db_instances($opt = null)
|
729 |
+
{
|
730 |
+
if (!$opt) $opt = array();
|
731 |
+
|
732 |
+
return $this->authenticate('DescribeReservedDBInstances', $opt, $this->hostname);
|
733 |
+
}
|
734 |
+
|
735 |
+
/**
|
736 |
+
*
|
737 |
+
* This API creates a new database parameter group.
|
738 |
+
*
|
739 |
+
* @param string $db_parameter_group_name (Required) The name of the DB Parameter Group. Constraints: <ul> <li>Must be 1 to 255 alphanumeric characters</li><li>First character must be a letter</li><li>Cannot end with a hyphen or contain two consecutive hyphens</li> </ul> This value is stored as a lower-case string.
|
740 |
+
* @param string $db_parameter_group_family (Required) The DB parameter group family name. A DB parameter group can be associated with one and only one DB parameter group family, and can be applied only to a DB instance running a database engine compatible with that DB parameter group family and version. Valid Values: <code>MySQL5.1</code> | <code>MySQL5.5</code>
|
741 |
+
* @param string $description (Required) The description for the DB Parameter Group.
|
742 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
743 |
+
* <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>
|
744 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
745 |
+
*/
|
746 |
+
public function create_db_parameter_group($db_parameter_group_name, $db_parameter_group_family, $description, $opt = null)
|
747 |
+
{
|
748 |
+
if (!$opt) $opt = array();
|
749 |
+
$opt['DBParameterGroupName'] = $db_parameter_group_name;
|
750 |
+
$opt['DBParameterGroupFamily'] = $db_parameter_group_family;
|
751 |
+
$opt['Description'] = $description;
|
752 |
+
|
753 |
+
return $this->authenticate('CreateDBParameterGroup', $opt, $this->hostname);
|
754 |
+
}
|
755 |
+
|
756 |
+
/**
|
757 |
+
*
|
758 |
+
* This API deletes a database security group.
|
759 |
+
*
|
760 |
+
* The specified database security group must not be associated with any DB instances.
|
761 |
+
*
|
762 |
+
* @param string $db_security_group_name (Required) The name of the database security group to delete. You cannot delete the default security group. Constraints: <ul> <li>Must be 1 to 255 alphanumeric characters</li><li>First character must be a letter</li><li>Cannot end with a hyphen or contain two consecutive hyphens</li> </ul>
|
763 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
764 |
+
* <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>
|
765 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
766 |
+
*/
|
767 |
+
public function delete_db_security_group($db_security_group_name, $opt = null)
|
768 |
+
{
|
769 |
+
if (!$opt) $opt = array();
|
770 |
+
$opt['DBSecurityGroupName'] = $db_security_group_name;
|
771 |
+
|
772 |
+
return $this->authenticate('DeleteDBSecurityGroup', $opt, $this->hostname);
|
773 |
+
}
|
774 |
+
|
775 |
+
/**
|
776 |
+
*
|
777 |
+
* Creates a DB Instance that acts as a Read Replica of a source DB Instance.
|
778 |
+
*
|
779 |
+
* All Read Replica DB Instances are created as Single-AZ deployments with backups disabled. All other DB Instance
|
780 |
+
* attributes (including DB Security Groups and DB Parameter Groups) are inherited from the source DB Instance, except as
|
781 |
+
* specified below.
|
782 |
+
*
|
783 |
+
* The source DB Instance must have backup retention enabled.
|
784 |
+
*
|
785 |
+
* @param string $db_instance_identifier (Required) The DB Instance identifier of the Read Replica. This is the unique key that identifies a DB Instance. This parameter is stored as a lowercase string.
|
786 |
+
* @param string $source_db_instance_identifier (Required) The identifier of the DB Instance that will act as the source for the Read Replica. Each DB Instance can have up to five Read Replicas. Constraints: Must be the identifier of an existing DB Instance that is not already a Read Replica DB Instance.
|
787 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
788 |
+
* <li><code>DBInstanceClass</code> - <code>string</code> - Optional - The compute and memory capacity of the Read Replica. Valid Values: <code>db.m1.small | db.m1.large | db.m1.xlarge | db.m2.xlarge |db.m2.2xlarge | db.m2.4xlarge</code> Default: Inherits from the source DB Instance. </li>
|
789 |
+
* <li><code>AvailabilityZone</code> - <code>string</code> - Optional - The Amazon EC2 Availability Zone that the Read Replica will be created in. Default: A random, system-chosen Availability Zone in the endpoint's region. Example: <code>us-east-1d</code> </li>
|
790 |
+
* <li><code>Port</code> - <code>integer</code> - Optional - The port number that the DB Instance uses for connections. Default: Inherits from the source DB Instance Valid Values: <code>1150-65535</code> </li>
|
791 |
+
* <li><code>AutoMinorVersionUpgrade</code> - <code>boolean</code> - Optional - Indicates that minor engine upgrades will be applied automatically to the Read Replica during the maintenance window. Default: Inherits from the source DB Instance </li>
|
792 |
+
* <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>
|
793 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
794 |
+
*/
|
795 |
+
public function create_db_instance_read_replica($db_instance_identifier, $source_db_instance_identifier, $opt = null)
|
796 |
+
{
|
797 |
+
if (!$opt) $opt = array();
|
798 |
+
$opt['DBInstanceIdentifier'] = $db_instance_identifier;
|
799 |
+
$opt['SourceDBInstanceIdentifier'] = $source_db_instance_identifier;
|
800 |
+
|
801 |
+
return $this->authenticate('CreateDBInstanceReadReplica', $opt, $this->hostname);
|
802 |
+
}
|
803 |
+
|
804 |
+
/**
|
805 |
+
*
|
806 |
+
* Purchases a reserved DB Instance offering.
|
807 |
+
*
|
808 |
+
* @param string $reserved_db_instances_offering_id (Required) The ID of the Reserved DB Instance offering to purchase. Example: 438012d3-4052-4cc7-b2e3-8d3372e0e706
|
809 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
810 |
+
* <li><code>ReservedDBInstanceId</code> - <code>string</code> - Optional - Customer-specified identifier to track this reservation. Example: myreservationID </li>
|
811 |
+
* <li><code>DBInstanceCount</code> - <code>integer</code> - Optional - The number of instances to reserve. Default: <code>1</code> </li>
|
812 |
+
* <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>
|
813 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
814 |
+
*/
|
815 |
+
public function purchase_reserved_db_instances_offering($reserved_db_instances_offering_id, $opt = null)
|
816 |
+
{
|
817 |
+
if (!$opt) $opt = array();
|
818 |
+
$opt['ReservedDBInstancesOfferingId'] = $reserved_db_instances_offering_id;
|
819 |
+
|
820 |
+
return $this->authenticate('PurchaseReservedDBInstancesOffering', $opt, $this->hostname);
|
821 |
+
}
|
822 |
+
}
|
823 |
+
|
824 |
+
|
825 |
+
/*%******************************************************************************************%*/
|
826 |
+
// EXCEPTIONS
|
827 |
+
|
828 |
+
/**
|
829 |
+
* Default RDS Exception.
|
830 |
+
*/
|
831 |
+
class RDS_Exception extends Exception {}
|
app/libs/aws/services/s3.class.php
ADDED
@@ -0,0 +1,3309 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
// EXCEPTIONS
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Default S3 Exception.
|
23 |
+
*/
|
24 |
+
class S3_Exception extends Exception {}
|
25 |
+
|
26 |
+
|
27 |
+
/*%******************************************************************************************%*/
|
28 |
+
// MAIN CLASS
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Amazon S3 is a web service that enables you to store data in the cloud. You can then download the data
|
32 |
+
* or use the data with other AWS services, such as Amazon Elastic Cloud Computer (EC2).
|
33 |
+
*
|
34 |
+
* Amazon Simple Storage Service (Amazon S3) is storage for the Internet. You can use Amazon S3 to store
|
35 |
+
* and retrieve any amount of data at any time, from anywhere on the web. You can accomplish these tasks
|
36 |
+
* using the AWS Management Console, which is a simple and intuitive web interface.
|
37 |
+
*
|
38 |
+
* To get the most out of Amazon S3, you need to understand a few simple concepts. Amazon S3 stores data
|
39 |
+
* as objects in buckets. An object is comprised of a file and optionally any metadata that describes
|
40 |
+
* that file.
|
41 |
+
*
|
42 |
+
* To store an object in Amazon S3, you upload the file you want to store to a bucket. When you upload a
|
43 |
+
* file, you can set permissions on the object as well as any metadata.
|
44 |
+
*
|
45 |
+
* Buckets are the containers for objects. You can have one or more buckets. For each bucket, you can control
|
46 |
+
* access to the bucket (who can create, delete, and list objects in the bucket), view access logs for the
|
47 |
+
* bucket and its objects, and choose the geographical region where Amazon S3 will store the bucket and its
|
48 |
+
* contents.
|
49 |
+
*
|
50 |
+
* Visit <http://aws.amazon.com/s3/> for more information.
|
51 |
+
*
|
52 |
+
* @version 2011.02.16
|
53 |
+
* @license See the included NOTICE.md file for more information.
|
54 |
+
* @copyright See the included NOTICE.md file for more information.
|
55 |
+
* @link http://aws.amazon.com/s3/ Amazon Simple Storage Service
|
56 |
+
* @link http://aws.amazon.com/documentation/s3/ Amazon Simple Storage Service documentation
|
57 |
+
*/
|
58 |
+
class AmazonS3 extends CFRuntime
|
59 |
+
{
|
60 |
+
/*%******************************************************************************************%*/
|
61 |
+
// CLASS CONSTANTS
|
62 |
+
|
63 |
+
/**
|
64 |
+
* The default endpoint.
|
65 |
+
*/
|
66 |
+
const DEFAULT_URL = 's3.amazonaws.com';
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Specify the queue URL for the US-East (Northern Virginia) Region.
|
70 |
+
*/
|
71 |
+
const REGION_US_E1 = '';
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Specify the queue URL for the US-West (Northern California) Region.
|
75 |
+
*/
|
76 |
+
const REGION_US_W1 = 'us-west-1';
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Specify the queue URL for the EU (Ireland) Region.
|
80 |
+
*/
|
81 |
+
const REGION_EU_W1 = 'EU';
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Specify the queue URL for the Asia Pacific (Singapore) Region.
|
85 |
+
*/
|
86 |
+
const REGION_APAC_SE1 = 'ap-southeast-1';
|
87 |
+
|
88 |
+
/**
|
89 |
+
* ACL: Owner-only read/write.
|
90 |
+
*/
|
91 |
+
const ACL_PRIVATE = 'private';
|
92 |
+
|
93 |
+
/**
|
94 |
+
* ACL: Owner read/write, public read.
|
95 |
+
*/
|
96 |
+
const ACL_PUBLIC = 'public-read';
|
97 |
+
|
98 |
+
/**
|
99 |
+
* ACL: Public read/write.
|
100 |
+
*/
|
101 |
+
const ACL_OPEN = 'public-read-write';
|
102 |
+
|
103 |
+
/**
|
104 |
+
* ACL: Owner read/write, authenticated read.
|
105 |
+
*/
|
106 |
+
const ACL_AUTH_READ = 'authenticated-read';
|
107 |
+
|
108 |
+
/**
|
109 |
+
* ACL: Bucket owner read.
|
110 |
+
*/
|
111 |
+
const ACL_OWNER_READ = 'bucket-owner-read';
|
112 |
+
|
113 |
+
/**
|
114 |
+
* ACL: Bucket owner full control.
|
115 |
+
*/
|
116 |
+
const ACL_OWNER_FULL_CONTROL = 'bucket-owner-full-control';
|
117 |
+
|
118 |
+
/**
|
119 |
+
* When applied to a bucket, grants permission to list the bucket. When applied to an object, this
|
120 |
+
* grants permission to read the object data and/or metadata.
|
121 |
+
*/
|
122 |
+
const GRANT_READ = 'READ';
|
123 |
+
|
124 |
+
/**
|
125 |
+
* When applied to a bucket, grants permission to create, overwrite, and delete any object in the
|
126 |
+
* bucket. This permission is not supported for objects.
|
127 |
+
*/
|
128 |
+
const GRANT_WRITE = 'WRITE';
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Grants permission to read the ACL for the applicable bucket or object. The owner of a bucket or
|
132 |
+
* object always has this permission implicitly.
|
133 |
+
*/
|
134 |
+
const GRANT_READ_ACP = 'READ_ACP';
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Gives permission to overwrite the ACP for the applicable bucket or object. The owner of a bucket
|
138 |
+
* or object always has this permission implicitly. Granting this permission is equivalent to granting
|
139 |
+
* FULL_CONTROL because the grant recipient can make any changes to the ACP.
|
140 |
+
*/
|
141 |
+
const GRANT_WRITE_ACP = 'WRITE_ACP';
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Provides READ, WRITE, READ_ACP, and WRITE_ACP permissions. It does not convey additional rights and
|
145 |
+
* is provided only for convenience.
|
146 |
+
*/
|
147 |
+
const GRANT_FULL_CONTROL = 'FULL_CONTROL';
|
148 |
+
|
149 |
+
/**
|
150 |
+
* The "AuthenticatedUsers" group for access control policies.
|
151 |
+
*/
|
152 |
+
const USERS_AUTH = 'http://acs.amazonaws.com/groups/global/AuthenticatedUsers';
|
153 |
+
|
154 |
+
/**
|
155 |
+
* The "AllUsers" group for access control policies.
|
156 |
+
*/
|
157 |
+
const USERS_ALL = 'http://acs.amazonaws.com/groups/global/AllUsers';
|
158 |
+
|
159 |
+
/**
|
160 |
+
* The "LogDelivery" group for access control policies.
|
161 |
+
*/
|
162 |
+
const USERS_LOGGING = 'http://acs.amazonaws.com/groups/s3/LogDelivery';
|
163 |
+
|
164 |
+
/**
|
165 |
+
* PCRE: Match all items
|
166 |
+
*/
|
167 |
+
const PCRE_ALL = '/.*/i';
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Standard storage redundancy.
|
171 |
+
*/
|
172 |
+
const STORAGE_STANDARD = 'STANDARD';
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Reduced storage redundancy.
|
176 |
+
*/
|
177 |
+
const STORAGE_REDUCED = 'REDUCED_REDUNDANCY';
|
178 |
+
|
179 |
+
|
180 |
+
/*%******************************************************************************************%*/
|
181 |
+
// PROPERTIES
|
182 |
+
|
183 |
+
/**
|
184 |
+
* The request URL.
|
185 |
+
*/
|
186 |
+
public $request_url;
|
187 |
+
|
188 |
+
/**
|
189 |
+
* The virtual host setting.
|
190 |
+
*/
|
191 |
+
public $vhost;
|
192 |
+
|
193 |
+
/**
|
194 |
+
* The base XML elements to use for access control policy methods.
|
195 |
+
*/
|
196 |
+
public $base_acp_xml;
|
197 |
+
|
198 |
+
/**
|
199 |
+
* The base XML elements to use for logging methods.
|
200 |
+
*/
|
201 |
+
public $base_logging_xml;
|
202 |
+
|
203 |
+
/**
|
204 |
+
* The base XML elements to use for notifications.
|
205 |
+
*/
|
206 |
+
public $base_notification_xml;
|
207 |
+
|
208 |
+
/**
|
209 |
+
* The base XML elements to use for versioning.
|
210 |
+
*/
|
211 |
+
public $base_versioning_xml;
|
212 |
+
|
213 |
+
/**
|
214 |
+
* The base XML elements to use for completing a multipart upload.
|
215 |
+
*/
|
216 |
+
public $complete_mpu_xml;
|
217 |
+
|
218 |
+
/**
|
219 |
+
* The base XML elements to use for website support.
|
220 |
+
*/
|
221 |
+
public $website_config_xml;
|
222 |
+
|
223 |
+
/**
|
224 |
+
* The DNS vs. Path-style setting.
|
225 |
+
*/
|
226 |
+
public $path_style = false;
|
227 |
+
|
228 |
+
/**
|
229 |
+
* The state of whether the prefix change is temporary or permanent.
|
230 |
+
*/
|
231 |
+
public $temporary_prefix = false;
|
232 |
+
|
233 |
+
|
234 |
+
/*%******************************************************************************************%*/
|
235 |
+
// CONSTRUCTOR
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Constructs a new instance of this class.
|
239 |
+
*
|
240 |
+
* @param string $key (Optional) Amazon API Key. If blank, the `AWS_KEY` constant is used.
|
241 |
+
* @param string $secret_key (Optional) Amazon API Secret Key. If blank, the `AWS_SECRET_KEY` constant is used.
|
242 |
+
* @return boolean A value of <code>false</code> if no valid values are set, otherwise <code>true</code>.
|
243 |
+
*/
|
244 |
+
public function __construct($key = null, $secret_key = null)
|
245 |
+
{
|
246 |
+
$this->vhost = null;
|
247 |
+
$this->api_version = '2006-03-01';
|
248 |
+
$this->hostname = self::DEFAULT_URL;
|
249 |
+
|
250 |
+
$this->base_acp_xml = '<?xml version="1.0" encoding="UTF-8"?><AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/latest/"></AccessControlPolicy>';
|
251 |
+
$this->base_location_constraint = '<?xml version="1.0" encoding="UTF-8"?><CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/' . $this->api_version . '/"><LocationConstraint></LocationConstraint></CreateBucketConfiguration>';
|
252 |
+
$this->base_logging_xml = '<?xml version="1.0" encoding="utf-8"?><BucketLoggingStatus xmlns="http://doc.s3.amazonaws.com/' . $this->api_version . '"></BucketLoggingStatus>';
|
253 |
+
$this->base_notification_xml = '<?xml version="1.0" encoding="utf-8"?><NotificationConfiguration></NotificationConfiguration>';
|
254 |
+
$this->base_versioning_xml = '<?xml version="1.0" encoding="utf-8"?><VersioningConfiguration xmlns="http://s3.amazonaws.com/doc/' . $this->api_version . '/"></VersioningConfiguration>';
|
255 |
+
$this->complete_mpu_xml = '<?xml version="1.0" encoding="utf-8"?><CompleteMultipartUpload></CompleteMultipartUpload>';
|
256 |
+
$this->website_config_xml = '<?xml version="1.0" encoding="utf-8"?><WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/' . $this->api_version . '/"><IndexDocument><Suffix>index.html</Suffix></IndexDocument><ErrorDocument><Key>error.html</Key></ErrorDocument></WebsiteConfiguration>';
|
257 |
+
|
258 |
+
if (!$key && !defined('AWS_KEY'))
|
259 |
+
{
|
260 |
+
throw new S3_Exception('No account key was passed into the constructor, nor was it set in the AWS_KEY constant.');
|
261 |
+
}
|
262 |
+
|
263 |
+
if (!$secret_key && !defined('AWS_SECRET_KEY'))
|
264 |
+
{
|
265 |
+
throw new S3_Exception('No account secret was passed into the constructor, nor was it set in the AWS_SECRET_KEY constant.');
|
266 |
+
}
|
267 |
+
|
268 |
+
return parent::__construct($key, $secret_key);
|
269 |
+
}
|
270 |
+
|
271 |
+
|
272 |
+
/*%******************************************************************************************%*/
|
273 |
+
// AUTHENTICATION
|
274 |
+
|
275 |
+
/**
|
276 |
+
* Authenticates a connection to Amazon S3. Do not use directly unless implementing custom methods for
|
277 |
+
* this class.
|
278 |
+
*
|
279 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
280 |
+
* @param array $opt (Optional) An associative array of parameters for authenticating. See the individual methods for allowed keys.
|
281 |
+
* @param string $location (Do Not Use) Used internally by this function on occasions when Amazon S3 returns a redirect code and it needs to call itself recursively.
|
282 |
+
* @param integer $redirects (Do Not Use) Used internally by this function on occasions when Amazon S3 returns a redirect code and it needs to call itself recursively.
|
283 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
284 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/RESTAuthentication.html REST authentication
|
285 |
+
*/
|
286 |
+
public function authenticate($bucket, $opt = null, $location = null, $redirects = 0, $nothing = null)
|
287 |
+
{
|
288 |
+
/*
|
289 |
+
* Overriding or extending this class? You can pass the following "magic" keys into $opt.
|
290 |
+
*
|
291 |
+
* ## verb, resource, sub_resource and query_string ##
|
292 |
+
* <verb> /<resource>?<sub_resource>&<query_string>
|
293 |
+
* GET /filename.txt?versions&prefix=abc&max-items=1
|
294 |
+
*
|
295 |
+
* ## versionId, uploadId, partNumber, response-* ##
|
296 |
+
* These don't follow the same rules as above, in that the they needs to be signed, while
|
297 |
+
* other query_string values do not.
|
298 |
+
*
|
299 |
+
* ## curlopts ##
|
300 |
+
* These values get passed directly to the cURL methods in RequestCore.
|
301 |
+
*
|
302 |
+
* ## fileUpload, fileDownload, seekTo ##
|
303 |
+
* These are slightly modified and then passed to the cURL methods in RequestCore.
|
304 |
+
*
|
305 |
+
* ## headers ##
|
306 |
+
* $opt['headers'] is an array, whose keys are HTTP headers to be sent.
|
307 |
+
*
|
308 |
+
* ## body ##
|
309 |
+
* This is the request body that is sent to the server via PUT/POST.
|
310 |
+
*
|
311 |
+
* ## preauth ##
|
312 |
+
* This is a hook that tells authenticate() to generate a pre-authenticated URL.
|
313 |
+
*
|
314 |
+
* ## returnCurlHandle ##
|
315 |
+
* Tells authenticate() to return the cURL handle for the request instead of executing it.
|
316 |
+
*/
|
317 |
+
|
318 |
+
/**
|
319 |
+
* @todo: Handle duplicate headers with different values.
|
320 |
+
*/
|
321 |
+
|
322 |
+
// Validate the S3 bucket name
|
323 |
+
if (!$this->validate_bucketname_support($bucket))
|
324 |
+
{
|
325 |
+
throw new S3_Exception('S3 does not support "' . $bucket . '" as a valid bucket name. Review "Bucket Restrictions and Limitations" in the S3 Developer Guide for more information.');
|
326 |
+
}
|
327 |
+
|
328 |
+
// Die if $opt isn't set.
|
329 |
+
if (!$opt) return false;
|
330 |
+
|
331 |
+
$method_arguments = func_get_args();
|
332 |
+
|
333 |
+
// Use the caching flow to determine if we need to do a round-trip to the server.
|
334 |
+
if ($this->use_cache_flow)
|
335 |
+
{
|
336 |
+
// Generate an identifier specific to this particular set of arguments.
|
337 |
+
$cache_id = $this->key . '_' . get_class($this) . '_' . $bucket . '_' . sha1(serialize($method_arguments));
|
338 |
+
|
339 |
+
// Instantiate the appropriate caching object.
|
340 |
+
$this->cache_object = new $this->cache_class($cache_id, $this->cache_location, $this->cache_expires, $this->cache_compress);
|
341 |
+
|
342 |
+
if ($this->delete_cache)
|
343 |
+
{
|
344 |
+
$this->use_cache_flow = false;
|
345 |
+
$this->delete_cache = false;
|
346 |
+
return $this->cache_object->delete();
|
347 |
+
}
|
348 |
+
|
349 |
+
// Invoke the cache callback function to determine whether to pull data from the cache or make a fresh request.
|
350 |
+
$data = $this->cache_object->response_manager(array($this, 'cache_callback'), $method_arguments);
|
351 |
+
|
352 |
+
// Parse the XML body
|
353 |
+
$data = $this->parse_callback($data);
|
354 |
+
|
355 |
+
// End!
|
356 |
+
return $data;
|
357 |
+
}
|
358 |
+
|
359 |
+
// If we haven't already set a resource prefix...
|
360 |
+
if (!$this->resource_prefix || $this->path_style)
|
361 |
+
{
|
362 |
+
// And if the bucket name isn't DNS-valid...
|
363 |
+
if (!$this->validate_bucketname_create($bucket))
|
364 |
+
{
|
365 |
+
// Fall back to the older path-style URI
|
366 |
+
$this->set_resource_prefix('/' . $bucket);
|
367 |
+
$this->temporary_prefix = true;
|
368 |
+
}
|
369 |
+
elseif ($this->path_style)
|
370 |
+
{
|
371 |
+
// Fall back to the older path-style URI
|
372 |
+
$this->set_resource_prefix('/' . $bucket);
|
373 |
+
}
|
374 |
+
}
|
375 |
+
|
376 |
+
// Determine hostname
|
377 |
+
$scheme = $this->use_ssl ? 'https://' : 'http://';
|
378 |
+
if ($this->resource_prefix || $this->path_style) // Use bucket-in-path method.
|
379 |
+
{
|
380 |
+
$hostname = $this->hostname . $this->resource_prefix . (($bucket === '' || $this->resource_prefix === '/' . $bucket) ? '' : ('/' . $bucket));
|
381 |
+
}
|
382 |
+
else
|
383 |
+
{
|
384 |
+
$hostname = $this->vhost ? $this->vhost : (($bucket === '') ? $this->hostname : ($bucket . '.') . $this->hostname);
|
385 |
+
}
|
386 |
+
|
387 |
+
// Get the UTC timestamp in RFC 2616 format
|
388 |
+
$date = gmdate($this->util->konst($this->util, 'DATE_FORMAT_RFC2616'), (time() + (integer) $this->adjust_offset));
|
389 |
+
|
390 |
+
// Storage for request parameters.
|
391 |
+
$resource = '';
|
392 |
+
$sub_resource = '';
|
393 |
+
$querystringparams = array();
|
394 |
+
$signable_querystringparams = array();
|
395 |
+
$string_to_sign = '';
|
396 |
+
$headers = array(
|
397 |
+
'Content-MD5' => '',
|
398 |
+
'Content-Type' => 'application/x-www-form-urlencoded',
|
399 |
+
'Date' => $date
|
400 |
+
);
|
401 |
+
|
402 |
+
/*%******************************************************************************************%*/
|
403 |
+
|
404 |
+
// Handle specific resources
|
405 |
+
if (isset($opt['resource']))
|
406 |
+
{
|
407 |
+
$resource .= $opt['resource'];
|
408 |
+
}
|
409 |
+
|
410 |
+
// Merge query string values
|
411 |
+
if (isset($opt['query_string']))
|
412 |
+
{
|
413 |
+
$querystringparams = array_merge($querystringparams, $opt['query_string']);
|
414 |
+
}
|
415 |
+
$query_string = $this->util->to_query_string($querystringparams);
|
416 |
+
|
417 |
+
// Merge the signable query string values. Must be alphabetical.
|
418 |
+
$signable_list = array(
|
419 |
+
'partNumber',
|
420 |
+
'response-cache-control',
|
421 |
+
'response-content-disposition',
|
422 |
+
'response-content-encoding',
|
423 |
+
'response-content-language',
|
424 |
+
'response-content-type',
|
425 |
+
'response-expires',
|
426 |
+
'uploadId',
|
427 |
+
'versionId'
|
428 |
+
);
|
429 |
+
foreach ($signable_list as $item)
|
430 |
+
{
|
431 |
+
if (isset($opt[$item]))
|
432 |
+
{
|
433 |
+
$signable_querystringparams[$item] = $opt[$item];
|
434 |
+
}
|
435 |
+
}
|
436 |
+
$signable_query_string = $this->util->to_query_string($signable_querystringparams);
|
437 |
+
|
438 |
+
// Merge the HTTP headers
|
439 |
+
if (isset($opt['headers']))
|
440 |
+
{
|
441 |
+
$headers = array_merge($headers, $opt['headers']);
|
442 |
+
}
|
443 |
+
|
444 |
+
// Compile the URI to request
|
445 |
+
$conjunction = '?';
|
446 |
+
$signable_resource = '/' . str_replace('%2F', '/', rawurlencode($resource));
|
447 |
+
$non_signable_resource = '';
|
448 |
+
|
449 |
+
if (isset($opt['sub_resource']))
|
450 |
+
{
|
451 |
+
$signable_resource .= $conjunction . rawurlencode($opt['sub_resource']);
|
452 |
+
$conjunction = '&';
|
453 |
+
}
|
454 |
+
if ($signable_query_string !== '')
|
455 |
+
{
|
456 |
+
$signable_query_string = $conjunction . $signable_query_string;
|
457 |
+
$conjunction = '&';
|
458 |
+
}
|
459 |
+
if ($query_string !== '')
|
460 |
+
{
|
461 |
+
$non_signable_resource .= $conjunction . $query_string;
|
462 |
+
$conjunction = '&';
|
463 |
+
}
|
464 |
+
$this->request_url = $scheme . $hostname . $signable_resource . $signable_query_string . $non_signable_resource;
|
465 |
+
|
466 |
+
// Instantiate the request class
|
467 |
+
$request = new $this->request_class($this->request_url, $this->proxy);
|
468 |
+
|
469 |
+
// Update RequestCore settings
|
470 |
+
$request->request_class = $this->request_class;
|
471 |
+
$request->response_class = $this->response_class;
|
472 |
+
|
473 |
+
// Streaming uploads
|
474 |
+
if (isset($opt['fileUpload']))
|
475 |
+
{
|
476 |
+
if (is_resource($opt['fileUpload']))
|
477 |
+
{
|
478 |
+
// Determine the length to read from the stream
|
479 |
+
$length = null; // From current position until EOF by default, size determined by set_read_stream()
|
480 |
+
|
481 |
+
if (isset($headers['Content-Length']))
|
482 |
+
{
|
483 |
+
$length = $headers['Content-Length'];
|
484 |
+
}
|
485 |
+
elseif (isset($opt['seekTo']))
|
486 |
+
{
|
487 |
+
// Read from seekTo until EOF by default
|
488 |
+
$stats = fstat($opt['fileUpload']);
|
489 |
+
|
490 |
+
if ($stats && $stats['size'] >= 0)
|
491 |
+
{
|
492 |
+
$length = $stats['size'] - (integer) $opt['seekTo'];
|
493 |
+
}
|
494 |
+
}
|
495 |
+
|
496 |
+
$request->set_read_stream($opt['fileUpload'], $length);
|
497 |
+
|
498 |
+
if ($headers['Content-Type'] === 'application/x-www-form-urlencoded')
|
499 |
+
{
|
500 |
+
$headers['Content-Type'] = 'application/octet-stream';
|
501 |
+
}
|
502 |
+
}
|
503 |
+
else
|
504 |
+
{
|
505 |
+
$request->set_read_file($opt['fileUpload']);
|
506 |
+
|
507 |
+
// Determine the length to read from the file
|
508 |
+
$length = $request->read_stream_size; // The file size by default
|
509 |
+
|
510 |
+
if (isset($headers['Content-Length']))
|
511 |
+
{
|
512 |
+
$length = $headers['Content-Length'];
|
513 |
+
}
|
514 |
+
elseif (isset($opt['seekTo']) && isset($length))
|
515 |
+
{
|
516 |
+
// Read from seekTo until EOF by default
|
517 |
+
$length -= (integer) $opt['seekTo'];
|
518 |
+
}
|
519 |
+
|
520 |
+
$request->set_read_stream_size($length);
|
521 |
+
|
522 |
+
// Attempt to guess the correct mime-type
|
523 |
+
if ($headers['Content-Type'] === 'application/x-www-form-urlencoded')
|
524 |
+
{
|
525 |
+
$extension = explode('.', $opt['fileUpload']);
|
526 |
+
$extension = array_pop($extension);
|
527 |
+
$mime_type = CFMimeTypes::get_mimetype($extension);
|
528 |
+
$headers['Content-Type'] = $mime_type;
|
529 |
+
}
|
530 |
+
}
|
531 |
+
|
532 |
+
$headers['Content-Length'] = $request->read_stream_size;
|
533 |
+
$headers['Content-MD5'] = '';
|
534 |
+
}
|
535 |
+
|
536 |
+
// Handle streaming file offsets
|
537 |
+
if (isset($opt['seekTo']))
|
538 |
+
{
|
539 |
+
// Pass the seek position to RequestCore
|
540 |
+
$request->set_seek_position((integer) $opt['seekTo']);
|
541 |
+
}
|
542 |
+
|
543 |
+
// Streaming downloads
|
544 |
+
if (isset($opt['fileDownload']))
|
545 |
+
{
|
546 |
+
if (is_resource($opt['fileDownload']))
|
547 |
+
{
|
548 |
+
$request->set_write_stream($opt['fileDownload']);
|
549 |
+
}
|
550 |
+
else
|
551 |
+
{
|
552 |
+
$request->set_write_file($opt['fileDownload']);
|
553 |
+
}
|
554 |
+
}
|
555 |
+
|
556 |
+
$curlopts = array();
|
557 |
+
|
558 |
+
// Set custom CURLOPT settings
|
559 |
+
if (isset($opt['curlopts']))
|
560 |
+
{
|
561 |
+
$curlopts = $opt['curlopts'];
|
562 |
+
unset($opt['curlopts']);
|
563 |
+
}
|
564 |
+
|
565 |
+
// Debug mode
|
566 |
+
if ($this->debug_mode)
|
567 |
+
{
|
568 |
+
$curlopts[CURLOPT_VERBOSE] = true;
|
569 |
+
}
|
570 |
+
|
571 |
+
// Set the curl options.
|
572 |
+
if (count($curlopts))
|
573 |
+
{
|
574 |
+
$request->set_curlopts($curlopts);
|
575 |
+
}
|
576 |
+
|
577 |
+
// Do we have a verb?
|
578 |
+
if (isset($opt['verb']))
|
579 |
+
{
|
580 |
+
$request->set_method($opt['verb']);
|
581 |
+
$string_to_sign .= $opt['verb'] . "\n";
|
582 |
+
}
|
583 |
+
|
584 |
+
// Add headers and content when we have a body
|
585 |
+
if (isset($opt['body']))
|
586 |
+
{
|
587 |
+
$request->set_body($opt['body']);
|
588 |
+
$headers['Content-Length'] = strlen($opt['body']);
|
589 |
+
|
590 |
+
if ($headers['Content-Type'] === 'application/x-www-form-urlencoded')
|
591 |
+
{
|
592 |
+
$headers['Content-Type'] = 'application/octet-stream';
|
593 |
+
}
|
594 |
+
|
595 |
+
if (!isset($opt['NoContentMD5']) || $opt['NoContentMD5'] !== true)
|
596 |
+
{
|
597 |
+
$headers['Content-MD5'] = $this->util->hex_to_base64(md5($opt['body']));
|
598 |
+
}
|
599 |
+
}
|
600 |
+
|
601 |
+
// Handle query-string authentication
|
602 |
+
if (isset($opt['preauth']) && (integer) $opt['preauth'] > 0)
|
603 |
+
{
|
604 |
+
unset($headers['Date']);
|
605 |
+
$headers['Content-Type'] = '';
|
606 |
+
$headers['Expires'] = is_int($opt['preauth']) ? $opt['preauth'] : strtotime($opt['preauth']);
|
607 |
+
}
|
608 |
+
|
609 |
+
// Sort headers
|
610 |
+
uksort($headers, 'strnatcasecmp');
|
611 |
+
|
612 |
+
// Add headers to request and compute the string to sign
|
613 |
+
foreach ($headers as $header_key => $header_value)
|
614 |
+
{
|
615 |
+
// Strip linebreaks from header values as they're illegal and can allow for security issues
|
616 |
+
$header_value = str_replace(array("\r", "\n"), '', $header_value);
|
617 |
+
|
618 |
+
// Add the header if it has a value
|
619 |
+
if ($header_value !== '')
|
620 |
+
{
|
621 |
+
$request->add_header($header_key, $header_value);
|
622 |
+
}
|
623 |
+
|
624 |
+
// Generate the string to sign
|
625 |
+
if (
|
626 |
+
strtolower($header_key) === 'content-md5' ||
|
627 |
+
strtolower($header_key) === 'content-type' ||
|
628 |
+
strtolower($header_key) === 'date' ||
|
629 |
+
(strtolower($header_key) === 'expires' && isset($opt['preauth']) && (integer) $opt['preauth'] > 0)
|
630 |
+
)
|
631 |
+
{
|
632 |
+
$string_to_sign .= $header_value . "\n";
|
633 |
+
}
|
634 |
+
elseif (substr(strtolower($header_key), 0, 6) === 'x-amz-')
|
635 |
+
{
|
636 |
+
$string_to_sign .= strtolower($header_key) . ':' . $header_value . "\n";
|
637 |
+
}
|
638 |
+
}
|
639 |
+
|
640 |
+
// Add the signable resource location
|
641 |
+
$string_to_sign .= ($this->resource_prefix ? $this->resource_prefix : '');
|
642 |
+
$string_to_sign .= (($bucket === '' || $this->resource_prefix === '/' . $bucket) ? '' : ('/' . $bucket)) . $signable_resource . urldecode($signable_query_string);
|
643 |
+
|
644 |
+
// Hash the AWS secret key and generate a signature for the request.
|
645 |
+
$signature = base64_encode(hash_hmac('sha1', $string_to_sign, $this->secret_key, true));
|
646 |
+
$request->add_header('Authorization', 'AWS ' . $this->key . ':' . $signature);
|
647 |
+
|
648 |
+
// If we're generating a URL, return certain data to the calling method.
|
649 |
+
if (isset($opt['preauth']) && (integer) $opt['preauth'] > 0)
|
650 |
+
{
|
651 |
+
return $this->request_url . $conjunction . 'AWSAccessKeyId=' . $this->key . '&Expires=' . $headers['Expires'] . '&Signature=' . rawurlencode($signature);
|
652 |
+
}
|
653 |
+
elseif (isset($opt['preauth']))
|
654 |
+
{
|
655 |
+
return $this->request_url;
|
656 |
+
}
|
657 |
+
|
658 |
+
/*%******************************************************************************************%*/
|
659 |
+
|
660 |
+
// If our changes were temporary, reset them.
|
661 |
+
if ($this->temporary_prefix)
|
662 |
+
{
|
663 |
+
$this->temporary_prefix = false;
|
664 |
+
$this->resource_prefix = null;
|
665 |
+
}
|
666 |
+
|
667 |
+
// Manage the (newer) batch request API or the (older) returnCurlHandle setting.
|
668 |
+
if ($this->use_batch_flow)
|
669 |
+
{
|
670 |
+
$handle = $request->prep_request();
|
671 |
+
$this->batch_object->add($handle);
|
672 |
+
$this->use_batch_flow = false;
|
673 |
+
|
674 |
+
return $handle;
|
675 |
+
}
|
676 |
+
elseif (isset($opt['returnCurlHandle']) && $opt['returnCurlHandle'] === true)
|
677 |
+
{
|
678 |
+
return $request->prep_request();
|
679 |
+
}
|
680 |
+
|
681 |
+
// Send!
|
682 |
+
$request->send_request();
|
683 |
+
|
684 |
+
// Prepare the response
|
685 |
+
$headers = $request->get_response_header();
|
686 |
+
$headers['x-aws-request-url'] = $this->request_url;
|
687 |
+
$headers['x-aws-redirects'] = $redirects;
|
688 |
+
$headers['x-aws-stringtosign'] = $string_to_sign;
|
689 |
+
$headers['x-aws-requestheaders'] = $request->request_headers;
|
690 |
+
|
691 |
+
// Did we have a request body?
|
692 |
+
if (isset($opt['body']))
|
693 |
+
{
|
694 |
+
$headers['x-aws-requestbody'] = $opt['body'];
|
695 |
+
}
|
696 |
+
|
697 |
+
$data = new $this->response_class($headers, $this->parse_callback($request->get_response_body()), $request->get_response_code());
|
698 |
+
|
699 |
+
// Did Amazon tell us to redirect? Typically happens for multiple rapid requests EU datacenters.
|
700 |
+
// @see: http://docs.amazonwebservices.com/AmazonS3/latest/Redirects.html
|
701 |
+
if ((integer) $request->get_response_code() === 307) // Temporary redirect to new endpoint.
|
702 |
+
{
|
703 |
+
$data = $this->authenticate($bucket, $opt, $headers['location'], ++$redirects);
|
704 |
+
}
|
705 |
+
|
706 |
+
// Was it Amazon's fault the request failed? Retry the request until we reach $max_retries.
|
707 |
+
elseif ((integer) $request->get_response_code() === 500 || (integer) $request->get_response_code() === 503)
|
708 |
+
{
|
709 |
+
if ($redirects <= $this->max_retries)
|
710 |
+
{
|
711 |
+
// Exponential backoff
|
712 |
+
$delay = (integer) (pow(4, $redirects) * 100000);
|
713 |
+
usleep($delay);
|
714 |
+
$data = $this->authenticate($bucket, $opt, null, ++$redirects);
|
715 |
+
}
|
716 |
+
}
|
717 |
+
|
718 |
+
// Return!
|
719 |
+
return $data;
|
720 |
+
}
|
721 |
+
|
722 |
+
/**
|
723 |
+
* Validates whether or not the specified Amazon S3 bucket name is valid for DNS-style access. This
|
724 |
+
* method is leveraged by any method that creates buckets.
|
725 |
+
*
|
726 |
+
* @param string $bucket (Required) The name of the bucket to validate.
|
727 |
+
* @return boolean Whether or not the specified Amazon S3 bucket name is valid for DNS-style access. A value of <code>true</code> means that the bucket name is valid. A value of <code>false</code> means that the bucket name is invalid.
|
728 |
+
*/
|
729 |
+
public function validate_bucketname_create($bucket)
|
730 |
+
{
|
731 |
+
// list_buckets() uses this. Let it pass.
|
732 |
+
if ($bucket === '') return true;
|
733 |
+
|
734 |
+
if (
|
735 |
+
($bucket === null || $bucket === false) || // Must not be null or false
|
736 |
+
preg_match('/[^(a-z0-9\-\.)]/', $bucket) || // Must be in the lowercase Roman alphabet, period or hyphen
|
737 |
+
!preg_match('/^([a-z]|\d)/', $bucket) || // Must start with a number or letter
|
738 |
+
!(strlen($bucket) >= 3 && strlen($bucket) <= 63) || // Must be between 3 and 63 characters long
|
739 |
+
(strpos($bucket, '..') !== false) || // Bucket names cannot contain two, adjacent periods
|
740 |
+
(strpos($bucket, '-.') !== false) || // Bucket names cannot contain dashes next to periods
|
741 |
+
(strpos($bucket, '.-') !== false) || // Bucket names cannot contain dashes next to periods
|
742 |
+
preg_match('/(-|\.)$/', $bucket) || // Bucket names should not end with a dash or period
|
743 |
+
preg_match('/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/', $bucket) // Must not be formatted as an IP address
|
744 |
+
) return false;
|
745 |
+
|
746 |
+
return true;
|
747 |
+
}
|
748 |
+
|
749 |
+
/**
|
750 |
+
* Validates whether or not the specified Amazon S3 bucket name is valid for path-style access. This
|
751 |
+
* method is leveraged by any method that reads from buckets.
|
752 |
+
*
|
753 |
+
* @param string $bucket (Required) The name of the bucket to validate.
|
754 |
+
* @return boolean Whether or not the bucket name is valid. A value of <code>true</code> means that the bucket name is valid. A value of <code>false</code> means that the bucket name is invalid.
|
755 |
+
*/
|
756 |
+
public function validate_bucketname_support($bucket)
|
757 |
+
{
|
758 |
+
// list_buckets() uses this. Let it pass.
|
759 |
+
if ($bucket === '') return true;
|
760 |
+
|
761 |
+
// Validate
|
762 |
+
if (
|
763 |
+
($bucket === null || $bucket === false) || // Must not be null or false
|
764 |
+
preg_match('/[^(a-z0-9_\-\.)]/i', $bucket) || // Must be in the Roman alphabet, period, hyphen or underscore
|
765 |
+
!preg_match('/^([a-z]|\d)/i', $bucket) || // Must start with a number or letter
|
766 |
+
!(strlen($bucket) >= 3 && strlen($bucket) <= 255) || // Must be between 3 and 255 characters long
|
767 |
+
preg_match('/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/', $bucket) // Must not be formatted as an IP address
|
768 |
+
) return false;
|
769 |
+
|
770 |
+
return true;
|
771 |
+
}
|
772 |
+
|
773 |
+
/**
|
774 |
+
* The callback function that is executed when the cache doesn't exist or has expired. The response of
|
775 |
+
* this method is cached. Accepts identical parameters as the <authenticate()> method. Never call this
|
776 |
+
* method directly -- it is used internally by the caching system.
|
777 |
+
*
|
778 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
779 |
+
* @param array $opt (Optional) An associative array of parameters for authenticating. See the individual methods for allowed keys.
|
780 |
+
* @param string $location (Optional) Used internally by this method when Amazon S3 returns a redirect code and needs to call itself recursively.
|
781 |
+
* @param integer $redirects (Optional) Used internally by this method when Amazon S3 returns a redirect code and needs to call itself recursively.
|
782 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
783 |
+
*/
|
784 |
+
public function cache_callback($bucket, $opt = null, $location = null, $redirects = 0)
|
785 |
+
{
|
786 |
+
// Disable the cache flow since it's already been handled.
|
787 |
+
$this->use_cache_flow = false;
|
788 |
+
|
789 |
+
// Make the request
|
790 |
+
$response = $this->authenticate($bucket, $opt, $location, $redirects);
|
791 |
+
|
792 |
+
if (isset($response->body) && ($response->body instanceof SimpleXMLElement))
|
793 |
+
{
|
794 |
+
$response->body = $response->body->asXML();
|
795 |
+
}
|
796 |
+
|
797 |
+
return $response;
|
798 |
+
}
|
799 |
+
|
800 |
+
|
801 |
+
/*%******************************************************************************************%*/
|
802 |
+
// SETTERS
|
803 |
+
|
804 |
+
/**
|
805 |
+
* Sets the region to use for subsequent Amazon S3 operations. This will also reset any prior use of
|
806 |
+
* <enable_path_style()>.
|
807 |
+
*
|
808 |
+
* @param string $region (Required) The region to use for subsequent Amazon S3 operations. [Allowed values: `AmazonS3::REGION_US_E1 `, `AmazonS3::REGION_US_W1`, `AmazonS3::REGION_EU_W1`, `AmazonS3::REGION_APAC_SE1`]
|
809 |
+
* @return $this A reference to the current instance.
|
810 |
+
*/
|
811 |
+
public function set_region($region)
|
812 |
+
{
|
813 |
+
switch ($region)
|
814 |
+
{
|
815 |
+
case self::REGION_US_W1: // Northern California
|
816 |
+
case self::REGION_APAC_SE1: // Singapore
|
817 |
+
$this->set_hostname('s3-' . $region . '.amazonaws.com');
|
818 |
+
$this->enable_path_style(false);
|
819 |
+
break;
|
820 |
+
|
821 |
+
case self::REGION_EU_W1: // Ireland
|
822 |
+
$this->set_hostname('s3-eu-west-1.amazonaws.com');
|
823 |
+
$this->enable_path_style(); // Always use path-style access for EU endpoint.
|
824 |
+
break;
|
825 |
+
|
826 |
+
default:
|
827 |
+
// REGION_US_E1 // Northern Virginia
|
828 |
+
$this->set_hostname(self::DEFAULT_URL);
|
829 |
+
$this->enable_path_style(false);
|
830 |
+
break;
|
831 |
+
}
|
832 |
+
|
833 |
+
return $this;
|
834 |
+
}
|
835 |
+
|
836 |
+
/**
|
837 |
+
* Sets the virtual host to use in place of the default `bucket.s3.amazonaws.com` domain.
|
838 |
+
*
|
839 |
+
* @param string $vhost (Required) The virtual host to use in place of the default `bucket.s3.amazonaws.com` domain.
|
840 |
+
* @return $this A reference to the current instance.
|
841 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/VirtualHosting.html Virtual Hosting of Buckets
|
842 |
+
*/
|
843 |
+
public function set_vhost($vhost)
|
844 |
+
{
|
845 |
+
$this->vhost = $vhost;
|
846 |
+
return $this;
|
847 |
+
}
|
848 |
+
|
849 |
+
/**
|
850 |
+
* Enables the use of the older path-style URI access for all requests.
|
851 |
+
*
|
852 |
+
* @param string $style (Optional) Whether or not to enable path-style URI access for all requests. The default value is <code>true</code>.
|
853 |
+
* @return $this A reference to the current instance.
|
854 |
+
*/
|
855 |
+
public function enable_path_style($style = true)
|
856 |
+
{
|
857 |
+
$this->path_style = $style;
|
858 |
+
return $this;
|
859 |
+
}
|
860 |
+
|
861 |
+
|
862 |
+
/*%******************************************************************************************%*/
|
863 |
+
// BUCKET METHODS
|
864 |
+
|
865 |
+
/**
|
866 |
+
* Creates an Amazon S3 bucket.
|
867 |
+
*
|
868 |
+
* Every object stored in Amazon S3 is contained in a bucket. Buckets partition the namespace of
|
869 |
+
* objects stored in Amazon S3 at the top level. in a bucket, any name can be used for objects.
|
870 |
+
* However, bucket names must be unique across all of Amazon S3.
|
871 |
+
*
|
872 |
+
* @param string $bucket (Required) The name of the bucket to create.
|
873 |
+
* @param string $region (Required) The preferred geographical location for the bucket. [Allowed values: `AmazonS3::REGION_US_E1 `, `AmazonS3::REGION_US_W1`, `AmazonS3::REGION_EU_W1`, `AmazonS3::REGION_APAC_SE1`]
|
874 |
+
* @param string $acl (Optional) The ACL settings for the specified bucket. [Allowed values: <code>AmazonS3::ACL_PRIVATE</code>, <code>AmazonS3::ACL_PUBLIC</code>, <code>AmazonS3::ACL_OPEN</code>, <code>AmazonS3::ACL_AUTH_READ</code>, <code>AmazonS3::ACL_OWNER_READ</code>, <code>AmazonS3::ACL_OWNER_FULL_CONTROL</code>]. The default value is <ACL_PRIVATE>.
|
875 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
876 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request.</li></ul>
|
877 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
878 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/UsingBucket.html Working with Amazon S3 Buckets
|
879 |
+
*/
|
880 |
+
public function create_bucket($bucket, $region, $acl = self::ACL_PRIVATE, $opt = null)
|
881 |
+
{
|
882 |
+
// If the bucket contains uppercase letters...
|
883 |
+
if (preg_match('/[A-Z]/', $bucket))
|
884 |
+
{
|
885 |
+
// Throw a warning
|
886 |
+
trigger_error('Since DNS-valid bucket names cannot contain uppercase characters, "' . $bucket . '" has been automatically converted to "' . strtolower($bucket) . '"', E_USER_WARNING);
|
887 |
+
|
888 |
+
// Force the bucketname to lowercase
|
889 |
+
$bucket = strtolower($bucket);
|
890 |
+
}
|
891 |
+
|
892 |
+
// Validate the S3 bucket name for creation
|
893 |
+
if (!$this->validate_bucketname_create($bucket))
|
894 |
+
{
|
895 |
+
throw new S3_Exception('"' . $bucket . '" is not DNS-valid (i.e., <bucketname>.s3.amazonaws.com), and cannot be used as an S3 bucket name. Review "Bucket Restrictions and Limitations" in the S3 Developer Guide for more information.');
|
896 |
+
}
|
897 |
+
|
898 |
+
if (!$opt) $opt = array();
|
899 |
+
$opt['verb'] = 'PUT';
|
900 |
+
$opt['headers'] = array(
|
901 |
+
'Content-Type' => 'application/xml',
|
902 |
+
'x-amz-acl' => $acl
|
903 |
+
);
|
904 |
+
|
905 |
+
// Defaults
|
906 |
+
$this->set_region($region);
|
907 |
+
$xml = simplexml_load_string($this->base_location_constraint);
|
908 |
+
|
909 |
+
switch ($region)
|
910 |
+
{
|
911 |
+
case self::REGION_US_W1: // Northern California
|
912 |
+
case self::REGION_APAC_SE1: // Singapore
|
913 |
+
$xml->LocationConstraint = $region;
|
914 |
+
$opt['body'] = $xml->asXML();
|
915 |
+
break;
|
916 |
+
|
917 |
+
case self::REGION_EU_W1: // Ireland
|
918 |
+
$this->enable_path_style(); // DNS-style doesn't seem to work for creation, only in EU. Switch over to path-style.
|
919 |
+
$xml->LocationConstraint = $region;
|
920 |
+
$opt['body'] = $xml->asXML();
|
921 |
+
break;
|
922 |
+
|
923 |
+
default: // REGION_US_E1 // Northern Virginia
|
924 |
+
$opt['body'] = '';
|
925 |
+
break;
|
926 |
+
}
|
927 |
+
|
928 |
+
$response = $this->authenticate($bucket, $opt);
|
929 |
+
|
930 |
+
return $response;
|
931 |
+
}
|
932 |
+
|
933 |
+
/**
|
934 |
+
* Gets the region in which the specified Amazon S3 bucket is located.
|
935 |
+
*
|
936 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
937 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
938 |
+
* <li><code>preauth</code> - <code>integer|string</code> - Optional - Specifies that a presigned URL for this request should be returned. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
939 |
+
* <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>
|
940 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
941 |
+
*/
|
942 |
+
public function get_bucket_region($bucket, $opt = null)
|
943 |
+
{
|
944 |
+
// Add this to our request
|
945 |
+
if (!$opt) $opt = array();
|
946 |
+
$opt['verb'] = 'GET';
|
947 |
+
$opt['sub_resource'] = 'location';
|
948 |
+
|
949 |
+
// Authenticate to S3
|
950 |
+
$response = $this->authenticate($bucket, $opt);
|
951 |
+
|
952 |
+
if ($response->isOK())
|
953 |
+
{
|
954 |
+
// Handle body
|
955 |
+
$response->body = (string) $response->body;
|
956 |
+
}
|
957 |
+
|
958 |
+
return $response;
|
959 |
+
}
|
960 |
+
|
961 |
+
/**
|
962 |
+
* Gets the HTTP headers for the specified Amazon S3 bucket.
|
963 |
+
*
|
964 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
965 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
966 |
+
* <li><code>preauth</code> - <code>integer|string</code> - Optional - Specifies that a presigned URL for this request should be returned. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
967 |
+
* <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>
|
968 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
969 |
+
*/
|
970 |
+
public function get_bucket_headers($bucket, $opt = null)
|
971 |
+
{
|
972 |
+
if (!$opt) $opt = array();
|
973 |
+
$opt['verb'] = 'HEAD';
|
974 |
+
|
975 |
+
return $this->authenticate($bucket, $opt);
|
976 |
+
}
|
977 |
+
|
978 |
+
/**
|
979 |
+
* Deletes a bucket from an Amazon S3 account. A bucket must be empty before the bucket itself can be deleted.
|
980 |
+
*
|
981 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
982 |
+
* @param boolean $force (Optional) Whether to force-delete the bucket and all of its contents. The default value is <code>false</code>.
|
983 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
984 |
+
* <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>
|
985 |
+
* @return mixed A <CFResponse> object if the bucket was deleted successfully. Returns boolean <code>false</code> if otherwise.
|
986 |
+
*/
|
987 |
+
public function delete_bucket($bucket, $force = false, $opt = null)
|
988 |
+
{
|
989 |
+
// Set default value
|
990 |
+
$success = true;
|
991 |
+
|
992 |
+
if ($force)
|
993 |
+
{
|
994 |
+
// Delete all of the items from the bucket.
|
995 |
+
$success = $this->delete_all_object_versions($bucket);
|
996 |
+
}
|
997 |
+
|
998 |
+
// As long as we were successful...
|
999 |
+
if ($success)
|
1000 |
+
{
|
1001 |
+
if (!$opt) $opt = array();
|
1002 |
+
$opt['verb'] = 'DELETE';
|
1003 |
+
|
1004 |
+
return $this->authenticate($bucket, $opt);
|
1005 |
+
}
|
1006 |
+
|
1007 |
+
return false;
|
1008 |
+
}
|
1009 |
+
|
1010 |
+
/**
|
1011 |
+
* Gets a list of all buckets contained in the caller's Amazon S3 account.
|
1012 |
+
*
|
1013 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1014 |
+
* <li><code>preauth</code> - <code>integer|string</code> - Optional - Specifies that a presigned URL for this request should be returned. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
1015 |
+
* <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>
|
1016 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1017 |
+
*/
|
1018 |
+
public function list_buckets($opt = null)
|
1019 |
+
{
|
1020 |
+
if (!$opt) $opt = array();
|
1021 |
+
$opt['verb'] = 'GET';
|
1022 |
+
|
1023 |
+
return $this->authenticate('', $opt);
|
1024 |
+
}
|
1025 |
+
|
1026 |
+
/**
|
1027 |
+
* Gets the access control list (ACL) settings for the specified Amazon S3 bucket.
|
1028 |
+
*
|
1029 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
1030 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1031 |
+
* <li><code>preauth</code> - <code>integer|string</code> - Optional - Specifies that a presigned URL for this request should be returned. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
1032 |
+
* <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>
|
1033 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1034 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/RESTAccessPolicy.html REST Access Control Policy
|
1035 |
+
*/
|
1036 |
+
public function get_bucket_acl($bucket, $opt = null)
|
1037 |
+
{
|
1038 |
+
// Add this to our request
|
1039 |
+
if (!$opt) $opt = array();
|
1040 |
+
$opt['verb'] = 'GET';
|
1041 |
+
$opt['sub_resource'] = 'acl';
|
1042 |
+
|
1043 |
+
// Authenticate to S3
|
1044 |
+
return $this->authenticate($bucket, $opt);
|
1045 |
+
}
|
1046 |
+
|
1047 |
+
/**
|
1048 |
+
* Sets the access control list (ACL) settings for the specified Amazon S3 bucket.
|
1049 |
+
*
|
1050 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
1051 |
+
* @param string $acl (Optional) The ACL settings for the specified bucket. [Allowed values: <code>AmazonS3::ACL_PRIVATE</code>, <code>AmazonS3::ACL_PUBLIC</code>, <code>AmazonS3::ACL_OPEN</code>, <code>AmazonS3::ACL_AUTH_READ</code>, <code>AmazonS3::ACL_OWNER_READ</code>, <code>AmazonS3::ACL_OWNER_FULL_CONTROL</code>]. Alternatively, an array of associative arrays. Each associative array contains an `id` and a `permission` key. The default value is <ACL_PRIVATE>.
|
1052 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1053 |
+
* <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>
|
1054 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1055 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/RESTAccessPolicy.html REST Access Control Policy
|
1056 |
+
*/
|
1057 |
+
public function set_bucket_acl($bucket, $acl = self::ACL_PRIVATE, $opt = null)
|
1058 |
+
{
|
1059 |
+
// Add this to our request
|
1060 |
+
if (!$opt) $opt = array();
|
1061 |
+
$opt['verb'] = 'PUT';
|
1062 |
+
$opt['sub_resource'] = 'acl';
|
1063 |
+
$opt['headers'] = array(
|
1064 |
+
'Content-Type' => 'application/xml'
|
1065 |
+
);
|
1066 |
+
|
1067 |
+
// Make sure these are defined.
|
1068 |
+
if (!defined('AWS_CANONICAL_ID') || !defined('AWS_CANONICAL_NAME'))
|
1069 |
+
{
|
1070 |
+
// Fetch the data live.
|
1071 |
+
$canonical = $this->get_canonical_user_id();
|
1072 |
+
define('AWS_CANONICAL_ID', $canonical['id']);
|
1073 |
+
define('AWS_CANONICAL_NAME', $canonical['display_name']);
|
1074 |
+
}
|
1075 |
+
|
1076 |
+
if (is_array($acl))
|
1077 |
+
{
|
1078 |
+
$opt['body'] = $this->generate_access_policy(AWS_CANONICAL_ID, AWS_CANONICAL_NAME, $acl);
|
1079 |
+
}
|
1080 |
+
else
|
1081 |
+
{
|
1082 |
+
$opt['body'] = '';
|
1083 |
+
$opt['headers']['x-amz-acl'] = $acl;
|
1084 |
+
}
|
1085 |
+
|
1086 |
+
// Authenticate to S3
|
1087 |
+
return $this->authenticate($bucket, $opt);
|
1088 |
+
}
|
1089 |
+
|
1090 |
+
|
1091 |
+
/*%******************************************************************************************%*/
|
1092 |
+
// OBJECT METHODS
|
1093 |
+
|
1094 |
+
/**
|
1095 |
+
* Creates an Amazon S3 object. After an Amazon S3 bucket is created, objects can be stored in it.
|
1096 |
+
*
|
1097 |
+
* Each standard object can hold up to 5 GB of data. When an object is stored in Amazon S3, the data is streamed
|
1098 |
+
* to multiple storage servers in multiple data centers. This ensures the data remains available in the
|
1099 |
+
* event of internal network or hardware failure.
|
1100 |
+
*
|
1101 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
1102 |
+
* @param string $filename (Required) The file name for the object.
|
1103 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1104 |
+
* <li><code>body</code> - <code>string</code> - Required; Conditional - The data to be stored in the object. Either this parameter or <code>fileUpload</code> must be specified.</li>
|
1105 |
+
* <li><code>fileUpload</code> - <code>string|resource</code> - Required; Conditional - The URL/path for the file to upload, or an open resource. Either this parameter or <code>body</code> is required.</li>
|
1106 |
+
* <li><code>acl</code> - <code>string</code> - Optional - The ACL settings for the specified object. [Allowed values: <code>AmazonS3::ACL_PRIVATE</code>, <code>AmazonS3::ACL_PUBLIC</code>, <code>AmazonS3::ACL_OPEN</code>, <code>AmazonS3::ACL_AUTH_READ</code>, <code>AmazonS3::ACL_OWNER_READ</code>, <code>AmazonS3::ACL_OWNER_FULL_CONTROL</code>]. The default value is <code>ACL_PRIVATE</code>.</li>
|
1107 |
+
* <li><code>contentType</code> - <code>string</code> - Optional - The type of content that is being sent in the body. If a file is being uploaded via <code>fileUpload</code> as a file system path, it will attempt to determine the correct mime-type based on the file extension. The default value is <code>application/octet-stream</code>.</li>
|
1108 |
+
* <li><code>headers</code> - <code>array</code> - Optional - The standard HTTP headers to send along in the request.</li>
|
1109 |
+
* <li><code>length</code> - <code>integer</code> - Optional - The size of the object in bytes. For more information, see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13">RFC 2616, section 14.13</a>. The value can also be passed to the <code>header</code> option as <code>Content-Length</code>.</li>
|
1110 |
+
* <li><code>meta</code> - <code>array</code> - Optional - An associative array of key-value pairs. Represented by <code>x-amz-meta-:</code>. Any header starting with this prefix is considered user metadata. It will be stored with the object and returned when you retrieve the object. The total size of the HTTP request, not including the body, must be less than 4 KB.</li>
|
1111 |
+
* <li><code>seekTo</code> - <code>integer</code> - Optional - The starting position in bytes within the file/stream to upload from.</li>
|
1112 |
+
* <li><code>storage</code> - <code>string</code> - Optional - Whether to use Standard or Reduced Redundancy storage. [Allowed values: <code>AmazonS3::STORAGE_STANDARD</code>, <code>AmazonS3::STORAGE_REDUCED</code>]. The default value is <code>STORAGE_STANDARD</code>.</li>
|
1113 |
+
* <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>
|
1114 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1115 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/RESTAccessPolicy.html REST Access Control Policy
|
1116 |
+
*/
|
1117 |
+
public function create_object($bucket, $filename, $opt = null)
|
1118 |
+
{
|
1119 |
+
if (!$opt) $opt = array();
|
1120 |
+
|
1121 |
+
// Add this to our request
|
1122 |
+
$opt['verb'] = 'PUT';
|
1123 |
+
$opt['resource'] = $filename;
|
1124 |
+
|
1125 |
+
// Handle content length. Can also be passed as an HTTP header.
|
1126 |
+
if (isset($opt['length']))
|
1127 |
+
{
|
1128 |
+
$opt['headers']['Content-Length'] = $opt['length'];
|
1129 |
+
unset($opt['length']);
|
1130 |
+
}
|
1131 |
+
|
1132 |
+
// Handle content type. Can also be passed as an HTTP header.
|
1133 |
+
if (isset($opt['contentType']))
|
1134 |
+
{
|
1135 |
+
$opt['headers']['Content-Type'] = $opt['contentType'];
|
1136 |
+
unset($opt['contentType']);
|
1137 |
+
}
|
1138 |
+
|
1139 |
+
// Handle Access Control Lists. Can also be passed as an HTTP header.
|
1140 |
+
if (isset($opt['acl']))
|
1141 |
+
{
|
1142 |
+
$opt['headers']['x-amz-acl'] = $opt['acl'];
|
1143 |
+
unset($opt['acl']);
|
1144 |
+
}
|
1145 |
+
|
1146 |
+
// Handle storage settings. Can also be passed as an HTTP header.
|
1147 |
+
if (isset($opt['storage']))
|
1148 |
+
{
|
1149 |
+
$opt['headers']['x-amz-storage-class'] = $opt['storage'];
|
1150 |
+
unset($opt['storage']);
|
1151 |
+
}
|
1152 |
+
|
1153 |
+
// Handle meta tags. Can also be passed as an HTTP header.
|
1154 |
+
if (isset($opt['meta']))
|
1155 |
+
{
|
1156 |
+
foreach ($opt['meta'] as $meta_key => $meta_value)
|
1157 |
+
{
|
1158 |
+
// e.g., `My Meta Header` is converted to `x-amz-meta-my-meta-header`.
|
1159 |
+
$opt['headers']['x-amz-meta-' . strtolower(str_replace(' ', '-', $meta_key))] = $meta_value;
|
1160 |
+
}
|
1161 |
+
unset($opt['meta']);
|
1162 |
+
}
|
1163 |
+
|
1164 |
+
// Authenticate to S3
|
1165 |
+
return $this->authenticate($bucket, $opt);
|
1166 |
+
}
|
1167 |
+
|
1168 |
+
/**
|
1169 |
+
* Gets the contents of an Amazon S3 object in the specified bucket.
|
1170 |
+
*
|
1171 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
1172 |
+
* @param string $filename (Required) The file name for the object.
|
1173 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1174 |
+
* <li><code>etag</code> - <code>string</code> - Optional - The <code>ETag</code> header passed in from a previous request. If specified, request <code>LastModified</code> option must be specified as well. Will trigger a <code>304 Not Modified</code> status code if the file hasn't changed.</li>
|
1175 |
+
* <li><code>fileDownload</code> - <code>string|resource</code> - Optional - The file system location to download the file to, or an open file resource. Must be a server-writable location.</li>
|
1176 |
+
* <li><code>headers</code> - <code>array</code> - Optional - Standard HTTP headers to send along in the request.</li>
|
1177 |
+
* <li><code>lastmodified</code> - <code>string</code> - Optional - The <code>LastModified</code> header passed in from a previous request. If specified, request <code>ETag</code> option must be specified as well. Will trigger a <code>304 Not Modified</code> status code if the file hasn't changed.</li>
|
1178 |
+
* <li><code>preauth</code> - <code>integer|string</code> - Optional - Specifies that a presigned URL for this request should be returned. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
1179 |
+
* <li><code>range</code> - <code>string</code> - Optional - The range of bytes to fetch from the object. Specify this parameter when downloading partial bits or completing incomplete object downloads. The specified range must be notated with a hyphen (e.g., 0-10485759). Defaults to the byte range of the complete Amazon S3 object.</li>
|
1180 |
+
* <li><code>response</code> - <code>array</code> - Optional - Allows adjustments to specific response headers. Pass an associative array where each key is one of the following: <code>cache-control</code>, <code>content-disposition</code>, <code>content-encoding</code>, <code>content-language</code>, <code>content-type</code>, <code>expires</code>. The <code>expires</code> value should use <php:gmdate()> and be formatted with the <code>DATE_RFC2822</code> constant.</li>
|
1181 |
+
* <li><code>versionId</code> - <code>string</code> - Optional - The version of the object to retrieve. Version IDs are returned in the <code>x-amz-version-id</code> header of any previous object-related request.</li>
|
1182 |
+
* <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>
|
1183 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1184 |
+
*/
|
1185 |
+
public function get_object($bucket, $filename, $opt = null)
|
1186 |
+
{
|
1187 |
+
if (!$opt) $opt = array();
|
1188 |
+
|
1189 |
+
// Add this to our request
|
1190 |
+
$opt['verb'] = 'GET';
|
1191 |
+
$opt['resource'] = $filename;
|
1192 |
+
|
1193 |
+
if (!isset($opt['headers']) || !is_array($opt['headers']))
|
1194 |
+
{
|
1195 |
+
$opt['headers'] = array();
|
1196 |
+
}
|
1197 |
+
|
1198 |
+
// Are we checking for changes?
|
1199 |
+
if (isset($opt['lastmodified']) && isset($opt['etag']))
|
1200 |
+
{
|
1201 |
+
$opt['headers']['If-Modified-Since'] = $opt['lastmodified'];
|
1202 |
+
$opt['headers']['If-None-Match'] = $opt['etag'];
|
1203 |
+
}
|
1204 |
+
|
1205 |
+
// Partial content range
|
1206 |
+
if (isset($opt['range']))
|
1207 |
+
{
|
1208 |
+
$opt['headers']['Range'] = 'bytes=' . $opt['range'];
|
1209 |
+
}
|
1210 |
+
|
1211 |
+
// GET responses
|
1212 |
+
if (isset($opt['response']))
|
1213 |
+
{
|
1214 |
+
foreach ($opt['response'] as $key => $value)
|
1215 |
+
{
|
1216 |
+
$opt['response-' . $key] = $value;
|
1217 |
+
unset($opt['response'][$key]);
|
1218 |
+
}
|
1219 |
+
}
|
1220 |
+
|
1221 |
+
// Authenticate to S3
|
1222 |
+
return $this->authenticate($bucket, $opt);
|
1223 |
+
}
|
1224 |
+
|
1225 |
+
/**
|
1226 |
+
* Gets the HTTP headers for the specified Amazon S3 object.
|
1227 |
+
*
|
1228 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
1229 |
+
* @param string $filename (Required) The file name for the object.
|
1230 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1231 |
+
* <li><code>versionId</code> - <code>string</code> - Optional - The version of the object to retrieve. Version IDs are returned in the <code>x-amz-version-id</code> header of any previous object-related request.</li>
|
1232 |
+
* <li><code>preauth</code> - <code>integer|string</code> - Optional - Specifies that a presigned URL for this request should be returned. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
1233 |
+
* <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>
|
1234 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1235 |
+
*/
|
1236 |
+
public function get_object_headers($bucket, $filename, $opt = null)
|
1237 |
+
{
|
1238 |
+
// Add this to our request
|
1239 |
+
if (!$opt) $opt = array();
|
1240 |
+
$opt['verb'] = 'HEAD';
|
1241 |
+
$opt['resource'] = $filename;
|
1242 |
+
|
1243 |
+
// Authenticate to S3
|
1244 |
+
return $this->authenticate($bucket, $opt);
|
1245 |
+
}
|
1246 |
+
|
1247 |
+
/**
|
1248 |
+
* Deletes an Amazon S3 object from the specified bucket.
|
1249 |
+
*
|
1250 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
1251 |
+
* @param string $filename (Required) The file name for the object.
|
1252 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1253 |
+
* <li><code>versionId</code> - <code>string</code> - Optional - The version of the object to delete. Version IDs are returned in the <code>x-amz-version-id</code> header of any previous object-related request.</li>
|
1254 |
+
* <li><code>MFASerial</code> - <code>string</code> - Optional - The serial number on the back of the Gemalto device. <code>MFASerial</code> and <code>MFAToken</code> must both be set for MFA to work.</li>
|
1255 |
+
* <li><code>MFAToken</code> - <code>string</code> - Optional - The current token displayed on the Gemalto device. <code>MFASerial</code> and <code>MFAToken</code> must both be set for MFA to work.</li>
|
1256 |
+
* <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>
|
1257 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1258 |
+
* @link http://aws.amazon.com/mfa/ Multi-Factor Authentication
|
1259 |
+
*/
|
1260 |
+
public function delete_object($bucket, $filename, $opt = null)
|
1261 |
+
{
|
1262 |
+
// Add this to our request
|
1263 |
+
if (!$opt) $opt = array();
|
1264 |
+
$opt['verb'] = 'DELETE';
|
1265 |
+
$opt['resource'] = $filename;
|
1266 |
+
|
1267 |
+
// Enable MFA delete?
|
1268 |
+
if (isset($opt['MFASerial']) && isset($opt['MFAToken']))
|
1269 |
+
{
|
1270 |
+
$opt['headers'] = array(
|
1271 |
+
'x-amz-mfa' => ($opt['MFASerial'] . ' ' . $opt['MFAToken'])
|
1272 |
+
);
|
1273 |
+
}
|
1274 |
+
|
1275 |
+
// Authenticate to S3
|
1276 |
+
return $this->authenticate($bucket, $opt);
|
1277 |
+
}
|
1278 |
+
|
1279 |
+
/**
|
1280 |
+
* Gets a list of all Amazon S3 objects in the specified bucket.
|
1281 |
+
*
|
1282 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
1283 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1284 |
+
* <li><code>delimiter</code> - <code>string</code> - Optional - Keys that contain the same string between the prefix and the first occurrence of the delimiter will be rolled up into a single result element in the CommonPrefixes collection.</li>
|
1285 |
+
* <li><code>marker</code> - <code>string</code> - Optional - Restricts the response to contain results that only occur alphabetically after the value of the marker.</li>
|
1286 |
+
* <li><code>max-keys</code> - <code>string</code> - Optional - The maximum number of results returned by the method call. The returned list will contain no more results than the specified value, but may return less.</li>
|
1287 |
+
* <li><code>preauth</code> - <code>integer|string</code> - Optional - Specifies that a presigned URL for this request should be returned. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
1288 |
+
* <li><code>prefix</code> - <code>string</code> - Optional - Restricts the response to contain results that begin only with the specified prefix.</li>
|
1289 |
+
* <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>
|
1290 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1291 |
+
*/
|
1292 |
+
public function list_objects($bucket, $opt = null)
|
1293 |
+
{
|
1294 |
+
if (!$opt) $opt = array();
|
1295 |
+
|
1296 |
+
// Add this to our request
|
1297 |
+
$opt['verb'] = 'GET';
|
1298 |
+
|
1299 |
+
foreach (array('delimiter', 'marker', 'max-keys', 'prefix') as $param)
|
1300 |
+
{
|
1301 |
+
if (isset($opt[$param]))
|
1302 |
+
{
|
1303 |
+
$opt['query_string'][$param] = $opt[$param];
|
1304 |
+
unset($opt[$param]);
|
1305 |
+
}
|
1306 |
+
}
|
1307 |
+
|
1308 |
+
// Authenticate to S3
|
1309 |
+
return $this->authenticate($bucket, $opt);
|
1310 |
+
}
|
1311 |
+
|
1312 |
+
/**
|
1313 |
+
* Copies an Amazon S3 object to a new location, whether in the same Amazon S3 region, bucket, or otherwise.
|
1314 |
+
*
|
1315 |
+
* @param array $source (Required) The bucket and file name to copy from. The following keys must be set: <ul>
|
1316 |
+
* <li><code>bucket</code> - <code>string</code> - Required - Specifies the name of the bucket containing the source object.</li>
|
1317 |
+
* <li><code>filename</code> - <code>string</code> - Required - Specifies the file name of the source object to copy.</li></ul>
|
1318 |
+
* @param array $dest (Required) The bucket and file name to copy to. The following keys must be set: <ul>
|
1319 |
+
* <li><code>bucket</code> - <code>string</code> - Required - Specifies the name of the bucket to copy the object to.</li>
|
1320 |
+
* <li><code>filename</code> - <code>string</code> - Required - Specifies the file name to copy the object to.</li></ul>
|
1321 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1322 |
+
* <li><code>acl</code> - <code>string</code> - Optional - The ACL settings for the specified object. [Allowed values: <code>AmazonS3::ACL_PRIVATE</code>, <code>AmazonS3::ACL_PUBLIC</code>, <code>AmazonS3::ACL_OPEN</code>, <code>AmazonS3::ACL_AUTH_READ</code>, <code>AmazonS3::ACL_OWNER_READ</code>, <code>AmazonS3::ACL_OWNER_FULL_CONTROL</code>]. Alternatively, an array of associative arrays. Each associative array contains an <code>id</code> and a <code>permission</code> key. The default value is <code>ACL_PRIVATE</code>.</li>
|
1323 |
+
* <li><code>storage</code> - <code>string</code> - Optional - Whether to use Standard or Reduced Redundancy storage. [Allowed values: <code>AmazonS3::STORAGE_STANDARD</code>, <code>AmazonS3::STORAGE_REDUCED</code>]. The default value is <code>STORAGE_STANDARD</code>.</li>
|
1324 |
+
* <li><code>versionId</code> - <code>string</code> - Optional - The version of the object to copy. Version IDs are returned in the <code>x-amz-version-id</code> header of any previous object-related request.</li>
|
1325 |
+
* <li><code>ifMatch</code> - <code>string</code> - Optional - The ETag header from a previous request. Copies the object if its entity tag (ETag) matches the specified tag; otherwise, the request returns a <code>412</code> HTTP status code error (precondition failed). Used in conjunction with <code>ifUnmodifiedSince</code>.</li>
|
1326 |
+
* <li><code>ifUnmodifiedSince</code> - <code>string</code> - Optional - The LastModified header from a previous request. Copies the object if it hasn't been modified since the specified time; otherwise, the request returns a <code>412</code> HTTP status code error (precondition failed). Used in conjunction with <code>ifMatch</code>.</li>
|
1327 |
+
* <li><code>ifNoneMatch</code> - <code>string</code> - Optional - The ETag header from a previous request. Copies the object if its entity tag (ETag) is different than the specified ETag; otherwise, the request returns a <code>412</code> HTTP status code error (failed condition). Used in conjunction with <code>ifModifiedSince</code>.</li>
|
1328 |
+
* <li><code>ifModifiedSince</code> - <code>string</code> - Optional - The LastModified header from a previous request. Copies the object if it has been modified since the specified time; otherwise, the request returns a <code>412</code> HTTP status code error (failed condition). Used in conjunction with <code>ifNoneMatch</code>.</li>
|
1329 |
+
* <li><code>headers</code> - <code>array</code> - Optional - Standard HTTP headers to send along in the request.</li>
|
1330 |
+
* <li><code>meta</code> - <code>array</code> - Optional - Associative array of key-value pairs. Represented by <code>x-amz-meta-:</code> Any header starting with this prefix is considered user metadata. It will be stored with the object and returned when you retrieve the object. The total size of the HTTP request, not including the body, must be less than 4 KB.</li>
|
1331 |
+
* <li><code>metadataDirective</code> - <code>string</code> - Optional - Accepts either COPY or REPLACE. You will likely never need to use this, as it manages itself with no issues.</li>
|
1332 |
+
* <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>
|
1333 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1334 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/UsingCopyingObjects.html Copying Amazon S3 Objects
|
1335 |
+
*/
|
1336 |
+
public function copy_object($source, $dest, $opt = null)
|
1337 |
+
{
|
1338 |
+
if (!$opt) $opt = array();
|
1339 |
+
$batch = array();
|
1340 |
+
|
1341 |
+
// Add this to our request
|
1342 |
+
$opt['verb'] = 'PUT';
|
1343 |
+
$opt['resource'] = $dest['filename'];
|
1344 |
+
$opt['body'] = '';
|
1345 |
+
|
1346 |
+
// Handle copy source
|
1347 |
+
if (isset($source['bucket']) && isset($source['filename']))
|
1348 |
+
{
|
1349 |
+
$opt['headers']['x-amz-copy-source'] = '/' . $source['bucket'] . '/' . rawurlencode($source['filename'])
|
1350 |
+
. (isset($opt['versionId']) ? ('?' . 'versionId=' . rawurlencode($opt['versionId'])) : ''); // Append the versionId to copy, if available
|
1351 |
+
unset($opt['versionId']);
|
1352 |
+
|
1353 |
+
// Determine if we need to lookup the pre-existing content-type.
|
1354 |
+
if (
|
1355 |
+
(!$this->use_batch_flow && !isset($opt['returnCurlHandle'])) &&
|
1356 |
+
!in_array(strtolower('content-type'), array_map('strtolower', array_keys($opt['headers'])))
|
1357 |
+
)
|
1358 |
+
{
|
1359 |
+
$response = $this->get_object_headers($source['bucket'], $source['filename']);
|
1360 |
+
if ($response->isOK())
|
1361 |
+
{
|
1362 |
+
$opt['headers']['Content-Type'] = $response->header['content-type'];
|
1363 |
+
}
|
1364 |
+
}
|
1365 |
+
}
|
1366 |
+
|
1367 |
+
// Handle metadata directive
|
1368 |
+
$opt['headers']['x-amz-metadata-directive'] = 'COPY';
|
1369 |
+
if ($source['bucket'] === $dest['bucket'] && $source['filename'] === $dest['filename'])
|
1370 |
+
{
|
1371 |
+
$opt['headers']['x-amz-metadata-directive'] = 'REPLACE';
|
1372 |
+
}
|
1373 |
+
if (isset($opt['metadataDirective']))
|
1374 |
+
{
|
1375 |
+
$opt['headers']['x-amz-metadata-directive'] = $opt['metadataDirective'];
|
1376 |
+
unset($opt['metadataDirective']);
|
1377 |
+
}
|
1378 |
+
|
1379 |
+
// Handle Access Control Lists. Can also pass canned ACLs as an HTTP header.
|
1380 |
+
if (isset($opt['acl']) && is_array($opt['acl']))
|
1381 |
+
{
|
1382 |
+
$batch[] = $this->set_object_acl($dest['bucket'], $dest['filename'], $opt['acl'], array(
|
1383 |
+
'returnCurlHandle' => true
|
1384 |
+
));
|
1385 |
+
unset($opt['acl']);
|
1386 |
+
}
|
1387 |
+
elseif (isset($opt['acl']))
|
1388 |
+
{
|
1389 |
+
$opt['headers']['x-amz-acl'] = $opt['acl'];
|
1390 |
+
unset($opt['acl']);
|
1391 |
+
}
|
1392 |
+
|
1393 |
+
// Handle storage settings. Can also be passed as an HTTP header.
|
1394 |
+
if (isset($opt['storage']))
|
1395 |
+
{
|
1396 |
+
$opt['headers']['x-amz-storage-class'] = $opt['storage'];
|
1397 |
+
unset($opt['storage']);
|
1398 |
+
}
|
1399 |
+
|
1400 |
+
// Handle conditional-copy parameters
|
1401 |
+
if (isset($opt['ifMatch']))
|
1402 |
+
{
|
1403 |
+
$opt['headers']['x-amz-copy-source-if-match'] = $opt['ifMatch'];
|
1404 |
+
unset($opt['ifMatch']);
|
1405 |
+
}
|
1406 |
+
if (isset($opt['ifNoneMatch']))
|
1407 |
+
{
|
1408 |
+
$opt['headers']['x-amz-copy-source-if-none-match'] = $opt['ifNoneMatch'];
|
1409 |
+
unset($opt['ifNoneMatch']);
|
1410 |
+
}
|
1411 |
+
if (isset($opt['ifUnmodifiedSince']))
|
1412 |
+
{
|
1413 |
+
$opt['headers']['x-amz-copy-source-if-unmodified-since'] = $opt['ifUnmodifiedSince'];
|
1414 |
+
unset($opt['ifUnmodifiedSince']);
|
1415 |
+
}
|
1416 |
+
if (isset($opt['ifModifiedSince']))
|
1417 |
+
{
|
1418 |
+
$opt['headers']['x-amz-copy-source-if-modified-since'] = $opt['ifModifiedSince'];
|
1419 |
+
unset($opt['ifModifiedSince']);
|
1420 |
+
}
|
1421 |
+
|
1422 |
+
// Handle meta tags. Can also be passed as an HTTP header.
|
1423 |
+
if (isset($opt['meta']))
|
1424 |
+
{
|
1425 |
+
foreach ($opt['meta'] as $meta_key => $meta_value)
|
1426 |
+
{
|
1427 |
+
// e.g., `My Meta Header` is converted to `x-amz-meta-my-meta-header`.
|
1428 |
+
$opt['headers']['x-amz-meta-' . strtolower(str_replace(' ', '-', $meta_key))] = $meta_value;
|
1429 |
+
}
|
1430 |
+
unset($opt['meta']);
|
1431 |
+
}
|
1432 |
+
|
1433 |
+
// Authenticate to S3
|
1434 |
+
$response = $this->authenticate($dest['bucket'], $opt);
|
1435 |
+
|
1436 |
+
// Attempt to reset ACLs
|
1437 |
+
$http = new RequestCore();
|
1438 |
+
$http->send_multi_request($batch);
|
1439 |
+
|
1440 |
+
return $response;
|
1441 |
+
}
|
1442 |
+
|
1443 |
+
/**
|
1444 |
+
* Updates an Amazon S3 object with new headers or other metadata. To replace the content of the
|
1445 |
+
* specified Amazon S3 object, call <create_object()> with the same bucket and file name parameters.
|
1446 |
+
*
|
1447 |
+
* @param string $bucket (Required) The name of the bucket that contains the source file.
|
1448 |
+
* @param string $filename (Required) The source file name that you want to update.
|
1449 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1450 |
+
* <li><code>acl</code> - <code>string</code> - Optional - The ACL settings for the specified object. [Allowed values: <code>AmazonS3::ACL_PRIVATE</code>, <code>AmazonS3::ACL_PUBLIC</code>, <code>AmazonS3::ACL_OPEN</code>, <code>AmazonS3::ACL_AUTH_READ</code>, <code>AmazonS3::ACL_OWNER_READ</code>, <code>AmazonS3::ACL_OWNER_FULL_CONTROL</code>]. The default value is <ACL_PRIVATE>.</li>
|
1451 |
+
* <li><code>headers</code> - <code>array</code> - Optional - The standard HTTP headers to update the Amazon S3 object with.</li>
|
1452 |
+
* <li><code>meta</code> - <code>array</code> - Optional - An associative array of key-value pairs. Any header with the <code>x-amz-meta-</code> prefix is considered user metadata and is stored with the Amazon S3 object. It will be stored with the object and returned when you retrieve the object. The total size of the HTTP request, not including the body, must be less than 4 KB.</li>
|
1453 |
+
* <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>
|
1454 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1455 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/UsingCopyingObjects.html Copying Amazon S3 Objects
|
1456 |
+
*/
|
1457 |
+
public function update_object($bucket, $filename, $opt = null)
|
1458 |
+
{
|
1459 |
+
if (!$opt) $opt = array();
|
1460 |
+
$opt['metadataDirective'] = 'REPLACE';
|
1461 |
+
|
1462 |
+
// Authenticate to S3
|
1463 |
+
return $this->copy_object(
|
1464 |
+
array('bucket' => $bucket, 'filename' => $filename),
|
1465 |
+
array('bucket' => $bucket, 'filename' => $filename),
|
1466 |
+
$opt
|
1467 |
+
);
|
1468 |
+
}
|
1469 |
+
|
1470 |
+
|
1471 |
+
/*%******************************************************************************************%*/
|
1472 |
+
// ACCESS CONTROL LISTS
|
1473 |
+
|
1474 |
+
/**
|
1475 |
+
* Gets the access control list (ACL) settings for the specified Amazon S3 object.
|
1476 |
+
*
|
1477 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
1478 |
+
* @param string $filename (Required) The file name for the object.
|
1479 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1480 |
+
* <li><code>versionId</code> - <code>string</code> - Optional - The version of the object to retrieve. Version IDs are returned in the <code>x-amz-version-id</code> header of any previous object-related request.</li>
|
1481 |
+
* <li><code>preauth</code> - <code>integer|string</code> - Optional - Specifies that a presigned URL for this request should be returned. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
1482 |
+
* <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>
|
1483 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1484 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/RESTAccessPolicy.html REST Access Control Policy
|
1485 |
+
*/
|
1486 |
+
public function get_object_acl($bucket, $filename, $opt = null)
|
1487 |
+
{
|
1488 |
+
// Add this to our request
|
1489 |
+
if (!$opt) $opt = array();
|
1490 |
+
$opt['verb'] = 'GET';
|
1491 |
+
$opt['resource'] = $filename;
|
1492 |
+
$opt['sub_resource'] = 'acl';
|
1493 |
+
|
1494 |
+
// Authenticate to S3
|
1495 |
+
return $this->authenticate($bucket, $opt);
|
1496 |
+
}
|
1497 |
+
|
1498 |
+
/**
|
1499 |
+
* Sets the access control list (ACL) settings for the specified Amazon S3 object.
|
1500 |
+
*
|
1501 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
1502 |
+
* @param string $filename (Required) The file name for the object.
|
1503 |
+
* @param string $acl (Optional) The ACL settings for the specified object. Accepts any of the following constants: [Allowed values: <code>AmazonS3::ACL_PRIVATE</code>, <code>AmazonS3::ACL_PUBLIC</code>, <code>AmazonS3::ACL_OPEN</code>, <code>AmazonS3::ACL_AUTH_READ</code>, <code>AmazonS3::ACL_OWNER_READ</code>, <code>AmazonS3::ACL_OWNER_FULL_CONTROL</code>]. Alternatively, an array of associative arrays. Each associative array contains an <code>id</code> and a <code>permission</code> key. The default value is <code>ACL_PRIVATE</code>.
|
1504 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1505 |
+
* <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>
|
1506 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1507 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/RESTAccessPolicy.html REST Access Control Policy
|
1508 |
+
*/
|
1509 |
+
public function set_object_acl($bucket, $filename, $acl = self::ACL_PRIVATE, $opt = null)
|
1510 |
+
{
|
1511 |
+
// Add this to our request
|
1512 |
+
if (!$opt) $opt = array();
|
1513 |
+
$opt['verb'] = 'PUT';
|
1514 |
+
$opt['resource'] = $filename;
|
1515 |
+
$opt['sub_resource'] = 'acl';
|
1516 |
+
|
1517 |
+
// Retrieve the original metadata
|
1518 |
+
$metadata = $this->get_object_metadata($bucket, $filename);
|
1519 |
+
if ($metadata && $metadata['ContentType'])
|
1520 |
+
{
|
1521 |
+
$opt['headers']['Content-Type'] = $metadata['ContentType'];
|
1522 |
+
}
|
1523 |
+
if ($metadata && $metadata['StorageClass'])
|
1524 |
+
{
|
1525 |
+
$opt['headers']['x-amz-storage-class'] = $metadata['StorageClass'];
|
1526 |
+
}
|
1527 |
+
|
1528 |
+
// Make sure these are defined.
|
1529 |
+
if (!defined('AWS_CANONICAL_ID') || !defined('AWS_CANONICAL_NAME'))
|
1530 |
+
{
|
1531 |
+
// Fetch the data live.
|
1532 |
+
$canonical = $this->get_canonical_user_id();
|
1533 |
+
define('AWS_CANONICAL_ID', $canonical['id']);
|
1534 |
+
define('AWS_CANONICAL_NAME', $canonical['display_name']);
|
1535 |
+
}
|
1536 |
+
|
1537 |
+
if (is_array($acl))
|
1538 |
+
{
|
1539 |
+
$opt['body'] = $this->generate_access_policy(AWS_CANONICAL_ID, AWS_CANONICAL_NAME, $acl);
|
1540 |
+
}
|
1541 |
+
else
|
1542 |
+
{
|
1543 |
+
$opt['body'] = '';
|
1544 |
+
$opt['headers']['x-amz-acl'] = $acl;
|
1545 |
+
}
|
1546 |
+
|
1547 |
+
// Authenticate to S3
|
1548 |
+
return $this->authenticate($bucket, $opt);
|
1549 |
+
}
|
1550 |
+
|
1551 |
+
/**
|
1552 |
+
* Generates the XML to be used for the Access Control Policy.
|
1553 |
+
*
|
1554 |
+
* @param string $canonical_id (Required) The canonical ID for the bucket owner. Use the `AWS_CANONICAL_ID` constant or the `id` return value from <get_canonical_user_id()>.
|
1555 |
+
* @param string $canonical_name (Required) The canonical display name for the bucket owner. Use the `AWS_CANONICAL_NAME` constant or the `display_name` value from <get_canonical_user_id()>.
|
1556 |
+
* @param array $users (Optional) An array of associative arrays. Each associative array contains an `id` value and a `permission` value.
|
1557 |
+
* @return string Access Control Policy XML.
|
1558 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/S3_ACLs.html Access Control Lists
|
1559 |
+
*/
|
1560 |
+
public function generate_access_policy($canonical_id, $canonical_name, $users)
|
1561 |
+
{
|
1562 |
+
$xml = simplexml_load_string($this->base_acp_xml);
|
1563 |
+
$owner = $xml->addChild('Owner');
|
1564 |
+
$owner->addChild('ID', $canonical_id);
|
1565 |
+
$owner->addChild('DisplayName', $canonical_name);
|
1566 |
+
$acl = $xml->addChild('AccessControlList');
|
1567 |
+
|
1568 |
+
foreach ($users as $user)
|
1569 |
+
{
|
1570 |
+
$grant = $acl->addChild('Grant');
|
1571 |
+
$grantee = $grant->addChild('Grantee');
|
1572 |
+
|
1573 |
+
switch ($user['id'])
|
1574 |
+
{
|
1575 |
+
// Authorized Users
|
1576 |
+
case self::USERS_AUTH:
|
1577 |
+
$grantee->addAttribute('xsi:type', 'Group', 'http://www.w3.org/2001/XMLSchema-instance');
|
1578 |
+
$grantee->addChild('URI', self::USERS_AUTH);
|
1579 |
+
break;
|
1580 |
+
|
1581 |
+
// All Users
|
1582 |
+
case self::USERS_ALL:
|
1583 |
+
$grantee->addAttribute('xsi:type', 'Group', 'http://www.w3.org/2001/XMLSchema-instance');
|
1584 |
+
$grantee->addChild('URI', self::USERS_ALL);
|
1585 |
+
break;
|
1586 |
+
|
1587 |
+
// The Logging User
|
1588 |
+
case self::USERS_LOGGING:
|
1589 |
+
$grantee->addAttribute('xsi:type', 'Group', 'http://www.w3.org/2001/XMLSchema-instance');
|
1590 |
+
$grantee->addChild('URI', self::USERS_LOGGING);
|
1591 |
+
break;
|
1592 |
+
|
1593 |
+
// Email Address or Canonical Id
|
1594 |
+
default:
|
1595 |
+
if (strpos($user['id'], '@'))
|
1596 |
+
{
|
1597 |
+
$grantee->addAttribute('xsi:type', 'AmazonCustomerByEmail', 'http://www.w3.org/2001/XMLSchema-instance');
|
1598 |
+
$grantee->addChild('EmailAddress', $user['id']);
|
1599 |
+
}
|
1600 |
+
else
|
1601 |
+
{
|
1602 |
+
// Assume Canonical Id
|
1603 |
+
$grantee->addAttribute('xsi:type', 'CanonicalUser', 'http://www.w3.org/2001/XMLSchema-instance');
|
1604 |
+
$grantee->addChild('ID', $user['id']);
|
1605 |
+
}
|
1606 |
+
break;
|
1607 |
+
}
|
1608 |
+
|
1609 |
+
$grant->addChild('Permission', $user['permission']);
|
1610 |
+
}
|
1611 |
+
|
1612 |
+
return $xml->asXML();
|
1613 |
+
}
|
1614 |
+
|
1615 |
+
|
1616 |
+
/*%******************************************************************************************%*/
|
1617 |
+
// LOGGING METHODS
|
1618 |
+
|
1619 |
+
/**
|
1620 |
+
* Gets the access logs associated with the specified Amazon S3 bucket.
|
1621 |
+
*
|
1622 |
+
* @param string $bucket (Required) The name of the bucket to use. Pass a `null` value when using the <set_vhost()> method.
|
1623 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1624 |
+
* <li><code>preauth</code> - <code>integer|string</code> - Optional - Specifies that a presigned URL for this request should be returned. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
1625 |
+
* <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>
|
1626 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1627 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/ServerLogs.html Server Access Logging
|
1628 |
+
*/
|
1629 |
+
public function get_logs($bucket, $opt = null)
|
1630 |
+
{
|
1631 |
+
// Add this to our request
|
1632 |
+
if (!$opt) $opt = array();
|
1633 |
+
$opt['verb'] = 'GET';
|
1634 |
+
$opt['sub_resource'] = 'logging';
|
1635 |
+
|
1636 |
+
// Authenticate to S3
|
1637 |
+
return $this->authenticate($bucket, $opt);
|
1638 |
+
}
|
1639 |
+
|
1640 |
+
/**
|
1641 |
+
* Enables access logging for the specified Amazon S3 bucket.
|
1642 |
+
*
|
1643 |
+
* @param string $bucket (Required) The name of the bucket to enable logging for. Pass a `null` value when using the <set_vhost()> method.
|
1644 |
+
* @param string $target_bucket (Required) The name of the bucket to store the logs in.
|
1645 |
+
* @param string $target_prefix (Required) The prefix to give to the log file names.
|
1646 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1647 |
+
* <li><code>users</code> - <code>array</code> - Optional - An array of associative arrays specifying any user to give access to. Each associative array contains an <code>id</code> and <code>permission</code> value.</li>
|
1648 |
+
* <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>
|
1649 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1650 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/LoggingAPI.html Server Access Logging Configuration API
|
1651 |
+
*/
|
1652 |
+
public function enable_logging($bucket, $target_bucket, $target_prefix, $opt = null)
|
1653 |
+
{
|
1654 |
+
// Add this to our request
|
1655 |
+
if (!$opt) $opt = array();
|
1656 |
+
$opt['verb'] = 'PUT';
|
1657 |
+
$opt['sub_resource'] = 'logging';
|
1658 |
+
$opt['headers'] = array(
|
1659 |
+
'Content-Type' => 'application/xml'
|
1660 |
+
);
|
1661 |
+
|
1662 |
+
$xml = simplexml_load_string($this->base_logging_xml);
|
1663 |
+
$LoggingEnabled = $xml->addChild('LoggingEnabled');
|
1664 |
+
$LoggingEnabled->addChild('TargetBucket', $target_bucket);
|
1665 |
+
$LoggingEnabled->addChild('TargetPrefix', $target_prefix);
|
1666 |
+
$TargetGrants = $LoggingEnabled->addChild('TargetGrants');
|
1667 |
+
|
1668 |
+
if (isset($opt['users']) && is_array($opt['users']))
|
1669 |
+
{
|
1670 |
+
foreach ($opt['users'] as $user)
|
1671 |
+
{
|
1672 |
+
$grant = $TargetGrants->addChild('Grant');
|
1673 |
+
$grantee = $grant->addChild('Grantee');
|
1674 |
+
|
1675 |
+
switch ($user['id'])
|
1676 |
+
{
|
1677 |
+
// Authorized Users
|
1678 |
+
case self::USERS_AUTH:
|
1679 |
+
$grantee->addAttribute('xsi:type', 'Group', 'http://www.w3.org/2001/XMLSchema-instance');
|
1680 |
+
$grantee->addChild('URI', self::USERS_AUTH);
|
1681 |
+
break;
|
1682 |
+
|
1683 |
+
// All Users
|
1684 |
+
case self::USERS_ALL:
|
1685 |
+
$grantee->addAttribute('xsi:type', 'Group', 'http://www.w3.org/2001/XMLSchema-instance');
|
1686 |
+
$grantee->addChild('URI', self::USERS_ALL);
|
1687 |
+
break;
|
1688 |
+
|
1689 |
+
// The Logging User
|
1690 |
+
case self::USERS_LOGGING:
|
1691 |
+
$grantee->addAttribute('xsi:type', 'Group', 'http://www.w3.org/2001/XMLSchema-instance');
|
1692 |
+
$grantee->addChild('URI', self::USERS_LOGGING);
|
1693 |
+
break;
|
1694 |
+
|
1695 |
+
// Email Address or Canonical Id
|
1696 |
+
default:
|
1697 |
+
if (strpos($user['id'], '@'))
|
1698 |
+
{
|
1699 |
+
$grantee->addAttribute('xsi:type', 'AmazonCustomerByEmail', 'http://www.w3.org/2001/XMLSchema-instance');
|
1700 |
+
$grantee->addChild('EmailAddress', $user['id']);
|
1701 |
+
}
|
1702 |
+
else
|
1703 |
+
{
|
1704 |
+
// Assume Canonical Id
|
1705 |
+
$grantee->addAttribute('xsi:type', 'CanonicalUser', 'http://www.w3.org/2001/XMLSchema-instance');
|
1706 |
+
$grantee->addChild('ID', $user['id']);
|
1707 |
+
}
|
1708 |
+
break;
|
1709 |
+
}
|
1710 |
+
|
1711 |
+
$grant->addChild('Permission', $user['permission']);
|
1712 |
+
}
|
1713 |
+
}
|
1714 |
+
|
1715 |
+
$opt['body'] = $xml->asXML();
|
1716 |
+
|
1717 |
+
// Authenticate to S3
|
1718 |
+
return $this->authenticate($bucket, $opt);
|
1719 |
+
}
|
1720 |
+
|
1721 |
+
/**
|
1722 |
+
* Disables access logging for the specified Amazon S3 bucket.
|
1723 |
+
*
|
1724 |
+
* @param string $bucket (Required) The name of the bucket to use. Pass `null` if using <set_vhost()>.
|
1725 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1726 |
+
* <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>
|
1727 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1728 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/LoggingAPI.html Server Access Logging Configuration API
|
1729 |
+
*/
|
1730 |
+
public function disable_logging($bucket, $opt = null)
|
1731 |
+
{
|
1732 |
+
// Add this to our request
|
1733 |
+
if (!$opt) $opt = array();
|
1734 |
+
$opt['verb'] = 'PUT';
|
1735 |
+
$opt['sub_resource'] = 'logging';
|
1736 |
+
$opt['headers'] = array(
|
1737 |
+
'Content-Type' => 'application/xml'
|
1738 |
+
);
|
1739 |
+
$opt['body'] = $this->base_logging_xml;
|
1740 |
+
|
1741 |
+
// Authenticate to S3
|
1742 |
+
return $this->authenticate($bucket, $opt);
|
1743 |
+
}
|
1744 |
+
|
1745 |
+
|
1746 |
+
/*%******************************************************************************************%*/
|
1747 |
+
// CONVENIENCE METHODS
|
1748 |
+
|
1749 |
+
/**
|
1750 |
+
* Gets whether or not the specified Amazon S3 bucket exists in Amazon S3. This includes buckets
|
1751 |
+
* that do not belong to the caller.
|
1752 |
+
*
|
1753 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
1754 |
+
* @return boolean A value of <code>true</code> if the bucket exists, or a value of <code>false</code> if it does not.
|
1755 |
+
*/
|
1756 |
+
public function if_bucket_exists($bucket)
|
1757 |
+
{
|
1758 |
+
if ($this->use_batch_flow)
|
1759 |
+
{
|
1760 |
+
throw new S3_Exception(__FUNCTION__ . '() cannot be batch requested');
|
1761 |
+
}
|
1762 |
+
|
1763 |
+
$header = $this->get_bucket_headers($bucket);
|
1764 |
+
return (bool) $header->isOK();
|
1765 |
+
}
|
1766 |
+
|
1767 |
+
/**
|
1768 |
+
* Gets whether or not the specified Amazon S3 object exists in the specified bucket.
|
1769 |
+
*
|
1770 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
1771 |
+
* @param string $filename (Required) The file name for the object.
|
1772 |
+
* @return boolean A value of <code>true</code> if the object exists, or a value of <code>false</code> if it does not.
|
1773 |
+
*/
|
1774 |
+
public function if_object_exists($bucket, $filename)
|
1775 |
+
{
|
1776 |
+
if ($this->use_batch_flow)
|
1777 |
+
{
|
1778 |
+
throw new S3_Exception(__FUNCTION__ . '() cannot be batch requested');
|
1779 |
+
}
|
1780 |
+
|
1781 |
+
$header = $this->get_object_headers($bucket, $filename);
|
1782 |
+
|
1783 |
+
if ($header->isOK()) { return true; }
|
1784 |
+
elseif ($header->status === 404) { return false; }
|
1785 |
+
return null;
|
1786 |
+
}
|
1787 |
+
|
1788 |
+
/**
|
1789 |
+
* Gets whether or not the specified Amazon S3 bucket has a bucket policy associated with it.
|
1790 |
+
*
|
1791 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
1792 |
+
* @return boolean A value of <code>true</code> if a bucket policy exists, or a value of <code>false</code> if one does not.
|
1793 |
+
*/
|
1794 |
+
public function if_bucket_policy_exists($bucket)
|
1795 |
+
{
|
1796 |
+
if ($this->use_batch_flow)
|
1797 |
+
{
|
1798 |
+
throw new S3_Exception(__FUNCTION__ . '() cannot be batch requested');
|
1799 |
+
}
|
1800 |
+
|
1801 |
+
$response = $this->get_bucket_policy($bucket);
|
1802 |
+
|
1803 |
+
if ($response->isOK()) { return true; }
|
1804 |
+
elseif ($response->status === 404) { return false; }
|
1805 |
+
return null;
|
1806 |
+
}
|
1807 |
+
|
1808 |
+
/**
|
1809 |
+
* Gets the number of Amazon S3 objects in the specified bucket.
|
1810 |
+
*
|
1811 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
1812 |
+
* @return integer The number of Amazon S3 objects in the bucket.
|
1813 |
+
*/
|
1814 |
+
public function get_bucket_object_count($bucket)
|
1815 |
+
{
|
1816 |
+
if ($this->use_batch_flow)
|
1817 |
+
{
|
1818 |
+
throw new S3_Exception(__FUNCTION__ . '() cannot be batch requested');
|
1819 |
+
}
|
1820 |
+
|
1821 |
+
return count($this->get_object_list($bucket));
|
1822 |
+
}
|
1823 |
+
|
1824 |
+
/**
|
1825 |
+
* Gets the cumulative file size of the contents of the Amazon S3 bucket.
|
1826 |
+
*
|
1827 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
1828 |
+
* @param boolean $friendly_format (Optional) A value of <code>true</code> will format the return value to 2 decimal points using the largest possible unit (i.e., 3.42 GB). A value of <code>false</code> will format the return value as the raw number of bytes.
|
1829 |
+
* @return integer|string The number of bytes as an integer, or the friendly format as a string.
|
1830 |
+
*/
|
1831 |
+
public function get_bucket_filesize($bucket, $friendly_format = false)
|
1832 |
+
{
|
1833 |
+
if ($this->use_batch_flow)
|
1834 |
+
{
|
1835 |
+
throw new S3_Exception(__FUNCTION__ . '() cannot be batch requested');
|
1836 |
+
}
|
1837 |
+
|
1838 |
+
$filesize = 0;
|
1839 |
+
$list = $this->list_objects($bucket);
|
1840 |
+
|
1841 |
+
foreach ($list->body->Contents as $filename)
|
1842 |
+
{
|
1843 |
+
$filesize += (integer) $filename->Size;
|
1844 |
+
}
|
1845 |
+
|
1846 |
+
while ((string) $list->body->IsTruncated === 'true')
|
1847 |
+
{
|
1848 |
+
$body = (array) $list->body;
|
1849 |
+
$list = $this->list_objects($bucket, array(
|
1850 |
+
'marker' => (string) end($body['Contents'])->Key
|
1851 |
+
));
|
1852 |
+
|
1853 |
+
foreach ($list->body->Contents as $object)
|
1854 |
+
{
|
1855 |
+
$filesize += (integer) $object->Size;
|
1856 |
+
}
|
1857 |
+
}
|
1858 |
+
|
1859 |
+
if ($friendly_format)
|
1860 |
+
{
|
1861 |
+
$filesize = $this->util->size_readable($filesize);
|
1862 |
+
}
|
1863 |
+
|
1864 |
+
return $filesize;
|
1865 |
+
}
|
1866 |
+
|
1867 |
+
/**
|
1868 |
+
* Gets the file size of the specified Amazon S3 object.
|
1869 |
+
*
|
1870 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
1871 |
+
* @param string $filename (Required) The file name for the object.
|
1872 |
+
* @param boolean $friendly_format (Optional) A value of <code>true</code> will format the return value to 2 decimal points using the largest possible unit (i.e., 3.42 GB). A value of <code>false</code> will format the return value as the raw number of bytes.
|
1873 |
+
* @return integer|string The number of bytes as an integer, or the friendly format as a string.
|
1874 |
+
*/
|
1875 |
+
public function get_object_filesize($bucket, $filename, $friendly_format = false)
|
1876 |
+
{
|
1877 |
+
if ($this->use_batch_flow)
|
1878 |
+
{
|
1879 |
+
throw new S3_Exception(__FUNCTION__ . '() cannot be batch requested');
|
1880 |
+
}
|
1881 |
+
|
1882 |
+
$object = $this->get_object_headers($bucket, $filename);
|
1883 |
+
$filesize = (integer) $object->header['content-length'];
|
1884 |
+
|
1885 |
+
if ($friendly_format)
|
1886 |
+
{
|
1887 |
+
$filesize = $this->util->size_readable($filesize);
|
1888 |
+
}
|
1889 |
+
|
1890 |
+
return $filesize;
|
1891 |
+
}
|
1892 |
+
|
1893 |
+
/**
|
1894 |
+
* Changes the content type for an existing Amazon S3 object.
|
1895 |
+
*
|
1896 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
1897 |
+
* @param string $filename (Required) The file name for the object.
|
1898 |
+
* @param string $contentType (Required) The content-type to apply to the object.
|
1899 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1900 |
+
* <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>
|
1901 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1902 |
+
*/
|
1903 |
+
public function change_content_type($bucket, $filename, $contentType, $opt = null)
|
1904 |
+
{
|
1905 |
+
if (!$opt) $opt = array();
|
1906 |
+
|
1907 |
+
// Retrieve the original metadata
|
1908 |
+
$metadata = $this->get_object_metadata($bucket, $filename);
|
1909 |
+
if ($metadata && $metadata['ACL'])
|
1910 |
+
{
|
1911 |
+
$opt['acl'] = $metadata['ACL'];
|
1912 |
+
}
|
1913 |
+
if ($metadata && $metadata['StorageClass'])
|
1914 |
+
{
|
1915 |
+
$opt['headers']['x-amz-storage-class'] = $metadata['StorageClass'];
|
1916 |
+
}
|
1917 |
+
|
1918 |
+
// Merge optional parameters
|
1919 |
+
$opt = array_merge_recursive(array(
|
1920 |
+
'headers' => array(
|
1921 |
+
'Content-Type' => $contentType
|
1922 |
+
),
|
1923 |
+
'metadataDirective' => 'REPLACE'
|
1924 |
+
), $opt);
|
1925 |
+
|
1926 |
+
return $this->copy_object(
|
1927 |
+
array('bucket' => $bucket, 'filename' => $filename),
|
1928 |
+
array('bucket' => $bucket, 'filename' => $filename),
|
1929 |
+
$opt
|
1930 |
+
);
|
1931 |
+
}
|
1932 |
+
|
1933 |
+
/**
|
1934 |
+
* Changes the storage redundancy for an existing object.
|
1935 |
+
*
|
1936 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
1937 |
+
* @param string $filename (Required) The file name for the object.
|
1938 |
+
* @param string $storage (Required) The storage setting to apply to the object. [Allowed values: <code>AmazonS3::STORAGE_STANDARD</code>, <code>AmazonS3::STORAGE_REDUCED</code>]
|
1939 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1940 |
+
* <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>
|
1941 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1942 |
+
*/
|
1943 |
+
public function change_storage_redundancy($bucket, $filename, $storage, $opt = null)
|
1944 |
+
{
|
1945 |
+
if (!$opt) $opt = array();
|
1946 |
+
|
1947 |
+
// Retrieve the original metadata
|
1948 |
+
$metadata = $this->get_object_metadata($bucket, $filename);
|
1949 |
+
if ($metadata && $metadata['ACL'])
|
1950 |
+
{
|
1951 |
+
$opt['acl'] = $metadata['ACL'];
|
1952 |
+
}
|
1953 |
+
if ($metadata && $metadata['ContentType'])
|
1954 |
+
{
|
1955 |
+
$opt['headers']['Content-Type'] = $metadata['ContentType'];
|
1956 |
+
}
|
1957 |
+
|
1958 |
+
// Merge optional parameters
|
1959 |
+
$opt = array_merge(array(
|
1960 |
+
'storage' => $storage,
|
1961 |
+
'metadataDirective' => 'COPY',
|
1962 |
+
), $opt);
|
1963 |
+
|
1964 |
+
return $this->copy_object(
|
1965 |
+
array('bucket' => $bucket, 'filename' => $filename),
|
1966 |
+
array('bucket' => $bucket, 'filename' => $filename),
|
1967 |
+
$opt
|
1968 |
+
);
|
1969 |
+
}
|
1970 |
+
|
1971 |
+
/**
|
1972 |
+
* Gets a simplified list of bucket names on an Amazon S3 account.
|
1973 |
+
*
|
1974 |
+
* @param string $pcre (Optional) A Perl-Compatible Regular Expression (PCRE) to filter the bucket names against.
|
1975 |
+
* @return array The list of matching bucket names. If there are no results, the method will return an empty array.
|
1976 |
+
* @link http://php.net/pcre Regular Expressions (Perl-Compatible)
|
1977 |
+
*/
|
1978 |
+
public function get_bucket_list($pcre = null)
|
1979 |
+
{
|
1980 |
+
if ($this->use_batch_flow)
|
1981 |
+
{
|
1982 |
+
throw new S3_Exception(__FUNCTION__ . '() cannot be batch requested');
|
1983 |
+
}
|
1984 |
+
|
1985 |
+
// Get a list of buckets.
|
1986 |
+
$list = $this->list_buckets();
|
1987 |
+
if ($list = $list->body->query('descendant-or-self::Name'))
|
1988 |
+
{
|
1989 |
+
$list = $list->map_string($pcre);
|
1990 |
+
return $list;
|
1991 |
+
}
|
1992 |
+
|
1993 |
+
return array();
|
1994 |
+
}
|
1995 |
+
|
1996 |
+
/**
|
1997 |
+
* Gets a simplified list of Amazon S3 object file names contained in a bucket.
|
1998 |
+
*
|
1999 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
2000 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2001 |
+
* <li><code>delimiter</code> - <code>string</code> - Optional - Keys that contain the same string between the prefix and the first occurrence of the delimiter will be rolled up into a single result element in the CommonPrefixes collection.</li>
|
2002 |
+
* <li><code>marker</code> - <code>string</code> - Optional - Restricts the response to contain results that only occur alphabetically after the value of the marker.</li>
|
2003 |
+
* <li><code>max-keys</code> - <code>string</code> - Optional - The maximum number of results returned by the method call. The returned list will contain no more results than the specified value, but may return less.</li>
|
2004 |
+
* <li><code>pcre</code> - <code>string</code> - Optional - A Perl-Compatible Regular Expression (PCRE) to filter the names against. This is applied only AFTER any native Amazon S3 filtering from specified <code>prefix</code>, <code>marker</code>, <code>max-keys</code>, or <code>delimiter</code> values are applied.</li>
|
2005 |
+
* <li><code>prefix</code> - <code>string</code> - Optional - Restricts the response to contain results that begin only with the specified prefix.</li>
|
2006 |
+
* <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>
|
2007 |
+
* @return array The list of matching object names. If there are no results, the method will return an empty array.
|
2008 |
+
* @link http://php.net/pcre Regular Expressions (Perl-Compatible)
|
2009 |
+
*/
|
2010 |
+
public function get_object_list($bucket, $opt = null)
|
2011 |
+
{
|
2012 |
+
if ($this->use_batch_flow)
|
2013 |
+
{
|
2014 |
+
throw new S3_Exception(__FUNCTION__ . '() cannot be batch requested');
|
2015 |
+
}
|
2016 |
+
|
2017 |
+
if (!$opt) $opt = array();
|
2018 |
+
|
2019 |
+
// Set some default values
|
2020 |
+
$pcre = isset($opt['pcre']) ? $opt['pcre'] : null;
|
2021 |
+
$max_keys = isset($opt['max-keys']) ? (integer) $opt['max-keys'] : 'all';
|
2022 |
+
$objects = array();
|
2023 |
+
|
2024 |
+
if ($max_keys === 'all')
|
2025 |
+
{
|
2026 |
+
do
|
2027 |
+
{
|
2028 |
+
$list = $this->list_objects($bucket, $opt);
|
2029 |
+
if ($keys = $list->body->query('descendant-or-self::Key')->map_string($pcre))
|
2030 |
+
{
|
2031 |
+
$objects = array_merge($objects, $keys);
|
2032 |
+
}
|
2033 |
+
|
2034 |
+
$body = (array) $list->body;
|
2035 |
+
$opt = array_merge($opt, array(
|
2036 |
+
'marker' => (isset($body['Contents']) && is_array($body['Contents'])) ?
|
2037 |
+
((string) end($body['Contents'])->Key) :
|
2038 |
+
((string) $list->body->Contents->Key)
|
2039 |
+
));
|
2040 |
+
}
|
2041 |
+
while ((string) $list->body->IsTruncated === 'true');
|
2042 |
+
}
|
2043 |
+
else
|
2044 |
+
{
|
2045 |
+
$loops = ceil($max_keys / 1000);
|
2046 |
+
|
2047 |
+
do
|
2048 |
+
{
|
2049 |
+
$list = $this->list_objects($bucket, $opt);
|
2050 |
+
if ($keys = $list->body->query('descendant-or-self::Key')->map_string($pcre))
|
2051 |
+
{
|
2052 |
+
$objects = array_merge($objects, $keys);
|
2053 |
+
}
|
2054 |
+
|
2055 |
+
if ($max_keys > 1000)
|
2056 |
+
{
|
2057 |
+
$max_keys -= 1000;
|
2058 |
+
}
|
2059 |
+
|
2060 |
+
$body = (array) $list->body;
|
2061 |
+
$opt = array_merge($opt, array(
|
2062 |
+
'max-keys' => $max_keys,
|
2063 |
+
'marker' => (isset($body['Contents']) && is_array($body['Contents'])) ?
|
2064 |
+
((string) end($body['Contents'])->Key) :
|
2065 |
+
((string) $list->body->Contents->Key)
|
2066 |
+
));
|
2067 |
+
}
|
2068 |
+
while (--$loops);
|
2069 |
+
}
|
2070 |
+
|
2071 |
+
if (count($objects) > 0)
|
2072 |
+
{
|
2073 |
+
return $objects;
|
2074 |
+
}
|
2075 |
+
|
2076 |
+
return array();
|
2077 |
+
}
|
2078 |
+
|
2079 |
+
/**
|
2080 |
+
* Deletes all Amazon S3 objects inside the specified bucket.
|
2081 |
+
*
|
2082 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
2083 |
+
* @param string $pcre (Optional) A Perl-Compatible Regular Expression (PCRE) to filter the names against. The default value is <PCRE_ALL>.
|
2084 |
+
* @return boolean A value of <code>true</code> means that all objects were successfully deleted. A value of <code>false</code> means that at least one object failed to delete.
|
2085 |
+
* @link http://php.net/pcre Regular Expressions (Perl-Compatible)
|
2086 |
+
*/
|
2087 |
+
public function delete_all_objects($bucket, $pcre = self::PCRE_ALL)
|
2088 |
+
{
|
2089 |
+
if ($this->use_batch_flow)
|
2090 |
+
{
|
2091 |
+
throw new S3_Exception(__FUNCTION__ . '() cannot be batch requested');
|
2092 |
+
}
|
2093 |
+
|
2094 |
+
// Collect all matches
|
2095 |
+
$list = $this->get_object_list($bucket, array('pcre' => $pcre));
|
2096 |
+
|
2097 |
+
// As long as we have at least one match...
|
2098 |
+
if (count($list) > 0)
|
2099 |
+
{
|
2100 |
+
// Create new batch request object
|
2101 |
+
$q = new $this->batch_class();
|
2102 |
+
|
2103 |
+
// Go through all of the items and delete them.
|
2104 |
+
foreach ($list as $item)
|
2105 |
+
{
|
2106 |
+
$this->batch($q)->delete_object($bucket, $item);
|
2107 |
+
}
|
2108 |
+
|
2109 |
+
return $this->batch($q)->send()->areOK();
|
2110 |
+
}
|
2111 |
+
|
2112 |
+
// If there are no matches, return true
|
2113 |
+
return true;
|
2114 |
+
}
|
2115 |
+
|
2116 |
+
/**
|
2117 |
+
* Deletes all of the versions of all Amazon S3 objects inside the specified bucket.
|
2118 |
+
*
|
2119 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
2120 |
+
* @param string $pcre (Optional) A Perl-Compatible Regular Expression (PCRE) to filter the names against. The default value is <PCRE_ALL>.
|
2121 |
+
* @return boolean A value of <code>true</code> means that all object versions were successfully deleted. A value of <code>false</code> means that at least one object/version failed to delete.
|
2122 |
+
* @link http://php.net/pcre Regular Expressions (Perl-Compatible)
|
2123 |
+
*/
|
2124 |
+
public function delete_all_object_versions($bucket, $pcre = null)
|
2125 |
+
{
|
2126 |
+
if ($this->use_batch_flow)
|
2127 |
+
{
|
2128 |
+
throw new S3_Exception(__FUNCTION__ . '() cannot be batch requested');
|
2129 |
+
}
|
2130 |
+
|
2131 |
+
// Instantiate
|
2132 |
+
$q = new CFBatchRequest(200);
|
2133 |
+
$response = $this->list_bucket_object_versions($bucket);
|
2134 |
+
|
2135 |
+
// Gather all nodes together into a single array
|
2136 |
+
if ($response->body->DeleteMarker() && $response->body->Version())
|
2137 |
+
{
|
2138 |
+
$markers = array_merge($response->body->DeleteMarker()->getArrayCopy(), $response->body->Version()->getArrayCopy());
|
2139 |
+
}
|
2140 |
+
elseif ($response->body->DeleteMarker())
|
2141 |
+
{
|
2142 |
+
$markers = $response->body->DeleteMarker()->getArrayCopy();
|
2143 |
+
}
|
2144 |
+
elseif ($response->body->Version())
|
2145 |
+
{
|
2146 |
+
$markers = $response->body->Version()->getArrayCopy();
|
2147 |
+
}
|
2148 |
+
else
|
2149 |
+
{
|
2150 |
+
$markers = array();
|
2151 |
+
}
|
2152 |
+
|
2153 |
+
while ((string) $response->body->IsTruncated === 'true')
|
2154 |
+
{
|
2155 |
+
$response = $this->list_bucket_object_versions($bucket, array(
|
2156 |
+
'key-marker' => (string) $response->body->NextKeyMarker
|
2157 |
+
));
|
2158 |
+
|
2159 |
+
// Gather all nodes together into a single array
|
2160 |
+
if ($response->body->DeleteMarker() && $response->body->Version())
|
2161 |
+
{
|
2162 |
+
$markers = array_merge($markers, $response->body->DeleteMarker()->getArrayCopy(), $response->body->Version()->getArrayCopy());
|
2163 |
+
}
|
2164 |
+
elseif ($response->body->DeleteMarker())
|
2165 |
+
{
|
2166 |
+
$markers = array_merge($markers, $response->body->DeleteMarker()->getArrayCopy());
|
2167 |
+
}
|
2168 |
+
elseif ($response->body->Version())
|
2169 |
+
{
|
2170 |
+
$markers = array_merge($markers, $response->body->Version()->getArrayCopy());
|
2171 |
+
}
|
2172 |
+
}
|
2173 |
+
|
2174 |
+
// Loop through markers
|
2175 |
+
foreach ($markers as $marker)
|
2176 |
+
{
|
2177 |
+
if ($pcre)
|
2178 |
+
{
|
2179 |
+
if (preg_match($pcre, (string) $marker->Key))
|
2180 |
+
{
|
2181 |
+
$this->batch($q)->delete_object($bucket, (string) $marker->Key, array(
|
2182 |
+
'versionId' => (string) $marker->VersionId
|
2183 |
+
));
|
2184 |
+
}
|
2185 |
+
}
|
2186 |
+
else
|
2187 |
+
{
|
2188 |
+
$this->batch($q)->delete_object($bucket, (string) $marker->Key, array(
|
2189 |
+
'versionId' => (string) $marker->VersionId
|
2190 |
+
));
|
2191 |
+
}
|
2192 |
+
}
|
2193 |
+
|
2194 |
+
return $this->batch($q)->send();
|
2195 |
+
}
|
2196 |
+
|
2197 |
+
/**
|
2198 |
+
* Gets the collective metadata for the given Amazon S3 object.
|
2199 |
+
*
|
2200 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
2201 |
+
* @param string $filename (Required) The file name for the Amazon S3 object.
|
2202 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2203 |
+
* <li><code>versionId</code> - <code>string</code> - Optional - The version of the object to retrieve. Version IDs are returned in the <code>x-amz-version-id</code> header of any previous object-related request.</li>
|
2204 |
+
* <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>
|
2205 |
+
* @return mixed If the object exists, the method returns the collective metadata for the Amazon S3 object. If the object does not exist, the method returns boolean <code>false</code>.
|
2206 |
+
*/
|
2207 |
+
public function get_object_metadata($bucket, $filename, $opt = null)
|
2208 |
+
{
|
2209 |
+
$batch = new CFBatchRequest();
|
2210 |
+
$this->batch($batch)->get_object_acl($bucket, $filename); // Get ACL info
|
2211 |
+
$this->batch($batch)->get_object_headers($bucket, $filename); // Get content-type
|
2212 |
+
$this->batch($batch)->list_objects($bucket, array( // Get other metadata
|
2213 |
+
'max-keys' => 1,
|
2214 |
+
'prefix' => $filename
|
2215 |
+
));
|
2216 |
+
$response = $this->batch($batch)->send();
|
2217 |
+
|
2218 |
+
// Fail if any requests were unsuccessful
|
2219 |
+
if (!$response->areOK())
|
2220 |
+
{
|
2221 |
+
return false;
|
2222 |
+
}
|
2223 |
+
|
2224 |
+
$data = array(
|
2225 |
+
'ACL' => array(),
|
2226 |
+
'ContentType' => null,
|
2227 |
+
'ETag' => null,
|
2228 |
+
'Headers' => null,
|
2229 |
+
'Key' => null,
|
2230 |
+
'LastModified' => null,
|
2231 |
+
'Owner' => array(),
|
2232 |
+
'Size' => null,
|
2233 |
+
'StorageClass' => null,
|
2234 |
+
);
|
2235 |
+
|
2236 |
+
// Add the content type
|
2237 |
+
$data['ContentType'] = (string) $response[1]->header['content-type'];
|
2238 |
+
|
2239 |
+
// Add the other metadata (including storage type)
|
2240 |
+
$contents = json_decode(json_encode($response[2]->body->query('descendant-or-self::Contents')->first()), true);
|
2241 |
+
$data = array_merge($data, (is_array($contents) ? $contents : array()));
|
2242 |
+
|
2243 |
+
// Add ACL info
|
2244 |
+
$grants = $response[0]->body->query('descendant-or-self::Grant');
|
2245 |
+
$max = count($grants);
|
2246 |
+
|
2247 |
+
// Add raw header info
|
2248 |
+
$data['Headers'] = $response[1]->header;
|
2249 |
+
foreach (array('_info', 'x-amz-id-2', 'x-amz-request-id', 'cneonction', 'server', 'content-length', 'content-type', 'etag') as $header)
|
2250 |
+
{
|
2251 |
+
unset($data['Headers'][$header]);
|
2252 |
+
}
|
2253 |
+
ksort($data['Headers']);
|
2254 |
+
|
2255 |
+
if (count($grants) > 0)
|
2256 |
+
{
|
2257 |
+
foreach ($grants as $grant)
|
2258 |
+
{
|
2259 |
+
$dgrant = array(
|
2260 |
+
'id' => (string) $this->util->try_these(array('ID', 'URI'), $grant->Grantee),
|
2261 |
+
'permission' => (string) $grant->Permission
|
2262 |
+
);
|
2263 |
+
|
2264 |
+
$data['ACL'][] = $dgrant;
|
2265 |
+
}
|
2266 |
+
}
|
2267 |
+
|
2268 |
+
return $data;
|
2269 |
+
}
|
2270 |
+
|
2271 |
+
|
2272 |
+
/*%******************************************************************************************%*/
|
2273 |
+
// URLS
|
2274 |
+
|
2275 |
+
/**
|
2276 |
+
* Gets the web-accessible URL for the Amazon S3 object or generates a time-limited signed request for
|
2277 |
+
* a private file.
|
2278 |
+
*
|
2279 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
2280 |
+
* @param string $filename (Required) The file name for the Amazon S3 object.
|
2281 |
+
* @param integer|string $preauth (Optional) Specifies that a presigned URL for this request should be returned. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.
|
2282 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2283 |
+
* <li><code>method</code> - <code>string</code> - Optional - The HTTP method to use for the request. Defaults to a value of <code>GET</code>.</li>
|
2284 |
+
* <li><code>response</code> - <code>array</code> - Optional - Allows adjustments to specific response headers. Pass an associative array where each key is one of the following: <code>cache-control</code>, <code>content-disposition</code>, <code>content-encoding</code>, <code>content-language</code>, <code>content-type</code>, <code>expires</code>. The <code>expires</code> value should use <php:gmdate()> and be formatted with the <code>DATE_RFC2822</code> constant.</li>
|
2285 |
+
* <li><code>torrent</code> - <code>boolean</code> - Optional - A value of <code>true</code> will return a URL to a torrent of the Amazon S3 object. A value of <code>false</code> will return a non-torrent URL. Defaults to <code>false</code>.</li>
|
2286 |
+
* <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>
|
2287 |
+
* @return string The file URL, with authentication and/or torrent parameters if requested.
|
2288 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/S3_QSAuth.html Using Query String Authentication
|
2289 |
+
*/
|
2290 |
+
public function get_object_url($bucket, $filename, $preauth = 0, $opt = null)
|
2291 |
+
{
|
2292 |
+
// Add this to our request
|
2293 |
+
if (!$opt) $opt = array();
|
2294 |
+
$opt['verb'] = isset($opt['method']) ? $opt['method'] : 'GET';
|
2295 |
+
$opt['resource'] = $filename;
|
2296 |
+
$opt['preauth'] = $preauth;
|
2297 |
+
|
2298 |
+
if (isset($opt['torrent']) && $opt['torrent'])
|
2299 |
+
{
|
2300 |
+
$opt['sub_resource'] = 'torrent';
|
2301 |
+
unset($opt['torrent']);
|
2302 |
+
}
|
2303 |
+
|
2304 |
+
// GET responses
|
2305 |
+
if (isset($opt['response']))
|
2306 |
+
{
|
2307 |
+
foreach ($opt['response'] as $key => $value)
|
2308 |
+
{
|
2309 |
+
$opt['response-' . $key] = $value;
|
2310 |
+
unset($opt['response'][$key]);
|
2311 |
+
}
|
2312 |
+
}
|
2313 |
+
|
2314 |
+
// Authenticate to S3
|
2315 |
+
$current_ssl_setting = $this->use_ssl;
|
2316 |
+
$this->use_ssl = false;
|
2317 |
+
$response = $this->authenticate($bucket, $opt);
|
2318 |
+
$this->use_ssl = $current_ssl_setting;
|
2319 |
+
|
2320 |
+
return $response;
|
2321 |
+
}
|
2322 |
+
|
2323 |
+
/**
|
2324 |
+
* Gets the web-accessible URL to a torrent of the Amazon S3 object. The Amazon S3 object's access
|
2325 |
+
* control list settings (ACL) MUST be set to <ACL_PUBLIC> for a valid URL to be returned.
|
2326 |
+
*
|
2327 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
2328 |
+
* @param string $filename (Required) The file name for the object.
|
2329 |
+
* @param integer|string $preauth (Optional) Specifies that a presigned URL for this request should be returned. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.
|
2330 |
+
* @return string The torrent URL, with authentication parameters if requested.
|
2331 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/index.html?S3TorrentRetrieve.html Using BitTorrent to Retrieve Objects Stored in Amazon S3
|
2332 |
+
*/
|
2333 |
+
public function get_torrent_url($bucket, $filename, $preauth = 0)
|
2334 |
+
{
|
2335 |
+
return $this->get_object_url($bucket, $filename, $preauth, array(
|
2336 |
+
'torrent' => true
|
2337 |
+
));
|
2338 |
+
}
|
2339 |
+
|
2340 |
+
|
2341 |
+
/*%******************************************************************************************%*/
|
2342 |
+
// VERSIONING
|
2343 |
+
|
2344 |
+
/**
|
2345 |
+
* Enables versioning support for the specified Amazon S3 bucket.
|
2346 |
+
*
|
2347 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
2348 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2349 |
+
* <li><code>MFASerial</code> - string (Optional) The serial number on the back of the Gemalto device. <code>MFASerial</code>, <code>MFAToken</code> and <code>MFAStatus</code> must all be set for MFA to work.</li>
|
2350 |
+
* <li><code>MFAToken</code> - string (Optional) The current token displayed on the Gemalto device. <code>MFASerial</code>, <code>MFAToken</code> and <code>MFAStatus</code> must all be set for MFA to work.</li>
|
2351 |
+
* <li><code>MFAStatus</code> - string (Optional) The MFA Delete status. Can be <code>Enabled</code> or <code>Disabled</code>. <code>MFASerial</code>, <code>MFAToken</code> and <code>MFAStatus</code> must all be set for MFA to work.</li>
|
2352 |
+
* <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>
|
2353 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2354 |
+
* @link http://aws.amazon.com/mfa/ Multi-Factor Authentication
|
2355 |
+
*/
|
2356 |
+
public function enable_versioning($bucket, $opt = null)
|
2357 |
+
{
|
2358 |
+
if (!$opt) $opt = array();
|
2359 |
+
|
2360 |
+
// Add this to our request
|
2361 |
+
$opt['verb'] = 'PUT';
|
2362 |
+
$opt['sub_resource'] = 'versioning';
|
2363 |
+
$opt['headers'] = array(
|
2364 |
+
'Content-Type' => 'application/xml'
|
2365 |
+
);
|
2366 |
+
|
2367 |
+
$xml = simplexml_load_string($this->base_versioning_xml);
|
2368 |
+
$xml->addChild('Status', 'Enabled');
|
2369 |
+
|
2370 |
+
// Enable MFA delete?
|
2371 |
+
if (isset($opt['MFASerial']) && isset($opt['MFAToken']) && isset($opt['MFAStatus']))
|
2372 |
+
{
|
2373 |
+
$xml->addChild('MfaDelete', $opt['MFAStatus']);
|
2374 |
+
|
2375 |
+
$opt['headers']['x-amz-mfa'] = ($opt['MFASerial'] . ' ' . $opt['MFAToken']);
|
2376 |
+
}
|
2377 |
+
|
2378 |
+
$opt['body'] = $xml->asXML();
|
2379 |
+
|
2380 |
+
// Authenticate to S3
|
2381 |
+
return $this->authenticate($bucket, $opt);
|
2382 |
+
}
|
2383 |
+
|
2384 |
+
/**
|
2385 |
+
* Disables versioning support for the specified Amazon S3 bucket.
|
2386 |
+
*
|
2387 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
2388 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2389 |
+
* <li><code>MFASerial</code> - <code>string</code> - Optional - The serial number on the back of the Gemalto device. <code>MFASerial</code>, <code>MFAToken</code> and <code>MFAStatus</code> must all be set for MFA to work.</li>
|
2390 |
+
* <li><code>MFAToken</code> - <code>string</code> - Optional - The current token displayed on the Gemalto device. <code>MFASerial</code>, <code>MFAToken</code> and <code>MFAStatus</code> must all be set for MFA to work.</li>
|
2391 |
+
* <li><code>MFAStatus</code> - <code>string</code> - Optional - The MFA Delete status. Can be <code>Enabled</code> or <code>Disabled</code>. <code>MFASerial</code>, <code>MFAToken</code> and <code>MFAStatus</code> must all be set for MFA to work.</li>
|
2392 |
+
* <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>
|
2393 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2394 |
+
* @link http://aws.amazon.com/mfa/ Multi-Factor Authentication
|
2395 |
+
*/
|
2396 |
+
public function disable_versioning($bucket, $opt = null)
|
2397 |
+
{
|
2398 |
+
if (!$opt) $opt = array();
|
2399 |
+
|
2400 |
+
// Add this to our request
|
2401 |
+
$opt['verb'] = 'PUT';
|
2402 |
+
$opt['sub_resource'] = 'versioning';
|
2403 |
+
$opt['headers'] = array(
|
2404 |
+
'Content-Type' => 'application/xml'
|
2405 |
+
);
|
2406 |
+
|
2407 |
+
$xml = simplexml_load_string($this->base_versioning_xml);
|
2408 |
+
$xml->addChild('Status', 'Suspended');
|
2409 |
+
|
2410 |
+
// Enable MFA delete?
|
2411 |
+
if (isset($opt['MFASerial']) && isset($opt['MFAToken']) && isset($opt['MFAStatus']))
|
2412 |
+
{
|
2413 |
+
$xml->addChild('MfaDelete', $opt['MFAStatus']);
|
2414 |
+
|
2415 |
+
$opt['headers']['x-amz-mfa'] = ($opt['MFASerial'] . ' ' . $opt['MFAToken']);
|
2416 |
+
}
|
2417 |
+
|
2418 |
+
$opt['body'] = $xml->asXML();
|
2419 |
+
|
2420 |
+
// Authenticate to S3
|
2421 |
+
return $this->authenticate($bucket, $opt);
|
2422 |
+
}
|
2423 |
+
|
2424 |
+
/**
|
2425 |
+
* Gets an Amazon S3 bucket's versioning status.
|
2426 |
+
*
|
2427 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
2428 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2429 |
+
* <li><code>preauth</code> - <code>integer|string</code> - Optional - Specifies that a presigned URL for this request should be returned. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
2430 |
+
* <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>
|
2431 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2432 |
+
*/
|
2433 |
+
public function get_versioning_status($bucket, $opt = null)
|
2434 |
+
{
|
2435 |
+
if (!$opt) $opt = array();
|
2436 |
+
$opt['verb'] = 'GET';
|
2437 |
+
$opt['sub_resource'] = 'versioning';
|
2438 |
+
|
2439 |
+
// Authenticate to S3
|
2440 |
+
return $this->authenticate($bucket, $opt);
|
2441 |
+
}
|
2442 |
+
|
2443 |
+
/**
|
2444 |
+
* Gets a list of all the versions of Amazon S3 objects in the specified bucket.
|
2445 |
+
*
|
2446 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
2447 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2448 |
+
* <li><code>delimiter</code> - <code>string</code> - Optional - Unicode string parameter. Keys that contain the same string between the prefix and the first occurrence of the delimiter will be rolled up into a single result element in the CommonPrefixes collection.</li>
|
2449 |
+
* <li><code>key-marker</code> - <code>string</code> - Optional - Restricts the response to contain results that only occur alphabetically after the value of the <code>key-marker</code>.</li>
|
2450 |
+
* <li><code>max-keys</code> - <code>string</code> - Optional - Limits the number of results returned in response to your query. Will return no more than this number of results, but possibly less.</li>
|
2451 |
+
* <li><code>prefix</code> - <code>string</code> - Optional - Restricts the response to only contain results that begin with the specified prefix.</li>
|
2452 |
+
* <li><code>version-id-marker</code> - <code>string</code> - Optional - Restricts the response to contain results that only occur alphabetically after the value of the <code>version-id-marker</code>.</li>
|
2453 |
+
* <li><code>preauth</code> - <code>integer|string</code> - Optional - Specifies that a presigned URL for this request should be returned. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.</li>
|
2454 |
+
* <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>
|
2455 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2456 |
+
*/
|
2457 |
+
public function list_bucket_object_versions($bucket, $opt = null)
|
2458 |
+
{
|
2459 |
+
if (!$opt) $opt = array();
|
2460 |
+
$opt['verb'] = 'GET';
|
2461 |
+
$opt['sub_resource'] = 'versions';
|
2462 |
+
|
2463 |
+
foreach (array('delimiter', 'key-marker', 'max-keys', 'prefix', 'version-id-marker') as $param)
|
2464 |
+
{
|
2465 |
+
if (isset($opt[$param]))
|
2466 |
+
{
|
2467 |
+
$opt['query_string'][$param] = $opt[$param];
|
2468 |
+
unset($opt[$param]);
|
2469 |
+
}
|
2470 |
+
}
|
2471 |
+
|
2472 |
+
// Authenticate to S3
|
2473 |
+
return $this->authenticate($bucket, $opt);
|
2474 |
+
}
|
2475 |
+
|
2476 |
+
|
2477 |
+
/*%******************************************************************************************%*/
|
2478 |
+
// BUCKET POLICIES
|
2479 |
+
|
2480 |
+
/**
|
2481 |
+
* Sets the policy sub-resource for the specified Amazon S3 bucket. The specified policy replaces any
|
2482 |
+
* policy the bucket already has.
|
2483 |
+
*
|
2484 |
+
* To perform this operation, the caller must be authorized to set a policy for the bucket and have
|
2485 |
+
* PutPolicy permissions. If the caller does not have PutPolicy permissions for the bucket, Amazon S3
|
2486 |
+
* returns a `403 Access Denied` error. If the caller has the correct permissions but has not been
|
2487 |
+
* authorized by the bucket owner, Amazon S3 returns a `405 Method Not Allowed` error.
|
2488 |
+
*
|
2489 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
2490 |
+
* @param CFPolicy $policy (Required) The JSON policy to use.
|
2491 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2492 |
+
* <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>
|
2493 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2494 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/dev/AccessPolicyLanguage.html Appendix: The Access Policy Language
|
2495 |
+
*/
|
2496 |
+
public function set_bucket_policy($bucket, CFPolicy $policy, $opt = null)
|
2497 |
+
{
|
2498 |
+
if (!$opt) $opt = array();
|
2499 |
+
$opt['verb'] = 'PUT';
|
2500 |
+
$opt['sub_resource'] = 'policy';
|
2501 |
+
$opt['body'] = $policy->get_json();
|
2502 |
+
|
2503 |
+
// Authenticate to S3
|
2504 |
+
return $this->authenticate($bucket, $opt);
|
2505 |
+
}
|
2506 |
+
|
2507 |
+
/**
|
2508 |
+
* Gets the policy of the specified Amazon S3 bucket.
|
2509 |
+
*
|
2510 |
+
* To use this operation, the caller must have GetPolicy permissions for the specified bucket and must be
|
2511 |
+
* the bucket owner. If the caller does not have GetPolicy permissions, this method will generate a
|
2512 |
+
* `403 Access Denied` error. If the caller has the correct permissions but is not the bucket owner, this
|
2513 |
+
* method will generate a `405 Method Not Allowed` error. If the bucket does not have a policy defined for
|
2514 |
+
* it, this method will generate a `404 Policy Not Found` error.
|
2515 |
+
*
|
2516 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
2517 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2518 |
+
* <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>
|
2519 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2520 |
+
*/
|
2521 |
+
public function get_bucket_policy($bucket, $opt = null)
|
2522 |
+
{
|
2523 |
+
if (!$opt) $opt = array();
|
2524 |
+
$opt['verb'] = 'GET';
|
2525 |
+
$opt['sub_resource'] = 'policy';
|
2526 |
+
|
2527 |
+
// Authenticate to S3
|
2528 |
+
return $this->authenticate($bucket, $opt);
|
2529 |
+
}
|
2530 |
+
|
2531 |
+
/**
|
2532 |
+
* Deletes the bucket policy for the specified Amazon S3 bucket. To delete the policy, the caller must
|
2533 |
+
* be the bucket owner and have `DeletePolicy` permissions for the specified bucket.
|
2534 |
+
*
|
2535 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
2536 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2537 |
+
* <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>
|
2538 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response. If you do not have `DeletePolicy` permissions, Amazon S3 returns a `403 Access Denied` error. If you have the correct permissions, but are not the bucket owner, Amazon S3 returns a `405 Method Not Allowed` error. If the bucket doesn't have a policy, Amazon S3 returns a `204 No Content` error.
|
2539 |
+
*/
|
2540 |
+
public function delete_bucket_policy($bucket, $opt = null)
|
2541 |
+
{
|
2542 |
+
if (!$opt) $opt = array();
|
2543 |
+
$opt['verb'] = 'DELETE';
|
2544 |
+
$opt['sub_resource'] = 'policy';
|
2545 |
+
|
2546 |
+
// Authenticate to S3
|
2547 |
+
return $this->authenticate($bucket, $opt);
|
2548 |
+
}
|
2549 |
+
|
2550 |
+
|
2551 |
+
/*%******************************************************************************************%*/
|
2552 |
+
// BUCKET NOTIFICATIONS
|
2553 |
+
|
2554 |
+
/**
|
2555 |
+
* Enables notifications of specified events for an Amazon S3 bucket. Currently, the
|
2556 |
+
* `s3:ReducedRedundancyLostObject` event is the only event supported for notifications. The
|
2557 |
+
* `s3:ReducedRedundancyLostObject` event is triggered when Amazon S3 detects that it has lost all
|
2558 |
+
* copies of an Amazon S3 object and can no longer service requests for that object.
|
2559 |
+
*
|
2560 |
+
* If the bucket owner and Amazon SNS topic owner are the same, the bucket owner has permission to
|
2561 |
+
* publish notifications to the topic by default. Otherwise, the owner of the topic must create a
|
2562 |
+
* policy to enable the bucket owner to publish to the topic.
|
2563 |
+
*
|
2564 |
+
* By default, only the bucket owner can configure notifications on a bucket. However, bucket owners
|
2565 |
+
* can use bucket policies to grant permission to other users to set this configuration with the
|
2566 |
+
* `s3:PutBucketNotification` permission.
|
2567 |
+
*
|
2568 |
+
* After a PUT operation is called to configure notifications on a bucket, Amazon S3 publishes a test
|
2569 |
+
* notification to ensure that the topic exists and that the bucket owner has permission to publish
|
2570 |
+
* to the specified topic. If the notification is successfully published to the SNS topic, the PUT
|
2571 |
+
* operation updates the bucket configuration and returns the 200 OK responses with a
|
2572 |
+
* `x-amz-sns-test-message-id` header containing the message ID of the test notification sent to topic.
|
2573 |
+
*
|
2574 |
+
* @param string $bucket (Required) The name of the bucket to create bucket notifications for.
|
2575 |
+
* @param string $topic_arn (Required) The SNS topic ARN to send notifications to.
|
2576 |
+
* @param string $event (Required) The event type to listen for.
|
2577 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2578 |
+
* <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>
|
2579 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2580 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/dev/NotificationHowTo.html Setting Up Notification of Bucket Events
|
2581 |
+
*/
|
2582 |
+
public function create_bucket_notification($bucket, $topic_arn, $event, $opt = null)
|
2583 |
+
{
|
2584 |
+
if (!$opt) $opt = array();
|
2585 |
+
$opt['verb'] = 'PUT';
|
2586 |
+
$opt['sub_resource'] = 'notification';
|
2587 |
+
$opt['headers'] = array(
|
2588 |
+
'Content-Type' => 'application/xml'
|
2589 |
+
);
|
2590 |
+
|
2591 |
+
$xml = simplexml_load_string($this->base_notification_xml);
|
2592 |
+
$topic_config = $xml->addChild('TopicConfiguration');
|
2593 |
+
$topic_config->addChild('Topic', $topic_arn);
|
2594 |
+
$topic_config->addChild('Event', $event);
|
2595 |
+
|
2596 |
+
$opt['body'] = $xml->asXML();
|
2597 |
+
|
2598 |
+
// Authenticate to S3
|
2599 |
+
return $this->authenticate($bucket, $opt);
|
2600 |
+
}
|
2601 |
+
|
2602 |
+
/**
|
2603 |
+
* Gets the notification configuration of a bucket. Currently, the `s3:ReducedRedundancyLostObject` event
|
2604 |
+
* is the only event supported for notifications. The `s3:ReducedRedundancyLostObject` event is triggered
|
2605 |
+
* when Amazon S3 detects that it has lost all replicas of a Reduced Redundancy Storage object and can no
|
2606 |
+
* longer service requests for that object.
|
2607 |
+
*
|
2608 |
+
* If notifications are not enabled on the bucket, the operation returns an empty
|
2609 |
+
* `NotificatonConfiguration` element.
|
2610 |
+
*
|
2611 |
+
* By default, you must be the bucket owner to read the notification configuration of a bucket. However,
|
2612 |
+
* the bucket owner can use a bucket policy to grant permission to other users to read this configuration
|
2613 |
+
* with the `s3:GetBucketNotification` permission.
|
2614 |
+
*
|
2615 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
2616 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2617 |
+
* <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>
|
2618 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2619 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/dev/NotificationHowTo.html Setting Up Notification of Bucket Events
|
2620 |
+
*/
|
2621 |
+
public function get_bucket_notifications($bucket, $opt = null)
|
2622 |
+
{
|
2623 |
+
if (!$opt) $opt = array();
|
2624 |
+
$opt['verb'] = 'GET';
|
2625 |
+
$opt['sub_resource'] = 'notification';
|
2626 |
+
|
2627 |
+
// Authenticate to S3
|
2628 |
+
return $this->authenticate($bucket, $opt);
|
2629 |
+
}
|
2630 |
+
|
2631 |
+
/**
|
2632 |
+
* Empties the list of SNS topics to send notifications to.
|
2633 |
+
*
|
2634 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
2635 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2636 |
+
* <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>
|
2637 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2638 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/dev/NotificationHowTo.html Setting Up Notification of Bucket Events
|
2639 |
+
*/
|
2640 |
+
public function delete_bucket_notification($bucket, $opt = null)
|
2641 |
+
{
|
2642 |
+
if (!$opt) $opt = array();
|
2643 |
+
$opt['verb'] = 'PUT';
|
2644 |
+
$opt['sub_resource'] = 'notification';
|
2645 |
+
$opt['body'] = $this->base_notification_xml;
|
2646 |
+
|
2647 |
+
// Authenticate to S3
|
2648 |
+
return $this->authenticate($bucket, $opt);
|
2649 |
+
}
|
2650 |
+
|
2651 |
+
|
2652 |
+
/*%******************************************************************************************%*/
|
2653 |
+
// MULTIPART UPLOAD
|
2654 |
+
|
2655 |
+
/**
|
2656 |
+
* Calculates the correct values for sequentially reading a file for multipart upload. This method should
|
2657 |
+
* be used in conjunction with <upload_part()>.
|
2658 |
+
*
|
2659 |
+
* @param integer $filesize (Required) The size in bytes of the entire file.
|
2660 |
+
* @param integer $part_size (Required) The size in bytes of the part of the file to send.
|
2661 |
+
* @return array An array containing key-value pairs. The keys are `seekTo` and `length`.
|
2662 |
+
*/
|
2663 |
+
public function get_multipart_counts($filesize, $part_size)
|
2664 |
+
{
|
2665 |
+
$i = 0;
|
2666 |
+
$sizecount = $filesize;
|
2667 |
+
$values = array();
|
2668 |
+
|
2669 |
+
while ($sizecount > 0)
|
2670 |
+
{
|
2671 |
+
$sizecount -= $part_size;
|
2672 |
+
$values[] = array(
|
2673 |
+
'seekTo' => ($part_size * $i),
|
2674 |
+
'length' => (($sizecount > 0) ? $part_size : ($sizecount + $part_size)),
|
2675 |
+
);
|
2676 |
+
$i++;
|
2677 |
+
}
|
2678 |
+
|
2679 |
+
return $values;
|
2680 |
+
}
|
2681 |
+
|
2682 |
+
/**
|
2683 |
+
* Initiates a multipart upload and returns an `UploadId`.
|
2684 |
+
*
|
2685 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
2686 |
+
* @param string $filename (Required) The file name for the object.
|
2687 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2688 |
+
* <li><code>acl</code> - <code>string</code> - Optional - The ACL settings for the specified object. [Allowed values: <code>AmazonS3::ACL_PRIVATE</code>, <code>AmazonS3::ACL_PUBLIC</code>, <code>AmazonS3::ACL_OPEN</code>, <code>AmazonS3::ACL_AUTH_READ</code>, <code>AmazonS3::ACL_OWNER_READ</code>, <code>AmazonS3::ACL_OWNER_FULL_CONTROL</code>]. The default value is <code>ACL_PRIVATE</code>.</li>
|
2689 |
+
* <li><code>contentType</code> - <code>string</code> - Optional - The type of content that is being sent. The default value is <code>application/octet-stream</code>.</li>
|
2690 |
+
* <li><code>headers</code> - <code>array</code> - Optional - The standard HTTP headers to send along in the request.</li>
|
2691 |
+
* <li><code>meta</code> - <code>array</code> - Optional - An associative array of key-value pairs. Any header starting with <code>x-amz-meta-:</code> is considered user metadata. It will be stored with the object and returned when you retrieve the object. The total size of the HTTP request, not including the body, must be less than 4 KB.</li>
|
2692 |
+
* <li><code>storage</code> - <code>string</code> - Optional - Whether to use Standard or Reduced Redundancy storage. [Allowed values: <code>AmazonS3::STORAGE_STANDARD</code>, <code>AmazonS3::STORAGE_REDUCED</code>]. The default value is <code>STORAGE_STANDARD</code>.</li>
|
2693 |
+
* <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>
|
2694 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2695 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/RESTAccessPolicy.html REST Access Control Policy
|
2696 |
+
*/
|
2697 |
+
public function initiate_multipart_upload($bucket, $filename, $opt = null)
|
2698 |
+
{
|
2699 |
+
if (!$opt) $opt = array();
|
2700 |
+
|
2701 |
+
// Add this to our request
|
2702 |
+
$opt['verb'] = 'POST';
|
2703 |
+
$opt['resource'] = $filename;
|
2704 |
+
$opt['sub_resource'] = 'uploads';
|
2705 |
+
$opt['body'] = '';
|
2706 |
+
|
2707 |
+
// Handle content type. Can also be passed as an HTTP header.
|
2708 |
+
if (isset($opt['contentType']))
|
2709 |
+
{
|
2710 |
+
$opt['headers']['Content-Type'] = $opt['contentType'];
|
2711 |
+
unset($opt['contentType']);
|
2712 |
+
}
|
2713 |
+
|
2714 |
+
// Set a default content type.
|
2715 |
+
if (!isset($opt['headers']['Content-Type']))
|
2716 |
+
{
|
2717 |
+
$opt['headers']['Content-Type'] = 'application/octet-stream';
|
2718 |
+
}
|
2719 |
+
|
2720 |
+
// Handle Access Control Lists. Can also be passed as an HTTP header.
|
2721 |
+
if (isset($opt['acl']))
|
2722 |
+
{
|
2723 |
+
$opt['headers']['x-amz-acl'] = $opt['acl'];
|
2724 |
+
unset($opt['acl']);
|
2725 |
+
}
|
2726 |
+
|
2727 |
+
// Handle storage settings. Can also be passed as an HTTP header.
|
2728 |
+
if (isset($opt['storage']))
|
2729 |
+
{
|
2730 |
+
$opt['headers']['x-amz-storage-class'] = $opt['storage'];
|
2731 |
+
unset($opt['storage']);
|
2732 |
+
}
|
2733 |
+
|
2734 |
+
// Handle meta tags. Can also be passed as an HTTP header.
|
2735 |
+
if (isset($opt['meta']))
|
2736 |
+
{
|
2737 |
+
foreach ($opt['meta'] as $meta_key => $meta_value)
|
2738 |
+
{
|
2739 |
+
// e.g., `My Meta Header` is converted to `x-amz-meta-my-meta-header`.
|
2740 |
+
$opt['headers']['x-amz-meta-' . strtolower(str_replace(' ', '-', $meta_key))] = $meta_value;
|
2741 |
+
}
|
2742 |
+
unset($opt['meta']);
|
2743 |
+
}
|
2744 |
+
|
2745 |
+
// Authenticate to S3
|
2746 |
+
return $this->authenticate($bucket, $opt);
|
2747 |
+
}
|
2748 |
+
|
2749 |
+
/**
|
2750 |
+
* Uploads a single part of a multipart upload. The part size cannot be smaller than 5 MB
|
2751 |
+
* or larger than 5 TB. A multipart upload can have no more than 10,000 parts.
|
2752 |
+
*
|
2753 |
+
* Amazon S3 charges for storage as well as requests to the service. Smaller part sizes (and more
|
2754 |
+
* requests) allow for faster failures and better upload reliability. Larger part sizes (and fewer
|
2755 |
+
* requests) costs slightly less but has lower upload reliability.
|
2756 |
+
*
|
2757 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
2758 |
+
* @param string $filename (Required) The file name for the object.
|
2759 |
+
* @param string $upload_id (Required) The upload ID identifying the multipart upload whose parts are being listed. The upload ID is retrieved from a call to <initiate_multipart_upload()>.
|
2760 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2761 |
+
* <li><code>fileUpload</code> - <code>string|resource</code> - Required - The URL/path for the file to upload or an open resource.</li>
|
2762 |
+
* <li><code>partNumber</code> - <code>integer</code> - Required - The part number order of the multipart upload.</li>
|
2763 |
+
* <li><code>expect</code> - <code>string</code> - Optional - Specifies that the SDK not send the request body until it receives an acknowledgement. If the message is rejected based on the headers, the body of the message is not sent. For more information, see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.20">RFC 2616, section 14.20</a>. The value can also be passed to the <code>header</code> option as <code>Expect</code>. [Allowed values: <code>100-continue</code>]</li>
|
2764 |
+
* <li><code>headers</code> - <code>array</code> - Optional - The standard HTTP headers to send along in the request.</li>
|
2765 |
+
* <li><code>length</code> - <code>integer</code> - Optional - The size of the part in bytes. For more information, see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13">RFC 2616, section 14.13</a>. The value can also be passed to the <code>header</code> option as <code>Content-Length</code>.</li>
|
2766 |
+
* <li><code>md5</code> - <code>string</code> - Optional - The base64 encoded 128-bit MD5 digest of the part data. This header can be used as a message integrity check to verify that the part data is the same data that was originally sent. Although it is optional, we recommend using this mechanism as an end-to-end integrity check. For more information, see <a href="http://www.ietf.org/rfc/rfc1864.txt">RFC 1864</a>. The value can also be passed to the <code>header</code> option as <code>Content-MD5</code>.</li>
|
2767 |
+
* <li><code>seekTo</code> - <code>integer</code> - Optional - The starting position in bytes for the piece of the file/stream to upload.</li>
|
2768 |
+
* <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>
|
2769 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2770 |
+
*/
|
2771 |
+
public function upload_part($bucket, $filename, $upload_id, $opt = null)
|
2772 |
+
{
|
2773 |
+
if (!$opt) $opt = array();
|
2774 |
+
|
2775 |
+
// Add this to our request
|
2776 |
+
$opt['verb'] = 'PUT';
|
2777 |
+
$opt['resource'] = $filename;
|
2778 |
+
$opt['uploadId'] = $upload_id;
|
2779 |
+
|
2780 |
+
if (!isset($opt['fileUpload']) || !isset($opt['partNumber']))
|
2781 |
+
{
|
2782 |
+
throw new S3_Exception('The `fileUpload` and `partNumber` options are both required in ' . __FUNCTION__ . '().');
|
2783 |
+
}
|
2784 |
+
|
2785 |
+
// Handle expectation. Can also be passed as an HTTP header.
|
2786 |
+
if (isset($opt['expect']))
|
2787 |
+
{
|
2788 |
+
$opt['headers']['Expect'] = $opt['expect'];
|
2789 |
+
unset($opt['expect']);
|
2790 |
+
}
|
2791 |
+
|
2792 |
+
// Handle content length. Can also be passed as an HTTP header.
|
2793 |
+
if (isset($opt['length']))
|
2794 |
+
{
|
2795 |
+
$opt['headers']['Content-Length'] = $opt['length'];
|
2796 |
+
unset($opt['length']);
|
2797 |
+
}
|
2798 |
+
|
2799 |
+
// Handle content md5. Can also be passed as an HTTP header.
|
2800 |
+
if (isset($opt['md5']))
|
2801 |
+
{
|
2802 |
+
$opt['headers']['Content-MD5'] = $opt['md5'];
|
2803 |
+
unset($opt['md5']);
|
2804 |
+
}
|
2805 |
+
|
2806 |
+
// Authenticate to S3
|
2807 |
+
return $this->authenticate($bucket, $opt);
|
2808 |
+
}
|
2809 |
+
|
2810 |
+
/**
|
2811 |
+
* Lists the completed parts of an in-progress multipart upload.
|
2812 |
+
*
|
2813 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
2814 |
+
* @param string $filename (Required) The file name for the object.
|
2815 |
+
* @param string $upload_id (Required) The upload ID identifying the multipart upload whose parts are being listed. The upload ID is retrieved from a call to <initiate_multipart_upload()>.
|
2816 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2817 |
+
* <li><code>max-parts</code> - <code>integer</code> - Optional - The maximum number of parts to return in the response body.</li>
|
2818 |
+
* <li><code>part-number-marker</code> - <code>string</code> - Optional - Restricts the response to contain results that only occur numerically after the value of the <code>part-number-marker</code>.</li>
|
2819 |
+
* <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>
|
2820 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2821 |
+
*/
|
2822 |
+
public function list_parts($bucket, $filename, $upload_id, $opt = null)
|
2823 |
+
{
|
2824 |
+
if (!$opt) $opt = array();
|
2825 |
+
|
2826 |
+
// Add this to our request
|
2827 |
+
$opt['verb'] = 'GET';
|
2828 |
+
$opt['resource'] = $filename;
|
2829 |
+
$opt['uploadId'] = $upload_id;
|
2830 |
+
$opt['query_string'] = array();
|
2831 |
+
|
2832 |
+
foreach (array('max-parts', 'part-number-marker') as $param)
|
2833 |
+
{
|
2834 |
+
if (isset($opt[$param]))
|
2835 |
+
{
|
2836 |
+
$opt['query_string'][$param] = $opt[$param];
|
2837 |
+
unset($opt[$param]);
|
2838 |
+
}
|
2839 |
+
}
|
2840 |
+
|
2841 |
+
// Authenticate to S3
|
2842 |
+
return $this->authenticate($bucket, $opt);
|
2843 |
+
}
|
2844 |
+
|
2845 |
+
/**
|
2846 |
+
* Aborts an in-progress multipart upload. This operation cannot be reversed.
|
2847 |
+
*
|
2848 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
2849 |
+
* @param string $filename (Required) The file name for the object.
|
2850 |
+
* @param string $upload_id (Required) The upload ID identifying the multipart upload whose parts are being listed. The upload ID is retrieved from a call to <initiate_multipart_upload()>.
|
2851 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2852 |
+
* <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>
|
2853 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2854 |
+
*/
|
2855 |
+
public function abort_multipart_upload($bucket, $filename, $upload_id, $opt = null)
|
2856 |
+
{
|
2857 |
+
if (!$opt) $opt = array();
|
2858 |
+
|
2859 |
+
// Add this to our request
|
2860 |
+
$opt['verb'] = 'DELETE';
|
2861 |
+
$opt['resource'] = $filename;
|
2862 |
+
$opt['uploadId'] = $upload_id;
|
2863 |
+
|
2864 |
+
// Authenticate to S3
|
2865 |
+
return $this->authenticate($bucket, $opt);
|
2866 |
+
}
|
2867 |
+
|
2868 |
+
/**
|
2869 |
+
* Completes an in-progress multipart upload. A multipart upload is completed by describing the part
|
2870 |
+
* numbers and corresponding ETag values in order, and submitting that data to Amazon S3 as an XML document.
|
2871 |
+
*
|
2872 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
2873 |
+
* @param string $filename (Required) The file name for the object.
|
2874 |
+
* @param string $upload_id (Required) The upload ID identifying the multipart upload whose parts are being listed. The upload ID is retrieved from a call to <initiate_multipart_upload()>.
|
2875 |
+
* @param string|array|SimpleXMLElement|CFResponse $parts (Required) The completion XML document. This document can be provided in multiple ways; as a string of XML, as a <php:SimpleXMLElement> object representing the XML document, as an indexed array of associative arrays where the keys are <code>PartNumber</code> and <code>ETag</code>, or as a <CFResponse> object returned by <list_parts()>.
|
2876 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2877 |
+
* <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>
|
2878 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2879 |
+
*/
|
2880 |
+
public function complete_multipart_upload($bucket, $filename, $upload_id, $parts, $opt = null)
|
2881 |
+
{
|
2882 |
+
if (!$opt) $opt = array();
|
2883 |
+
|
2884 |
+
// Add this to our request
|
2885 |
+
$opt['verb'] = 'POST';
|
2886 |
+
$opt['resource'] = $filename;
|
2887 |
+
$opt['uploadId'] = $upload_id;
|
2888 |
+
$opt['headers'] = array(
|
2889 |
+
'Content-Type' => 'application/xml'
|
2890 |
+
);
|
2891 |
+
|
2892 |
+
// Disable Content-MD5 calculation for this operation
|
2893 |
+
$opt['NoContentMD5'] = true;
|
2894 |
+
|
2895 |
+
if (is_string($parts))
|
2896 |
+
{
|
2897 |
+
// Assume it's the intended XML.
|
2898 |
+
$opt['body'] = $parts;
|
2899 |
+
}
|
2900 |
+
elseif ($parts instanceof SimpleXMLElement)
|
2901 |
+
{
|
2902 |
+
// Assume it's a SimpleXMLElement object representing the XML.
|
2903 |
+
$opt['body'] = $parts->asXML();
|
2904 |
+
}
|
2905 |
+
elseif (is_array($parts) || $parts instanceof CFResponse)
|
2906 |
+
{
|
2907 |
+
$xml = simplexml_load_string($this->complete_mpu_xml);
|
2908 |
+
|
2909 |
+
if (is_array($parts))
|
2910 |
+
{
|
2911 |
+
// Generate the appropriate XML.
|
2912 |
+
foreach ($parts as $node)
|
2913 |
+
{
|
2914 |
+
$part = $xml->addChild('Part');
|
2915 |
+
$part->addChild('PartNumber', $node['PartNumber']);
|
2916 |
+
$part->addChild('ETag', $node['ETag']);
|
2917 |
+
}
|
2918 |
+
|
2919 |
+
}
|
2920 |
+
elseif ($parts instanceof CFResponse)
|
2921 |
+
{
|
2922 |
+
// Assume it's a response from list_parts().
|
2923 |
+
foreach ($parts->body->Part as $node)
|
2924 |
+
{
|
2925 |
+
$part = $xml->addChild('Part');
|
2926 |
+
$part->addChild('PartNumber', (string) $node->PartNumber);
|
2927 |
+
$part->addChild('ETag', (string) $node->ETag);
|
2928 |
+
}
|
2929 |
+
}
|
2930 |
+
|
2931 |
+
$opt['body'] = $xml->asXML();
|
2932 |
+
}
|
2933 |
+
|
2934 |
+
// Authenticate to S3
|
2935 |
+
return $this->authenticate($bucket, $opt);
|
2936 |
+
}
|
2937 |
+
|
2938 |
+
/**
|
2939 |
+
* Lists the in-progress multipart uploads.
|
2940 |
+
*
|
2941 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
2942 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2943 |
+
* <li><code>delimiter</code> - <code>string</code> - Optional - Keys that contain the same string between the prefix and the first occurrence of the delimiter will be rolled up into a single result element in the CommonPrefixes collection.</li>
|
2944 |
+
* <li><code>key-marker</code> - <code>string</code> - Optional - Restricts the response to contain results that only occur alphabetically after the value of the <code>key-marker</code>. If used in conjunction with <code>upload-id-marker</code>, the results will be filtered to include keys whose upload ID is alphabetically after the value of <code>upload-id-marker</code>.</li>
|
2945 |
+
* <li><code>upload-id-marker</code> - <code>string</code> - Optional - Restricts the response to contain results that only occur alphabetically after the value of the <code>upload-id-marker</code>. Must be used in conjunction with <code>key-marker</code>.</li>
|
2946 |
+
* <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>
|
2947 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2948 |
+
*/
|
2949 |
+
public function list_multipart_uploads($bucket, $opt = null)
|
2950 |
+
{
|
2951 |
+
if (!$opt) $opt = array();
|
2952 |
+
|
2953 |
+
// Add this to our request
|
2954 |
+
$opt['verb'] = 'GET';
|
2955 |
+
$opt['sub_resource'] = 'uploads';
|
2956 |
+
|
2957 |
+
foreach (array('key-marker', 'max-uploads', 'upload-id-marker') as $param)
|
2958 |
+
{
|
2959 |
+
if (isset($opt[$param]))
|
2960 |
+
{
|
2961 |
+
$opt['query_string'][$param] = $opt[$param];
|
2962 |
+
unset($opt[$param]);
|
2963 |
+
}
|
2964 |
+
}
|
2965 |
+
|
2966 |
+
// Authenticate to S3
|
2967 |
+
return $this->authenticate($bucket, $opt);
|
2968 |
+
}
|
2969 |
+
|
2970 |
+
/**
|
2971 |
+
* Creates an Amazon S3 object using the multipart upload APIs. It is analogous to <create_object()>.
|
2972 |
+
*
|
2973 |
+
* While each individual part of a multipart upload can hold up to 5 GB of data, this method limits the
|
2974 |
+
* part size to a maximum of 500 MB. The combined size of all parts can not exceed 5 TB of data. When an
|
2975 |
+
* object is stored in Amazon S3, the data is streamed to multiple storage servers in multiple data
|
2976 |
+
* centers. This ensures the data remains available in the event of internal network or hardware failure.
|
2977 |
+
*
|
2978 |
+
* Amazon S3 charges for storage as well as requests to the service. Smaller part sizes (and more
|
2979 |
+
* requests) allow for faster failures and better upload reliability. Larger part sizes (and fewer
|
2980 |
+
* requests) costs slightly less but has lower upload reliability.
|
2981 |
+
*
|
2982 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
2983 |
+
* @param string $filename (Required) The file name for the object.
|
2984 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2985 |
+
* <li><code>fileUpload</code> - <code>string|resource</code> - Required - The URL/path for the file to upload, or an open resource.</li>
|
2986 |
+
* <li><code>acl</code> - <code>string</code> - Optional - The ACL settings for the specified object. [Allowed values: <code>AmazonS3::ACL_PRIVATE</code>, <code>AmazonS3::ACL_PUBLIC</code>, <code>AmazonS3::ACL_OPEN</code>, <code>AmazonS3::ACL_AUTH_READ</code>, <code>AmazonS3::ACL_OWNER_READ</code>, <code>AmazonS3::ACL_OWNER_FULL_CONTROL</code>]. The default value is <code>ACL_PRIVATE</code>.</li>
|
2987 |
+
* <li><code>contentType</code> - <code>string</code> - Optional - The type of content that is being sent in the body. The default value is <code>application/octet-stream</code>.</li>
|
2988 |
+
* <li><code>headers</code> - <code>array</code> - Optional - The standard HTTP headers to send along in the request.</li>
|
2989 |
+
* <li><code>length</code> - <code>integer</code> - Optional - The size of the object in bytes. For more information, see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13">RFC 2616, section 14.13</a>. The value can also be passed to the <code>header</code> option as <code>Content-Length</code>.</li>
|
2990 |
+
* <li><code>limit</code> - <code>integer</code> - Optional - The maximum number of concurrent uploads done by cURL. Gets passed to <code>CFBatchRequest</code>.</li>
|
2991 |
+
* <li><code>meta</code> - <code>array</code> - Optional - An associative array of key-value pairs. Any header starting with <code>x-amz-meta-:</code> is considered user metadata. It will be stored with the object and returned when you retrieve the object. The total size of the HTTP request, not including the body, must be less than 4 KB.</li>
|
2992 |
+
* <li><code>partSize</code> - <code>integer</code> - Optional - The size of an individual part. The size may not be smaller than 5 MB or larger than 500 MB. The default value is 50 MB.</li>
|
2993 |
+
* <li><code>seekTo</code> - <code>integer</code> - Optional - The starting position in bytes for the first piece of the file/stream to upload.</li>
|
2994 |
+
* <li><code>storage</code> - <code>string</code> - Optional - Whether to use Standard or Reduced Redundancy storage. [Allowed values: <code>AmazonS3::STORAGE_STANDARD</code>, <code>AmazonS3::STORAGE_REDUCED</code>]. The default value is <code>STORAGE_STANDARD</code>.</li>
|
2995 |
+
* <li><code>uploadId</code> - <code>string</code> - Optional - An upload ID identifying an existing multipart upload to use. If this option is not set, one will be created automatically.</li>
|
2996 |
+
* <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>
|
2997 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2998 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/RESTAccessPolicy.html REST Access Control Policy
|
2999 |
+
*/
|
3000 |
+
public function create_mpu_object($bucket, $filename, $opt = null)
|
3001 |
+
{
|
3002 |
+
if ($this->use_batch_flow)
|
3003 |
+
{
|
3004 |
+
throw new S3_Exception(__FUNCTION__ . '() cannot be batch requested');
|
3005 |
+
}
|
3006 |
+
|
3007 |
+
if (!$opt) $opt = array();
|
3008 |
+
|
3009 |
+
// Handle content length. Can also be passed as an HTTP header.
|
3010 |
+
if (isset($opt['length']))
|
3011 |
+
{
|
3012 |
+
$opt['headers']['Content-Length'] = $opt['length'];
|
3013 |
+
unset($opt['length']);
|
3014 |
+
}
|
3015 |
+
|
3016 |
+
if (!isset($opt['fileUpload']))
|
3017 |
+
{
|
3018 |
+
throw new S3_Exception('The `fileUpload` option is required in ' . __FUNCTION__ . '().');
|
3019 |
+
}
|
3020 |
+
elseif (is_resource($opt['fileUpload']))
|
3021 |
+
{
|
3022 |
+
$opt['limit'] = 1; // We can only read from this one resource.
|
3023 |
+
$upload_position = isset($opt['seekTo']) ? (integer) $opt['seekTo'] : ftell($opt['fileUpload']);
|
3024 |
+
$upload_filesize = isset($opt['headers']['Content-Length']) ? (integer) $opt['headers']['Content-Length'] : null;
|
3025 |
+
|
3026 |
+
if (!isset($upload_filesize) && $upload_position !== false)
|
3027 |
+
{
|
3028 |
+
$stats = fstat($opt['fileUpload']);
|
3029 |
+
|
3030 |
+
if ($stats && $stats['size'] >= 0)
|
3031 |
+
{
|
3032 |
+
$upload_filesize = $stats['size'] - $upload_position;
|
3033 |
+
}
|
3034 |
+
}
|
3035 |
+
}
|
3036 |
+
else
|
3037 |
+
{
|
3038 |
+
$upload_position = isset($opt['seekTo']) ? (integer) $opt['seekTo'] : 0;
|
3039 |
+
|
3040 |
+
if (isset($opt['headers']['Content-Length']))
|
3041 |
+
{
|
3042 |
+
$upload_filesize = (integer) $opt['headers']['Content-Length'];
|
3043 |
+
}
|
3044 |
+
else
|
3045 |
+
{
|
3046 |
+
$upload_filesize = filesize($opt['fileUpload']);
|
3047 |
+
|
3048 |
+
if ($upload_filesize !== false)
|
3049 |
+
{
|
3050 |
+
$upload_filesize -= $upload_position;
|
3051 |
+
}
|
3052 |
+
}
|
3053 |
+
}
|
3054 |
+
|
3055 |
+
if ($upload_position === false || !isset($upload_filesize) || $upload_filesize === false || $upload_filesize < 0)
|
3056 |
+
{
|
3057 |
+
throw new S3_Exception('The size of `fileUpload` cannot be determined in ' . __FUNCTION__ . '().');
|
3058 |
+
}
|
3059 |
+
|
3060 |
+
// Handle part size
|
3061 |
+
if (isset($opt['partSize']))
|
3062 |
+
{
|
3063 |
+
// If less that 5 MB...
|
3064 |
+
if ((integer) $opt['partSize'] < 5242880)
|
3065 |
+
{
|
3066 |
+
$opt['partSize'] = 5242880; // 5 MB
|
3067 |
+
}
|
3068 |
+
// If more than 500 MB...
|
3069 |
+
elseif ((integer) $opt['partSize'] > 524288000)
|
3070 |
+
{
|
3071 |
+
$opt['partSize'] = 524288000; // 500 MB
|
3072 |
+
}
|
3073 |
+
}
|
3074 |
+
else
|
3075 |
+
{
|
3076 |
+
$opt['partSize'] = 52428800; // 50 MB
|
3077 |
+
}
|
3078 |
+
|
3079 |
+
// If the upload size is smaller than the piece size, failover to create_object().
|
3080 |
+
if ($upload_filesize < $opt['partSize'] && !isset($opt['uploadId']))
|
3081 |
+
{
|
3082 |
+
return $this->create_object($bucket, $filename, $opt);
|
3083 |
+
}
|
3084 |
+
|
3085 |
+
// Initiate multipart upload
|
3086 |
+
if (isset($opt['uploadId']))
|
3087 |
+
{
|
3088 |
+
$upload_id = $opt['uploadId'];
|
3089 |
+
}
|
3090 |
+
else
|
3091 |
+
{
|
3092 |
+
// Compose options for initiate_multipart_upload().
|
3093 |
+
$_opt = array();
|
3094 |
+
foreach (array('contentType', 'acl', 'storage', 'headers', 'meta') as $param)
|
3095 |
+
{
|
3096 |
+
if (isset($opt[$param]))
|
3097 |
+
{
|
3098 |
+
$_opt[$param] = $opt[$param];
|
3099 |
+
}
|
3100 |
+
}
|
3101 |
+
|
3102 |
+
$upload = $this->initiate_multipart_upload($bucket, $filename, $_opt);
|
3103 |
+
if (!$upload->isOK())
|
3104 |
+
{
|
3105 |
+
return $upload;
|
3106 |
+
}
|
3107 |
+
|
3108 |
+
// Fetch the UploadId
|
3109 |
+
$upload_id = (string) $upload->body->UploadId;
|
3110 |
+
}
|
3111 |
+
|
3112 |
+
// Get the list of pieces
|
3113 |
+
$pieces = $this->get_multipart_counts($upload_filesize, (integer) $opt['partSize']);
|
3114 |
+
|
3115 |
+
// Queue batch requests
|
3116 |
+
$batch = new CFBatchRequest(isset($opt['limit']) ? (integer) $opt['limit'] : null);
|
3117 |
+
foreach ($pieces as $i => $piece)
|
3118 |
+
{
|
3119 |
+
$this->batch($batch)->upload_part($bucket, $filename, $upload_id, array(
|
3120 |
+
'expect' => '100-continue',
|
3121 |
+
'fileUpload' => $opt['fileUpload'],
|
3122 |
+
'partNumber' => ($i + 1),
|
3123 |
+
'seekTo' => $upload_position + (integer) $piece['seekTo'],
|
3124 |
+
'length' => (integer) $piece['length'],
|
3125 |
+
));
|
3126 |
+
}
|
3127 |
+
|
3128 |
+
// Send batch requests
|
3129 |
+
$batch_responses = $this->batch($batch)->send();
|
3130 |
+
if (!$batch_responses->areOK())
|
3131 |
+
{
|
3132 |
+
return $batch_responses;
|
3133 |
+
}
|
3134 |
+
|
3135 |
+
// Compose completion XML
|
3136 |
+
$parts = array();
|
3137 |
+
foreach ($batch_responses as $i => $response)
|
3138 |
+
{
|
3139 |
+
$parts[] = array('PartNumber' => ($i + 1), 'ETag' => $response->header['etag']);
|
3140 |
+
}
|
3141 |
+
|
3142 |
+
return $this->complete_multipart_upload($bucket, $filename, $upload_id, $parts);
|
3143 |
+
}
|
3144 |
+
|
3145 |
+
/**
|
3146 |
+
* Aborts all multipart uploads initiated before the specified date. This operation cannot be reversed.
|
3147 |
+
*
|
3148 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
3149 |
+
* @param string|integer $when (Optional) The time and date to use for comparison. Accepts any value that <php:strtotime()> understands.
|
3150 |
+
* @return CFArray A <CFArray> containing a series of 0 or more <CFResponse> objects, containing a parsed HTTP response.
|
3151 |
+
*/
|
3152 |
+
public function abort_multipart_uploads_by_date($bucket, $when = null)
|
3153 |
+
{
|
3154 |
+
if ($this->use_batch_flow)
|
3155 |
+
{
|
3156 |
+
throw new S3_Exception(__FUNCTION__ . '() cannot be batch requested');
|
3157 |
+
}
|
3158 |
+
|
3159 |
+
$when = $when ? $when : time();
|
3160 |
+
$handles = array();
|
3161 |
+
$data = $this->list_multipart_uploads($bucket)->body;
|
3162 |
+
$when = is_int($when) ? $when : strtotime($when);
|
3163 |
+
|
3164 |
+
if (!($data instanceof CFSimpleXML))
|
3165 |
+
{
|
3166 |
+
return false;
|
3167 |
+
}
|
3168 |
+
|
3169 |
+
$list = $data->query('descendant-or-self::Upload/Initiated');
|
3170 |
+
|
3171 |
+
foreach ($list as $node)
|
3172 |
+
{
|
3173 |
+
if (strtotime((string) $node) < $when)
|
3174 |
+
{
|
3175 |
+
$q = new CFBatchRequest();
|
3176 |
+
$parent = $node->parent();
|
3177 |
+
|
3178 |
+
$upload_id = $parent
|
3179 |
+
->query('descendant-or-self::UploadId')
|
3180 |
+
->first()
|
3181 |
+
->to_string();
|
3182 |
+
|
3183 |
+
$filename = $parent
|
3184 |
+
->query('descendant-or-self::Key')
|
3185 |
+
->first()
|
3186 |
+
->to_string();
|
3187 |
+
|
3188 |
+
$handles[] = $this->abort_multipart_upload($bucket, $filename, $upload_id, array(
|
3189 |
+
'returnCurlHandle' => true
|
3190 |
+
));
|
3191 |
+
}
|
3192 |
+
}
|
3193 |
+
|
3194 |
+
$http = new CFRequest();
|
3195 |
+
$responses = $http->send_multi_request($handles);
|
3196 |
+
|
3197 |
+
return new CFArray($responses);
|
3198 |
+
}
|
3199 |
+
|
3200 |
+
|
3201 |
+
/*%******************************************************************************************%*/
|
3202 |
+
// WEBSITE CONFIGURATION
|
3203 |
+
|
3204 |
+
/**
|
3205 |
+
* This operation enables/configures an S3 Website using the corresponding bucket as the content source.
|
3206 |
+
* The website will have one default domain name associated with it, which is the bucket name. If you
|
3207 |
+
* attempt to configure an S3 website for a bucket whose name is not compatible with DNS, Amazon S3
|
3208 |
+
* returns an <code>InvalidBucketName</code> error. For more information on bucket names and DNS,
|
3209 |
+
* refer to Bucket Restrictions and Limitations.
|
3210 |
+
*
|
3211 |
+
* To visit the S3 bucket as a website a new endpoint is created in the following pattern
|
3212 |
+
* <code>http://<bucketName>.s3-website-<region>.amazonaws.com</code>. This is a sample URL
|
3213 |
+
* for a bucket called <code>example-bucket</code> in the <code>us-east-1</code> region.
|
3214 |
+
* (e.g., <code>http://example-bucket.s3-website-us-east-1.amazonaws.com</code>)
|
3215 |
+
*
|
3216 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
3217 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
3218 |
+
* <li><code>indexDocument</code> - <code>string</code> - Optional - The file path to use as the root document. The default value is <code>index.html</code>.</li>
|
3219 |
+
* <li><code>errorDocument</code> - <code>string</code> - Optional - The file path to use as the error document. The default value is <code>error.html</code>.</li>
|
3220 |
+
* <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>
|
3221 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
3222 |
+
*/
|
3223 |
+
public function create_website_config($bucket, $opt = null)
|
3224 |
+
{
|
3225 |
+
if (!$opt) $opt = array();
|
3226 |
+
$opt['verb'] = 'PUT';
|
3227 |
+
$opt['sub_resource'] = 'website';
|
3228 |
+
|
3229 |
+
$xml = simplexml_load_string($this->website_config_xml);
|
3230 |
+
if (isset($opt['indexDocument']))
|
3231 |
+
{
|
3232 |
+
$xml->IndexDocument->Suffix = $opt['indexDocument'];
|
3233 |
+
}
|
3234 |
+
if (isset($opt['errorDocument']))
|
3235 |
+
{
|
3236 |
+
$xml->ErrorDocument->Key = $opt['errorDocument'];
|
3237 |
+
}
|
3238 |
+
|
3239 |
+
$opt['body'] = $xml->asXML();
|
3240 |
+
|
3241 |
+
// Authenticate to S3
|
3242 |
+
return $this->authenticate($bucket, $opt);
|
3243 |
+
}
|
3244 |
+
|
3245 |
+
/**
|
3246 |
+
* This operation retrieves the website configuration for a bucket. The contents of this response are identical
|
3247 |
+
* to the content submitted by the user during the website creation operation. If a website configuration has
|
3248 |
+
* never been set, Amazon S3 will return a 404 error.
|
3249 |
+
*
|
3250 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
3251 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
3252 |
+
* <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>
|
3253 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
3254 |
+
*/
|
3255 |
+
public function get_website_config($bucket, $opt = null)
|
3256 |
+
{
|
3257 |
+
if (!$opt) $opt = array();
|
3258 |
+
$opt['verb'] = 'GET';
|
3259 |
+
$opt['sub_resource'] = 'website';
|
3260 |
+
$opt['headers'] = array(
|
3261 |
+
'Content-Type' => 'application/xml'
|
3262 |
+
);
|
3263 |
+
|
3264 |
+
// Authenticate to S3
|
3265 |
+
return $this->authenticate($bucket, $opt);
|
3266 |
+
}
|
3267 |
+
|
3268 |
+
/**
|
3269 |
+
* This operation removes the website configuration for a bucket.
|
3270 |
+
*
|
3271 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
3272 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
3273 |
+
* <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>
|
3274 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
3275 |
+
*/
|
3276 |
+
public function delete_website_config($bucket, $opt = null)
|
3277 |
+
{
|
3278 |
+
if (!$opt) $opt = array();
|
3279 |
+
$opt['verb'] = 'DELETE';
|
3280 |
+
$opt['sub_resource'] = 'website';
|
3281 |
+
|
3282 |
+
// Authenticate to S3
|
3283 |
+
return $this->authenticate($bucket, $opt);
|
3284 |
+
}
|
3285 |
+
|
3286 |
+
|
3287 |
+
/*%******************************************************************************************%*/
|
3288 |
+
// MISCELLANEOUS
|
3289 |
+
|
3290 |
+
/**
|
3291 |
+
* Gets the canonical user ID and display name from the Amazon S3 server.
|
3292 |
+
*
|
3293 |
+
* @return array An associative array containing the `id` and `display_name` values.
|
3294 |
+
*/
|
3295 |
+
public function get_canonical_user_id()
|
3296 |
+
{
|
3297 |
+
if ($this->use_batch_flow)
|
3298 |
+
{
|
3299 |
+
throw new S3_Exception(__FUNCTION__ . '() cannot be batch requested');
|
3300 |
+
}
|
3301 |
+
|
3302 |
+
$id = $this->list_buckets();
|
3303 |
+
|
3304 |
+
return array(
|
3305 |
+
'id' => (string) $id->body->Owner->ID,
|
3306 |
+
'display_name' => (string) $id->body->Owner->DisplayName
|
3307 |
+
);
|
3308 |
+
}
|
3309 |
+
}
|
app/libs/aws/services/sdb.class.php
ADDED
@@ -0,0 +1,656 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
*
|
20 |
+
* Amazon SimpleDB is a web service providing the core database functions of data indexing and querying in the cloud. By
|
21 |
+
* offloading the time and effort associated with building and operating a web-scale database, SimpleDB provides developers
|
22 |
+
* the freedom to focus on application development.
|
23 |
+
*
|
24 |
+
*
|
25 |
+
*
|
26 |
+
* A traditional, clustered relational database requires a sizable upfront capital outlay, is complex to design, and often
|
27 |
+
* requires extensive and repetitive database administration. Amazon SimpleDB is dramatically simpler, requiring no schema,
|
28 |
+
* automatically indexing your data and providing a simple API for storage and access. This approach eliminates the
|
29 |
+
* administrative burden of data modeling, index maintenance, and performance tuning. Developers gain access to this
|
30 |
+
* functionality within Amazon's proven computing environment, are able to scale instantly, and pay only for what they use.
|
31 |
+
*
|
32 |
+
* Visit <a href="http://aws.amazon.com/simpledb/">http://aws.amazon.com/simpledb/</a> for more information.
|
33 |
+
*
|
34 |
+
* @version Wed Feb 16 17:09:59 PST 2011
|
35 |
+
* @license See the included NOTICE.md file for complete information.
|
36 |
+
* @copyright See the included NOTICE.md file for complete information.
|
37 |
+
* @link http://aws.amazon.com/simpledb/Amazon SimpleDB
|
38 |
+
* @link http://aws.amazon.com/documentation/simpledb/Amazon SimpleDB documentation
|
39 |
+
*/
|
40 |
+
class AmazonSDB extends CFRuntime
|
41 |
+
{
|
42 |
+
|
43 |
+
/*%******************************************************************************************%*/
|
44 |
+
// CLASS CONSTANTS
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Specify the default queue URL.
|
48 |
+
*/
|
49 |
+
const DEFAULT_URL = 'sdb.amazonaws.com';
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Specify the queue URL for the US-East (Northern Virginia) Region.
|
53 |
+
*/
|
54 |
+
const REGION_US_E1 = self::DEFAULT_URL;
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Specify the queue URL for the US-West (Northern California) Region.
|
58 |
+
*/
|
59 |
+
const REGION_US_W1 = 'sdb.us-west-1.amazonaws.com';
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Specify the queue URL for the EU (Ireland) Region.
|
63 |
+
*/
|
64 |
+
const REGION_EU_W1 = 'sdb.eu-west-1.amazonaws.com';
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Specify the queue URL for the Asia Pacific (Singapore) Region.
|
68 |
+
*/
|
69 |
+
const REGION_APAC_SE1 = 'sdb.ap-southeast-1.amazonaws.com';
|
70 |
+
|
71 |
+
|
72 |
+
/*%******************************************************************************************%*/
|
73 |
+
// SETTERS
|
74 |
+
|
75 |
+
/**
|
76 |
+
* This allows you to explicitly sets the region for the service to use.
|
77 |
+
*
|
78 |
+
* @param string $region (Required) The region to explicitly set. Available options are <REGION_US_E1>, <REGION_US_W1>, <REGION_EU_W1>, or <REGION_APAC_SE1>.
|
79 |
+
* @return $this A reference to the current instance.
|
80 |
+
*/
|
81 |
+
public function set_region($region)
|
82 |
+
{
|
83 |
+
$this->set_hostname($region);
|
84 |
+
return $this;
|
85 |
+
}
|
86 |
+
|
87 |
+
/*%******************************************************************************************%*/
|
88 |
+
// CONVENIENCE METHODS
|
89 |
+
|
90 |
+
/**
|
91 |
+
* ONLY lists the domains, as an array, on the SimpleDB account.
|
92 |
+
*
|
93 |
+
* @param string $pcre (Optional) A Perl-Compatible Regular Expression (PCRE) to filter the names against.
|
94 |
+
* @return array The list of matching queue names. If there are no results, the method will return an empty array.
|
95 |
+
* @link http://php.net/pcre Perl-Compatible Regular Expression (PCRE) Docs
|
96 |
+
*/
|
97 |
+
public function get_domain_list($pcre = null)
|
98 |
+
{
|
99 |
+
if ($this->use_batch_flow)
|
100 |
+
{
|
101 |
+
throw new SDB_Exception(__FUNCTION__ . '() cannot be batch requested');
|
102 |
+
}
|
103 |
+
|
104 |
+
// Get a list of domains.
|
105 |
+
$list = $this->list_domains();
|
106 |
+
if ($list = $list->body->DomainName())
|
107 |
+
{
|
108 |
+
$list = $list->map_string($pcre);
|
109 |
+
return $list;
|
110 |
+
}
|
111 |
+
|
112 |
+
return array();
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Remaps the custom item-key-value format used by Batch* operations to the more common ComplexList
|
117 |
+
* format. Internal use only.
|
118 |
+
*
|
119 |
+
* @param array $items (Required) The item-key-value format passed by <batch_put_attributes()> and <batch_delete_attributes()>.
|
120 |
+
* @param boolean|array $replace (Optional) The `$replace` value passed by <batch_put_attributes()> and <batch_delete_attributes()>.
|
121 |
+
* @return array A <CFComplexType>-compatible mapping of parameters.
|
122 |
+
*/
|
123 |
+
public static function remap_batch_items_for_complextype($items, $replace = false)
|
124 |
+
{
|
125 |
+
$map = array(
|
126 |
+
'Item' => array()
|
127 |
+
);
|
128 |
+
|
129 |
+
foreach ($items as $key => $value)
|
130 |
+
{
|
131 |
+
$node = array();
|
132 |
+
$node['ItemName'] = $key;
|
133 |
+
|
134 |
+
if (is_array($value))
|
135 |
+
{
|
136 |
+
$node['Attribute'] = array();
|
137 |
+
|
138 |
+
foreach ($value as $k => $v)
|
139 |
+
{
|
140 |
+
$v = is_array($v) ? $v : array($v);
|
141 |
+
|
142 |
+
foreach ($v as $vv)
|
143 |
+
{
|
144 |
+
$n = array();
|
145 |
+
$n['Name'] = $k;
|
146 |
+
$n['Value'] = $vv;
|
147 |
+
|
148 |
+
if (
|
149 |
+
$replace === (boolean) true ||
|
150 |
+
(isset($replace[$key]) && array_search($k, $replace[$key], true) !== false)
|
151 |
+
)
|
152 |
+
{
|
153 |
+
$n['Replace'] = 'true';
|
154 |
+
}
|
155 |
+
|
156 |
+
$node['Attribute'][] = $n;
|
157 |
+
}
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
$map['Item'][] = $node;
|
162 |
+
}
|
163 |
+
|
164 |
+
return $map;
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Remaps the custom item-key-value format used by Batch* operations to the more common ComplexList
|
169 |
+
* format. Internal use only.
|
170 |
+
*
|
171 |
+
* @param array $keys (Required) The key-value format passed by <put_attributes()>.
|
172 |
+
* @param boolean|array $replace (Optional) The `$replace` value passed by <batch_put_attributes()> and <batch_delete_attributes()>.
|
173 |
+
* @return array A <CFComplexType>-compatible mapping of parameters.
|
174 |
+
*/
|
175 |
+
public static function remap_attribute_items_for_complextype($keys, $replace = false)
|
176 |
+
{
|
177 |
+
$map = array(
|
178 |
+
'Attribute' => array()
|
179 |
+
);
|
180 |
+
|
181 |
+
foreach ($keys as $k => $v)
|
182 |
+
{
|
183 |
+
$v = is_array($v) ? $v : array($v);
|
184 |
+
|
185 |
+
foreach ($v as $vv)
|
186 |
+
{
|
187 |
+
$n = array();
|
188 |
+
$n['Name'] = $k;
|
189 |
+
$n['Value'] = $vv;
|
190 |
+
|
191 |
+
if (
|
192 |
+
$replace === (boolean) true ||
|
193 |
+
(is_array($replace) && array_search($k, $replace, true) !== false)
|
194 |
+
)
|
195 |
+
{
|
196 |
+
$n['Replace'] = 'true';
|
197 |
+
}
|
198 |
+
|
199 |
+
$map['Attribute'][] = $n;
|
200 |
+
}
|
201 |
+
}
|
202 |
+
|
203 |
+
return $map;
|
204 |
+
}
|
205 |
+
|
206 |
+
|
207 |
+
/*%******************************************************************************************%*/
|
208 |
+
// CONSTRUCTOR
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Constructs a new instance of <AmazonSDB>.
|
212 |
+
*
|
213 |
+
* @param string $key (Optional) Your Amazon API Key. If blank, it will look for the <code>AWS_KEY</code> constant.
|
214 |
+
* @param string $secret_key (Optional) Your Amazon API Secret Key. If blank, it will look for the <code>AWS_SECRET_KEY</code> constant.
|
215 |
+
* @return boolean false if no valid values are set, otherwise true.
|
216 |
+
*/
|
217 |
+
public function __construct($key = null, $secret_key = null)
|
218 |
+
{
|
219 |
+
$this->api_version = '2009-04-15';
|
220 |
+
$this->hostname = self::DEFAULT_URL;
|
221 |
+
|
222 |
+
if (!$key && !defined('AWS_KEY'))
|
223 |
+
{
|
224 |
+
throw new SDB_Exception('No account key was passed into the constructor, nor was it set in the AWS_KEY constant.');
|
225 |
+
}
|
226 |
+
|
227 |
+
if (!$secret_key && !defined('AWS_SECRET_KEY'))
|
228 |
+
{
|
229 |
+
throw new SDB_Exception('No account secret was passed into the constructor, nor was it set in the AWS_SECRET_KEY constant.');
|
230 |
+
}
|
231 |
+
|
232 |
+
return parent::__construct($key, $secret_key);
|
233 |
+
}
|
234 |
+
|
235 |
+
|
236 |
+
/*%******************************************************************************************%*/
|
237 |
+
// SERVICE METHODS
|
238 |
+
|
239 |
+
/**
|
240 |
+
*
|
241 |
+
* The <code>Select</code> operation returns a set of attributes for <code>ItemNames</code> that match the select
|
242 |
+
* expression. <code>Select</code> is similar to the standard SQL SELECT statement.
|
243 |
+
*
|
244 |
+
* The total size of the response cannot exceed 1 MB in total size. Amazon SimpleDB automatically adjusts the number of
|
245 |
+
* items returned per page to enforce this limit. For example, if the client asks to retrieve 2500 items, but each
|
246 |
+
* individual item is 10 kB in size, the system returns 100 items and an appropriate <code>NextToken</code> so the client
|
247 |
+
* can access the next page of results.
|
248 |
+
*
|
249 |
+
* For information on how to construct select expressions, see Using Select to Create Amazon SimpleDB Queries in the
|
250 |
+
* Developer Guide.
|
251 |
+
*
|
252 |
+
* @param string $select_expression (Required) The expression used to query the domain.
|
253 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
254 |
+
* <li><code>NextToken</code> - <code>string</code> - Optional - A string informing Amazon SimpleDB where to start the next list of <code>ItemNames</code>. </li>
|
255 |
+
* <li><code>ConsistentRead</code> - <code>boolean</code> - Optional - Determines whether or not strong consistency should be enforced when data is read from SimpleDB. If <code>true</code>, any data previously written to SimpleDB will be returned. Otherwise, results will be consistent eventually, and the client may not see data that was written immediately before your read. </li>
|
256 |
+
* <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>
|
257 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
258 |
+
*/
|
259 |
+
public function select($select_expression, $opt = null)
|
260 |
+
{
|
261 |
+
if (!$opt) $opt = array();
|
262 |
+
$opt['SelectExpression'] = $select_expression;
|
263 |
+
|
264 |
+
return $this->authenticate('Select', $opt, $this->hostname);
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* The PutAttributes operation creates or replaces attributes in an item.
|
269 |
+
*
|
270 |
+
* A single item can have the attributes <code>{ "first_name", "first_value" }</code> and
|
271 |
+
* <code>{ "first_name", second_value" }</code>. However, it cannot have two attribute instances where
|
272 |
+
* both the attribute name and attribute value are the same. Optionally, the requestor can supply the
|
273 |
+
* <code>Replace</code> parameter for each individual attribute. Setting this value to true causes the
|
274 |
+
* new attribute value to replace the existing attribute value(s).
|
275 |
+
*
|
276 |
+
* For example, if an item has the attributes <code>{ 'a', '1' }, { 'b', '2'}</code> and <code>{ 'b', '3' }</code>
|
277 |
+
* and the requestor calls <code>PutAttributes</code> using the attributes <code>{ 'b', '4' }</code> with
|
278 |
+
* the <code>Replace</code> parameter set to <code>true</code>, the final attributes of the item are changed
|
279 |
+
* to <code>{ 'a', '1' }</code> and <code>{ 'b', '4' }</code>, which replaces the previous values of the 'b'
|
280 |
+
* attribute with the new value.
|
281 |
+
*
|
282 |
+
* Using PutAttributes to replace attribute values that do not exist will not result in an error
|
283 |
+
* response.
|
284 |
+
*
|
285 |
+
* You cannot specify an empty string as an attribute name.
|
286 |
+
*
|
287 |
+
* Because Amazon SimpleDB makes multiple copies of your data and uses an eventual consistency update
|
288 |
+
* model, an immediate GetAttributes or Select request (read) immediately after a DeleteAttributes
|
289 |
+
* request (write) might not return the updated data.
|
290 |
+
*
|
291 |
+
* The following limitations are enforced for this operation:
|
292 |
+
*
|
293 |
+
* <ul>
|
294 |
+
* <li>256 attribute name-value pairs per item</li>
|
295 |
+
* <li>1 billion attributes per domain</li>
|
296 |
+
* <li>10 GB of total user data storage per domain</li>
|
297 |
+
* </ul>
|
298 |
+
*
|
299 |
+
* @param string $domain_name (Required) The name of the domain in which the attributes are being deleted.
|
300 |
+
* @param string $item_name (Required) The name of the base item which will contain the series of keypairs.
|
301 |
+
* @param array $keypairs (Required) Associative array of parameters which are treated as key-value and key-multivalue pairs (i.e. a key can have one or more values; think tags). <ul>
|
302 |
+
* <li><code>[key]</code> - <code>array</code> - Set the custom key name as the key for this value. For the value, pass a string for a single value, or an indexed array for multiple values.</li>
|
303 |
+
* </ul>
|
304 |
+
* @param boolean|array $replace (Optional) Whether to replace a key-value pair if a matching key already exists. Supports either a boolean (which affects ALL key-value pairs) or an indexed array of key names (which affects only the keys specified). Defaults to boolean <code>false</code>.
|
305 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
306 |
+
* <li><code>Expected</code> - <code>array</code> - Optional - The update condition which, if specified, determines if the specified attributes will be updated or not. The update condition must be satisfied in order for this request to be processed and the attributes to be updated. <ul>
|
307 |
+
* <li><code>Name</code> - <code>string</code> - Optional - The name of the attribute involved in the condition.</li>
|
308 |
+
* <li><code>Value</code> - <code>string</code> - Optional - The value of an attribute. This value can only be specified when the exists parameter is equal to true.</li>
|
309 |
+
* <li><code>Exists</code> - <code>string</code> - Optional - True if the specified attribute must exist with the specified value in order for this update condition to be satisfied, otherwise false if the specified attribute should not exist in order for this update condition to be satisfied.</li>
|
310 |
+
* </ul></li>
|
311 |
+
* <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 is useful for manually-managed batch requests.</li></ul>
|
312 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
313 |
+
*/
|
314 |
+
public function put_attributes($domain_name, $item_name, $keypairs, $replace = null, $opt = null)
|
315 |
+
{
|
316 |
+
if (!$opt) $opt = array();
|
317 |
+
$opt['DomainName'] = $domain_name;
|
318 |
+
$opt['ItemName'] = $item_name;
|
319 |
+
|
320 |
+
$opt = array_merge($opt, CFComplexType::map(
|
321 |
+
self::remap_attribute_items_for_complextype($keypairs, $replace)
|
322 |
+
));
|
323 |
+
|
324 |
+
if (isset($opt['Expected']))
|
325 |
+
{
|
326 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
327 |
+
'Expected' => $opt['Expected']
|
328 |
+
)));
|
329 |
+
unset($opt['Expected']);
|
330 |
+
}
|
331 |
+
|
332 |
+
return $this->authenticate('PutAttributes', $opt, $this->hostname);
|
333 |
+
}
|
334 |
+
|
335 |
+
/**
|
336 |
+
* Performs multiple DeleteAttributes operations in a single call, which reduces round trips and latencies.
|
337 |
+
* This enables Amazon SimpleDB to optimize requests, which generally yields better throughput.
|
338 |
+
*
|
339 |
+
* If you specify BatchDeleteAttributes without attributes or values, all the attributes for the item are
|
340 |
+
* deleted. BatchDeleteAttributes is an idempotent operation; running it multiple times on the same item
|
341 |
+
* or attribute doesn't result in an error. The BatchDeleteAttributes operation succeeds or fails in its
|
342 |
+
* entirety. There are no partial deletes.
|
343 |
+
*
|
344 |
+
* You can execute multiple BatchDeleteAttributes operations and other operations in parallel. However,
|
345 |
+
* large numbers of concurrent BatchDeleteAttributes calls can result in Service Unavailable (503) responses.
|
346 |
+
* This operation does not support conditions using <code>Expected.X.Name</code>, <code>Expected.X.Value</code>,
|
347 |
+
* or <code>Expected.X.Exists</code>.
|
348 |
+
*
|
349 |
+
* The following limitations are enforced for this operation:
|
350 |
+
*
|
351 |
+
* <ul>
|
352 |
+
* <li>1 MB request size</li>
|
353 |
+
* <li>25 item limit per BatchDeleteAttributes operation</li>
|
354 |
+
* </ul>
|
355 |
+
*
|
356 |
+
* @param string $domain_name (Required) The name of the domain in which the attributes are being deleted.
|
357 |
+
* @param array $item_keypairs (Required) Associative array of parameters which are treated as item-key-value and item-key-multivalue pairs (i.e. a key can have one or more values; think tags).
|
358 |
+
* <li><code>[item]</code> - <code>array</code> - Set the custom item name as the key for this value.<ul>
|
359 |
+
* <li><code>[key]</code> - <code>array</code> - Set the custom key name as the key for this value. For the value, pass a string for a single value, or an indexed array for multiple values.</li>
|
360 |
+
* </ul></li></ul>
|
361 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
362 |
+
* <li><code>Item</code> - <code>array</code> - Optional - A list of items on which to perform the operation. <ul>
|
363 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
364 |
+
* <li><code>ItemName</code> - <code>string</code> - Optional - This is the parameter format supported by the web service API. This is the item name to use.<ul>
|
365 |
+
* <li><code>Attribute</code> - <code>array</code> - Optional - This is the parameter format supported by the web service API. This is the attribute node.<ul>
|
366 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
367 |
+
* <li><code>Name</code> - <code>string</code> - Required - The name of the attribute. </li>
|
368 |
+
* <li><code>AlternateNameEncoding</code> - <code>string</code> - Optional - This is the parameter format supported by the web service API. This is the alternate name encoding to use.</li>
|
369 |
+
* <li><code>Value</code> - <code>string</code> - Required - The value of the attribute. </li>
|
370 |
+
* <li><code>AlternateValueEncoding</code> - <code>string</code> - Optional - This is the parameter format supported by the web service API. This is the alternate value encoding to use.</li>
|
371 |
+
* </ul></li>
|
372 |
+
* </ul></li>
|
373 |
+
* </ul></li>
|
374 |
+
* </ul></li>
|
375 |
+
* <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 is useful for manually-managed batch requests.</li></ul>
|
376 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
377 |
+
*/
|
378 |
+
public function batch_delete_attributes($domain_name, $item_keypairs, $opt = null)
|
379 |
+
{
|
380 |
+
if (!$opt) $opt = array();
|
381 |
+
$opt['DomainName'] = $domain_name;
|
382 |
+
|
383 |
+
$opt = array_merge($opt, CFComplexType::map(
|
384 |
+
self::remap_batch_items_for_complextype($item_keypairs)
|
385 |
+
));
|
386 |
+
|
387 |
+
if (isset($opt['Item']))
|
388 |
+
{
|
389 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
390 |
+
'Item' => $opt['Item']
|
391 |
+
)));
|
392 |
+
unset($opt['Item']);
|
393 |
+
}
|
394 |
+
|
395 |
+
return $this->authenticate('BatchDeleteAttributes', $opt, $this->hostname);
|
396 |
+
}
|
397 |
+
|
398 |
+
/**
|
399 |
+
*
|
400 |
+
* The <code>DeleteDomain</code> operation deletes a domain. Any items (and their attributes) in the domain are deleted as
|
401 |
+
* well. The <code>DeleteDomain</code> operation might take 10 or more seconds to complete.
|
402 |
+
*
|
403 |
+
* Running <code>DeleteDomain</code> on a domain that does not exist or running the function multiple times using the same
|
404 |
+
* domain name will not result in an error response.
|
405 |
+
*
|
406 |
+
* @param string $domain_name (Required) The name of the domain to delete.
|
407 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
408 |
+
* <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>
|
409 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
410 |
+
*/
|
411 |
+
public function delete_domain($domain_name, $opt = null)
|
412 |
+
{
|
413 |
+
if (!$opt) $opt = array();
|
414 |
+
$opt['DomainName'] = $domain_name;
|
415 |
+
|
416 |
+
return $this->authenticate('DeleteDomain', $opt, $this->hostname);
|
417 |
+
}
|
418 |
+
|
419 |
+
/**
|
420 |
+
*
|
421 |
+
* The <code>CreateDomain</code> operation creates a new domain. The domain name should be unique among the domains
|
422 |
+
* associated with the Access Key ID provided in the request. The <code>CreateDomain</code> operation may take 10 or more
|
423 |
+
* seconds to complete.
|
424 |
+
*
|
425 |
+
* CreateDomain is an idempotent operation; running it multiple times using the same domain name will not result in an
|
426 |
+
* error response.
|
427 |
+
*
|
428 |
+
* The client can create up to 100 domains per account.
|
429 |
+
*
|
430 |
+
* If the client requires additional domains, go to <a
|
431 |
+
* "http://aws.amazon.com/contact-us/simpledb-limit-request/">http://aws.amazon.com/contact-us/simpledb-limit-request/</a>.
|
432 |
+
*
|
433 |
+
* @param string $domain_name (Required) The name of the domain to create. The name can range between 3 and 255 characters and can contain the following characters: a-z, A-Z, 0-9, '_', '-', and '.'.
|
434 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
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 create_domain($domain_name, $opt = null)
|
439 |
+
{
|
440 |
+
if (!$opt) $opt = array();
|
441 |
+
$opt['DomainName'] = $domain_name;
|
442 |
+
|
443 |
+
return $this->authenticate('CreateDomain', $opt, $this->hostname);
|
444 |
+
}
|
445 |
+
|
446 |
+
/**
|
447 |
+
* Deletes one or more attributes associated with the item. If all attributes of an item are deleted,
|
448 |
+
* the item is deleted.
|
449 |
+
*
|
450 |
+
* If you specify DeleteAttributes without attributes or values, all the attributes for the item are
|
451 |
+
* deleted.
|
452 |
+
*
|
453 |
+
* DeleteAttributes is an idempotent operation; running it multiple times on the same item or
|
454 |
+
* attribute does not result in an error response.
|
455 |
+
*
|
456 |
+
* Because Amazon SimpleDB makes multiple copies of your data and uses an eventual consistency update
|
457 |
+
* model, performing a GetAttributes or Select request (read) immediately after a DeleteAttributes or
|
458 |
+
* PutAttributes request (write) might not return the updated data.
|
459 |
+
*
|
460 |
+
* @param string $domain_name (Required) The name of the domain in which the attributes are being deleted.
|
461 |
+
* @param string $item_name (Required) The name of the base item which will contain the series of keypairs.
|
462 |
+
* @param array $attributes (Optional) Similar to columns on a spreadsheet, attributes represent categories of data that can be assigned to items. Takes an associative array of parameters that can have the following keys: <ul>
|
463 |
+
* <li><code>Attribute</code> - <code>array</code> - Optional - This is the parameter format supported by the web service API. This is the attribute node.<ul>
|
464 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
465 |
+
* <li><code>Name</code> - <code>string</code> - Required - The name of the attribute. </li>
|
466 |
+
* <li><code>AlternateNameEncoding</code> - <code>string</code> - Optional - This is the parameter format supported by the web service API. This is the alternate name encoding to use.</li>
|
467 |
+
* <li><code>Value</code> - <code>string</code> - Required - The value of the attribute. </li>
|
468 |
+
* <li><code>AlternateValueEncoding</code> - <code>string</code> - Optional - This is the parameter format supported by the web service API. This is the alternate value encoding to use.</li>
|
469 |
+
* </ul></li>
|
470 |
+
* </ul></li></ul>
|
471 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
472 |
+
* <li><code>Expected</code> - <code>array</code> - Optional - The update condition which, if specified, determines if the specified attributes will be updated or not. The update condition must be satisfied in order for this request to be processed and the attributes to be updated. <ul>
|
473 |
+
* <li><code>Name</code> - <code>string</code> - Optional - The name of the attribute involved in the condition.</li>
|
474 |
+
* <li><code>Value</code> - <code>string</code> - Optional - The value of an attribute. This value can only be specified when the exists parameter is equal to true.</li>
|
475 |
+
* <li><code>Exists</code> - <code>string</code> - Optional - True if the specified attribute must exist with the specified value in order for this update condition to be satisfied, otherwise false if the specified attribute should not exist in order for this update condition to be satisfied.</li>
|
476 |
+
* </ul></li>
|
477 |
+
* <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 is useful for manually-managed batch requests.</li></ul>
|
478 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
479 |
+
*/
|
480 |
+
public function delete_attributes($domain_name, $item_name, $attributes = null, $opt = null)
|
481 |
+
{
|
482 |
+
if (!$opt) $opt = array();
|
483 |
+
$opt['DomainName'] = $domain_name;
|
484 |
+
$opt['ItemName'] = $item_name;
|
485 |
+
|
486 |
+
if ($attributes)
|
487 |
+
{
|
488 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
489 |
+
'Attribute' => (is_array($attributes) ? $attributes : array($attributes))
|
490 |
+
)));
|
491 |
+
}
|
492 |
+
|
493 |
+
if (isset($opt['Expected']))
|
494 |
+
{
|
495 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
496 |
+
'Expected' => $opt['Expected']
|
497 |
+
)));
|
498 |
+
unset($opt['Expected']);
|
499 |
+
}
|
500 |
+
|
501 |
+
return $this->authenticate('DeleteAttributes', $opt, $this->hostname);
|
502 |
+
}
|
503 |
+
|
504 |
+
/**
|
505 |
+
*
|
506 |
+
* The <code>ListDomains</code> operation lists all domains associated with the Access Key ID. It returns domain names up
|
507 |
+
* to the limit set by <a href="#MaxNumberOfDomains">MaxNumberOfDomains</a>. A <a href="#NextToken">NextToken</a> is
|
508 |
+
* returned if there are more than <code>MaxNumberOfDomains</code> domains. Calling <code>ListDomains</code> successive
|
509 |
+
* times with the <code>NextToken</code> provided by the operation returns up to <code>MaxNumberOfDomains</code> more
|
510 |
+
* domain names with each successive operation call.
|
511 |
+
*
|
512 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
513 |
+
* <li><code>MaxNumberOfDomains</code> - <code>integer</code> - Optional - The maximum number of domain names you want returned. The range is 1 to 100. The default setting is 100. </li>
|
514 |
+
* <li><code>NextToken</code> - <code>string</code> - Optional - A string informing Amazon SimpleDB where to start the next list of domain names. </li>
|
515 |
+
* <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>
|
516 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
517 |
+
*/
|
518 |
+
public function list_domains($opt = null)
|
519 |
+
{
|
520 |
+
if (!$opt) $opt = array();
|
521 |
+
|
522 |
+
return $this->authenticate('ListDomains', $opt, $this->hostname);
|
523 |
+
}
|
524 |
+
|
525 |
+
/**
|
526 |
+
* Returns all of the attributes associated with the item. Optionally, the attributes returned can be
|
527 |
+
* limited to one or more specified attribute name parameters.
|
528 |
+
*
|
529 |
+
* If the item does not exist on the replica that was accessed for this operation, an empty set is
|
530 |
+
* returned. The system does not return an error as it cannot guarantee the item does not exist on
|
531 |
+
* other replicas.
|
532 |
+
*
|
533 |
+
* If you specify GetAttributes without any attribute names, all the attributes for the item are
|
534 |
+
* returned.
|
535 |
+
*
|
536 |
+
* @param string $domain_name (Required) The name of the domain in which to perform the operation.
|
537 |
+
* @param string $item_name (Required) The name of the base item which will contain the series of keypairs.
|
538 |
+
* @param string|array $attribute_name (Optional) The names of the attributes. Pass a string for a single value, or an indexed array for multiple values.
|
539 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
540 |
+
* <li><code>ConsistentRead</code> - <code>boolean</code> - Optional - True if strong consistency should be enforced when data is read from SimpleDB, meaning that any data previously written to SimpleDB will be returned. Without specifying this parameter, results will be eventually consistent, and you may not see data that was written immediately before your read.</li>
|
541 |
+
* <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 is useful for manually-managed batch requests.</li></ul>
|
542 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
543 |
+
*/
|
544 |
+
public function get_attributes($domain_name, $item_name, $attribute_name = null, $opt = null)
|
545 |
+
{
|
546 |
+
if (!$opt) $opt = array();
|
547 |
+
$opt['DomainName'] = $domain_name;
|
548 |
+
$opt['ItemName'] = $item_name;
|
549 |
+
|
550 |
+
if ($attribute_name)
|
551 |
+
{
|
552 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
553 |
+
'AttributeName' => (is_array($attribute_name) ? $attribute_name : array($attribute_name))
|
554 |
+
)));
|
555 |
+
}
|
556 |
+
|
557 |
+
return $this->authenticate('GetAttributes', $opt, $this->hostname);
|
558 |
+
}
|
559 |
+
|
560 |
+
/**
|
561 |
+
* The BatchPutAttributes operation creates or replaces attributes within one or more items.
|
562 |
+
*
|
563 |
+
* Attributes are uniquely identified within an item by their name/value combination. For example, a single item can
|
564 |
+
* have the attributes <code>{ "first_name", "first_value" }</code> and <code>{"first_name", "second_value" }</code>.
|
565 |
+
* However, it cannot have two attribute instances where both the item attribute name and item attribute value are
|
566 |
+
* the same.
|
567 |
+
*
|
568 |
+
* Optionally, the requester can supply the <code>Replace</code> parameter for each individual value. Setting this value to
|
569 |
+
* true will cause the new attribute value to replace the existing attribute value(s). For example, if an item I has the
|
570 |
+
* attributes <code>{ 'a', '1' }, { 'b', '2'}</code> and <code>{ 'b', '3' }</code> and the requester does a
|
571 |
+
* <code>BatchPutAttributes</code> of <code>{'I', 'b', '4' }</code> with the <code>Replace</code> parameter set to true,
|
572 |
+
* the final attributes of the item will be { 'a', '1' } and { 'b', '4' }, replacing the previous values of the 'b'
|
573 |
+
* attribute with the new value. You cannot specify an empty string as an item or attribute name.
|
574 |
+
*
|
575 |
+
* The BatchPutAttributes operation succeeds or fails in its entirety. There are no partial puts. You can execute multiple
|
576 |
+
* BatchPutAttributes operations and other operations in parallel. However, large numbers of concurrent BatchPutAttributes
|
577 |
+
* calls can result in Service Unavailable (503) responses. The following limitations are enforced for this operation:
|
578 |
+
*
|
579 |
+
* <ul>
|
580 |
+
* <li>256 attribute name-value pairs per item</li>
|
581 |
+
* <li>1 MB request size</li>
|
582 |
+
* <li>1 billion attributes per domain</li>
|
583 |
+
* <li>10 GB of total user data storage per domain</li>
|
584 |
+
* <li>25 item limit per BatchPutAttributes operation</li>
|
585 |
+
* </ul>
|
586 |
+
*
|
587 |
+
* @param string $domain_name (Required) The name of the domain in which the attributes are being deleted.
|
588 |
+
* @param array $item_keypairs (Required) Associative array of parameters which are treated as item-key-value and item-key-multivalue pairs (i.e. a key can have one or more values; think tags).
|
589 |
+
* <li><code>[item]</code> - <code>array</code> - Set the custom item name as the key for this value.<ul>
|
590 |
+
* <li><code>[key]</code> - <code>array</code> - Set the custom key name as the key for this value. For the value, pass a string for a single value, or an indexed array for multiple values.</li>
|
591 |
+
* </ul></li></ul>
|
592 |
+
* @param boolean|array $replace (Optional) Whether to replace a key-value pair if a matching key already exists. Supports either a boolean (which affects ALL key-value pairs) or an indexed array of key names (which affects only the keys specified). Defaults to boolean <code>false</code>.
|
593 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
594 |
+
* <li><code>Item</code> - <code>array</code> - Optional - A list of items on which to perform the operation. <ul>
|
595 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
596 |
+
* <li><code>ItemName</code> - <code>string</code> - Optional - This is the parameter format supported by the web service API. This is the item name to use.<ul>
|
597 |
+
* <li><code>Attribute</code> - <code>array</code> - Optional - This is the parameter format supported by the web service API. This is the attribute node.<ul>
|
598 |
+
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
|
599 |
+
* <li><code>Name</code> - <code>string</code> - Required - The name of the attribute. </li>
|
600 |
+
* <li><code>AlternateNameEncoding</code> - <code>string</code> - Optional - This is the parameter format supported by the web service API. This is the alternate name encoding to use.</li>
|
601 |
+
* <li><code>Value</code> - <code>string</code> - Required - The value of the attribute. </li>
|
602 |
+
* <li><code>AlternateValueEncoding</code> - <code>string</code> - Optional - This is the parameter format supported by the web service API. This is the alternate value encoding to use.</li>
|
603 |
+
* </ul></li>
|
604 |
+
* </ul></li>
|
605 |
+
* </ul></li>
|
606 |
+
* </ul></li>
|
607 |
+
* <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 is useful for manually-managed batch requests.</li></ul>
|
608 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
609 |
+
*/
|
610 |
+
public function batch_put_attributes($domain_name, $item_keypairs, $replace = null, $opt = null)
|
611 |
+
{
|
612 |
+
if (!$opt) $opt = array();
|
613 |
+
$opt['DomainName'] = $domain_name;
|
614 |
+
|
615 |
+
$opt = array_merge($opt, CFComplexType::map(
|
616 |
+
self::remap_batch_items_for_complextype($item_keypairs, $replace)
|
617 |
+
));
|
618 |
+
|
619 |
+
if (isset($opt['Item']))
|
620 |
+
{
|
621 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
622 |
+
'Item' => $opt['Item']
|
623 |
+
)));
|
624 |
+
unset($opt['Item']);
|
625 |
+
|