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\Iam\Resource;
|
---|
19 |
|
---|
20 | use Google\Service\Iam\GoogleIamV2ListPoliciesResponse;
|
---|
21 | use Google\Service\Iam\GoogleIamV2Policy;
|
---|
22 | use Google\Service\Iam\GoogleLongrunningOperation;
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * The "policies" collection of methods.
|
---|
26 | * Typical usage is:
|
---|
27 | * <code>
|
---|
28 | * $iamService = new Google\Service\Iam(...);
|
---|
29 | * $policies = $iamService->policies;
|
---|
30 | * </code>
|
---|
31 | */
|
---|
32 | class Policies extends \Google\Service\Resource
|
---|
33 | {
|
---|
34 | /**
|
---|
35 | * Creates a policy. (policies.createPolicy)
|
---|
36 | *
|
---|
37 | * @param string $parent Required. The resource that the policy is attached to,
|
---|
38 | * along with the kind of policy to create. Format:
|
---|
39 | * `policies/{attachment_point}/denypolicies` The attachment point is identified
|
---|
40 | * by its URL-encoded full resource name, which means that the forward-slash
|
---|
41 | * character, `/`, must be written as `%2F`. For example,
|
---|
42 | * `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-
|
---|
43 | * project/denypolicies`. For organizations and folders, use the numeric ID in
|
---|
44 | * the full resource name. For projects, you can use the alphanumeric or the
|
---|
45 | * numeric ID.
|
---|
46 | * @param GoogleIamV2Policy $postBody
|
---|
47 | * @param array $optParams Optional parameters.
|
---|
48 | *
|
---|
49 | * @opt_param string policyId The ID to use for this policy, which will become
|
---|
50 | * the final component of the policy's resource name. The ID must contain 3 to
|
---|
51 | * 63 characters. It can contain lowercase letters and numbers, as well as
|
---|
52 | * dashes (`-`) and periods (`.`). The first character must be a lowercase
|
---|
53 | * letter.
|
---|
54 | * @return GoogleLongrunningOperation
|
---|
55 | * @throws \Google\Service\Exception
|
---|
56 | */
|
---|
57 | public function createPolicy($parent, GoogleIamV2Policy $postBody, $optParams = [])
|
---|
58 | {
|
---|
59 | $params = ['parent' => $parent, 'postBody' => $postBody];
|
---|
60 | $params = array_merge($params, $optParams);
|
---|
61 | return $this->call('createPolicy', [$params], GoogleLongrunningOperation::class);
|
---|
62 | }
|
---|
63 | /**
|
---|
64 | * Deletes a policy. This action is permanent. (policies.delete)
|
---|
65 | *
|
---|
66 | * @param string $name Required. The resource name of the policy to delete.
|
---|
67 | * Format: `policies/{attachment_point}/denypolicies/{policy_id}` Use the URL-
|
---|
68 | * encoded full resource name, which means that the forward-slash character,
|
---|
69 | * `/`, must be written as `%2F`. For example,
|
---|
70 | * `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-
|
---|
71 | * project/denypolicies/my-policy`. For organizations and folders, use the
|
---|
72 | * numeric ID in the full resource name. For projects, you can use the
|
---|
73 | * alphanumeric or the numeric ID.
|
---|
74 | * @param array $optParams Optional parameters.
|
---|
75 | *
|
---|
76 | * @opt_param string etag Optional. The expected `etag` of the policy to delete.
|
---|
77 | * If the value does not match the value that is stored in IAM, the request
|
---|
78 | * fails with a `409` error code and `ABORTED` status. If you omit this field,
|
---|
79 | * the policy is deleted regardless of its current `etag`.
|
---|
80 | * @return GoogleLongrunningOperation
|
---|
81 | * @throws \Google\Service\Exception
|
---|
82 | */
|
---|
83 | public function delete($name, $optParams = [])
|
---|
84 | {
|
---|
85 | $params = ['name' => $name];
|
---|
86 | $params = array_merge($params, $optParams);
|
---|
87 | return $this->call('delete', [$params], GoogleLongrunningOperation::class);
|
---|
88 | }
|
---|
89 | /**
|
---|
90 | * Gets a policy. (policies.get)
|
---|
91 | *
|
---|
92 | * @param string $name Required. The resource name of the policy to retrieve.
|
---|
93 | * Format: `policies/{attachment_point}/denypolicies/{policy_id}` Use the URL-
|
---|
94 | * encoded full resource name, which means that the forward-slash character,
|
---|
95 | * `/`, must be written as `%2F`. For example,
|
---|
96 | * `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-
|
---|
97 | * project/denypolicies/my-policy`. For organizations and folders, use the
|
---|
98 | * numeric ID in the full resource name. For projects, you can use the
|
---|
99 | * alphanumeric or the numeric ID.
|
---|
100 | * @param array $optParams Optional parameters.
|
---|
101 | * @return GoogleIamV2Policy
|
---|
102 | * @throws \Google\Service\Exception
|
---|
103 | */
|
---|
104 | public function get($name, $optParams = [])
|
---|
105 | {
|
---|
106 | $params = ['name' => $name];
|
---|
107 | $params = array_merge($params, $optParams);
|
---|
108 | return $this->call('get', [$params], GoogleIamV2Policy::class);
|
---|
109 | }
|
---|
110 | /**
|
---|
111 | * Retrieves the policies of the specified kind that are attached to a resource.
|
---|
112 | * The response lists only policy metadata. In particular, policy rules are
|
---|
113 | * omitted. (policies.listPolicies)
|
---|
114 | *
|
---|
115 | * @param string $parent Required. The resource that the policy is attached to,
|
---|
116 | * along with the kind of policy to list. Format:
|
---|
117 | * `policies/{attachment_point}/denypolicies` The attachment point is identified
|
---|
118 | * by its URL-encoded full resource name, which means that the forward-slash
|
---|
119 | * character, `/`, must be written as `%2F`. For example,
|
---|
120 | * `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-
|
---|
121 | * project/denypolicies`. For organizations and folders, use the numeric ID in
|
---|
122 | * the full resource name. For projects, you can use the alphanumeric or the
|
---|
123 | * numeric ID.
|
---|
124 | * @param array $optParams Optional parameters.
|
---|
125 | *
|
---|
126 | * @opt_param int pageSize The maximum number of policies to return. IAM ignores
|
---|
127 | * this value and uses the value 1000.
|
---|
128 | * @opt_param string pageToken A page token received in a ListPoliciesResponse.
|
---|
129 | * Provide this token to retrieve the next page.
|
---|
130 | * @return GoogleIamV2ListPoliciesResponse
|
---|
131 | * @throws \Google\Service\Exception
|
---|
132 | */
|
---|
133 | public function listPolicies($parent, $optParams = [])
|
---|
134 | {
|
---|
135 | $params = ['parent' => $parent];
|
---|
136 | $params = array_merge($params, $optParams);
|
---|
137 | return $this->call('listPolicies', [$params], GoogleIamV2ListPoliciesResponse::class);
|
---|
138 | }
|
---|
139 | /**
|
---|
140 | * Updates the specified policy. You can update only the rules and the display
|
---|
141 | * name for the policy. To update a policy, you should use a read-modify-write
|
---|
142 | * loop: 1. Use GetPolicy to read the current version of the policy. 2. Modify
|
---|
143 | * the policy as needed. 3. Use `UpdatePolicy` to write the updated policy. This
|
---|
144 | * pattern helps prevent conflicts between concurrent updates. (policies.update)
|
---|
145 | *
|
---|
146 | * @param string $name Immutable. The resource name of the `Policy`, which must
|
---|
147 | * be unique. Format: `policies/{attachment_point}/denypolicies/{policy_id}` The
|
---|
148 | * attachment point is identified by its URL-encoded full resource name, which
|
---|
149 | * means that the forward-slash character, `/`, must be written as `%2F`. For
|
---|
150 | * example, `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-
|
---|
151 | * project/denypolicies/my-deny-policy`. For organizations and folders, use the
|
---|
152 | * numeric ID in the full resource name. For projects, requests can use the
|
---|
153 | * alphanumeric or the numeric ID. Responses always contain the numeric ID.
|
---|
154 | * @param GoogleIamV2Policy $postBody
|
---|
155 | * @param array $optParams Optional parameters.
|
---|
156 | * @return GoogleLongrunningOperation
|
---|
157 | * @throws \Google\Service\Exception
|
---|
158 | */
|
---|
159 | public function update($name, GoogleIamV2Policy $postBody, $optParams = [])
|
---|
160 | {
|
---|
161 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
162 | $params = array_merge($params, $optParams);
|
---|
163 | return $this->call('update', [$params], GoogleLongrunningOperation::class);
|
---|
164 | }
|
---|
165 | }
|
---|
166 |
|
---|
167 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
168 | class_alias(Policies::class, 'Google_Service_Iam_Resource_Policies');
|
---|