Google Cloud Pub/Sub C++ Client 2.13.0
A C++ Client Library for Google Cloud Pub/Sub
Loading...
Searching...
No Matches
subscription_admin_connection.h
1// Copyright 2020 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_SUBSCRIPTION_ADMIN_CONNECTION_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_SUBSCRIPTION_ADMIN_CONNECTION_H
17
18#include "google/cloud/pubsub/backoff_policy.h"
19#include "google/cloud/pubsub/connection_options.h"
20#include "google/cloud/pubsub/internal/subscriber_stub.h"
21#include "google/cloud/pubsub/retry_policy.h"
22#include "google/cloud/pubsub/snapshot.h"
23#include "google/cloud/pubsub/subscription.h"
24#include "google/cloud/pubsub/version.h"
25#include "google/cloud/internal/non_constructible.h"
26#include "google/cloud/internal/pagination_range.h"
27#include "google/cloud/status_or.h"
28#include <google/pubsub/v1/pubsub.pb.h>
29#include <initializer_list>
30#include <memory>
31#include <string>
32
33namespace google {
34namespace cloud {
35namespace pubsub {
36GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
37
38/**
39 * An input range to stream Cloud Pub/Sub subscriptions.
40 *
41 * This type models an [input range][cppref-input-range] of
42 * `google::pubsub::v1::Subscription` objects. Applications can make a
43 * single pass through the results.
44 *
45 * [cppref-input-range]: https://en.cppreference.com/w/cpp/ranges/input_range
46 */
47using ListSubscriptionsRange =
48 google::cloud::internal::PaginationRange<google::pubsub::v1::Subscription>;
49
50/**
51 * An input range to stream Cloud Pub/Sub snapshots.
52 *
53 * This type models an [input range][cppref-input-range] of
54 * `google::pubsub::v1::Snapshot` objects. Applications can make a
55 * single pass through the results.
56 *
57 * [cppref-input-range]: https://en.cppreference.com/w/cpp/ranges/input_range
58 */
59using ListSnapshotsRange =
60 google::cloud::internal::PaginationRange<google::pubsub::v1::Snapshot>;
61
62/**
63 * A connection to Cloud Pub/Sub for subscription-related administrative
64 * operations.
65 *
66 * This interface defines pure-virtual functions for each of the user-facing
67 * overload sets in `SubscriptionAdminClient`. That is, all of
68 * `SubscriptionAdminClient` overloads will forward to the one pure-virtual
69 * function declared in this interface. This allows users to inject custom
70 * behavior (e.g., with a Google Mock object) in a `SubscriptionAdminClient`
71 * object for use in their own tests.
72 *
73 * To create a concrete instance that connects you to the real Cloud Pub/Sub
74 * service, see `MakeSubscriptionAdminConnection()`.
75 *
76 * @par The *Params nested classes
77 * Applications may define classes derived from `SubscriptionAdminConnection`,
78 * for example, because they want to mock the class. To avoid breaking all such
79 * derived classes when we change the number or type of the arguments to the
80 * member functions we define lightweight structures to pass the arguments.
81 */
83 public:
84 virtual ~SubscriptionAdminConnection() = 0;
85
86 /// Wrap the arguments for `CreateSubscription()`
88 google::pubsub::v1::Subscription subscription;
89 };
90
91 /// Wrap the arguments for `GetSubscription()`
94 };
95
96 /// Wrap the arguments for `UpdateSubscription()`
98 google::pubsub::v1::UpdateSubscriptionRequest request;
99 };
100
101 /// Wrap the arguments for `ListSubscriptions()`
103 std::string project_id;
104 };
105
106 /// Wrap the arguments for `DeleteSubscription()`
109 };
110
111 /// Wrap the arguments for `ModifyPushConfig()`
113 google::pubsub::v1::ModifyPushConfigRequest request;
114 };
115
116 /// Wrap the arguments for `CreateSnapshot()`
117 struct CreateSnapshotParams {
118 google::pubsub::v1::CreateSnapshotRequest request;
119 };
120
121 /// Wrap the arguments for `GetSnapshot()`
122 struct GetSnapshotParams {
124 };
125
126 /// Wrap the arguments for `ListSnapshots()`
127 struct ListSnapshotsParams {
128 std::string project_id;
129 };
130
131 /// Wrap the arguments for `UpdateSnapshot()`
132 struct UpdateSnapshotParams {
133 google::pubsub::v1::UpdateSnapshotRequest request;
134 };
135
136 /// Wrap the arguments for `DeleteSnapshot()`
137 struct DeleteSnapshotParams {
139 };
140
141 /// Wrap the arguments for `Seek()`
142 struct SeekParams {
143 google::pubsub::v1::SeekRequest request;
144 };
145
146 /// Defines the interface for `SubscriptionAdminClient::CreateSubscription()`
147 virtual StatusOr<google::pubsub::v1::Subscription> CreateSubscription(
149
150 /// Defines the interface for `SubscriptionAdminClient::GetSubscription()`
151 virtual StatusOr<google::pubsub::v1::Subscription> GetSubscription(
153
154 /// Defines the interface for `SubscriptionAdminClient::UpdateSubscription()`
155 virtual StatusOr<google::pubsub::v1::Subscription> UpdateSubscription(
157
158 /// Defines the interface for `SubscriptionAdminClient::ListSubscriptions()`
159 virtual ListSubscriptionsRange ListSubscriptions(ListSubscriptionsParams);
160
161 /// Defines the interface for `SubscriptionAdminClient::DeleteSubscription()`
163
164 /// Defines the interface for `SubscriptionAdminClient::ModifyPushConfig()`
166
167 /// Defines the interface for `SnapshotAdminClient::CreateSnapshot()`
168 virtual StatusOr<google::pubsub::v1::Snapshot> CreateSnapshot(
170
171 /// Defines the interface for `SnapshotAdminClient::GetSnapshot()`
172 virtual StatusOr<google::pubsub::v1::Snapshot> GetSnapshot(GetSnapshotParams);
173
174 /// Defines the interface for `SnapshotAdminClient::UpdateSnapshot()`
175 virtual StatusOr<google::pubsub::v1::Snapshot> UpdateSnapshot(
177
178 /// Defines the interface for `SubscriptionAdminClient::ListSnapshots()`
179 virtual ListSnapshotsRange ListSnapshots(ListSnapshotsParams);
180
181 /// Defines the interface for `SnapshotAdminClient::DeleteSnapshot()`
183
184 /// Defines the interface for `SubscriptionAdminClient::Seek()`
185 virtual StatusOr<google::pubsub::v1::SeekResponse> Seek(SeekParams);
186
187 /// Return the options used to create the connection.
188 virtual Options options() const { return Options{}; }
189};
190
191/**
192 * Creates a new `SubscriptionAdminConnection` object to work with
193 * `SubscriptionAdminClient`.
194 *
195 * @note This function exists solely for backwards compatibility. It prevents
196 * existing code that calls `MakeSubscriptionAdminConnection({})` from
197 * breaking, due to ambiguity.
198 *
199 * @deprecated Please use `MakeSubscriptionAdminConnection()` instead.
200 */
201GOOGLE_CLOUD_CPP_DEPRECATED("use MakeSubscriptionAdminConnection() instead")
203 std::initializer_list<internal::NonConstructible>);
204
205/**
206 * Creates a new `SubscriptionAdminConnection` object to work with
207 * `SubscriptionAdminClient`.
208 *
209 * The `SubscriptionAdminConnection` class is provided for applications wanting
210 * to mock the `SubscriptionAdminClient` behavior in their tests. It is not
211 * intended for direct use.
212 *
213 * @par Performance
214 * Creating a new `SubscriptionAdminConnection` is relatively expensive. This
215 * typically initiates connections to the service, and therefore these objects
216 * should be shared and reused when possible. Note that gRPC reuses existing OS
217 * resources (sockets) whenever possible, so applications may experience better
218 * performance on the second (and subsequent) calls to this function with the
219 * same `Options` from `GrpcOptionList` and `CommonOptionList`. However, this
220 * behavior is not guaranteed and applications should not rely on it.
221 *
222 * @see `SubscriptionAdminClient`
223 *
224 * @param opts The options to use for this call. Expected options are any of
225 * the types in the following option lists.
226 * - `google::cloud::CommonOptionList`
227 * - `google::cloud::GrpcOptionList`
228 * - `google::cloud::pubsub::PolicyOptionList`
229 */
231 Options opts = {});
232
233/**
234 * Creates a new `SubscriptionAdminConnection` object to work with
235 * `SubscriptionAdminClient`.
236 *
237 * The `SubscriptionAdminConnection` class is not intended for direct use in
238 * applications, it is provided for applications wanting to mock the
239 * `SubscriptionAdminClient` behavior in their tests.
240 *
241 * @par Performance
242 * Creating a new `SubscriptionAdminConnection` is relatively expensive. This
243 * typically initiates connections to the service, and therefore these objects
244 * should be shared and reused when possible. Note that gRPC reuses existing OS
245 * resources (sockets) whenever possible, so applications may experience better
246 * performance on the second (and subsequent) calls to this function with the
247 * identical values for @p options. However, this behavior is not guaranteed
248 * and applications should not rely on it.
249 *
250 * @see `SubscriberConnection`
251 *
252 * @param options (optional) configure the `SubscriptionAdminConnection` created
253 * by this function.
254 * @param retry_policy control for how long (or how many times) are retryable
255 * RPCs attempted.
256 * @param backoff_policy controls the backoff behavior between retry attempts,
257 * typically some form of exponential backoff with jitter.
258 *
259 * @deprecated Please use the `MakeSubscriptionAdminConnection` function that
260 * accepts `google::cloud::Options` instead.
261 */
262GOOGLE_CLOUD_CPP_DEPRECATED(
263 "use the overload consuming google::cloud::Options instead")
265 ConnectionOptions const& options,
266 std::unique_ptr<pubsub::RetryPolicy const> retry_policy = {},
267 std::unique_ptr<pubsub::BackoffPolicy const> backoff_policy = {});
268
269GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
270} // namespace pubsub
271
272namespace pubsub_internal {
273GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
274
275std::shared_ptr<pubsub::SubscriptionAdminConnection>
276MakeTestSubscriptionAdminConnection(Options const& opts,
277 std::shared_ptr<SubscriberStub> stub);
278
279GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
280} // namespace pubsub_internal
281} // namespace cloud
282} // namespace google
283
284#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_SUBSCRIPTION_ADMIN_CONNECTION_H
Objects of this class identify a Cloud Pub/Sub snapshot.
Definition: snapshot.h:37
A connection to Cloud Pub/Sub for subscription-related administrative operations.
Definition: subscription_admin_connection.h:82
virtual Options options() const
Return the options used to create the connection.
Definition: subscription_admin_connection.h:188
virtual StatusOr< google::pubsub::v1::Snapshot > CreateSnapshot(CreateSnapshotParams)
Defines the interface for SnapshotAdminClient::CreateSnapshot()
virtual StatusOr< google::pubsub::v1::Subscription > GetSubscription(GetSubscriptionParams)
Defines the interface for SubscriptionAdminClient::GetSubscription()
virtual StatusOr< google::pubsub::v1::Snapshot > GetSnapshot(GetSnapshotParams)
Defines the interface for SnapshotAdminClient::GetSnapshot()
virtual Status DeleteSubscription(DeleteSubscriptionParams)
Defines the interface for SubscriptionAdminClient::DeleteSubscription()
virtual Status DeleteSnapshot(DeleteSnapshotParams)
Defines the interface for SnapshotAdminClient::DeleteSnapshot()
virtual StatusOr< google::pubsub::v1::Subscription > CreateSubscription(CreateSubscriptionParams)
Defines the interface for SubscriptionAdminClient::CreateSubscription()
virtual Status ModifyPushConfig(ModifyPushConfigParams)
Defines the interface for SubscriptionAdminClient::ModifyPushConfig()
virtual StatusOr< google::pubsub::v1::SeekResponse > Seek(SeekParams)
Defines the interface for SubscriptionAdminClient::Seek()
virtual StatusOr< google::pubsub::v1::Subscription > UpdateSubscription(UpdateSubscriptionParams)
Defines the interface for SubscriptionAdminClient::UpdateSubscription()
virtual ListSnapshotsRange ListSnapshots(ListSnapshotsParams)
Defines the interface for SubscriptionAdminClient::ListSnapshots()
virtual StatusOr< google::pubsub::v1::Snapshot > UpdateSnapshot(UpdateSnapshotParams)
Defines the interface for SnapshotAdminClient::UpdateSnapshot()
virtual ListSubscriptionsRange ListSubscriptions(ListSubscriptionsParams)
Defines the interface for SubscriptionAdminClient::ListSubscriptions()
Objects of this class identify a Cloud Pub/Sub subscription.
Definition: subscription.h:37
Contains all the Cloud Pub/Sub C++ client types and functions.
Definition: ack_handler.h:25
std::shared_ptr< SubscriptionAdminConnection > MakeSubscriptionAdminConnection(ConnectionOptions const &options, std::unique_ptr< pubsub::RetryPolicy const > retry_policy={}, std::unique_ptr< pubsub::BackoffPolicy const > backoff_policy={})
Creates a new SubscriptionAdminConnection object to work with SubscriptionAdminClient.
std::shared_ptr< SubscriptionAdminConnection > MakeSubscriptionAdminConnection(std::initializer_list< internal::NonConstructible >)
Creates a new SubscriptionAdminConnection object to work with SubscriptionAdminClient.
std::shared_ptr< SubscriptionAdminConnection > MakeSubscriptionAdminConnection(Options opts={})
Creates a new SubscriptionAdminConnection object to work with SubscriptionAdminClient.
The namespace Google Cloud Platform C++ client libraries.
Wrap the arguments for CreateSnapshot()
Definition: subscription_admin_connection.h:117
google::pubsub::v1::CreateSnapshotRequest request
Definition: subscription_admin_connection.h:118
Wrap the arguments for CreateSubscription()
Definition: subscription_admin_connection.h:87
google::pubsub::v1::Subscription subscription
Definition: subscription_admin_connection.h:88
Wrap the arguments for DeleteSnapshot()
Definition: subscription_admin_connection.h:137
Snapshot snapshot
Definition: subscription_admin_connection.h:138
Wrap the arguments for DeleteSubscription()
Definition: subscription_admin_connection.h:107
Subscription subscription
Definition: subscription_admin_connection.h:108
Wrap the arguments for GetSnapshot()
Definition: subscription_admin_connection.h:122
Snapshot snapshot
Definition: subscription_admin_connection.h:123
Wrap the arguments for GetSubscription()
Definition: subscription_admin_connection.h:92
Subscription subscription
Definition: subscription_admin_connection.h:93
Wrap the arguments for ListSnapshots()
Definition: subscription_admin_connection.h:127
std::string project_id
Definition: subscription_admin_connection.h:128
Wrap the arguments for ListSubscriptions()
Definition: subscription_admin_connection.h:102
std::string project_id
Definition: subscription_admin_connection.h:103
Wrap the arguments for ModifyPushConfig()
Definition: subscription_admin_connection.h:112
google::pubsub::v1::ModifyPushConfigRequest request
Definition: subscription_admin_connection.h:113
Wrap the arguments for Seek()
Definition: subscription_admin_connection.h:142
google::pubsub::v1::SeekRequest request
Definition: subscription_admin_connection.h:143
Wrap the arguments for UpdateSnapshot()
Definition: subscription_admin_connection.h:132
google::pubsub::v1::UpdateSnapshotRequest request
Definition: subscription_admin_connection.h:133
Wrap the arguments for UpdateSubscription()
Definition: subscription_admin_connection.h:97
google::pubsub::v1::UpdateSubscriptionRequest request
Definition: subscription_admin_connection.h:98