mirror of
https://github.com/ceph/go-ceph
synced 2025-01-22 14:12:50 +00:00
rgw/admin: use http verbs from the http package
The http package provides constants for common http methods so let's use them. Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
parent
7f34da0592
commit
7881ee6829
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Bucket describes an object store bucket
|
||||
@ -82,7 +83,7 @@ type Policy struct {
|
||||
|
||||
// ListBuckets will return the list of all buckets present in the object store
|
||||
func (api *API) ListBuckets(ctx context.Context) ([]string, error) {
|
||||
body, err := api.call(ctx, get, "/bucket", nil)
|
||||
body, err := api.call(ctx, http.MethodGet, "/bucket", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -97,7 +98,7 @@ func (api *API) ListBuckets(ctx context.Context) ([]string, error) {
|
||||
|
||||
// GetBucketInfo will return various information about a specific token
|
||||
func (api *API) GetBucketInfo(ctx context.Context, bucket Bucket) (Bucket, error) {
|
||||
body, err := api.call(ctx, get, "/bucket", valueToURLParams(bucket))
|
||||
body, err := api.call(ctx, http.MethodGet, "/bucket", valueToURLParams(bucket))
|
||||
if err != nil {
|
||||
return Bucket{}, err
|
||||
}
|
||||
@ -115,7 +116,7 @@ func (api *API) GetBucketInfo(ctx context.Context, bucket Bucket) (Bucket, error
|
||||
func (api *API) GetBucketPolicy(ctx context.Context, bucket Bucket) (Policy, error) {
|
||||
policy := true
|
||||
bucket.Policy = &policy
|
||||
body, err := api.call(ctx, get, "/bucket", valueToURLParams(bucket))
|
||||
body, err := api.call(ctx, http.MethodGet, "/bucket", valueToURLParams(bucket))
|
||||
if err != nil {
|
||||
return Policy{}, err
|
||||
}
|
||||
@ -131,7 +132,7 @@ func (api *API) GetBucketPolicy(ctx context.Context, bucket Bucket) (Policy, err
|
||||
|
||||
// RemoveBucket will remove a given token from the object store
|
||||
func (api *API) RemoveBucket(ctx context.Context, bucket Bucket) error {
|
||||
_, err := api.call(ctx, delete, "/bucket", valueToURLParams(bucket))
|
||||
_, err := api.call(ctx, http.MethodDelete, "/bucket", valueToURLParams(bucket))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// QuotaSpec describes an object store quota for a user or a bucket
|
||||
@ -27,7 +28,7 @@ func (api *API) GetUserQuota(ctx context.Context, quota QuotaSpec) (QuotaSpec, e
|
||||
return QuotaSpec{}, errMissingUserID
|
||||
}
|
||||
|
||||
body, err := api.call(ctx, get, "/user?quota", valueToURLParams(quota))
|
||||
body, err := api.call(ctx, http.MethodGet, "/user?quota", valueToURLParams(quota))
|
||||
if err != nil {
|
||||
return QuotaSpec{}, err
|
||||
}
|
||||
@ -52,7 +53,7 @@ func (api *API) SetUserQuota(ctx context.Context, quota QuotaSpec) error {
|
||||
return errMissingUserID
|
||||
}
|
||||
|
||||
_, err := api.call(ctx, put, "/user?quota", valueToURLParams(quota))
|
||||
_, err := api.call(ctx, http.MethodPut, "/user?quota", valueToURLParams(quota))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -17,13 +17,9 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
authRegion = "default"
|
||||
service = "s3"
|
||||
connectionTimeout = time.Second * 3
|
||||
post verbHTTP = "POST"
|
||||
put verbHTTP = "PUT"
|
||||
get verbHTTP = "GET"
|
||||
delete verbHTTP = "DELETE"
|
||||
authRegion = "default"
|
||||
service = "s3"
|
||||
connectionTimeout = time.Second * 3
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Usage struct
|
||||
@ -49,7 +50,7 @@ type Usage struct {
|
||||
|
||||
// GetUsage request bandwidth usage information on the object store
|
||||
func (api *API) GetUsage(ctx context.Context, usage Usage) (Usage, error) {
|
||||
body, err := api.call(ctx, get, "/usage", valueToURLParams(usage))
|
||||
body, err := api.call(ctx, http.MethodGet, "/usage", valueToURLParams(usage))
|
||||
if err != nil {
|
||||
return Usage{}, err
|
||||
}
|
||||
@ -64,6 +65,6 @@ func (api *API) GetUsage(ctx context.Context, usage Usage) (Usage, error) {
|
||||
|
||||
// TrimUsage removes bandwidth usage information. With no dates specified, removes all usage information.
|
||||
func (api *API) TrimUsage(ctx context.Context, usage Usage) error {
|
||||
_, err := api.call(ctx, delete, "/usage", valueToURLParams(usage))
|
||||
_, err := api.call(ctx, http.MethodDelete, "/usage", valueToURLParams(usage))
|
||||
return err
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// User is GO representation of the json output of a user creation
|
||||
@ -51,7 +52,7 @@ func (api *API) GetUser(ctx context.Context, user User) (User, error) {
|
||||
return User{}, errMissingUserID
|
||||
}
|
||||
|
||||
body, err := api.call(ctx, get, "/user", valueToURLParams(user))
|
||||
body, err := api.call(ctx, http.MethodGet, "/user", valueToURLParams(user))
|
||||
if err != nil {
|
||||
return User{}, err
|
||||
}
|
||||
@ -67,7 +68,7 @@ func (api *API) GetUser(ctx context.Context, user User) (User, error) {
|
||||
|
||||
// GetUsers lists all object store users
|
||||
func (api *API) GetUsers(ctx context.Context) (*[]string, error) {
|
||||
body, err := api.call(ctx, get, "/metadata/user", nil)
|
||||
body, err := api.call(ctx, http.MethodGet, "/metadata/user", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -90,7 +91,7 @@ func (api *API) CreateUser(ctx context.Context, user User) (User, error) {
|
||||
}
|
||||
|
||||
// Send request
|
||||
body, err := api.call(ctx, put, "/user", valueToURLParams(user))
|
||||
body, err := api.call(ctx, http.MethodPut, "/user", valueToURLParams(user))
|
||||
if err != nil {
|
||||
return User{}, err
|
||||
}
|
||||
@ -111,7 +112,7 @@ func (api *API) RemoveUser(ctx context.Context, user User) error {
|
||||
return errMissingUserID
|
||||
}
|
||||
|
||||
_, err := api.call(ctx, delete, "/user", valueToURLParams(user))
|
||||
_, err := api.call(ctx, http.MethodDelete, "/user", valueToURLParams(user))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -125,7 +126,7 @@ func (api *API) ModifyUser(ctx context.Context, user User) (User, error) {
|
||||
return User{}, errMissingUserID
|
||||
}
|
||||
|
||||
body, err := api.call(ctx, post, "/user", valueToURLParams(user))
|
||||
body, err := api.call(ctx, http.MethodPost, "/user", valueToURLParams(user))
|
||||
if err != nil {
|
||||
return User{}, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user