Skip to content

Commit

Permalink
feat(client-cloudtrail): Add ThrottlingException with error code 429 …
Browse files Browse the repository at this point in the history
…to handle CloudTrail Delegated Admin request rate exceeded on organization resources.
  • Loading branch information
awstools committed Aug 25, 2023
1 parent ae8e27c commit e7333b8
Show file tree
Hide file tree
Showing 11 changed files with 152 additions and 0 deletions.
5 changes: 5 additions & 0 deletions clients/client-cloudtrail/src/commands/CreateTrailCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ export interface CreateTrailCommandOutput extends CreateTrailResponse, __Metadat
* <p>The number of tags per trail, event data store, or channel has exceeded the permitted amount. Currently, the limit is
* 50.</p>
*
* @throws {@link ThrottlingException} (client fault)
* <p>
* This exception is thrown when the request rate exceeds the limit.
* </p>
*
* @throws {@link TrailAlreadyExistsException} (client fault)
* <p>This exception is thrown when the specified trail already exists.</p>
*
Expand Down
5 changes: 5 additions & 0 deletions clients/client-cloudtrail/src/commands/DeleteTrailCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ export interface DeleteTrailCommandOutput extends DeleteTrailResponse, __Metadat
* @throws {@link OperationNotPermittedException} (client fault)
* <p>This exception is thrown when the requested operation is not permitted.</p>
*
* @throws {@link ThrottlingException} (client fault)
* <p>
* This exception is thrown when the request rate exceeds the limit.
* </p>
*
* @throws {@link TrailNotFoundException} (client fault)
* <p>This exception is thrown when the trail with the given name is not found.</p>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ export interface GetInsightSelectorsCommandOutput extends GetInsightSelectorsRes
* @throws {@link OperationNotPermittedException} (client fault)
* <p>This exception is thrown when the requested operation is not permitted.</p>
*
* @throws {@link ThrottlingException} (client fault)
* <p>
* This exception is thrown when the request rate exceeds the limit.
* </p>
*
* @throws {@link TrailNotFoundException} (client fault)
* <p>This exception is thrown when the trail with the given name is not found.</p>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ export interface PutEventSelectorsCommandOutput extends PutEventSelectorsRespons
* @throws {@link OperationNotPermittedException} (client fault)
* <p>This exception is thrown when the requested operation is not permitted.</p>
*
* @throws {@link ThrottlingException} (client fault)
* <p>
* This exception is thrown when the request rate exceeds the limit.
* </p>
*
* @throws {@link TrailNotFoundException} (client fault)
* <p>This exception is thrown when the trail with the given name is not found.</p>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ export interface PutInsightSelectorsCommandOutput extends PutInsightSelectorsRes
* @throws {@link S3BucketDoesNotExistException} (client fault)
* <p>This exception is thrown when the specified S3 bucket does not exist.</p>
*
* @throws {@link ThrottlingException} (client fault)
* <p>
* This exception is thrown when the request rate exceeds the limit.
* </p>
*
* @throws {@link TrailNotFoundException} (client fault)
* <p>This exception is thrown when the trail with the given name is not found.</p>
*
Expand Down
5 changes: 5 additions & 0 deletions clients/client-cloudtrail/src/commands/StartLoggingCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ export interface StartLoggingCommandOutput extends StartLoggingResponse, __Metad
* @throws {@link OperationNotPermittedException} (client fault)
* <p>This exception is thrown when the requested operation is not permitted.</p>
*
* @throws {@link ThrottlingException} (client fault)
* <p>
* This exception is thrown when the request rate exceeds the limit.
* </p>
*
* @throws {@link TrailNotFoundException} (client fault)
* <p>This exception is thrown when the trail with the given name is not found.</p>
*
Expand Down
5 changes: 5 additions & 0 deletions clients/client-cloudtrail/src/commands/StopLoggingCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ export interface StopLoggingCommandOutput extends StopLoggingResponse, __Metadat
* @throws {@link OperationNotPermittedException} (client fault)
* <p>This exception is thrown when the requested operation is not permitted.</p>
*
* @throws {@link ThrottlingException} (client fault)
* <p>
* This exception is thrown when the request rate exceeds the limit.
* </p>
*
* @throws {@link TrailNotFoundException} (client fault)
* <p>This exception is thrown when the trail with the given name is not found.</p>
*
Expand Down
5 changes: 5 additions & 0 deletions clients/client-cloudtrail/src/commands/UpdateTrailCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ export interface UpdateTrailCommandOutput extends UpdateTrailResponse, __Metadat
* @throws {@link S3BucketDoesNotExistException} (client fault)
* <p>This exception is thrown when the specified S3 bucket does not exist.</p>
*
* @throws {@link ThrottlingException} (client fault)
* <p>
* This exception is thrown when the request rate exceeds the limit.
* </p>
*
* @throws {@link TrailNotFoundException} (client fault)
* <p>This exception is thrown when the trail with the given name is not found.</p>
*
Expand Down
28 changes: 28 additions & 0 deletions clients/client-cloudtrail/src/models/models_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2747,6 +2747,34 @@ export class S3BucketDoesNotExistException extends __BaseException {
}
}

/**
* @public
* <p>
* This exception is thrown when the request rate exceeds the limit.
* </p>
*/
export class ThrottlingException extends __BaseException {
readonly name: "ThrottlingException" = "ThrottlingException";
readonly $fault: "client" = "client";
/**
* @public
* <p>Brief description of the exception returned by the request.</p>
*/
Message?: string;
/**
* @internal
*/
constructor(opts: __ExceptionOptionType<ThrottlingException, __BaseException>) {
super({
name: "ThrottlingException",
$fault: "client",
...opts,
});
Object.setPrototypeOf(this, ThrottlingException.prototype);
this.Message = opts.Message;
}
}

/**
* @public
* <p>This exception is thrown when the specified trail already exists.</p>
Expand Down
40 changes: 40 additions & 0 deletions clients/client-cloudtrail/src/protocols/Aws_json1_1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ import {
StopLoggingRequest,
Tag,
TagsLimitExceededException,
ThrottlingException,
TrailAlreadyExistsException,
TrailNotFoundException,
TrailNotProvidedException,
Expand Down Expand Up @@ -1321,6 +1322,9 @@ const de_CreateTrailCommandError = async (
case "TagsLimitExceededException":
case "com.amazonaws.cloudtrail#TagsLimitExceededException":
throw await de_TagsLimitExceededExceptionRes(parsedOutput, context);
case "ThrottlingException":
case "com.amazonaws.cloudtrail#ThrottlingException":
throw await de_ThrottlingExceptionRes(parsedOutput, context);
case "TrailAlreadyExistsException":
case "com.amazonaws.cloudtrail#TrailAlreadyExistsException":
throw await de_TrailAlreadyExistsExceptionRes(parsedOutput, context);
Expand Down Expand Up @@ -1592,6 +1596,9 @@ const de_DeleteTrailCommandError = async (
case "OperationNotPermittedException":
case "com.amazonaws.cloudtrail#OperationNotPermittedException":
throw await de_OperationNotPermittedExceptionRes(parsedOutput, context);
case "ThrottlingException":
case "com.amazonaws.cloudtrail#ThrottlingException":
throw await de_ThrottlingExceptionRes(parsedOutput, context);
case "TrailNotFoundException":
case "com.amazonaws.cloudtrail#TrailNotFoundException":
throw await de_TrailNotFoundExceptionRes(parsedOutput, context);
Expand Down Expand Up @@ -2086,6 +2093,9 @@ const de_GetInsightSelectorsCommandError = async (
case "OperationNotPermittedException":
case "com.amazonaws.cloudtrail#OperationNotPermittedException":
throw await de_OperationNotPermittedExceptionRes(parsedOutput, context);
case "ThrottlingException":
case "com.amazonaws.cloudtrail#ThrottlingException":
throw await de_ThrottlingExceptionRes(parsedOutput, context);
case "TrailNotFoundException":
case "com.amazonaws.cloudtrail#TrailNotFoundException":
throw await de_TrailNotFoundExceptionRes(parsedOutput, context);
Expand Down Expand Up @@ -2958,6 +2968,9 @@ const de_PutEventSelectorsCommandError = async (
case "OperationNotPermittedException":
case "com.amazonaws.cloudtrail#OperationNotPermittedException":
throw await de_OperationNotPermittedExceptionRes(parsedOutput, context);
case "ThrottlingException":
case "com.amazonaws.cloudtrail#ThrottlingException":
throw await de_ThrottlingExceptionRes(parsedOutput, context);
case "TrailNotFoundException":
case "com.amazonaws.cloudtrail#TrailNotFoundException":
throw await de_TrailNotFoundExceptionRes(parsedOutput, context);
Expand Down Expand Up @@ -3040,6 +3053,9 @@ const de_PutInsightSelectorsCommandError = async (
case "S3BucketDoesNotExistException":
case "com.amazonaws.cloudtrail#S3BucketDoesNotExistException":
throw await de_S3BucketDoesNotExistExceptionRes(parsedOutput, context);
case "ThrottlingException":
case "com.amazonaws.cloudtrail#ThrottlingException":
throw await de_ThrottlingExceptionRes(parsedOutput, context);
case "TrailNotFoundException":
case "com.amazonaws.cloudtrail#TrailNotFoundException":
throw await de_TrailNotFoundExceptionRes(parsedOutput, context);
Expand Down Expand Up @@ -3575,6 +3591,9 @@ const de_StartLoggingCommandError = async (
case "OperationNotPermittedException":
case "com.amazonaws.cloudtrail#OperationNotPermittedException":
throw await de_OperationNotPermittedExceptionRes(parsedOutput, context);
case "ThrottlingException":
case "com.amazonaws.cloudtrail#ThrottlingException":
throw await de_ThrottlingExceptionRes(parsedOutput, context);
case "TrailNotFoundException":
case "com.amazonaws.cloudtrail#TrailNotFoundException":
throw await de_TrailNotFoundExceptionRes(parsedOutput, context);
Expand Down Expand Up @@ -3861,6 +3880,9 @@ const de_StopLoggingCommandError = async (
case "OperationNotPermittedException":
case "com.amazonaws.cloudtrail#OperationNotPermittedException":
throw await de_OperationNotPermittedExceptionRes(parsedOutput, context);
case "ThrottlingException":
case "com.amazonaws.cloudtrail#ThrottlingException":
throw await de_ThrottlingExceptionRes(parsedOutput, context);
case "TrailNotFoundException":
case "com.amazonaws.cloudtrail#TrailNotFoundException":
throw await de_TrailNotFoundExceptionRes(parsedOutput, context);
Expand Down Expand Up @@ -4170,6 +4192,9 @@ const de_UpdateTrailCommandError = async (
case "S3BucketDoesNotExistException":
case "com.amazonaws.cloudtrail#S3BucketDoesNotExistException":
throw await de_S3BucketDoesNotExistExceptionRes(parsedOutput, context);
case "ThrottlingException":
case "com.amazonaws.cloudtrail#ThrottlingException":
throw await de_ThrottlingExceptionRes(parsedOutput, context);
case "TrailNotFoundException":
case "com.amazonaws.cloudtrail#TrailNotFoundException":
throw await de_TrailNotFoundExceptionRes(parsedOutput, context);
Expand Down Expand Up @@ -5383,6 +5408,19 @@ const de_TagsLimitExceededExceptionRes = async (
return __decorateServiceException(exception, body);
};

/**
* deserializeAws_json1_1ThrottlingExceptionRes
*/
const de_ThrottlingExceptionRes = async (parsedOutput: any, context: __SerdeContext): Promise<ThrottlingException> => {
const body = parsedOutput.body;
const deserialized: any = _json(body);
const exception = new ThrottlingException({
$metadata: deserializeMetadata(parsedOutput),
...deserialized,
});
return __decorateServiceException(exception, body);
};

/**
* deserializeAws_json1_1TrailAlreadyExistsExceptionRes
*/
Expand Down Expand Up @@ -6307,6 +6345,8 @@ const de_StopImportResponse = (output: any, context: __SerdeContext): StopImport

// de_TagsList omitted.

// de_ThrottlingException omitted.

// de_Trail omitted.

// de_TrailAlreadyExistsException omitted.
Expand Down
44 changes: 44 additions & 0 deletions codegen/sdk-codegen/aws-models/cloudtrail.json
Original file line number Diff line number Diff line change
Expand Up @@ -2272,6 +2272,9 @@
{
"target": "com.amazonaws.cloudtrail#TagsLimitExceededException"
},
{
"target": "com.amazonaws.cloudtrail#ThrottlingException"
},
{
"target": "com.amazonaws.cloudtrail#TrailAlreadyExistsException"
},
Expand Down Expand Up @@ -2718,6 +2721,9 @@
{
"target": "com.amazonaws.cloudtrail#OperationNotPermittedException"
},
{
"target": "com.amazonaws.cloudtrail#ThrottlingException"
},
{
"target": "com.amazonaws.cloudtrail#TrailNotFoundException"
},
Expand Down Expand Up @@ -3958,6 +3964,9 @@
{
"target": "com.amazonaws.cloudtrail#OperationNotPermittedException"
},
{
"target": "com.amazonaws.cloudtrail#ThrottlingException"
},
{
"target": "com.amazonaws.cloudtrail#TrailNotFoundException"
},
Expand Down Expand Up @@ -6649,6 +6658,9 @@
{
"target": "com.amazonaws.cloudtrail#OperationNotPermittedException"
},
{
"target": "com.amazonaws.cloudtrail#ThrottlingException"
},
{
"target": "com.amazonaws.cloudtrail#TrailNotFoundException"
},
Expand Down Expand Up @@ -6756,6 +6768,9 @@
{
"target": "com.amazonaws.cloudtrail#S3BucketDoesNotExistException"
},
{
"target": "com.amazonaws.cloudtrail#ThrottlingException"
},
{
"target": "com.amazonaws.cloudtrail#TrailNotFoundException"
},
Expand Down Expand Up @@ -7973,6 +7988,9 @@
{
"target": "com.amazonaws.cloudtrail#OperationNotPermittedException"
},
{
"target": "com.amazonaws.cloudtrail#ThrottlingException"
},
{
"target": "com.amazonaws.cloudtrail#TrailNotFoundException"
},
Expand Down Expand Up @@ -8314,6 +8332,9 @@
{
"target": "com.amazonaws.cloudtrail#OperationNotPermittedException"
},
{
"target": "com.amazonaws.cloudtrail#ThrottlingException"
},
{
"target": "com.amazonaws.cloudtrail#TrailNotFoundException"
},
Expand Down Expand Up @@ -8428,6 +8449,26 @@
"com.amazonaws.cloudtrail#TerminationProtectionEnabled": {
"type": "boolean"
},
"com.amazonaws.cloudtrail#ThrottlingException": {
"type": "structure",
"members": {
"Message": {
"target": "com.amazonaws.cloudtrail#ErrorMessage",
"traits": {
"smithy.api#documentation": "<p>Brief description of the exception returned by the request.</p>"
}
}
},
"traits": {
"aws.protocols#awsQueryError": {
"code": "ThrottlingException",
"httpResponseCode": 429
},
"smithy.api#documentation": "<p>\n This exception is thrown when the request rate exceeds the limit. \n </p>",
"smithy.api#error": "client",
"smithy.api#httpError": 429
}
},
"com.amazonaws.cloudtrail#Trail": {
"type": "structure",
"members": {
Expand Down Expand Up @@ -9070,6 +9111,9 @@
{
"target": "com.amazonaws.cloudtrail#S3BucketDoesNotExistException"
},
{
"target": "com.amazonaws.cloudtrail#ThrottlingException"
},
{
"target": "com.amazonaws.cloudtrail#TrailNotFoundException"
},
Expand Down

0 comments on commit e7333b8

Please sign in to comment.