Skip to content

Commit

Permalink
Add DetachSubscription RPC
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 313276022

Source-Author: Google APIs <noreply@google.com>
Source-Date: Tue May 26 15:11:32 2020 -0700
Source-Repo: googleapis/googleapis
Source-Sha: f5f268f5293e60143ac742a4eeb7dd6306ebf505
Source-Link: googleapis/googleapis@f5f268f
  • Loading branch information
yoshi-automation authored and jskeet committed May 27, 2020
1 parent 3b9798b commit 5f5b8aa
Show file tree
Hide file tree
Showing 7 changed files with 727 additions and 228 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1267,5 +1267,38 @@ public async Task DeleteTopicResourceNamesAsync()
await publisherServiceApiClient.DeleteTopicAsync(topic);
// End snippet
}

/// <summary>Snippet for DetachSubscription</summary>
public void DetachSubscriptionRequestObject()
{
// Snippet: DetachSubscription(DetachSubscriptionRequest, CallSettings)
// Create client
PublisherServiceApiClient publisherServiceApiClient = PublisherServiceApiClient.Create();
// Initialize request argument(s)
DetachSubscriptionRequest request = new DetachSubscriptionRequest
{
SubscriptionAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"),
};
// Make the request
DetachSubscriptionResponse response = publisherServiceApiClient.DetachSubscription(request);
// End snippet
}

/// <summary>Snippet for DetachSubscriptionAsync</summary>
public async Task DetachSubscriptionRequestObjectAsync()
{
// Snippet: DetachSubscriptionAsync(DetachSubscriptionRequest, CallSettings)
// Additional: DetachSubscriptionAsync(DetachSubscriptionRequest, CancellationToken)
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
DetachSubscriptionRequest request = new DetachSubscriptionRequest
{
SubscriptionAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"),
};
// Make the request
DetachSubscriptionResponse response = await publisherServiceApiClient.DetachSubscriptionAsync(request);
// End snippet
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -707,5 +707,39 @@ public void DeleteTopicResourceNames()
await client.DeleteTopicAsync(request.TopicAsTopicName, st::CancellationToken.None);
mockGrpcClient.VerifyAll();
}

[xunit::FactAttribute]
public void DetachSubscriptionRequestObject()
{
moq::Mock<Publisher.PublisherClient> mockGrpcClient = new moq::Mock<Publisher.PublisherClient>(moq::MockBehavior.Strict);
DetachSubscriptionRequest request = new DetachSubscriptionRequest
{
SubscriptionAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"),
};
DetachSubscriptionResponse expectedResponse = new DetachSubscriptionResponse { };
mockGrpcClient.Setup(x => x.DetachSubscription(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(expectedResponse);
PublisherServiceApiClient client = new PublisherServiceApiClientImpl(mockGrpcClient.Object, null);
DetachSubscriptionResponse response = client.DetachSubscription(request);
xunit::Assert.Same(expectedResponse, response);
mockGrpcClient.VerifyAll();
}

[xunit::FactAttribute]
public async stt::Task DetachSubscriptionRequestObjectAsync()
{
moq::Mock<Publisher.PublisherClient> mockGrpcClient = new moq::Mock<Publisher.PublisherClient>(moq::MockBehavior.Strict);
DetachSubscriptionRequest request = new DetachSubscriptionRequest
{
SubscriptionAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"),
};
DetachSubscriptionResponse expectedResponse = new DetachSubscriptionResponse { };
mockGrpcClient.Setup(x => x.DetachSubscriptionAsync(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall<DetachSubscriptionResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
PublisherServiceApiClient client = new PublisherServiceApiClientImpl(mockGrpcClient.Object, null);
DetachSubscriptionResponse responseCallSettings = await client.DetachSubscriptionAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));
xunit::Assert.Same(expectedResponse, responseCallSettings);
DetachSubscriptionResponse responseCancellationToken = await client.DetachSubscriptionAsync(request, st::CancellationToken.None);
xunit::Assert.Same(expectedResponse, responseCancellationToken);
mockGrpcClient.VerifyAll();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ private PublisherServiceApiSettings(PublisherServiceApiSettings existing) : base
ListTopicSubscriptionsSettings = existing.ListTopicSubscriptionsSettings;
ListTopicSnapshotsSettings = existing.ListTopicSnapshotsSettings;
DeleteTopicSettings = existing.DeleteTopicSettings;
DetachSubscriptionSettings = existing.DetachSubscriptionSettings;
OnCopy(existing);
}

Expand Down Expand Up @@ -157,6 +158,19 @@ private PublisherServiceApiSettings(PublisherServiceApiSettings existing) : base
/// </remarks>
public gaxgrpc::CallSettings DeleteTopicSettings { get; set; } = gaxgrpc::CallSettings.FromExpiration(gax::Expiration.None);

/// <summary>
/// <see cref="gaxgrpc::CallSettings"/> for synchronous and asynchronous calls to
/// <c>PublisherServiceApiClient.DetachSubscription</c> and <c>PublisherServiceApiClient.DetachSubscriptionAsync</c>
/// .
/// </summary>
/// <remarks>
/// <list type="bullet">
/// <item><description>This call will not be retried.</description></item>
/// <item><description>No timeout is applied.</description></item>
/// </list>
/// </remarks>
public gaxgrpc::CallSettings DetachSubscriptionSettings { get; set; } = gaxgrpc::CallSettings.FromExpiration(gax::Expiration.None);

/// <summary>Creates a deep clone of this object, with all the same property values.</summary>
/// <returns>A deep clone of this <see cref="PublisherServiceApiSettings"/> object.</returns>
public PublisherServiceApiSettings Clone() => new PublisherServiceApiSettings(this);
Expand Down Expand Up @@ -869,7 +883,7 @@ internal static PublisherServiceApiClient Create(grpccore::CallInvoker callInvok
}, callSettings);

/// <summary>
/// Lists the names of the subscriptions on this topic.
/// Lists the names of the attached subscriptions on this topic.
/// </summary>
/// <param name="request">The request object containing all of the parameters for the API call.</param>
/// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
Expand All @@ -878,7 +892,7 @@ internal static PublisherServiceApiClient Create(grpccore::CallInvoker callInvok
throw new sys::NotImplementedException();

/// <summary>
/// Lists the names of the subscriptions on this topic.
/// Lists the names of the attached subscriptions on this topic.
/// </summary>
/// <param name="request">The request object containing all of the parameters for the API call.</param>
/// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
Expand All @@ -887,7 +901,7 @@ internal static PublisherServiceApiClient Create(grpccore::CallInvoker callInvok
throw new sys::NotImplementedException();

/// <summary>
/// Lists the names of the subscriptions on this topic.
/// Lists the names of the attached subscriptions on this topic.
/// </summary>
/// <param name="topic">
/// Required. The name of the topic that subscriptions are attached to.
Expand All @@ -912,7 +926,7 @@ internal static PublisherServiceApiClient Create(grpccore::CallInvoker callInvok
}, callSettings);

/// <summary>
/// Lists the names of the subscriptions on this topic.
/// Lists the names of the attached subscriptions on this topic.
/// </summary>
/// <param name="topic">
/// Required. The name of the topic that subscriptions are attached to.
Expand All @@ -937,7 +951,7 @@ internal static PublisherServiceApiClient Create(grpccore::CallInvoker callInvok
}, callSettings);

/// <summary>
/// Lists the names of the subscriptions on this topic.
/// Lists the names of the attached subscriptions on this topic.
/// </summary>
/// <param name="topic">
/// Required. The name of the topic that subscriptions are attached to.
Expand All @@ -962,7 +976,7 @@ internal static PublisherServiceApiClient Create(grpccore::CallInvoker callInvok
}, callSettings);

/// <summary>
/// Lists the names of the subscriptions on this topic.
/// Lists the names of the attached subscriptions on this topic.
/// </summary>
/// <param name="topic">
/// Required. The name of the topic that subscriptions are attached to.
Expand Down Expand Up @@ -1280,6 +1294,42 @@ internal static PublisherServiceApiClient Create(grpccore::CallInvoker callInvok
/// <returns>A Task containing the RPC response.</returns>
public virtual stt::Task DeleteTopicAsync(TopicName topic, st::CancellationToken cancellationToken) =>
DeleteTopicAsync(topic, gaxgrpc::CallSettings.FromCancellationToken(cancellationToken));

/// <summary>
/// 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.
/// </summary>
/// <param name="request">The request object containing all of the parameters for the API call.</param>
/// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
/// <returns>The RPC response.</returns>
public virtual DetachSubscriptionResponse DetachSubscription(DetachSubscriptionRequest request, gaxgrpc::CallSettings callSettings = null) =>
throw new sys::NotImplementedException();

/// <summary>
/// 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.
/// </summary>
/// <param name="request">The request object containing all of the parameters for the API call.</param>
/// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
/// <returns>A Task containing the RPC response.</returns>
public virtual stt::Task<DetachSubscriptionResponse> DetachSubscriptionAsync(DetachSubscriptionRequest request, gaxgrpc::CallSettings callSettings = null) =>
throw new sys::NotImplementedException();

/// <summary>
/// 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.
/// </summary>
/// <param name="request">The request object containing all of the parameters for the API call.</param>
/// <param name="cancellationToken">A <see cref="st::CancellationToken"/> to use for this RPC.</param>
/// <returns>A Task containing the RPC response.</returns>
public virtual stt::Task<DetachSubscriptionResponse> DetachSubscriptionAsync(DetachSubscriptionRequest request, st::CancellationToken cancellationToken) =>
DetachSubscriptionAsync(request, gaxgrpc::CallSettings.FromCancellationToken(cancellationToken));
}

/// <summary>PublisherServiceApi client wrapper implementation, for convenient use.</summary>
Expand All @@ -1301,6 +1351,8 @@ public sealed partial class PublisherServiceApiClientImpl : PublisherServiceApiC

private readonly gaxgrpc::ApiCall<DeleteTopicRequest, wkt::Empty> _callDeleteTopic;

private readonly gaxgrpc::ApiCall<DetachSubscriptionRequest, DetachSubscriptionResponse> _callDetachSubscription;

/// <summary>
/// Constructs a client wrapper for the PublisherServiceApi service, with the specified gRPC client and
/// settings.
Expand Down Expand Up @@ -1336,6 +1388,9 @@ public PublisherServiceApiClientImpl(Publisher.PublisherClient grpcClient, Publi
_callDeleteTopic = clientHelper.BuildApiCall<DeleteTopicRequest, wkt::Empty>(grpcClient.DeleteTopicAsync, grpcClient.DeleteTopic, effectiveSettings.DeleteTopicSettings).WithGoogleRequestParam("topic", request => request.Topic);
Modify_ApiCall(ref _callDeleteTopic);
Modify_DeleteTopicApiCall(ref _callDeleteTopic);
_callDetachSubscription = clientHelper.BuildApiCall<DetachSubscriptionRequest, DetachSubscriptionResponse>(grpcClient.DetachSubscriptionAsync, grpcClient.DetachSubscription, effectiveSettings.DetachSubscriptionSettings).WithGoogleRequestParam("subscription", request => request.Subscription);
Modify_ApiCall(ref _callDetachSubscription);
Modify_DetachSubscriptionApiCall(ref _callDetachSubscription);
OnConstruction(grpcClient, effectiveSettings, clientHelper);
}

Expand All @@ -1357,6 +1412,8 @@ public PublisherServiceApiClientImpl(Publisher.PublisherClient grpcClient, Publi

partial void Modify_DeleteTopicApiCall(ref gaxgrpc::ApiCall<DeleteTopicRequest, wkt::Empty> call);

partial void Modify_DetachSubscriptionApiCall(ref gaxgrpc::ApiCall<DetachSubscriptionRequest, DetachSubscriptionResponse> call);

partial void OnConstruction(Publisher.PublisherClient grpcClient, PublisherServiceApiSettings effectiveSettings, gaxgrpc::ClientHelper clientHelper);

/// <summary>The underlying gRPC PublisherServiceApi client</summary>
Expand All @@ -1378,6 +1435,8 @@ public PublisherServiceApiClientImpl(Publisher.PublisherClient grpcClient, Publi

partial void Modify_DeleteTopicRequest(ref DeleteTopicRequest request, ref gaxgrpc::CallSettings settings);

partial void Modify_DetachSubscriptionRequest(ref DetachSubscriptionRequest request, ref gaxgrpc::CallSettings settings);

/// <summary>
/// Creates the given topic with the given name. See the
/// &amp;lt;a href="https://cloud.google.com/pubsub/docs/admin#resource_names"&amp;gt;
Expand Down Expand Up @@ -1507,7 +1566,7 @@ public override Topic GetTopic(GetTopicRequest request, gaxgrpc::CallSettings ca
}

/// <summary>
/// Lists the names of the subscriptions on this topic.
/// Lists the names of the attached subscriptions on this topic.
/// </summary>
/// <param name="request">The request object containing all of the parameters for the API call.</param>
/// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
Expand All @@ -1519,7 +1578,7 @@ public override Topic GetTopic(GetTopicRequest request, gaxgrpc::CallSettings ca
}

/// <summary>
/// Lists the names of the subscriptions on this topic.
/// Lists the names of the attached subscriptions on this topic.
/// </summary>
/// <param name="request">The request object containing all of the parameters for the API call.</param>
/// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
Expand Down Expand Up @@ -1595,6 +1654,36 @@ public override void DeleteTopic(DeleteTopicRequest request, gaxgrpc::CallSettin
Modify_DeleteTopicRequest(ref request, ref callSettings);
return _callDeleteTopic.Async(request, callSettings);
}

/// <summary>
/// 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.
/// </summary>
/// <param name="request">The request object containing all of the parameters for the API call.</param>
/// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
/// <returns>The RPC response.</returns>
public override DetachSubscriptionResponse DetachSubscription(DetachSubscriptionRequest request, gaxgrpc::CallSettings callSettings = null)
{
Modify_DetachSubscriptionRequest(ref request, ref callSettings);
return _callDetachSubscription.Sync(request, callSettings);
}

/// <summary>
/// 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.
/// </summary>
/// <param name="request">The request object containing all of the parameters for the API call.</param>
/// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
/// <returns>A Task containing the RPC response.</returns>
public override stt::Task<DetachSubscriptionResponse> DetachSubscriptionAsync(DetachSubscriptionRequest request, gaxgrpc::CallSettings callSettings = null)
{
Modify_DetachSubscriptionRequest(ref request, ref callSettings);
return _callDetachSubscription.Async(request, callSettings);
}
}

public partial class ListTopicsRequest : gaxgrpc::IPageRequest
Expand Down

0 comments on commit 5f5b8aa

Please sign in to comment.