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\CryptoKey; 21use Google\Service\CloudKMS\DecryptRequest; 22use Google\Service\CloudKMS\DecryptResponse; 23use Google\Service\CloudKMS\EncryptRequest; 24use Google\Service\CloudKMS\EncryptResponse; 25use Google\Service\CloudKMS\ListCryptoKeysResponse; 26use Google\Service\CloudKMS\Policy; 27use Google\Service\CloudKMS\SetIamPolicyRequest; 28use Google\Service\CloudKMS\TestIamPermissionsRequest; 29use Google\Service\CloudKMS\TestIamPermissionsResponse; 30use Google\Service\CloudKMS\UpdateCryptoKeyPrimaryVersionRequest; 31 32/** 33 * The "cryptoKeys" collection of methods. 34 * Typical usage is: 35 * <code> 36 * $cloudkmsService = new Google\Service\CloudKMS(...); 37 * $cryptoKeys = $cloudkmsService->cryptoKeys; 38 * </code> 39 */ 40class ProjectsLocationsKeyRingsCryptoKeys extends \Google\Service\Resource 41{ 42 /** 43 * Create a new CryptoKey within a KeyRing. CryptoKey.purpose and 44 * CryptoKey.version_template.algorithm are required. (cryptoKeys.create) 45 * 46 * @param string $parent Required. The name of the KeyRing associated with the 47 * CryptoKeys. 48 * @param CryptoKey $postBody 49 * @param array $optParams Optional parameters. 50 * 51 * @opt_param string cryptoKeyId Required. It must be unique within a KeyRing 52 * and match the regular expression `[a-zA-Z0-9_-]{1,63}` 53 * @opt_param bool skipInitialVersionCreation If set to true, the request will 54 * create a CryptoKey without any CryptoKeyVersions. You must manually call 55 * CreateCryptoKeyVersion or ImportCryptoKeyVersion before you can use this 56 * CryptoKey. 57 * @return CryptoKey 58 */ 59 public function create($parent, CryptoKey $postBody, $optParams = []) 60 { 61 $params = ['parent' => $parent, 'postBody' => $postBody]; 62 $params = array_merge($params, $optParams); 63 return $this->call('create', [$params], CryptoKey::class); 64 } 65 /** 66 * Decrypts data that was protected by Encrypt. The CryptoKey.purpose must be 67 * ENCRYPT_DECRYPT. (cryptoKeys.decrypt) 68 * 69 * @param string $name Required. The resource name of the CryptoKey to use for 70 * decryption. The server will choose the appropriate version. 71 * @param DecryptRequest $postBody 72 * @param array $optParams Optional parameters. 73 * @return DecryptResponse 74 */ 75 public function decrypt($name, DecryptRequest $postBody, $optParams = []) 76 { 77 $params = ['name' => $name, 'postBody' => $postBody]; 78 $params = array_merge($params, $optParams); 79 return $this->call('decrypt', [$params], DecryptResponse::class); 80 } 81 /** 82 * Encrypts data, so that it can only be recovered by a call to Decrypt. The 83 * CryptoKey.purpose must be ENCRYPT_DECRYPT. (cryptoKeys.encrypt) 84 * 85 * @param string $name Required. The resource name of the CryptoKey or 86 * CryptoKeyVersion to use for encryption. If a CryptoKey is specified, the 87 * server will use its primary version. 88 * @param EncryptRequest $postBody 89 * @param array $optParams Optional parameters. 90 * @return EncryptResponse 91 */ 92 public function encrypt($name, EncryptRequest $postBody, $optParams = []) 93 { 94 $params = ['name' => $name, 'postBody' => $postBody]; 95 $params = array_merge($params, $optParams); 96 return $this->call('encrypt', [$params], EncryptResponse::class); 97 } 98 /** 99 * Returns metadata for a given CryptoKey, as well as its primary 100 * CryptoKeyVersion. (cryptoKeys.get) 101 * 102 * @param string $name Required. The name of the CryptoKey to get. 103 * @param array $optParams Optional parameters. 104 * @return CryptoKey 105 */ 106 public function get($name, $optParams = []) 107 { 108 $params = ['name' => $name]; 109 $params = array_merge($params, $optParams); 110 return $this->call('get', [$params], CryptoKey::class); 111 } 112 /** 113 * Gets the access control policy for a resource. Returns an empty policy if the 114 * resource exists and does not have a policy set. (cryptoKeys.getIamPolicy) 115 * 116 * @param string $resource REQUIRED: The resource for which the policy is being 117 * requested. See the operation documentation for the appropriate value for this 118 * field. 119 * @param array $optParams Optional parameters. 120 * 121 * @opt_param int options.requestedPolicyVersion Optional. The maximum policy 122 * version that will be used to format the policy. Valid values are 0, 1, and 3. 123 * Requests specifying an invalid value will be rejected. Requests for policies 124 * with any conditional role bindings must specify version 3. Policies with no 125 * conditional role bindings may specify any valid value or leave the field 126 * unset. The policy in the response might use the policy version that you 127 * specified, or it might use a lower policy version. For example, if you 128 * specify version 3, but the policy has no conditional role bindings, the 129 * response uses version 1. To learn which resources support conditions in their 130 * IAM policies, see the [IAM 131 * documentation](https://cloud.google.com/iam/help/conditions/resource- 132 * policies). 133 * @return Policy 134 */ 135 public function getIamPolicy($resource, $optParams = []) 136 { 137 $params = ['resource' => $resource]; 138 $params = array_merge($params, $optParams); 139 return $this->call('getIamPolicy', [$params], Policy::class); 140 } 141 /** 142 * Lists CryptoKeys. (cryptoKeys.listProjectsLocationsKeyRingsCryptoKeys) 143 * 144 * @param string $parent Required. The resource name of the KeyRing to list, in 145 * the format `projects/locations/keyRings`. 146 * @param array $optParams Optional parameters. 147 * 148 * @opt_param string filter Optional. Only include resources that match the 149 * filter in the response. For more information, see [Sorting and filtering list 150 * results](https://cloud.google.com/kms/docs/sorting-and-filtering). 151 * @opt_param string orderBy Optional. Specify how the results should be sorted. 152 * If not specified, the results will be sorted in the default order. For more 153 * information, see [Sorting and filtering list 154 * results](https://cloud.google.com/kms/docs/sorting-and-filtering). 155 * @opt_param int pageSize Optional. Optional limit on the number of CryptoKeys 156 * to include in the response. Further CryptoKeys can subsequently be obtained 157 * by including the ListCryptoKeysResponse.next_page_token in a subsequent 158 * request. If unspecified, the server will pick an appropriate default. 159 * @opt_param string pageToken Optional. Optional pagination token, returned 160 * earlier via ListCryptoKeysResponse.next_page_token. 161 * @opt_param string versionView The fields of the primary version to include in 162 * the response. 163 * @return ListCryptoKeysResponse 164 */ 165 public function listProjectsLocationsKeyRingsCryptoKeys($parent, $optParams = []) 166 { 167 $params = ['parent' => $parent]; 168 $params = array_merge($params, $optParams); 169 return $this->call('list', [$params], ListCryptoKeysResponse::class); 170 } 171 /** 172 * Update a CryptoKey. (cryptoKeys.patch) 173 * 174 * @param string $name Output only. The resource name for this CryptoKey in the 175 * format `projects/locations/keyRings/cryptoKeys`. 176 * @param CryptoKey $postBody 177 * @param array $optParams Optional parameters. 178 * 179 * @opt_param string updateMask Required. List of fields to be updated in this 180 * request. 181 * @return CryptoKey 182 */ 183 public function patch($name, CryptoKey $postBody, $optParams = []) 184 { 185 $params = ['name' => $name, 'postBody' => $postBody]; 186 $params = array_merge($params, $optParams); 187 return $this->call('patch', [$params], CryptoKey::class); 188 } 189 /** 190 * Sets the access control policy on the specified resource. Replaces any 191 * existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and 192 * `PERMISSION_DENIED` errors. (cryptoKeys.setIamPolicy) 193 * 194 * @param string $resource REQUIRED: The resource for which the policy is being 195 * specified. See the operation documentation for the appropriate value for this 196 * field. 197 * @param SetIamPolicyRequest $postBody 198 * @param array $optParams Optional parameters. 199 * @return Policy 200 */ 201 public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = []) 202 { 203 $params = ['resource' => $resource, 'postBody' => $postBody]; 204 $params = array_merge($params, $optParams); 205 return $this->call('setIamPolicy', [$params], Policy::class); 206 } 207 /** 208 * Returns permissions that a caller has on the specified resource. If the 209 * resource does not exist, this will return an empty set of permissions, not a 210 * `NOT_FOUND` error. Note: This operation is designed to be used for building 211 * permission-aware UIs and command-line tools, not for authorization checking. 212 * This operation may "fail open" without warning. 213 * (cryptoKeys.testIamPermissions) 214 * 215 * @param string $resource REQUIRED: The resource for which the policy detail is 216 * being requested. See the operation documentation for the appropriate value 217 * for this field. 218 * @param TestIamPermissionsRequest $postBody 219 * @param array $optParams Optional parameters. 220 * @return TestIamPermissionsResponse 221 */ 222 public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = []) 223 { 224 $params = ['resource' => $resource, 'postBody' => $postBody]; 225 $params = array_merge($params, $optParams); 226 return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class); 227 } 228 /** 229 * Update the version of a CryptoKey that will be used in Encrypt. Returns an 230 * error if called on a key whose purpose is not ENCRYPT_DECRYPT. 231 * (cryptoKeys.updatePrimaryVersion) 232 * 233 * @param string $name Required. The resource name of the CryptoKey to update. 234 * @param UpdateCryptoKeyPrimaryVersionRequest $postBody 235 * @param array $optParams Optional parameters. 236 * @return CryptoKey 237 */ 238 public function updatePrimaryVersion($name, UpdateCryptoKeyPrimaryVersionRequest $postBody, $optParams = []) 239 { 240 $params = ['name' => $name, 'postBody' => $postBody]; 241 $params = array_merge($params, $optParams); 242 return $this->call('updatePrimaryVersion', [$params], CryptoKey::class); 243 } 244} 245 246// Adding a class alias for backwards compatibility with the previous class name. 247class_alias(ProjectsLocationsKeyRingsCryptoKeys::class, 'Google_Service_CloudKMS_Resource_ProjectsLocationsKeyRingsCryptoKeys'); 248