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

Method getBucketPolicy

api-bucket-policy.go:132–163  ·  view source on GitHub ↗

Request server for current bucket policy.

(ctx context.Context, bucketName string)

Source from the content-addressed store, hash-verified

130
131// Request server for current bucket policy.
132func (c *Client) getBucketPolicy(ctx context.Context, bucketName string) (string, error) {
133 // Get resources properly escaped and lined up before
134 // using them in http request.
135 urlValues := make(url.Values)
136 urlValues.Set("policy", "")
137
138 // Execute GET on bucket to list objects.
139 resp, err := c.executeMethod(ctx, http.MethodGet, requestMetadata{
140 bucketName: bucketName,
141 queryValues: urlValues,
142 contentSHA256Hex: emptySHA256Hex,
143 })
144
145 defer closeResponse(resp)
146 if err != nil {
147 return "", err
148 }
149
150 if resp != nil {
151 if resp.StatusCode != http.StatusOK {
152 return "", httpRespToErrorResponse(resp, bucketName, "")
153 }
154 }
155
156 bucketPolicyBuf, err := io.ReadAll(resp.Body)
157 if err != nil {
158 return "", err
159 }
160
161 policy := string(bucketPolicyBuf)
162 return policy, err
163}

Callers 2

GetBucketPolicyMethod · 0.95
GetBucketPolicyMethod · 0.80

Calls 4

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

Tested by

no test coverage detected