Google Cloud Spanner C++ Client  1.32.0
A C++ Client Library for Google Cloud Spanner
instance_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/instance/v1/spanner_instance_admin.proto
18 
19 #include "google/cloud/spanner/admin/internal/instance_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/instance/v1/spanner_instance_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<InstanceAdminStub> child)
32  : child_(std::move(child)),
33  api_client_header_(
34  google::cloud::internal::ApiClientHeader("generator")) {}
35 
36 StatusOr<google::spanner::admin::instance::v1::ListInstanceConfigsResponse>
38  grpc::ClientContext& context,
39  google::spanner::admin::instance::v1::ListInstanceConfigsRequest const&
40  request) {
41  SetMetadata(context, "parent=" + request.parent());
42  return child_->ListInstanceConfigs(context, request);
43 }
44 
45 StatusOr<google::spanner::admin::instance::v1::InstanceConfig>
47  grpc::ClientContext& context,
48  google::spanner::admin::instance::v1::GetInstanceConfigRequest const&
49  request) {
50  SetMetadata(context, "name=" + request.name());
51  return child_->GetInstanceConfig(context, request);
52 }
53 
54 StatusOr<google::spanner::admin::instance::v1::ListInstancesResponse>
56  grpc::ClientContext& context,
57  google::spanner::admin::instance::v1::ListInstancesRequest const& request) {
58  SetMetadata(context, "parent=" + request.parent());
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  SetMetadata(context, "name=" + request.name());
67  return child_->GetInstance(context, request);
68 }
69 
70 future<StatusOr<google::longrunning::Operation>>
73  std::unique_ptr<grpc::ClientContext> context,
74  google::spanner::admin::instance::v1::CreateInstanceRequest const&
75  request) {
76  SetMetadata(*context, "parent=" + request.parent());
77  return child_->AsyncCreateInstance(cq, std::move(context), request);
78 }
79 
80 future<StatusOr<google::longrunning::Operation>>
83  std::unique_ptr<grpc::ClientContext> context,
84  google::spanner::admin::instance::v1::UpdateInstanceRequest const&
85  request) {
86  SetMetadata(*context, "instance.name=" + request.instance().name());
87  return child_->AsyncUpdateInstance(cq, std::move(context), request);
88 }
89 
91  grpc::ClientContext& context,
92  google::spanner::admin::instance::v1::DeleteInstanceRequest const&
93  request) {
94  SetMetadata(context, "name=" + request.name());
95  return child_->DeleteInstance(context, request);
96 }
97 
98 StatusOr<google::iam::v1::Policy> InstanceAdminMetadata::SetIamPolicy(
99  grpc::ClientContext& context,
100  google::iam::v1::SetIamPolicyRequest const& request) {
101  SetMetadata(context, "resource=" + request.resource());
102  return child_->SetIamPolicy(context, request);
103 }
104 
105 StatusOr<google::iam::v1::Policy> InstanceAdminMetadata::GetIamPolicy(
106  grpc::ClientContext& context,
107  google::iam::v1::GetIamPolicyRequest const& request) {
108  SetMetadata(context, "resource=" + request.resource());
109  return child_->GetIamPolicy(context, request);
110 }
111 
112 StatusOr<google::iam::v1::TestIamPermissionsResponse>
114  grpc::ClientContext& context,
115  google::iam::v1::TestIamPermissionsRequest const& request) {
116  SetMetadata(context, "resource=" + request.resource());
117  return child_->TestIamPermissions(context, request);
118 }
119 
120 future<StatusOr<google::longrunning::Operation>>
123  std::unique_ptr<grpc::ClientContext> context,
124  google::longrunning::GetOperationRequest const& request) {
125  SetMetadata(*context, "name=" + request.name());
126  return child_->AsyncGetOperation(cq, std::move(context), request);
127 }
128 
131  std::unique_ptr<grpc::ClientContext> context,
132  google::longrunning::CancelOperationRequest const& request) {
133  SetMetadata(*context, "name=" + request.name());
134  return child_->AsyncCancelOperation(cq, std::move(context), request);
135 }
136 
137 void InstanceAdminMetadata::SetMetadata(grpc::ClientContext& context,
138  std::string const& request_params) {
139  context.AddMetadata("x-goog-request-params", request_params);
140  context.AddMetadata("x-goog-api-client", api_client_header_);
141 }
142 
143 } // namespace GOOGLE_CLOUD_CPP_GENERATED_NS
144 } // namespace spanner_admin_internal
145 } // namespace cloud
146 } // namespace google