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\AsymmetricDecryptRequest;
21use Google\Service\CloudKMS\AsymmetricDecryptResponse;
22use Google\Service\CloudKMS\AsymmetricSignRequest;
23use Google\Service\CloudKMS\AsymmetricSignResponse;
24use Google\Service\CloudKMS\CryptoKeyVersion;
25use Google\Service\CloudKMS\DestroyCryptoKeyVersionRequest;
26use Google\Service\CloudKMS\ImportCryptoKeyVersionRequest;
27use Google\Service\CloudKMS\ListCryptoKeyVersionsResponse;
28use Google\Service\CloudKMS\MacSignRequest;
29use Google\Service\CloudKMS\MacSignResponse;
30use Google\Service\CloudKMS\MacVerifyRequest;
31use Google\Service\CloudKMS\MacVerifyResponse;
32use Google\Service\CloudKMS\PublicKey;
33use Google\Service\CloudKMS\RestoreCryptoKeyVersionRequest;
34
35/**
36 * The "cryptoKeyVersions" collection of methods.
37 * Typical usage is:
38 *  <code>
39 *   $cloudkmsService = new Google\Service\CloudKMS(...);
40 *   $cryptoKeyVersions = $cloudkmsService->cryptoKeyVersions;
41 *  </code>
42 */
43class ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersions extends \Google\Service\Resource
44{
45  /**
46   * Decrypts data that was encrypted with a public key retrieved from
47   * GetPublicKey corresponding to a CryptoKeyVersion with CryptoKey.purpose
48   * ASYMMETRIC_DECRYPT. (cryptoKeyVersions.asymmetricDecrypt)
49   *
50   * @param string $name Required. The resource name of the CryptoKeyVersion to
51   * use for decryption.
52   * @param AsymmetricDecryptRequest $postBody
53   * @param array $optParams Optional parameters.
54   * @return AsymmetricDecryptResponse
55   */
56  public function asymmetricDecrypt($name, AsymmetricDecryptRequest $postBody, $optParams = [])
57  {
58    $params = ['name' => $name, 'postBody' => $postBody];
59    $params = array_merge($params, $optParams);
60    return $this->call('asymmetricDecrypt', [$params], AsymmetricDecryptResponse::class);
61  }
62  /**
63   * Signs data using a CryptoKeyVersion with CryptoKey.purpose ASYMMETRIC_SIGN,
64   * producing a signature that can be verified with the public key retrieved from
65   * GetPublicKey. (cryptoKeyVersions.asymmetricSign)
66   *
67   * @param string $name Required. The resource name of the CryptoKeyVersion to
68   * use for signing.
69   * @param AsymmetricSignRequest $postBody
70   * @param array $optParams Optional parameters.
71   * @return AsymmetricSignResponse
72   */
73  public function asymmetricSign($name, AsymmetricSignRequest $postBody, $optParams = [])
74  {
75    $params = ['name' => $name, 'postBody' => $postBody];
76    $params = array_merge($params, $optParams);
77    return $this->call('asymmetricSign', [$params], AsymmetricSignResponse::class);
78  }
79  /**
80   * Create a new CryptoKeyVersion in a CryptoKey. The server will assign the next
81   * sequential id. If unset, state will be set to ENABLED.
82   * (cryptoKeyVersions.create)
83   *
84   * @param string $parent Required. The name of the CryptoKey associated with the
85   * CryptoKeyVersions.
86   * @param CryptoKeyVersion $postBody
87   * @param array $optParams Optional parameters.
88   * @return CryptoKeyVersion
89   */
90  public function create($parent, CryptoKeyVersion $postBody, $optParams = [])
91  {
92    $params = ['parent' => $parent, 'postBody' => $postBody];
93    $params = array_merge($params, $optParams);
94    return $this->call('create', [$params], CryptoKeyVersion::class);
95  }
96  /**
97   * Schedule a CryptoKeyVersion for destruction. Upon calling this method,
98   * CryptoKeyVersion.state will be set to DESTROY_SCHEDULED, and destroy_time
99   * will be set to the time destroy_scheduled_duration in the future. At that
100   * time, the state will automatically change to DESTROYED, and the key material
101   * will be irrevocably destroyed. Before the destroy_time is reached,
102   * RestoreCryptoKeyVersion may be called to reverse the process.
103   * (cryptoKeyVersions.destroy)
104   *
105   * @param string $name Required. The resource name of the CryptoKeyVersion to
106   * destroy.
107   * @param DestroyCryptoKeyVersionRequest $postBody
108   * @param array $optParams Optional parameters.
109   * @return CryptoKeyVersion
110   */
111  public function destroy($name, DestroyCryptoKeyVersionRequest $postBody, $optParams = [])
112  {
113    $params = ['name' => $name, 'postBody' => $postBody];
114    $params = array_merge($params, $optParams);
115    return $this->call('destroy', [$params], CryptoKeyVersion::class);
116  }
117  /**
118   * Returns metadata for a given CryptoKeyVersion. (cryptoKeyVersions.get)
119   *
120   * @param string $name Required. The name of the CryptoKeyVersion to get.
121   * @param array $optParams Optional parameters.
122   * @return CryptoKeyVersion
123   */
124  public function get($name, $optParams = [])
125  {
126    $params = ['name' => $name];
127    $params = array_merge($params, $optParams);
128    return $this->call('get', [$params], CryptoKeyVersion::class);
129  }
130  /**
131   * Returns the public key for the given CryptoKeyVersion. The CryptoKey.purpose
132   * must be ASYMMETRIC_SIGN or ASYMMETRIC_DECRYPT.
133   * (cryptoKeyVersions.getPublicKey)
134   *
135   * @param string $name Required. The name of the CryptoKeyVersion public key to
136   * get.
137   * @param array $optParams Optional parameters.
138   * @return PublicKey
139   */
140  public function getPublicKey($name, $optParams = [])
141  {
142    $params = ['name' => $name];
143    $params = array_merge($params, $optParams);
144    return $this->call('getPublicKey', [$params], PublicKey::class);
145  }
146  /**
147   * Import wrapped key material into a CryptoKeyVersion. All requests must
148   * specify a CryptoKey. If a CryptoKeyVersion is additionally specified in the
149   * request, key material will be reimported into that version. Otherwise, a new
150   * version will be created, and will be assigned the next sequential id within
151   * the CryptoKey. (cryptoKeyVersions.import)
152   *
153   * @param string $parent Required. The name of the CryptoKey to be imported
154   * into. The create permission is only required on this key when creating a new
155   * CryptoKeyVersion.
156   * @param ImportCryptoKeyVersionRequest $postBody
157   * @param array $optParams Optional parameters.
158   * @return CryptoKeyVersion
159   */
160  public function import($parent, ImportCryptoKeyVersionRequest $postBody, $optParams = [])
161  {
162    $params = ['parent' => $parent, 'postBody' => $postBody];
163    $params = array_merge($params, $optParams);
164    return $this->call('import', [$params], CryptoKeyVersion::class);
165  }
166  /**
167   * Lists CryptoKeyVersions.
168   * (cryptoKeyVersions.listProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersions)
169   *
170   * @param string $parent Required. The resource name of the CryptoKey to list,
171   * in the format `projects/locations/keyRings/cryptoKeys`.
172   * @param array $optParams Optional parameters.
173   *
174   * @opt_param string filter Optional. Only include resources that match the
175   * filter in the response. For more information, see [Sorting and filtering list
176   * results](https://cloud.google.com/kms/docs/sorting-and-filtering).
177   * @opt_param string orderBy Optional. Specify how the results should be sorted.
178   * If not specified, the results will be sorted in the default order. For more
179   * information, see [Sorting and filtering list
180   * results](https://cloud.google.com/kms/docs/sorting-and-filtering).
181   * @opt_param int pageSize Optional. Optional limit on the number of
182   * CryptoKeyVersions to include in the response. Further CryptoKeyVersions can
183   * subsequently be obtained by including the
184   * ListCryptoKeyVersionsResponse.next_page_token in a subsequent request. If
185   * unspecified, the server will pick an appropriate default.
186   * @opt_param string pageToken Optional. Optional pagination token, returned
187   * earlier via ListCryptoKeyVersionsResponse.next_page_token.
188   * @opt_param string view The fields to include in the response.
189   * @return ListCryptoKeyVersionsResponse
190   */
191  public function listProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersions($parent, $optParams = [])
192  {
193    $params = ['parent' => $parent];
194    $params = array_merge($params, $optParams);
195    return $this->call('list', [$params], ListCryptoKeyVersionsResponse::class);
196  }
197  /**
198   * Signs data using a CryptoKeyVersion with CryptoKey.purpose MAC, producing a
199   * tag that can be verified by another source with the same key.
200   * (cryptoKeyVersions.macSign)
201   *
202   * @param string $name Required. The resource name of the CryptoKeyVersion to
203   * use for signing.
204   * @param MacSignRequest $postBody
205   * @param array $optParams Optional parameters.
206   * @return MacSignResponse
207   */
208  public function macSign($name, MacSignRequest $postBody, $optParams = [])
209  {
210    $params = ['name' => $name, 'postBody' => $postBody];
211    $params = array_merge($params, $optParams);
212    return $this->call('macSign', [$params], MacSignResponse::class);
213  }
214  /**
215   * Verifies MAC tag using a CryptoKeyVersion with CryptoKey.purpose MAC, and
216   * returns a response that indicates whether or not the verification was
217   * successful. (cryptoKeyVersions.macVerify)
218   *
219   * @param string $name Required. The resource name of the CryptoKeyVersion to
220   * use for verification.
221   * @param MacVerifyRequest $postBody
222   * @param array $optParams Optional parameters.
223   * @return MacVerifyResponse
224   */
225  public function macVerify($name, MacVerifyRequest $postBody, $optParams = [])
226  {
227    $params = ['name' => $name, 'postBody' => $postBody];
228    $params = array_merge($params, $optParams);
229    return $this->call('macVerify', [$params], MacVerifyResponse::class);
230  }
231  /**
232   * Update a CryptoKeyVersion's metadata. state may be changed between ENABLED
233   * and DISABLED using this method. See DestroyCryptoKeyVersion and
234   * RestoreCryptoKeyVersion to move between other states.
235   * (cryptoKeyVersions.patch)
236   *
237   * @param string $name Output only. The resource name for this CryptoKeyVersion
238   * in the format `projects/locations/keyRings/cryptoKeys/cryptoKeyVersions`.
239   * @param CryptoKeyVersion $postBody
240   * @param array $optParams Optional parameters.
241   *
242   * @opt_param string updateMask Required. List of fields to be updated in this
243   * request.
244   * @return CryptoKeyVersion
245   */
246  public function patch($name, CryptoKeyVersion $postBody, $optParams = [])
247  {
248    $params = ['name' => $name, 'postBody' => $postBody];
249    $params = array_merge($params, $optParams);
250    return $this->call('patch', [$params], CryptoKeyVersion::class);
251  }
252  /**
253   * Restore a CryptoKeyVersion in the DESTROY_SCHEDULED state. Upon restoration
254   * of the CryptoKeyVersion, state will be set to DISABLED, and destroy_time will
255   * be cleared. (cryptoKeyVersions.restore)
256   *
257   * @param string $name Required. The resource name of the CryptoKeyVersion to
258   * restore.
259   * @param RestoreCryptoKeyVersionRequest $postBody
260   * @param array $optParams Optional parameters.
261   * @return CryptoKeyVersion
262   */
263  public function restore($name, RestoreCryptoKeyVersionRequest $postBody, $optParams = [])
264  {
265    $params = ['name' => $name, 'postBody' => $postBody];
266    $params = array_merge($params, $optParams);
267    return $this->call('restore', [$params], CryptoKeyVersion::class);
268  }
269}
270
271// Adding a class alias for backwards compatibility with the previous class name.
272class_alias(ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersions::class, 'Google_Service_CloudKMS_Resource_ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersions');
273