Class TopicAdminClient

  • All Implemented Interfaces:
    com.google.api.gax.core.BackgroundResource, AutoCloseable

    @Generated("by gapic-generator-java")
    public class TopicAdminClient
    extends Object
    implements com.google.api.gax.core.BackgroundResource
    Service Description: The service that an application uses to manipulate topics, and to send messages to a topic.

    This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:

    
     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
       TopicName name = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]");
       Topic response = topicAdminClient.createTopic(name);
     }
     

    Note: close() needs to be called on the TopicAdminClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

    The surface of this class includes several types of Java methods for each of the API's methods:

    1. A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
    2. A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
    3. A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.

    See the individual methods for example code.

    Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.

    This class can be customized by passing in a custom instance of TopicAdminSettings to create(). For example:

    To customize credentials:

    
     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     TopicAdminSettings topicAdminSettings =
         TopicAdminSettings.newBuilder()
             .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
             .build();
     TopicAdminClient topicAdminClient = TopicAdminClient.create(topicAdminSettings);
     

    To customize the endpoint:

    
     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     TopicAdminSettings topicAdminSettings =
         TopicAdminSettings.newBuilder().setEndpoint(myEndpoint).build();
     TopicAdminClient topicAdminClient = TopicAdminClient.create(topicAdminSettings);
     

    To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:

    
     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     TopicAdminSettings topicAdminSettings = TopicAdminSettings.newHttpJsonBuilder().build();
     TopicAdminClient topicAdminClient = TopicAdminClient.create(topicAdminSettings);
     

    Please refer to the GitHub repository's samples for more quickstart code snippets.

    • Constructor Detail

      • TopicAdminClient

        protected TopicAdminClient​(TopicAdminSettings settings)
                            throws IOException
        Constructs an instance of TopicAdminClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
        Throws:
        IOException
      • TopicAdminClient

        protected TopicAdminClient​(PublisherStub stub)
    • Method Detail

      • create

        public static final TopicAdminClient create​(TopicAdminSettings settings)
                                             throws IOException
        Constructs an instance of TopicAdminClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
        Throws:
        IOException
      • create

        public static final TopicAdminClient create​(PublisherStub stub)
        Constructs an instance of TopicAdminClient, using the given stub for making calls. This is for advanced usage - prefer using create(TopicAdminSettings).
      • createTopic

        public final Topic createTopic​(TopicName name)
        Creates the given topic with the given name. See the [resource name rules] (https://cloud.google.com/pubsub/docs/admin#resource_names).

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           TopicName name = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]");
           Topic response = topicAdminClient.createTopic(name);
         }
         
        Parameters:
        name - Required. 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"`.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • createTopic

        public final Topic createTopic​(String name)
        Creates the given topic with the given name. See the [resource name rules] (https://cloud.google.com/pubsub/docs/admin#resource_names).

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           String name = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString();
           Topic response = topicAdminClient.createTopic(name);
         }
         
        Parameters:
        name - Required. 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"`.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • createTopic

        @Deprecated
        public final Topic createTopic​(ProjectTopicName name)
        Deprecated.
        Creates the given topic with the given name. See the <a href="https://cloud.google.com/pubsub/docs/admin#resource_names"> resource name rules</a>.

        Sample code:

        
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           ProjectTopicName name = ProjectTopicName.of("[PROJECT]", "[TOPIC]");
           Topic response = topicAdminClient.createTopic(name);
         }
         
        Parameters:
        name - Required. 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"`.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • createTopic

        public final Topic createTopic​(Topic request)
        Creates the given topic with the given name. See the [resource name rules] (https://cloud.google.com/pubsub/docs/admin#resource_names).

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           Topic request =
               Topic.newBuilder()
                   .setName(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
                   .putAllLabels(new HashMap<String, String>())
                   .setMessageStoragePolicy(MessageStoragePolicy.newBuilder().build())
                   .setKmsKeyName("kmsKeyName412586233")
                   .setSchemaSettings(SchemaSettings.newBuilder().build())
                   .setSatisfiesPzs(true)
                   .setMessageRetentionDuration(Duration.newBuilder().build())
                   .build();
           Topic response = topicAdminClient.createTopic(request);
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • createTopicCallable

        public final com.google.api.gax.rpc.UnaryCallable<Topic,​Topic> createTopicCallable()
        Creates the given topic with the given name. See the [resource name rules] (https://cloud.google.com/pubsub/docs/admin#resource_names).

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           Topic request =
               Topic.newBuilder()
                   .setName(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
                   .putAllLabels(new HashMap<String, String>())
                   .setMessageStoragePolicy(MessageStoragePolicy.newBuilder().build())
                   .setKmsKeyName("kmsKeyName412586233")
                   .setSchemaSettings(SchemaSettings.newBuilder().build())
                   .setSatisfiesPzs(true)
                   .setMessageRetentionDuration(Duration.newBuilder().build())
                   .build();
           ApiFuture<Topic> future = topicAdminClient.createTopicCallable().futureCall(request);
           // Do something.
           Topic response = future.get();
         }
         
      • updateTopic

        public final Topic updateTopic​(Topic topic,
                                       com.google.protobuf.FieldMask updateMask)
        Updates an existing topic. Note that certain properties of a topic are not modifiable.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           Topic topic = Topic.newBuilder().build();
           FieldMask updateMask = FieldMask.newBuilder().build();
           Topic response = topicAdminClient.updateTopic(topic, updateMask);
         }
         
        Parameters:
        topic - Required. The updated topic object.
        updateMask - Required. Indicates which fields in the provided topic to update. Must be specified and non-empty. Note that if `update_mask` contains "message_storage_policy" but the `message_storage_policy` is not set in the `topic` provided above, then the updated value is determined by the policy configured at the project or organization level.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • updateTopic

        public final Topic updateTopic​(UpdateTopicRequest request)
        Updates an existing topic. Note that certain properties of a topic are not modifiable.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           UpdateTopicRequest request =
               UpdateTopicRequest.newBuilder()
                   .setTopic(Topic.newBuilder().build())
                   .setUpdateMask(FieldMask.newBuilder().build())
                   .build();
           Topic response = topicAdminClient.updateTopic(request);
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • updateTopicCallable

        public final com.google.api.gax.rpc.UnaryCallable<UpdateTopicRequest,​Topic> updateTopicCallable()
        Updates an existing topic. Note that certain properties of a topic are not modifiable.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           UpdateTopicRequest request =
               UpdateTopicRequest.newBuilder()
                   .setTopic(Topic.newBuilder().build())
                   .setUpdateMask(FieldMask.newBuilder().build())
                   .build();
           ApiFuture<Topic> future = topicAdminClient.updateTopicCallable().futureCall(request);
           // Do something.
           Topic response = future.get();
         }
         
      • publish

        public final PublishResponse publish​(TopicName topic,
                                             List<PubsubMessage> messages)
        Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic does not exist.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           TopicName topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]");
           List<PubsubMessage> messages = new ArrayList<>();
           PublishResponse response = topicAdminClient.publish(topic, messages);
         }
         
        Parameters:
        topic - Required. The messages in the request will be published on this topic. Format is `projects/{project}/topics/{topic}`.
        messages - Required. The messages to publish.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • publish

        public final PublishResponse publish​(String topic,
                                             List<PubsubMessage> messages)
        Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic does not exist.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           String topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString();
           List<PubsubMessage> messages = new ArrayList<>();
           PublishResponse response = topicAdminClient.publish(topic, messages);
         }
         
        Parameters:
        topic - Required. The messages in the request will be published on this topic. Format is `projects/{project}/topics/{topic}`.
        messages - Required. The messages to publish.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • publish

        public final PublishResponse publish​(PublishRequest request)
        Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic does not exist.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           PublishRequest request =
               PublishRequest.newBuilder()
                   .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
                   .addAllMessages(new ArrayList<PubsubMessage>())
                   .build();
           PublishResponse response = topicAdminClient.publish(request);
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • publishCallable

        public final com.google.api.gax.rpc.UnaryCallable<PublishRequest,​PublishResponse> publishCallable()
        Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic does not exist.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           PublishRequest request =
               PublishRequest.newBuilder()
                   .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
                   .addAllMessages(new ArrayList<PubsubMessage>())
                   .build();
           ApiFuture<PublishResponse> future = topicAdminClient.publishCallable().futureCall(request);
           // Do something.
           PublishResponse response = future.get();
         }
         
      • getTopic

        public final Topic getTopic​(TopicName topic)
        Gets the configuration of a topic.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           TopicName topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]");
           Topic response = topicAdminClient.getTopic(topic);
         }
         
        Parameters:
        topic - Required. The name of the topic to get. Format is `projects/{project}/topics/{topic}`.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • getTopic

        public final Topic getTopic​(String topic)
        Gets the configuration of a topic.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           String topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString();
           Topic response = topicAdminClient.getTopic(topic);
         }
         
        Parameters:
        topic - Required. The name of the topic to get. Format is `projects/{project}/topics/{topic}`.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • getTopic

        @Deprecated
        public final Topic getTopic​(ProjectTopicName topic)
        Deprecated.
        Use getTopic(TopicName) instead.
        Gets the configuration of a topic.

        Sample code:

        
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           ProjectTopicName topic = ProjectTopicName.of("[PROJECT]", "[TOPIC]");
           Topic response = topicAdminClient.getTopic(topic);
         }
         
        Parameters:
        topic - Required. The name of the topic to get. Format is `projects/{project}/topics/{topic}`.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • getTopic

        public final Topic getTopic​(GetTopicRequest request)
        Gets the configuration of a topic.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           GetTopicRequest request =
               GetTopicRequest.newBuilder()
                   .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
                   .build();
           Topic response = topicAdminClient.getTopic(request);
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • getTopicCallable

        public final com.google.api.gax.rpc.UnaryCallable<GetTopicRequest,​Topic> getTopicCallable()
        Gets the configuration of a topic.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           GetTopicRequest request =
               GetTopicRequest.newBuilder()
                   .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
                   .build();
           ApiFuture<Topic> future = topicAdminClient.getTopicCallable().futureCall(request);
           // Do something.
           Topic response = future.get();
         }
         
      • listTopics

        public final TopicAdminClient.ListTopicsPagedResponse listTopics​(ProjectName project)
        Lists matching topics.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           ProjectName project = ProjectName.of("[PROJECT]");
           for (Topic element : topicAdminClient.listTopics(project).iterateAll()) {
             // doThingsWith(element);
           }
         }
         
        Parameters:
        project - Required. The name of the project in which to list topics. Format is `projects/{project-id}`.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • listTopics

        public final TopicAdminClient.ListTopicsPagedResponse listTopics​(String project)
        Lists matching topics.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           String project = ProjectName.of("[PROJECT]").toString();
           for (Topic element : topicAdminClient.listTopics(project).iterateAll()) {
             // doThingsWith(element);
           }
         }
         
        Parameters:
        project - Required. The name of the project in which to list topics. Format is `projects/{project-id}`.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • listTopics

        public final TopicAdminClient.ListTopicsPagedResponse listTopics​(ListTopicsRequest request)
        Lists matching topics.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           ListTopicsRequest request =
               ListTopicsRequest.newBuilder()
                   .setProject(ProjectName.of("[PROJECT]").toString())
                   .setPageSize(883849137)
                   .setPageToken("pageToken873572522")
                   .build();
           for (Topic element : topicAdminClient.listTopics(request).iterateAll()) {
             // doThingsWith(element);
           }
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • listTopicsPagedCallable

        public final com.google.api.gax.rpc.UnaryCallable<ListTopicsRequest,​TopicAdminClient.ListTopicsPagedResponse> listTopicsPagedCallable()
        Lists matching topics.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           ListTopicsRequest request =
               ListTopicsRequest.newBuilder()
                   .setProject(ProjectName.of("[PROJECT]").toString())
                   .setPageSize(883849137)
                   .setPageToken("pageToken873572522")
                   .build();
           ApiFuture<Topic> future = topicAdminClient.listTopicsPagedCallable().futureCall(request);
           // Do something.
           for (Topic element : future.get().iterateAll()) {
             // doThingsWith(element);
           }
         }
         
      • listTopicsCallable

        public final com.google.api.gax.rpc.UnaryCallable<ListTopicsRequest,​ListTopicsResponse> listTopicsCallable()
        Lists matching topics.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           ListTopicsRequest request =
               ListTopicsRequest.newBuilder()
                   .setProject(ProjectName.of("[PROJECT]").toString())
                   .setPageSize(883849137)
                   .setPageToken("pageToken873572522")
                   .build();
           while (true) {
             ListTopicsResponse response = topicAdminClient.listTopicsCallable().call(request);
             for (Topic element : response.getTopicsList()) {
               // doThingsWith(element);
             }
             String nextPageToken = response.getNextPageToken();
             if (!Strings.isNullOrEmpty(nextPageToken)) {
               request = request.toBuilder().setPageToken(nextPageToken).build();
             } else {
               break;
             }
           }
         }
         
      • listTopicSubscriptions

        public final TopicAdminClient.ListTopicSubscriptionsPagedResponse listTopicSubscriptions​(TopicName topic)
        Lists the names of the attached subscriptions on this topic.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           TopicName topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]");
           for (String element : topicAdminClient.listTopicSubscriptions(topic).iterateAll()) {
             // doThingsWith(element);
           }
         }
         
        Parameters:
        topic - Required. The name of the topic that subscriptions are attached to. Format is `projects/{project}/topics/{topic}`.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • listTopicSubscriptions

        public final TopicAdminClient.ListTopicSubscriptionsPagedResponse listTopicSubscriptions​(String topic)
        Lists the names of the attached subscriptions on this topic.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           String topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString();
           for (String element : topicAdminClient.listTopicSubscriptions(topic).iterateAll()) {
             // doThingsWith(element);
           }
         }
         
        Parameters:
        topic - Required. The name of the topic that subscriptions are attached to. Format is `projects/{project}/topics/{topic}`.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • listTopicSubscriptions

        @Deprecated
        public final TopicAdminClient.ListTopicSubscriptionsPagedResponse listTopicSubscriptions​(ProjectTopicName topic)
        Deprecated.
        Lists the names of the subscriptions on this topic.

        Sample code:

        
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           ProjectTopicName topic = ProjectTopicName.of("[PROJECT]", "[TOPIC]");
           for (ProjectSubscriptionName element : topicAdminClient.listTopicSubscriptions(topic).iterateAllAsProjectSubscriptionName()) {
             // doThingsWith(element);
           }
         }
         
        Parameters:
        topic - Required. The name of the topic that subscriptions are attached to. Format is `projects/{project}/topics/{topic}`.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • listTopicSubscriptions

        public final TopicAdminClient.ListTopicSubscriptionsPagedResponse listTopicSubscriptions​(ListTopicSubscriptionsRequest request)
        Lists the names of the attached subscriptions on this topic.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           ListTopicSubscriptionsRequest request =
               ListTopicSubscriptionsRequest.newBuilder()
                   .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
                   .setPageSize(883849137)
                   .setPageToken("pageToken873572522")
                   .build();
           for (String element : topicAdminClient.listTopicSubscriptions(request).iterateAll()) {
             // doThingsWith(element);
           }
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • listTopicSubscriptionsPagedCallable

        public final com.google.api.gax.rpc.UnaryCallable<ListTopicSubscriptionsRequest,​TopicAdminClient.ListTopicSubscriptionsPagedResponse> listTopicSubscriptionsPagedCallable()
        Lists the names of the attached subscriptions on this topic.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           ListTopicSubscriptionsRequest request =
               ListTopicSubscriptionsRequest.newBuilder()
                   .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
                   .setPageSize(883849137)
                   .setPageToken("pageToken873572522")
                   .build();
           ApiFuture<String> future =
               topicAdminClient.listTopicSubscriptionsPagedCallable().futureCall(request);
           // Do something.
           for (String element : future.get().iterateAll()) {
             // doThingsWith(element);
           }
         }
         
      • listTopicSubscriptionsCallable

        public final com.google.api.gax.rpc.UnaryCallable<ListTopicSubscriptionsRequest,​ListTopicSubscriptionsResponse> listTopicSubscriptionsCallable()
        Lists the names of the attached subscriptions on this topic.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           ListTopicSubscriptionsRequest request =
               ListTopicSubscriptionsRequest.newBuilder()
                   .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
                   .setPageSize(883849137)
                   .setPageToken("pageToken873572522")
                   .build();
           while (true) {
             ListTopicSubscriptionsResponse response =
                 topicAdminClient.listTopicSubscriptionsCallable().call(request);
             for (String element : response.getSubscriptionsList()) {
               // doThingsWith(element);
             }
             String nextPageToken = response.getNextPageToken();
             if (!Strings.isNullOrEmpty(nextPageToken)) {
               request = request.toBuilder().setPageToken(nextPageToken).build();
             } else {
               break;
             }
           }
         }
         
      • listTopicSnapshots

        public final TopicAdminClient.ListTopicSnapshotsPagedResponse listTopicSnapshots​(TopicName topic)
        Lists the names of the snapshots on this topic. Snapshots are used in [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           TopicName topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]");
           for (String element : topicAdminClient.listTopicSnapshots(topic).iterateAll()) {
             // doThingsWith(element);
           }
         }
         
        Parameters:
        topic - Required. The name of the topic that snapshots are attached to. Format is `projects/{project}/topics/{topic}`.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • listTopicSnapshots

        public final TopicAdminClient.ListTopicSnapshotsPagedResponse listTopicSnapshots​(String topic)
        Lists the names of the snapshots on this topic. Snapshots are used in [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           String topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString();
           for (String element : topicAdminClient.listTopicSnapshots(topic).iterateAll()) {
             // doThingsWith(element);
           }
         }
         
        Parameters:
        topic - Required. The name of the topic that snapshots are attached to. Format is `projects/{project}/topics/{topic}`.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • listTopicSnapshots

        public final TopicAdminClient.ListTopicSnapshotsPagedResponse listTopicSnapshots​(ListTopicSnapshotsRequest request)
        Lists the names of the snapshots on this topic. Snapshots are used in [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           ListTopicSnapshotsRequest request =
               ListTopicSnapshotsRequest.newBuilder()
                   .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
                   .setPageSize(883849137)
                   .setPageToken("pageToken873572522")
                   .build();
           for (String element : topicAdminClient.listTopicSnapshots(request).iterateAll()) {
             // doThingsWith(element);
           }
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • listTopicSnapshotsPagedCallable

        public final com.google.api.gax.rpc.UnaryCallable<ListTopicSnapshotsRequest,​TopicAdminClient.ListTopicSnapshotsPagedResponse> listTopicSnapshotsPagedCallable()
        Lists the names of the snapshots on this topic. Snapshots are used in [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           ListTopicSnapshotsRequest request =
               ListTopicSnapshotsRequest.newBuilder()
                   .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
                   .setPageSize(883849137)
                   .setPageToken("pageToken873572522")
                   .build();
           ApiFuture<String> future =
               topicAdminClient.listTopicSnapshotsPagedCallable().futureCall(request);
           // Do something.
           for (String element : future.get().iterateAll()) {
             // doThingsWith(element);
           }
         }
         
      • listTopicSnapshotsCallable

        public final com.google.api.gax.rpc.UnaryCallable<ListTopicSnapshotsRequest,​ListTopicSnapshotsResponse> listTopicSnapshotsCallable()
        Lists the names of the snapshots on this topic. Snapshots are used in [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           ListTopicSnapshotsRequest request =
               ListTopicSnapshotsRequest.newBuilder()
                   .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
                   .setPageSize(883849137)
                   .setPageToken("pageToken873572522")
                   .build();
           while (true) {
             ListTopicSnapshotsResponse response =
                 topicAdminClient.listTopicSnapshotsCallable().call(request);
             for (String element : response.getSnapshotsList()) {
               // doThingsWith(element);
             }
             String nextPageToken = response.getNextPageToken();
             if (!Strings.isNullOrEmpty(nextPageToken)) {
               request = request.toBuilder().setPageToken(nextPageToken).build();
             } else {
               break;
             }
           }
         }
         
      • deleteTopic

        public final void deleteTopic​(TopicName topic)
        Deletes the topic with the given name. Returns `NOT_FOUND` if the topic does not exist. After a topic is deleted, a new topic may be created with the same name; this is an entirely new topic with none of the old configuration or subscriptions. Existing subscriptions to this topic are not deleted, but their `topic` field is set to `_deleted-topic_`.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           TopicName topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]");
           topicAdminClient.deleteTopic(topic);
         }
         
        Parameters:
        topic - Required. Name of the topic to delete. Format is `projects/{project}/topics/{topic}`.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • deleteTopic

        public final void deleteTopic​(String topic)
        Deletes the topic with the given name. Returns `NOT_FOUND` if the topic does not exist. After a topic is deleted, a new topic may be created with the same name; this is an entirely new topic with none of the old configuration or subscriptions. Existing subscriptions to this topic are not deleted, but their `topic` field is set to `_deleted-topic_`.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           String topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString();
           topicAdminClient.deleteTopic(topic);
         }
         
        Parameters:
        topic - Required. Name of the topic to delete. Format is `projects/{project}/topics/{topic}`.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • deleteTopic

        @Deprecated
        public final void deleteTopic​(ProjectTopicName topic)
        Deprecated.
        Deletes the topic with the given name. Returns `NOT_FOUND` if the topic does not exist. After a topic is deleted, a new topic may be created with the same name; this is an entirely new topic with none of the old configuration or subscriptions. Existing subscriptions to this topic are not deleted, but their `topic` field is set to `_deleted-topic_`.

        Sample code:

        
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           ProjectTopicName topic = ProjectTopicName.of("[PROJECT]", "[TOPIC]");
           topicAdminClient.deleteTopic(topic);
         }
         
        Parameters:
        topic - Required. Name of the topic to delete. Format is `projects/{project}/topics/{topic}`.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • deleteTopic

        public final void deleteTopic​(DeleteTopicRequest request)
        Deletes the topic with the given name. Returns `NOT_FOUND` if the topic does not exist. After a topic is deleted, a new topic may be created with the same name; this is an entirely new topic with none of the old configuration or subscriptions. Existing subscriptions to this topic are not deleted, but their `topic` field is set to `_deleted-topic_`.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           DeleteTopicRequest request =
               DeleteTopicRequest.newBuilder()
                   .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
                   .build();
           topicAdminClient.deleteTopic(request);
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • deleteTopicCallable

        public final com.google.api.gax.rpc.UnaryCallable<DeleteTopicRequest,​com.google.protobuf.Empty> deleteTopicCallable()
        Deletes the topic with the given name. Returns `NOT_FOUND` if the topic does not exist. After a topic is deleted, a new topic may be created with the same name; this is an entirely new topic with none of the old configuration or subscriptions. Existing subscriptions to this topic are not deleted, but their `topic` field is set to `_deleted-topic_`.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           DeleteTopicRequest request =
               DeleteTopicRequest.newBuilder()
                   .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
                   .build();
           ApiFuture<Empty> future = topicAdminClient.deleteTopicCallable().futureCall(request);
           // Do something.
           future.get();
         }
         
      • detachSubscription

        public final DetachSubscriptionResponse detachSubscription​(DetachSubscriptionRequest request)
        Detaches a subscription from this topic. All messages retained in the subscription are dropped. Subsequent `Pull` and `StreamingPull` requests will return FAILED_PRECONDITION. If the subscription is a push subscription, pushes to the endpoint will stop.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           DetachSubscriptionRequest request =
               DetachSubscriptionRequest.newBuilder()
                   .setSubscription(SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString())
                   .build();
           DetachSubscriptionResponse response = topicAdminClient.detachSubscription(request);
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • detachSubscriptionCallable

        public final com.google.api.gax.rpc.UnaryCallable<DetachSubscriptionRequest,​DetachSubscriptionResponse> detachSubscriptionCallable()
        Detaches a subscription from this topic. All messages retained in the subscription are dropped. Subsequent `Pull` and `StreamingPull` requests will return FAILED_PRECONDITION. If the subscription is a push subscription, pushes to the endpoint will stop.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           DetachSubscriptionRequest request =
               DetachSubscriptionRequest.newBuilder()
                   .setSubscription(SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString())
                   .build();
           ApiFuture<DetachSubscriptionResponse> future =
               topicAdminClient.detachSubscriptionCallable().futureCall(request);
           // Do something.
           DetachSubscriptionResponse response = future.get();
         }
         
      • setIamPolicy

        public final com.google.iam.v1.Policy setIamPolicy​(com.google.iam.v1.SetIamPolicyRequest request)
        Sets the access control policy on the specified resource. Replacesany existing policy.

        Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           SetIamPolicyRequest request =
               SetIamPolicyRequest.newBuilder()
                   .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString())
                   .setPolicy(Policy.newBuilder().build())
                   .setUpdateMask(FieldMask.newBuilder().build())
                   .build();
           Policy response = topicAdminClient.setIamPolicy(request);
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • setIamPolicy

        @Deprecated
        public final com.google.iam.v1.Policy setIamPolicy​(String resource,
                                                           com.google.iam.v1.Policy policy)
        Deprecated.
        Sets the access control policy on the specified resource. Replaces any existing policy.

        Can return Public Errors: NOT_FOUND, INVALID_ARGUMENT and PERMISSION_DENIED

        Sample code:

        
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           String formattedResource = ProjectTopicName.format("[PROJECT]", "[TOPIC]");
           Policy policy = Policy.newBuilder().build();
           Policy response = topicAdminClient.setIamPolicy(formattedResource, policy);
         }
         
        Parameters:
        resource - REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.
        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.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • setIamPolicyCallable

        public final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,​com.google.iam.v1.Policy> setIamPolicyCallable()
        Sets the access control policy on the specified resource. Replacesany existing policy.

        Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           SetIamPolicyRequest request =
               SetIamPolicyRequest.newBuilder()
                   .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString())
                   .setPolicy(Policy.newBuilder().build())
                   .setUpdateMask(FieldMask.newBuilder().build())
                   .build();
           ApiFuture<Policy> future = topicAdminClient.setIamPolicyCallable().futureCall(request);
           // Do something.
           Policy response = future.get();
         }
         
      • getIamPolicy

        public final com.google.iam.v1.Policy getIamPolicy​(com.google.iam.v1.GetIamPolicyRequest request)
        Gets the access control policy for a resource. Returns an empty policyif the resource exists and does not have a policy set.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           GetIamPolicyRequest request =
               GetIamPolicyRequest.newBuilder()
                   .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString())
                   .setOptions(GetPolicyOptions.newBuilder().build())
                   .build();
           Policy response = topicAdminClient.getIamPolicy(request);
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • getIamPolicy

        @Deprecated
        public final com.google.iam.v1.Policy getIamPolicy​(String resource)
        Deprecated.
        Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.

        Sample code:

        
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           String formattedResource = ProjectTopicName.format("[PROJECT]", "[TOPIC]");
           Policy response = topicAdminClient.getIamPolicy(formattedResource);
         }
         
        Parameters:
        resource - REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • getIamPolicyCallable

        public final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,​com.google.iam.v1.Policy> getIamPolicyCallable()
        Gets the access control policy for a resource. Returns an empty policyif the resource exists and does not have a policy set.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           GetIamPolicyRequest request =
               GetIamPolicyRequest.newBuilder()
                   .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString())
                   .setOptions(GetPolicyOptions.newBuilder().build())
                   .build();
           ApiFuture<Policy> future = topicAdminClient.getIamPolicyCallable().futureCall(request);
           // Do something.
           Policy response = future.get();
         }
         
      • testIamPermissions

        public final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions​(com.google.iam.v1.TestIamPermissionsRequest request)
        Returns permissions that a caller has on the specified resource. If theresource does not exist, this will return an empty set ofpermissions, not a `NOT_FOUND` error.

        Note: This operation is designed to be used for buildingpermission-aware UIs and command-line tools, not for authorizationchecking. This operation may "fail open" without warning.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           TestIamPermissionsRequest request =
               TestIamPermissionsRequest.newBuilder()
                   .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString())
                   .addAllPermissions(new ArrayList<String>())
                   .build();
           TestIamPermissionsResponse response = topicAdminClient.testIamPermissions(request);
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • testIamPermissions

        @Deprecated
        public final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions​(String resource,
                                                                                     List<String> permissions)
        Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.

        Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.

        Sample code:

        
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           String formattedResource = ProjectTopicName.format("[PROJECT]", "[TOPIC]");
           List<String> permissions = new ArrayList<>();
           TestIamPermissionsResponse response = topicAdminClient.testIamPermissions(formattedResource, permissions);
         }
         
        Parameters:
        resource - REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.
        permissions - 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).
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • testIamPermissionsCallable

        public final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,​com.google.iam.v1.TestIamPermissionsResponse> testIamPermissionsCallable()
        Returns permissions that a caller has on the specified resource. If theresource does not exist, this will return an empty set ofpermissions, not a `NOT_FOUND` error.

        Note: This operation is designed to be used for buildingpermission-aware UIs and command-line tools, not for authorizationchecking. This operation may "fail open" without warning.

        Sample code:

        
         // This snippet has been automatically generated and should be regarded as a code template only.
         // It will require modifications to work:
         // - It may require correct/in-range values for request initialization.
         // - It may require specifying regional endpoints when creating the service client as shown in
         // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
         try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
           TestIamPermissionsRequest request =
               TestIamPermissionsRequest.newBuilder()
                   .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString())
                   .addAllPermissions(new ArrayList<String>())
                   .build();
           ApiFuture<TestIamPermissionsResponse> future =
               topicAdminClient.testIamPermissionsCallable().futureCall(request);
           // Do something.
           TestIamPermissionsResponse response = future.get();
         }
         
      • shutdown

        public void shutdown()
        Specified by:
        shutdown in interface com.google.api.gax.core.BackgroundResource
      • isShutdown

        public boolean isShutdown()
        Specified by:
        isShutdown in interface com.google.api.gax.core.BackgroundResource
      • isTerminated

        public boolean isTerminated()
        Specified by:
        isTerminated in interface com.google.api.gax.core.BackgroundResource
      • shutdownNow

        public void shutdownNow()
        Specified by:
        shutdownNow in interface com.google.api.gax.core.BackgroundResource