1"""Generated client library for iam version v1."""
2# NOTE: This file is autogenerated and should not be edited by hand.
3from apitools.base.py import base_api
4from samples.iam_sample.iam_v1 import iam_v1_messages as messages
5
6
7class IamV1(base_api.BaseApiClient):
8  """Generated client library for service iam version v1."""
9
10  MESSAGES_MODULE = messages
11  BASE_URL = u'https://iam.googleapis.com/'
12
13  _PACKAGE = u'iam'
14  _SCOPES = [u'https://www.googleapis.com/auth/cloud-platform']
15  _VERSION = u'v1'
16  _CLIENT_ID = '1042881264118.apps.googleusercontent.com'
17  _CLIENT_SECRET = 'x_Tw5K8nnjoRAqULM9PFAC2b'
18  _USER_AGENT = 'x_Tw5K8nnjoRAqULM9PFAC2b'
19  _CLIENT_CLASS_NAME = u'IamV1'
20  _URL_VERSION = u'v1'
21  _API_KEY = None
22
23  def __init__(self, url='', credentials=None,
24               get_credentials=True, http=None, model=None,
25               log_request=False, log_response=False,
26               credentials_args=None, default_global_params=None,
27               additional_http_headers=None):
28    """Create a new iam handle."""
29    url = url or self.BASE_URL
30    super(IamV1, self).__init__(
31        url, credentials=credentials,
32        get_credentials=get_credentials, http=http, model=model,
33        log_request=log_request, log_response=log_response,
34        credentials_args=credentials_args,
35        default_global_params=default_global_params,
36        additional_http_headers=additional_http_headers)
37    self.iamPolicies = self.IamPoliciesService(self)
38    self.projects_serviceAccounts_keys = self.ProjectsServiceAccountsKeysService(self)
39    self.projects_serviceAccounts = self.ProjectsServiceAccountsService(self)
40    self.projects = self.ProjectsService(self)
41    self.roles = self.RolesService(self)
42
43  class IamPoliciesService(base_api.BaseApiService):
44    """Service class for the iamPolicies resource."""
45
46    _NAME = u'iamPolicies'
47
48    def __init__(self, client):
49      super(IamV1.IamPoliciesService, self).__init__(client)
50      self._upload_configs = {
51          }
52
53    def GetPolicyDetails(self, request, global_params=None):
54      """Returns the current IAM policy and the policies on the inherited resources.
55that the user has access to.
56
57      Args:
58        request: (GetPolicyDetailsRequest) input message
59        global_params: (StandardQueryParameters, default: None) global arguments
60      Returns:
61        (GetPolicyDetailsResponse) The response message.
62      """
63      config = self.GetMethodConfig('GetPolicyDetails')
64      return self._RunMethod(
65          config, request, global_params=global_params)
66
67    GetPolicyDetails.method_config = lambda: base_api.ApiMethodInfo(
68        http_method=u'POST',
69        method_id=u'iam.iamPolicies.getPolicyDetails',
70        ordered_params=[],
71        path_params=[],
72        query_params=[],
73        relative_path=u'v1/iamPolicies:getPolicyDetails',
74        request_field='<request>',
75        request_type_name=u'GetPolicyDetailsRequest',
76        response_type_name=u'GetPolicyDetailsResponse',
77        supports_download=False,
78    )
79
80  class ProjectsServiceAccountsKeysService(base_api.BaseApiService):
81    """Service class for the projects_serviceAccounts_keys resource."""
82
83    _NAME = u'projects_serviceAccounts_keys'
84
85    def __init__(self, client):
86      super(IamV1.ProjectsServiceAccountsKeysService, self).__init__(client)
87      self._upload_configs = {
88          }
89
90    def Create(self, request, global_params=None):
91      """Creates a ServiceAccountKey.
92and returns it.
93
94      Args:
95        request: (IamProjectsServiceAccountsKeysCreateRequest) input message
96        global_params: (StandardQueryParameters, default: None) global arguments
97      Returns:
98        (ServiceAccountKey) The response message.
99      """
100      config = self.GetMethodConfig('Create')
101      return self._RunMethod(
102          config, request, global_params=global_params)
103
104    Create.method_config = lambda: base_api.ApiMethodInfo(
105        flat_path=u'v1/projects/{projectsId}/serviceAccounts/{serviceAccountsId}/keys',
106        http_method=u'POST',
107        method_id=u'iam.projects.serviceAccounts.keys.create',
108        ordered_params=[u'name'],
109        path_params=[u'name'],
110        query_params=[],
111        relative_path=u'v1/{+name}/keys',
112        request_field=u'createServiceAccountKeyRequest',
113        request_type_name=u'IamProjectsServiceAccountsKeysCreateRequest',
114        response_type_name=u'ServiceAccountKey',
115        supports_download=False,
116    )
117
118    def Delete(self, request, global_params=None):
119      """Deletes a ServiceAccountKey.
120
121      Args:
122        request: (IamProjectsServiceAccountsKeysDeleteRequest) input message
123        global_params: (StandardQueryParameters, default: None) global arguments
124      Returns:
125        (Empty) The response message.
126      """
127      config = self.GetMethodConfig('Delete')
128      return self._RunMethod(
129          config, request, global_params=global_params)
130
131    Delete.method_config = lambda: base_api.ApiMethodInfo(
132        flat_path=u'v1/projects/{projectsId}/serviceAccounts/{serviceAccountsId}/keys/{keysId}',
133        http_method=u'DELETE',
134        method_id=u'iam.projects.serviceAccounts.keys.delete',
135        ordered_params=[u'name'],
136        path_params=[u'name'],
137        query_params=[],
138        relative_path=u'v1/{+name}',
139        request_field='',
140        request_type_name=u'IamProjectsServiceAccountsKeysDeleteRequest',
141        response_type_name=u'Empty',
142        supports_download=False,
143    )
144
145    def Get(self, request, global_params=None):
146      """Gets the ServiceAccountKey.
147by key id.
148
149      Args:
150        request: (IamProjectsServiceAccountsKeysGetRequest) input message
151        global_params: (StandardQueryParameters, default: None) global arguments
152      Returns:
153        (ServiceAccountKey) The response message.
154      """
155      config = self.GetMethodConfig('Get')
156      return self._RunMethod(
157          config, request, global_params=global_params)
158
159    Get.method_config = lambda: base_api.ApiMethodInfo(
160        flat_path=u'v1/projects/{projectsId}/serviceAccounts/{serviceAccountsId}/keys/{keysId}',
161        http_method=u'GET',
162        method_id=u'iam.projects.serviceAccounts.keys.get',
163        ordered_params=[u'name'],
164        path_params=[u'name'],
165        query_params=[u'publicKeyType'],
166        relative_path=u'v1/{+name}',
167        request_field='',
168        request_type_name=u'IamProjectsServiceAccountsKeysGetRequest',
169        response_type_name=u'ServiceAccountKey',
170        supports_download=False,
171    )
172
173    def List(self, request, global_params=None):
174      """Lists ServiceAccountKeys.
175
176      Args:
177        request: (IamProjectsServiceAccountsKeysListRequest) input message
178        global_params: (StandardQueryParameters, default: None) global arguments
179      Returns:
180        (ListServiceAccountKeysResponse) The response message.
181      """
182      config = self.GetMethodConfig('List')
183      return self._RunMethod(
184          config, request, global_params=global_params)
185
186    List.method_config = lambda: base_api.ApiMethodInfo(
187        flat_path=u'v1/projects/{projectsId}/serviceAccounts/{serviceAccountsId}/keys',
188        http_method=u'GET',
189        method_id=u'iam.projects.serviceAccounts.keys.list',
190        ordered_params=[u'name'],
191        path_params=[u'name'],
192        query_params=[u'keyTypes'],
193        relative_path=u'v1/{+name}/keys',
194        request_field='',
195        request_type_name=u'IamProjectsServiceAccountsKeysListRequest',
196        response_type_name=u'ListServiceAccountKeysResponse',
197        supports_download=False,
198    )
199
200  class ProjectsServiceAccountsService(base_api.BaseApiService):
201    """Service class for the projects_serviceAccounts resource."""
202
203    _NAME = u'projects_serviceAccounts'
204
205    def __init__(self, client):
206      super(IamV1.ProjectsServiceAccountsService, self).__init__(client)
207      self._upload_configs = {
208          }
209
210    def Create(self, request, global_params=None):
211      """Creates a ServiceAccount.
212and returns it.
213
214      Args:
215        request: (IamProjectsServiceAccountsCreateRequest) input message
216        global_params: (StandardQueryParameters, default: None) global arguments
217      Returns:
218        (ServiceAccount) The response message.
219      """
220      config = self.GetMethodConfig('Create')
221      return self._RunMethod(
222          config, request, global_params=global_params)
223
224    Create.method_config = lambda: base_api.ApiMethodInfo(
225        flat_path=u'v1/projects/{projectsId}/serviceAccounts',
226        http_method=u'POST',
227        method_id=u'iam.projects.serviceAccounts.create',
228        ordered_params=[u'name'],
229        path_params=[u'name'],
230        query_params=[],
231        relative_path=u'v1/{+name}/serviceAccounts',
232        request_field=u'createServiceAccountRequest',
233        request_type_name=u'IamProjectsServiceAccountsCreateRequest',
234        response_type_name=u'ServiceAccount',
235        supports_download=False,
236    )
237
238    def Delete(self, request, global_params=None):
239      """Deletes a ServiceAccount.
240
241      Args:
242        request: (IamProjectsServiceAccountsDeleteRequest) input message
243        global_params: (StandardQueryParameters, default: None) global arguments
244      Returns:
245        (Empty) The response message.
246      """
247      config = self.GetMethodConfig('Delete')
248      return self._RunMethod(
249          config, request, global_params=global_params)
250
251    Delete.method_config = lambda: base_api.ApiMethodInfo(
252        flat_path=u'v1/projects/{projectsId}/serviceAccounts/{serviceAccountsId}',
253        http_method=u'DELETE',
254        method_id=u'iam.projects.serviceAccounts.delete',
255        ordered_params=[u'name'],
256        path_params=[u'name'],
257        query_params=[],
258        relative_path=u'v1/{+name}',
259        request_field='',
260        request_type_name=u'IamProjectsServiceAccountsDeleteRequest',
261        response_type_name=u'Empty',
262        supports_download=False,
263    )
264
265    def Get(self, request, global_params=None):
266      """Gets a ServiceAccount.
267
268      Args:
269        request: (IamProjectsServiceAccountsGetRequest) input message
270        global_params: (StandardQueryParameters, default: None) global arguments
271      Returns:
272        (ServiceAccount) The response message.
273      """
274      config = self.GetMethodConfig('Get')
275      return self._RunMethod(
276          config, request, global_params=global_params)
277
278    Get.method_config = lambda: base_api.ApiMethodInfo(
279        flat_path=u'v1/projects/{projectsId}/serviceAccounts/{serviceAccountsId}',
280        http_method=u'GET',
281        method_id=u'iam.projects.serviceAccounts.get',
282        ordered_params=[u'name'],
283        path_params=[u'name'],
284        query_params=[],
285        relative_path=u'v1/{+name}',
286        request_field='',
287        request_type_name=u'IamProjectsServiceAccountsGetRequest',
288        response_type_name=u'ServiceAccount',
289        supports_download=False,
290    )
291
292    def GetIamPolicy(self, request, global_params=None):
293      """Returns the IAM access control policy for specified IAM resource.
294
295      Args:
296        request: (IamProjectsServiceAccountsGetIamPolicyRequest) input message
297        global_params: (StandardQueryParameters, default: None) global arguments
298      Returns:
299        (Policy) The response message.
300      """
301      config = self.GetMethodConfig('GetIamPolicy')
302      return self._RunMethod(
303          config, request, global_params=global_params)
304
305    GetIamPolicy.method_config = lambda: base_api.ApiMethodInfo(
306        flat_path=u'v1/projects/{projectsId}/serviceAccounts/{serviceAccountsId}:getIamPolicy',
307        http_method=u'POST',
308        method_id=u'iam.projects.serviceAccounts.getIamPolicy',
309        ordered_params=[u'resource'],
310        path_params=[u'resource'],
311        query_params=[],
312        relative_path=u'v1/{+resource}:getIamPolicy',
313        request_field='',
314        request_type_name=u'IamProjectsServiceAccountsGetIamPolicyRequest',
315        response_type_name=u'Policy',
316        supports_download=False,
317    )
318
319    def List(self, request, global_params=None):
320      """Lists ServiceAccounts for a project.
321
322      Args:
323        request: (IamProjectsServiceAccountsListRequest) input message
324        global_params: (StandardQueryParameters, default: None) global arguments
325      Returns:
326        (ListServiceAccountsResponse) The response message.
327      """
328      config = self.GetMethodConfig('List')
329      return self._RunMethod(
330          config, request, global_params=global_params)
331
332    List.method_config = lambda: base_api.ApiMethodInfo(
333        flat_path=u'v1/projects/{projectsId}/serviceAccounts',
334        http_method=u'GET',
335        method_id=u'iam.projects.serviceAccounts.list',
336        ordered_params=[u'name'],
337        path_params=[u'name'],
338        query_params=[u'pageSize', u'pageToken', u'removeDeletedServiceAccounts'],
339        relative_path=u'v1/{+name}/serviceAccounts',
340        request_field='',
341        request_type_name=u'IamProjectsServiceAccountsListRequest',
342        response_type_name=u'ListServiceAccountsResponse',
343        supports_download=False,
344    )
345
346    def SetIamPolicy(self, request, global_params=None):
347      """Sets the IAM access control policy for the specified IAM resource.
348
349      Args:
350        request: (IamProjectsServiceAccountsSetIamPolicyRequest) input message
351        global_params: (StandardQueryParameters, default: None) global arguments
352      Returns:
353        (Policy) The response message.
354      """
355      config = self.GetMethodConfig('SetIamPolicy')
356      return self._RunMethod(
357          config, request, global_params=global_params)
358
359    SetIamPolicy.method_config = lambda: base_api.ApiMethodInfo(
360        flat_path=u'v1/projects/{projectsId}/serviceAccounts/{serviceAccountsId}:setIamPolicy',
361        http_method=u'POST',
362        method_id=u'iam.projects.serviceAccounts.setIamPolicy',
363        ordered_params=[u'resource'],
364        path_params=[u'resource'],
365        query_params=[],
366        relative_path=u'v1/{+resource}:setIamPolicy',
367        request_field=u'setIamPolicyRequest',
368        request_type_name=u'IamProjectsServiceAccountsSetIamPolicyRequest',
369        response_type_name=u'Policy',
370        supports_download=False,
371    )
372
373    def SignBlob(self, request, global_params=None):
374      """Signs a blob using a service account's system-managed private key.
375
376      Args:
377        request: (IamProjectsServiceAccountsSignBlobRequest) input message
378        global_params: (StandardQueryParameters, default: None) global arguments
379      Returns:
380        (SignBlobResponse) The response message.
381      """
382      config = self.GetMethodConfig('SignBlob')
383      return self._RunMethod(
384          config, request, global_params=global_params)
385
386    SignBlob.method_config = lambda: base_api.ApiMethodInfo(
387        flat_path=u'v1/projects/{projectsId}/serviceAccounts/{serviceAccountsId}:signBlob',
388        http_method=u'POST',
389        method_id=u'iam.projects.serviceAccounts.signBlob',
390        ordered_params=[u'name'],
391        path_params=[u'name'],
392        query_params=[],
393        relative_path=u'v1/{+name}:signBlob',
394        request_field=u'signBlobRequest',
395        request_type_name=u'IamProjectsServiceAccountsSignBlobRequest',
396        response_type_name=u'SignBlobResponse',
397        supports_download=False,
398    )
399
400    def SignJwt(self, request, global_params=None):
401      """Signs a JWT using a service account's system-managed private key.
402
403If no `exp` (expiry) time is contained in the claims, we will
404provide an expiry of one hour in the future. If an expiry
405of more than one hour in the future is requested, the request
406will fail.
407
408      Args:
409        request: (IamProjectsServiceAccountsSignJwtRequest) input message
410        global_params: (StandardQueryParameters, default: None) global arguments
411      Returns:
412        (SignJwtResponse) The response message.
413      """
414      config = self.GetMethodConfig('SignJwt')
415      return self._RunMethod(
416          config, request, global_params=global_params)
417
418    SignJwt.method_config = lambda: base_api.ApiMethodInfo(
419        flat_path=u'v1/projects/{projectsId}/serviceAccounts/{serviceAccountsId}:signJwt',
420        http_method=u'POST',
421        method_id=u'iam.projects.serviceAccounts.signJwt',
422        ordered_params=[u'name'],
423        path_params=[u'name'],
424        query_params=[],
425        relative_path=u'v1/{+name}:signJwt',
426        request_field=u'signJwtRequest',
427        request_type_name=u'IamProjectsServiceAccountsSignJwtRequest',
428        response_type_name=u'SignJwtResponse',
429        supports_download=False,
430    )
431
432    def TestIamPermissions(self, request, global_params=None):
433      """Tests the specified permissions against the IAM access control policy.
434for the specified IAM resource.
435
436      Args:
437        request: (IamProjectsServiceAccountsTestIamPermissionsRequest) input message
438        global_params: (StandardQueryParameters, default: None) global arguments
439      Returns:
440        (TestIamPermissionsResponse) The response message.
441      """
442      config = self.GetMethodConfig('TestIamPermissions')
443      return self._RunMethod(
444          config, request, global_params=global_params)
445
446    TestIamPermissions.method_config = lambda: base_api.ApiMethodInfo(
447        flat_path=u'v1/projects/{projectsId}/serviceAccounts/{serviceAccountsId}:testIamPermissions',
448        http_method=u'POST',
449        method_id=u'iam.projects.serviceAccounts.testIamPermissions',
450        ordered_params=[u'resource'],
451        path_params=[u'resource'],
452        query_params=[],
453        relative_path=u'v1/{+resource}:testIamPermissions',
454        request_field=u'testIamPermissionsRequest',
455        request_type_name=u'IamProjectsServiceAccountsTestIamPermissionsRequest',
456        response_type_name=u'TestIamPermissionsResponse',
457        supports_download=False,
458    )
459
460    def Update(self, request, global_params=None):
461      """Updates a ServiceAccount.
462
463Currently, only the following fields are updatable:
464`display_name` .
465The `etag` is mandatory.
466
467      Args:
468        request: (ServiceAccount) input message
469        global_params: (StandardQueryParameters, default: None) global arguments
470      Returns:
471        (ServiceAccount) The response message.
472      """
473      config = self.GetMethodConfig('Update')
474      return self._RunMethod(
475          config, request, global_params=global_params)
476
477    Update.method_config = lambda: base_api.ApiMethodInfo(
478        flat_path=u'v1/projects/{projectsId}/serviceAccounts/{serviceAccountsId}',
479        http_method=u'PUT',
480        method_id=u'iam.projects.serviceAccounts.update',
481        ordered_params=[u'name'],
482        path_params=[u'name'],
483        query_params=[],
484        relative_path=u'v1/{+name}',
485        request_field='<request>',
486        request_type_name=u'ServiceAccount',
487        response_type_name=u'ServiceAccount',
488        supports_download=False,
489    )
490
491  class ProjectsService(base_api.BaseApiService):
492    """Service class for the projects resource."""
493
494    _NAME = u'projects'
495
496    def __init__(self, client):
497      super(IamV1.ProjectsService, self).__init__(client)
498      self._upload_configs = {
499          }
500
501  class RolesService(base_api.BaseApiService):
502    """Service class for the roles resource."""
503
504    _NAME = u'roles'
505
506    def __init__(self, client):
507      super(IamV1.RolesService, self).__init__(client)
508      self._upload_configs = {
509          }
510
511    def QueryGrantableRoles(self, request, global_params=None):
512      """Queries roles that can be granted on a particular resource.
513
514      Args:
515        request: (QueryGrantableRolesRequest) input message
516        global_params: (StandardQueryParameters, default: None) global arguments
517      Returns:
518        (QueryGrantableRolesResponse) The response message.
519      """
520      config = self.GetMethodConfig('QueryGrantableRoles')
521      return self._RunMethod(
522          config, request, global_params=global_params)
523
524    QueryGrantableRoles.method_config = lambda: base_api.ApiMethodInfo(
525        http_method=u'POST',
526        method_id=u'iam.roles.queryGrantableRoles',
527        ordered_params=[],
528        path_params=[],
529        query_params=[],
530        relative_path=u'v1/roles:queryGrantableRoles',
531        request_field='<request>',
532        request_type_name=u'QueryGrantableRolesRequest',
533        response_type_name=u'QueryGrantableRolesResponse',
534        supports_download=False,
535    )
536