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\CreateRoleRequest; 21use Google\Service\Iam\ListRolesResponse; 22use Google\Service\Iam\Role; 23use Google\Service\Iam\UndeleteRoleRequest; 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 ProjectsRoles extends \Google\Service\Resource 34{ 35 /** 36 * Creates a new custom Role. (roles.create) 37 * 38 * @param string $parent The `parent` parameter's value depends on the target 39 * resource for the request, namely 40 * [`projects`](https://cloud.google.com/iam/reference/rest/v1/projects.roles) 41 * or [`organizations`](https://cloud.google.com/iam/reference/rest/v1/organizat 42 * ions.roles). Each resource type's `parent` value format is described below: * 43 * [`projects.roles.create()`](https://cloud.google.com/iam/reference/rest/v1/pr 44 * ojects.roles/create): `projects/{PROJECT_ID}`. This method creates project- 45 * level [custom roles](https://cloud.google.com/iam/docs/understanding-custom- 46 * roles). Example request URL: 47 * `https://iam.googleapis.com/v1/projects/{PROJECT_ID}/roles` * [`organizations 48 * .roles.create()`](https://cloud.google.com/iam/reference/rest/v1/organization 49 * s.roles/create): `organizations/{ORGANIZATION_ID}`. This method creates 50 * organization-level [custom roles](https://cloud.google.com/iam/docs 51 * /understanding-custom-roles). Example request URL: 52 * `https://iam.googleapis.com/v1/organizations/{ORGANIZATION_ID}/roles` Note: 53 * Wildcard (*) values are invalid; you must specify a complete project ID or 54 * organization ID. 55 * @param CreateRoleRequest $postBody 56 * @param array $optParams Optional parameters. 57 * @return Role 58 */ 59 public function create($parent, CreateRoleRequest $postBody, $optParams = []) 60 { 61 $params = ['parent' => $parent, 'postBody' => $postBody]; 62 $params = array_merge($params, $optParams); 63 return $this->call('create', [$params], Role::class); 64 } 65 /** 66 * Deletes a custom Role. When you delete a custom role, the following changes 67 * occur immediately: * You cannot bind a principal to the custom role in an IAM 68 * Policy. * Existing bindings to the custom role are not changed, but they have 69 * no effect. * By default, the response from ListRoles does not include the 70 * custom role. You have 7 days to undelete the custom role. After 7 days, the 71 * following changes occur: * The custom role is permanently deleted and cannot 72 * be recovered. * If an IAM policy contains a binding to the custom role, the 73 * binding is permanently removed. (roles.delete) 74 * 75 * @param string $name The `name` parameter's value depends on the target 76 * resource for the request, namely 77 * [`projects`](https://cloud.google.com/iam/reference/rest/v1/projects.roles) 78 * or [`organizations`](https://cloud.google.com/iam/reference/rest/v1/organizat 79 * ions.roles). Each resource type's `name` value format is described below: * [ 80 * `projects.roles.delete()`](https://cloud.google.com/iam/reference/rest/v1/pro 81 * jects.roles/delete): `projects/{PROJECT_ID}/roles/{CUSTOM_ROLE_ID}`. This 82 * method deletes only [custom roles](https://cloud.google.com/iam/docs 83 * /understanding-custom-roles) that have been created at the project level. 84 * Example request URL: 85 * `https://iam.googleapis.com/v1/projects/{PROJECT_ID}/roles/{CUSTOM_ROLE_ID}` 86 * * [`organizations.roles.delete()`](https://cloud.google.com/iam/reference/res 87 * t/v1/organizations.roles/delete): 88 * `organizations/{ORGANIZATION_ID}/roles/{CUSTOM_ROLE_ID}`. This method deletes 89 * only [custom roles](https://cloud.google.com/iam/docs/understanding-custom- 90 * roles) that have been created at the organization level. Example request URL: 91 * `https://iam.googleapis.com/v1/organizations/{ORGANIZATION_ID}/roles/{CUSTOM_ 92 * ROLE_ID}` Note: Wildcard (*) values are invalid; you must specify a complete 93 * project ID or organization ID. 94 * @param array $optParams Optional parameters. 95 * 96 * @opt_param string etag Used to perform a consistent read-modify-write. 97 * @return Role 98 */ 99 public function delete($name, $optParams = []) 100 { 101 $params = ['name' => $name]; 102 $params = array_merge($params, $optParams); 103 return $this->call('delete', [$params], Role::class); 104 } 105 /** 106 * Gets the definition of a Role. (roles.get) 107 * 108 * @param string $name The `name` parameter's value depends on the target 109 * resource for the request, namely 110 * [`roles`](https://cloud.google.com/iam/reference/rest/v1/roles), 111 * [`projects`](https://cloud.google.com/iam/reference/rest/v1/projects.roles), 112 * or [`organizations`](https://cloud.google.com/iam/reference/rest/v1/organizat 113 * ions.roles). Each resource type's `name` value format is described below: * 114 * [`roles.get()`](https://cloud.google.com/iam/reference/rest/v1/roles/get): 115 * `roles/{ROLE_NAME}`. This method returns results from all [predefined 116 * roles](https://cloud.google.com/iam/docs/understanding- 117 * roles#predefined_roles) in Cloud IAM. Example request URL: 118 * `https://iam.googleapis.com/v1/roles/{ROLE_NAME}` * [`projects.roles.get()`]( 119 * https://cloud.google.com/iam/reference/rest/v1/projects.roles/get): 120 * `projects/{PROJECT_ID}/roles/{CUSTOM_ROLE_ID}`. This method returns only 121 * [custom roles](https://cloud.google.com/iam/docs/understanding-custom-roles) 122 * that have been created at the project level. Example request URL: 123 * `https://iam.googleapis.com/v1/projects/{PROJECT_ID}/roles/{CUSTOM_ROLE_ID}` 124 * * [`organizations.roles.get()`](https://cloud.google.com/iam/reference/rest/v 125 * 1/organizations.roles/get): 126 * `organizations/{ORGANIZATION_ID}/roles/{CUSTOM_ROLE_ID}`. This method returns 127 * only [custom roles](https://cloud.google.com/iam/docs/understanding-custom- 128 * roles) that have been created at the organization level. Example request URL: 129 * `https://iam.googleapis.com/v1/organizations/{ORGANIZATION_ID}/roles/{CUSTOM_ 130 * ROLE_ID}` Note: Wildcard (*) values are invalid; you must specify a complete 131 * project ID or organization ID. 132 * @param array $optParams Optional parameters. 133 * @return Role 134 */ 135 public function get($name, $optParams = []) 136 { 137 $params = ['name' => $name]; 138 $params = array_merge($params, $optParams); 139 return $this->call('get', [$params], Role::class); 140 } 141 /** 142 * Lists every predefined Role that IAM supports, or every custom role that is 143 * defined for an organization or project. (roles.listProjectsRoles) 144 * 145 * @param string $parent The `parent` parameter's value depends on the target 146 * resource for the request, namely 147 * [`roles`](https://cloud.google.com/iam/reference/rest/v1/roles), 148 * [`projects`](https://cloud.google.com/iam/reference/rest/v1/projects.roles), 149 * or [`organizations`](https://cloud.google.com/iam/reference/rest/v1/organizat 150 * ions.roles). Each resource type's `parent` value format is described below: * 151 * [`roles.list()`](https://cloud.google.com/iam/reference/rest/v1/roles/list): 152 * An empty string. This method doesn't require a resource; it simply returns 153 * all [predefined roles](https://cloud.google.com/iam/docs/understanding- 154 * roles#predefined_roles) in Cloud IAM. Example request URL: 155 * `https://iam.googleapis.com/v1/roles` * [`projects.roles.list()`](https://clo 156 * ud.google.com/iam/reference/rest/v1/projects.roles/list): 157 * `projects/{PROJECT_ID}`. This method lists all project-level [custom 158 * roles](https://cloud.google.com/iam/docs/understanding-custom-roles). Example 159 * request URL: `https://iam.googleapis.com/v1/projects/{PROJECT_ID}/roles` * [` 160 * organizations.roles.list()`](https://cloud.google.com/iam/reference/rest/v1/o 161 * rganizations.roles/list): `organizations/{ORGANIZATION_ID}`. This method 162 * lists all organization-level [custom roles](https://cloud.google.com/iam/docs 163 * /understanding-custom-roles). Example request URL: 164 * `https://iam.googleapis.com/v1/organizations/{ORGANIZATION_ID}/roles` Note: 165 * Wildcard (*) values are invalid; you must specify a complete project ID or 166 * organization ID. 167 * @param array $optParams Optional parameters. 168 * 169 * @opt_param int pageSize Optional limit on the number of roles to include in 170 * the response. The default is 300, and the maximum is 1,000. 171 * @opt_param string pageToken Optional pagination token returned in an earlier 172 * ListRolesResponse. 173 * @opt_param bool showDeleted Include Roles that have been deleted. 174 * @opt_param string view Optional view for the returned Role objects. When 175 * `FULL` is specified, the `includedPermissions` field is returned, which 176 * includes a list of all permissions in the role. The default value is `BASIC`, 177 * which does not return the `includedPermissions` field. 178 * @return ListRolesResponse 179 */ 180 public function listProjectsRoles($parent, $optParams = []) 181 { 182 $params = ['parent' => $parent]; 183 $params = array_merge($params, $optParams); 184 return $this->call('list', [$params], ListRolesResponse::class); 185 } 186 /** 187 * Updates the definition of a custom Role. (roles.patch) 188 * 189 * @param string $name The `name` parameter's value depends on the target 190 * resource for the request, namely 191 * [`projects`](https://cloud.google.com/iam/reference/rest/v1/projects.roles) 192 * or [`organizations`](https://cloud.google.com/iam/reference/rest/v1/organizat 193 * ions.roles). Each resource type's `name` value format is described below: * [ 194 * `projects.roles.patch()`](https://cloud.google.com/iam/reference/rest/v1/proj 195 * ects.roles/patch): `projects/{PROJECT_ID}/roles/{CUSTOM_ROLE_ID}`. This 196 * method updates only [custom roles](https://cloud.google.com/iam/docs 197 * /understanding-custom-roles) that have been created at the project level. 198 * Example request URL: 199 * `https://iam.googleapis.com/v1/projects/{PROJECT_ID}/roles/{CUSTOM_ROLE_ID}` 200 * * [`organizations.roles.patch()`](https://cloud.google.com/iam/reference/rest 201 * /v1/organizations.roles/patch): 202 * `organizations/{ORGANIZATION_ID}/roles/{CUSTOM_ROLE_ID}`. This method updates 203 * only [custom roles](https://cloud.google.com/iam/docs/understanding-custom- 204 * roles) that have been created at the organization level. Example request URL: 205 * `https://iam.googleapis.com/v1/organizations/{ORGANIZATION_ID}/roles/{CUSTOM_ 206 * ROLE_ID}` Note: Wildcard (*) values are invalid; you must specify a complete 207 * project ID or organization ID. 208 * @param Role $postBody 209 * @param array $optParams Optional parameters. 210 * 211 * @opt_param string updateMask A mask describing which fields in the Role have 212 * changed. 213 * @return Role 214 */ 215 public function patch($name, Role $postBody, $optParams = []) 216 { 217 $params = ['name' => $name, 'postBody' => $postBody]; 218 $params = array_merge($params, $optParams); 219 return $this->call('patch', [$params], Role::class); 220 } 221 /** 222 * Undeletes a custom Role. (roles.undelete) 223 * 224 * @param string $name The `name` parameter's value depends on the target 225 * resource for the request, namely 226 * [`projects`](https://cloud.google.com/iam/reference/rest/v1/projects.roles) 227 * or [`organizations`](https://cloud.google.com/iam/reference/rest/v1/organizat 228 * ions.roles). Each resource type's `name` value format is described below: * [ 229 * `projects.roles.undelete()`](https://cloud.google.com/iam/reference/rest/v1/p 230 * rojects.roles/undelete): `projects/{PROJECT_ID}/roles/{CUSTOM_ROLE_ID}`. This 231 * method undeletes only [custom roles](https://cloud.google.com/iam/docs 232 * /understanding-custom-roles) that have been created at the project level. 233 * Example request URL: 234 * `https://iam.googleapis.com/v1/projects/{PROJECT_ID}/roles/{CUSTOM_ROLE_ID}` 235 * * [`organizations.roles.undelete()`](https://cloud.google.com/iam/reference/r 236 * est/v1/organizations.roles/undelete): 237 * `organizations/{ORGANIZATION_ID}/roles/{CUSTOM_ROLE_ID}`. This method 238 * undeletes only [custom roles](https://cloud.google.com/iam/docs 239 * /understanding-custom-roles) that have been created at the organization 240 * level. Example request URL: `https://iam.googleapis.com/v1/organizations/{ORG 241 * ANIZATION_ID}/roles/{CUSTOM_ROLE_ID}` Note: Wildcard (*) values are invalid; 242 * you must specify a complete project ID or organization ID. 243 * @param UndeleteRoleRequest $postBody 244 * @param array $optParams Optional parameters. 245 * @return Role 246 */ 247 public function undelete($name, UndeleteRoleRequest $postBody, $optParams = []) 248 { 249 $params = ['name' => $name, 'postBody' => $postBody]; 250 $params = array_merge($params, $optParams); 251 return $this->call('undelete', [$params], Role::class); 252 } 253} 254 255// Adding a class alias for backwards compatibility with the previous class name. 256class_alias(ProjectsRoles::class, 'Google_Service_Iam_Resource_ProjectsRoles'); 257