Skip to content

Commit 6aedd97

Browse files
authored
[Lambda] Add operation to list functions, list function version and to delete functions (#977)
* [Lambda] Add operation to list functions, list function version and to delete functions. * Fixed tests * Added changelog
1 parent b2e9dd0 commit 6aedd97

33 files changed

+2544
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
## NOT RELEASED
44

5+
## 1.4.0
6+
57
### Added
68

7-
- AWS api-change: Added constant for NodeJs 14
9+
- AWS api-change: Added constant for NodeJs 14.
10+
- Added operation `deleteFunction`, `listFunctions`, and `listVersionsByFunction`.
811

912
## 1.3.0
1013

src/Enum/FunctionVersion.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace AsyncAws\Lambda\Enum;
4+
5+
/**
6+
* Set to `ALL` to include entries for all published versions of each function.
7+
*/
8+
final class FunctionVersion
9+
{
10+
public const ALL = 'ALL';
11+
12+
public static function exists(string $value): bool
13+
{
14+
return isset([
15+
self::ALL => true,
16+
][$value]);
17+
}
18+
}

src/Enum/LastUpdateStatus.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace AsyncAws\Lambda\Enum;
4+
5+
/**
6+
* The status of the last update that was performed on the function. This is first set to `Successful` after function
7+
* creation completes.
8+
*/
9+
final class LastUpdateStatus
10+
{
11+
public const FAILED = 'Failed';
12+
public const IN_PROGRESS = 'InProgress';
13+
public const SUCCESSFUL = 'Successful';
14+
15+
public static function exists(string $value): bool
16+
{
17+
return isset([
18+
self::FAILED => true,
19+
self::IN_PROGRESS => true,
20+
self::SUCCESSFUL => true,
21+
][$value]);
22+
}
23+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace AsyncAws\Lambda\Enum;
4+
5+
/**
6+
* The reason code for the last update that was performed on the function.
7+
*/
8+
final class LastUpdateStatusReasonCode
9+
{
10+
public const ENI_LIMIT_EXCEEDED = 'EniLimitExceeded';
11+
public const IMAGE_ACCESS_DENIED = 'ImageAccessDenied';
12+
public const IMAGE_DELETED = 'ImageDeleted';
13+
public const INSUFFICIENT_ROLE_PERMISSIONS = 'InsufficientRolePermissions';
14+
public const INTERNAL_ERROR = 'InternalError';
15+
public const INVALID_CONFIGURATION = 'InvalidConfiguration';
16+
public const INVALID_IMAGE = 'InvalidImage';
17+
public const INVALID_SECURITY_GROUP = 'InvalidSecurityGroup';
18+
public const INVALID_SUBNET = 'InvalidSubnet';
19+
public const SUBNET_OUT_OF_IPADDRESSES = 'SubnetOutOfIPAddresses';
20+
21+
public static function exists(string $value): bool
22+
{
23+
return isset([
24+
self::ENI_LIMIT_EXCEEDED => true,
25+
self::IMAGE_ACCESS_DENIED => true,
26+
self::IMAGE_DELETED => true,
27+
self::INSUFFICIENT_ROLE_PERMISSIONS => true,
28+
self::INTERNAL_ERROR => true,
29+
self::INVALID_CONFIGURATION => true,
30+
self::INVALID_IMAGE => true,
31+
self::INVALID_SECURITY_GROUP => true,
32+
self::INVALID_SUBNET => true,
33+
self::SUBNET_OUT_OF_IPADDRESSES => true,
34+
][$value]);
35+
}
36+
}

src/Enum/PackageType.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace AsyncAws\Lambda\Enum;
4+
5+
/**
6+
* The type of deployment package. Set to `Image` for container image and set `Zip` for .zip file archive.
7+
*/
8+
final class PackageType
9+
{
10+
public const IMAGE = 'Image';
11+
public const ZIP = 'Zip';
12+
13+
public static function exists(string $value): bool
14+
{
15+
return isset([
16+
self::IMAGE => true,
17+
self::ZIP => true,
18+
][$value]);
19+
}
20+
}

src/Enum/Runtime.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace AsyncAws\Lambda\Enum;
44

55
/**
6-
* A runtime identifier. For example, `go1.x`.
6+
* The runtime environment for the Lambda function.
77
*/
88
final class Runtime
99
{

src/Enum/State.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace AsyncAws\Lambda\Enum;
4+
5+
/**
6+
* The current state of the function. When the state is `Inactive`, you can reactivate the function by invoking it.
7+
*/
8+
final class State
9+
{
10+
public const ACTIVE = 'Active';
11+
public const FAILED = 'Failed';
12+
public const INACTIVE = 'Inactive';
13+
public const PENDING = 'Pending';
14+
15+
public static function exists(string $value): bool
16+
{
17+
return isset([
18+
self::ACTIVE => true,
19+
self::FAILED => true,
20+
self::INACTIVE => true,
21+
self::PENDING => true,
22+
][$value]);
23+
}
24+
}

src/Enum/StateReasonCode.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace AsyncAws\Lambda\Enum;
4+
5+
/**
6+
* The reason code for the function's current state. When the code is `Creating`, you can't invoke or modify the
7+
* function.
8+
*/
9+
final class StateReasonCode
10+
{
11+
public const CREATING = 'Creating';
12+
public const ENI_LIMIT_EXCEEDED = 'EniLimitExceeded';
13+
public const IDLE = 'Idle';
14+
public const IMAGE_ACCESS_DENIED = 'ImageAccessDenied';
15+
public const IMAGE_DELETED = 'ImageDeleted';
16+
public const INSUFFICIENT_ROLE_PERMISSIONS = 'InsufficientRolePermissions';
17+
public const INTERNAL_ERROR = 'InternalError';
18+
public const INVALID_CONFIGURATION = 'InvalidConfiguration';
19+
public const INVALID_IMAGE = 'InvalidImage';
20+
public const INVALID_SECURITY_GROUP = 'InvalidSecurityGroup';
21+
public const INVALID_SUBNET = 'InvalidSubnet';
22+
public const RESTORING = 'Restoring';
23+
public const SUBNET_OUT_OF_IPADDRESSES = 'SubnetOutOfIPAddresses';
24+
25+
public static function exists(string $value): bool
26+
{
27+
return isset([
28+
self::CREATING => true,
29+
self::ENI_LIMIT_EXCEEDED => true,
30+
self::IDLE => true,
31+
self::IMAGE_ACCESS_DENIED => true,
32+
self::IMAGE_DELETED => true,
33+
self::INSUFFICIENT_ROLE_PERMISSIONS => true,
34+
self::INTERNAL_ERROR => true,
35+
self::INVALID_CONFIGURATION => true,
36+
self::INVALID_IMAGE => true,
37+
self::INVALID_SECURITY_GROUP => true,
38+
self::INVALID_SUBNET => true,
39+
self::RESTORING => true,
40+
self::SUBNET_OUT_OF_IPADDRESSES => true,
41+
][$value]);
42+
}
43+
}

src/Enum/TracingMode.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace AsyncAws\Lambda\Enum;
4+
5+
/**
6+
* The tracing mode.
7+
*/
8+
final class TracingMode
9+
{
10+
public const ACTIVE = 'Active';
11+
public const PASS_THROUGH = 'PassThrough';
12+
13+
public static function exists(string $value): bool
14+
{
15+
return isset([
16+
self::ACTIVE => true,
17+
self::PASS_THROUGH => true,
18+
][$value]);
19+
}
20+
}

src/Input/DeleteFunctionRequest.php

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?php
2+
3+
namespace AsyncAws\Lambda\Input;
4+
5+
use AsyncAws\Core\Exception\InvalidArgument;
6+
use AsyncAws\Core\Input;
7+
use AsyncAws\Core\Request;
8+
use AsyncAws\Core\Stream\StreamFactory;
9+
10+
final class DeleteFunctionRequest extends Input
11+
{
12+
/**
13+
* The name of the Lambda function or version.
14+
*
15+
* @required
16+
*
17+
* @var string|null
18+
*/
19+
private $functionName;
20+
21+
/**
22+
* Specify a version to delete. You can't delete a version that's referenced by an alias.
23+
*
24+
* @var string|null
25+
*/
26+
private $qualifier;
27+
28+
/**
29+
* @param array{
30+
* FunctionName?: string,
31+
* Qualifier?: string,
32+
* @region?: string,
33+
* } $input
34+
*/
35+
public function __construct(array $input = [])
36+
{
37+
$this->functionName = $input['FunctionName'] ?? null;
38+
$this->qualifier = $input['Qualifier'] ?? null;
39+
parent::__construct($input);
40+
}
41+
42+
public static function create($input): self
43+
{
44+
return $input instanceof self ? $input : new self($input);
45+
}
46+
47+
public function getFunctionName(): ?string
48+
{
49+
return $this->functionName;
50+
}
51+
52+
public function getQualifier(): ?string
53+
{
54+
return $this->qualifier;
55+
}
56+
57+
/**
58+
* @internal
59+
*/
60+
public function request(): Request
61+
{
62+
// Prepare headers
63+
$headers = ['content-type' => 'application/json'];
64+
65+
// Prepare query
66+
$query = [];
67+
if (null !== $this->qualifier) {
68+
$query['Qualifier'] = $this->qualifier;
69+
}
70+
71+
// Prepare URI
72+
$uri = [];
73+
if (null === $v = $this->functionName) {
74+
throw new InvalidArgument(sprintf('Missing parameter "FunctionName" for "%s". The value cannot be null.', __CLASS__));
75+
}
76+
$uri['FunctionName'] = $v;
77+
$uriString = '/2015-03-31/functions/' . rawurlencode($uri['FunctionName']);
78+
79+
// Prepare Body
80+
$body = '';
81+
82+
// Return the Request
83+
return new Request('DELETE', $uriString, $query, $headers, StreamFactory::create($body));
84+
}
85+
86+
public function setFunctionName(?string $value): self
87+
{
88+
$this->functionName = $value;
89+
90+
return $this;
91+
}
92+
93+
public function setQualifier(?string $value): self
94+
{
95+
$this->qualifier = $value;
96+
97+
return $this;
98+
}
99+
}

0 commit comments

Comments
 (0)