Google Cloud Spanner C++ Client  1.32.0
A C++ Client Library for Google Cloud Spanner
instance_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/instance/v1/spanner_instance_admin.proto
18 
19 #include "google/cloud/spanner/admin/internal/instance_admin_auth_decorator.h"
20 #include <google/spanner/admin/instance/v1/spanner_instance_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<InstanceAdminStub> child)
31  : auth_(std::move(auth)), child_(std::move(child)) {}
32 
33 StatusOr<google::spanner::admin::instance::v1::ListInstanceConfigsResponse>
35  grpc::ClientContext& context,
36  google::spanner::admin::instance::v1::ListInstanceConfigsRequest const&
37  request) {
38  auto status = auth_->ConfigureContext(context);
39  if (!status.ok()) return status;
40  return child_->ListInstanceConfigs(context, request);
41 }
42 
43 StatusOr<google::spanner::admin::instance::v1::InstanceConfig>
45  grpc::ClientContext& context,
46  google::spanner::admin::instance::v1::GetInstanceConfigRequest const&
47  request) {
48  auto status = auth_->ConfigureContext(context);
49  if (!status.ok()) return status;
50  return child_->GetInstanceConfig(context, request);
51 }
52 
53 StatusOr<google::spanner::admin::instance::v1::ListInstancesResponse>
55  grpc::ClientContext& context,
56  google::spanner::admin::instance::v1::ListInstancesRequest const& request) {
57  auto status = auth_->ConfigureContext(context);
58  if (!status.ok()) return status;
59  return child_->ListInstances(context, request);
60 }
61 
62 StatusOr<google::spanner::admin::instance::v1::Instance>
64  grpc::ClientContext& context,
65  google::spanner::admin::instance::v1::GetInstanceRequest const& request) {
66  auto status = auth_->ConfigureContext(context);
67  if (!status.ok()) return status;
68  return child_->GetInstance(context, request);
69 }
70 
71 future<StatusOr<google::longrunning::Operation>>
74  std::unique_ptr<grpc::ClientContext> context,
75  google::spanner::admin::instance::v1::CreateInstanceRequest 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->AsyncCreateInstance(cq, *std::move(context), request);
88  });
89 }
90 
91 future<StatusOr<google::longrunning::Operation>>
94  std::unique_ptr<grpc::ClientContext> context,
95  google::spanner::admin::instance::v1::UpdateInstanceRequest const&
96  request) {
97  using ReturnType = StatusOr<google::longrunning::Operation>;
98  auto child = child_;
99  return auth_->AsyncConfigureContext(std::move(context))
100  .then([cq, child,
101  request](future<StatusOr<std::unique_ptr<grpc::ClientContext>>>
102  f) mutable {
103  auto context = f.get();
104  if (!context) {
105  return make_ready_future(ReturnType(std::move(context).status()));
106  }
107  return child->AsyncUpdateInstance(cq, *std::move(context), request);
108  });
109 }
110 
112  grpc::ClientContext& context,
113  google::spanner::admin::instance::v1::DeleteInstanceRequest const&
114  request) {
115  auto status = auth_->ConfigureContext(context);
116  if (!status.ok()) return status;
117  return child_->DeleteInstance(context, request);
118 }
119 
120 StatusOr<google::iam::v1::Policy> InstanceAdminAuth::SetIamPolicy(
121  grpc::ClientContext& context,
122  google::iam::v1::SetIamPolicyRequest const& request) {
123  auto status = auth_->ConfigureContext(context);
124  if (!status.ok()) return status;
125  return child_->SetIamPolicy(context, request);
126 }
127 
128 StatusOr<google::iam::v1::Policy> InstanceAdminAuth::GetIamPolicy(
129  grpc::ClientContext& context,
130  google::iam::v1::GetIamPolicyRequest const& request) {
131  auto status = auth_->ConfigureContext(context);
132  if (!status.ok()) return status;
133  return child_->GetIamPolicy(context, request);
134 }
135 
136 StatusOr<google::iam::v1::TestIamPermissionsResponse>
138  grpc::ClientContext& context,
139  google::iam::v1::TestIamPermissionsRequest const& request) {
140  auto status = auth_->ConfigureContext(context);
141  if (!status.ok()) return status;
142  return child_->TestIamPermissions(context, request);
143 }
144 
145 future<StatusOr<google::longrunning::Operation>>
148  std::unique_ptr<grpc::ClientContext> context,
149  google::longrunning::GetOperationRequest const& request) {
150  using ReturnType = StatusOr<google::longrunning::Operation>;
151  auto child = child_;
152  return auth_->AsyncConfigureContext(std::move(context))
153  .then([cq, child,
154  request](future<StatusOr<std::unique_ptr<grpc::ClientContext>>>
155  f) mutable {
156  auto context = f.get();
157  if (!context) {
158  return make_ready_future(ReturnType(std::move(context).status()));
159  }
160  return child->AsyncGetOperation(cq, *std::move(context), request);
161  });
162 }
163 
166  std::unique_ptr<grpc::ClientContext> context,
167  google::longrunning::CancelOperationRequest const& request) {
168  auto child = child_;
169  return auth_->AsyncConfigureContext(std::move(context))
170  .then([cq, child,
171  request](future<StatusOr<std::unique_ptr<grpc::ClientContext>>>
172  f) mutable {
173  auto context = f.get();
174  if (!context) return make_ready_future(std::move(context).status());
175  return child->AsyncCancelOperation(cq, *std::move(context), request);
176  });
177 }
178 
179 } // namespace GOOGLE_CLOUD_CPP_GENERATED_NS
180 } // namespace spanner_admin_internal
181 } // namespace cloud
182 } // namespace google