1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package iam 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// Retrieves the specified inline policy document that is embedded in the specified 14// IAM user. Policies returned by this API are URL-encoded compliant with RFC 3986 15// (https://tools.ietf.org/html/rfc3986). You can use a URL decoding method to 16// convert the policy back to plain JSON text. For example, if you use Java, you 17// can use the decode method of the java.net.URLDecoder utility class in the Java 18// SDK. Other languages and SDKs provide similar functionality. An IAM user can 19// also have managed policies attached to it. To retrieve a managed policy document 20// that is attached to a user, use GetPolicy to determine the policy's default 21// version. Then use GetPolicyVersion to retrieve the policy document. For more 22// information about policies, see Managed Policies and Inline Policies 23// (https://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-vs-inline.html) 24// in the IAM User Guide. 25func (c *Client) GetUserPolicy(ctx context.Context, params *GetUserPolicyInput, optFns ...func(*Options)) (*GetUserPolicyOutput, error) { 26 if params == nil { 27 params = &GetUserPolicyInput{} 28 } 29 30 result, metadata, err := c.invokeOperation(ctx, "GetUserPolicy", params, optFns, addOperationGetUserPolicyMiddlewares) 31 if err != nil { 32 return nil, err 33 } 34 35 out := result.(*GetUserPolicyOutput) 36 out.ResultMetadata = metadata 37 return out, nil 38} 39 40type GetUserPolicyInput struct { 41 42 // The name of the policy document to get. This parameter allows (through its regex 43 // pattern (http://wikipedia.org/wiki/regex)) a string of characters consisting of 44 // upper and lowercase alphanumeric characters with no spaces. You can also include 45 // any of the following characters: _+=,.@- 46 // 47 // This member is required. 48 PolicyName *string 49 50 // The name of the user who the policy is associated with. This parameter allows 51 // (through its regex pattern (http://wikipedia.org/wiki/regex)) a string of 52 // characters consisting of upper and lowercase alphanumeric characters with no 53 // spaces. You can also include any of the following characters: _+=,.@- 54 // 55 // This member is required. 56 UserName *string 57} 58 59// Contains the response to a successful GetUserPolicy request. 60type GetUserPolicyOutput struct { 61 62 // The policy document. IAM stores policies in JSON format. However, resources that 63 // were created using AWS CloudFormation templates can be formatted in YAML. AWS 64 // CloudFormation always converts a YAML policy to JSON format before submitting it 65 // to IAM. 66 // 67 // This member is required. 68 PolicyDocument *string 69 70 // The name of the policy. 71 // 72 // This member is required. 73 PolicyName *string 74 75 // The user the policy is associated with. 76 // 77 // This member is required. 78 UserName *string 79 80 // Metadata pertaining to the operation's result. 81 ResultMetadata middleware.Metadata 82} 83 84func addOperationGetUserPolicyMiddlewares(stack *middleware.Stack, options Options) (err error) { 85 err = stack.Serialize.Add(&awsAwsquery_serializeOpGetUserPolicy{}, middleware.After) 86 if err != nil { 87 return err 88 } 89 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpGetUserPolicy{}, middleware.After) 90 if err != nil { 91 return err 92 } 93 if err = addSetLoggerMiddleware(stack, options); err != nil { 94 return err 95 } 96 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 97 return err 98 } 99 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 100 return err 101 } 102 if err = addResolveEndpointMiddleware(stack, options); err != nil { 103 return err 104 } 105 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 106 return err 107 } 108 if err = addRetryMiddlewares(stack, options); err != nil { 109 return err 110 } 111 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 112 return err 113 } 114 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 115 return err 116 } 117 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 118 return err 119 } 120 if err = addClientUserAgent(stack); err != nil { 121 return err 122 } 123 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 124 return err 125 } 126 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 127 return err 128 } 129 if err = addOpGetUserPolicyValidationMiddleware(stack); err != nil { 130 return err 131 } 132 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetUserPolicy(options.Region), middleware.Before); err != nil { 133 return err 134 } 135 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 136 return err 137 } 138 if err = addResponseErrorMiddleware(stack); err != nil { 139 return err 140 } 141 if err = addRequestResponseLogging(stack, options); err != nil { 142 return err 143 } 144 return nil 145} 146 147func newServiceMetadataMiddleware_opGetUserPolicy(region string) *awsmiddleware.RegisterServiceMetadata { 148 return &awsmiddleware.RegisterServiceMetadata{ 149 Region: region, 150 ServiceID: ServiceID, 151 SigningName: "iam", 152 OperationName: "GetUserPolicy", 153 } 154} 155