Skip to content

Commit

Permalink
Use groupName
Browse files Browse the repository at this point in the history
  • Loading branch information
razor-x committed Jun 9, 2024
1 parent e2eb2fc commit d7f93bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
18 changes: 11 additions & 7 deletions examples/schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import { SchedulerClient } from '../index.js'

export const createSchedule =
({ log }) =>
async (scheduleName, arn, roleArn) => {
async (scheduleName, groupName, arn, roleArn) => {
const client = new SchedulerClient({
log
})
return client.createSchedule(scheduleName, {
scheduleExpression: 'rate(1 minute)',
flexibleTimeWindow: { mode: 'OFF' },
input: { foo: 'bar' },
groupName,
target: {
arn,
roleArn,
Expand All @@ -23,27 +24,30 @@ export const createSchedule =

export const deleteSchedule =
({ log }) =>
async (scheduleName) => {
async (scheduleName, groupName) => {
const client = new SchedulerClient({
log
})
return client.deleteSchedule(scheduleName)
return client.deleteSchedule(scheduleName, { groupName })
}

export const updateSchedule =
({ log }) =>
async (scheduleName) => {
async (scheduleName, groupName) => {
const client = new SchedulerClient({
log
})
return client.updateSchedule(scheduleName, {})
return client.updateSchedule(scheduleName, {
scheduleExpression: 'rate(2 minute)',
groupName
})
}

export const getSchedule =
({ log }) =>
async (scheduleName) => {
async (scheduleName, groupName) => {
const client = new SchedulerClient({
log
})
return client.getSchedule(scheduleName)
return client.getSchedule(scheduleName, { groupName })
}
6 changes: 4 additions & 2 deletions lib/clients/scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class SchedulerClient {
})
try {
log.info('start')
const req = formatReq({ name: scheduleName })
const req = formatReq({ ...params, name: scheduleName })
const command = new DeleteScheduleCommand(req)

const res = await this.#client.send(command)
Expand All @@ -125,7 +125,9 @@ export class SchedulerClient {
})
try {
log.info('start')
const schedule = await this.getSchedule(scheduleName)
const schedule = await this.getSchedule(scheduleName, {
groupName: params.groupName
})

const req = formatReq({ ...schedule, ...params, name: scheduleName })
const command = new UpdateScheduleCommand(req)
Expand Down

0 comments on commit d7f93bf

Please sign in to comment.