// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. package iam import ( "context" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/internal/awsutil" "github.com/aws/aws-sdk-go-v2/private/protocol" "github.com/aws/aws-sdk-go-v2/private/protocol/query" ) type PutRolePolicyInput struct { _ struct{} `type:"structure"` // The policy document. // // You must provide policies in JSON format in IAM. However, for AWS CloudFormation // templates formatted in YAML, you can provide the policy in JSON or YAML format. // AWS CloudFormation always converts a YAML policy to JSON format before submitting // it to IAM. // // The regex pattern (http://wikipedia.org/wiki/regex) used to validate this // parameter is a string of characters consisting of the following: // // * Any printable ASCII character ranging from the space character (\u0020) // through the end of the ASCII character range // // * The printable characters in the Basic Latin and Latin-1 Supplement character // set (through \u00FF) // // * The special characters tab (\u0009), line feed (\u000A), and carriage // return (\u000D) // // PolicyDocument is a required field PolicyDocument *string `min:"1" type:"string" required:"true"` // The name of the policy document. // // This parameter allows (through its regex pattern (http://wikipedia.org/wiki/regex)) // a string of characters consisting of upper and lowercase alphanumeric characters // with no spaces. You can also include any of the following characters: _+=,.@- // // PolicyName is a required field PolicyName *string `min:"1" type:"string" required:"true"` // The name of the role to associate the policy with. // // This parameter allows (through its regex pattern (http://wikipedia.org/wiki/regex)) // a string of characters consisting of upper and lowercase alphanumeric characters // with no spaces. You can also include any of the following characters: _+=,.@- // // RoleName is a required field RoleName *string `min:"1" type:"string" required:"true"` } // String returns the string representation func (s PutRolePolicyInput) String() string { return awsutil.Prettify(s) } // Validate inspects the fields of the type to determine if they are valid. func (s *PutRolePolicyInput) Validate() error { invalidParams := aws.ErrInvalidParams{Context: "PutRolePolicyInput"} if s.PolicyDocument == nil { invalidParams.Add(aws.NewErrParamRequired("PolicyDocument")) } if s.PolicyDocument != nil && len(*s.PolicyDocument) < 1 { invalidParams.Add(aws.NewErrParamMinLen("PolicyDocument", 1)) } if s.PolicyName == nil { invalidParams.Add(aws.NewErrParamRequired("PolicyName")) } if s.PolicyName != nil && len(*s.PolicyName) < 1 { invalidParams.Add(aws.NewErrParamMinLen("PolicyName", 1)) } if s.RoleName == nil { invalidParams.Add(aws.NewErrParamRequired("RoleName")) } if s.RoleName != nil && len(*s.RoleName) < 1 { invalidParams.Add(aws.NewErrParamMinLen("RoleName", 1)) } if invalidParams.Len() > 0 { return invalidParams } return nil } type PutRolePolicyOutput struct { _ struct{} `type:"structure"` } // String returns the string representation func (s PutRolePolicyOutput) String() string { return awsutil.Prettify(s) } const opPutRolePolicy = "PutRolePolicy" // PutRolePolicyRequest returns a request value for making API operation for // AWS Identity and Access Management. // // Adds or updates an inline policy document that is embedded in the specified // IAM role. // // When you embed an inline policy in a role, the inline policy is used as part // of the role's access (permissions) policy. The role's trust policy is created // at the same time as the role, using CreateRole. You can update a role's trust // policy using UpdateAssumeRolePolicy. For more information about IAM roles, // go to Using Roles to Delegate Permissions and Federate Identities (https://docs.aws.amazon.com/IAM/latest/UserGuide/roles-toplevel.html). // // A role can also have a managed policy attached to it. To attach a managed // policy to a role, use AttachRolePolicy. To create a new managed policy, use // CreatePolicy. For information about policies, see Managed Policies and Inline // Policies (https://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-vs-inline.html) // in the IAM User Guide. // // For information about limits on the number of inline policies that you can // embed with a role, see Limitations on IAM Entities (https://docs.aws.amazon.com/IAM/latest/UserGuide/LimitationsOnEntities.html) // in the IAM User Guide. // // Because policy documents can be large, you should use POST rather than GET // when calling PutRolePolicy. For general information about using the Query // API with IAM, go to Making Query Requests (https://docs.aws.amazon.com/IAM/latest/UserGuide/IAM_UsingQueryAPI.html) // in the IAM User Guide. // // // Example sending a request using PutRolePolicyRequest. // req := client.PutRolePolicyRequest(params) // resp, err := req.Send(context.TODO()) // if err == nil { // fmt.Println(resp) // } // // Please also see https://docs.aws.amazon.com/goto/WebAPI/iam-2010-05-08/PutRolePolicy func (c *Client) PutRolePolicyRequest(input *PutRolePolicyInput) PutRolePolicyRequest { op := &aws.Operation{ Name: opPutRolePolicy, HTTPMethod: "POST", HTTPPath: "/", } if input == nil { input = &PutRolePolicyInput{} } req := c.newRequest(op, input, &PutRolePolicyOutput{}) req.Handlers.Unmarshal.Remove(query.UnmarshalHandler) req.Handlers.Unmarshal.PushBackNamed(protocol.UnmarshalDiscardBodyHandler) return PutRolePolicyRequest{Request: req, Input: input, Copy: c.PutRolePolicyRequest} } // PutRolePolicyRequest is the request type for the // PutRolePolicy API operation. type PutRolePolicyRequest struct { *aws.Request Input *PutRolePolicyInput Copy func(*PutRolePolicyInput) PutRolePolicyRequest } // Send marshals and sends the PutRolePolicy API request. func (r PutRolePolicyRequest) Send(ctx context.Context) (*PutRolePolicyResponse, error) { r.Request.SetContext(ctx) err := r.Request.Send() if err != nil { return nil, err } resp := &PutRolePolicyResponse{ PutRolePolicyOutput: r.Request.Data.(*PutRolePolicyOutput), response: &aws.Response{Request: r.Request}, } return resp, nil } // PutRolePolicyResponse is the response type for the // PutRolePolicy API operation. type PutRolePolicyResponse struct { *PutRolePolicyOutput response *aws.Response } // SDKResponseMetdata returns the response metadata for the // PutRolePolicy request. func (r *PutRolePolicyResponse) SDKResponseMetdata() *aws.Response { return r.response }