@SdkInternalApi
    final PutPermissionPolicyResult executePutPermissionPolicy(PutPermissionPolicyRequest putPermissionPolicyRequest) {

        ExecutionContext executionContext = createExecutionContext(putPermissionPolicyRequest);
        AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
        awsRequestMetrics.startEvent(Field.ClientExecuteTime);
        Request<PutPermissionPolicyRequest> request = null;
        Response<PutPermissionPolicyResult> response = null;

        try {
            awsRequestMetrics.startEvent(Field.RequestMarshallTime);
            try {
                request = new PutPermissionPolicyRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(putPermissionPolicyRequest));
                // Binds the request metrics to the current request.
                request.setAWSRequestMetrics(awsRequestMetrics);
                request.addHandlerContext(HandlerContextKey.CLIENT_ENDPOINT, endpoint);
                request.addHandlerContext(HandlerContextKey.ENDPOINT_OVERRIDDEN, isEndpointOverridden());
                request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
                request.addHandlerContext(HandlerContextKey.SERVICE_ID, "WAF Regional");
                request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "PutPermissionPolicy");
                request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);

            } finally {
                awsRequestMetrics.endEvent(Field.RequestMarshallTime);
            }

            HttpResponseHandler<AmazonWebServiceResponse<PutPermissionPolicyResult>> responseHandler = protocolFactory.createResponseHandler(
                    new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new PutPermissionPolicyResultJsonUnmarshaller());
            response = invoke(request, responseHandler, executionContext);

            return response.getAwsResponse();

        } finally {

            endClientExecution(awsRequestMetrics, request, response);
        }
    }
<note>
<p>
This is <b>AWS WAF Classic</b> documentation. For more information, see <a
href="https://docs.aws.amazon.com/waf/latest/developerguide/classic-waf-chapter.html">AWS WAF Classic</a> in the
developer guide.
</p>
<p>
<b>For the latest version of AWS WAF</b>, use the AWS WAFV2 API and see the <a
href="https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html">AWS WAF Developer Guide</a>. With
the latest version, AWS WAF has a single set of endpoints for regional and global use.
</p>
</note>
<p>
Attaches an IAM policy to the specified resource. The only supported use for this action is to share a RuleGroup
across accounts.
</p>
<p>
The <code>PutPermissionPolicy</code> is subject to the following restrictions:
</p>
<ul>
<li>
<p>
You can attach only one policy with each <code>PutPermissionPolicy</code> request.
</p>
</li>
<li>
<p>
The policy must include an <code>Effect</code>, <code>Action</code> and <code>Principal</code>.
</p>
</li>
<li>
<p>
<code>Effect</code> must specify <code>Allow</code>.
</p>
</li>
<li>
<p>
The <code>Action</code> in the policy must be <code>waf:UpdateWebACL</code>,
<code>waf-regional:UpdateWebACL</code>, <code>waf:GetRuleGroup</code> and <code>waf-regional:GetRuleGroup</code>
. Any extra or wildcard actions in the policy will be rejected.
</p>
</li>
<li>
<p>
The policy cannot include a <code>Resource</code> parameter.
</p>
</li>
<li>
<p>
The ARN in the request must be a valid WAF RuleGroup ARN and the RuleGroup must exist in the same region.
</p>
</li>
<li>
<p>
The user making the request must be the owner of the RuleGroup.
</p>
</li>
<li>
<p>
Your policy must be composed using IAM Policy version 2012-10-17.
</p>
</li>
</ul>
<p>
For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html">IAM
Policies</a>.
</p>
<p>
An example of a valid policy parameter is shown in the Examples section below.
</p>

@param putPermissionPolicyRequest
@return Result of the PutPermissionPolicy operation returned by the service.
@throws WAFInternalErrorException
        The operation failed because of a system problem, even though the request was valid. Retry your request.
@throws WAFStaleDataException
        The operation failed because you tried to create, update, or delete an object by using a change token
        that has already been used.
@throws WAFNonexistentItemException
        The operation failed because the referenced object doesn't exist.
@throws WAFInvalidPermissionPolicyException
        The operation failed because the specified policy is not in the proper format. </p>
        <p>
        The policy is subject to the following restrictions:
        </p>
        <ul>
        <li>
        <p>
        You can attach only one policy with each <code>PutPermissionPolicy</code> request.
        </p>
        </li>
        <li>
        <p>
        The policy must include an <code>Effect</code>, <code>Action</code> and <code>Principal</code>.
        </p>
        </li>
        <li>
        <p>
        <code>Effect</code> must specify <code>Allow</code>.
        </p>
        </li>
        <li>
        <p>
        The <code>Action</code> in the policy must be <code>waf:UpdateWebACL</code>,
        <code>waf-regional:UpdateWebACL</code>, <code>waf:GetRuleGroup</code> and
        <code>waf-regional:GetRuleGroup</code> . Any extra or wildcard actions in the policy will be rejected.
        </p>
        </li>
        <li>
        <p>
        The policy cannot include a <code>Resource</code> parameter.
        </p>
        </li>
        <li>
        <p>
        The ARN in the request must be a valid WAF RuleGroup ARN and the RuleGroup must exist in the same region.
        </p>
        </li>
        <li>
        <p>
        The user making the request must be the owner of the RuleGroup.
        </p>
        </li>
        <li>
        <p>
        Your policy must be composed using IAM Policy version 2012-10-17.
        </p>
        </li>
@sample AWSWAFRegional.PutPermissionPolicy
@see <a href="http://docs.aws.amazon.com/goto/WebAPI/waf-regional-2016-11-28/PutPermissionPolicy"
     target="_top">AWS API Documentation</a>
aws-java-sdk-waf/src/main/java/com/amazonaws/services/waf/AWSWAFRegionalClient.java