From 440a577563c313f7ce6fe928ff9a18ac1ad0deb3 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 17 May 2022 17:51:38 +0200 Subject: [PATCH] Prefix all APIs with `v0/` --- doc/drafts/admin-api.md | 48 ++++++++++++++++++++--------------------- src/api/admin/router.rs | 48 ++++++++++++++++++++--------------------- 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/doc/drafts/admin-api.md b/doc/drafts/admin-api.md index e8ed087d..cbd73e15 100644 --- a/doc/drafts/admin-api.md +++ b/doc/drafts/admin-api.md @@ -15,7 +15,7 @@ Returns internal Garage metrics in Prometheus format. ## Cluster operations -### GetClusterStatus `GET /status` +### GetClusterStatus `GET /v0/status` Returns the cluster's current status in JSON, including: @@ -94,7 +94,7 @@ Example response body: } ``` -### GetClusterLayout `GET /layout` +### GetClusterLayout `GET /v0/layout` Returns the cluster's current layout in JSON, including: @@ -143,7 +143,7 @@ Example response body: } ``` -### UpdateClusterLayout `POST /layout` +### UpdateClusterLayout `POST /v0/layout` Send modifications to the cluster layout. These modifications will be included in the staged role changes, visible in subsequent calls @@ -174,7 +174,7 @@ Contrary to the CLI that may update only a subset of the fields values must be specified. -### ApplyClusterLayout `POST /layout/apply` +### ApplyClusterLayout `POST /v0/layout/apply` Applies to the cluster the layout changes currently registered as staged layout changes. @@ -191,7 +191,7 @@ Similarly to the CLI, the body must include the version of the new layout that will be created, which MUST be 1 + the value of the currently existing layout in the cluster. -### RevertClusterLayout `POST /layout/revert` +### RevertClusterLayout `POST /v0/layout/revert` Clears all of the staged layout changes. @@ -212,7 +212,7 @@ existing layout in the cluster. ## Access key operations -### ListKeys `GET /key` +### ListKeys `GET /v0/key` Returns all API access keys in the cluster. @@ -231,7 +231,7 @@ Example response: ] ``` -### CreateKey `POST /key` +### CreateKey `POST /v0/key` Creates a new API access key. @@ -243,8 +243,8 @@ Request body format: } ``` -### GetKeyInfo `GET /key?id=` -### GetKeyInfo `GET /key?search=` +### GetKeyInfo `GET /v0/key?id=` +### GetKeyInfo `GET /v0/key?search=` Returns information about the requested API access key. @@ -315,11 +315,11 @@ Example response: } ``` -### DeleteKey `DELETE /key?id=` +### DeleteKey `DELETE /v0/key?id=` Deletes an API access key. -### UpdateKey `POST /key?id=` +### UpdateKey `POST /v0/key?id=` Updates information about the specified API access key. @@ -342,7 +342,7 @@ The possible flags in `allow` and `deny` are: `createBucket`. ## Bucket operations -### ListBuckets `GET /bucket` +### ListBuckets `GET /v0/bucket` Returns all storage buckets in the cluster. @@ -384,8 +384,8 @@ Example response: ] ``` -### GetBucketInfo `GET /bucket?id=` -### GetBucketInfo `GET /bucket?globalAlias=` +### GetBucketInfo `GET /v0/bucket?id=` +### GetBucketInfo `GET /v0/bucket?globalAlias=` Returns information about the requested storage bucket. @@ -418,7 +418,7 @@ Example response: } ``` -### CreateBucket `POST /bucket` +### CreateBucket `POST /v0/bucket` Creates a new storage bucket. @@ -451,13 +451,13 @@ OR Creates a new bucket, either with a global alias, a local one, or no alias at all. -### DeleteBucket `DELETE /bucket?id=` +### DeleteBucket `DELETE /v0/bucket?id=` Deletes a storage bucket. A bucket cannot be deleted if it is not empty. Warning: this will delete all aliases associated with the bucket! -### PutBucketWebsite `PUT /bucket/website?id=` +### PutBucketWebsite `PUT /v0/bucket/website?id=` Sets the website configuration for a bucket (this also enables website access for this bucket). @@ -473,14 +473,14 @@ Request body format: The field `errorDocument` is optional, if no error document is set a generic error message is displayed when errors happen. -### DeleteBucketWebsite `DELETE /bucket/website?id=` +### DeleteBucketWebsite `DELETE /v0/bucket/website?id=` Deletes the website configuration for a bucket (disables website access for this bucket). ## Operations on permissions for keys on buckets -### BucketAllowKey `POST /bucket/allow` +### BucketAllowKey `POST /v0/bucket/allow` Allows a key to do read/write/owner operations on a bucket. @@ -501,7 +501,7 @@ Request body format: Flags in `permissions` which have the value `true` will be activated. Other flags will remain unchanged. -### BucketDenyKey `POST /bucket/deny` +### BucketDenyKey `POST /v0/bucket/deny` Denies a key from doing read/write/owner operations on a bucket. @@ -525,19 +525,19 @@ Other flags will remain unchanged. ## Operations on bucket aliases -### GlobalAliasBucket `PUT /bucket/alias/global?id=&alias=` +### GlobalAliasBucket `PUT /v0/bucket/alias/global?id=&alias=` Empty body. Creates a global alias for a bucket. -### GlobalUnaliasBucket `DELETE /bucket/alias/global?id=&alias=` +### GlobalUnaliasBucket `DELETE /v0/bucket/alias/global?id=&alias=` Removes a global alias for a bucket. -### LocalAliasBucket `PUT /bucket/alias/local?id=&accessKeyId=&alias=` +### LocalAliasBucket `PUT /v0/bucket/alias/local?id=&accessKeyId=&alias=` Empty body. Creates a local alias for a bucket in the namespace of a specific access key. -### LocalUnaliasBucket `DELETE /bucket/alias/local?id=&accessKeyId&alias=` +### LocalUnaliasBucket `DELETE /v0/bucket/alias/local?id=&accessKeyId&alias=` Removes a local alias for a bucket in the namespace of a specific access key. diff --git a/src/api/admin/router.rs b/src/api/admin/router.rs index ae9e6681..909ef102 100644 --- a/src/api/admin/router.rs +++ b/src/api/admin/router.rs @@ -90,35 +90,35 @@ impl Endpoint { let res = router_match!(@gen_path_parser (req.method(), path, query) [ OPTIONS _ => Options, GET "/metrics" => Metrics, - GET "/status" => GetClusterStatus, + GET "/v0/status" => GetClusterStatus, // Layout endpoints - GET "/layout" => GetClusterLayout, - POST "/layout" => UpdateClusterLayout, - POST "/layout/apply" => ApplyClusterLayout, - POST "/layout/revert" => RevertClusterLayout, + GET "/v0/layout" => GetClusterLayout, + POST "/v0/layout" => UpdateClusterLayout, + POST "/v0/layout/apply" => ApplyClusterLayout, + POST "/v0/layout/revert" => RevertClusterLayout, // API key endpoints - GET "/key" if id => GetKeyInfo (query_opt::id, query_opt::search), - GET "/key" if search => GetKeyInfo (query_opt::id, query_opt::search), - POST "/key" if id => UpdateKey (query::id), - POST "/key" => CreateKey, - DELETE "/key" if id => DeleteKey (query::id), - GET "/key" => ListKeys, + GET "/v0/key" if id => GetKeyInfo (query_opt::id, query_opt::search), + GET "/v0/key" if search => GetKeyInfo (query_opt::id, query_opt::search), + POST "/v0/key" if id => UpdateKey (query::id), + POST "/v0/key" => CreateKey, + DELETE "/v0/key" if id => DeleteKey (query::id), + GET "/v0/key" => ListKeys, // Bucket endpoints - GET "/bucket" if id => GetBucketInfo (query_opt::id, query_opt::global_alias), - GET "/bucket" if global_alias => GetBucketInfo (query_opt::id, query_opt::global_alias), - GET "/bucket" => ListBuckets, - POST "/bucket" => CreateBucket, - DELETE "/bucket" if id => DeleteBucket (query::id), - PUT "/bucket/website" if id => PutBucketWebsite (query::id), - DELETE "/bucket/website" if id => DeleteBucketWebsite (query::id), + GET "/v0/bucket" if id => GetBucketInfo (query_opt::id, query_opt::global_alias), + GET "/v0/bucket" if global_alias => GetBucketInfo (query_opt::id, query_opt::global_alias), + GET "/v0/bucket" => ListBuckets, + POST "/v0/bucket" => CreateBucket, + DELETE "/v0/bucket" if id => DeleteBucket (query::id), + PUT "/v0/bucket/website" if id => PutBucketWebsite (query::id), + DELETE "/v0/bucket/website" if id => DeleteBucketWebsite (query::id), // Bucket-key permissions - POST "/bucket/allow" => BucketAllowKey, - POST "/bucket/deny" => BucketDenyKey, + POST "/v0/bucket/allow" => BucketAllowKey, + POST "/v0/bucket/deny" => BucketDenyKey, // Bucket aliases - PUT "/bucket/alias/global" => GlobalAliasBucket (query::id, query::alias), - DELETE "/bucket/alias/global" => GlobalUnaliasBucket (query::id, query::alias), - PUT "/bucket/alias/local" => LocalAliasBucket (query::id, query::access_key_id, query::alias), - DELETE "/bucket/alias/local" => LocalUnaliasBucket (query::id, query::access_key_id, query::alias), + PUT "/v0/bucket/alias/global" => GlobalAliasBucket (query::id, query::alias), + DELETE "/v0/bucket/alias/global" => GlobalUnaliasBucket (query::id, query::alias), + PUT "/v0/bucket/alias/local" => LocalAliasBucket (query::id, query::access_key_id, query::alias), + DELETE "/v0/bucket/alias/local" => LocalUnaliasBucket (query::id, query::access_key_id, query::alias), ]); if let Some(message) = query.nonempty_message() {