Skip to content

Commit

Permalink
add delete bucket opt
Browse files Browse the repository at this point in the history
  • Loading branch information
jojoliang committed Oct 12, 2022
1 parent e19eb11 commit 5389852
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,23 @@ func (s *BucketService) Put(ctx context.Context, opt *BucketPutOptions) (*Respon
return resp, err
}

type BucketDeleteOptions struct {
XOptionHeader *http.Header `header:"-,omitempty" url:"-" xml:"-"`
}

// Delete Bucket请求可以在指定账号下删除Bucket,删除之前要求Bucket为空。
//
// https://www.qcloud.com/document/product/436/7732
func (s *BucketService) Delete(ctx context.Context) (*Response, error) {
func (s *BucketService) Delete(ctx context.Context, opt ...*BucketDeleteOptions) (*Response, error) {
var dopt *BucketDeleteOptions
if len(opt) > 0 {
dopt = opt[0]
}
sendOpt := sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/",
method: http.MethodDelete,
baseURL: s.client.BaseURL.BucketURL,
uri: "/",
method: http.MethodDelete,
optHeader: dopt,
}
resp, err := s.client.send(ctx, &sendOpt)
return resp, err
Expand All @@ -103,9 +112,9 @@ type BucketHeadOptions struct {

// Head Bucket请求可以确认是否存在该Bucket,是否有权限访问,Head的权限与Read一致。
//
// 当其存在时,返回 HTTP 状态码200;
// 当无权限时,返回 HTTP 状态码403;
// 当不存在时,返回 HTTP 状态码404。
// 当其存在时,返回 HTTP 状态码200;
// 当无权限时,返回 HTTP 状态码403;
// 当不存在时,返回 HTTP 状态码404。
//
// https://www.qcloud.com/document/product/436/7735
func (s *BucketService) Head(ctx context.Context, opt ...*BucketHeadOptions) (*Response, error) {
Expand Down

0 comments on commit 5389852

Please sign in to comment.