Skip to content

Commit

Permalink
feat(clients): update command documentation examples as of 2024-09-20
Browse files Browse the repository at this point in the history
  • Loading branch information
awstools committed Sep 20, 2024
1 parent cdacf56 commit ab843b8
Show file tree
Hide file tree
Showing 48 changed files with 1,330 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,27 @@ export interface AddLayerVersionPermissionCommandOutput extends AddLayerVersionP
* <p>Base exception class for all service exceptions from Lambda service.</p>
*
* @public
* @example To add permissions to a layer version
* ```javascript
* // The following example grants permission for the account 223456789012 to use version 1 of a layer named my-layer.
* const input = {
* "Action": "lambda:GetLayerVersion",
* "LayerName": "my-layer",
* "Principal": "223456789012",
* "StatementId": "xaccount",
* "VersionNumber": 1
* };
* const command = new AddLayerVersionPermissionCommand(input);
* const response = await client.send(command);
* /* response ==
* {
* "RevisionId": "35d87451-f796-4a3f-a618-95a3671b0a0c",
* "Statement": "{\"Sid\":\"xaccount\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::223456789012:root\"},\"Action\":\"lambda:GetLayerVersion\",\"Resource\":\"arn:aws:lambda:us-east-2:123456789012:layer:my-layer:1\"}"
* }
* *\/
* // example id: to-add-permissions-to-a-layer-version-1586479797163
* ```
*
*/
export class AddLayerVersionPermissionCommand extends $Command
.classBuilder<
Expand Down
40 changes: 40 additions & 0 deletions clients/client-lambda/src/commands/AddPermissionCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,46 @@ export interface AddPermissionCommandOutput extends AddPermissionResponse, __Met
* <p>Base exception class for all service exceptions from Lambda service.</p>
*
* @public
* @example To grant Amazon S3 permission to invoke a function
* ```javascript
* // The following example adds permission for Amazon S3 to invoke a Lambda function named my-function for notifications from a bucket named my-bucket-1xpuxmplzrlbh in account 123456789012.
* const input = {
* "Action": "lambda:InvokeFunction",
* "FunctionName": "my-function",
* "Principal": "s3.amazonaws.com",
* "SourceAccount": "123456789012",
* "SourceArn": "arn:aws:s3:::my-bucket-1xpuxmplzrlbh/*",
* "StatementId": "s3"
* };
* const command = new AddPermissionCommand(input);
* const response = await client.send(command);
* /* response ==
* {
* "Statement": "{\"Sid\":\"s3\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"s3.amazonaws.com\"},\"Action\":\"lambda:InvokeFunction\",\"Resource\":\"arn:aws:lambda:us-east-2:123456789012:function:my-function\",\"Condition\":{\"StringEquals\":{\"AWS:SourceAccount\":\"123456789012\"},\"ArnLike\":{\"AWS:SourceArn\":\"arn:aws:s3:::my-bucket-1xpuxmplzrlbh\"}}}"
* }
* *\/
* // example id: add-permission-1474651469455
* ```
*
* @example To grant another account permission to invoke a function
* ```javascript
* // The following example adds permission for account 223456789012 invoke a Lambda function named my-function.
* const input = {
* "Action": "lambda:InvokeFunction",
* "FunctionName": "my-function",
* "Principal": "223456789012",
* "StatementId": "xaccount"
* };
* const command = new AddPermissionCommand(input);
* const response = await client.send(command);
* /* response ==
* {
* "Statement": "{\"Sid\":\"xaccount\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::223456789012:root\"},\"Action\":\"lambda:InvokeFunction\",\"Resource\":\"arn:aws:lambda:us-east-2:123456789012:function:my-function\"}"
* }
* *\/
* // example id: add-permission-1474651469456
* ```
*
*/
export class AddPermissionCommand extends $Command
.classBuilder<
Expand Down
23 changes: 23 additions & 0 deletions clients/client-lambda/src/commands/CreateAliasCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,29 @@ export interface CreateAliasCommandOutput extends AliasConfiguration, __Metadata
* <p>Base exception class for all service exceptions from Lambda service.</p>
*
* @public
* @example To create an alias for a Lambda function
* ```javascript
* // The following example creates an alias named LIVE that points to version 1 of the my-function Lambda function.
* const input = {
* "Description": "alias for live version of function",
* "FunctionName": "my-function",
* "FunctionVersion": "1",
* "Name": "LIVE"
* };
* const command = new CreateAliasCommand(input);
* const response = await client.send(command);
* /* response ==
* {
* "AliasArn": "arn:aws:lambda:us-east-2:123456789012:function:my-function:LIVE",
* "Description": "alias for live version of function",
* "FunctionVersion": "1",
* "Name": "LIVE",
* "RevisionId": "873282ed-xmpl-4dc8-a069-d0c647e470c6"
* }
* *\/
* // example id: to-create-an-alias-for-a-lambda-function-1586480324259
* ```
*
*/
export class CreateAliasCommand extends $Command
.classBuilder<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,30 @@ export interface CreateEventSourceMappingCommandOutput extends EventSourceMappin
* <p>Base exception class for all service exceptions from Lambda service.</p>
*
* @public
* @example To create a mapping between an event source and an AWS Lambda function
* ```javascript
* // The following example creates a mapping between an SQS queue and the my-function Lambda function.
* const input = {
* "BatchSize": 5,
* "EventSourceArn": "arn:aws:sqs:us-west-2:123456789012:my-queue",
* "FunctionName": "my-function"
* };
* const command = new CreateEventSourceMappingCommand(input);
* const response = await client.send(command);
* /* response ==
* {
* "BatchSize": 5,
* "EventSourceArn": "arn:aws:sqs:us-west-2:123456789012:my-queue",
* "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function",
* "LastModified": 1569284520.333,
* "State": "Creating",
* "StateTransitionReason": "USER_INITIATED",
* "UUID": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE"
* }
* *\/
* // example id: to-create-a-mapping-between-an-event-source-and-an-aws-lambda-function-1586480555467
* ```
*
*/
export class CreateEventSourceMappingCommand extends $Command
.classBuilder<
Expand Down
64 changes: 64 additions & 0 deletions clients/client-lambda/src/commands/CreateFunctionCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,70 @@ export interface CreateFunctionCommandOutput extends FunctionConfiguration, __Me
* <p>Base exception class for all service exceptions from Lambda service.</p>
*
* @public
* @example To create a function
* ```javascript
* // The following example creates a function with a deployment package in Amazon S3 and enables X-Ray tracing and environment variable encryption.
* const input = {
* "Code": {
* "S3Bucket": "my-bucket-1xpuxmplzrlbh",
* "S3Key": "function.zip"
* },
* "Description": "Process image objects from Amazon S3.",
* "Environment": {
* "Variables": {
* "BUCKET": "my-bucket-1xpuxmplzrlbh",
* "PREFIX": "inbound"
* }
* },
* "FunctionName": "my-function",
* "Handler": "index.handler",
* "KMSKeyArn": "arn:aws:kms:us-west-2:123456789012:key/b0844d6c-xmpl-4463-97a4-d49f50839966",
* "MemorySize": 256,
* "Publish": true,
* "Role": "arn:aws:iam::123456789012:role/lambda-role",
* "Runtime": "nodejs12.x",
* "Tags": {
* "DEPARTMENT": "Assets"
* },
* "Timeout": 15,
* "TracingConfig": {
* "Mode": "Active"
* }
* };
* const command = new CreateFunctionCommand(input);
* const response = await client.send(command);
* /* response ==
* {
* "CodeSha256": "YFgDgEKG3ugvF1+pX64gV6tu9qNuIYNUdgJm8nCxsm4=",
* "CodeSize": 5797206,
* "Description": "Process image objects from Amazon S3.",
* "Environment": {
* "Variables": {
* "BUCKET": "my-bucket-1xpuxmplzrlbh",
* "PREFIX": "inbound"
* }
* },
* "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function",
* "FunctionName": "my-function",
* "Handler": "index.handler",
* "KMSKeyArn": "arn:aws:kms:us-west-2:123456789012:key/b0844d6c-xmpl-4463-97a4-d49f50839966",
* "LastModified": "2020-04-10T19:06:32.563+0000",
* "LastUpdateStatus": "Successful",
* "MemorySize": 256,
* "RevisionId": "b75dcd81-xmpl-48a8-a75a-93ba8b5b9727",
* "Role": "arn:aws:iam::123456789012:role/lambda-role",
* "Runtime": "nodejs12.x",
* "State": "Active",
* "Timeout": 15,
* "TracingConfig": {
* "Mode": "Active"
* },
* "Version": "1"
* }
* *\/
* // example id: to-create-a-function-1586492061186
* ```
*
*/
export class CreateFunctionCommand extends $Command
.classBuilder<
Expand Down
12 changes: 12 additions & 0 deletions clients/client-lambda/src/commands/DeleteAliasCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ export interface DeleteAliasCommandOutput extends __MetadataBearer {}
* <p>Base exception class for all service exceptions from Lambda service.</p>
*
* @public
* @example To delete a Lambda function alias
* ```javascript
* // The following example deletes an alias named BLUE from a function named my-function
* const input = {
* "FunctionName": "my-function",
* "Name": "BLUE"
* };
* const command = new DeleteAliasCommand(input);
* await client.send(command);
* // example id: to-delete-a-lambda-function-alias-1481660370804
* ```
*
*/
export class DeleteAliasCommand extends $Command
.classBuilder<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,28 @@ export interface DeleteEventSourceMappingCommandOutput extends EventSourceMappin
* <p>Base exception class for all service exceptions from Lambda service.</p>
*
* @public
* @example To delete a Lambda function event source mapping
* ```javascript
* // The following example deletes an event source mapping. To get a mapping's UUID, use ListEventSourceMappings.
* const input = {
* "UUID": "14e0db71-xmpl-4eb5-b481-8945cf9d10c2"
* };
* const command = new DeleteEventSourceMappingCommand(input);
* const response = await client.send(command);
* /* response ==
* {
* "BatchSize": 5,
* "EventSourceArn": "arn:aws:sqs:us-west-2:123456789012:my-queue",
* "FunctionArn": "arn:aws:lambda:us-east-2:123456789012:function:my-function",
* "LastModified": "${timestamp}",
* "State": "Enabled",
* "StateTransitionReason": "USER_INITIATED",
* "UUID": "14e0db71-xmpl-4eb5-b481-8945cf9d10c2"
* }
* *\/
* // example id: to-delete-a-lambda-function-event-source-mapping-1481658973862
* ```
*
*/
export class DeleteEventSourceMappingCommand extends $Command
.classBuilder<
Expand Down
12 changes: 12 additions & 0 deletions clients/client-lambda/src/commands/DeleteFunctionCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ export interface DeleteFunctionCommandOutput extends __MetadataBearer {}
* <p>Base exception class for all service exceptions from Lambda service.</p>
*
* @public
* @example To delete a version of a Lambda function
* ```javascript
* // The following example deletes version 1 of a Lambda function named my-function.
* const input = {
* "FunctionName": "my-function",
* "Qualifier": "1"
* };
* const command = new DeleteFunctionCommand(input);
* await client.send(command);
* // example id: to-delete-a-lambda-function-1481648553696
* ```
*
*/
export class DeleteFunctionCommand extends $Command
.classBuilder<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ export interface DeleteFunctionConcurrencyCommandOutput extends __MetadataBearer
* <p>Base exception class for all service exceptions from Lambda service.</p>
*
* @public
* @example To remove the reserved concurrent execution limit from a function
* ```javascript
* // The following example deletes the reserved concurrent execution limit from a function named my-function.
* const input = {
* "FunctionName": "my-function"
* };
* const command = new DeleteFunctionConcurrencyCommand(input);
* await client.send(command);
* // example id: to-remove-the-reserved-concurrent-execution-limit-from-a-function-1586480714680
* ```
*
*/
export class DeleteFunctionConcurrencyCommand extends $Command
.classBuilder<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ export interface DeleteFunctionEventInvokeConfigCommandOutput extends __Metadata
* <p>Base exception class for all service exceptions from Lambda service.</p>
*
* @public
* @example To delete an asynchronous invocation configuration
* ```javascript
* // The following example deletes the asynchronous invocation configuration for the GREEN alias of a function named my-function.
* const input = {
* "FunctionName": "my-function",
* "Qualifier": "GREEN"
* };
* const command = new DeleteFunctionEventInvokeConfigCommand(input);
* await client.send(command);
* // example id: to-delete-an-asynchronous-invocation-configuration-1586481102187
* ```
*
*/
export class DeleteFunctionEventInvokeConfigCommand extends $Command
.classBuilder<
Expand Down
12 changes: 12 additions & 0 deletions clients/client-lambda/src/commands/DeleteLayerVersionCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ export interface DeleteLayerVersionCommandOutput extends __MetadataBearer {}
* <p>Base exception class for all service exceptions from Lambda service.</p>
*
* @public
* @example To delete a version of a Lambda layer
* ```javascript
* // The following example deletes version 2 of a layer named my-layer.
* const input = {
* "LayerName": "my-layer",
* "VersionNumber": 2
* };
* const command = new DeleteLayerVersionCommand(input);
* await client.send(command);
* // example id: to-delete-a-version-of-a-lambda-layer-1586481157547
* ```
*
*/
export class DeleteLayerVersionCommand extends $Command
.classBuilder<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ export interface DeleteProvisionedConcurrencyConfigCommandOutput extends __Metad
* <p>Base exception class for all service exceptions from Lambda service.</p>
*
* @public
* @example To delete a provisioned concurrency configuration
* ```javascript
* // The following example deletes the provisioned concurrency configuration for the GREEN alias of a function named my-function.
* const input = {
* "FunctionName": "my-function",
* "Qualifier": "GREEN"
* };
* const command = new DeleteProvisionedConcurrencyConfigCommand(input);
* await client.send(command);
* // example id: to-delete-a-provisioned-concurrency-configuration-1586481032551
* ```
*
*/
export class DeleteProvisionedConcurrencyConfigCommand extends $Command
.classBuilder<
Expand Down
24 changes: 24 additions & 0 deletions clients/client-lambda/src/commands/GetAccountSettingsCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,30 @@ export interface GetAccountSettingsCommandOutput extends GetAccountSettingsRespo
* <p>Base exception class for all service exceptions from Lambda service.</p>
*
* @public
* @example To get account settings
* ```javascript
* // This operation takes no parameters and returns details about storage and concurrency quotas in the current Region.
* const input = {};
* const command = new GetAccountSettingsCommand(input);
* const response = await client.send(command);
* /* response ==
* {
* "AccountLimit": {
* "CodeSizeUnzipped": 262144000,
* "CodeSizeZipped": 52428800,
* "ConcurrentExecutions": 1000,
* "TotalCodeSize": 80530636800,
* "UnreservedConcurrentExecutions": 1000
* },
* "AccountUsage": {
* "FunctionCount": 4,
* "TotalCodeSize": 9426
* }
* }
* *\/
* // example id: to-get-account-settings-1481657495274
* ```
*
*/
export class GetAccountSettingsCommand extends $Command
.classBuilder<
Expand Down
Loading

0 comments on commit ab843b8

Please sign in to comment.