diff --git a/satellite/admin/README.md b/satellite/admin/README.md index 17ed53bc2..fcd58fb15 100644 --- a/satellite/admin/README.md +++ b/satellite/admin/README.md @@ -8,6 +8,7 @@ Requires setting `Authorization` header for requests. - [satellite/admin](#satelliteadmin) * [API design](#api-design) + * [Successful responses](#successful-responses) * [Error responses](#error-responses) * [API Endpoints](#api-endpoints) * [User Management](#user-management) @@ -42,6 +43,11 @@ Requires setting `Authorization` header for requests. ## API design +### Successful responses + +For non-get requests (`PUT`, `POST`, `DELETE`), endpoints should return an empty response body on success. `GET` +requests can return a non-empty body for the resource that we're interacting with. + ### Error responses When an API endpoint returns a client error (status code 4XX) it returns a JSON error response which contains 2 fields: diff --git a/satellite/admin/bucket.go b/satellite/admin/bucket.go index 0cc7eb724..0301091a8 100644 --- a/satellite/admin/bucket.go +++ b/satellite/admin/bucket.go @@ -74,7 +74,7 @@ func (server *Server) updateBucket(w http.ResponseWriter, r *http.Request, place b.Placement = placement - b, err = server.buckets.UpdateBucket(ctx, b) + _, err = server.buckets.UpdateBucket(ctx, b) if err != nil { switch { case storj.ErrBucketNotFound.Has(err): @@ -87,12 +87,7 @@ func (server *Server) updateBucket(w http.ResponseWriter, r *http.Request, place return } - data, err := json.Marshal(b) - if err != nil { - sendJSONError(w, "failed to marshal bucket", err.Error(), http.StatusInternalServerError) - } else { - sendJSONData(w, http.StatusOK, data) - } + w.WriteHeader(http.StatusOK) } func (server *Server) createGeofenceForBucket(w http.ResponseWriter, r *http.Request) { diff --git a/satellite/admin/ui/src/lib/api.ts b/satellite/admin/ui/src/lib/api.ts index 9886f3456..8167549c5 100644 --- a/satellite/admin/ui/src/lib/api.ts +++ b/satellite/admin/ui/src/lib/api.ts @@ -49,8 +49,11 @@ export class Admin { ['Project ID', new InputText('text', true)], ['Bucket name', new InputText('text', true)] ], - func: async (projectId: string, bucketName: string): Promise> => { - return this.fetch('DELETE', `projects/${projectId}/buckets/${bucketName}/geofence`); + func: async (projectId: string, bucketName: string): Promise => { + return this.fetch( + 'DELETE', + `projects/${projectId}/buckets/${bucketName}/geofence` + ) as Promise; } }, { @@ -69,17 +72,17 @@ export class Admin { ]) ] ], - func: async ( - projectId: string, - bucketName: string, - region: string - ): Promise> => { + func: async (projectId: string, bucketName: string, region: string): Promise => { const query = this.urlQueryFromObject({ region }); if (query === '') { throw new APIError('region cannot be empty'); } - return this.fetch('POST', `projects/${projectId}/buckets/${bucketName}/geofence`, query); + return this.fetch( + 'POST', + `projects/${projectId}/buckets/${bucketName}/geofence`, + query + ) as Promise; } } ],