Thanks to visit codestin.com
Credit goes to github.com

Skip to content
/ core Public

Commit 6414067

Browse files
Implement EC2 client (#2064)
* Implement EC2 client * Applied corrections * Bump aliases
1 parent e8b02ac commit 6414067

4 files changed

Lines changed: 30 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## NOT RELEASED
44

5+
### Added
6+
7+
- AwsClientFactory: add `ec2()` method for the new `async-aws/ec2` client
8+
- XmlAwsErrorFactory: parse EC2-style error envelopes (`<Response><Errors><Error>...`)
9+
510
## 1.28.1
611

712
### Changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
},
4343
"extra": {
4444
"branch-alias": {
45-
"dev-master": "1.28-dev"
45+
"dev-master": "1.29-dev"
4646
}
4747
}
4848
}

src/AwsClientFactory.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use AsyncAws\Core\Exception\MissingDependency;
2525
use AsyncAws\Core\Sts\StsClient;
2626
use AsyncAws\DynamoDb\DynamoDbClient;
27+
use AsyncAws\Ec2\Ec2Client;
2728
use AsyncAws\Ecr\EcrClient;
2829
use AsyncAws\ElastiCache\ElastiCacheClient;
2930
use AsyncAws\EventBridge\EventBridgeClient;
@@ -264,6 +265,19 @@ public function dynamoDb(): DynamoDbClient
264265
return $this->serviceCache[__METHOD__];
265266
}
266267

268+
public function ec2(): Ec2Client
269+
{
270+
if (!class_exists(Ec2Client::class)) {
271+
throw MissingDependency::create('async-aws/ec2', 'EC2');
272+
}
273+
274+
if (!isset($this->serviceCache[__METHOD__])) {
275+
$this->serviceCache[__METHOD__] = new Ec2Client($this->configuration, $this->credentialProvider, $this->httpClient, $this->logger);
276+
}
277+
278+
return $this->serviceCache[__METHOD__];
279+
}
280+
267281
public function ecr(): EcrClient
268282
{
269283
if (!class_exists(EcrClient::class)) {

src/AwsError/XmlAwsErrorFactory.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ private static function parseXml(\SimpleXMLElement $xml): AwsError
4040
);
4141
}
4242

43+
// EC2 error envelope: <Response><Errors><Error><Code/><Message/></Error></Errors><RequestID/></Response>
44+
if (0 < $xml->Errors->count() && 0 < $xml->Errors->Error->count()) {
45+
return new AwsError(
46+
$xml->Errors->Error->Code->__toString(),
47+
$xml->Errors->Error->Message->__toString(),
48+
null,
49+
null
50+
);
51+
}
52+
4353
if (1 === $xml->Code->count() && 1 === $xml->Message->count()) {
4454
return new AwsError(
4555
$xml->Code->__toString(),

0 commit comments

Comments
 (0)