Google\Cloud\PubSub\V1\PublisherClient::setIamPolicy PHP Method

setIamPolicy() public method

Sample code: try { $publisherClient = new PublisherClient(); $formattedResource = PublisherClient::formatTopicName("[PROJECT]", "[TOPIC]"); $policy = new Policy(); $response = $publisherClient->setIamPolicy($formattedResource, $policy); } finally { if (isset($publisherClient)) { $publisherClient->close(); } }
public setIamPolicy ( string $resource, google\iam\v1\Policy $policy, array $optionalArgs = [] ) : google\iam\v1\Policy
$resource string 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}`.
$policy google\iam\v1\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.
$optionalArgs array { Optional. @type \Google\GAX\RetrySettings $retrySettings Retry settings to use for this call. If present, then $timeoutMillis is ignored. @type int $timeoutMillis Timeout to use for this call. Only used if $retrySettings is not set. }
return google\iam\v1\Policy
    public function setIamPolicy($resource, $policy, $optionalArgs = [])
    {
        $request = new SetIamPolicyRequest();
        $request->setResource($resource);
        $request->setPolicy($policy);
        $mergedSettings = $this->defaultCallSettings['setIamPolicy']->merge(new CallSettings($optionalArgs));
        $callable = ApiCallable::createApiCall($this->iamPolicyStub, 'SetIamPolicy', $mergedSettings, $this->descriptors['setIamPolicy']);
        return $callable($request, [], ['call_credentials_callback' => $this->createCredentialsCallback()]);
    }