Search in sources :

Example 1 with ModifyPushConfigRequest

use of com.google.pubsub.v1.ModifyPushConfigRequest in project google-cloud-java by GoogleCloudPlatform.

the class SubscriptionAdminClient method modifyPushConfig.

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
   * Modifies the `PushConfig` for a specified subscription.
   *
   * <p>This may be used to change a push subscription to a pull one (signified by an empty
   * `PushConfig`) or vice versa, or change the endpoint URL and other attributes of a push
   * subscription. Messages will accumulate for delivery continuously through the call regardless of
   * changes to the `PushConfig`.
   *
   * <p>Sample code:
   *
   * <pre><code>
   * try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
   *   SubscriptionName subscription = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
   *   PushConfig pushConfig = PushConfig.newBuilder().build();
   *   subscriptionAdminClient.modifyPushConfig(subscription, pushConfig);
   * }
   * </code></pre>
   *
   * @param subscription The name of the subscription. Format is
   *     `projects/{project}/subscriptions/{sub}`.
   * @param pushConfig The push configuration for future deliveries.
   *     <p>An empty `pushConfig` indicates that the Pub/Sub system should stop pushing messages
   *     from the given subscription and allow messages to be pulled and acknowledged - effectively
   *     pausing the subscription if `Pull` is not called.
   * @throws com.google.api.gax.grpc.ApiException if the remote call fails
   */
public final void modifyPushConfig(SubscriptionName subscription, PushConfig pushConfig) {
    ModifyPushConfigRequest request = ModifyPushConfigRequest.newBuilder().setSubscriptionWithSubscriptionName(subscription).setPushConfig(pushConfig).build();
    modifyPushConfig(request);
}
Also used : ModifyPushConfigRequest(com.google.pubsub.v1.ModifyPushConfigRequest)

Example 2 with ModifyPushConfigRequest

use of com.google.pubsub.v1.ModifyPushConfigRequest in project google-cloud-java by GoogleCloudPlatform.

the class SubscriptionAdminClientTest method modifyPushConfigTest.

@Test
@SuppressWarnings("all")
public void modifyPushConfigTest() {
    Empty expectedResponse = Empty.newBuilder().build();
    mockSubscriber.addResponse(expectedResponse);
    SubscriptionName subscription = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
    PushConfig pushConfig = PushConfig.newBuilder().build();
    client.modifyPushConfig(subscription, pushConfig);
    List<GeneratedMessageV3> actualRequests = mockSubscriber.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ModifyPushConfigRequest actualRequest = (ModifyPushConfigRequest) actualRequests.get(0);
    Assert.assertEquals(subscription, actualRequest.getSubscriptionAsSubscriptionName());
    Assert.assertEquals(pushConfig, actualRequest.getPushConfig());
}
Also used : PushConfig(com.google.pubsub.v1.PushConfig) Empty(com.google.protobuf.Empty) SubscriptionName(com.google.pubsub.v1.SubscriptionName) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) ModifyPushConfigRequest(com.google.pubsub.v1.ModifyPushConfigRequest) Test(org.junit.Test)

Aggregations

ModifyPushConfigRequest (com.google.pubsub.v1.ModifyPushConfigRequest)2 Empty (com.google.protobuf.Empty)1 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1 PushConfig (com.google.pubsub.v1.PushConfig)1 SubscriptionName (com.google.pubsub.v1.SubscriptionName)1 Test (org.junit.Test)1