[e3d4e0a] | 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 |
|
---|
| 18 | namespace Google\Service\CloudResourceManager\Resource;
|
---|
| 19 |
|
---|
| 20 | use Google\Service\CloudResourceManager\GetIamPolicyRequest;
|
---|
| 21 | use Google\Service\CloudResourceManager\ListProjectsResponse;
|
---|
| 22 | use Google\Service\CloudResourceManager\MoveProjectRequest;
|
---|
| 23 | use Google\Service\CloudResourceManager\Operation;
|
---|
| 24 | use Google\Service\CloudResourceManager\Policy;
|
---|
| 25 | use Google\Service\CloudResourceManager\Project;
|
---|
| 26 | use Google\Service\CloudResourceManager\SearchProjectsResponse;
|
---|
| 27 | use Google\Service\CloudResourceManager\SetIamPolicyRequest;
|
---|
| 28 | use Google\Service\CloudResourceManager\TestIamPermissionsRequest;
|
---|
| 29 | use Google\Service\CloudResourceManager\TestIamPermissionsResponse;
|
---|
| 30 | use Google\Service\CloudResourceManager\UndeleteProjectRequest;
|
---|
| 31 |
|
---|
| 32 | /**
|
---|
| 33 | * The "projects" collection of methods.
|
---|
| 34 | * Typical usage is:
|
---|
| 35 | * <code>
|
---|
| 36 | * $cloudresourcemanagerService = new Google\Service\CloudResourceManager(...);
|
---|
| 37 | * $projects = $cloudresourcemanagerService->projects;
|
---|
| 38 | * </code>
|
---|
| 39 | */
|
---|
| 40 | class Projects extends \Google\Service\Resource
|
---|
| 41 | {
|
---|
| 42 | /**
|
---|
| 43 | * Request that a new project be created. The result is an `Operation` which can
|
---|
| 44 | * be used to track the creation process. This process usually takes a few
|
---|
| 45 | * seconds, but can sometimes take much longer. The tracking `Operation` is
|
---|
| 46 | * automatically deleted after a few hours, so there is no need to call
|
---|
| 47 | * `DeleteOperation`. (projects.create)
|
---|
| 48 | *
|
---|
| 49 | * @param Project $postBody
|
---|
| 50 | * @param array $optParams Optional parameters.
|
---|
| 51 | * @return Operation
|
---|
| 52 | * @throws \Google\Service\Exception
|
---|
| 53 | */
|
---|
| 54 | public function create(Project $postBody, $optParams = [])
|
---|
| 55 | {
|
---|
| 56 | $params = ['postBody' => $postBody];
|
---|
| 57 | $params = array_merge($params, $optParams);
|
---|
| 58 | return $this->call('create', [$params], Operation::class);
|
---|
| 59 | }
|
---|
| 60 | /**
|
---|
| 61 | * Marks the project identified by the specified `name` (for example,
|
---|
| 62 | * `projects/415104041262`) for deletion. This method will only affect the
|
---|
| 63 | * project if it has a lifecycle state of ACTIVE. This method changes the
|
---|
| 64 | * Project's lifecycle state from ACTIVE to DELETE_REQUESTED. The deletion
|
---|
| 65 | * starts at an unspecified time, at which point the Project is no longer
|
---|
| 66 | * accessible. Until the deletion completes, you can check the lifecycle state
|
---|
| 67 | * checked by retrieving the project with GetProject, and the project remains
|
---|
| 68 | * visible to ListProjects. However, you cannot update the project. After the
|
---|
| 69 | * deletion completes, the project is not retrievable by the GetProject,
|
---|
| 70 | * ListProjects, and SearchProjects methods. This method behaves idempotently,
|
---|
| 71 | * such that deleting a `DELETE_REQUESTED` project will not cause an error, but
|
---|
| 72 | * also won't do anything. The caller must have
|
---|
| 73 | * `resourcemanager.projects.delete` permissions for this project.
|
---|
| 74 | * (projects.delete)
|
---|
| 75 | *
|
---|
| 76 | * @param string $name Required. The name of the Project (for example,
|
---|
| 77 | * `projects/415104041262`).
|
---|
| 78 | * @param array $optParams Optional parameters.
|
---|
| 79 | * @return Operation
|
---|
| 80 | * @throws \Google\Service\Exception
|
---|
| 81 | */
|
---|
| 82 | public function delete($name, $optParams = [])
|
---|
| 83 | {
|
---|
| 84 | $params = ['name' => $name];
|
---|
| 85 | $params = array_merge($params, $optParams);
|
---|
| 86 | return $this->call('delete', [$params], Operation::class);
|
---|
| 87 | }
|
---|
| 88 | /**
|
---|
| 89 | * Retrieves the project identified by the specified `name` (for example,
|
---|
| 90 | * `projects/415104041262`). The caller must have `resourcemanager.projects.get`
|
---|
| 91 | * permission for this project. (projects.get)
|
---|
| 92 | *
|
---|
| 93 | * @param string $name Required. The name of the project (for example,
|
---|
| 94 | * `projects/415104041262`).
|
---|
| 95 | * @param array $optParams Optional parameters.
|
---|
| 96 | * @return Project
|
---|
| 97 | * @throws \Google\Service\Exception
|
---|
| 98 | */
|
---|
| 99 | public function get($name, $optParams = [])
|
---|
| 100 | {
|
---|
| 101 | $params = ['name' => $name];
|
---|
| 102 | $params = array_merge($params, $optParams);
|
---|
| 103 | return $this->call('get', [$params], Project::class);
|
---|
| 104 | }
|
---|
| 105 | /**
|
---|
| 106 | * Returns the IAM access control policy for the specified project, in the
|
---|
| 107 | * format `projects/{ProjectIdOrNumber}` e.g. projects/123. Permission is denied
|
---|
| 108 | * if the policy or the resource do not exist. (projects.getIamPolicy)
|
---|
| 109 | *
|
---|
| 110 | * @param string $resource REQUIRED: The resource for which the policy is being
|
---|
| 111 | * requested. See [Resource
|
---|
| 112 | * names](https://cloud.google.com/apis/design/resource_names) for the
|
---|
| 113 | * appropriate value for this field.
|
---|
| 114 | * @param GetIamPolicyRequest $postBody
|
---|
| 115 | * @param array $optParams Optional parameters.
|
---|
| 116 | * @return Policy
|
---|
| 117 | * @throws \Google\Service\Exception
|
---|
| 118 | */
|
---|
| 119 | public function getIamPolicy($resource, GetIamPolicyRequest $postBody, $optParams = [])
|
---|
| 120 | {
|
---|
| 121 | $params = ['resource' => $resource, 'postBody' => $postBody];
|
---|
| 122 | $params = array_merge($params, $optParams);
|
---|
| 123 | return $this->call('getIamPolicy', [$params], Policy::class);
|
---|
| 124 | }
|
---|
| 125 | /**
|
---|
| 126 | * Lists projects that are direct children of the specified folder or
|
---|
| 127 | * organization resource. `list()` provides a strongly consistent view of the
|
---|
| 128 | * projects underneath the specified parent resource. `list()` returns projects
|
---|
| 129 | * sorted based upon the (ascending) lexical ordering of their `display_name`.
|
---|
| 130 | * The caller must have `resourcemanager.projects.list` permission on the
|
---|
| 131 | * identified parent. (projects.listProjects)
|
---|
| 132 | *
|
---|
| 133 | * @param array $optParams Optional parameters.
|
---|
| 134 | *
|
---|
| 135 | * @opt_param int pageSize Optional. The maximum number of projects to return in
|
---|
| 136 | * the response. The server can return fewer projects than requested. If
|
---|
| 137 | * unspecified, server picks an appropriate default.
|
---|
| 138 | * @opt_param string pageToken Optional. A pagination token returned from a
|
---|
| 139 | * previous call to ListProjects that indicates from where listing should
|
---|
| 140 | * continue.
|
---|
| 141 | * @opt_param string parent Required. The name of the parent resource whose
|
---|
| 142 | * projects are being listed. Only children of this parent resource are listed;
|
---|
| 143 | * descendants are not listed. If the parent is a folder, use the value
|
---|
| 144 | * `folders/{folder_id}`. If the parent is an organization, use the value
|
---|
| 145 | * `organizations/{org_id}`.
|
---|
| 146 | * @opt_param bool showDeleted Optional. Indicate that projects in the
|
---|
| 147 | * `DELETE_REQUESTED` state should also be returned. Normally only `ACTIVE`
|
---|
| 148 | * projects are returned.
|
---|
| 149 | * @return ListProjectsResponse
|
---|
| 150 | * @throws \Google\Service\Exception
|
---|
| 151 | */
|
---|
| 152 | public function listProjects($optParams = [])
|
---|
| 153 | {
|
---|
| 154 | $params = [];
|
---|
| 155 | $params = array_merge($params, $optParams);
|
---|
| 156 | return $this->call('list', [$params], ListProjectsResponse::class);
|
---|
| 157 | }
|
---|
| 158 | /**
|
---|
| 159 | * Move a project to another place in your resource hierarchy, under a new
|
---|
| 160 | * resource parent. Returns an operation which can be used to track the process
|
---|
| 161 | * of the project move workflow. Upon success, the `Operation.response` field
|
---|
| 162 | * will be populated with the moved project. The caller must have
|
---|
| 163 | * `resourcemanager.projects.move` permission on the project, on the project's
|
---|
| 164 | * current and proposed new parent. If project has no current parent, or it
|
---|
| 165 | * currently does not have an associated organization resource, you will also
|
---|
| 166 | * need the `resourcemanager.projects.setIamPolicy` permission in the project.
|
---|
| 167 | * (projects.move)
|
---|
| 168 | *
|
---|
| 169 | * @param string $name Required. The name of the project to move.
|
---|
| 170 | * @param MoveProjectRequest $postBody
|
---|
| 171 | * @param array $optParams Optional parameters.
|
---|
| 172 | * @return Operation
|
---|
| 173 | * @throws \Google\Service\Exception
|
---|
| 174 | */
|
---|
| 175 | public function move($name, MoveProjectRequest $postBody, $optParams = [])
|
---|
| 176 | {
|
---|
| 177 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
| 178 | $params = array_merge($params, $optParams);
|
---|
| 179 | return $this->call('move', [$params], Operation::class);
|
---|
| 180 | }
|
---|
| 181 | /**
|
---|
| 182 | * Updates the `display_name` and labels of the project identified by the
|
---|
| 183 | * specified `name` (for example, `projects/415104041262`). Deleting all labels
|
---|
| 184 | * requires an update mask for labels field. The caller must have
|
---|
| 185 | * `resourcemanager.projects.update` permission for this project.
|
---|
| 186 | * (projects.patch)
|
---|
| 187 | *
|
---|
| 188 | * @param string $name Output only. The unique resource name of the project. It
|
---|
| 189 | * is an int64 generated number prefixed by "projects/". Example:
|
---|
| 190 | * `projects/415104041262`
|
---|
| 191 | * @param Project $postBody
|
---|
| 192 | * @param array $optParams Optional parameters.
|
---|
| 193 | *
|
---|
| 194 | * @opt_param string updateMask Optional. An update mask to selectively update
|
---|
| 195 | * fields.
|
---|
| 196 | * @return Operation
|
---|
| 197 | * @throws \Google\Service\Exception
|
---|
| 198 | */
|
---|
| 199 | public function patch($name, Project $postBody, $optParams = [])
|
---|
| 200 | {
|
---|
| 201 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
| 202 | $params = array_merge($params, $optParams);
|
---|
| 203 | return $this->call('patch', [$params], Operation::class);
|
---|
| 204 | }
|
---|
| 205 | /**
|
---|
| 206 | * Search for projects that the caller has the `resourcemanager.projects.get`
|
---|
| 207 | * permission on, and also satisfy the specified query. This method returns
|
---|
| 208 | * projects in an unspecified order. This method is eventually consistent with
|
---|
| 209 | * project mutations; this means that a newly created project may not appear in
|
---|
| 210 | * the results or recent updates to an existing project may not be reflected in
|
---|
| 211 | * the results. To retrieve the latest state of a project, use the GetProject
|
---|
| 212 | * method. (projects.search)
|
---|
| 213 | *
|
---|
| 214 | * @param array $optParams Optional parameters.
|
---|
| 215 | *
|
---|
| 216 | * @opt_param int pageSize Optional. The maximum number of projects to return in
|
---|
| 217 | * the response. The server can return fewer projects than requested. If
|
---|
| 218 | * unspecified, server picks an appropriate default.
|
---|
| 219 | * @opt_param string pageToken Optional. A pagination token returned from a
|
---|
| 220 | * previous call to ListProjects that indicates from where listing should
|
---|
| 221 | * continue.
|
---|
| 222 | * @opt_param string query Optional. A query string for searching for projects
|
---|
| 223 | * that the caller has `resourcemanager.projects.get` permission to. If multiple
|
---|
| 224 | * fields are included in the query, then it will return results that match any
|
---|
| 225 | * of the fields. Some eligible fields are: ``` | Field | Description |
|
---|
| 226 | * |-------------------------|----------------------------------------------| |
|
---|
| 227 | * displayName, name | Filters by displayName. | | parent | Project's parent
|
---|
| 228 | * (for example: folders/123, organizations). Prefer parent field over
|
---|
| 229 | * parent.type and parent.id.| | parent.type | Parent's type: `folder` or
|
---|
| 230 | * `organization`. | | parent.id | Parent's id number (for example: 123) | | id,
|
---|
| 231 | * projectId | Filters by projectId. | | state, lifecycleState | Filters by
|
---|
| 232 | * state. | | labels | Filters by label name or value. | | labels.\ (where *key*
|
---|
| 233 | * is the name of a label) | Filters by label name.| ``` Search expressions are
|
---|
| 234 | * case insensitive. Some examples queries: ``` | Query | Description |
|
---|
| 235 | * |------------------|-----------------------------------------------------| |
|
---|
| 236 | * name:how* | The project's name starts with "how". | | name:Howl | The
|
---|
| 237 | * project's name is `Howl` or `howl`. | | name:HOWL | Equivalent to above. | |
|
---|
| 238 | * NAME:howl | Equivalent to above. | | labels.color:* | The project has the
|
---|
| 239 | * label `color`. | | labels.color:red | The project's label `color` has the
|
---|
| 240 | * value `red`. | | labels.color:red labels.size:big | The project's label
|
---|
| 241 | * `color` has the value `red` or its label `size` has the value `big`. | ``` If
|
---|
| 242 | * no query is specified, the call will return projects for which the user has
|
---|
| 243 | * the `resourcemanager.projects.get` permission.
|
---|
| 244 | * @return SearchProjectsResponse
|
---|
| 245 | * @throws \Google\Service\Exception
|
---|
| 246 | */
|
---|
| 247 | public function search($optParams = [])
|
---|
| 248 | {
|
---|
| 249 | $params = [];
|
---|
| 250 | $params = array_merge($params, $optParams);
|
---|
| 251 | return $this->call('search', [$params], SearchProjectsResponse::class);
|
---|
| 252 | }
|
---|
| 253 | /**
|
---|
| 254 | * Sets the IAM access control policy for the specified project, in the format
|
---|
| 255 | * `projects/{ProjectIdOrNumber}` e.g. projects/123. CAUTION: This method will
|
---|
| 256 | * replace the existing policy, and cannot be used to append additional IAM
|
---|
| 257 | * settings. Note: Removing service accounts from policies or changing their
|
---|
| 258 | * roles can render services completely inoperable. It is important to
|
---|
| 259 | * understand how the service account is being used before removing or updating
|
---|
| 260 | * its roles. The following constraints apply when using `setIamPolicy()`: +
|
---|
| 261 | * Project does not support `allUsers` and `allAuthenticatedUsers` as `members`
|
---|
| 262 | * in a `Binding` of a `Policy`. + The owner role can be granted to a `user`,
|
---|
| 263 | * `serviceAccount`, or a group that is part of an organization. For example,
|
---|
| 264 | * group@myownpersonaldomain.com could be added as an owner to a project in the
|
---|
| 265 | * myownpersonaldomain.com organization, but not the examplepetstore.com
|
---|
| 266 | * organization. + Service accounts can be made owners of a project directly
|
---|
| 267 | * without any restrictions. However, to be added as an owner, a user must be
|
---|
| 268 | * invited using the Cloud Platform console and must accept the invitation. + A
|
---|
| 269 | * user cannot be granted the owner role using `setIamPolicy()`. The user must
|
---|
| 270 | * be granted the owner role using the Cloud Platform Console and must
|
---|
| 271 | * explicitly accept the invitation. + Invitations to grant the owner role
|
---|
| 272 | * cannot be sent using `setIamPolicy()`; they must be sent only using the Cloud
|
---|
| 273 | * Platform Console. + If the project is not part of an organization, there must
|
---|
| 274 | * be at least one owner who has accepted the Terms of Service (ToS) agreement
|
---|
| 275 | * in the policy. Calling `setIamPolicy()` to remove the last ToS-accepted owner
|
---|
| 276 | * from the policy will fail. This restriction also applies to legacy projects
|
---|
| 277 | * that no longer have owners who have accepted the ToS. Edits to IAM policies
|
---|
| 278 | * will be rejected until the lack of a ToS-accepting owner is rectified. If the
|
---|
| 279 | * project is part of an organization, you can remove all owners, potentially
|
---|
| 280 | * making the organization inaccessible. (projects.setIamPolicy)
|
---|
| 281 | *
|
---|
| 282 | * @param string $resource REQUIRED: The resource for which the policy is being
|
---|
| 283 | * specified. See [Resource
|
---|
| 284 | * names](https://cloud.google.com/apis/design/resource_names) for the
|
---|
| 285 | * appropriate value for this field.
|
---|
| 286 | * @param SetIamPolicyRequest $postBody
|
---|
| 287 | * @param array $optParams Optional parameters.
|
---|
| 288 | * @return Policy
|
---|
| 289 | * @throws \Google\Service\Exception
|
---|
| 290 | */
|
---|
| 291 | public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = [])
|
---|
| 292 | {
|
---|
| 293 | $params = ['resource' => $resource, 'postBody' => $postBody];
|
---|
| 294 | $params = array_merge($params, $optParams);
|
---|
| 295 | return $this->call('setIamPolicy', [$params], Policy::class);
|
---|
| 296 | }
|
---|
| 297 | /**
|
---|
| 298 | * Returns permissions that a caller has on the specified project, in the format
|
---|
| 299 | * `projects/{ProjectIdOrNumber}` e.g. projects/123..
|
---|
| 300 | * (projects.testIamPermissions)
|
---|
| 301 | *
|
---|
| 302 | * @param string $resource REQUIRED: The resource for which the policy detail is
|
---|
| 303 | * being requested. See [Resource
|
---|
| 304 | * names](https://cloud.google.com/apis/design/resource_names) for the
|
---|
| 305 | * appropriate value for this field.
|
---|
| 306 | * @param TestIamPermissionsRequest $postBody
|
---|
| 307 | * @param array $optParams Optional parameters.
|
---|
| 308 | * @return TestIamPermissionsResponse
|
---|
| 309 | * @throws \Google\Service\Exception
|
---|
| 310 | */
|
---|
| 311 | public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = [])
|
---|
| 312 | {
|
---|
| 313 | $params = ['resource' => $resource, 'postBody' => $postBody];
|
---|
| 314 | $params = array_merge($params, $optParams);
|
---|
| 315 | return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class);
|
---|
| 316 | }
|
---|
| 317 | /**
|
---|
| 318 | * Restores the project identified by the specified `name` (for example,
|
---|
| 319 | * `projects/415104041262`). You can only use this method for a project that has
|
---|
| 320 | * a lifecycle state of DELETE_REQUESTED. After deletion starts, the project
|
---|
| 321 | * cannot be restored. The caller must have `resourcemanager.projects.undelete`
|
---|
| 322 | * permission for this project. (projects.undelete)
|
---|
| 323 | *
|
---|
| 324 | * @param string $name Required. The name of the project (for example,
|
---|
| 325 | * `projects/415104041262`). Required.
|
---|
| 326 | * @param UndeleteProjectRequest $postBody
|
---|
| 327 | * @param array $optParams Optional parameters.
|
---|
| 328 | * @return Operation
|
---|
| 329 | * @throws \Google\Service\Exception
|
---|
| 330 | */
|
---|
| 331 | public function undelete($name, UndeleteProjectRequest $postBody, $optParams = [])
|
---|
| 332 | {
|
---|
| 333 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
| 334 | $params = array_merge($params, $optParams);
|
---|
| 335 | return $this->call('undelete', [$params], Operation::class);
|
---|
| 336 | }
|
---|
| 337 | }
|
---|
| 338 |
|
---|
| 339 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
| 340 | class_alias(Projects::class, 'Google_Service_CloudResourceManager_Resource_Projects');
|
---|