Skip to content

Commit

Permalink
feat(scheduler): fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
sakurai-ryo committed Dec 8, 2023
1 parent ba4630b commit 540561c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-scheduler-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,18 @@ const schedule = new Schedule(this, 'Schedule', {

> Visit [Data protection in Amazon EventBridge Scheduler](https://docs.aws.amazon.com/scheduler/latest/UserGuide/data-protection.html) for more details.
## Configuring flexible time window
## Configuring flexible time windows

You can configure flexible time windows by specifying the `flexibleTimeWindow` property.
By default, the mode of `flexibleTimeWindow` is set to `OFF` and this feature is disabled.
Flexible time windows is disabled by default.

```ts
declare const target: targets.LambdaInvoke;

const schedule = new Schedule(this, 'Schedule', {
schedule: ScheduleExpression.rate(Duration.hours(12)),
target,
flexibleTimeWindow: FlexibleTimeWindowMode.Flexible(Duration.hours(10)),
flexibleTimeWindow: FlexibleTimeWindowMode.flexible(Duration.hours(10)),
});
```

Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-scheduler-alpha/lib/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ export class FlexibleTimeWindowMode {
/**
* FlexibleTimeWindow is disabled.
*/
public static Off(): FlexibleTimeWindowMode {
public static off(): FlexibleTimeWindowMode {
return new FlexibleTimeWindowMode('OFF');
}

/**
* FlexibleTimeWindow is enabled.
*/
public static Flexible(maximumWindowInMinutes: Duration): FlexibleTimeWindowMode {
public static flexible(maximumWindowInMinutes: Duration): FlexibleTimeWindowMode {
if (maximumWindowInMinutes.toMinutes() < 1 || maximumWindowInMinutes.toMinutes() > 1440) {
throw new Error(`maximumWindowInMinutes must be between 1 and 1440, got ${maximumWindowInMinutes.toMinutes()}`);
}
Expand Down Expand Up @@ -162,7 +162,7 @@ export interface ScheduleProps {
*
* @see https://docs.aws.amazon.com/scheduler/latest/UserGuide/managing-schedule-flexible-time-windows.html
*
* @default FlexibleTimeWindowMode.Off()
* @default FlexibleTimeWindowMode.off()
*/
readonly flexibleTimeWindow?: FlexibleTimeWindowMode;
}
Expand Down Expand Up @@ -305,7 +305,7 @@ export class Schedule extends Resource implements ISchedule {

this.retryPolicy = targetConfig.retryPolicy;

const flexibleTimeWindow = props.flexibleTimeWindow ?? FlexibleTimeWindowMode.Off();
const flexibleTimeWindow = props.flexibleTimeWindow ?? FlexibleTimeWindowMode.off();

const resource = new CfnSchedule(this, 'Resource', {
name: this.physicalName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ new scheduler.Schedule(stack, 'CustomerKmsSchedule', {
new scheduler.Schedule(stack, 'UseFlexibleTimeWindow', {
schedule: expression,
target: target,
flexibleTimeWindow: scheduler.FlexibleTimeWindowMode.Flexible(cdk.Duration.minutes(10)),
flexibleTimeWindow: scheduler.FlexibleTimeWindowMode.flexible(cdk.Duration.minutes(10)),
});

new IntegTest(app, 'integtest-schedule', {
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-scheduler-alpha/test/schedule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ describe('Schedule', () => {
new Schedule(stack, 'TestSchedule', {
schedule: expr,
target: new SomeLambdaTarget(func, role),
flexibleTimeWindow: FlexibleTimeWindowMode.Flexible(Duration.minutes(1440)),
flexibleTimeWindow: FlexibleTimeWindowMode.flexible(Duration.minutes(1440)),
});

// THEN
Expand All @@ -167,7 +167,7 @@ describe('Schedule', () => {
new Schedule(stack, 'TestSchedule', {
schedule: expr,
target: new SomeLambdaTarget(func, role),
flexibleTimeWindow: FlexibleTimeWindowMode.Flexible(Duration.minutes(1441)),
flexibleTimeWindow: FlexibleTimeWindowMode.flexible(Duration.minutes(1441)),
});
}).toThrow('maximumWindowInMinutes must be between 1 and 1440, got 1441');
});
Expand All @@ -177,7 +177,7 @@ describe('Schedule', () => {
new Schedule(stack, 'TestSchedule', {
schedule: expr,
target: new SomeLambdaTarget(func, role),
flexibleTimeWindow: FlexibleTimeWindowMode.Flexible(Duration.minutes(0)),
flexibleTimeWindow: FlexibleTimeWindowMode.flexible(Duration.minutes(0)),
});
}).toThrow('maximumWindowInMinutes must be between 1 and 1440, got 0');
});
Expand Down

0 comments on commit 540561c

Please sign in to comment.