1<?php
2/*
3 * Copyright 2014 Google Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6 * use this file except in compliance with the License. You may obtain a copy of
7 * the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17
18namespace Google\Service\Iam\Resource;
19
20use Google\Service\Iam\ListRolesResponse;
21use Google\Service\Iam\QueryGrantableRolesRequest;
22use Google\Service\Iam\QueryGrantableRolesResponse;
23use Google\Service\Iam\Role;
24
25/**
26 * The "roles" collection of methods.
27 * Typical usage is:
28 *  <code>
29 *   $iamService = new Google\Service\Iam(...);
30 *   $roles = $iamService->roles;
31 *  </code>
32 */
33class Roles extends \Google\Service\Resource
34{
35  /**
36   * Gets the definition of a Role. (roles.get)
37   *
38   * @param string $name The `name` parameter's value depends on the target
39   * resource for the request, namely
40   * [`roles`](https://cloud.google.com/iam/reference/rest/v1/roles),
41   * [`projects`](https://cloud.google.com/iam/reference/rest/v1/projects.roles),
42   * or [`organizations`](https://cloud.google.com/iam/reference/rest/v1/organizat
43   * ions.roles). Each resource type's `name` value format is described below: *
44   * [`roles.get()`](https://cloud.google.com/iam/reference/rest/v1/roles/get):
45   * `roles/{ROLE_NAME}`. This method returns results from all [predefined
46   * roles](https://cloud.google.com/iam/docs/understanding-
47   * roles#predefined_roles) in Cloud IAM. Example request URL:
48   * `https://iam.googleapis.com/v1/roles/{ROLE_NAME}` * [`projects.roles.get()`](
49   * https://cloud.google.com/iam/reference/rest/v1/projects.roles/get):
50   * `projects/{PROJECT_ID}/roles/{CUSTOM_ROLE_ID}`. This method returns only
51   * [custom roles](https://cloud.google.com/iam/docs/understanding-custom-roles)
52   * that have been created at the project level. Example request URL:
53   * `https://iam.googleapis.com/v1/projects/{PROJECT_ID}/roles/{CUSTOM_ROLE_ID}`
54   * * [`organizations.roles.get()`](https://cloud.google.com/iam/reference/rest/v
55   * 1/organizations.roles/get):
56   * `organizations/{ORGANIZATION_ID}/roles/{CUSTOM_ROLE_ID}`. This method returns
57   * only [custom roles](https://cloud.google.com/iam/docs/understanding-custom-
58   * roles) that have been created at the organization level. Example request URL:
59   * `https://iam.googleapis.com/v1/organizations/{ORGANIZATION_ID}/roles/{CUSTOM_
60   * ROLE_ID}` Note: Wildcard (*) values are invalid; you must specify a complete
61   * project ID or organization ID.
62   * @param array $optParams Optional parameters.
63   * @return Role
64   */
65  public function get($name, $optParams = [])
66  {
67    $params = ['name' => $name];
68    $params = array_merge($params, $optParams);
69    return $this->call('get', [$params], Role::class);
70  }
71  /**
72   * Lists every predefined Role that IAM supports, or every custom role that is
73   * defined for an organization or project. (roles.listRoles)
74   *
75   * @param array $optParams Optional parameters.
76   *
77   * @opt_param int pageSize Optional limit on the number of roles to include in
78   * the response. The default is 300, and the maximum is 1,000.
79   * @opt_param string pageToken Optional pagination token returned in an earlier
80   * ListRolesResponse.
81   * @opt_param string parent The `parent` parameter's value depends on the target
82   * resource for the request, namely
83   * [`roles`](https://cloud.google.com/iam/reference/rest/v1/roles),
84   * [`projects`](https://cloud.google.com/iam/reference/rest/v1/projects.roles),
85   * or [`organizations`](https://cloud.google.com/iam/reference/rest/v1/organizat
86   * ions.roles). Each resource type's `parent` value format is described below: *
87   * [`roles.list()`](https://cloud.google.com/iam/reference/rest/v1/roles/list):
88   * An empty string. This method doesn't require a resource; it simply returns
89   * all [predefined roles](https://cloud.google.com/iam/docs/understanding-
90   * roles#predefined_roles) in Cloud IAM. Example request URL:
91   * `https://iam.googleapis.com/v1/roles` * [`projects.roles.list()`](https://clo
92   * ud.google.com/iam/reference/rest/v1/projects.roles/list):
93   * `projects/{PROJECT_ID}`. This method lists all project-level [custom
94   * roles](https://cloud.google.com/iam/docs/understanding-custom-roles). Example
95   * request URL: `https://iam.googleapis.com/v1/projects/{PROJECT_ID}/roles` * [`
96   * organizations.roles.list()`](https://cloud.google.com/iam/reference/rest/v1/o
97   * rganizations.roles/list): `organizations/{ORGANIZATION_ID}`. This method
98   * lists all organization-level [custom roles](https://cloud.google.com/iam/docs
99   * /understanding-custom-roles). Example request URL:
100   * `https://iam.googleapis.com/v1/organizations/{ORGANIZATION_ID}/roles` Note:
101   * Wildcard (*) values are invalid; you must specify a complete project ID or
102   * organization ID.
103   * @opt_param bool showDeleted Include Roles that have been deleted.
104   * @opt_param string view Optional view for the returned Role objects. When
105   * `FULL` is specified, the `includedPermissions` field is returned, which
106   * includes a list of all permissions in the role. The default value is `BASIC`,
107   * which does not return the `includedPermissions` field.
108   * @return ListRolesResponse
109   */
110  public function listRoles($optParams = [])
111  {
112    $params = [];
113    $params = array_merge($params, $optParams);
114    return $this->call('list', [$params], ListRolesResponse::class);
115  }
116  /**
117   * Lists roles that can be granted on a Google Cloud resource. A role is
118   * grantable if the IAM policy for the resource can contain bindings to the
119   * role. (roles.queryGrantableRoles)
120   *
121   * @param QueryGrantableRolesRequest $postBody
122   * @param array $optParams Optional parameters.
123   * @return QueryGrantableRolesResponse
124   */
125  public function queryGrantableRoles(QueryGrantableRolesRequest $postBody, $optParams = [])
126  {
127    $params = ['postBody' => $postBody];
128    $params = array_merge($params, $optParams);
129    return $this->call('queryGrantableRoles', [$params], QueryGrantableRolesResponse::class);
130  }
131}
132
133// Adding a class alias for backwards compatibility with the previous class name.
134class_alias(Roles::class, 'Google_Service_Iam_Resource_Roles');
135