Google Cloud Spanner C++ Client  1.32.0
A C++ Client Library for Google Cloud Spanner
database_admin_metadata_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_metadata_decorator.h"
20 #include "google/cloud/internal/api_client_header.h"
21 #include "google/cloud/status_or.h"
22 #include <google/spanner/admin/database/v1/spanner_database_admin.grpc.pb.h>
23 #include <memory>
24 
25 namespace google {
26 namespace cloud {
27 namespace spanner_admin_internal {
28 inline namespace GOOGLE_CLOUD_CPP_GENERATED_NS {
29 
31  std::shared_ptr<DatabaseAdminStub> child)
32  : child_(std::move(child)),
33  api_client_header_(
34  google::cloud::internal::ApiClientHeader("generator")) {}
35 
36 StatusOr<google::spanner::admin::database::v1::ListDatabasesResponse>
38  grpc::ClientContext& context,
39  google::spanner::admin::database::v1::ListDatabasesRequest const& request) {
40  SetMetadata(context, "parent=" + request.parent());
41  return child_->ListDatabases(context, request);
42 }
43 
44 future<StatusOr<google::longrunning::Operation>>
47  std::unique_ptr<grpc::ClientContext> context,
48  google::spanner::admin::database::v1::CreateDatabaseRequest const&
49  request) {
50  SetMetadata(*context, "parent=" + request.parent());
51  return child_->AsyncCreateDatabase(cq, std::move(context), request);
52 }
53 
54 StatusOr<google::spanner::admin::database::v1::Database>
56  grpc::ClientContext& context,
57  google::spanner::admin::database::v1::GetDatabaseRequest const& request) {
58  SetMetadata(context, "name=" + request.name());
59  return child_->GetDatabase(context, request);
60 }
61 
62 future<StatusOr<google::longrunning::Operation>>
65  std::unique_ptr<grpc::ClientContext> context,
66  google::spanner::admin::database::v1::UpdateDatabaseDdlRequest const&
67  request) {
68  SetMetadata(*context, "database=" + request.database());
69  return child_->AsyncUpdateDatabaseDdl(cq, std::move(context), request);
70 }
71 
73  grpc::ClientContext& context,
74  google::spanner::admin::database::v1::DropDatabaseRequest const& request) {
75  SetMetadata(context, "database=" + request.database());
76  return child_->DropDatabase(context, request);
77 }
78 
79 StatusOr<google::spanner::admin::database::v1::GetDatabaseDdlResponse>
81  grpc::ClientContext& context,
82  google::spanner::admin::database::v1::GetDatabaseDdlRequest const&
83  request) {
84  SetMetadata(context, "database=" + request.database());
85  return child_->GetDatabaseDdl(context, request);
86 }
87 
88 StatusOr<google::iam::v1::Policy> DatabaseAdminMetadata::SetIamPolicy(
89  grpc::ClientContext& context,
90  google::iam::v1::SetIamPolicyRequest const& request) {
91  SetMetadata(context, "resource=" + request.resource());
92  return child_->SetIamPolicy(context, request);
93 }
94 
95 StatusOr<google::iam::v1::Policy> DatabaseAdminMetadata::GetIamPolicy(
96  grpc::ClientContext& context,
97  google::iam::v1::GetIamPolicyRequest const& request) {
98  SetMetadata(context, "resource=" + request.resource());
99  return child_->GetIamPolicy(context, request);
100 }
101 
102 StatusOr<google::iam::v1::TestIamPermissionsResponse>
104  grpc::ClientContext& context,
105  google::iam::v1::TestIamPermissionsRequest const& request) {
106  SetMetadata(context, "resource=" + request.resource());
107  return child_->TestIamPermissions(context, request);
108 }
109 
110 future<StatusOr<google::longrunning::Operation>>
113  std::unique_ptr<grpc::ClientContext> context,
114  google::spanner::admin::database::v1::CreateBackupRequest const& request) {
115  SetMetadata(*context, "parent=" + request.parent());
116  return child_->AsyncCreateBackup(cq, std::move(context), request);
117 }
118 
119 StatusOr<google::spanner::admin::database::v1::Backup>
121  grpc::ClientContext& context,
122  google::spanner::admin::database::v1::GetBackupRequest const& request) {
123  SetMetadata(context, "name=" + request.name());
124  return child_->GetBackup(context, request);
125 }
126 
127 StatusOr<google::spanner::admin::database::v1::Backup>
129  grpc::ClientContext& context,
130  google::spanner::admin::database::v1::UpdateBackupRequest const& request) {
131  SetMetadata(context, "backup.name=" + request.backup().name());
132  return child_->UpdateBackup(context, request);
133 }
134 
136  grpc::ClientContext& context,
137  google::spanner::admin::database::v1::DeleteBackupRequest const& request) {
138  SetMetadata(context, "name=" + request.name());
139  return child_->DeleteBackup(context, request);
140 }
141 
142 StatusOr<google::spanner::admin::database::v1::ListBackupsResponse>
144  grpc::ClientContext& context,
145  google::spanner::admin::database::v1::ListBackupsRequest const& request) {
146  SetMetadata(context, "parent=" + request.parent());
147  return child_->ListBackups(context, request);
148 }
149 
150 future<StatusOr<google::longrunning::Operation>>
153  std::unique_ptr<grpc::ClientContext> context,
154  google::spanner::admin::database::v1::RestoreDatabaseRequest const&
155  request) {
156  SetMetadata(*context, "parent=" + request.parent());
157  return child_->AsyncRestoreDatabase(cq, std::move(context), request);
158 }
159 
160 StatusOr<google::spanner::admin::database::v1::ListDatabaseOperationsResponse>
162  grpc::ClientContext& context,
163  google::spanner::admin::database::v1::ListDatabaseOperationsRequest const&
164  request) {
165  SetMetadata(context, "parent=" + request.parent());
166  return child_->ListDatabaseOperations(context, request);
167 }
168 
169 StatusOr<google::spanner::admin::database::v1::ListBackupOperationsResponse>
171  grpc::ClientContext& context,
172  google::spanner::admin::database::v1::ListBackupOperationsRequest const&
173  request) {
174  SetMetadata(context, "parent=" + request.parent());
175  return child_->ListBackupOperations(context, request);
176 }
177 
178 future<StatusOr<google::longrunning::Operation>>
181  std::unique_ptr<grpc::ClientContext> context,
182  google::longrunning::GetOperationRequest const& request) {
183  SetMetadata(*context, "name=" + request.name());
184  return child_->AsyncGetOperation(cq, std::move(context), request);
185 }
186 
189  std::unique_ptr<grpc::ClientContext> context,
190  google::longrunning::CancelOperationRequest const& request) {
191  SetMetadata(*context, "name=" + request.name());
192  return child_->AsyncCancelOperation(cq, std::move(context), request);
193 }
194 
195 void DatabaseAdminMetadata::SetMetadata(grpc::ClientContext& context,
196  std::string const& request_params) {
197  context.AddMetadata("x-goog-request-params", request_params);
198  context.AddMetadata("x-goog-api-client", api_client_header_);
199 }
200 
201 } // namespace GOOGLE_CLOUD_CPP_GENERATED_NS
202 } // namespace spanner_admin_internal
203 } // namespace cloud
204 } // namespace google