go-ceph/rgw/admin/link.go
Sven Anderson 9d74c3c2b1 go-ceph: change mature preview APIs to stable
Signed-off-by: Sven Anderson <sven@redhat.com>
2022-08-16 11:42:41 +00:00

41 lines
1.1 KiB
Go

package admin
import (
"context"
"net/http"
)
// BucketLinkInput the bucket link/unlink input parameters
type BucketLinkInput struct {
Bucket string `url:"bucket" json:"bucket"`
BucketID string `url:"bucket-id" json:"bucket_id"`
UID string `url:"uid" json:"uid"`
}
// UnlinkBucket unlink a bucket from a specified user
// Primarily useful for changing bucket ownership.
func (api *API) UnlinkBucket(ctx context.Context, link BucketLinkInput) error {
if link.UID == "" {
return errMissingUserID
}
if link.Bucket == "" {
return errMissingBucket
}
_, err := api.call(ctx, http.MethodPost, "/bucket", valueToURLParams(link, []string{"uid", "bucket"}))
return err
}
// LinkBucket will link a bucket to a specified user
// unlinking the bucket from any previous user
func (api *API) LinkBucket(ctx context.Context, link BucketLinkInput) error {
if link.UID == "" {
return errMissingUserID
}
if link.Bucket == "" {
return errMissingBucket
}
// valid parameters not supported by go-ceph: new-bucket-name
_, err := api.call(ctx, http.MethodPut, "/bucket", valueToURLParams(link, []string{"uid", "bucket-id", "bucket"}))
return err
}