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

createTopic() public method

Sample code: try { $publisherClient = new PublisherClient(); $formattedName = PublisherClient::formatTopicName("[PROJECT]", "[TOPIC]"); $response = $publisherClient->createTopic($formattedName); } finally { if (isset($publisherClient)) { $publisherClient->close(); } }
public createTopic ( string $name, array $optionalArgs = [] ) : google\pubsub\v1\Topic
$name string The name of the topic. It must have the format `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter, and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters in length, and it must not start with `"goog"`.
$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\pubsub\v1\Topic
    public function createTopic($name, $optionalArgs = [])
    {
        $request = new Topic();
        $request->setName($name);
        $mergedSettings = $this->defaultCallSettings['createTopic']->merge(new CallSettings($optionalArgs));
        $callable = ApiCallable::createApiCall($this->publisherStub, 'CreateTopic', $mergedSettings, $this->descriptors['createTopic']);
        return $callable($request, [], ['call_credentials_callback' => $this->createCredentialsCallback()]);
    }