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