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

Method GetBucketPolicy

api-bucket-policy.go:115–129  ·  view source on GitHub ↗

GetBucketPolicy retrieves the access permissions policy for the bucket. If no bucket policy exists, returns an empty string with no error. Parameters: - ctx: Context for request cancellation and timeout - bucketName: Name of the bucket Returns the policy as a JSON string or an error if the operati

(ctx context.Context, bucketName string)

Source from the content-addressed store, hash-verified

113//
114// Returns the policy as a JSON string or an error if the operation fails.
115func (c *Client) GetBucketPolicy(ctx context.Context, bucketName string) (string, error) {
116 // Input validation.
117 if err := s3utils.CheckValidBucketName(bucketName); err != nil {
118 return "", err
119 }
120 bucketPolicy, err := c.getBucketPolicy(ctx, bucketName)
121 if err != nil {
122 errResponse := ToErrorResponse(err)
123 if errResponse.Code == NoSuchBucketPolicy {
124 return "", nil
125 }
126 return "", err
127 }
128 return bucketPolicy, nil
129}
130
131// Request server for current bucket policy.
132func (c *Client) getBucketPolicy(ctx context.Context, bucketName string) (string, error) {

Callers 1

testFunctionalFunction · 0.95

Calls 3

getBucketPolicyMethod · 0.95
CheckValidBucketNameFunction · 0.92
ToErrorResponseFunction · 0.85

Tested by

no test coverage detected