From 02c9f1aaf549d582d607d44b9974dfa3f3dcdbf4 Mon Sep 17 00:00:00 2001 From: Pat Patterson Date: Mon, 11 Dec 2023 13:48:08 -0800 Subject: [PATCH] Add S3 ListBuckets operation --- plugins/s3/readme.md | 9 ++++++++- plugins/s3/src/incomplete.mjs | 2 +- plugins/s3/src/index.mjs | 15 ++++++++++++++- plugins/s3/types/index.d.ts | 3 +++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/plugins/s3/readme.md b/plugins/s3/readme.md index 229df558..7d17d623 100644 --- a/plugins/s3/readme.md +++ b/plugins/s3/readme.md @@ -112,6 +112,14 @@ Properties: - Sets request header: `x-amz-checksum-mode` +### `ListBuckets` + +[Canonical AWS API doc](https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBuckets.html) + +Properties: + + + ### `ListObjectsV2` [Canonical AWS API doc](https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html) @@ -285,7 +293,6 @@ Properties: - `ListBucketIntelligentTieringConfigurations` - `ListBucketInventoryConfigurations` - `ListBucketMetricsConfigurations` -- `ListBuckets` - `ListMultipartUploads` - `ListObjects` - `ListObjectVersions` diff --git a/plugins/s3/src/incomplete.mjs b/plugins/s3/src/incomplete.mjs index 7b76d9bc..fe2895cc 100644 --- a/plugins/s3/src/incomplete.mjs +++ b/plugins/s3/src/incomplete.mjs @@ -1,2 +1,2 @@ const x = false -export default { AbortMultipartUpload: x, CompleteMultipartUpload: x, CopyObject: x, CreateBucket: x, CreateMultipartUpload: x, DeleteBucket: x, DeleteBucketAnalyticsConfiguration: x, DeleteBucketCors: x, DeleteBucketEncryption: x, DeleteBucketIntelligentTieringConfiguration: x, DeleteBucketInventoryConfiguration: x, DeleteBucketLifecycle: x, DeleteBucketMetricsConfiguration: x, DeleteBucketOwnershipControls: x, DeleteBucketPolicy: x, DeleteBucketReplication: x, DeleteBucketTagging: x, DeleteBucketWebsite: x, DeleteObject: x, DeleteObjects: x, DeleteObjectTagging: x, DeletePublicAccessBlock: x, GetBucketAccelerateConfiguration: x, GetBucketAcl: x, GetBucketAnalyticsConfiguration: x, GetBucketCors: x, GetBucketEncryption: x, GetBucketIntelligentTieringConfiguration: x, GetBucketInventoryConfiguration: x, GetBucketLifecycle: x, GetBucketLifecycleConfiguration: x, GetBucketLocation: x, GetBucketLogging: x, GetBucketMetricsConfiguration: x, GetBucketNotification: x, GetBucketNotificationConfiguration: x, GetBucketOwnershipControls: x, GetBucketPolicy: x, GetBucketPolicyStatus: x, GetBucketReplication: x, GetBucketRequestPayment: x, GetBucketTagging: x, GetBucketVersioning: x, GetBucketWebsite: x, GetObjectAcl: x, GetObjectAttributes: x, GetObjectLegalHold: x, GetObjectLockConfiguration: x, GetObjectRetention: x, GetObjectTagging: x, GetObjectTorrent: x, GetPublicAccessBlock: x, HeadBucket: x, ListBucketAnalyticsConfigurations: x, ListBucketIntelligentTieringConfigurations: x, ListBucketInventoryConfigurations: x, ListBucketMetricsConfigurations: x, ListBuckets: x, ListMultipartUploads: x, ListObjects: x, ListObjectVersions: x, ListParts: x, PutBucketAccelerateConfiguration: x, PutBucketAcl: x, PutBucketAnalyticsConfiguration: x, PutBucketCors: x, PutBucketEncryption: x, PutBucketIntelligentTieringConfiguration: x, PutBucketInventoryConfiguration: x, PutBucketLifecycle: x, PutBucketLifecycleConfiguration: x, PutBucketLogging: x, PutBucketMetricsConfiguration: x, PutBucketNotification: x, PutBucketNotificationConfiguration: x, PutBucketOwnershipControls: x, PutBucketPolicy: x, PutBucketReplication: x, PutBucketRequestPayment: x, PutBucketTagging: x, PutBucketVersioning: x, PutBucketWebsite: x, PutObjectAcl: x, PutObjectLegalHold: x, PutObjectLockConfiguration: x, PutObjectRetention: x, PutObjectTagging: x, PutPublicAccessBlock: x, RestoreObject: x, SelectObjectContent: x, UploadPart: x, UploadPartCopy: x, WriteGetObjectResponse: x } +export default { AbortMultipartUpload: x, CompleteMultipartUpload: x, CopyObject: x, CreateBucket: x, CreateMultipartUpload: x, DeleteBucket: x, DeleteBucketAnalyticsConfiguration: x, DeleteBucketCors: x, DeleteBucketEncryption: x, DeleteBucketIntelligentTieringConfiguration: x, DeleteBucketInventoryConfiguration: x, DeleteBucketLifecycle: x, DeleteBucketMetricsConfiguration: x, DeleteBucketOwnershipControls: x, DeleteBucketPolicy: x, DeleteBucketReplication: x, DeleteBucketTagging: x, DeleteBucketWebsite: x, DeleteObject: x, DeleteObjects: x, DeleteObjectTagging: x, DeletePublicAccessBlock: x, GetBucketAccelerateConfiguration: x, GetBucketAcl: x, GetBucketAnalyticsConfiguration: x, GetBucketCors: x, GetBucketEncryption: x, GetBucketIntelligentTieringConfiguration: x, GetBucketInventoryConfiguration: x, GetBucketLifecycle: x, GetBucketLifecycleConfiguration: x, GetBucketLocation: x, GetBucketLogging: x, GetBucketMetricsConfiguration: x, GetBucketNotification: x, GetBucketNotificationConfiguration: x, GetBucketOwnershipControls: x, GetBucketPolicy: x, GetBucketPolicyStatus: x, GetBucketReplication: x, GetBucketRequestPayment: x, GetBucketTagging: x, GetBucketVersioning: x, GetBucketWebsite: x, GetObjectAcl: x, GetObjectAttributes: x, GetObjectLegalHold: x, GetObjectLockConfiguration: x, GetObjectRetention: x, GetObjectTagging: x, GetObjectTorrent: x, GetPublicAccessBlock: x, HeadBucket: x, ListBucketAnalyticsConfigurations: x, ListBucketIntelligentTieringConfigurations: x, ListBucketInventoryConfigurations: x, ListBucketMetricsConfigurations: x, ListMultipartUploads: x, ListObjects: x, ListObjectVersions: x, ListParts: x, PutBucketAccelerateConfiguration: x, PutBucketAcl: x, PutBucketAnalyticsConfiguration: x, PutBucketCors: x, PutBucketEncryption: x, PutBucketIntelligentTieringConfiguration: x, PutBucketInventoryConfiguration: x, PutBucketLifecycle: x, PutBucketLifecycleConfiguration: x, PutBucketLogging: x, PutBucketMetricsConfiguration: x, PutBucketNotification: x, PutBucketNotificationConfiguration: x, PutBucketOwnershipControls: x, PutBucketPolicy: x, PutBucketReplication: x, PutBucketRequestPayment: x, PutBucketTagging: x, PutBucketVersioning: x, PutBucketWebsite: x, PutObjectAcl: x, PutObjectLegalHold: x, PutObjectLockConfiguration: x, PutObjectRetention: x, PutObjectTagging: x, PutPublicAccessBlock: x, RestoreObject: x, SelectObjectContent: x, UploadPart: x, UploadPartCopy: x, WriteGetObjectResponse: x } diff --git a/plugins/s3/src/index.mjs b/plugins/s3/src/index.mjs index baa7b931..5237bb59 100644 --- a/plugins/s3/src/index.mjs +++ b/plugins/s3/src/index.mjs @@ -77,6 +77,19 @@ const HeadObject = { response: parseHeadersToResults, } +const ListBuckets = { + awsDoc: 'https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBuckets.html', + validate: {}, + request: async () => { + return { + endpoint: '/', + } + }, + response: async ({ payload }) => { + return payload + }, +} + const ListObjectsV2 = { awsDoc: 'https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html', validate: { @@ -114,5 +127,5 @@ const ListObjectsV2 = { }, } -const methods = { GetObject, HeadObject, ListObjectsV2, PutObject, ...incomplete } +const methods = { GetObject, HeadObject, ListBuckets, ListObjectsV2, PutObject, ...incomplete } export default { service, property, methods } diff --git a/plugins/s3/types/index.d.ts b/plugins/s3/types/index.d.ts index 3293ef35..4610e21a 100644 --- a/plugins/s3/types/index.d.ts +++ b/plugins/s3/types/index.d.ts @@ -3,6 +3,7 @@ import { // $IMPORTS_START GetObjectCommandOutput as GetObjectResponse, HeadObjectCommandOutput as HeadObjectResponse, + ListBucketsCommandOutput as ListBucketsResponse, ListObjectsV2CommandOutput as ListObjectsV2Response, PutObjectCommandOutput as PutObjectResponse, // $IMPORTS_END @@ -23,6 +24,8 @@ declare interface AwsLiteS3 { * - aws-lite docs: {@link https://github.com/architect/aws-lite/blob/main/plugins/s3/readme.md#HeadObject S3: HeadObject} */ HeadObject: (input: { Bucket: string, Key: string, PartNumber?: number, VersionId?: string, IfMatch?: string, IfModifiedSince?: string, IfNoneMatch?: string, IfUnmodifiedSince?: string, Range?: string, SSECustomerAlgorithm?: string, SSECustomerKey?: string, SSECustomerKeyMD5?: string, RequestPayer?: string, ExpectedBucketOwner?: string, ChecksumMode?: string }) => Promise + /** @description aws-lite docs: {@link https://github.com/architect/aws-lite/blob/main/plugins/s3/readme.md#ListBuckets S3: ListBuckets} */ + ListBuckets: () => Promise /** * @description * - AWS docs: {@link https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html S3: ListObjectsV2}