Google Cloud Pub/Sub C++ Client 2.13.0
A C++ Client Library for Google Cloud Pub/Sub
Loading...
Searching...
No Matches
subscription.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_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_SUBSCRIPTION_H
17
18#include "google/cloud/pubsub/version.h"
19#include <grpcpp/grpcpp.h>
20#include <string>
21
22namespace google {
23namespace cloud {
24namespace pubsub {
25GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
26
27/**
28 * Objects of this class identify a Cloud Pub/Sub subscription.
29 *
30 * @note
31 * This class makes no effort to validate the ids provided. The application
32 * should verify that any ids passed to this application conform to the
33 * Cloud Pub/Sub [resource name][name-link] restrictions.
34 *
35 * [name-link]: https://cloud.google.com/pubsub/docs/admin#resource_names
36 */
37class Subscription {
38 public:
39 /// The default constructor creates an invalid subscription.
41 Subscription(std::string project_id, std::string subscription_id)
42 : project_id_(std::move(project_id)),
43 subscription_id_(std::move(subscription_id)) {}
44
45 /// @name Copy and move
46 ///@{
47 Subscription(Subscription const&) = default;
48 Subscription& operator=(Subscription const&) = default;
49 Subscription(Subscription&&) = default;
50 Subscription& operator=(Subscription&&) = default;
51 ///@}
52
53 /// Returns the Project ID
54 std::string const& project_id() const { return project_id_; }
55
56 /// Returns the Subscription ID
57 std::string const& subscription_id() const { return subscription_id_; }
58
59 /**
60 * Returns the fully qualified subscription name as a string of the form:
61 * "projects/<project-id>/subscriptions/<subscription-id>"
62 */
63 std::string FullName() const;
64
65 /// @name Equality operators
66 ///@{
67 friend bool operator==(Subscription const& a, Subscription const& b);
68 friend bool operator!=(Subscription const& a, Subscription const& b) {
69 return !(a == b);
70 }
71 ///@}
72
73 /// Output the `FullName()` format.
74 friend std::ostream& operator<<(std::ostream& os, Subscription const& rhs);
75
76 private:
77 std::string project_id_;
78 std::string subscription_id_;
79};
80
81GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
82} // namespace pubsub
83} // namespace cloud
84} // namespace google
85
86#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_SUBSCRIPTION_H
Objects of this class identify a Cloud Pub/Sub subscription.
Definition: subscription.h:37
Subscription(Subscription const &)=default
std::string const & subscription_id() const
Returns the Subscription ID.
Definition: subscription.h:57
Subscription()
The default constructor creates an invalid subscription.
Subscription & operator=(Subscription &&)=default
std::string FullName() const
Returns the fully qualified subscription name as a string of the form: "projects/<project-id>/subscri...
friend bool operator!=(Subscription const &a, Subscription const &b)
Definition: subscription.h:68
Subscription(Subscription &&)=default
Subscription & operator=(Subscription const &)=default
Subscription(std::string project_id, std::string subscription_id)
Definition: subscription.h:41
friend bool operator==(Subscription const &a, Subscription const &b)
std::string const & project_id() const
Returns the Project ID.
Definition: subscription.h:54
Contains all the Cloud Pub/Sub C++ client types and functions.
Definition: ack_handler.h:25
The namespace Google Cloud Platform C++ client libraries.