Google Cloud Spanner C++ Client  1.32.0
A C++ Client Library for Google Cloud Spanner
database_admin_auth_decorator.cc
Go to the documentation of this file.
1 // Copyright 2021 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 // Generated by the Codegen C++ plugin.
16 // If you make any local changes, they will be lost.
17 // source: google/spanner/admin/database/v1/spanner_database_admin.proto
18 
19 #include "google/cloud/spanner/admin/internal/database_admin_auth_decorator.h"
20 #include <google/spanner/admin/database/v1/spanner_database_admin.grpc.pb.h>
21 #include <memory>
22 
23 namespace google {
24 namespace cloud {
25 namespace spanner_admin_internal {
26 inline namespace GOOGLE_CLOUD_CPP_GENERATED_NS {
27 
29  std::shared_ptr<google::cloud::internal::GrpcAuthenticationStrategy> auth,
30  std::shared_ptr<DatabaseAdminStub> child)
31  : auth_(std::move(auth)), child_(std::move(child)) {}
32 
33 StatusOr<google::spanner::admin::database::v1::ListDatabasesResponse>
35  grpc::ClientContext& context,
36  google::spanner::admin::database::v1::ListDatabasesRequest const& request) {
37  auto status = auth_->ConfigureContext(context);
38  if (!status.ok()) return status;
39  return child_->ListDatabases(context, request);
40 }
41 
42 future<StatusOr<google::longrunning::Operation>>
45  std::unique_ptr<grpc::ClientContext> context,
46  google::spanner::admin::database::v1::CreateDatabaseRequest const&
47  request) {
48  using ReturnType = StatusOr<google::longrunning::Operation>;
49  auto child = child_;
50  return auth_->AsyncConfigureContext(std::move(context))
51  .then([cq, child,
52  request](future<StatusOr<std::unique_ptr<grpc::ClientContext>>>
53  f) mutable {
54  auto context = f.get();
55  if (!context) {
56  return make_ready_future(ReturnType(std::move(context).status()));
57  }
58  return child->AsyncCreateDatabase(cq, *std::move(context), request);
59  });
60 }
61 
62 StatusOr<google::spanner::admin::database::v1::Database>
64  grpc::ClientContext& context,
65  google::spanner::admin::database::v1::GetDatabaseRequest const& request) {
66  auto status = auth_->ConfigureContext(context);
67  if (!status.ok()) return status;
68  return child_->GetDatabase(context, request);
69 }
70 
71 future<StatusOr<google::longrunning::Operation>>
74  std::unique_ptr<grpc::ClientContext> context,
75  google::spanner::admin::database::v1::UpdateDatabaseDdlRequest const&
76  request) {
77  using ReturnType = StatusOr<google::longrunning::Operation>;
78  auto child = child_;
79  return auth_->AsyncConfigureContext(std::move(context))
80  .then([cq, child,
81  request](future<StatusOr<std::unique_ptr<grpc::ClientContext>>>
82  f) mutable {
83  auto context = f.get();
84  if (!context) {
85  return make_ready_future(ReturnType(std::move(context).status()));
86  }
87  return child->AsyncUpdateDatabaseDdl(cq, *std::move(context), request);
88  });
89 }
90 
92  grpc::ClientContext& context,
93  google::spanner::admin::database::v1::DropDatabaseRequest const& request) {
94  auto status = auth_->ConfigureContext(context);
95  if (!status.ok()) return status;
96  return child_->DropDatabase(context, request);
97 }
98 
99 StatusOr<google::spanner::admin::database::v1::GetDatabaseDdlResponse>
101  grpc::ClientContext& context,
102  google::spanner::admin::database::v1::GetDatabaseDdlRequest const&
103  request) {
104  auto status = auth_->ConfigureContext(context);
105  if (!status.ok()) return status;
106  return child_->GetDatabaseDdl(context, request);
107 }
108 
109 StatusOr<google::iam::v1::Policy> DatabaseAdminAuth::SetIamPolicy(
110  grpc::ClientContext& context,
111  google::iam::v1::SetIamPolicyRequest const& request) {
112  auto status = auth_->ConfigureContext(context);
113  if (!status.ok()) return status;
114  return child_->SetIamPolicy(context, request);
115 }
116 
117 StatusOr<google::iam::v1::Policy> DatabaseAdminAuth::GetIamPolicy(
118  grpc::ClientContext& context,
119  google::iam::v1::GetIamPolicyRequest const& request) {
120  auto status = auth_->ConfigureContext(context);
121  if (!status.ok()) return status;
122  return child_->GetIamPolicy(context, request);
123 }
124 
125 StatusOr<google::iam::v1::TestIamPermissionsResponse>
127  grpc::ClientContext& context,
128  google::iam::v1::TestIamPermissionsRequest const& request) {
129  auto status = auth_->ConfigureContext(context);
130  if (!status.ok()) return status;
131  return child_->TestIamPermissions(context, request);
132 }
133 
134 future<StatusOr<google::longrunning::Operation>>
137  std::unique_ptr<grpc::ClientContext> context,
138  google::spanner::admin::database::v1::CreateBackupRequest const& request) {
139  using ReturnType = StatusOr<google::longrunning::Operation>;
140  auto child = child_;
141  return auth_->AsyncConfigureContext(std::move(context))
142  .then([cq, child,
143  request](future<StatusOr<std::unique_ptr<grpc::ClientContext>>>
144  f) mutable {
145  auto context = f.get();
146  if (!context) {
147  return make_ready_future(ReturnType(std::move(context).status()));
148  }
149  return child->AsyncCreateBackup(cq, *std::move(context), request);
150  });
151 }
152 
153 StatusOr<google::spanner::admin::database::v1::Backup>
155  grpc::ClientContext& context,
156  google::spanner::admin::database::v1::GetBackupRequest const& request) {
157  auto status = auth_->ConfigureContext(context);
158  if (!status.ok()) return status;
159  return child_->GetBackup(context, request);
160 }
161 
162 StatusOr<google::spanner::admin::database::v1::Backup>
164  grpc::ClientContext& context,
165  google::spanner::admin::database::v1::UpdateBackupRequest const& request) {
166  auto status = auth_->ConfigureContext(context);
167  if (!status.ok()) return status;
168  return child_->UpdateBackup(context, request);
169 }
170 
172  grpc::ClientContext& context,
173  google::spanner::admin::database::v1::DeleteBackupRequest const& request) {
174  auto status = auth_->ConfigureContext(context);
175  if (!status.ok()) return status;
176  return child_->DeleteBackup(context, request);
177 }
178 
179 StatusOr<google::spanner::admin::database::v1::ListBackupsResponse>
181  grpc::ClientContext& context,
182  google::spanner::admin::database::v1::ListBackupsRequest const& request) {
183  auto status = auth_->ConfigureContext(context);
184  if (!status.ok()) return status;
185  return child_->ListBackups(context, request);
186 }
187 
188 future<StatusOr<google::longrunning::Operation>>
191  std::unique_ptr<grpc::ClientContext> context,
192  google::spanner::admin::database::v1::RestoreDatabaseRequest const&
193  request) {
194  using ReturnType = StatusOr<google::longrunning::Operation>;
195  auto child = child_;
196  return auth_->AsyncConfigureContext(std::move(context))
197  .then([cq, child,
198  request](future<StatusOr<std::unique_ptr<grpc::ClientContext>>>
199  f) mutable {
200  auto context = f.get();
201  if (!context) {
202  return make_ready_future(ReturnType(std::move(context).status()));
203  }
204  return child->AsyncRestoreDatabase(cq, *std::move(context), request);
205  });
206 }
207 
208 StatusOr<google::spanner::admin::database::v1::ListDatabaseOperationsResponse>
210  grpc::ClientContext& context,
211  google::spanner::admin::database::v1::ListDatabaseOperationsRequest const&
212  request) {
213  auto status = auth_->ConfigureContext(context);
214  if (!status.ok()) return status;
215  return child_->ListDatabaseOperations(context, request);
216 }
217 
218 StatusOr<google::spanner::admin::database::v1::ListBackupOperationsResponse>
220  grpc::ClientContext& context,
221  google::spanner::admin::database::v1::ListBackupOperationsRequest const&
222  request) {
223  auto status = auth_->ConfigureContext(context);
224  if (!status.ok()) return status;
225  return child_->ListBackupOperations(context, request);
226 }
227 
228 future<StatusOr<google::longrunning::Operation>>
231  std::unique_ptr<grpc::ClientContext> context,
232  google::longrunning::GetOperationRequest const& request) {
233  using ReturnType = StatusOr<google::longrunning::Operation>;
234  auto child = child_;
235  return auth_->AsyncConfigureContext(std::move(context))
236  .then([cq, child,
237  request](future<StatusOr<std::unique_ptr<grpc::ClientContext>>>
238  f) mutable {
239  auto context = f.get();
240  if (!context) {
241  return make_ready_future(ReturnType(std::move(context).status()));
242  }
243  return child->AsyncGetOperation(cq, *std::move(context), request);
244  });
245 }
246 
249  std::unique_ptr<grpc::ClientContext> context,
250  google::longrunning::CancelOperationRequest const& request) {
251  auto child = child_;
252  return auth_->AsyncConfigureContext(std::move(context))
253  .then([cq, child,
254  request](future<StatusOr<std::unique_ptr<grpc::ClientContext>>>
255  f) mutable {
256  auto context = f.get();
257  if (!context) return make_ready_future(std::move(context).status());
258  return child->AsyncCancelOperation(cq, *std::move(context), request);
259  });
260 }
261 
262 } // namespace GOOGLE_CLOUD_CPP_GENERATED_NS
263 } // namespace spanner_admin_internal
264 } // namespace cloud
265 } // namespace google