From e4cccde0db2ab0da5c66faa6b275eee43082ffb1 Mon Sep 17 00:00:00 2001 From: Luca Pizzini Date: Tue, 24 Oct 2023 10:20:02 +0200 Subject: [PATCH] variables renaming and documentation cleanup --- .../@aws-cdk/aws-scheduler-alpha/README.md | 6 ++-- .../aws-scheduler-alpha/lib/schedule.ts | 32 +++---------------- .../test/integ.schedule.ts | 4 +-- .../test/retry-policy.test.ts | 20 ++++++------ .../schema/cloud-assembly.version.json | 2 +- 5 files changed, 21 insertions(+), 43 deletions(-) diff --git a/packages/@aws-cdk/aws-scheduler-alpha/README.md b/packages/@aws-cdk/aws-scheduler-alpha/README.md index 03f19413b891a..1a3d19bd5da34 100644 --- a/packages/@aws-cdk/aws-scheduler-alpha/README.md +++ b/packages/@aws-cdk/aws-scheduler-alpha/README.md @@ -257,7 +257,7 @@ const target = new targets.LambdaInvoke(fn, { ## Overriding Target Properties If you wish to reuse the same target in multiple schedules, you can override target properties like `input`, -`maximumRetryAttempts` and `maximumEventAge` when creating a Schedule using the `targetOverrides` parameter: +`maximumRetryAttempts` and `maximumEventAgeInSeconds` when creating a Schedule using the `targetOverrides` parameter: ```ts declare const target: targets.LambdaInvoke; @@ -267,8 +267,8 @@ const oneTimeSchedule = new Schedule(this, 'Schedule', { target, targetOverrides: { input: ScheduleTargetInput.fromText("Overriding Target Input"), - maximumEventAge: Duration.seconds(180), - maximumRetryAttempts: 5, + maxEventAge: Duration.seconds(180), + retryAttempts: 5, }, }); ``` diff --git a/packages/@aws-cdk/aws-scheduler-alpha/lib/schedule.ts b/packages/@aws-cdk/aws-scheduler-alpha/lib/schedule.ts index 34eefa29fad97..7a946bce71c20 100644 --- a/packages/@aws-cdk/aws-scheduler-alpha/lib/schedule.ts +++ b/packages/@aws-cdk/aws-scheduler-alpha/lib/schedule.ts @@ -43,42 +43,20 @@ export interface ScheduleTargetProps { * @default - The target's input is used. */ readonly input?: ScheduleTargetInput; - /** - * The maximum amount of time, in seconds, to continue to make retry attempts. - * - * @default - The target's maximumEventAgeInSeconds is used. - */ - readonly maximumEventAge?: Duration; - /** - * The maximum number of retry attempts to make before the request fails. - * - * @default - The target's maximumRetryAttempts is used. - */ - readonly maximumRetryAttempts?: number; -} -export interface ScheduleTargetProps { - /** - * The text, or well-formed JSON, passed to the target. - * - * If you are configuring a templated Lambda, AWS Step Functions, or Amazon EventBridge target, - * the input must be a well-formed JSON. For all other target types, a JSON is not required. - * - * @default - The target's input is used. - */ - readonly input?: ScheduleTargetInput; /** * The maximum amount of time, in seconds, to continue to make retry attempts. * * @default - The target's maximumEventAgeInSeconds is used. */ - readonly maximumEventAge?: Duration; + readonly maxEventAge?: Duration; + /** * The maximum number of retry attempts to make before the request fails. * * @default - The target's maximumRetryAttempts is used. */ - readonly maximumRetryAttempts?: number; + readonly retryAttempts?: number; } /** @@ -268,8 +246,8 @@ export class Schedule extends Resource implements ISchedule { } const retryPolicy = { - maximumEventAgeInSeconds: props.targetOverrides?.maximumEventAge?.toSeconds() ?? targetConfig.retryPolicy?.maximumEventAgeInSeconds, - maximumRetryAttempts: props.targetOverrides?.maximumRetryAttempts ?? targetConfig.retryPolicy?.maximumRetryAttempts, + maximumEventAgeInSeconds: props.targetOverrides?.maxEventAge?.toSeconds() ?? targetConfig.retryPolicy?.maximumEventAgeInSeconds, + maximumRetryAttempts: props.targetOverrides?.retryAttempts ?? targetConfig.retryPolicy?.maximumRetryAttempts, }; this.validateRetryPolicy(retryPolicy.maximumEventAgeInSeconds, retryPolicy.maximumRetryAttempts); diff --git a/packages/@aws-cdk/aws-scheduler-alpha/test/integ.schedule.ts b/packages/@aws-cdk/aws-scheduler-alpha/test/integ.schedule.ts index 6ced46d6a239f..11284409a7930 100644 --- a/packages/@aws-cdk/aws-scheduler-alpha/test/integ.schedule.ts +++ b/packages/@aws-cdk/aws-scheduler-alpha/test/integ.schedule.ts @@ -55,8 +55,8 @@ new scheduler.Schedule(stack, 'TargetOverrideSchedule', { target: target, targetOverrides: { input: scheduler.ScheduleTargetInput.fromText('Changed Text'), - maximumEventAge: cdk.Duration.seconds(360), - maximumRetryAttempts: 5, + maxEventAge: cdk.Duration.seconds(360), + retryAttempts: 5, }, }); diff --git a/packages/@aws-cdk/aws-scheduler-alpha/test/retry-policy.test.ts b/packages/@aws-cdk/aws-scheduler-alpha/test/retry-policy.test.ts index 82d536bceeab4..99b462169a64b 100644 --- a/packages/@aws-cdk/aws-scheduler-alpha/test/retry-policy.test.ts +++ b/packages/@aws-cdk/aws-scheduler-alpha/test/retry-policy.test.ts @@ -61,8 +61,8 @@ describe('schedule target retry policy', () => { schedule: expr, target: new SomeLambdaTarget(func), targetOverrides: { - maximumEventAge: Duration.seconds(120), - maximumRetryAttempts: 5, + maxEventAge: Duration.seconds(120), + retryAttempts: 5, }, enabled: false, }); @@ -86,8 +86,8 @@ describe('schedule target retry policy', () => { schedule: expr, target: new SomeLambdaTarget(func), targetOverrides: { - maximumEventAge: Duration.seconds(50), - maximumRetryAttempts: 5, + maxEventAge: Duration.seconds(50), + retryAttempts: 5, }, enabled: false, }); @@ -100,8 +100,8 @@ describe('schedule target retry policy', () => { schedule: expr, target: new SomeLambdaTarget(func), targetOverrides: { - maximumEventAge: Duration.seconds(100000), - maximumRetryAttempts: 5, + maxEventAge: Duration.seconds(100000), + retryAttempts: 5, }, enabled: false, }); @@ -114,8 +114,8 @@ describe('schedule target retry policy', () => { schedule: expr, target: new SomeLambdaTarget(func), targetOverrides: { - maximumEventAge: Duration.seconds(120), - maximumRetryAttempts: -1, + maxEventAge: Duration.seconds(120), + retryAttempts: -1, }, enabled: false, }); @@ -128,8 +128,8 @@ describe('schedule target retry policy', () => { schedule: expr, target: new SomeLambdaTarget(func), targetOverrides: { - maximumEventAge: Duration.seconds(120), - maximumRetryAttempts: 200, + maxEventAge: Duration.seconds(120), + retryAttempts: 200, }, enabled: false, }); diff --git a/packages/aws-cdk-lib/cloud-assembly-schema/schema/cloud-assembly.version.json b/packages/aws-cdk-lib/cloud-assembly-schema/schema/cloud-assembly.version.json index 2313ab5436501..560dae10d018f 100644 --- a/packages/aws-cdk-lib/cloud-assembly-schema/schema/cloud-assembly.version.json +++ b/packages/aws-cdk-lib/cloud-assembly-schema/schema/cloud-assembly.version.json @@ -1 +1 @@ -{"version":"34.0.0"} \ No newline at end of file +{"version":"33.0.0"} \ No newline at end of file