Skip to content

Commit

Permalink
Support transformation of waiter configuration (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr authored Feb 22, 2023
1 parent b264bbc commit 2d477e0
Show file tree
Hide file tree
Showing 24 changed files with 471 additions and 51 deletions.
5 changes: 5 additions & 0 deletions .changeset/eighty-lemons-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"aws-sdk-js-codemod": patch
---

Support transformation of waiter configuration
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@ const client = new AWS.S3({ region: "REGION" });

await client.waitFor("bucketNotExists", { Bucket }).promise();
await client.createBucket({ Bucket }).promise();
await client.waitFor("bucketExists", { Bucket }).promise();
await client.waitFor("bucketExists", { Bucket }).promise();

// Waiter configuration: delay
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2 } }).promise();

// Waiter configuration: maxAttempts
await client.waitFor("bucketExists", { Bucket, $waiter: { maxAttempts: 5 } }).promise();

// Waiter configuration: delay+maxAttempts
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2, maxAttempts: 5 } }).promise();
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,36 @@ const client = new S3({ region: "REGION" });

await waitUntilBucketNotExists({
client,
maxWaitTime: 180
maxWaitTime: 200
}, { Bucket });
await client.createBucket({ Bucket });
await waitUntilBucketExists({
client,
maxWaitTime: 180
}, { Bucket });
maxWaitTime: 200
}, { Bucket });

// Waiter configuration: delay
await waitUntilBucketExists({
client,
minDelay: 2,
maxWaitTime: 40
}, {
Bucket
});

// Waiter configuration: maxAttempts
await waitUntilBucketExists({
client,
maxWaitTime: 100
}, {
Bucket
});

// Waiter configuration: delay+maxAttempts
await waitUntilBucketExists({
client,
minDelay: 2,
maxWaitTime: 20
}, {
Bucket
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@ const client = new AWS.S3({ region: "REGION" });

await client.waitFor("bucketNotExists", { Bucket }).promise();
await client.createBucket({ Bucket }).promise();
await client.waitFor("bucketExists", { Bucket }).promise();
await client.waitFor("bucketExists", { Bucket }).promise();

// Waiter configuration: delay
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2 } }).promise();

// Waiter configuration: maxAttempts
await client.waitFor("bucketExists", { Bucket, $waiter: { maxAttempts: 5 } }).promise();

// Waiter configuration: delay+maxAttempts
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2, maxAttempts: 5 } }).promise();
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,36 @@ const client = new S3({ region: "REGION" });

await waitUntilBucketNotExists({
client,
maxWaitTime: 180
maxWaitTime: 200
}, { Bucket });
await client.createBucket({ Bucket });
await waitUntilBucketExists({
client,
maxWaitTime: 180
}, { Bucket });
maxWaitTime: 200
}, { Bucket });

// Waiter configuration: delay
await waitUntilBucketExists({
client,
minDelay: 2,
maxWaitTime: 40
}, {
Bucket
});

// Waiter configuration: maxAttempts
await waitUntilBucketExists({
client,
maxWaitTime: 100
}, {
Bucket
});

// Waiter configuration: delay+maxAttempts
await waitUntilBucketExists({
client,
minDelay: 2,
maxWaitTime: 20
}, {
Bucket
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@ const client = new S3({ region: "REGION" });

await client.waitFor("bucketNotExists", { Bucket }).promise();
await client.createBucket({ Bucket }).promise();
await client.waitFor("bucketExists", { Bucket }).promise();
await client.waitFor("bucketExists", { Bucket }).promise();

// Waiter configuration: delay
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2 } }).promise();

// Waiter configuration: maxAttempts
await client.waitFor("bucketExists", { Bucket, $waiter: { maxAttempts: 5 } }).promise();

// Waiter configuration: delay+maxAttempts
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2, maxAttempts: 5 } }).promise();
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,36 @@ const client = new S3({ region: "REGION" });

await waitUntilBucketNotExists({
client,
maxWaitTime: 180
maxWaitTime: 200
}, { Bucket });
await client.createBucket({ Bucket });
await waitUntilBucketExists({
client,
maxWaitTime: 180
}, { Bucket });
maxWaitTime: 200
}, { Bucket });

// Waiter configuration: delay
await waitUntilBucketExists({
client,
minDelay: 2,
maxWaitTime: 40
}, {
Bucket
});

// Waiter configuration: maxAttempts
await waitUntilBucketExists({
client,
maxWaitTime: 100
}, {
Bucket
});

// Waiter configuration: delay+maxAttempts
await waitUntilBucketExists({
client,
minDelay: 2,
maxWaitTime: 20
}, {
Bucket
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@ const client = new AWS.S3({ region: "REGION" });

await client.waitFor("bucketNotExists", { Bucket }).promise();
await client.createBucket({ Bucket }).promise();
await client.waitFor("bucketExists", { Bucket }).promise();
await client.waitFor("bucketExists", { Bucket }).promise();

// Waiter configuration: delay
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2 } }).promise();

// Waiter configuration: maxAttempts
await client.waitFor("bucketExists", { Bucket, $waiter: { maxAttempts: 5 } }).promise();

// Waiter configuration: delay+maxAttempts
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2, maxAttempts: 5 } }).promise();
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,36 @@ const client = new S3({ region: "REGION" });

await waitUntilBucketNotExists({
client,
maxWaitTime: 180
maxWaitTime: 200
}, { Bucket });
await client.createBucket({ Bucket });
await waitUntilBucketExists({
client,
maxWaitTime: 180
}, { Bucket });
maxWaitTime: 200
}, { Bucket });

// Waiter configuration: delay
await waitUntilBucketExists({
client,
minDelay: 2,
maxWaitTime: 40
}, {
Bucket
});

// Waiter configuration: maxAttempts
await waitUntilBucketExists({
client,
maxWaitTime: 100
}, {
Bucket
});

// Waiter configuration: delay+maxAttempts
await waitUntilBucketExists({
client,
minDelay: 2,
maxWaitTime: 20
}, {
Bucket
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@ const client = new S3({ region: "REGION" });

await client.waitFor("bucketNotExists", { Bucket }).promise();
await client.createBucket({ Bucket }).promise();
await client.waitFor("bucketExists", { Bucket }).promise();
await client.waitFor("bucketExists", { Bucket }).promise();

// Waiter configuration: delay
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2 } }).promise();

// Waiter configuration: maxAttempts
await client.waitFor("bucketExists", { Bucket, $waiter: { maxAttempts: 5 } }).promise();

// Waiter configuration: delay+maxAttempts
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2, maxAttempts: 5 } }).promise();
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,36 @@ const client = new S3({ region: "REGION" });

await waitUntilBucketNotExists({
client,
maxWaitTime: 180
maxWaitTime: 200
}, { Bucket });
await client.createBucket({ Bucket });
await waitUntilBucketExists({
client,
maxWaitTime: 180
}, { Bucket });
maxWaitTime: 200
}, { Bucket });

// Waiter configuration: delay
await waitUntilBucketExists({
client,
minDelay: 2,
maxWaitTime: 40
}, {
Bucket
});

// Waiter configuration: maxAttempts
await waitUntilBucketExists({
client,
maxWaitTime: 100
}, {
Bucket
});

// Waiter configuration: delay+maxAttempts
await waitUntilBucketExists({
client,
minDelay: 2,
maxWaitTime: 20
}, {
Bucket
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@ const client = new S3({ region: "REGION" });

await client.waitFor("bucketNotExists", { Bucket }).promise();
await client.createBucket({ Bucket }).promise();
await client.waitFor("bucketExists", { Bucket }).promise();
await client.waitFor("bucketExists", { Bucket }).promise();

// Waiter configuration: delay
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2 } }).promise();

// Waiter configuration: maxAttempts
await client.waitFor("bucketExists", { Bucket, $waiter: { maxAttempts: 5 } }).promise();

// Waiter configuration: delay+maxAttempts
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2, maxAttempts: 5 } }).promise();
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,36 @@ const client = new S3({ region: "REGION" });

await waitUntilBucketNotExists({
client,
maxWaitTime: 180
maxWaitTime: 200
}, { Bucket });
await client.createBucket({ Bucket });
await waitUntilBucketExists({
client,
maxWaitTime: 180
}, { Bucket });
maxWaitTime: 200
}, { Bucket });

// Waiter configuration: delay
await waitUntilBucketExists({
client,
minDelay: 2,
maxWaitTime: 40
}, {
Bucket
});

// Waiter configuration: maxAttempts
await waitUntilBucketExists({
client,
maxWaitTime: 100
}, {
Bucket
});

// Waiter configuration: delay+maxAttempts
await waitUntilBucketExists({
client,
minDelay: 2,
maxWaitTime: 20
}, {
Bucket
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@ const client = new S3({ region: "REGION" });

await client.waitFor("bucketNotExists", { Bucket }).promise();
await client.createBucket({ Bucket }).promise();
await client.waitFor("bucketExists", { Bucket }).promise();
await client.waitFor("bucketExists", { Bucket }).promise();

// Waiter configuration: delay
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2 } }).promise();

// Waiter configuration: maxAttempts
await client.waitFor("bucketExists", { Bucket, $waiter: { maxAttempts: 5 } }).promise();

// Waiter configuration: delay+maxAttempts
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2, maxAttempts: 5 } }).promise();
Loading

0 comments on commit 2d477e0

Please sign in to comment.