Kms/src/V1/Gapic/KeyManagementServiceGapicClient.php
public function setIamPolicy($resource, $policy, array $optionalArgs = [])
    {
        $request = new SetIamPolicyRequest();
        $request->setResource($resource);
        $request->setPolicy($policy);

        $requestParams = new RequestParamsHeaderDescriptor([
          'resource' => $request->getResource(),
        ]);
        $optionalArgs['headers'] = isset($optionalArgs['headers'])
            ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
            : $requestParams->getHeader();

        return $this->startCall(
            'SetIamPolicy',
            Policy::class,
            $optionalArgs,
            $request,
            Call::UNARY_CALL,
            'google.iam.v1.IAMPolicy'
        )->wait();
    }
public function setIamPolicy($resource, $policy, array $optionalArgs = [])
    {
        $request = new SetIamPolicyRequest();
        $request->setResource($resource);
        $request->setPolicy($policy);

        $requestParams = new RequestParamsHeaderDescriptor([
          'resource' => $request->getResource(),
        ]);
        $optionalArgs['headers'] = isset($optionalArgs['headers'])
            ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
            : $requestParams->getHeader();

        return $this->startCall(
            'SetIamPolicy',
            Policy::class,
            $optionalArgs,
            $request,
            Call::UNARY_CALL,
            'google.iam.v1.IAMPolicy'
        )->wait();
    }
public function setIamPolicy ( $ resource , $ policy , array $ optionalArgs = [ ] ) { $ request = new SetIamPolicyRequest ( ) ; $ request -> setResource ( $ resource ) ; $ request -> setPolicy ( $ policy ) ; $ requestParams = new RequestParamsHeaderDescriptor ( [ 'resource' => $ request -> getResource ( ) , ] ) ; $ optionalArgs [ 'headers' ] = isset ( $ optionalArgs [ 'headers' ] ) ? array_merge ( $ requestParams -> getHeader ( ) , $ optionalArgs [ 'headers' ] ) : $ requestParams -> getHeader ( ) ; return $ this -> startCall ( 'SetIamPolicy' , Policy :: class , $ optionalArgs , $ request , Call :: UNARY_CALL , 'google.iam.v1.IAMPolicy' ) -> wait ( ) ; }
Sets the access control policy on the specified resource. Replaces any
existing policy.

Sample code:
```
$keyManagementServiceClient = new KeyManagementServiceClient();
try {
$formattedResource = $keyManagementServiceClient->keyRingName('[PROJECT]', '[LOCATION]', '[KEY_RING]');
$policy = new Policy();
$response = $keyManagementServiceClient->setIamPolicy($formattedResource, $policy);
} finally {
$keyManagementServiceClient->close();
}
```

@param string $resource     REQUIRED: The resource for which the policy is being specified.
`resource` is usually specified as a path. For example, a Project
resource is specified as `projects/{project}`.
@param Policy $policy       REQUIRED: The complete policy to be applied to the `resource`. The size of
the policy is limited to a few 10s of KB. An empty policy is a
valid policy but certain Cloud Platform services (such as Projects)
might reject them.
@param array  $optionalArgs {
Optional.

@type RetrySettings|array $retrySettings
Retry settings to use for this call. Can be a
{@see Google\ApiCore\RetrySettings} object, or an associative array
of retry settings parameters. See the documentation on
{@see Google\ApiCore\RetrySettings} for example usage.
}

@return \Google\Cloud\Iam\V1\Policy

@throws ApiException if the remote call fails
@experimental
Sets the access control policy on the specified resource . Replaces any existing policy .