1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package ecr 4 5import ( 6 "context" 7 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 8 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 9 "github.com/aws/smithy-go/middleware" 10 smithyhttp "github.com/aws/smithy-go/transport/http" 11) 12 13// Applies a repository policy to the specified repository to control access 14// permissions. For more information, see Amazon ECR Repository Policies 15// (https://docs.aws.amazon.com/AmazonECR/latest/userguide/repository-policies.html) 16// in the Amazon Elastic Container Registry User Guide. 17func (c *Client) SetRepositoryPolicy(ctx context.Context, params *SetRepositoryPolicyInput, optFns ...func(*Options)) (*SetRepositoryPolicyOutput, error) { 18 if params == nil { 19 params = &SetRepositoryPolicyInput{} 20 } 21 22 result, metadata, err := c.invokeOperation(ctx, "SetRepositoryPolicy", params, optFns, addOperationSetRepositoryPolicyMiddlewares) 23 if err != nil { 24 return nil, err 25 } 26 27 out := result.(*SetRepositoryPolicyOutput) 28 out.ResultMetadata = metadata 29 return out, nil 30} 31 32type SetRepositoryPolicyInput struct { 33 34 // The JSON repository policy text to apply to the repository. For more 35 // information, see Amazon ECR Repository Policies 36 // (https://docs.aws.amazon.com/AmazonECR/latest/userguide/repository-policy-examples.html) 37 // in the Amazon Elastic Container Registry User Guide. 38 // 39 // This member is required. 40 PolicyText *string 41 42 // The name of the repository to receive the policy. 43 // 44 // This member is required. 45 RepositoryName *string 46 47 // If the policy you are attempting to set on a repository policy would prevent you 48 // from setting another policy in the future, you must force the 49 // SetRepositoryPolicy operation. This is intended to prevent accidental repository 50 // lock outs. 51 Force bool 52 53 // The AWS account ID associated with the registry that contains the repository. If 54 // you do not specify a registry, the default registry is assumed. 55 RegistryId *string 56} 57 58type SetRepositoryPolicyOutput struct { 59 60 // The JSON repository policy text applied to the repository. 61 PolicyText *string 62 63 // The registry ID associated with the request. 64 RegistryId *string 65 66 // The repository name associated with the request. 67 RepositoryName *string 68 69 // Metadata pertaining to the operation's result. 70 ResultMetadata middleware.Metadata 71} 72 73func addOperationSetRepositoryPolicyMiddlewares(stack *middleware.Stack, options Options) (err error) { 74 err = stack.Serialize.Add(&awsAwsjson11_serializeOpSetRepositoryPolicy{}, middleware.After) 75 if err != nil { 76 return err 77 } 78 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpSetRepositoryPolicy{}, middleware.After) 79 if err != nil { 80 return err 81 } 82 if err = addSetLoggerMiddleware(stack, options); err != nil { 83 return err 84 } 85 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 86 return err 87 } 88 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 89 return err 90 } 91 if err = addResolveEndpointMiddleware(stack, options); err != nil { 92 return err 93 } 94 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 95 return err 96 } 97 if err = addRetryMiddlewares(stack, options); err != nil { 98 return err 99 } 100 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 101 return err 102 } 103 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 104 return err 105 } 106 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 107 return err 108 } 109 if err = addClientUserAgent(stack); err != nil { 110 return err 111 } 112 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 113 return err 114 } 115 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 116 return err 117 } 118 if err = addOpSetRepositoryPolicyValidationMiddleware(stack); err != nil { 119 return err 120 } 121 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opSetRepositoryPolicy(options.Region), middleware.Before); err != nil { 122 return err 123 } 124 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 125 return err 126 } 127 if err = addResponseErrorMiddleware(stack); err != nil { 128 return err 129 } 130 if err = addRequestResponseLogging(stack, options); err != nil { 131 return err 132 } 133 return nil 134} 135 136func newServiceMetadataMiddleware_opSetRepositoryPolicy(region string) *awsmiddleware.RegisterServiceMetadata { 137 return &awsmiddleware.RegisterServiceMetadata{ 138 Region: region, 139 ServiceID: ServiceID, 140 SigningName: "ecr", 141 OperationName: "SetRepositoryPolicy", 142 } 143} 144