Google Cloud Spanner C++ Client  1.32.0
A C++ Client Library for Google Cloud Spanner
instance_admin_stub_factory.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_stub_factory.h"
20 #include "google/cloud/spanner/admin/internal/instance_admin_auth_decorator.h"
21 #include "google/cloud/spanner/admin/internal/instance_admin_logging_decorator.h"
22 #include "google/cloud/spanner/admin/internal/instance_admin_metadata_decorator.h"
23 #include "google/cloud/spanner/admin/internal/instance_admin_stub.h"
24 #include "google/cloud/common_options.h"
25 #include "google/cloud/grpc_options.h"
26 #include "google/cloud/internal/algorithm.h"
27 #include "google/cloud/log.h"
28 #include "google/cloud/options.h"
29 #include <memory>
30 
31 namespace google {
32 namespace cloud {
33 namespace spanner_admin_internal {
34 inline namespace GOOGLE_CLOUD_CPP_GENERATED_NS {
35 
37  google::cloud::CompletionQueue cq, Options const& options) {
38  auto auth = [&] {
40  return google::cloud::internal::CreateAuthenticationStrategy(
42  options);
43  }
44  return google::cloud::internal::CreateAuthenticationStrategy(
46  }();
47  auto channel = auth->CreateChannel(options.get<EndpointOption>(),
48  internal::MakeChannelArguments(options));
49  auto service_grpc_stub =
50  google::spanner::admin::instance::v1::InstanceAdmin::NewStub(channel);
51  std::shared_ptr<InstanceAdminStub> stub =
52  std::make_shared<DefaultInstanceAdminStub>(
53  std::move(service_grpc_stub),
54  google::longrunning::Operations::NewStub(channel));
55 
56  if (auth->RequiresConfigureContext()) {
57  stub =
58  std::make_shared<InstanceAdminAuth>(std::move(auth), std::move(stub));
59  }
60  stub = std::make_shared<InstanceAdminMetadata>(std::move(stub));
61  if (internal::Contains(options.get<TracingComponentsOption>(), "rpc")) {
62  GCP_LOG(INFO) << "Enabled logging for gRPC calls";
63  stub = std::make_shared<InstanceAdminLogging>(
64  std::move(stub), options.get<GrpcTracingOptionsOption>(),
66  }
67  return stub;
68 }
69 
70 } // namespace GOOGLE_CLOUD_CPP_GENERATED_NS
71 } // namespace spanner_admin_internal
72 } // namespace cloud
73 } // namespace google