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

Method SetBucketPolicy

api-bucket-policy.go:39–52  ·  view source on GitHub ↗

SetBucketPolicy sets the access permissions policy on an existing bucket. The policy should be a valid JSON string that conforms to the IAM policy format. If policy is an empty string, the existing bucket policy will be removed. Parameters: - ctx: Context for request cancellation and timeout - buck

(ctx context.Context, bucketName, policy string)

Source from the content-addressed store, hash-verified

37//
38// Returns an error if the operation fails.
39func (c *Client) SetBucketPolicy(ctx context.Context, bucketName, policy string) error {
40 // Input validation.
41 if err := s3utils.CheckValidBucketName(bucketName); err != nil {
42 return err
43 }
44
45 // If policy is empty then delete the bucket policy.
46 if policy == "" {
47 return c.removeBucketPolicy(ctx, bucketName)
48 }
49
50 // Save the updated policies.
51 return c.putBucketPolicy(ctx, bucketName, policy)
52}
53
54// Saves a new bucket policy.
55func (c *Client) putBucketPolicy(ctx context.Context, bucketName, policy string) error {

Callers 4

testFunctionalFunction · 0.95
testFunctionalV2Function · 0.95
testCorsFunction · 0.95
mainFunction · 0.80

Calls 3

removeBucketPolicyMethod · 0.95
putBucketPolicyMethod · 0.95
CheckValidBucketNameFunction · 0.92

Tested by

no test coverage detected