MCPcopy
hub / github.com/minio/minio-go / putBucketLifecycle

Method putBucketLifecycle

api-bucket-lifecycle.go:55–82  ·  view source on GitHub ↗

Saves a new bucket lifecycle.

(ctx context.Context, bucketName string, buf []byte)

Source from the content-addressed store, hash-verified

53
54// Saves a new bucket lifecycle.
55func (c *Client) putBucketLifecycle(ctx context.Context, bucketName string, buf []byte) error {
56 // Get resources properly escaped and lined up before
57 // using them in http request.
58 urlValues := make(url.Values)
59 urlValues.Set("lifecycle", "")
60
61 // Content-length is mandatory for put lifecycle request
62 reqMetadata := requestMetadata{
63 bucketName: bucketName,
64 queryValues: urlValues,
65 contentBody: bytes.NewReader(buf),
66 contentLength: int64(len(buf)),
67 contentMD5Base64: sumMD5Base64(buf),
68 }
69
70 // Execute PUT to upload a new bucket lifecycle.
71 resp, err := c.executeMethod(ctx, http.MethodPut, reqMetadata)
72 defer closeResponse(resp)
73 if err != nil {
74 return err
75 }
76 if resp != nil {
77 if resp.StatusCode != http.StatusOK {
78 return httpRespToErrorResponse(resp, bucketName, "")
79 }
80 }
81 return nil
82}
83
84// Remove lifecycle from a bucket.
85func (c *Client) removeBucketLifecycle(ctx context.Context, bucketName string) error {

Callers 1

SetBucketLifecycleMethod · 0.95

Calls 5

executeMethodMethod · 0.95
sumMD5Base64Function · 0.85
httpRespToErrorResponseFunction · 0.85
closeResponseFunction · 0.70
SetMethod · 0.45

Tested by

no test coverage detected