mirror of
https://github.com/ceph/go-ceph
synced 2024-12-18 12:25:22 +00:00
9d74c3c2b1
Signed-off-by: Sven Anderson <sven@redhat.com>
41 lines
1.1 KiB
Go
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
|
|
}
|