-
Notifications
You must be signed in to change notification settings - Fork 43
/
AmazonWebServices.php
189 lines (175 loc) · 4.27 KB
/
AmazonWebServices.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?php
namespace AmazonWebServicesBundle;
use Aws\Sdk;
use Aws\Credentials\Credentials;
/**
* Class AmazonWebServices
*
* @package AmazonWebServicesBundle\SharedConfig
*
* @Author : El Mehdi Mouddene <[email protected]>
*
* Initial version created on: 10/28/2015
*
*/
class AmazonWebServices {
/**
* @var array
*/
private $configs = array();
/**
* @var Sdk
*/
private $sdk;
/**
* __constructor
* @param array $config
*/
public function __construct($config = array())
{
$this->configs = $config;
$options = array(
'region' => $this->getRegion(),
// use specific aws sdk php version or latest version if not defined
'version' => ($this->getVersion() !== '') ? $this->getVersion() : 'latest',
);
if ($this->getKey() !== '' && $this->getSecret() !== '') {
$options['credentials'] = new Credentials($this->getKey(), $this->getSecret());
}
$this->sdk = new Sdk($options);
}
/**
* Create aws service clients
* @param $serviceType
* @return mixed
*/
public function createAwsServiceClient($serviceType){
return $this->sdk->createClient($serviceType);
}
/**
* Get the accountId
*
* @return string The account id provided via the bundle configuration
*/
public function accountId()
{
return $this->configs['account_id'];
}
/**
* Get the canonicalId
*
* @return string The cononical id provided via the bundle configuration
*/
public function canonicalId()
{
return $this->configs['canonical_id'];
}
/**
* Get the cononicalName
*
* @return string The canonical name provided via the bundle configuration
*/
public function canonicalName()
{
return $this->configs['canonical_name'];
}
/**
* Get the certificateAuthority
*
* @return string The certificate authority provided via the bundle configuration
*/
public function certificateAuthority()
{
return (bool) $this->configs['certificate_authority'];
}
/**
* Get the cloudFrontKeypair
*
* @return string The Cloudfront keypair id provided via the bundle configuration
*/
public function cloudfrontKeypair()
{
return $this->configs['cloudfront_keypair'];
}
/**
* Get the cloudfrontPem
*
* @return string The Cloudfront private key pem provided via the bundle configuration
*/
public function cloudfrontPrivateKeyPem()
{
return $this->configs['cloudfront_pem'];
}
/**
* Get the defaultCacheConfig
*
* @return string The default cache config provided via the bundle configuration
*/
public function defaultCacheConfig()
{
return $this->configs['default_cache_config'];
}
/**
* enableExtensions
*
* @return boolean
*/
public function enableExtensions()
{
return (bool) $this->configs['enable_extensions'];
}
/**
* Get the key
*
* @return string The key provided via the bundle configuration
*/
public function getKey()
{
return $this->configs['key'];
}
/**
* Get the parameters
*
* @return array The array of all configuration parameters provided via the bundle configuration
*/
public function getConfigs()
{
return $this->configs;
}
/**
* Get the mfaSerial
*
* @return string The mfa serial provided via the bundle configuration
*/
public function mfaSerial()
{
return $this->configs['mfa_serial'];
}
/**
* Get the secret
*
* @return string The secret key provided via the bundle configuration
*/
public function getSecret()
{
return $this->configs['secret'];
}
/**
* Get the mfaSerial
*
* @return string The mfa serial provided via the bundle configuration
*/
public function getVersion()
{
return $this->configs['version'];
}
/**
* Get the secret
*
* @return string The secret key provided via the bundle configuration
*/
public function getRegion()
{
return $this->configs['region'];
}
}