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);
}
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());
}
Aggregations