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

testIamPermissions() public method

If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error. Sample code: try { $publisherClient = new PublisherClient(); $formattedResource = PublisherClient::formatTopicName("[PROJECT]", "[TOPIC]"); $permissions = []; $response = $publisherClient->testIamPermissions($formattedResource, $permissions); } finally { if (isset($publisherClient)) { $publisherClient->close(); } }
public testIamPermissions ( string $resource, string[] $permissions, array $optionalArgs = [] ) : google\iam\v1\TestIamPermissionsResponse
$resource string REQUIRED: The resource for which the policy detail is being requested. `resource` is usually specified as a path. For example, a Project resource is specified as `projects/{project}`.
$permissions string[] The set of permissions to check for the `resource`. Permissions with wildcards (such as '*' or 'storage.*') are not allowed. For more information see [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
$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\TestIamPermissionsResponse
    public function testIamPermissions($resource, $permissions, $optionalArgs = [])
    {
        $request = new TestIamPermissionsRequest();
        $request->setResource($resource);
        foreach ($permissions as $elem) {
            $request->addPermissions($elem);
        }
        $mergedSettings = $this->defaultCallSettings['testIamPermissions']->merge(new CallSettings($optionalArgs));
        $callable = ApiCallable::createApiCall($this->iamPolicyStub, 'TestIamPermissions', $mergedSettings, $this->descriptors['testIamPermissions']);
        return $callable($request, [], ['call_credentials_callback' => $this->createCredentialsCallback()]);
    }