Google Cloud IAM C++ Client  1.32.1
A C++ Client Library for Google Cloud IAM
iam_connection.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/iam/admin/v1/iam.proto
18 
19 #include "google/cloud/iam/iam_connection.h"
20 #include "google/cloud/iam/iam_options.h"
21 #include "google/cloud/iam/internal/iam_option_defaults.h"
22 #include "google/cloud/iam/internal/iam_stub_factory.h"
23 #include "google/cloud/background_threads.h"
24 #include "google/cloud/grpc_options.h"
25 #include "google/cloud/internal/pagination_range.h"
26 #include "google/cloud/internal/retry_loop.h"
27 #include <memory>
28 
29 namespace google {
30 namespace cloud {
31 namespace iam {
32 inline namespace GOOGLE_CLOUD_CPP_GENERATED_NS {
33 
34 IAMConnection::~IAMConnection() = default;
35 
36 StreamRange<google::iam::admin::v1::ServiceAccount>
38  google::iam::admin::v1::ListServiceAccountsRequest request) {
39  return google::cloud::internal::MakePaginationRange<
40  StreamRange<google::iam::admin::v1::ServiceAccount>>(
41  std::move(request),
42  [](google::iam::admin::v1::ListServiceAccountsRequest const&) {
43  return StatusOr<google::iam::admin::v1::ListServiceAccountsResponse>{};
44  },
45  [](google::iam::admin::v1::ListServiceAccountsResponse const&) {
46  return std::vector<google::iam::admin::v1::ServiceAccount>();
47  });
48 }
49 
50 StatusOr<google::iam::admin::v1::ServiceAccount>
52  google::iam::admin::v1::GetServiceAccountRequest const&) {
53  return Status(StatusCode::kUnimplemented, "not implemented");
54 }
55 
56 StatusOr<google::iam::admin::v1::ServiceAccount>
58  google::iam::admin::v1::CreateServiceAccountRequest const&) {
59  return Status(StatusCode::kUnimplemented, "not implemented");
60 }
61 
62 StatusOr<google::iam::admin::v1::ServiceAccount>
64  google::iam::admin::v1::PatchServiceAccountRequest const&) {
65  return Status(StatusCode::kUnimplemented, "not implemented");
66 }
67 
69  google::iam::admin::v1::DeleteServiceAccountRequest const&) {
70  return Status(StatusCode::kUnimplemented, "not implemented");
71 }
72 
73 StatusOr<google::iam::admin::v1::UndeleteServiceAccountResponse>
75  google::iam::admin::v1::UndeleteServiceAccountRequest const&) {
76  return Status(StatusCode::kUnimplemented, "not implemented");
77 }
78 
80  google::iam::admin::v1::EnableServiceAccountRequest const&) {
81  return Status(StatusCode::kUnimplemented, "not implemented");
82 }
83 
85  google::iam::admin::v1::DisableServiceAccountRequest const&) {
86  return Status(StatusCode::kUnimplemented, "not implemented");
87 }
88 
89 StatusOr<google::iam::admin::v1::ListServiceAccountKeysResponse>
91  google::iam::admin::v1::ListServiceAccountKeysRequest const&) {
92  return Status(StatusCode::kUnimplemented, "not implemented");
93 }
94 
95 StatusOr<google::iam::admin::v1::ServiceAccountKey>
97  google::iam::admin::v1::GetServiceAccountKeyRequest const&) {
98  return Status(StatusCode::kUnimplemented, "not implemented");
99 }
100 
101 StatusOr<google::iam::admin::v1::ServiceAccountKey>
103  google::iam::admin::v1::CreateServiceAccountKeyRequest const&) {
104  return Status(StatusCode::kUnimplemented, "not implemented");
105 }
106 
107 StatusOr<google::iam::admin::v1::ServiceAccountKey>
109  google::iam::admin::v1::UploadServiceAccountKeyRequest const&) {
110  return Status(StatusCode::kUnimplemented, "not implemented");
111 }
112 
114  google::iam::admin::v1::DeleteServiceAccountKeyRequest const&) {
115  return Status(StatusCode::kUnimplemented, "not implemented");
116 }
117 
118 StatusOr<google::iam::v1::Policy> IAMConnection::GetIamPolicy(
119  google::iam::v1::GetIamPolicyRequest const&) {
120  return Status(StatusCode::kUnimplemented, "not implemented");
121 }
122 
123 StatusOr<google::iam::v1::Policy> IAMConnection::SetIamPolicy(
124  google::iam::v1::SetIamPolicyRequest const&) {
125  return Status(StatusCode::kUnimplemented, "not implemented");
126 }
127 
128 StatusOr<google::iam::v1::TestIamPermissionsResponse>
130  google::iam::v1::TestIamPermissionsRequest const&) {
131  return Status(StatusCode::kUnimplemented, "not implemented");
132 }
133 
134 StreamRange<google::iam::admin::v1::Role> IAMConnection::QueryGrantableRoles(
135  google::iam::admin::v1::QueryGrantableRolesRequest request) {
136  return google::cloud::internal::MakePaginationRange<
137  StreamRange<google::iam::admin::v1::Role>>(
138  std::move(request),
139  [](google::iam::admin::v1::QueryGrantableRolesRequest const&) {
140  return StatusOr<google::iam::admin::v1::QueryGrantableRolesResponse>{};
141  },
142  [](google::iam::admin::v1::QueryGrantableRolesResponse const&) {
143  return std::vector<google::iam::admin::v1::Role>();
144  });
145 }
146 
147 StreamRange<google::iam::admin::v1::Role> IAMConnection::ListRoles(
148  google::iam::admin::v1::ListRolesRequest request) {
149  return google::cloud::internal::MakePaginationRange<
150  StreamRange<google::iam::admin::v1::Role>>(
151  std::move(request),
152  [](google::iam::admin::v1::ListRolesRequest const&) {
153  return StatusOr<google::iam::admin::v1::ListRolesResponse>{};
154  },
155  [](google::iam::admin::v1::ListRolesResponse const&) {
156  return std::vector<google::iam::admin::v1::Role>();
157  });
158 }
159 
160 StatusOr<google::iam::admin::v1::Role> IAMConnection::GetRole(
161  google::iam::admin::v1::GetRoleRequest const&) {
162  return Status(StatusCode::kUnimplemented, "not implemented");
163 }
164 
165 StatusOr<google::iam::admin::v1::Role> IAMConnection::CreateRole(
166  google::iam::admin::v1::CreateRoleRequest const&) {
167  return Status(StatusCode::kUnimplemented, "not implemented");
168 }
169 
170 StatusOr<google::iam::admin::v1::Role> IAMConnection::UpdateRole(
171  google::iam::admin::v1::UpdateRoleRequest const&) {
172  return Status(StatusCode::kUnimplemented, "not implemented");
173 }
174 
175 StatusOr<google::iam::admin::v1::Role> IAMConnection::DeleteRole(
176  google::iam::admin::v1::DeleteRoleRequest const&) {
177  return Status(StatusCode::kUnimplemented, "not implemented");
178 }
179 
180 StatusOr<google::iam::admin::v1::Role> IAMConnection::UndeleteRole(
181  google::iam::admin::v1::UndeleteRoleRequest const&) {
182  return Status(StatusCode::kUnimplemented, "not implemented");
183 }
184 
185 StreamRange<google::iam::admin::v1::Permission>
187  google::iam::admin::v1::QueryTestablePermissionsRequest request) {
188  return google::cloud::internal::MakePaginationRange<
189  StreamRange<google::iam::admin::v1::Permission>>(
190  std::move(request),
191  [](google::iam::admin::v1::QueryTestablePermissionsRequest const&) {
192  return StatusOr<
193  google::iam::admin::v1::QueryTestablePermissionsResponse>{};
194  },
195  [](google::iam::admin::v1::QueryTestablePermissionsResponse const&) {
196  return std::vector<google::iam::admin::v1::Permission>();
197  });
198 }
199 
200 StatusOr<google::iam::admin::v1::QueryAuditableServicesResponse>
202  google::iam::admin::v1::QueryAuditableServicesRequest const&) {
203  return Status(StatusCode::kUnimplemented, "not implemented");
204 }
205 
206 StatusOr<google::iam::admin::v1::LintPolicyResponse> IAMConnection::LintPolicy(
207  google::iam::admin::v1::LintPolicyRequest const&) {
208  return Status(StatusCode::kUnimplemented, "not implemented");
209 }
210 
211 namespace {
212 class IAMConnectionImpl : public IAMConnection {
213  public:
214  IAMConnectionImpl(
215  std::unique_ptr<google::cloud::BackgroundThreads> background,
216  std::shared_ptr<iam_internal::IAMStub> stub, Options const& options)
217  : background_(std::move(background)),
218  stub_(std::move(stub)),
219  retry_policy_prototype_(options.get<IAMRetryPolicyOption>()->clone()),
220  backoff_policy_prototype_(
221  options.get<IAMBackoffPolicyOption>()->clone()),
222  idempotency_policy_(
224 
225  ~IAMConnectionImpl() override = default;
226 
227  StreamRange<google::iam::admin::v1::ServiceAccount> ListServiceAccounts(
228  google::iam::admin::v1::ListServiceAccountsRequest request) override {
229  request.clear_page_token();
230  auto stub = stub_;
231  auto retry =
232  std::shared_ptr<IAMRetryPolicy const>(retry_policy_prototype_->clone());
233  auto backoff = std::shared_ptr<BackoffPolicy const>(
234  backoff_policy_prototype_->clone());
235  auto idempotency = idempotency_policy_->ListServiceAccounts(request);
236  char const* function_name = __func__;
237  return google::cloud::internal::MakePaginationRange<
238  StreamRange<google::iam::admin::v1::ServiceAccount>>(
239  std::move(request),
240  [stub, retry, backoff, idempotency, function_name](
241  google::iam::admin::v1::ListServiceAccountsRequest const& r) {
242  return google::cloud::internal::RetryLoop(
243  retry->clone(), backoff->clone(), idempotency,
244  [stub](grpc::ClientContext& context,
245  google::iam::admin::v1::ListServiceAccountsRequest const&
246  request) {
247  return stub->ListServiceAccounts(context, request);
248  },
249  r, function_name);
250  },
251  [](google::iam::admin::v1::ListServiceAccountsResponse r) {
252  std::vector<google::iam::admin::v1::ServiceAccount> result(
253  r.accounts().size());
254  auto& messages = *r.mutable_accounts();
255  std::move(messages.begin(), messages.end(), result.begin());
256  return result;
257  });
258  }
259 
260  StatusOr<google::iam::admin::v1::ServiceAccount> GetServiceAccount(
261  google::iam::admin::v1::GetServiceAccountRequest const& request)
262  override {
263  return google::cloud::internal::RetryLoop(
264  retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
265  idempotency_policy_->GetServiceAccount(request),
266  [this](
267  grpc::ClientContext& context,
268  google::iam::admin::v1::GetServiceAccountRequest const& request) {
269  return stub_->GetServiceAccount(context, request);
270  },
271  request, __func__);
272  }
273 
274  StatusOr<google::iam::admin::v1::ServiceAccount> CreateServiceAccount(
275  google::iam::admin::v1::CreateServiceAccountRequest const& request)
276  override {
277  return google::cloud::internal::RetryLoop(
278  retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
279  idempotency_policy_->CreateServiceAccount(request),
280  [this](grpc::ClientContext& context,
281  google::iam::admin::v1::CreateServiceAccountRequest const&
282  request) {
283  return stub_->CreateServiceAccount(context, request);
284  },
285  request, __func__);
286  }
287 
288  StatusOr<google::iam::admin::v1::ServiceAccount> PatchServiceAccount(
289  google::iam::admin::v1::PatchServiceAccountRequest const& request)
290  override {
291  return google::cloud::internal::RetryLoop(
292  retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
293  idempotency_policy_->PatchServiceAccount(request),
294  [this](
295  grpc::ClientContext& context,
296  google::iam::admin::v1::PatchServiceAccountRequest const& request) {
297  return stub_->PatchServiceAccount(context, request);
298  },
299  request, __func__);
300  }
301 
302  Status DeleteServiceAccount(
303  google::iam::admin::v1::DeleteServiceAccountRequest const& request)
304  override {
305  return google::cloud::internal::RetryLoop(
306  retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
307  idempotency_policy_->DeleteServiceAccount(request),
308  [this](grpc::ClientContext& context,
309  google::iam::admin::v1::DeleteServiceAccountRequest const&
310  request) {
311  return stub_->DeleteServiceAccount(context, request);
312  },
313  request, __func__);
314  }
315 
316  StatusOr<google::iam::admin::v1::UndeleteServiceAccountResponse>
317  UndeleteServiceAccount(
318  google::iam::admin::v1::UndeleteServiceAccountRequest const& request)
319  override {
320  return google::cloud::internal::RetryLoop(
321  retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
322  idempotency_policy_->UndeleteServiceAccount(request),
323  [this](grpc::ClientContext& context,
324  google::iam::admin::v1::UndeleteServiceAccountRequest const&
325  request) {
326  return stub_->UndeleteServiceAccount(context, request);
327  },
328  request, __func__);
329  }
330 
331  Status EnableServiceAccount(
332  google::iam::admin::v1::EnableServiceAccountRequest const& request)
333  override {
334  return google::cloud::internal::RetryLoop(
335  retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
336  idempotency_policy_->EnableServiceAccount(request),
337  [this](grpc::ClientContext& context,
338  google::iam::admin::v1::EnableServiceAccountRequest const&
339  request) {
340  return stub_->EnableServiceAccount(context, request);
341  },
342  request, __func__);
343  }
344 
345  Status DisableServiceAccount(
346  google::iam::admin::v1::DisableServiceAccountRequest const& request)
347  override {
348  return google::cloud::internal::RetryLoop(
349  retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
350  idempotency_policy_->DisableServiceAccount(request),
351  [this](grpc::ClientContext& context,
352  google::iam::admin::v1::DisableServiceAccountRequest const&
353  request) {
354  return stub_->DisableServiceAccount(context, request);
355  },
356  request, __func__);
357  }
358 
359  StatusOr<google::iam::admin::v1::ListServiceAccountKeysResponse>
360  ListServiceAccountKeys(
361  google::iam::admin::v1::ListServiceAccountKeysRequest const& request)
362  override {
363  return google::cloud::internal::RetryLoop(
364  retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
365  idempotency_policy_->ListServiceAccountKeys(request),
366  [this](grpc::ClientContext& context,
367  google::iam::admin::v1::ListServiceAccountKeysRequest const&
368  request) {
369  return stub_->ListServiceAccountKeys(context, request);
370  },
371  request, __func__);
372  }
373 
374  StatusOr<google::iam::admin::v1::ServiceAccountKey> GetServiceAccountKey(
375  google::iam::admin::v1::GetServiceAccountKeyRequest const& request)
376  override {
377  return google::cloud::internal::RetryLoop(
378  retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
379  idempotency_policy_->GetServiceAccountKey(request),
380  [this](grpc::ClientContext& context,
381  google::iam::admin::v1::GetServiceAccountKeyRequest const&
382  request) {
383  return stub_->GetServiceAccountKey(context, request);
384  },
385  request, __func__);
386  }
387 
388  StatusOr<google::iam::admin::v1::ServiceAccountKey> CreateServiceAccountKey(
389  google::iam::admin::v1::CreateServiceAccountKeyRequest const& request)
390  override {
391  return google::cloud::internal::RetryLoop(
392  retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
393  idempotency_policy_->CreateServiceAccountKey(request),
394  [this](grpc::ClientContext& context,
395  google::iam::admin::v1::CreateServiceAccountKeyRequest const&
396  request) {
397  return stub_->CreateServiceAccountKey(context, request);
398  },
399  request, __func__);
400  }
401 
402  StatusOr<google::iam::admin::v1::ServiceAccountKey> UploadServiceAccountKey(
403  google::iam::admin::v1::UploadServiceAccountKeyRequest const& request)
404  override {
405  return google::cloud::internal::RetryLoop(
406  retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
407  idempotency_policy_->UploadServiceAccountKey(request),
408  [this](grpc::ClientContext& context,
409  google::iam::admin::v1::UploadServiceAccountKeyRequest const&
410  request) {
411  return stub_->UploadServiceAccountKey(context, request);
412  },
413  request, __func__);
414  }
415 
416  Status DeleteServiceAccountKey(
417  google::iam::admin::v1::DeleteServiceAccountKeyRequest const& request)
418  override {
419  return google::cloud::internal::RetryLoop(
420  retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
421  idempotency_policy_->DeleteServiceAccountKey(request),
422  [this](grpc::ClientContext& context,
423  google::iam::admin::v1::DeleteServiceAccountKeyRequest const&
424  request) {
425  return stub_->DeleteServiceAccountKey(context, request);
426  },
427  request, __func__);
428  }
429 
430  StatusOr<google::iam::v1::Policy> GetIamPolicy(
431  google::iam::v1::GetIamPolicyRequest const& request) override {
432  return google::cloud::internal::RetryLoop(
433  retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
434  idempotency_policy_->GetIamPolicy(request),
435  [this](grpc::ClientContext& context,
436  google::iam::v1::GetIamPolicyRequest const& request) {
437  return stub_->GetIamPolicy(context, request);
438  },
439  request, __func__);
440  }
441 
442  StatusOr<google::iam::v1::Policy> SetIamPolicy(
443  google::iam::v1::SetIamPolicyRequest const& request) override {
444  return google::cloud::internal::RetryLoop(
445  retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
446  idempotency_policy_->SetIamPolicy(request),
447  [this](grpc::ClientContext& context,
448  google::iam::v1::SetIamPolicyRequest const& request) {
449  return stub_->SetIamPolicy(context, request);
450  },
451  request, __func__);
452  }
453 
454  StatusOr<google::iam::v1::TestIamPermissionsResponse> TestIamPermissions(
455  google::iam::v1::TestIamPermissionsRequest const& request) override {
456  return google::cloud::internal::RetryLoop(
457  retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
458  idempotency_policy_->TestIamPermissions(request),
459  [this](grpc::ClientContext& context,
460  google::iam::v1::TestIamPermissionsRequest const& request) {
461  return stub_->TestIamPermissions(context, request);
462  },
463  request, __func__);
464  }
465 
466  StreamRange<google::iam::admin::v1::Role> QueryGrantableRoles(
467  google::iam::admin::v1::QueryGrantableRolesRequest request) override {
468  request.clear_page_token();
469  auto stub = stub_;
470  auto retry =
471  std::shared_ptr<IAMRetryPolicy const>(retry_policy_prototype_->clone());
472  auto backoff = std::shared_ptr<BackoffPolicy const>(
473  backoff_policy_prototype_->clone());
474  auto idempotency = idempotency_policy_->QueryGrantableRoles(request);
475  char const* function_name = __func__;
476  return google::cloud::internal::MakePaginationRange<
477  StreamRange<google::iam::admin::v1::Role>>(
478  std::move(request),
479  [stub, retry, backoff, idempotency, function_name](
480  google::iam::admin::v1::QueryGrantableRolesRequest const& r) {
481  return google::cloud::internal::RetryLoop(
482  retry->clone(), backoff->clone(), idempotency,
483  [stub](grpc::ClientContext& context,
484  google::iam::admin::v1::QueryGrantableRolesRequest const&
485  request) {
486  return stub->QueryGrantableRoles(context, request);
487  },
488  r, function_name);
489  },
490  [](google::iam::admin::v1::QueryGrantableRolesResponse r) {
491  std::vector<google::iam::admin::v1::Role> result(r.roles().size());
492  auto& messages = *r.mutable_roles();
493  std::move(messages.begin(), messages.end(), result.begin());
494  return result;
495  });
496  }
497 
498  StreamRange<google::iam::admin::v1::Role> ListRoles(
499  google::iam::admin::v1::ListRolesRequest request) override {
500  request.clear_page_token();
501  auto stub = stub_;
502  auto retry =
503  std::shared_ptr<IAMRetryPolicy const>(retry_policy_prototype_->clone());
504  auto backoff = std::shared_ptr<BackoffPolicy const>(
505  backoff_policy_prototype_->clone());
506  auto idempotency = idempotency_policy_->ListRoles(request);
507  char const* function_name = __func__;
508  return google::cloud::internal::MakePaginationRange<
509  StreamRange<google::iam::admin::v1::Role>>(
510  std::move(request),
511  [stub, retry, backoff, idempotency,
512  function_name](google::iam::admin::v1::ListRolesRequest const& r) {
513  return google::cloud::internal::RetryLoop(
514  retry->clone(), backoff->clone(), idempotency,
515  [stub](grpc::ClientContext& context,
516  google::iam::admin::v1::ListRolesRequest const& request) {
517  return stub->ListRoles(context, request);
518  },
519  r, function_name);
520  },
521  [](google::iam::admin::v1::ListRolesResponse r) {
522  std::vector<google::iam::admin::v1::Role> result(r.roles().size());
523  auto& messages = *r.mutable_roles();
524  std::move(messages.begin(), messages.end(), result.begin());
525  return result;
526  });
527  }
528 
529  StatusOr<google::iam::admin::v1::Role> GetRole(
530  google::iam::admin::v1::GetRoleRequest const& request) override {
531  return google::cloud::internal::RetryLoop(
532  retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
533  idempotency_policy_->GetRole(request),
534  [this](grpc::ClientContext& context,
535  google::iam::admin::v1::GetRoleRequest const& request) {
536  return stub_->GetRole(context, request);
537  },
538  request, __func__);
539  }
540 
541  StatusOr<google::iam::admin::v1::Role> CreateRole(
542  google::iam::admin::v1::CreateRoleRequest const& request) override {
543  return google::cloud::internal::RetryLoop(
544  retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
545  idempotency_policy_->CreateRole(request),
546  [this](grpc::ClientContext& context,
547  google::iam::admin::v1::CreateRoleRequest const& request) {
548  return stub_->CreateRole(context, request);
549  },
550  request, __func__);
551  }
552 
553  StatusOr<google::iam::admin::v1::Role> UpdateRole(
554  google::iam::admin::v1::UpdateRoleRequest const& request) override {
555  return google::cloud::internal::RetryLoop(
556  retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
557  idempotency_policy_->UpdateRole(request),
558  [this](grpc::ClientContext& context,
559  google::iam::admin::v1::UpdateRoleRequest const& request) {
560  return stub_->UpdateRole(context, request);
561  },
562  request, __func__);
563  }
564 
565  StatusOr<google::iam::admin::v1::Role> DeleteRole(
566  google::iam::admin::v1::DeleteRoleRequest const& request) override {
567  return google::cloud::internal::RetryLoop(
568  retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
569  idempotency_policy_->DeleteRole(request),
570  [this](grpc::ClientContext& context,
571  google::iam::admin::v1::DeleteRoleRequest const& request) {
572  return stub_->DeleteRole(context, request);
573  },
574  request, __func__);
575  }
576 
577  StatusOr<google::iam::admin::v1::Role> UndeleteRole(
578  google::iam::admin::v1::UndeleteRoleRequest const& request) override {
579  return google::cloud::internal::RetryLoop(
580  retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
581  idempotency_policy_->UndeleteRole(request),
582  [this](grpc::ClientContext& context,
583  google::iam::admin::v1::UndeleteRoleRequest const& request) {
584  return stub_->UndeleteRole(context, request);
585  },
586  request, __func__);
587  }
588 
589  StreamRange<google::iam::admin::v1::Permission> QueryTestablePermissions(
590  google::iam::admin::v1::QueryTestablePermissionsRequest request)
591  override {
592  request.clear_page_token();
593  auto stub = stub_;
594  auto retry =
595  std::shared_ptr<IAMRetryPolicy const>(retry_policy_prototype_->clone());
596  auto backoff = std::shared_ptr<BackoffPolicy const>(
597  backoff_policy_prototype_->clone());
598  auto idempotency = idempotency_policy_->QueryTestablePermissions(request);
599  char const* function_name = __func__;
600  return google::cloud::internal::MakePaginationRange<
601  StreamRange<google::iam::admin::v1::Permission>>(
602  std::move(request),
603  [stub, retry, backoff, idempotency, function_name](
604  google::iam::admin::v1::QueryTestablePermissionsRequest const& r) {
605  return google::cloud::internal::RetryLoop(
606  retry->clone(), backoff->clone(), idempotency,
607  [stub](
608  grpc::ClientContext& context,
609  google::iam::admin::v1::QueryTestablePermissionsRequest const&
610  request) {
611  return stub->QueryTestablePermissions(context, request);
612  },
613  r, function_name);
614  },
615  [](google::iam::admin::v1::QueryTestablePermissionsResponse r) {
616  std::vector<google::iam::admin::v1::Permission> result(
617  r.permissions().size());
618  auto& messages = *r.mutable_permissions();
619  std::move(messages.begin(), messages.end(), result.begin());
620  return result;
621  });
622  }
623 
624  StatusOr<google::iam::admin::v1::QueryAuditableServicesResponse>
625  QueryAuditableServices(
626  google::iam::admin::v1::QueryAuditableServicesRequest const& request)
627  override {
628  return google::cloud::internal::RetryLoop(
629  retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
630  idempotency_policy_->QueryAuditableServices(request),
631  [this](grpc::ClientContext& context,
632  google::iam::admin::v1::QueryAuditableServicesRequest const&
633  request) {
634  return stub_->QueryAuditableServices(context, request);
635  },
636  request, __func__);
637  }
638 
639  StatusOr<google::iam::admin::v1::LintPolicyResponse> LintPolicy(
640  google::iam::admin::v1::LintPolicyRequest const& request) override {
641  return google::cloud::internal::RetryLoop(
642  retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
643  idempotency_policy_->LintPolicy(request),
644  [this](grpc::ClientContext& context,
645  google::iam::admin::v1::LintPolicyRequest const& request) {
646  return stub_->LintPolicy(context, request);
647  },
648  request, __func__);
649  }
650 
651  private:
652  std::unique_ptr<google::cloud::BackgroundThreads> background_;
653  std::shared_ptr<iam_internal::IAMStub> stub_;
654  std::unique_ptr<IAMRetryPolicy const> retry_policy_prototype_;
655  std::unique_ptr<BackoffPolicy const> backoff_policy_prototype_;
656  std::unique_ptr<IAMConnectionIdempotencyPolicy> idempotency_policy_;
657 };
658 } // namespace
659 
660 std::shared_ptr<IAMConnection> MakeIAMConnection(Options options) {
661  options = iam_internal::IAMDefaultOptions(std::move(options));
662  auto background = internal::MakeBackgroundThreadsFactory(options)();
663  auto stub = iam_internal::CreateDefaultIAMStub(background->cq(), options);
664  return std::make_shared<IAMConnectionImpl>(std::move(background),
665  std::move(stub), options);
666 }
667 
668 } // namespace GOOGLE_CLOUD_CPP_GENERATED_NS
669 } // namespace iam
670 } // namespace cloud
671 } // namespace google
672 
673 namespace google {
674 namespace cloud {
675 namespace iam_internal {
676 inline namespace GOOGLE_CLOUD_CPP_GENERATED_NS {
677 
678 std::shared_ptr<iam::IAMConnection> MakeIAMConnection(
679  std::shared_ptr<IAMStub> stub, Options options) {
680  options = IAMDefaultOptions(std::move(options));
681  return std::make_shared<iam::IAMConnectionImpl>(
682  internal::MakeBackgroundThreadsFactory(options)(), std::move(stub),
683  std::move(options));
684 }
685 
686 } // namespace GOOGLE_CLOUD_CPP_GENERATED_NS
687 } // namespace iam_internal
688 } // namespace cloud
689 } // namespace google