Google Cloud Spanner C++ Client 2.13.0
A C++ Client Library for Google Cloud Spanner
Loading...
Searching...
No Matches
backup.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_SPANNER_BACKUP_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_BACKUP_H
17
18#include "google/cloud/spanner/instance.h"
19#include "google/cloud/spanner/version.h"
20#include "google/cloud/status_or.h"
21#include <iosfwd>
22#include <string>
23
24namespace google {
25namespace cloud {
26namespace spanner {
27GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
28
29/**
30 * This class identifies a Cloud Spanner Backup.
31 *
32 * A Cloud Spanner backup is identified by an `Instance` and a `backup_id`.
33 *
34 * @note This class makes no effort to validate the components of the
35 * backup name. It is the application's responsibility to provide valid
36 * project, instance, and backup ids. Passing invalid values will not be
37 * checked until the backup name is used in a RPC to spanner.
38 */
39class Backup {
40 public:
41 /*
42 * Constructs a Backup object identified by the given @p instance and
43 * @p backup_id.
44 */
45 Backup(Instance instance, std::string backup_id);
46
47 /// @name Copy and move
48 ///@{
49 Backup(Backup const&) = default;
50 Backup& operator=(Backup const&) = default;
51 Backup(Backup&&) = default;
52 Backup& operator=(Backup&&) = default;
53 ///@}
54
55 /// Returns the `Instance` containing this backup.
56 Instance const& instance() const { return instance_; }
57
58 /// Returns the Backup ID.
59 std::string const& backup_id() const { return backup_id_; }
60
61 /**
62 * Returns the fully qualified backup name as a string of the form:
63 * "projects/<project-id>/instances/<instance-id>/backups/<backup-id>"
64 */
65 std::string FullName() const;
66
67 /// @name Equality operators
68 ///@{
69 friend bool operator==(Backup const& a, Backup const& b);
70 friend bool operator!=(Backup const& a, Backup const& b);
71 ///@}
72
73 /// Output the `FullName()` format.
74 friend std::ostream& operator<<(std::ostream&, Backup const&);
75
76 private:
77 Instance instance_;
78 std::string backup_id_;
79};
80
81/**
82 * Constructs a `Backup` from the given @p full_name.
83 * Returns a non-OK Status if `full_name` is improperly formed.
84 */
85StatusOr<Backup> MakeBackup(std::string const& full_name);
86
87GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
88} // namespace spanner
89} // namespace cloud
90} // namespace google
91
92#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_BACKUP_H
This class identifies a Cloud Spanner Backup.
Definition: backup.h:39
std::string FullName() const
Returns the fully qualified backup name as a string of the form: "projects/<project-id>/instances/<in...
Backup(Instance instance, std::string backup_id)
std::string const & backup_id() const
Returns the Backup ID.
Definition: backup.h:59
Backup & operator=(Backup const &)=default
Backup(Backup const &)=default
friend bool operator==(Backup const &a, Backup const &b)
Backup & operator=(Backup &&)=default
friend bool operator!=(Backup const &a, Backup const &b)
Instance const & instance() const
Returns the Instance containing this backup.
Definition: backup.h:56
This class identifies a Cloud Spanner Instance.
Definition: instance.h:42
Contains all the Cloud Spanner C++ client types and functions.
Definition: backoff_policy.h:23
StatusOr< Backup > MakeBackup(std::string const &full_name)
Constructs a Backup from the given full_name.