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\CloudKMS\Resource;
19
20use Google\Service\CloudKMS\KeyRing;
21use Google\Service\CloudKMS\ListKeyRingsResponse;
22use Google\Service\CloudKMS\Policy;
23use Google\Service\CloudKMS\SetIamPolicyRequest;
24use Google\Service\CloudKMS\TestIamPermissionsRequest;
25use Google\Service\CloudKMS\TestIamPermissionsResponse;
26
27/**
28 * The "keyRings" collection of methods.
29 * Typical usage is:
30 *  <code>
31 *   $cloudkmsService = new Google\Service\CloudKMS(...);
32 *   $keyRings = $cloudkmsService->keyRings;
33 *  </code>
34 */
35class ProjectsLocationsKeyRings extends \Google\Service\Resource
36{
37  /**
38   * Create a new KeyRing in a given Project and Location. (keyRings.create)
39   *
40   * @param string $parent Required. The resource name of the location associated
41   * with the KeyRings, in the format `projects/locations`.
42   * @param KeyRing $postBody
43   * @param array $optParams Optional parameters.
44   *
45   * @opt_param string keyRingId Required. It must be unique within a location and
46   * match the regular expression `[a-zA-Z0-9_-]{1,63}`
47   * @return KeyRing
48   */
49  public function create($parent, KeyRing $postBody, $optParams = [])
50  {
51    $params = ['parent' => $parent, 'postBody' => $postBody];
52    $params = array_merge($params, $optParams);
53    return $this->call('create', [$params], KeyRing::class);
54  }
55  /**
56   * Returns metadata for a given KeyRing. (keyRings.get)
57   *
58   * @param string $name Required. The name of the KeyRing to get.
59   * @param array $optParams Optional parameters.
60   * @return KeyRing
61   */
62  public function get($name, $optParams = [])
63  {
64    $params = ['name' => $name];
65    $params = array_merge($params, $optParams);
66    return $this->call('get', [$params], KeyRing::class);
67  }
68  /**
69   * Gets the access control policy for a resource. Returns an empty policy if the
70   * resource exists and does not have a policy set. (keyRings.getIamPolicy)
71   *
72   * @param string $resource REQUIRED: The resource for which the policy is being
73   * requested. See the operation documentation for the appropriate value for this
74   * field.
75   * @param array $optParams Optional parameters.
76   *
77   * @opt_param int options.requestedPolicyVersion Optional. The maximum policy
78   * version that will be used to format the policy. Valid values are 0, 1, and 3.
79   * Requests specifying an invalid value will be rejected. Requests for policies
80   * with any conditional role bindings must specify version 3. Policies with no
81   * conditional role bindings may specify any valid value or leave the field
82   * unset. The policy in the response might use the policy version that you
83   * specified, or it might use a lower policy version. For example, if you
84   * specify version 3, but the policy has no conditional role bindings, the
85   * response uses version 1. To learn which resources support conditions in their
86   * IAM policies, see the [IAM
87   * documentation](https://cloud.google.com/iam/help/conditions/resource-
88   * policies).
89   * @return Policy
90   */
91  public function getIamPolicy($resource, $optParams = [])
92  {
93    $params = ['resource' => $resource];
94    $params = array_merge($params, $optParams);
95    return $this->call('getIamPolicy', [$params], Policy::class);
96  }
97  /**
98   * Lists KeyRings. (keyRings.listProjectsLocationsKeyRings)
99   *
100   * @param string $parent Required. The resource name of the location associated
101   * with the KeyRings, in the format `projects/locations`.
102   * @param array $optParams Optional parameters.
103   *
104   * @opt_param string filter Optional. Only include resources that match the
105   * filter in the response. For more information, see [Sorting and filtering list
106   * results](https://cloud.google.com/kms/docs/sorting-and-filtering).
107   * @opt_param string orderBy Optional. Specify how the results should be sorted.
108   * If not specified, the results will be sorted in the default order. For more
109   * information, see [Sorting and filtering list
110   * results](https://cloud.google.com/kms/docs/sorting-and-filtering).
111   * @opt_param int pageSize Optional. Optional limit on the number of KeyRings to
112   * include in the response. Further KeyRings can subsequently be obtained by
113   * including the ListKeyRingsResponse.next_page_token in a subsequent request.
114   * If unspecified, the server will pick an appropriate default.
115   * @opt_param string pageToken Optional. Optional pagination token, returned
116   * earlier via ListKeyRingsResponse.next_page_token.
117   * @return ListKeyRingsResponse
118   */
119  public function listProjectsLocationsKeyRings($parent, $optParams = [])
120  {
121    $params = ['parent' => $parent];
122    $params = array_merge($params, $optParams);
123    return $this->call('list', [$params], ListKeyRingsResponse::class);
124  }
125  /**
126   * Sets the access control policy on the specified resource. Replaces any
127   * existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and
128   * `PERMISSION_DENIED` errors. (keyRings.setIamPolicy)
129   *
130   * @param string $resource REQUIRED: The resource for which the policy is being
131   * specified. See the operation documentation for the appropriate value for this
132   * field.
133   * @param SetIamPolicyRequest $postBody
134   * @param array $optParams Optional parameters.
135   * @return Policy
136   */
137  public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = [])
138  {
139    $params = ['resource' => $resource, 'postBody' => $postBody];
140    $params = array_merge($params, $optParams);
141    return $this->call('setIamPolicy', [$params], Policy::class);
142  }
143  /**
144   * Returns permissions that a caller has on the specified resource. If the
145   * resource does not exist, this will return an empty set of permissions, not a
146   * `NOT_FOUND` error. Note: This operation is designed to be used for building
147   * permission-aware UIs and command-line tools, not for authorization checking.
148   * This operation may "fail open" without warning. (keyRings.testIamPermissions)
149   *
150   * @param string $resource REQUIRED: The resource for which the policy detail is
151   * being requested. See the operation documentation for the appropriate value
152   * for this field.
153   * @param TestIamPermissionsRequest $postBody
154   * @param array $optParams Optional parameters.
155   * @return TestIamPermissionsResponse
156   */
157  public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = [])
158  {
159    $params = ['resource' => $resource, 'postBody' => $postBody];
160    $params = array_merge($params, $optParams);
161    return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class);
162  }
163}
164
165// Adding a class alias for backwards compatibility with the previous class name.
166class_alias(ProjectsLocationsKeyRings::class, 'Google_Service_CloudKMS_Resource_ProjectsLocationsKeyRings');
167