-
Notifications
You must be signed in to change notification settings - Fork 0
Add bucket quota apis #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6063ef5
c882857
96dd338
677bfd9
d1aeca4
7f476de
2348f8f
7271bad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import { | ||
| BucketQuotaClient, | ||
| CloudserverBucketQuotaClientConfig, | ||
| GetBucketQuotaCommand | ||
| } from '@scality/cloudserverclient/clients/bucketQuota'; | ||
|
|
||
| const config: CloudserverBucketQuotaClientConfig = { | ||
| endpoint: 'http://localhost:8000', | ||
| credentials: { | ||
| accessKeyId: 'accessKey1', | ||
| secretAccessKey: 'verySecretKey1', | ||
| }, | ||
| region: 'us-east-1', | ||
| maxAttempts: 1, | ||
| }; | ||
|
|
||
| const bucketQuotaClient = new BucketQuotaClient(config); | ||
| try { | ||
| const getBucketQuotaCommand = new GetBucketQuotaCommand({ | ||
| Bucket: 'aBucketName', | ||
| }); | ||
|
|
||
| const quotaData = await bucketQuotaClient.send(getBucketQuotaCommand); | ||
| // { | ||
| // "$metadata": { | ||
| // "httpStatusCode": 200, | ||
| // "requestId": "aa0681fd844c9a2272fa", | ||
| // "extendedRequestId": "aa0681fd844c9a2272fa", | ||
| // "attempts": 1, | ||
| // "totalRetryDelay": 0 | ||
| // }, | ||
| // "Name": "aBucketName", | ||
| // "Quota": 42 | ||
| // } | ||
| } catch (error: any) { | ||
| console.error(error.name); // NoSuchBucket | ||
| console.error(error.message); // The specified bucket does not exist. | ||
| // { | ||
| // httpStatusCode: 404, | ||
| // requestId: "0caf000bc140bb9e62e9", | ||
| // extendedRequestId: "0caf000bc140bb9e62e9", | ||
| // cfId: undefined, | ||
| // attempts: 1, | ||
| // totalRetryDelay: 0, | ||
| // } | ||
| console.error(error.$metadata); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // cloudserverClient is a meta client that imports all other clients. | ||
| // In this library, you can either use individual clients (like BackbeatRoutesClient or BucketQuotaClient), | ||
| // or use this global client. | ||
|
|
||
| import { | ||
| CloudserverClient, | ||
| CloudserverClientConfig, | ||
| GetObjectCommand | ||
| } from '@scality/cloudserverclient'; | ||
|
|
||
| const command = new GetObjectCommand({ | ||
| Bucket: 'aBucketName', | ||
| Key: 'anObjectKey', | ||
| }); | ||
|
|
||
| const config: CloudserverClientConfig = { | ||
| endpoint: 'http://localhost:8000', | ||
| credentials: { | ||
| accessKeyId: 'accessKey1', | ||
| secretAccessKey: 'verySecretKey1', | ||
| }, | ||
| region: 'us-east-1', | ||
| }; | ||
| const client = new CloudserverClient(config); | ||
|
|
||
| const getData = await client.backbeatRoutes.send(command); | ||
| const bodyStr = await getData.Body.transformToString(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| $version: "2.0" | ||
| namespace cloudserver.client | ||
| namespace cloudserver.backbeatRoutes | ||
|
|
||
| use aws.auth#unsignedPayload | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| $version: "2.0" | ||
| namespace cloudserver.client | ||
| namespace cloudserver.backbeatRoutes | ||
|
|
||
| use aws.auth#unsignedPayload | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| $version: "2.0" | ||
| namespace cloudserver.client | ||
| namespace cloudserver.backbeatRoutes | ||
|
|
||
| use aws.auth#unsignedPayload | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| $version: "2.0" | ||
|
|
||
| namespace cloudserver.bucketquota | ||
|
|
||
| @http(method: "DELETE", uri: "/{Bucket}?quota=true") | ||
| @idempotent | ||
| operation DeleteBucketQuota { | ||
| input := { | ||
| @required | ||
| @httpLabel | ||
| Bucket: String | ||
| } | ||
| output := {} | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| $version: "2.0" | ||
|
|
||
| namespace cloudserver.bucketquota | ||
|
|
||
| @http(method: "GET", uri: "/{Bucket}?quota=true") | ||
| @readonly | ||
| operation GetBucketQuota { | ||
| input := { | ||
| @required | ||
| @httpLabel | ||
| Bucket: String | ||
| } | ||
| output := { | ||
| Name: String | ||
| Quota: Long | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,23 @@ | ||||||
| $version: "2.0" | ||||||
| namespace cloudserver.bucketquota | ||||||
|
|
||||||
| @http(method: "PUT", uri: "/{Bucket}?quota=true") | ||||||
| @idempotent | ||||||
| operation UpdateBucketQuota { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. keep same conventions as AWS (and http/rest in general) ?
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I kept the same names as the ones from the doc, do you confirm you wanna change it ?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤷♂️ let's ask for a vote from the team in the channel? |
||||||
| input: QuotaConfiguration | ||||||
| output: UpdateBucketQuotaOutput | ||||||
| } | ||||||
|
|
||||||
| structure QuotaConfiguration { | ||||||
| @required | ||||||
| @httpLabel | ||||||
| Bucket: String | ||||||
|
|
||||||
| @required | ||||||
| Quota: Long | ||||||
| } | ||||||
|
|
||||||
| structure UpdateBucketQuotaOutput { | ||||||
| @httpPayload | ||||||
| body: String | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not directly related with the pr, but this is nicer as we will only have one source of truth for smithy version.
I could definitely see someone updating smithy version here and forgetting about updating it in smithy-build.json