• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 Google LLC
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      https://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.cloud.kms.v1;
18 
19 import com.google.api.core.ApiFuture;
20 import com.google.api.core.ApiFutures;
21 import com.google.api.gax.core.BackgroundResource;
22 import com.google.api.gax.paging.AbstractFixedSizeCollection;
23 import com.google.api.gax.paging.AbstractPage;
24 import com.google.api.gax.paging.AbstractPagedListResponse;
25 import com.google.api.gax.rpc.PageContext;
26 import com.google.api.gax.rpc.UnaryCallable;
27 import com.google.api.resourcenames.ResourceName;
28 import com.google.cloud.kms.v1.stub.KeyManagementServiceStub;
29 import com.google.cloud.kms.v1.stub.KeyManagementServiceStubSettings;
30 import com.google.cloud.location.GetLocationRequest;
31 import com.google.cloud.location.ListLocationsRequest;
32 import com.google.cloud.location.ListLocationsResponse;
33 import com.google.cloud.location.Location;
34 import com.google.common.util.concurrent.MoreExecutors;
35 import com.google.iam.v1.GetIamPolicyRequest;
36 import com.google.iam.v1.Policy;
37 import com.google.iam.v1.SetIamPolicyRequest;
38 import com.google.iam.v1.TestIamPermissionsRequest;
39 import com.google.iam.v1.TestIamPermissionsResponse;
40 import com.google.protobuf.ByteString;
41 import com.google.protobuf.FieldMask;
42 import java.io.IOException;
43 import java.util.List;
44 import java.util.concurrent.TimeUnit;
45 import javax.annotation.Generated;
46 
47 // AUTO-GENERATED DOCUMENTATION AND CLASS.
48 /**
49  * Service Description: Google Cloud Key Management Service
50  *
51  * <p>Manages cryptographic keys and operations using those keys. Implements a REST model with the
52  * following objects:
53  *
54  * <ul>
55  *   <li>[KeyRing][google.cloud.kms.v1.KeyRing]
56  *   <li>[CryptoKey][google.cloud.kms.v1.CryptoKey]
57  *   <li>[CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]
58  *   <li>[ImportJob][google.cloud.kms.v1.ImportJob]
59  * </ul>
60  *
61  * <p>If you are using manual gRPC libraries, see [Using gRPC with Cloud
62  * KMS](https://cloud.google.com/kms/docs/grpc).
63  *
64  * <p>This class provides the ability to make remote calls to the backing service through method
65  * calls that map to API methods. Sample code to get started:
66  *
67  * <pre>{@code
68  * // This snippet has been automatically generated and should be regarded as a code template only.
69  * // It will require modifications to work:
70  * // - It may require correct/in-range values for request initialization.
71  * // - It may require specifying regional endpoints when creating the service client as shown in
72  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
73  * try (KeyManagementServiceClient keyManagementServiceClient =
74  *     KeyManagementServiceClient.create()) {
75  *   KeyRingName name = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
76  *   KeyRing response = keyManagementServiceClient.getKeyRing(name);
77  * }
78  * }</pre>
79  *
80  * <p>Note: close() needs to be called on the KeyManagementServiceClient object to clean up
81  * resources such as threads. In the example above, try-with-resources is used, which automatically
82  * calls close().
83  *
84  * <p>The surface of this class includes several types of Java methods for each of the API's
85  * methods:
86  *
87  * <ol>
88  *   <li>A "flattened" method. With this type of method, the fields of the request type have been
89  *       converted into function parameters. It may be the case that not all fields are available as
90  *       parameters, and not every API method will have a flattened method entry point.
91  *   <li>A "request object" method. This type of method only takes one parameter, a request object,
92  *       which must be constructed before the call. Not every API method will have a request object
93  *       method.
94  *   <li>A "callable" method. This type of method takes no parameters and returns an immutable API
95  *       callable object, which can be used to initiate calls to the service.
96  * </ol>
97  *
98  * <p>See the individual methods for example code.
99  *
100  * <p>Many parameters require resource names to be formatted in a particular way. To assist with
101  * these names, this class includes a format method for each type of name, and additionally a parse
102  * method to extract the individual identifiers contained within names that are returned.
103  *
104  * <p>This class can be customized by passing in a custom instance of KeyManagementServiceSettings
105  * to create(). For example:
106  *
107  * <p>To customize credentials:
108  *
109  * <pre>{@code
110  * // This snippet has been automatically generated and should be regarded as a code template only.
111  * // It will require modifications to work:
112  * // - It may require correct/in-range values for request initialization.
113  * // - It may require specifying regional endpoints when creating the service client as shown in
114  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
115  * KeyManagementServiceSettings keyManagementServiceSettings =
116  *     KeyManagementServiceSettings.newBuilder()
117  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
118  *         .build();
119  * KeyManagementServiceClient keyManagementServiceClient =
120  *     KeyManagementServiceClient.create(keyManagementServiceSettings);
121  * }</pre>
122  *
123  * <p>To customize the endpoint:
124  *
125  * <pre>{@code
126  * // This snippet has been automatically generated and should be regarded as a code template only.
127  * // It will require modifications to work:
128  * // - It may require correct/in-range values for request initialization.
129  * // - It may require specifying regional endpoints when creating the service client as shown in
130  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
131  * KeyManagementServiceSettings keyManagementServiceSettings =
132  *     KeyManagementServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
133  * KeyManagementServiceClient keyManagementServiceClient =
134  *     KeyManagementServiceClient.create(keyManagementServiceSettings);
135  * }</pre>
136  *
137  * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
138  * the wire:
139  *
140  * <pre>{@code
141  * // This snippet has been automatically generated and should be regarded as a code template only.
142  * // It will require modifications to work:
143  * // - It may require correct/in-range values for request initialization.
144  * // - It may require specifying regional endpoints when creating the service client as shown in
145  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
146  * KeyManagementServiceSettings keyManagementServiceSettings =
147  *     KeyManagementServiceSettings.newHttpJsonBuilder().build();
148  * KeyManagementServiceClient keyManagementServiceClient =
149  *     KeyManagementServiceClient.create(keyManagementServiceSettings);
150  * }</pre>
151  *
152  * <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
153  */
154 @Generated("by gapic-generator-java")
155 public class KeyManagementServiceClient implements BackgroundResource {
156   private final KeyManagementServiceSettings settings;
157   private final KeyManagementServiceStub stub;
158 
159   /** Constructs an instance of KeyManagementServiceClient with default settings. */
create()160   public static final KeyManagementServiceClient create() throws IOException {
161     return create(KeyManagementServiceSettings.newBuilder().build());
162   }
163 
164   /**
165    * Constructs an instance of KeyManagementServiceClient, using the given settings. The channels
166    * are created based on the settings passed in, or defaults for any settings that are not set.
167    */
create(KeyManagementServiceSettings settings)168   public static final KeyManagementServiceClient create(KeyManagementServiceSettings settings)
169       throws IOException {
170     return new KeyManagementServiceClient(settings);
171   }
172 
173   /**
174    * Constructs an instance of KeyManagementServiceClient, using the given stub for making calls.
175    * This is for advanced usage - prefer using create(KeyManagementServiceSettings).
176    */
create(KeyManagementServiceStub stub)177   public static final KeyManagementServiceClient create(KeyManagementServiceStub stub) {
178     return new KeyManagementServiceClient(stub);
179   }
180 
181   /**
182    * Constructs an instance of KeyManagementServiceClient, using the given settings. This is
183    * protected so that it is easy to make a subclass, but otherwise, the static factory methods
184    * should be preferred.
185    */
KeyManagementServiceClient(KeyManagementServiceSettings settings)186   protected KeyManagementServiceClient(KeyManagementServiceSettings settings) throws IOException {
187     this.settings = settings;
188     this.stub = ((KeyManagementServiceStubSettings) settings.getStubSettings()).createStub();
189   }
190 
KeyManagementServiceClient(KeyManagementServiceStub stub)191   protected KeyManagementServiceClient(KeyManagementServiceStub stub) {
192     this.settings = null;
193     this.stub = stub;
194   }
195 
getSettings()196   public final KeyManagementServiceSettings getSettings() {
197     return settings;
198   }
199 
getStub()200   public KeyManagementServiceStub getStub() {
201     return stub;
202   }
203 
204   // AUTO-GENERATED DOCUMENTATION AND METHOD.
205   /**
206    * Lists [KeyRings][google.cloud.kms.v1.KeyRing].
207    *
208    * <p>Sample code:
209    *
210    * <pre>{@code
211    * // This snippet has been automatically generated and should be regarded as a code template only.
212    * // It will require modifications to work:
213    * // - It may require correct/in-range values for request initialization.
214    * // - It may require specifying regional endpoints when creating the service client as shown in
215    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
216    * try (KeyManagementServiceClient keyManagementServiceClient =
217    *     KeyManagementServiceClient.create()) {
218    *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
219    *   for (KeyRing element : keyManagementServiceClient.listKeyRings(parent).iterateAll()) {
220    *     // doThingsWith(element);
221    *   }
222    * }
223    * }</pre>
224    *
225    * @param parent Required. The resource name of the location associated with the
226    *     [KeyRings][google.cloud.kms.v1.KeyRing], in the format `projects/&#42;/locations/&#42;`.
227    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
228    */
listKeyRings(LocationName parent)229   public final ListKeyRingsPagedResponse listKeyRings(LocationName parent) {
230     ListKeyRingsRequest request =
231         ListKeyRingsRequest.newBuilder()
232             .setParent(parent == null ? null : parent.toString())
233             .build();
234     return listKeyRings(request);
235   }
236 
237   // AUTO-GENERATED DOCUMENTATION AND METHOD.
238   /**
239    * Lists [KeyRings][google.cloud.kms.v1.KeyRing].
240    *
241    * <p>Sample code:
242    *
243    * <pre>{@code
244    * // This snippet has been automatically generated and should be regarded as a code template only.
245    * // It will require modifications to work:
246    * // - It may require correct/in-range values for request initialization.
247    * // - It may require specifying regional endpoints when creating the service client as shown in
248    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
249    * try (KeyManagementServiceClient keyManagementServiceClient =
250    *     KeyManagementServiceClient.create()) {
251    *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
252    *   for (KeyRing element : keyManagementServiceClient.listKeyRings(parent).iterateAll()) {
253    *     // doThingsWith(element);
254    *   }
255    * }
256    * }</pre>
257    *
258    * @param parent Required. The resource name of the location associated with the
259    *     [KeyRings][google.cloud.kms.v1.KeyRing], in the format `projects/&#42;/locations/&#42;`.
260    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
261    */
listKeyRings(String parent)262   public final ListKeyRingsPagedResponse listKeyRings(String parent) {
263     ListKeyRingsRequest request = ListKeyRingsRequest.newBuilder().setParent(parent).build();
264     return listKeyRings(request);
265   }
266 
267   // AUTO-GENERATED DOCUMENTATION AND METHOD.
268   /**
269    * Lists [KeyRings][google.cloud.kms.v1.KeyRing].
270    *
271    * <p>Sample code:
272    *
273    * <pre>{@code
274    * // This snippet has been automatically generated and should be regarded as a code template only.
275    * // It will require modifications to work:
276    * // - It may require correct/in-range values for request initialization.
277    * // - It may require specifying regional endpoints when creating the service client as shown in
278    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
279    * try (KeyManagementServiceClient keyManagementServiceClient =
280    *     KeyManagementServiceClient.create()) {
281    *   ListKeyRingsRequest request =
282    *       ListKeyRingsRequest.newBuilder()
283    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
284    *           .setPageSize(883849137)
285    *           .setPageToken("pageToken873572522")
286    *           .setFilter("filter-1274492040")
287    *           .setOrderBy("orderBy-1207110587")
288    *           .build();
289    *   for (KeyRing element : keyManagementServiceClient.listKeyRings(request).iterateAll()) {
290    *     // doThingsWith(element);
291    *   }
292    * }
293    * }</pre>
294    *
295    * @param request The request object containing all of the parameters for the API call.
296    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
297    */
listKeyRings(ListKeyRingsRequest request)298   public final ListKeyRingsPagedResponse listKeyRings(ListKeyRingsRequest request) {
299     return listKeyRingsPagedCallable().call(request);
300   }
301 
302   // AUTO-GENERATED DOCUMENTATION AND METHOD.
303   /**
304    * Lists [KeyRings][google.cloud.kms.v1.KeyRing].
305    *
306    * <p>Sample code:
307    *
308    * <pre>{@code
309    * // This snippet has been automatically generated and should be regarded as a code template only.
310    * // It will require modifications to work:
311    * // - It may require correct/in-range values for request initialization.
312    * // - It may require specifying regional endpoints when creating the service client as shown in
313    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
314    * try (KeyManagementServiceClient keyManagementServiceClient =
315    *     KeyManagementServiceClient.create()) {
316    *   ListKeyRingsRequest request =
317    *       ListKeyRingsRequest.newBuilder()
318    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
319    *           .setPageSize(883849137)
320    *           .setPageToken("pageToken873572522")
321    *           .setFilter("filter-1274492040")
322    *           .setOrderBy("orderBy-1207110587")
323    *           .build();
324    *   ApiFuture<KeyRing> future =
325    *       keyManagementServiceClient.listKeyRingsPagedCallable().futureCall(request);
326    *   // Do something.
327    *   for (KeyRing element : future.get().iterateAll()) {
328    *     // doThingsWith(element);
329    *   }
330    * }
331    * }</pre>
332    */
333   public final UnaryCallable<ListKeyRingsRequest, ListKeyRingsPagedResponse>
listKeyRingsPagedCallable()334       listKeyRingsPagedCallable() {
335     return stub.listKeyRingsPagedCallable();
336   }
337 
338   // AUTO-GENERATED DOCUMENTATION AND METHOD.
339   /**
340    * Lists [KeyRings][google.cloud.kms.v1.KeyRing].
341    *
342    * <p>Sample code:
343    *
344    * <pre>{@code
345    * // This snippet has been automatically generated and should be regarded as a code template only.
346    * // It will require modifications to work:
347    * // - It may require correct/in-range values for request initialization.
348    * // - It may require specifying regional endpoints when creating the service client as shown in
349    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
350    * try (KeyManagementServiceClient keyManagementServiceClient =
351    *     KeyManagementServiceClient.create()) {
352    *   ListKeyRingsRequest request =
353    *       ListKeyRingsRequest.newBuilder()
354    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
355    *           .setPageSize(883849137)
356    *           .setPageToken("pageToken873572522")
357    *           .setFilter("filter-1274492040")
358    *           .setOrderBy("orderBy-1207110587")
359    *           .build();
360    *   while (true) {
361    *     ListKeyRingsResponse response =
362    *         keyManagementServiceClient.listKeyRingsCallable().call(request);
363    *     for (KeyRing element : response.getKeyRingsList()) {
364    *       // doThingsWith(element);
365    *     }
366    *     String nextPageToken = response.getNextPageToken();
367    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
368    *       request = request.toBuilder().setPageToken(nextPageToken).build();
369    *     } else {
370    *       break;
371    *     }
372    *   }
373    * }
374    * }</pre>
375    */
listKeyRingsCallable()376   public final UnaryCallable<ListKeyRingsRequest, ListKeyRingsResponse> listKeyRingsCallable() {
377     return stub.listKeyRingsCallable();
378   }
379 
380   // AUTO-GENERATED DOCUMENTATION AND METHOD.
381   /**
382    * Lists [CryptoKeys][google.cloud.kms.v1.CryptoKey].
383    *
384    * <p>Sample code:
385    *
386    * <pre>{@code
387    * // This snippet has been automatically generated and should be regarded as a code template only.
388    * // It will require modifications to work:
389    * // - It may require correct/in-range values for request initialization.
390    * // - It may require specifying regional endpoints when creating the service client as shown in
391    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
392    * try (KeyManagementServiceClient keyManagementServiceClient =
393    *     KeyManagementServiceClient.create()) {
394    *   KeyRingName parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
395    *   for (CryptoKey element : keyManagementServiceClient.listCryptoKeys(parent).iterateAll()) {
396    *     // doThingsWith(element);
397    *   }
398    * }
399    * }</pre>
400    *
401    * @param parent Required. The resource name of the [KeyRing][google.cloud.kms.v1.KeyRing] to
402    *     list, in the format `projects/&#42;/locations/&#42;/keyRings/&#42;`.
403    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
404    */
listCryptoKeys(KeyRingName parent)405   public final ListCryptoKeysPagedResponse listCryptoKeys(KeyRingName parent) {
406     ListCryptoKeysRequest request =
407         ListCryptoKeysRequest.newBuilder()
408             .setParent(parent == null ? null : parent.toString())
409             .build();
410     return listCryptoKeys(request);
411   }
412 
413   // AUTO-GENERATED DOCUMENTATION AND METHOD.
414   /**
415    * Lists [CryptoKeys][google.cloud.kms.v1.CryptoKey].
416    *
417    * <p>Sample code:
418    *
419    * <pre>{@code
420    * // This snippet has been automatically generated and should be regarded as a code template only.
421    * // It will require modifications to work:
422    * // - It may require correct/in-range values for request initialization.
423    * // - It may require specifying regional endpoints when creating the service client as shown in
424    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
425    * try (KeyManagementServiceClient keyManagementServiceClient =
426    *     KeyManagementServiceClient.create()) {
427    *   String parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString();
428    *   for (CryptoKey element : keyManagementServiceClient.listCryptoKeys(parent).iterateAll()) {
429    *     // doThingsWith(element);
430    *   }
431    * }
432    * }</pre>
433    *
434    * @param parent Required. The resource name of the [KeyRing][google.cloud.kms.v1.KeyRing] to
435    *     list, in the format `projects/&#42;/locations/&#42;/keyRings/&#42;`.
436    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
437    */
listCryptoKeys(String parent)438   public final ListCryptoKeysPagedResponse listCryptoKeys(String parent) {
439     ListCryptoKeysRequest request = ListCryptoKeysRequest.newBuilder().setParent(parent).build();
440     return listCryptoKeys(request);
441   }
442 
443   // AUTO-GENERATED DOCUMENTATION AND METHOD.
444   /**
445    * Lists [CryptoKeys][google.cloud.kms.v1.CryptoKey].
446    *
447    * <p>Sample code:
448    *
449    * <pre>{@code
450    * // This snippet has been automatically generated and should be regarded as a code template only.
451    * // It will require modifications to work:
452    * // - It may require correct/in-range values for request initialization.
453    * // - It may require specifying regional endpoints when creating the service client as shown in
454    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
455    * try (KeyManagementServiceClient keyManagementServiceClient =
456    *     KeyManagementServiceClient.create()) {
457    *   ListCryptoKeysRequest request =
458    *       ListCryptoKeysRequest.newBuilder()
459    *           .setParent(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString())
460    *           .setPageSize(883849137)
461    *           .setPageToken("pageToken873572522")
462    *           .setFilter("filter-1274492040")
463    *           .setOrderBy("orderBy-1207110587")
464    *           .build();
465    *   for (CryptoKey element : keyManagementServiceClient.listCryptoKeys(request).iterateAll()) {
466    *     // doThingsWith(element);
467    *   }
468    * }
469    * }</pre>
470    *
471    * @param request The request object containing all of the parameters for the API call.
472    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
473    */
listCryptoKeys(ListCryptoKeysRequest request)474   public final ListCryptoKeysPagedResponse listCryptoKeys(ListCryptoKeysRequest request) {
475     return listCryptoKeysPagedCallable().call(request);
476   }
477 
478   // AUTO-GENERATED DOCUMENTATION AND METHOD.
479   /**
480    * Lists [CryptoKeys][google.cloud.kms.v1.CryptoKey].
481    *
482    * <p>Sample code:
483    *
484    * <pre>{@code
485    * // This snippet has been automatically generated and should be regarded as a code template only.
486    * // It will require modifications to work:
487    * // - It may require correct/in-range values for request initialization.
488    * // - It may require specifying regional endpoints when creating the service client as shown in
489    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
490    * try (KeyManagementServiceClient keyManagementServiceClient =
491    *     KeyManagementServiceClient.create()) {
492    *   ListCryptoKeysRequest request =
493    *       ListCryptoKeysRequest.newBuilder()
494    *           .setParent(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString())
495    *           .setPageSize(883849137)
496    *           .setPageToken("pageToken873572522")
497    *           .setFilter("filter-1274492040")
498    *           .setOrderBy("orderBy-1207110587")
499    *           .build();
500    *   ApiFuture<CryptoKey> future =
501    *       keyManagementServiceClient.listCryptoKeysPagedCallable().futureCall(request);
502    *   // Do something.
503    *   for (CryptoKey element : future.get().iterateAll()) {
504    *     // doThingsWith(element);
505    *   }
506    * }
507    * }</pre>
508    */
509   public final UnaryCallable<ListCryptoKeysRequest, ListCryptoKeysPagedResponse>
listCryptoKeysPagedCallable()510       listCryptoKeysPagedCallable() {
511     return stub.listCryptoKeysPagedCallable();
512   }
513 
514   // AUTO-GENERATED DOCUMENTATION AND METHOD.
515   /**
516    * Lists [CryptoKeys][google.cloud.kms.v1.CryptoKey].
517    *
518    * <p>Sample code:
519    *
520    * <pre>{@code
521    * // This snippet has been automatically generated and should be regarded as a code template only.
522    * // It will require modifications to work:
523    * // - It may require correct/in-range values for request initialization.
524    * // - It may require specifying regional endpoints when creating the service client as shown in
525    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
526    * try (KeyManagementServiceClient keyManagementServiceClient =
527    *     KeyManagementServiceClient.create()) {
528    *   ListCryptoKeysRequest request =
529    *       ListCryptoKeysRequest.newBuilder()
530    *           .setParent(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString())
531    *           .setPageSize(883849137)
532    *           .setPageToken("pageToken873572522")
533    *           .setFilter("filter-1274492040")
534    *           .setOrderBy("orderBy-1207110587")
535    *           .build();
536    *   while (true) {
537    *     ListCryptoKeysResponse response =
538    *         keyManagementServiceClient.listCryptoKeysCallable().call(request);
539    *     for (CryptoKey element : response.getCryptoKeysList()) {
540    *       // doThingsWith(element);
541    *     }
542    *     String nextPageToken = response.getNextPageToken();
543    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
544    *       request = request.toBuilder().setPageToken(nextPageToken).build();
545    *     } else {
546    *       break;
547    *     }
548    *   }
549    * }
550    * }</pre>
551    */
552   public final UnaryCallable<ListCryptoKeysRequest, ListCryptoKeysResponse>
listCryptoKeysCallable()553       listCryptoKeysCallable() {
554     return stub.listCryptoKeysCallable();
555   }
556 
557   // AUTO-GENERATED DOCUMENTATION AND METHOD.
558   /**
559    * Lists [CryptoKeyVersions][google.cloud.kms.v1.CryptoKeyVersion].
560    *
561    * <p>Sample code:
562    *
563    * <pre>{@code
564    * // This snippet has been automatically generated and should be regarded as a code template only.
565    * // It will require modifications to work:
566    * // - It may require correct/in-range values for request initialization.
567    * // - It may require specifying regional endpoints when creating the service client as shown in
568    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
569    * try (KeyManagementServiceClient keyManagementServiceClient =
570    *     KeyManagementServiceClient.create()) {
571    *   CryptoKeyName parent =
572    *       CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
573    *   for (CryptoKeyVersion element :
574    *       keyManagementServiceClient.listCryptoKeyVersions(parent).iterateAll()) {
575    *     // doThingsWith(element);
576    *   }
577    * }
578    * }</pre>
579    *
580    * @param parent Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] to
581    *     list, in the format `projects/&#42;/locations/&#42;/keyRings/&#42;/cryptoKeys/&#42;`.
582    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
583    */
listCryptoKeyVersions(CryptoKeyName parent)584   public final ListCryptoKeyVersionsPagedResponse listCryptoKeyVersions(CryptoKeyName parent) {
585     ListCryptoKeyVersionsRequest request =
586         ListCryptoKeyVersionsRequest.newBuilder()
587             .setParent(parent == null ? null : parent.toString())
588             .build();
589     return listCryptoKeyVersions(request);
590   }
591 
592   // AUTO-GENERATED DOCUMENTATION AND METHOD.
593   /**
594    * Lists [CryptoKeyVersions][google.cloud.kms.v1.CryptoKeyVersion].
595    *
596    * <p>Sample code:
597    *
598    * <pre>{@code
599    * // This snippet has been automatically generated and should be regarded as a code template only.
600    * // It will require modifications to work:
601    * // - It may require correct/in-range values for request initialization.
602    * // - It may require specifying regional endpoints when creating the service client as shown in
603    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
604    * try (KeyManagementServiceClient keyManagementServiceClient =
605    *     KeyManagementServiceClient.create()) {
606    *   String parent =
607    *       CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString();
608    *   for (CryptoKeyVersion element :
609    *       keyManagementServiceClient.listCryptoKeyVersions(parent).iterateAll()) {
610    *     // doThingsWith(element);
611    *   }
612    * }
613    * }</pre>
614    *
615    * @param parent Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] to
616    *     list, in the format `projects/&#42;/locations/&#42;/keyRings/&#42;/cryptoKeys/&#42;`.
617    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
618    */
listCryptoKeyVersions(String parent)619   public final ListCryptoKeyVersionsPagedResponse listCryptoKeyVersions(String parent) {
620     ListCryptoKeyVersionsRequest request =
621         ListCryptoKeyVersionsRequest.newBuilder().setParent(parent).build();
622     return listCryptoKeyVersions(request);
623   }
624 
625   // AUTO-GENERATED DOCUMENTATION AND METHOD.
626   /**
627    * Lists [CryptoKeyVersions][google.cloud.kms.v1.CryptoKeyVersion].
628    *
629    * <p>Sample code:
630    *
631    * <pre>{@code
632    * // This snippet has been automatically generated and should be regarded as a code template only.
633    * // It will require modifications to work:
634    * // - It may require correct/in-range values for request initialization.
635    * // - It may require specifying regional endpoints when creating the service client as shown in
636    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
637    * try (KeyManagementServiceClient keyManagementServiceClient =
638    *     KeyManagementServiceClient.create()) {
639    *   ListCryptoKeyVersionsRequest request =
640    *       ListCryptoKeyVersionsRequest.newBuilder()
641    *           .setParent(
642    *               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
643    *                   .toString())
644    *           .setPageSize(883849137)
645    *           .setPageToken("pageToken873572522")
646    *           .setFilter("filter-1274492040")
647    *           .setOrderBy("orderBy-1207110587")
648    *           .build();
649    *   for (CryptoKeyVersion element :
650    *       keyManagementServiceClient.listCryptoKeyVersions(request).iterateAll()) {
651    *     // doThingsWith(element);
652    *   }
653    * }
654    * }</pre>
655    *
656    * @param request The request object containing all of the parameters for the API call.
657    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
658    */
listCryptoKeyVersions( ListCryptoKeyVersionsRequest request)659   public final ListCryptoKeyVersionsPagedResponse listCryptoKeyVersions(
660       ListCryptoKeyVersionsRequest request) {
661     return listCryptoKeyVersionsPagedCallable().call(request);
662   }
663 
664   // AUTO-GENERATED DOCUMENTATION AND METHOD.
665   /**
666    * Lists [CryptoKeyVersions][google.cloud.kms.v1.CryptoKeyVersion].
667    *
668    * <p>Sample code:
669    *
670    * <pre>{@code
671    * // This snippet has been automatically generated and should be regarded as a code template only.
672    * // It will require modifications to work:
673    * // - It may require correct/in-range values for request initialization.
674    * // - It may require specifying regional endpoints when creating the service client as shown in
675    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
676    * try (KeyManagementServiceClient keyManagementServiceClient =
677    *     KeyManagementServiceClient.create()) {
678    *   ListCryptoKeyVersionsRequest request =
679    *       ListCryptoKeyVersionsRequest.newBuilder()
680    *           .setParent(
681    *               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
682    *                   .toString())
683    *           .setPageSize(883849137)
684    *           .setPageToken("pageToken873572522")
685    *           .setFilter("filter-1274492040")
686    *           .setOrderBy("orderBy-1207110587")
687    *           .build();
688    *   ApiFuture<CryptoKeyVersion> future =
689    *       keyManagementServiceClient.listCryptoKeyVersionsPagedCallable().futureCall(request);
690    *   // Do something.
691    *   for (CryptoKeyVersion element : future.get().iterateAll()) {
692    *     // doThingsWith(element);
693    *   }
694    * }
695    * }</pre>
696    */
697   public final UnaryCallable<ListCryptoKeyVersionsRequest, ListCryptoKeyVersionsPagedResponse>
listCryptoKeyVersionsPagedCallable()698       listCryptoKeyVersionsPagedCallable() {
699     return stub.listCryptoKeyVersionsPagedCallable();
700   }
701 
702   // AUTO-GENERATED DOCUMENTATION AND METHOD.
703   /**
704    * Lists [CryptoKeyVersions][google.cloud.kms.v1.CryptoKeyVersion].
705    *
706    * <p>Sample code:
707    *
708    * <pre>{@code
709    * // This snippet has been automatically generated and should be regarded as a code template only.
710    * // It will require modifications to work:
711    * // - It may require correct/in-range values for request initialization.
712    * // - It may require specifying regional endpoints when creating the service client as shown in
713    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
714    * try (KeyManagementServiceClient keyManagementServiceClient =
715    *     KeyManagementServiceClient.create()) {
716    *   ListCryptoKeyVersionsRequest request =
717    *       ListCryptoKeyVersionsRequest.newBuilder()
718    *           .setParent(
719    *               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
720    *                   .toString())
721    *           .setPageSize(883849137)
722    *           .setPageToken("pageToken873572522")
723    *           .setFilter("filter-1274492040")
724    *           .setOrderBy("orderBy-1207110587")
725    *           .build();
726    *   while (true) {
727    *     ListCryptoKeyVersionsResponse response =
728    *         keyManagementServiceClient.listCryptoKeyVersionsCallable().call(request);
729    *     for (CryptoKeyVersion element : response.getCryptoKeyVersionsList()) {
730    *       // doThingsWith(element);
731    *     }
732    *     String nextPageToken = response.getNextPageToken();
733    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
734    *       request = request.toBuilder().setPageToken(nextPageToken).build();
735    *     } else {
736    *       break;
737    *     }
738    *   }
739    * }
740    * }</pre>
741    */
742   public final UnaryCallable<ListCryptoKeyVersionsRequest, ListCryptoKeyVersionsResponse>
listCryptoKeyVersionsCallable()743       listCryptoKeyVersionsCallable() {
744     return stub.listCryptoKeyVersionsCallable();
745   }
746 
747   // AUTO-GENERATED DOCUMENTATION AND METHOD.
748   /**
749    * Lists [ImportJobs][google.cloud.kms.v1.ImportJob].
750    *
751    * <p>Sample code:
752    *
753    * <pre>{@code
754    * // This snippet has been automatically generated and should be regarded as a code template only.
755    * // It will require modifications to work:
756    * // - It may require correct/in-range values for request initialization.
757    * // - It may require specifying regional endpoints when creating the service client as shown in
758    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
759    * try (KeyManagementServiceClient keyManagementServiceClient =
760    *     KeyManagementServiceClient.create()) {
761    *   KeyRingName parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
762    *   for (ImportJob element : keyManagementServiceClient.listImportJobs(parent).iterateAll()) {
763    *     // doThingsWith(element);
764    *   }
765    * }
766    * }</pre>
767    *
768    * @param parent Required. The resource name of the [KeyRing][google.cloud.kms.v1.KeyRing] to
769    *     list, in the format `projects/&#42;/locations/&#42;/keyRings/&#42;`.
770    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
771    */
listImportJobs(KeyRingName parent)772   public final ListImportJobsPagedResponse listImportJobs(KeyRingName parent) {
773     ListImportJobsRequest request =
774         ListImportJobsRequest.newBuilder()
775             .setParent(parent == null ? null : parent.toString())
776             .build();
777     return listImportJobs(request);
778   }
779 
780   // AUTO-GENERATED DOCUMENTATION AND METHOD.
781   /**
782    * Lists [ImportJobs][google.cloud.kms.v1.ImportJob].
783    *
784    * <p>Sample code:
785    *
786    * <pre>{@code
787    * // This snippet has been automatically generated and should be regarded as a code template only.
788    * // It will require modifications to work:
789    * // - It may require correct/in-range values for request initialization.
790    * // - It may require specifying regional endpoints when creating the service client as shown in
791    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
792    * try (KeyManagementServiceClient keyManagementServiceClient =
793    *     KeyManagementServiceClient.create()) {
794    *   String parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString();
795    *   for (ImportJob element : keyManagementServiceClient.listImportJobs(parent).iterateAll()) {
796    *     // doThingsWith(element);
797    *   }
798    * }
799    * }</pre>
800    *
801    * @param parent Required. The resource name of the [KeyRing][google.cloud.kms.v1.KeyRing] to
802    *     list, in the format `projects/&#42;/locations/&#42;/keyRings/&#42;`.
803    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
804    */
listImportJobs(String parent)805   public final ListImportJobsPagedResponse listImportJobs(String parent) {
806     ListImportJobsRequest request = ListImportJobsRequest.newBuilder().setParent(parent).build();
807     return listImportJobs(request);
808   }
809 
810   // AUTO-GENERATED DOCUMENTATION AND METHOD.
811   /**
812    * Lists [ImportJobs][google.cloud.kms.v1.ImportJob].
813    *
814    * <p>Sample code:
815    *
816    * <pre>{@code
817    * // This snippet has been automatically generated and should be regarded as a code template only.
818    * // It will require modifications to work:
819    * // - It may require correct/in-range values for request initialization.
820    * // - It may require specifying regional endpoints when creating the service client as shown in
821    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
822    * try (KeyManagementServiceClient keyManagementServiceClient =
823    *     KeyManagementServiceClient.create()) {
824    *   ListImportJobsRequest request =
825    *       ListImportJobsRequest.newBuilder()
826    *           .setParent(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString())
827    *           .setPageSize(883849137)
828    *           .setPageToken("pageToken873572522")
829    *           .setFilter("filter-1274492040")
830    *           .setOrderBy("orderBy-1207110587")
831    *           .build();
832    *   for (ImportJob element : keyManagementServiceClient.listImportJobs(request).iterateAll()) {
833    *     // doThingsWith(element);
834    *   }
835    * }
836    * }</pre>
837    *
838    * @param request The request object containing all of the parameters for the API call.
839    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
840    */
listImportJobs(ListImportJobsRequest request)841   public final ListImportJobsPagedResponse listImportJobs(ListImportJobsRequest request) {
842     return listImportJobsPagedCallable().call(request);
843   }
844 
845   // AUTO-GENERATED DOCUMENTATION AND METHOD.
846   /**
847    * Lists [ImportJobs][google.cloud.kms.v1.ImportJob].
848    *
849    * <p>Sample code:
850    *
851    * <pre>{@code
852    * // This snippet has been automatically generated and should be regarded as a code template only.
853    * // It will require modifications to work:
854    * // - It may require correct/in-range values for request initialization.
855    * // - It may require specifying regional endpoints when creating the service client as shown in
856    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
857    * try (KeyManagementServiceClient keyManagementServiceClient =
858    *     KeyManagementServiceClient.create()) {
859    *   ListImportJobsRequest request =
860    *       ListImportJobsRequest.newBuilder()
861    *           .setParent(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString())
862    *           .setPageSize(883849137)
863    *           .setPageToken("pageToken873572522")
864    *           .setFilter("filter-1274492040")
865    *           .setOrderBy("orderBy-1207110587")
866    *           .build();
867    *   ApiFuture<ImportJob> future =
868    *       keyManagementServiceClient.listImportJobsPagedCallable().futureCall(request);
869    *   // Do something.
870    *   for (ImportJob element : future.get().iterateAll()) {
871    *     // doThingsWith(element);
872    *   }
873    * }
874    * }</pre>
875    */
876   public final UnaryCallable<ListImportJobsRequest, ListImportJobsPagedResponse>
listImportJobsPagedCallable()877       listImportJobsPagedCallable() {
878     return stub.listImportJobsPagedCallable();
879   }
880 
881   // AUTO-GENERATED DOCUMENTATION AND METHOD.
882   /**
883    * Lists [ImportJobs][google.cloud.kms.v1.ImportJob].
884    *
885    * <p>Sample code:
886    *
887    * <pre>{@code
888    * // This snippet has been automatically generated and should be regarded as a code template only.
889    * // It will require modifications to work:
890    * // - It may require correct/in-range values for request initialization.
891    * // - It may require specifying regional endpoints when creating the service client as shown in
892    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
893    * try (KeyManagementServiceClient keyManagementServiceClient =
894    *     KeyManagementServiceClient.create()) {
895    *   ListImportJobsRequest request =
896    *       ListImportJobsRequest.newBuilder()
897    *           .setParent(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString())
898    *           .setPageSize(883849137)
899    *           .setPageToken("pageToken873572522")
900    *           .setFilter("filter-1274492040")
901    *           .setOrderBy("orderBy-1207110587")
902    *           .build();
903    *   while (true) {
904    *     ListImportJobsResponse response =
905    *         keyManagementServiceClient.listImportJobsCallable().call(request);
906    *     for (ImportJob element : response.getImportJobsList()) {
907    *       // doThingsWith(element);
908    *     }
909    *     String nextPageToken = response.getNextPageToken();
910    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
911    *       request = request.toBuilder().setPageToken(nextPageToken).build();
912    *     } else {
913    *       break;
914    *     }
915    *   }
916    * }
917    * }</pre>
918    */
919   public final UnaryCallable<ListImportJobsRequest, ListImportJobsResponse>
listImportJobsCallable()920       listImportJobsCallable() {
921     return stub.listImportJobsCallable();
922   }
923 
924   // AUTO-GENERATED DOCUMENTATION AND METHOD.
925   /**
926    * Returns metadata for a given [KeyRing][google.cloud.kms.v1.KeyRing].
927    *
928    * <p>Sample code:
929    *
930    * <pre>{@code
931    * // This snippet has been automatically generated and should be regarded as a code template only.
932    * // It will require modifications to work:
933    * // - It may require correct/in-range values for request initialization.
934    * // - It may require specifying regional endpoints when creating the service client as shown in
935    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
936    * try (KeyManagementServiceClient keyManagementServiceClient =
937    *     KeyManagementServiceClient.create()) {
938    *   KeyRingName name = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
939    *   KeyRing response = keyManagementServiceClient.getKeyRing(name);
940    * }
941    * }</pre>
942    *
943    * @param name Required. The [name][google.cloud.kms.v1.KeyRing.name] of the
944    *     [KeyRing][google.cloud.kms.v1.KeyRing] to get.
945    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
946    */
getKeyRing(KeyRingName name)947   public final KeyRing getKeyRing(KeyRingName name) {
948     GetKeyRingRequest request =
949         GetKeyRingRequest.newBuilder().setName(name == null ? null : name.toString()).build();
950     return getKeyRing(request);
951   }
952 
953   // AUTO-GENERATED DOCUMENTATION AND METHOD.
954   /**
955    * Returns metadata for a given [KeyRing][google.cloud.kms.v1.KeyRing].
956    *
957    * <p>Sample code:
958    *
959    * <pre>{@code
960    * // This snippet has been automatically generated and should be regarded as a code template only.
961    * // It will require modifications to work:
962    * // - It may require correct/in-range values for request initialization.
963    * // - It may require specifying regional endpoints when creating the service client as shown in
964    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
965    * try (KeyManagementServiceClient keyManagementServiceClient =
966    *     KeyManagementServiceClient.create()) {
967    *   String name = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString();
968    *   KeyRing response = keyManagementServiceClient.getKeyRing(name);
969    * }
970    * }</pre>
971    *
972    * @param name Required. The [name][google.cloud.kms.v1.KeyRing.name] of the
973    *     [KeyRing][google.cloud.kms.v1.KeyRing] to get.
974    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
975    */
getKeyRing(String name)976   public final KeyRing getKeyRing(String name) {
977     GetKeyRingRequest request = GetKeyRingRequest.newBuilder().setName(name).build();
978     return getKeyRing(request);
979   }
980 
981   // AUTO-GENERATED DOCUMENTATION AND METHOD.
982   /**
983    * Returns metadata for a given [KeyRing][google.cloud.kms.v1.KeyRing].
984    *
985    * <p>Sample code:
986    *
987    * <pre>{@code
988    * // This snippet has been automatically generated and should be regarded as a code template only.
989    * // It will require modifications to work:
990    * // - It may require correct/in-range values for request initialization.
991    * // - It may require specifying regional endpoints when creating the service client as shown in
992    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
993    * try (KeyManagementServiceClient keyManagementServiceClient =
994    *     KeyManagementServiceClient.create()) {
995    *   GetKeyRingRequest request =
996    *       GetKeyRingRequest.newBuilder()
997    *           .setName(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString())
998    *           .build();
999    *   KeyRing response = keyManagementServiceClient.getKeyRing(request);
1000    * }
1001    * }</pre>
1002    *
1003    * @param request The request object containing all of the parameters for the API call.
1004    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1005    */
getKeyRing(GetKeyRingRequest request)1006   public final KeyRing getKeyRing(GetKeyRingRequest request) {
1007     return getKeyRingCallable().call(request);
1008   }
1009 
1010   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1011   /**
1012    * Returns metadata for a given [KeyRing][google.cloud.kms.v1.KeyRing].
1013    *
1014    * <p>Sample code:
1015    *
1016    * <pre>{@code
1017    * // This snippet has been automatically generated and should be regarded as a code template only.
1018    * // It will require modifications to work:
1019    * // - It may require correct/in-range values for request initialization.
1020    * // - It may require specifying regional endpoints when creating the service client as shown in
1021    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1022    * try (KeyManagementServiceClient keyManagementServiceClient =
1023    *     KeyManagementServiceClient.create()) {
1024    *   GetKeyRingRequest request =
1025    *       GetKeyRingRequest.newBuilder()
1026    *           .setName(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString())
1027    *           .build();
1028    *   ApiFuture<KeyRing> future =
1029    *       keyManagementServiceClient.getKeyRingCallable().futureCall(request);
1030    *   // Do something.
1031    *   KeyRing response = future.get();
1032    * }
1033    * }</pre>
1034    */
getKeyRingCallable()1035   public final UnaryCallable<GetKeyRingRequest, KeyRing> getKeyRingCallable() {
1036     return stub.getKeyRingCallable();
1037   }
1038 
1039   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1040   /**
1041    * Returns metadata for a given [CryptoKey][google.cloud.kms.v1.CryptoKey], as well as its
1042    * [primary][google.cloud.kms.v1.CryptoKey.primary]
1043    * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].
1044    *
1045    * <p>Sample code:
1046    *
1047    * <pre>{@code
1048    * // This snippet has been automatically generated and should be regarded as a code template only.
1049    * // It will require modifications to work:
1050    * // - It may require correct/in-range values for request initialization.
1051    * // - It may require specifying regional endpoints when creating the service client as shown in
1052    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1053    * try (KeyManagementServiceClient keyManagementServiceClient =
1054    *     KeyManagementServiceClient.create()) {
1055    *   CryptoKeyName name =
1056    *       CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
1057    *   CryptoKey response = keyManagementServiceClient.getCryptoKey(name);
1058    * }
1059    * }</pre>
1060    *
1061    * @param name Required. The [name][google.cloud.kms.v1.CryptoKey.name] of the
1062    *     [CryptoKey][google.cloud.kms.v1.CryptoKey] to get.
1063    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1064    */
getCryptoKey(CryptoKeyName name)1065   public final CryptoKey getCryptoKey(CryptoKeyName name) {
1066     GetCryptoKeyRequest request =
1067         GetCryptoKeyRequest.newBuilder().setName(name == null ? null : name.toString()).build();
1068     return getCryptoKey(request);
1069   }
1070 
1071   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1072   /**
1073    * Returns metadata for a given [CryptoKey][google.cloud.kms.v1.CryptoKey], as well as its
1074    * [primary][google.cloud.kms.v1.CryptoKey.primary]
1075    * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].
1076    *
1077    * <p>Sample code:
1078    *
1079    * <pre>{@code
1080    * // This snippet has been automatically generated and should be regarded as a code template only.
1081    * // It will require modifications to work:
1082    * // - It may require correct/in-range values for request initialization.
1083    * // - It may require specifying regional endpoints when creating the service client as shown in
1084    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1085    * try (KeyManagementServiceClient keyManagementServiceClient =
1086    *     KeyManagementServiceClient.create()) {
1087    *   String name =
1088    *       CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString();
1089    *   CryptoKey response = keyManagementServiceClient.getCryptoKey(name);
1090    * }
1091    * }</pre>
1092    *
1093    * @param name Required. The [name][google.cloud.kms.v1.CryptoKey.name] of the
1094    *     [CryptoKey][google.cloud.kms.v1.CryptoKey] to get.
1095    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1096    */
getCryptoKey(String name)1097   public final CryptoKey getCryptoKey(String name) {
1098     GetCryptoKeyRequest request = GetCryptoKeyRequest.newBuilder().setName(name).build();
1099     return getCryptoKey(request);
1100   }
1101 
1102   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1103   /**
1104    * Returns metadata for a given [CryptoKey][google.cloud.kms.v1.CryptoKey], as well as its
1105    * [primary][google.cloud.kms.v1.CryptoKey.primary]
1106    * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].
1107    *
1108    * <p>Sample code:
1109    *
1110    * <pre>{@code
1111    * // This snippet has been automatically generated and should be regarded as a code template only.
1112    * // It will require modifications to work:
1113    * // - It may require correct/in-range values for request initialization.
1114    * // - It may require specifying regional endpoints when creating the service client as shown in
1115    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1116    * try (KeyManagementServiceClient keyManagementServiceClient =
1117    *     KeyManagementServiceClient.create()) {
1118    *   GetCryptoKeyRequest request =
1119    *       GetCryptoKeyRequest.newBuilder()
1120    *           .setName(
1121    *               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
1122    *                   .toString())
1123    *           .build();
1124    *   CryptoKey response = keyManagementServiceClient.getCryptoKey(request);
1125    * }
1126    * }</pre>
1127    *
1128    * @param request The request object containing all of the parameters for the API call.
1129    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1130    */
getCryptoKey(GetCryptoKeyRequest request)1131   public final CryptoKey getCryptoKey(GetCryptoKeyRequest request) {
1132     return getCryptoKeyCallable().call(request);
1133   }
1134 
1135   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1136   /**
1137    * Returns metadata for a given [CryptoKey][google.cloud.kms.v1.CryptoKey], as well as its
1138    * [primary][google.cloud.kms.v1.CryptoKey.primary]
1139    * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].
1140    *
1141    * <p>Sample code:
1142    *
1143    * <pre>{@code
1144    * // This snippet has been automatically generated and should be regarded as a code template only.
1145    * // It will require modifications to work:
1146    * // - It may require correct/in-range values for request initialization.
1147    * // - It may require specifying regional endpoints when creating the service client as shown in
1148    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1149    * try (KeyManagementServiceClient keyManagementServiceClient =
1150    *     KeyManagementServiceClient.create()) {
1151    *   GetCryptoKeyRequest request =
1152    *       GetCryptoKeyRequest.newBuilder()
1153    *           .setName(
1154    *               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
1155    *                   .toString())
1156    *           .build();
1157    *   ApiFuture<CryptoKey> future =
1158    *       keyManagementServiceClient.getCryptoKeyCallable().futureCall(request);
1159    *   // Do something.
1160    *   CryptoKey response = future.get();
1161    * }
1162    * }</pre>
1163    */
getCryptoKeyCallable()1164   public final UnaryCallable<GetCryptoKeyRequest, CryptoKey> getCryptoKeyCallable() {
1165     return stub.getCryptoKeyCallable();
1166   }
1167 
1168   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1169   /**
1170    * Returns metadata for a given [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].
1171    *
1172    * <p>Sample code:
1173    *
1174    * <pre>{@code
1175    * // This snippet has been automatically generated and should be regarded as a code template only.
1176    * // It will require modifications to work:
1177    * // - It may require correct/in-range values for request initialization.
1178    * // - It may require specifying regional endpoints when creating the service client as shown in
1179    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1180    * try (KeyManagementServiceClient keyManagementServiceClient =
1181    *     KeyManagementServiceClient.create()) {
1182    *   CryptoKeyVersionName name =
1183    *       CryptoKeyVersionName.of(
1184    *           "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]");
1185    *   CryptoKeyVersion response = keyManagementServiceClient.getCryptoKeyVersion(name);
1186    * }
1187    * }</pre>
1188    *
1189    * @param name Required. The [name][google.cloud.kms.v1.CryptoKeyVersion.name] of the
1190    *     [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to get.
1191    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1192    */
getCryptoKeyVersion(CryptoKeyVersionName name)1193   public final CryptoKeyVersion getCryptoKeyVersion(CryptoKeyVersionName name) {
1194     GetCryptoKeyVersionRequest request =
1195         GetCryptoKeyVersionRequest.newBuilder()
1196             .setName(name == null ? null : name.toString())
1197             .build();
1198     return getCryptoKeyVersion(request);
1199   }
1200 
1201   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1202   /**
1203    * Returns metadata for a given [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].
1204    *
1205    * <p>Sample code:
1206    *
1207    * <pre>{@code
1208    * // This snippet has been automatically generated and should be regarded as a code template only.
1209    * // It will require modifications to work:
1210    * // - It may require correct/in-range values for request initialization.
1211    * // - It may require specifying regional endpoints when creating the service client as shown in
1212    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1213    * try (KeyManagementServiceClient keyManagementServiceClient =
1214    *     KeyManagementServiceClient.create()) {
1215    *   String name =
1216    *       CryptoKeyVersionName.of(
1217    *               "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]")
1218    *           .toString();
1219    *   CryptoKeyVersion response = keyManagementServiceClient.getCryptoKeyVersion(name);
1220    * }
1221    * }</pre>
1222    *
1223    * @param name Required. The [name][google.cloud.kms.v1.CryptoKeyVersion.name] of the
1224    *     [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to get.
1225    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1226    */
getCryptoKeyVersion(String name)1227   public final CryptoKeyVersion getCryptoKeyVersion(String name) {
1228     GetCryptoKeyVersionRequest request =
1229         GetCryptoKeyVersionRequest.newBuilder().setName(name).build();
1230     return getCryptoKeyVersion(request);
1231   }
1232 
1233   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1234   /**
1235    * Returns metadata for a given [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].
1236    *
1237    * <p>Sample code:
1238    *
1239    * <pre>{@code
1240    * // This snippet has been automatically generated and should be regarded as a code template only.
1241    * // It will require modifications to work:
1242    * // - It may require correct/in-range values for request initialization.
1243    * // - It may require specifying regional endpoints when creating the service client as shown in
1244    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1245    * try (KeyManagementServiceClient keyManagementServiceClient =
1246    *     KeyManagementServiceClient.create()) {
1247    *   GetCryptoKeyVersionRequest request =
1248    *       GetCryptoKeyVersionRequest.newBuilder()
1249    *           .setName(
1250    *               CryptoKeyVersionName.of(
1251    *                       "[PROJECT]",
1252    *                       "[LOCATION]",
1253    *                       "[KEY_RING]",
1254    *                       "[CRYPTO_KEY]",
1255    *                       "[CRYPTO_KEY_VERSION]")
1256    *                   .toString())
1257    *           .build();
1258    *   CryptoKeyVersion response = keyManagementServiceClient.getCryptoKeyVersion(request);
1259    * }
1260    * }</pre>
1261    *
1262    * @param request The request object containing all of the parameters for the API call.
1263    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1264    */
getCryptoKeyVersion(GetCryptoKeyVersionRequest request)1265   public final CryptoKeyVersion getCryptoKeyVersion(GetCryptoKeyVersionRequest request) {
1266     return getCryptoKeyVersionCallable().call(request);
1267   }
1268 
1269   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1270   /**
1271    * Returns metadata for a given [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].
1272    *
1273    * <p>Sample code:
1274    *
1275    * <pre>{@code
1276    * // This snippet has been automatically generated and should be regarded as a code template only.
1277    * // It will require modifications to work:
1278    * // - It may require correct/in-range values for request initialization.
1279    * // - It may require specifying regional endpoints when creating the service client as shown in
1280    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1281    * try (KeyManagementServiceClient keyManagementServiceClient =
1282    *     KeyManagementServiceClient.create()) {
1283    *   GetCryptoKeyVersionRequest request =
1284    *       GetCryptoKeyVersionRequest.newBuilder()
1285    *           .setName(
1286    *               CryptoKeyVersionName.of(
1287    *                       "[PROJECT]",
1288    *                       "[LOCATION]",
1289    *                       "[KEY_RING]",
1290    *                       "[CRYPTO_KEY]",
1291    *                       "[CRYPTO_KEY_VERSION]")
1292    *                   .toString())
1293    *           .build();
1294    *   ApiFuture<CryptoKeyVersion> future =
1295    *       keyManagementServiceClient.getCryptoKeyVersionCallable().futureCall(request);
1296    *   // Do something.
1297    *   CryptoKeyVersion response = future.get();
1298    * }
1299    * }</pre>
1300    */
1301   public final UnaryCallable<GetCryptoKeyVersionRequest, CryptoKeyVersion>
getCryptoKeyVersionCallable()1302       getCryptoKeyVersionCallable() {
1303     return stub.getCryptoKeyVersionCallable();
1304   }
1305 
1306   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1307   /**
1308    * Returns the public key for the given [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].
1309    * The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be
1310    * [ASYMMETRIC_SIGN][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_SIGN] or
1311    * [ASYMMETRIC_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_DECRYPT].
1312    *
1313    * <p>Sample code:
1314    *
1315    * <pre>{@code
1316    * // This snippet has been automatically generated and should be regarded as a code template only.
1317    * // It will require modifications to work:
1318    * // - It may require correct/in-range values for request initialization.
1319    * // - It may require specifying regional endpoints when creating the service client as shown in
1320    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1321    * try (KeyManagementServiceClient keyManagementServiceClient =
1322    *     KeyManagementServiceClient.create()) {
1323    *   CryptoKeyVersionName name =
1324    *       CryptoKeyVersionName.of(
1325    *           "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]");
1326    *   PublicKey response = keyManagementServiceClient.getPublicKey(name);
1327    * }
1328    * }</pre>
1329    *
1330    * @param name Required. The [name][google.cloud.kms.v1.CryptoKeyVersion.name] of the
1331    *     [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] public key to get.
1332    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1333    */
getPublicKey(CryptoKeyVersionName name)1334   public final PublicKey getPublicKey(CryptoKeyVersionName name) {
1335     GetPublicKeyRequest request =
1336         GetPublicKeyRequest.newBuilder().setName(name == null ? null : name.toString()).build();
1337     return getPublicKey(request);
1338   }
1339 
1340   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1341   /**
1342    * Returns the public key for the given [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].
1343    * The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be
1344    * [ASYMMETRIC_SIGN][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_SIGN] or
1345    * [ASYMMETRIC_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_DECRYPT].
1346    *
1347    * <p>Sample code:
1348    *
1349    * <pre>{@code
1350    * // This snippet has been automatically generated and should be regarded as a code template only.
1351    * // It will require modifications to work:
1352    * // - It may require correct/in-range values for request initialization.
1353    * // - It may require specifying regional endpoints when creating the service client as shown in
1354    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1355    * try (KeyManagementServiceClient keyManagementServiceClient =
1356    *     KeyManagementServiceClient.create()) {
1357    *   String name =
1358    *       CryptoKeyVersionName.of(
1359    *               "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]")
1360    *           .toString();
1361    *   PublicKey response = keyManagementServiceClient.getPublicKey(name);
1362    * }
1363    * }</pre>
1364    *
1365    * @param name Required. The [name][google.cloud.kms.v1.CryptoKeyVersion.name] of the
1366    *     [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] public key to get.
1367    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1368    */
getPublicKey(String name)1369   public final PublicKey getPublicKey(String name) {
1370     GetPublicKeyRequest request = GetPublicKeyRequest.newBuilder().setName(name).build();
1371     return getPublicKey(request);
1372   }
1373 
1374   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1375   /**
1376    * Returns the public key for the given [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].
1377    * The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be
1378    * [ASYMMETRIC_SIGN][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_SIGN] or
1379    * [ASYMMETRIC_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_DECRYPT].
1380    *
1381    * <p>Sample code:
1382    *
1383    * <pre>{@code
1384    * // This snippet has been automatically generated and should be regarded as a code template only.
1385    * // It will require modifications to work:
1386    * // - It may require correct/in-range values for request initialization.
1387    * // - It may require specifying regional endpoints when creating the service client as shown in
1388    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1389    * try (KeyManagementServiceClient keyManagementServiceClient =
1390    *     KeyManagementServiceClient.create()) {
1391    *   GetPublicKeyRequest request =
1392    *       GetPublicKeyRequest.newBuilder()
1393    *           .setName(
1394    *               CryptoKeyVersionName.of(
1395    *                       "[PROJECT]",
1396    *                       "[LOCATION]",
1397    *                       "[KEY_RING]",
1398    *                       "[CRYPTO_KEY]",
1399    *                       "[CRYPTO_KEY_VERSION]")
1400    *                   .toString())
1401    *           .build();
1402    *   PublicKey response = keyManagementServiceClient.getPublicKey(request);
1403    * }
1404    * }</pre>
1405    *
1406    * @param request The request object containing all of the parameters for the API call.
1407    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1408    */
getPublicKey(GetPublicKeyRequest request)1409   public final PublicKey getPublicKey(GetPublicKeyRequest request) {
1410     return getPublicKeyCallable().call(request);
1411   }
1412 
1413   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1414   /**
1415    * Returns the public key for the given [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].
1416    * The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be
1417    * [ASYMMETRIC_SIGN][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_SIGN] or
1418    * [ASYMMETRIC_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_DECRYPT].
1419    *
1420    * <p>Sample code:
1421    *
1422    * <pre>{@code
1423    * // This snippet has been automatically generated and should be regarded as a code template only.
1424    * // It will require modifications to work:
1425    * // - It may require correct/in-range values for request initialization.
1426    * // - It may require specifying regional endpoints when creating the service client as shown in
1427    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1428    * try (KeyManagementServiceClient keyManagementServiceClient =
1429    *     KeyManagementServiceClient.create()) {
1430    *   GetPublicKeyRequest request =
1431    *       GetPublicKeyRequest.newBuilder()
1432    *           .setName(
1433    *               CryptoKeyVersionName.of(
1434    *                       "[PROJECT]",
1435    *                       "[LOCATION]",
1436    *                       "[KEY_RING]",
1437    *                       "[CRYPTO_KEY]",
1438    *                       "[CRYPTO_KEY_VERSION]")
1439    *                   .toString())
1440    *           .build();
1441    *   ApiFuture<PublicKey> future =
1442    *       keyManagementServiceClient.getPublicKeyCallable().futureCall(request);
1443    *   // Do something.
1444    *   PublicKey response = future.get();
1445    * }
1446    * }</pre>
1447    */
getPublicKeyCallable()1448   public final UnaryCallable<GetPublicKeyRequest, PublicKey> getPublicKeyCallable() {
1449     return stub.getPublicKeyCallable();
1450   }
1451 
1452   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1453   /**
1454    * Returns metadata for a given [ImportJob][google.cloud.kms.v1.ImportJob].
1455    *
1456    * <p>Sample code:
1457    *
1458    * <pre>{@code
1459    * // This snippet has been automatically generated and should be regarded as a code template only.
1460    * // It will require modifications to work:
1461    * // - It may require correct/in-range values for request initialization.
1462    * // - It may require specifying regional endpoints when creating the service client as shown in
1463    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1464    * try (KeyManagementServiceClient keyManagementServiceClient =
1465    *     KeyManagementServiceClient.create()) {
1466    *   ImportJobName name =
1467    *       ImportJobName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[IMPORT_JOB]");
1468    *   ImportJob response = keyManagementServiceClient.getImportJob(name);
1469    * }
1470    * }</pre>
1471    *
1472    * @param name Required. The [name][google.cloud.kms.v1.ImportJob.name] of the
1473    *     [ImportJob][google.cloud.kms.v1.ImportJob] to get.
1474    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1475    */
getImportJob(ImportJobName name)1476   public final ImportJob getImportJob(ImportJobName name) {
1477     GetImportJobRequest request =
1478         GetImportJobRequest.newBuilder().setName(name == null ? null : name.toString()).build();
1479     return getImportJob(request);
1480   }
1481 
1482   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1483   /**
1484    * Returns metadata for a given [ImportJob][google.cloud.kms.v1.ImportJob].
1485    *
1486    * <p>Sample code:
1487    *
1488    * <pre>{@code
1489    * // This snippet has been automatically generated and should be regarded as a code template only.
1490    * // It will require modifications to work:
1491    * // - It may require correct/in-range values for request initialization.
1492    * // - It may require specifying regional endpoints when creating the service client as shown in
1493    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1494    * try (KeyManagementServiceClient keyManagementServiceClient =
1495    *     KeyManagementServiceClient.create()) {
1496    *   String name =
1497    *       ImportJobName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[IMPORT_JOB]").toString();
1498    *   ImportJob response = keyManagementServiceClient.getImportJob(name);
1499    * }
1500    * }</pre>
1501    *
1502    * @param name Required. The [name][google.cloud.kms.v1.ImportJob.name] of the
1503    *     [ImportJob][google.cloud.kms.v1.ImportJob] to get.
1504    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1505    */
getImportJob(String name)1506   public final ImportJob getImportJob(String name) {
1507     GetImportJobRequest request = GetImportJobRequest.newBuilder().setName(name).build();
1508     return getImportJob(request);
1509   }
1510 
1511   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1512   /**
1513    * Returns metadata for a given [ImportJob][google.cloud.kms.v1.ImportJob].
1514    *
1515    * <p>Sample code:
1516    *
1517    * <pre>{@code
1518    * // This snippet has been automatically generated and should be regarded as a code template only.
1519    * // It will require modifications to work:
1520    * // - It may require correct/in-range values for request initialization.
1521    * // - It may require specifying regional endpoints when creating the service client as shown in
1522    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1523    * try (KeyManagementServiceClient keyManagementServiceClient =
1524    *     KeyManagementServiceClient.create()) {
1525    *   GetImportJobRequest request =
1526    *       GetImportJobRequest.newBuilder()
1527    *           .setName(
1528    *               ImportJobName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[IMPORT_JOB]")
1529    *                   .toString())
1530    *           .build();
1531    *   ImportJob response = keyManagementServiceClient.getImportJob(request);
1532    * }
1533    * }</pre>
1534    *
1535    * @param request The request object containing all of the parameters for the API call.
1536    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1537    */
getImportJob(GetImportJobRequest request)1538   public final ImportJob getImportJob(GetImportJobRequest request) {
1539     return getImportJobCallable().call(request);
1540   }
1541 
1542   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1543   /**
1544    * Returns metadata for a given [ImportJob][google.cloud.kms.v1.ImportJob].
1545    *
1546    * <p>Sample code:
1547    *
1548    * <pre>{@code
1549    * // This snippet has been automatically generated and should be regarded as a code template only.
1550    * // It will require modifications to work:
1551    * // - It may require correct/in-range values for request initialization.
1552    * // - It may require specifying regional endpoints when creating the service client as shown in
1553    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1554    * try (KeyManagementServiceClient keyManagementServiceClient =
1555    *     KeyManagementServiceClient.create()) {
1556    *   GetImportJobRequest request =
1557    *       GetImportJobRequest.newBuilder()
1558    *           .setName(
1559    *               ImportJobName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[IMPORT_JOB]")
1560    *                   .toString())
1561    *           .build();
1562    *   ApiFuture<ImportJob> future =
1563    *       keyManagementServiceClient.getImportJobCallable().futureCall(request);
1564    *   // Do something.
1565    *   ImportJob response = future.get();
1566    * }
1567    * }</pre>
1568    */
getImportJobCallable()1569   public final UnaryCallable<GetImportJobRequest, ImportJob> getImportJobCallable() {
1570     return stub.getImportJobCallable();
1571   }
1572 
1573   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1574   /**
1575    * Create a new [KeyRing][google.cloud.kms.v1.KeyRing] in a given Project and Location.
1576    *
1577    * <p>Sample code:
1578    *
1579    * <pre>{@code
1580    * // This snippet has been automatically generated and should be regarded as a code template only.
1581    * // It will require modifications to work:
1582    * // - It may require correct/in-range values for request initialization.
1583    * // - It may require specifying regional endpoints when creating the service client as shown in
1584    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1585    * try (KeyManagementServiceClient keyManagementServiceClient =
1586    *     KeyManagementServiceClient.create()) {
1587    *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
1588    *   String keyRingId = "keyRingId-2027180374";
1589    *   KeyRing keyRing = KeyRing.newBuilder().build();
1590    *   KeyRing response = keyManagementServiceClient.createKeyRing(parent, keyRingId, keyRing);
1591    * }
1592    * }</pre>
1593    *
1594    * @param parent Required. The resource name of the location associated with the
1595    *     [KeyRings][google.cloud.kms.v1.KeyRing], in the format `projects/&#42;/locations/&#42;`.
1596    * @param keyRingId Required. It must be unique within a location and match the regular expression
1597    *     `[a-zA-Z0-9_-]{1,63}`
1598    * @param keyRing Required. A [KeyRing][google.cloud.kms.v1.KeyRing] with initial field values.
1599    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1600    */
createKeyRing(LocationName parent, String keyRingId, KeyRing keyRing)1601   public final KeyRing createKeyRing(LocationName parent, String keyRingId, KeyRing keyRing) {
1602     CreateKeyRingRequest request =
1603         CreateKeyRingRequest.newBuilder()
1604             .setParent(parent == null ? null : parent.toString())
1605             .setKeyRingId(keyRingId)
1606             .setKeyRing(keyRing)
1607             .build();
1608     return createKeyRing(request);
1609   }
1610 
1611   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1612   /**
1613    * Create a new [KeyRing][google.cloud.kms.v1.KeyRing] in a given Project and Location.
1614    *
1615    * <p>Sample code:
1616    *
1617    * <pre>{@code
1618    * // This snippet has been automatically generated and should be regarded as a code template only.
1619    * // It will require modifications to work:
1620    * // - It may require correct/in-range values for request initialization.
1621    * // - It may require specifying regional endpoints when creating the service client as shown in
1622    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1623    * try (KeyManagementServiceClient keyManagementServiceClient =
1624    *     KeyManagementServiceClient.create()) {
1625    *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
1626    *   String keyRingId = "keyRingId-2027180374";
1627    *   KeyRing keyRing = KeyRing.newBuilder().build();
1628    *   KeyRing response = keyManagementServiceClient.createKeyRing(parent, keyRingId, keyRing);
1629    * }
1630    * }</pre>
1631    *
1632    * @param parent Required. The resource name of the location associated with the
1633    *     [KeyRings][google.cloud.kms.v1.KeyRing], in the format `projects/&#42;/locations/&#42;`.
1634    * @param keyRingId Required. It must be unique within a location and match the regular expression
1635    *     `[a-zA-Z0-9_-]{1,63}`
1636    * @param keyRing Required. A [KeyRing][google.cloud.kms.v1.KeyRing] with initial field values.
1637    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1638    */
createKeyRing(String parent, String keyRingId, KeyRing keyRing)1639   public final KeyRing createKeyRing(String parent, String keyRingId, KeyRing keyRing) {
1640     CreateKeyRingRequest request =
1641         CreateKeyRingRequest.newBuilder()
1642             .setParent(parent)
1643             .setKeyRingId(keyRingId)
1644             .setKeyRing(keyRing)
1645             .build();
1646     return createKeyRing(request);
1647   }
1648 
1649   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1650   /**
1651    * Create a new [KeyRing][google.cloud.kms.v1.KeyRing] in a given Project and Location.
1652    *
1653    * <p>Sample code:
1654    *
1655    * <pre>{@code
1656    * // This snippet has been automatically generated and should be regarded as a code template only.
1657    * // It will require modifications to work:
1658    * // - It may require correct/in-range values for request initialization.
1659    * // - It may require specifying regional endpoints when creating the service client as shown in
1660    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1661    * try (KeyManagementServiceClient keyManagementServiceClient =
1662    *     KeyManagementServiceClient.create()) {
1663    *   CreateKeyRingRequest request =
1664    *       CreateKeyRingRequest.newBuilder()
1665    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
1666    *           .setKeyRingId("keyRingId-2027180374")
1667    *           .setKeyRing(KeyRing.newBuilder().build())
1668    *           .build();
1669    *   KeyRing response = keyManagementServiceClient.createKeyRing(request);
1670    * }
1671    * }</pre>
1672    *
1673    * @param request The request object containing all of the parameters for the API call.
1674    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1675    */
createKeyRing(CreateKeyRingRequest request)1676   public final KeyRing createKeyRing(CreateKeyRingRequest request) {
1677     return createKeyRingCallable().call(request);
1678   }
1679 
1680   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1681   /**
1682    * Create a new [KeyRing][google.cloud.kms.v1.KeyRing] in a given Project and Location.
1683    *
1684    * <p>Sample code:
1685    *
1686    * <pre>{@code
1687    * // This snippet has been automatically generated and should be regarded as a code template only.
1688    * // It will require modifications to work:
1689    * // - It may require correct/in-range values for request initialization.
1690    * // - It may require specifying regional endpoints when creating the service client as shown in
1691    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1692    * try (KeyManagementServiceClient keyManagementServiceClient =
1693    *     KeyManagementServiceClient.create()) {
1694    *   CreateKeyRingRequest request =
1695    *       CreateKeyRingRequest.newBuilder()
1696    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
1697    *           .setKeyRingId("keyRingId-2027180374")
1698    *           .setKeyRing(KeyRing.newBuilder().build())
1699    *           .build();
1700    *   ApiFuture<KeyRing> future =
1701    *       keyManagementServiceClient.createKeyRingCallable().futureCall(request);
1702    *   // Do something.
1703    *   KeyRing response = future.get();
1704    * }
1705    * }</pre>
1706    */
createKeyRingCallable()1707   public final UnaryCallable<CreateKeyRingRequest, KeyRing> createKeyRingCallable() {
1708     return stub.createKeyRingCallable();
1709   }
1710 
1711   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1712   /**
1713    * Create a new [CryptoKey][google.cloud.kms.v1.CryptoKey] within a
1714    * [KeyRing][google.cloud.kms.v1.KeyRing].
1715    *
1716    * <p>[CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] and
1717    * [CryptoKey.version_template.algorithm][google.cloud.kms.v1.CryptoKeyVersionTemplate.algorithm]
1718    * are required.
1719    *
1720    * <p>Sample code:
1721    *
1722    * <pre>{@code
1723    * // This snippet has been automatically generated and should be regarded as a code template only.
1724    * // It will require modifications to work:
1725    * // - It may require correct/in-range values for request initialization.
1726    * // - It may require specifying regional endpoints when creating the service client as shown in
1727    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1728    * try (KeyManagementServiceClient keyManagementServiceClient =
1729    *     KeyManagementServiceClient.create()) {
1730    *   KeyRingName parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
1731    *   String cryptoKeyId = "cryptoKeyId-1643185255";
1732    *   CryptoKey cryptoKey = CryptoKey.newBuilder().build();
1733    *   CryptoKey response =
1734    *       keyManagementServiceClient.createCryptoKey(parent, cryptoKeyId, cryptoKey);
1735    * }
1736    * }</pre>
1737    *
1738    * @param parent Required. The [name][google.cloud.kms.v1.KeyRing.name] of the KeyRing associated
1739    *     with the [CryptoKeys][google.cloud.kms.v1.CryptoKey].
1740    * @param cryptoKeyId Required. It must be unique within a KeyRing and match the regular
1741    *     expression `[a-zA-Z0-9_-]{1,63}`
1742    * @param cryptoKey Required. A [CryptoKey][google.cloud.kms.v1.CryptoKey] with initial field
1743    *     values.
1744    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1745    */
createCryptoKey( KeyRingName parent, String cryptoKeyId, CryptoKey cryptoKey)1746   public final CryptoKey createCryptoKey(
1747       KeyRingName parent, String cryptoKeyId, CryptoKey cryptoKey) {
1748     CreateCryptoKeyRequest request =
1749         CreateCryptoKeyRequest.newBuilder()
1750             .setParent(parent == null ? null : parent.toString())
1751             .setCryptoKeyId(cryptoKeyId)
1752             .setCryptoKey(cryptoKey)
1753             .build();
1754     return createCryptoKey(request);
1755   }
1756 
1757   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1758   /**
1759    * Create a new [CryptoKey][google.cloud.kms.v1.CryptoKey] within a
1760    * [KeyRing][google.cloud.kms.v1.KeyRing].
1761    *
1762    * <p>[CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] and
1763    * [CryptoKey.version_template.algorithm][google.cloud.kms.v1.CryptoKeyVersionTemplate.algorithm]
1764    * are required.
1765    *
1766    * <p>Sample code:
1767    *
1768    * <pre>{@code
1769    * // This snippet has been automatically generated and should be regarded as a code template only.
1770    * // It will require modifications to work:
1771    * // - It may require correct/in-range values for request initialization.
1772    * // - It may require specifying regional endpoints when creating the service client as shown in
1773    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1774    * try (KeyManagementServiceClient keyManagementServiceClient =
1775    *     KeyManagementServiceClient.create()) {
1776    *   String parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString();
1777    *   String cryptoKeyId = "cryptoKeyId-1643185255";
1778    *   CryptoKey cryptoKey = CryptoKey.newBuilder().build();
1779    *   CryptoKey response =
1780    *       keyManagementServiceClient.createCryptoKey(parent, cryptoKeyId, cryptoKey);
1781    * }
1782    * }</pre>
1783    *
1784    * @param parent Required. The [name][google.cloud.kms.v1.KeyRing.name] of the KeyRing associated
1785    *     with the [CryptoKeys][google.cloud.kms.v1.CryptoKey].
1786    * @param cryptoKeyId Required. It must be unique within a KeyRing and match the regular
1787    *     expression `[a-zA-Z0-9_-]{1,63}`
1788    * @param cryptoKey Required. A [CryptoKey][google.cloud.kms.v1.CryptoKey] with initial field
1789    *     values.
1790    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1791    */
createCryptoKey(String parent, String cryptoKeyId, CryptoKey cryptoKey)1792   public final CryptoKey createCryptoKey(String parent, String cryptoKeyId, CryptoKey cryptoKey) {
1793     CreateCryptoKeyRequest request =
1794         CreateCryptoKeyRequest.newBuilder()
1795             .setParent(parent)
1796             .setCryptoKeyId(cryptoKeyId)
1797             .setCryptoKey(cryptoKey)
1798             .build();
1799     return createCryptoKey(request);
1800   }
1801 
1802   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1803   /**
1804    * Create a new [CryptoKey][google.cloud.kms.v1.CryptoKey] within a
1805    * [KeyRing][google.cloud.kms.v1.KeyRing].
1806    *
1807    * <p>[CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] and
1808    * [CryptoKey.version_template.algorithm][google.cloud.kms.v1.CryptoKeyVersionTemplate.algorithm]
1809    * are required.
1810    *
1811    * <p>Sample code:
1812    *
1813    * <pre>{@code
1814    * // This snippet has been automatically generated and should be regarded as a code template only.
1815    * // It will require modifications to work:
1816    * // - It may require correct/in-range values for request initialization.
1817    * // - It may require specifying regional endpoints when creating the service client as shown in
1818    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1819    * try (KeyManagementServiceClient keyManagementServiceClient =
1820    *     KeyManagementServiceClient.create()) {
1821    *   CreateCryptoKeyRequest request =
1822    *       CreateCryptoKeyRequest.newBuilder()
1823    *           .setParent(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString())
1824    *           .setCryptoKeyId("cryptoKeyId-1643185255")
1825    *           .setCryptoKey(CryptoKey.newBuilder().build())
1826    *           .setSkipInitialVersionCreation(true)
1827    *           .build();
1828    *   CryptoKey response = keyManagementServiceClient.createCryptoKey(request);
1829    * }
1830    * }</pre>
1831    *
1832    * @param request The request object containing all of the parameters for the API call.
1833    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1834    */
createCryptoKey(CreateCryptoKeyRequest request)1835   public final CryptoKey createCryptoKey(CreateCryptoKeyRequest request) {
1836     return createCryptoKeyCallable().call(request);
1837   }
1838 
1839   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1840   /**
1841    * Create a new [CryptoKey][google.cloud.kms.v1.CryptoKey] within a
1842    * [KeyRing][google.cloud.kms.v1.KeyRing].
1843    *
1844    * <p>[CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] and
1845    * [CryptoKey.version_template.algorithm][google.cloud.kms.v1.CryptoKeyVersionTemplate.algorithm]
1846    * are required.
1847    *
1848    * <p>Sample code:
1849    *
1850    * <pre>{@code
1851    * // This snippet has been automatically generated and should be regarded as a code template only.
1852    * // It will require modifications to work:
1853    * // - It may require correct/in-range values for request initialization.
1854    * // - It may require specifying regional endpoints when creating the service client as shown in
1855    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1856    * try (KeyManagementServiceClient keyManagementServiceClient =
1857    *     KeyManagementServiceClient.create()) {
1858    *   CreateCryptoKeyRequest request =
1859    *       CreateCryptoKeyRequest.newBuilder()
1860    *           .setParent(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString())
1861    *           .setCryptoKeyId("cryptoKeyId-1643185255")
1862    *           .setCryptoKey(CryptoKey.newBuilder().build())
1863    *           .setSkipInitialVersionCreation(true)
1864    *           .build();
1865    *   ApiFuture<CryptoKey> future =
1866    *       keyManagementServiceClient.createCryptoKeyCallable().futureCall(request);
1867    *   // Do something.
1868    *   CryptoKey response = future.get();
1869    * }
1870    * }</pre>
1871    */
createCryptoKeyCallable()1872   public final UnaryCallable<CreateCryptoKeyRequest, CryptoKey> createCryptoKeyCallable() {
1873     return stub.createCryptoKeyCallable();
1874   }
1875 
1876   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1877   /**
1878    * Create a new [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in a
1879    * [CryptoKey][google.cloud.kms.v1.CryptoKey].
1880    *
1881    * <p>The server will assign the next sequential id. If unset,
1882    * [state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to
1883    * [ENABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.ENABLED].
1884    *
1885    * <p>Sample code:
1886    *
1887    * <pre>{@code
1888    * // This snippet has been automatically generated and should be regarded as a code template only.
1889    * // It will require modifications to work:
1890    * // - It may require correct/in-range values for request initialization.
1891    * // - It may require specifying regional endpoints when creating the service client as shown in
1892    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1893    * try (KeyManagementServiceClient keyManagementServiceClient =
1894    *     KeyManagementServiceClient.create()) {
1895    *   CryptoKeyName parent =
1896    *       CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
1897    *   CryptoKeyVersion cryptoKeyVersion = CryptoKeyVersion.newBuilder().build();
1898    *   CryptoKeyVersion response =
1899    *       keyManagementServiceClient.createCryptoKeyVersion(parent, cryptoKeyVersion);
1900    * }
1901    * }</pre>
1902    *
1903    * @param parent Required. The [name][google.cloud.kms.v1.CryptoKey.name] of the
1904    *     [CryptoKey][google.cloud.kms.v1.CryptoKey] associated with the
1905    *     [CryptoKeyVersions][google.cloud.kms.v1.CryptoKeyVersion].
1906    * @param cryptoKeyVersion Required. A [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]
1907    *     with initial field values.
1908    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1909    */
createCryptoKeyVersion( CryptoKeyName parent, CryptoKeyVersion cryptoKeyVersion)1910   public final CryptoKeyVersion createCryptoKeyVersion(
1911       CryptoKeyName parent, CryptoKeyVersion cryptoKeyVersion) {
1912     CreateCryptoKeyVersionRequest request =
1913         CreateCryptoKeyVersionRequest.newBuilder()
1914             .setParent(parent == null ? null : parent.toString())
1915             .setCryptoKeyVersion(cryptoKeyVersion)
1916             .build();
1917     return createCryptoKeyVersion(request);
1918   }
1919 
1920   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1921   /**
1922    * Create a new [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in a
1923    * [CryptoKey][google.cloud.kms.v1.CryptoKey].
1924    *
1925    * <p>The server will assign the next sequential id. If unset,
1926    * [state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to
1927    * [ENABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.ENABLED].
1928    *
1929    * <p>Sample code:
1930    *
1931    * <pre>{@code
1932    * // This snippet has been automatically generated and should be regarded as a code template only.
1933    * // It will require modifications to work:
1934    * // - It may require correct/in-range values for request initialization.
1935    * // - It may require specifying regional endpoints when creating the service client as shown in
1936    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1937    * try (KeyManagementServiceClient keyManagementServiceClient =
1938    *     KeyManagementServiceClient.create()) {
1939    *   String parent =
1940    *       CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString();
1941    *   CryptoKeyVersion cryptoKeyVersion = CryptoKeyVersion.newBuilder().build();
1942    *   CryptoKeyVersion response =
1943    *       keyManagementServiceClient.createCryptoKeyVersion(parent, cryptoKeyVersion);
1944    * }
1945    * }</pre>
1946    *
1947    * @param parent Required. The [name][google.cloud.kms.v1.CryptoKey.name] of the
1948    *     [CryptoKey][google.cloud.kms.v1.CryptoKey] associated with the
1949    *     [CryptoKeyVersions][google.cloud.kms.v1.CryptoKeyVersion].
1950    * @param cryptoKeyVersion Required. A [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]
1951    *     with initial field values.
1952    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1953    */
createCryptoKeyVersion( String parent, CryptoKeyVersion cryptoKeyVersion)1954   public final CryptoKeyVersion createCryptoKeyVersion(
1955       String parent, CryptoKeyVersion cryptoKeyVersion) {
1956     CreateCryptoKeyVersionRequest request =
1957         CreateCryptoKeyVersionRequest.newBuilder()
1958             .setParent(parent)
1959             .setCryptoKeyVersion(cryptoKeyVersion)
1960             .build();
1961     return createCryptoKeyVersion(request);
1962   }
1963 
1964   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1965   /**
1966    * Create a new [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in a
1967    * [CryptoKey][google.cloud.kms.v1.CryptoKey].
1968    *
1969    * <p>The server will assign the next sequential id. If unset,
1970    * [state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to
1971    * [ENABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.ENABLED].
1972    *
1973    * <p>Sample code:
1974    *
1975    * <pre>{@code
1976    * // This snippet has been automatically generated and should be regarded as a code template only.
1977    * // It will require modifications to work:
1978    * // - It may require correct/in-range values for request initialization.
1979    * // - It may require specifying regional endpoints when creating the service client as shown in
1980    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1981    * try (KeyManagementServiceClient keyManagementServiceClient =
1982    *     KeyManagementServiceClient.create()) {
1983    *   CreateCryptoKeyVersionRequest request =
1984    *       CreateCryptoKeyVersionRequest.newBuilder()
1985    *           .setParent(
1986    *               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
1987    *                   .toString())
1988    *           .setCryptoKeyVersion(CryptoKeyVersion.newBuilder().build())
1989    *           .build();
1990    *   CryptoKeyVersion response = keyManagementServiceClient.createCryptoKeyVersion(request);
1991    * }
1992    * }</pre>
1993    *
1994    * @param request The request object containing all of the parameters for the API call.
1995    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1996    */
createCryptoKeyVersion(CreateCryptoKeyVersionRequest request)1997   public final CryptoKeyVersion createCryptoKeyVersion(CreateCryptoKeyVersionRequest request) {
1998     return createCryptoKeyVersionCallable().call(request);
1999   }
2000 
2001   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2002   /**
2003    * Create a new [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in a
2004    * [CryptoKey][google.cloud.kms.v1.CryptoKey].
2005    *
2006    * <p>The server will assign the next sequential id. If unset,
2007    * [state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to
2008    * [ENABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.ENABLED].
2009    *
2010    * <p>Sample code:
2011    *
2012    * <pre>{@code
2013    * // This snippet has been automatically generated and should be regarded as a code template only.
2014    * // It will require modifications to work:
2015    * // - It may require correct/in-range values for request initialization.
2016    * // - It may require specifying regional endpoints when creating the service client as shown in
2017    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2018    * try (KeyManagementServiceClient keyManagementServiceClient =
2019    *     KeyManagementServiceClient.create()) {
2020    *   CreateCryptoKeyVersionRequest request =
2021    *       CreateCryptoKeyVersionRequest.newBuilder()
2022    *           .setParent(
2023    *               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
2024    *                   .toString())
2025    *           .setCryptoKeyVersion(CryptoKeyVersion.newBuilder().build())
2026    *           .build();
2027    *   ApiFuture<CryptoKeyVersion> future =
2028    *       keyManagementServiceClient.createCryptoKeyVersionCallable().futureCall(request);
2029    *   // Do something.
2030    *   CryptoKeyVersion response = future.get();
2031    * }
2032    * }</pre>
2033    */
2034   public final UnaryCallable<CreateCryptoKeyVersionRequest, CryptoKeyVersion>
createCryptoKeyVersionCallable()2035       createCryptoKeyVersionCallable() {
2036     return stub.createCryptoKeyVersionCallable();
2037   }
2038 
2039   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2040   /**
2041    * Import wrapped key material into a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].
2042    *
2043    * <p>All requests must specify a [CryptoKey][google.cloud.kms.v1.CryptoKey]. If a
2044    * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] is additionally specified in the
2045    * request, key material will be reimported into that version. Otherwise, a new version will be
2046    * created, and will be assigned the next sequential id within the
2047    * [CryptoKey][google.cloud.kms.v1.CryptoKey].
2048    *
2049    * <p>Sample code:
2050    *
2051    * <pre>{@code
2052    * // This snippet has been automatically generated and should be regarded as a code template only.
2053    * // It will require modifications to work:
2054    * // - It may require correct/in-range values for request initialization.
2055    * // - It may require specifying regional endpoints when creating the service client as shown in
2056    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2057    * try (KeyManagementServiceClient keyManagementServiceClient =
2058    *     KeyManagementServiceClient.create()) {
2059    *   ImportCryptoKeyVersionRequest request =
2060    *       ImportCryptoKeyVersionRequest.newBuilder()
2061    *           .setParent(
2062    *               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
2063    *                   .toString())
2064    *           .setCryptoKeyVersion(
2065    *               CryptoKeyVersionName.of(
2066    *                       "[PROJECT]",
2067    *                       "[LOCATION]",
2068    *                       "[KEY_RING]",
2069    *                       "[CRYPTO_KEY]",
2070    *                       "[CRYPTO_KEY_VERSION]")
2071    *                   .toString())
2072    *           .setImportJob("importJob-208547368")
2073    *           .setWrappedKey(ByteString.EMPTY)
2074    *           .build();
2075    *   CryptoKeyVersion response = keyManagementServiceClient.importCryptoKeyVersion(request);
2076    * }
2077    * }</pre>
2078    *
2079    * @param request The request object containing all of the parameters for the API call.
2080    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2081    */
importCryptoKeyVersion(ImportCryptoKeyVersionRequest request)2082   public final CryptoKeyVersion importCryptoKeyVersion(ImportCryptoKeyVersionRequest request) {
2083     return importCryptoKeyVersionCallable().call(request);
2084   }
2085 
2086   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2087   /**
2088    * Import wrapped key material into a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].
2089    *
2090    * <p>All requests must specify a [CryptoKey][google.cloud.kms.v1.CryptoKey]. If a
2091    * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] is additionally specified in the
2092    * request, key material will be reimported into that version. Otherwise, a new version will be
2093    * created, and will be assigned the next sequential id within the
2094    * [CryptoKey][google.cloud.kms.v1.CryptoKey].
2095    *
2096    * <p>Sample code:
2097    *
2098    * <pre>{@code
2099    * // This snippet has been automatically generated and should be regarded as a code template only.
2100    * // It will require modifications to work:
2101    * // - It may require correct/in-range values for request initialization.
2102    * // - It may require specifying regional endpoints when creating the service client as shown in
2103    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2104    * try (KeyManagementServiceClient keyManagementServiceClient =
2105    *     KeyManagementServiceClient.create()) {
2106    *   ImportCryptoKeyVersionRequest request =
2107    *       ImportCryptoKeyVersionRequest.newBuilder()
2108    *           .setParent(
2109    *               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
2110    *                   .toString())
2111    *           .setCryptoKeyVersion(
2112    *               CryptoKeyVersionName.of(
2113    *                       "[PROJECT]",
2114    *                       "[LOCATION]",
2115    *                       "[KEY_RING]",
2116    *                       "[CRYPTO_KEY]",
2117    *                       "[CRYPTO_KEY_VERSION]")
2118    *                   .toString())
2119    *           .setImportJob("importJob-208547368")
2120    *           .setWrappedKey(ByteString.EMPTY)
2121    *           .build();
2122    *   ApiFuture<CryptoKeyVersion> future =
2123    *       keyManagementServiceClient.importCryptoKeyVersionCallable().futureCall(request);
2124    *   // Do something.
2125    *   CryptoKeyVersion response = future.get();
2126    * }
2127    * }</pre>
2128    */
2129   public final UnaryCallable<ImportCryptoKeyVersionRequest, CryptoKeyVersion>
importCryptoKeyVersionCallable()2130       importCryptoKeyVersionCallable() {
2131     return stub.importCryptoKeyVersionCallable();
2132   }
2133 
2134   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2135   /**
2136    * Create a new [ImportJob][google.cloud.kms.v1.ImportJob] within a
2137    * [KeyRing][google.cloud.kms.v1.KeyRing].
2138    *
2139    * <p>[ImportJob.import_method][google.cloud.kms.v1.ImportJob.import_method] is required.
2140    *
2141    * <p>Sample code:
2142    *
2143    * <pre>{@code
2144    * // This snippet has been automatically generated and should be regarded as a code template only.
2145    * // It will require modifications to work:
2146    * // - It may require correct/in-range values for request initialization.
2147    * // - It may require specifying regional endpoints when creating the service client as shown in
2148    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2149    * try (KeyManagementServiceClient keyManagementServiceClient =
2150    *     KeyManagementServiceClient.create()) {
2151    *   KeyRingName parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
2152    *   String importJobId = "importJobId1449444627";
2153    *   ImportJob importJob = ImportJob.newBuilder().build();
2154    *   ImportJob response =
2155    *       keyManagementServiceClient.createImportJob(parent, importJobId, importJob);
2156    * }
2157    * }</pre>
2158    *
2159    * @param parent Required. The [name][google.cloud.kms.v1.KeyRing.name] of the
2160    *     [KeyRing][google.cloud.kms.v1.KeyRing] associated with the
2161    *     [ImportJobs][google.cloud.kms.v1.ImportJob].
2162    * @param importJobId Required. It must be unique within a KeyRing and match the regular
2163    *     expression `[a-zA-Z0-9_-]{1,63}`
2164    * @param importJob Required. An [ImportJob][google.cloud.kms.v1.ImportJob] with initial field
2165    *     values.
2166    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2167    */
createImportJob( KeyRingName parent, String importJobId, ImportJob importJob)2168   public final ImportJob createImportJob(
2169       KeyRingName parent, String importJobId, ImportJob importJob) {
2170     CreateImportJobRequest request =
2171         CreateImportJobRequest.newBuilder()
2172             .setParent(parent == null ? null : parent.toString())
2173             .setImportJobId(importJobId)
2174             .setImportJob(importJob)
2175             .build();
2176     return createImportJob(request);
2177   }
2178 
2179   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2180   /**
2181    * Create a new [ImportJob][google.cloud.kms.v1.ImportJob] within a
2182    * [KeyRing][google.cloud.kms.v1.KeyRing].
2183    *
2184    * <p>[ImportJob.import_method][google.cloud.kms.v1.ImportJob.import_method] is required.
2185    *
2186    * <p>Sample code:
2187    *
2188    * <pre>{@code
2189    * // This snippet has been automatically generated and should be regarded as a code template only.
2190    * // It will require modifications to work:
2191    * // - It may require correct/in-range values for request initialization.
2192    * // - It may require specifying regional endpoints when creating the service client as shown in
2193    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2194    * try (KeyManagementServiceClient keyManagementServiceClient =
2195    *     KeyManagementServiceClient.create()) {
2196    *   String parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString();
2197    *   String importJobId = "importJobId1449444627";
2198    *   ImportJob importJob = ImportJob.newBuilder().build();
2199    *   ImportJob response =
2200    *       keyManagementServiceClient.createImportJob(parent, importJobId, importJob);
2201    * }
2202    * }</pre>
2203    *
2204    * @param parent Required. The [name][google.cloud.kms.v1.KeyRing.name] of the
2205    *     [KeyRing][google.cloud.kms.v1.KeyRing] associated with the
2206    *     [ImportJobs][google.cloud.kms.v1.ImportJob].
2207    * @param importJobId Required. It must be unique within a KeyRing and match the regular
2208    *     expression `[a-zA-Z0-9_-]{1,63}`
2209    * @param importJob Required. An [ImportJob][google.cloud.kms.v1.ImportJob] with initial field
2210    *     values.
2211    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2212    */
createImportJob(String parent, String importJobId, ImportJob importJob)2213   public final ImportJob createImportJob(String parent, String importJobId, ImportJob importJob) {
2214     CreateImportJobRequest request =
2215         CreateImportJobRequest.newBuilder()
2216             .setParent(parent)
2217             .setImportJobId(importJobId)
2218             .setImportJob(importJob)
2219             .build();
2220     return createImportJob(request);
2221   }
2222 
2223   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2224   /**
2225    * Create a new [ImportJob][google.cloud.kms.v1.ImportJob] within a
2226    * [KeyRing][google.cloud.kms.v1.KeyRing].
2227    *
2228    * <p>[ImportJob.import_method][google.cloud.kms.v1.ImportJob.import_method] is required.
2229    *
2230    * <p>Sample code:
2231    *
2232    * <pre>{@code
2233    * // This snippet has been automatically generated and should be regarded as a code template only.
2234    * // It will require modifications to work:
2235    * // - It may require correct/in-range values for request initialization.
2236    * // - It may require specifying regional endpoints when creating the service client as shown in
2237    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2238    * try (KeyManagementServiceClient keyManagementServiceClient =
2239    *     KeyManagementServiceClient.create()) {
2240    *   CreateImportJobRequest request =
2241    *       CreateImportJobRequest.newBuilder()
2242    *           .setParent(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString())
2243    *           .setImportJobId("importJobId1449444627")
2244    *           .setImportJob(ImportJob.newBuilder().build())
2245    *           .build();
2246    *   ImportJob response = keyManagementServiceClient.createImportJob(request);
2247    * }
2248    * }</pre>
2249    *
2250    * @param request The request object containing all of the parameters for the API call.
2251    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2252    */
createImportJob(CreateImportJobRequest request)2253   public final ImportJob createImportJob(CreateImportJobRequest request) {
2254     return createImportJobCallable().call(request);
2255   }
2256 
2257   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2258   /**
2259    * Create a new [ImportJob][google.cloud.kms.v1.ImportJob] within a
2260    * [KeyRing][google.cloud.kms.v1.KeyRing].
2261    *
2262    * <p>[ImportJob.import_method][google.cloud.kms.v1.ImportJob.import_method] is required.
2263    *
2264    * <p>Sample code:
2265    *
2266    * <pre>{@code
2267    * // This snippet has been automatically generated and should be regarded as a code template only.
2268    * // It will require modifications to work:
2269    * // - It may require correct/in-range values for request initialization.
2270    * // - It may require specifying regional endpoints when creating the service client as shown in
2271    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2272    * try (KeyManagementServiceClient keyManagementServiceClient =
2273    *     KeyManagementServiceClient.create()) {
2274    *   CreateImportJobRequest request =
2275    *       CreateImportJobRequest.newBuilder()
2276    *           .setParent(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString())
2277    *           .setImportJobId("importJobId1449444627")
2278    *           .setImportJob(ImportJob.newBuilder().build())
2279    *           .build();
2280    *   ApiFuture<ImportJob> future =
2281    *       keyManagementServiceClient.createImportJobCallable().futureCall(request);
2282    *   // Do something.
2283    *   ImportJob response = future.get();
2284    * }
2285    * }</pre>
2286    */
createImportJobCallable()2287   public final UnaryCallable<CreateImportJobRequest, ImportJob> createImportJobCallable() {
2288     return stub.createImportJobCallable();
2289   }
2290 
2291   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2292   /**
2293    * Update a [CryptoKey][google.cloud.kms.v1.CryptoKey].
2294    *
2295    * <p>Sample code:
2296    *
2297    * <pre>{@code
2298    * // This snippet has been automatically generated and should be regarded as a code template only.
2299    * // It will require modifications to work:
2300    * // - It may require correct/in-range values for request initialization.
2301    * // - It may require specifying regional endpoints when creating the service client as shown in
2302    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2303    * try (KeyManagementServiceClient keyManagementServiceClient =
2304    *     KeyManagementServiceClient.create()) {
2305    *   CryptoKey cryptoKey = CryptoKey.newBuilder().build();
2306    *   FieldMask updateMask = FieldMask.newBuilder().build();
2307    *   CryptoKey response = keyManagementServiceClient.updateCryptoKey(cryptoKey, updateMask);
2308    * }
2309    * }</pre>
2310    *
2311    * @param cryptoKey Required. [CryptoKey][google.cloud.kms.v1.CryptoKey] with updated values.
2312    * @param updateMask Required. List of fields to be updated in this request.
2313    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2314    */
updateCryptoKey(CryptoKey cryptoKey, FieldMask updateMask)2315   public final CryptoKey updateCryptoKey(CryptoKey cryptoKey, FieldMask updateMask) {
2316     UpdateCryptoKeyRequest request =
2317         UpdateCryptoKeyRequest.newBuilder()
2318             .setCryptoKey(cryptoKey)
2319             .setUpdateMask(updateMask)
2320             .build();
2321     return updateCryptoKey(request);
2322   }
2323 
2324   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2325   /**
2326    * Update a [CryptoKey][google.cloud.kms.v1.CryptoKey].
2327    *
2328    * <p>Sample code:
2329    *
2330    * <pre>{@code
2331    * // This snippet has been automatically generated and should be regarded as a code template only.
2332    * // It will require modifications to work:
2333    * // - It may require correct/in-range values for request initialization.
2334    * // - It may require specifying regional endpoints when creating the service client as shown in
2335    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2336    * try (KeyManagementServiceClient keyManagementServiceClient =
2337    *     KeyManagementServiceClient.create()) {
2338    *   UpdateCryptoKeyRequest request =
2339    *       UpdateCryptoKeyRequest.newBuilder()
2340    *           .setCryptoKey(CryptoKey.newBuilder().build())
2341    *           .setUpdateMask(FieldMask.newBuilder().build())
2342    *           .build();
2343    *   CryptoKey response = keyManagementServiceClient.updateCryptoKey(request);
2344    * }
2345    * }</pre>
2346    *
2347    * @param request The request object containing all of the parameters for the API call.
2348    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2349    */
updateCryptoKey(UpdateCryptoKeyRequest request)2350   public final CryptoKey updateCryptoKey(UpdateCryptoKeyRequest request) {
2351     return updateCryptoKeyCallable().call(request);
2352   }
2353 
2354   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2355   /**
2356    * Update a [CryptoKey][google.cloud.kms.v1.CryptoKey].
2357    *
2358    * <p>Sample code:
2359    *
2360    * <pre>{@code
2361    * // This snippet has been automatically generated and should be regarded as a code template only.
2362    * // It will require modifications to work:
2363    * // - It may require correct/in-range values for request initialization.
2364    * // - It may require specifying regional endpoints when creating the service client as shown in
2365    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2366    * try (KeyManagementServiceClient keyManagementServiceClient =
2367    *     KeyManagementServiceClient.create()) {
2368    *   UpdateCryptoKeyRequest request =
2369    *       UpdateCryptoKeyRequest.newBuilder()
2370    *           .setCryptoKey(CryptoKey.newBuilder().build())
2371    *           .setUpdateMask(FieldMask.newBuilder().build())
2372    *           .build();
2373    *   ApiFuture<CryptoKey> future =
2374    *       keyManagementServiceClient.updateCryptoKeyCallable().futureCall(request);
2375    *   // Do something.
2376    *   CryptoKey response = future.get();
2377    * }
2378    * }</pre>
2379    */
updateCryptoKeyCallable()2380   public final UnaryCallable<UpdateCryptoKeyRequest, CryptoKey> updateCryptoKeyCallable() {
2381     return stub.updateCryptoKeyCallable();
2382   }
2383 
2384   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2385   /**
2386    * Update a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]'s metadata.
2387    *
2388    * <p>[state][google.cloud.kms.v1.CryptoKeyVersion.state] may be changed between
2389    * [ENABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.ENABLED] and
2390    * [DISABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED] using this
2391    * method. See
2392    * [DestroyCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.DestroyCryptoKeyVersion] and
2393    * [RestoreCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.RestoreCryptoKeyVersion] to
2394    * move between other states.
2395    *
2396    * <p>Sample code:
2397    *
2398    * <pre>{@code
2399    * // This snippet has been automatically generated and should be regarded as a code template only.
2400    * // It will require modifications to work:
2401    * // - It may require correct/in-range values for request initialization.
2402    * // - It may require specifying regional endpoints when creating the service client as shown in
2403    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2404    * try (KeyManagementServiceClient keyManagementServiceClient =
2405    *     KeyManagementServiceClient.create()) {
2406    *   CryptoKeyVersion cryptoKeyVersion = CryptoKeyVersion.newBuilder().build();
2407    *   FieldMask updateMask = FieldMask.newBuilder().build();
2408    *   CryptoKeyVersion response =
2409    *       keyManagementServiceClient.updateCryptoKeyVersion(cryptoKeyVersion, updateMask);
2410    * }
2411    * }</pre>
2412    *
2413    * @param cryptoKeyVersion Required. [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with
2414    *     updated values.
2415    * @param updateMask Required. List of fields to be updated in this request.
2416    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2417    */
updateCryptoKeyVersion( CryptoKeyVersion cryptoKeyVersion, FieldMask updateMask)2418   public final CryptoKeyVersion updateCryptoKeyVersion(
2419       CryptoKeyVersion cryptoKeyVersion, FieldMask updateMask) {
2420     UpdateCryptoKeyVersionRequest request =
2421         UpdateCryptoKeyVersionRequest.newBuilder()
2422             .setCryptoKeyVersion(cryptoKeyVersion)
2423             .setUpdateMask(updateMask)
2424             .build();
2425     return updateCryptoKeyVersion(request);
2426   }
2427 
2428   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2429   /**
2430    * Update a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]'s metadata.
2431    *
2432    * <p>[state][google.cloud.kms.v1.CryptoKeyVersion.state] may be changed between
2433    * [ENABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.ENABLED] and
2434    * [DISABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED] using this
2435    * method. See
2436    * [DestroyCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.DestroyCryptoKeyVersion] and
2437    * [RestoreCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.RestoreCryptoKeyVersion] to
2438    * move between other states.
2439    *
2440    * <p>Sample code:
2441    *
2442    * <pre>{@code
2443    * // This snippet has been automatically generated and should be regarded as a code template only.
2444    * // It will require modifications to work:
2445    * // - It may require correct/in-range values for request initialization.
2446    * // - It may require specifying regional endpoints when creating the service client as shown in
2447    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2448    * try (KeyManagementServiceClient keyManagementServiceClient =
2449    *     KeyManagementServiceClient.create()) {
2450    *   UpdateCryptoKeyVersionRequest request =
2451    *       UpdateCryptoKeyVersionRequest.newBuilder()
2452    *           .setCryptoKeyVersion(CryptoKeyVersion.newBuilder().build())
2453    *           .setUpdateMask(FieldMask.newBuilder().build())
2454    *           .build();
2455    *   CryptoKeyVersion response = keyManagementServiceClient.updateCryptoKeyVersion(request);
2456    * }
2457    * }</pre>
2458    *
2459    * @param request The request object containing all of the parameters for the API call.
2460    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2461    */
updateCryptoKeyVersion(UpdateCryptoKeyVersionRequest request)2462   public final CryptoKeyVersion updateCryptoKeyVersion(UpdateCryptoKeyVersionRequest request) {
2463     return updateCryptoKeyVersionCallable().call(request);
2464   }
2465 
2466   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2467   /**
2468    * Update a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]'s metadata.
2469    *
2470    * <p>[state][google.cloud.kms.v1.CryptoKeyVersion.state] may be changed between
2471    * [ENABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.ENABLED] and
2472    * [DISABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED] using this
2473    * method. See
2474    * [DestroyCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.DestroyCryptoKeyVersion] and
2475    * [RestoreCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.RestoreCryptoKeyVersion] to
2476    * move between other states.
2477    *
2478    * <p>Sample code:
2479    *
2480    * <pre>{@code
2481    * // This snippet has been automatically generated and should be regarded as a code template only.
2482    * // It will require modifications to work:
2483    * // - It may require correct/in-range values for request initialization.
2484    * // - It may require specifying regional endpoints when creating the service client as shown in
2485    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2486    * try (KeyManagementServiceClient keyManagementServiceClient =
2487    *     KeyManagementServiceClient.create()) {
2488    *   UpdateCryptoKeyVersionRequest request =
2489    *       UpdateCryptoKeyVersionRequest.newBuilder()
2490    *           .setCryptoKeyVersion(CryptoKeyVersion.newBuilder().build())
2491    *           .setUpdateMask(FieldMask.newBuilder().build())
2492    *           .build();
2493    *   ApiFuture<CryptoKeyVersion> future =
2494    *       keyManagementServiceClient.updateCryptoKeyVersionCallable().futureCall(request);
2495    *   // Do something.
2496    *   CryptoKeyVersion response = future.get();
2497    * }
2498    * }</pre>
2499    */
2500   public final UnaryCallable<UpdateCryptoKeyVersionRequest, CryptoKeyVersion>
updateCryptoKeyVersionCallable()2501       updateCryptoKeyVersionCallable() {
2502     return stub.updateCryptoKeyVersionCallable();
2503   }
2504 
2505   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2506   /**
2507    * Update the version of a [CryptoKey][google.cloud.kms.v1.CryptoKey] that will be used in
2508    * [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt].
2509    *
2510    * <p>Returns an error if called on a key whose purpose is not
2511    * [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT].
2512    *
2513    * <p>Sample code:
2514    *
2515    * <pre>{@code
2516    * // This snippet has been automatically generated and should be regarded as a code template only.
2517    * // It will require modifications to work:
2518    * // - It may require correct/in-range values for request initialization.
2519    * // - It may require specifying regional endpoints when creating the service client as shown in
2520    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2521    * try (KeyManagementServiceClient keyManagementServiceClient =
2522    *     KeyManagementServiceClient.create()) {
2523    *   CryptoKeyName name =
2524    *       CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
2525    *   String cryptoKeyVersionId = "cryptoKeyVersionId987674581";
2526    *   CryptoKey response =
2527    *       keyManagementServiceClient.updateCryptoKeyPrimaryVersion(name, cryptoKeyVersionId);
2528    * }
2529    * }</pre>
2530    *
2531    * @param name Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] to
2532    *     update.
2533    * @param cryptoKeyVersionId Required. The id of the child
2534    *     [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use as primary.
2535    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2536    */
updateCryptoKeyPrimaryVersion( CryptoKeyName name, String cryptoKeyVersionId)2537   public final CryptoKey updateCryptoKeyPrimaryVersion(
2538       CryptoKeyName name, String cryptoKeyVersionId) {
2539     UpdateCryptoKeyPrimaryVersionRequest request =
2540         UpdateCryptoKeyPrimaryVersionRequest.newBuilder()
2541             .setName(name == null ? null : name.toString())
2542             .setCryptoKeyVersionId(cryptoKeyVersionId)
2543             .build();
2544     return updateCryptoKeyPrimaryVersion(request);
2545   }
2546 
2547   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2548   /**
2549    * Update the version of a [CryptoKey][google.cloud.kms.v1.CryptoKey] that will be used in
2550    * [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt].
2551    *
2552    * <p>Returns an error if called on a key whose purpose is not
2553    * [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT].
2554    *
2555    * <p>Sample code:
2556    *
2557    * <pre>{@code
2558    * // This snippet has been automatically generated and should be regarded as a code template only.
2559    * // It will require modifications to work:
2560    * // - It may require correct/in-range values for request initialization.
2561    * // - It may require specifying regional endpoints when creating the service client as shown in
2562    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2563    * try (KeyManagementServiceClient keyManagementServiceClient =
2564    *     KeyManagementServiceClient.create()) {
2565    *   String name =
2566    *       CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString();
2567    *   String cryptoKeyVersionId = "cryptoKeyVersionId987674581";
2568    *   CryptoKey response =
2569    *       keyManagementServiceClient.updateCryptoKeyPrimaryVersion(name, cryptoKeyVersionId);
2570    * }
2571    * }</pre>
2572    *
2573    * @param name Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] to
2574    *     update.
2575    * @param cryptoKeyVersionId Required. The id of the child
2576    *     [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use as primary.
2577    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2578    */
updateCryptoKeyPrimaryVersion(String name, String cryptoKeyVersionId)2579   public final CryptoKey updateCryptoKeyPrimaryVersion(String name, String cryptoKeyVersionId) {
2580     UpdateCryptoKeyPrimaryVersionRequest request =
2581         UpdateCryptoKeyPrimaryVersionRequest.newBuilder()
2582             .setName(name)
2583             .setCryptoKeyVersionId(cryptoKeyVersionId)
2584             .build();
2585     return updateCryptoKeyPrimaryVersion(request);
2586   }
2587 
2588   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2589   /**
2590    * Update the version of a [CryptoKey][google.cloud.kms.v1.CryptoKey] that will be used in
2591    * [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt].
2592    *
2593    * <p>Returns an error if called on a key whose purpose is not
2594    * [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT].
2595    *
2596    * <p>Sample code:
2597    *
2598    * <pre>{@code
2599    * // This snippet has been automatically generated and should be regarded as a code template only.
2600    * // It will require modifications to work:
2601    * // - It may require correct/in-range values for request initialization.
2602    * // - It may require specifying regional endpoints when creating the service client as shown in
2603    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2604    * try (KeyManagementServiceClient keyManagementServiceClient =
2605    *     KeyManagementServiceClient.create()) {
2606    *   UpdateCryptoKeyPrimaryVersionRequest request =
2607    *       UpdateCryptoKeyPrimaryVersionRequest.newBuilder()
2608    *           .setName(
2609    *               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
2610    *                   .toString())
2611    *           .setCryptoKeyVersionId("cryptoKeyVersionId987674581")
2612    *           .build();
2613    *   CryptoKey response = keyManagementServiceClient.updateCryptoKeyPrimaryVersion(request);
2614    * }
2615    * }</pre>
2616    *
2617    * @param request The request object containing all of the parameters for the API call.
2618    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2619    */
updateCryptoKeyPrimaryVersion( UpdateCryptoKeyPrimaryVersionRequest request)2620   public final CryptoKey updateCryptoKeyPrimaryVersion(
2621       UpdateCryptoKeyPrimaryVersionRequest request) {
2622     return updateCryptoKeyPrimaryVersionCallable().call(request);
2623   }
2624 
2625   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2626   /**
2627    * Update the version of a [CryptoKey][google.cloud.kms.v1.CryptoKey] that will be used in
2628    * [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt].
2629    *
2630    * <p>Returns an error if called on a key whose purpose is not
2631    * [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT].
2632    *
2633    * <p>Sample code:
2634    *
2635    * <pre>{@code
2636    * // This snippet has been automatically generated and should be regarded as a code template only.
2637    * // It will require modifications to work:
2638    * // - It may require correct/in-range values for request initialization.
2639    * // - It may require specifying regional endpoints when creating the service client as shown in
2640    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2641    * try (KeyManagementServiceClient keyManagementServiceClient =
2642    *     KeyManagementServiceClient.create()) {
2643    *   UpdateCryptoKeyPrimaryVersionRequest request =
2644    *       UpdateCryptoKeyPrimaryVersionRequest.newBuilder()
2645    *           .setName(
2646    *               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
2647    *                   .toString())
2648    *           .setCryptoKeyVersionId("cryptoKeyVersionId987674581")
2649    *           .build();
2650    *   ApiFuture<CryptoKey> future =
2651    *       keyManagementServiceClient.updateCryptoKeyPrimaryVersionCallable().futureCall(request);
2652    *   // Do something.
2653    *   CryptoKey response = future.get();
2654    * }
2655    * }</pre>
2656    */
2657   public final UnaryCallable<UpdateCryptoKeyPrimaryVersionRequest, CryptoKey>
updateCryptoKeyPrimaryVersionCallable()2658       updateCryptoKeyPrimaryVersionCallable() {
2659     return stub.updateCryptoKeyPrimaryVersionCallable();
2660   }
2661 
2662   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2663   /**
2664    * Schedule a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] for destruction.
2665    *
2666    * <p>Upon calling this method,
2667    * [CryptoKeyVersion.state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to
2668    * [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED],
2669    * and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will be set to the time
2670    * [destroy_scheduled_duration][google.cloud.kms.v1.CryptoKey.destroy_scheduled_duration] in the
2671    * future. At that time, the [state][google.cloud.kms.v1.CryptoKeyVersion.state] will
2672    * automatically change to
2673    * [DESTROYED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROYED], and the key
2674    * material will be irrevocably destroyed.
2675    *
2676    * <p>Before the [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] is reached,
2677    * [RestoreCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.RestoreCryptoKeyVersion] may
2678    * be called to reverse the process.
2679    *
2680    * <p>Sample code:
2681    *
2682    * <pre>{@code
2683    * // This snippet has been automatically generated and should be regarded as a code template only.
2684    * // It will require modifications to work:
2685    * // - It may require correct/in-range values for request initialization.
2686    * // - It may require specifying regional endpoints when creating the service client as shown in
2687    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2688    * try (KeyManagementServiceClient keyManagementServiceClient =
2689    *     KeyManagementServiceClient.create()) {
2690    *   CryptoKeyVersionName name =
2691    *       CryptoKeyVersionName.of(
2692    *           "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]");
2693    *   CryptoKeyVersion response = keyManagementServiceClient.destroyCryptoKeyVersion(name);
2694    * }
2695    * }</pre>
2696    *
2697    * @param name Required. The resource name of the
2698    *     [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to destroy.
2699    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2700    */
destroyCryptoKeyVersion(CryptoKeyVersionName name)2701   public final CryptoKeyVersion destroyCryptoKeyVersion(CryptoKeyVersionName name) {
2702     DestroyCryptoKeyVersionRequest request =
2703         DestroyCryptoKeyVersionRequest.newBuilder()
2704             .setName(name == null ? null : name.toString())
2705             .build();
2706     return destroyCryptoKeyVersion(request);
2707   }
2708 
2709   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2710   /**
2711    * Schedule a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] for destruction.
2712    *
2713    * <p>Upon calling this method,
2714    * [CryptoKeyVersion.state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to
2715    * [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED],
2716    * and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will be set to the time
2717    * [destroy_scheduled_duration][google.cloud.kms.v1.CryptoKey.destroy_scheduled_duration] in the
2718    * future. At that time, the [state][google.cloud.kms.v1.CryptoKeyVersion.state] will
2719    * automatically change to
2720    * [DESTROYED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROYED], and the key
2721    * material will be irrevocably destroyed.
2722    *
2723    * <p>Before the [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] is reached,
2724    * [RestoreCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.RestoreCryptoKeyVersion] may
2725    * be called to reverse the process.
2726    *
2727    * <p>Sample code:
2728    *
2729    * <pre>{@code
2730    * // This snippet has been automatically generated and should be regarded as a code template only.
2731    * // It will require modifications to work:
2732    * // - It may require correct/in-range values for request initialization.
2733    * // - It may require specifying regional endpoints when creating the service client as shown in
2734    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2735    * try (KeyManagementServiceClient keyManagementServiceClient =
2736    *     KeyManagementServiceClient.create()) {
2737    *   String name =
2738    *       CryptoKeyVersionName.of(
2739    *               "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]")
2740    *           .toString();
2741    *   CryptoKeyVersion response = keyManagementServiceClient.destroyCryptoKeyVersion(name);
2742    * }
2743    * }</pre>
2744    *
2745    * @param name Required. The resource name of the
2746    *     [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to destroy.
2747    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2748    */
destroyCryptoKeyVersion(String name)2749   public final CryptoKeyVersion destroyCryptoKeyVersion(String name) {
2750     DestroyCryptoKeyVersionRequest request =
2751         DestroyCryptoKeyVersionRequest.newBuilder().setName(name).build();
2752     return destroyCryptoKeyVersion(request);
2753   }
2754 
2755   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2756   /**
2757    * Schedule a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] for destruction.
2758    *
2759    * <p>Upon calling this method,
2760    * [CryptoKeyVersion.state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to
2761    * [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED],
2762    * and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will be set to the time
2763    * [destroy_scheduled_duration][google.cloud.kms.v1.CryptoKey.destroy_scheduled_duration] in the
2764    * future. At that time, the [state][google.cloud.kms.v1.CryptoKeyVersion.state] will
2765    * automatically change to
2766    * [DESTROYED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROYED], and the key
2767    * material will be irrevocably destroyed.
2768    *
2769    * <p>Before the [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] is reached,
2770    * [RestoreCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.RestoreCryptoKeyVersion] may
2771    * be called to reverse the process.
2772    *
2773    * <p>Sample code:
2774    *
2775    * <pre>{@code
2776    * // This snippet has been automatically generated and should be regarded as a code template only.
2777    * // It will require modifications to work:
2778    * // - It may require correct/in-range values for request initialization.
2779    * // - It may require specifying regional endpoints when creating the service client as shown in
2780    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2781    * try (KeyManagementServiceClient keyManagementServiceClient =
2782    *     KeyManagementServiceClient.create()) {
2783    *   DestroyCryptoKeyVersionRequest request =
2784    *       DestroyCryptoKeyVersionRequest.newBuilder()
2785    *           .setName(
2786    *               CryptoKeyVersionName.of(
2787    *                       "[PROJECT]",
2788    *                       "[LOCATION]",
2789    *                       "[KEY_RING]",
2790    *                       "[CRYPTO_KEY]",
2791    *                       "[CRYPTO_KEY_VERSION]")
2792    *                   .toString())
2793    *           .build();
2794    *   CryptoKeyVersion response = keyManagementServiceClient.destroyCryptoKeyVersion(request);
2795    * }
2796    * }</pre>
2797    *
2798    * @param request The request object containing all of the parameters for the API call.
2799    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2800    */
destroyCryptoKeyVersion(DestroyCryptoKeyVersionRequest request)2801   public final CryptoKeyVersion destroyCryptoKeyVersion(DestroyCryptoKeyVersionRequest request) {
2802     return destroyCryptoKeyVersionCallable().call(request);
2803   }
2804 
2805   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2806   /**
2807    * Schedule a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] for destruction.
2808    *
2809    * <p>Upon calling this method,
2810    * [CryptoKeyVersion.state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to
2811    * [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED],
2812    * and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will be set to the time
2813    * [destroy_scheduled_duration][google.cloud.kms.v1.CryptoKey.destroy_scheduled_duration] in the
2814    * future. At that time, the [state][google.cloud.kms.v1.CryptoKeyVersion.state] will
2815    * automatically change to
2816    * [DESTROYED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROYED], and the key
2817    * material will be irrevocably destroyed.
2818    *
2819    * <p>Before the [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] is reached,
2820    * [RestoreCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.RestoreCryptoKeyVersion] may
2821    * be called to reverse the process.
2822    *
2823    * <p>Sample code:
2824    *
2825    * <pre>{@code
2826    * // This snippet has been automatically generated and should be regarded as a code template only.
2827    * // It will require modifications to work:
2828    * // - It may require correct/in-range values for request initialization.
2829    * // - It may require specifying regional endpoints when creating the service client as shown in
2830    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2831    * try (KeyManagementServiceClient keyManagementServiceClient =
2832    *     KeyManagementServiceClient.create()) {
2833    *   DestroyCryptoKeyVersionRequest request =
2834    *       DestroyCryptoKeyVersionRequest.newBuilder()
2835    *           .setName(
2836    *               CryptoKeyVersionName.of(
2837    *                       "[PROJECT]",
2838    *                       "[LOCATION]",
2839    *                       "[KEY_RING]",
2840    *                       "[CRYPTO_KEY]",
2841    *                       "[CRYPTO_KEY_VERSION]")
2842    *                   .toString())
2843    *           .build();
2844    *   ApiFuture<CryptoKeyVersion> future =
2845    *       keyManagementServiceClient.destroyCryptoKeyVersionCallable().futureCall(request);
2846    *   // Do something.
2847    *   CryptoKeyVersion response = future.get();
2848    * }
2849    * }</pre>
2850    */
2851   public final UnaryCallable<DestroyCryptoKeyVersionRequest, CryptoKeyVersion>
destroyCryptoKeyVersionCallable()2852       destroyCryptoKeyVersionCallable() {
2853     return stub.destroyCryptoKeyVersionCallable();
2854   }
2855 
2856   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2857   /**
2858    * Restore a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in the
2859    * [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED]
2860    * state.
2861    *
2862    * <p>Upon restoration of the CryptoKeyVersion,
2863    * [state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to
2864    * [DISABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED], and
2865    * [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will be cleared.
2866    *
2867    * <p>Sample code:
2868    *
2869    * <pre>{@code
2870    * // This snippet has been automatically generated and should be regarded as a code template only.
2871    * // It will require modifications to work:
2872    * // - It may require correct/in-range values for request initialization.
2873    * // - It may require specifying regional endpoints when creating the service client as shown in
2874    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2875    * try (KeyManagementServiceClient keyManagementServiceClient =
2876    *     KeyManagementServiceClient.create()) {
2877    *   CryptoKeyVersionName name =
2878    *       CryptoKeyVersionName.of(
2879    *           "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]");
2880    *   CryptoKeyVersion response = keyManagementServiceClient.restoreCryptoKeyVersion(name);
2881    * }
2882    * }</pre>
2883    *
2884    * @param name Required. The resource name of the
2885    *     [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to restore.
2886    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2887    */
restoreCryptoKeyVersion(CryptoKeyVersionName name)2888   public final CryptoKeyVersion restoreCryptoKeyVersion(CryptoKeyVersionName name) {
2889     RestoreCryptoKeyVersionRequest request =
2890         RestoreCryptoKeyVersionRequest.newBuilder()
2891             .setName(name == null ? null : name.toString())
2892             .build();
2893     return restoreCryptoKeyVersion(request);
2894   }
2895 
2896   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2897   /**
2898    * Restore a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in the
2899    * [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED]
2900    * state.
2901    *
2902    * <p>Upon restoration of the CryptoKeyVersion,
2903    * [state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to
2904    * [DISABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED], and
2905    * [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will be cleared.
2906    *
2907    * <p>Sample code:
2908    *
2909    * <pre>{@code
2910    * // This snippet has been automatically generated and should be regarded as a code template only.
2911    * // It will require modifications to work:
2912    * // - It may require correct/in-range values for request initialization.
2913    * // - It may require specifying regional endpoints when creating the service client as shown in
2914    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2915    * try (KeyManagementServiceClient keyManagementServiceClient =
2916    *     KeyManagementServiceClient.create()) {
2917    *   String name =
2918    *       CryptoKeyVersionName.of(
2919    *               "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]")
2920    *           .toString();
2921    *   CryptoKeyVersion response = keyManagementServiceClient.restoreCryptoKeyVersion(name);
2922    * }
2923    * }</pre>
2924    *
2925    * @param name Required. The resource name of the
2926    *     [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to restore.
2927    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2928    */
restoreCryptoKeyVersion(String name)2929   public final CryptoKeyVersion restoreCryptoKeyVersion(String name) {
2930     RestoreCryptoKeyVersionRequest request =
2931         RestoreCryptoKeyVersionRequest.newBuilder().setName(name).build();
2932     return restoreCryptoKeyVersion(request);
2933   }
2934 
2935   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2936   /**
2937    * Restore a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in the
2938    * [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED]
2939    * state.
2940    *
2941    * <p>Upon restoration of the CryptoKeyVersion,
2942    * [state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to
2943    * [DISABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED], and
2944    * [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will be cleared.
2945    *
2946    * <p>Sample code:
2947    *
2948    * <pre>{@code
2949    * // This snippet has been automatically generated and should be regarded as a code template only.
2950    * // It will require modifications to work:
2951    * // - It may require correct/in-range values for request initialization.
2952    * // - It may require specifying regional endpoints when creating the service client as shown in
2953    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2954    * try (KeyManagementServiceClient keyManagementServiceClient =
2955    *     KeyManagementServiceClient.create()) {
2956    *   RestoreCryptoKeyVersionRequest request =
2957    *       RestoreCryptoKeyVersionRequest.newBuilder()
2958    *           .setName(
2959    *               CryptoKeyVersionName.of(
2960    *                       "[PROJECT]",
2961    *                       "[LOCATION]",
2962    *                       "[KEY_RING]",
2963    *                       "[CRYPTO_KEY]",
2964    *                       "[CRYPTO_KEY_VERSION]")
2965    *                   .toString())
2966    *           .build();
2967    *   CryptoKeyVersion response = keyManagementServiceClient.restoreCryptoKeyVersion(request);
2968    * }
2969    * }</pre>
2970    *
2971    * @param request The request object containing all of the parameters for the API call.
2972    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2973    */
restoreCryptoKeyVersion(RestoreCryptoKeyVersionRequest request)2974   public final CryptoKeyVersion restoreCryptoKeyVersion(RestoreCryptoKeyVersionRequest request) {
2975     return restoreCryptoKeyVersionCallable().call(request);
2976   }
2977 
2978   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2979   /**
2980    * Restore a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in the
2981    * [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED]
2982    * state.
2983    *
2984    * <p>Upon restoration of the CryptoKeyVersion,
2985    * [state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to
2986    * [DISABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED], and
2987    * [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will be cleared.
2988    *
2989    * <p>Sample code:
2990    *
2991    * <pre>{@code
2992    * // This snippet has been automatically generated and should be regarded as a code template only.
2993    * // It will require modifications to work:
2994    * // - It may require correct/in-range values for request initialization.
2995    * // - It may require specifying regional endpoints when creating the service client as shown in
2996    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2997    * try (KeyManagementServiceClient keyManagementServiceClient =
2998    *     KeyManagementServiceClient.create()) {
2999    *   RestoreCryptoKeyVersionRequest request =
3000    *       RestoreCryptoKeyVersionRequest.newBuilder()
3001    *           .setName(
3002    *               CryptoKeyVersionName.of(
3003    *                       "[PROJECT]",
3004    *                       "[LOCATION]",
3005    *                       "[KEY_RING]",
3006    *                       "[CRYPTO_KEY]",
3007    *                       "[CRYPTO_KEY_VERSION]")
3008    *                   .toString())
3009    *           .build();
3010    *   ApiFuture<CryptoKeyVersion> future =
3011    *       keyManagementServiceClient.restoreCryptoKeyVersionCallable().futureCall(request);
3012    *   // Do something.
3013    *   CryptoKeyVersion response = future.get();
3014    * }
3015    * }</pre>
3016    */
3017   public final UnaryCallable<RestoreCryptoKeyVersionRequest, CryptoKeyVersion>
restoreCryptoKeyVersionCallable()3018       restoreCryptoKeyVersionCallable() {
3019     return stub.restoreCryptoKeyVersionCallable();
3020   }
3021 
3022   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3023   /**
3024    * Encrypts data, so that it can only be recovered by a call to
3025    * [Decrypt][google.cloud.kms.v1.KeyManagementService.Decrypt]. The
3026    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be
3027    * [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT].
3028    *
3029    * <p>Sample code:
3030    *
3031    * <pre>{@code
3032    * // This snippet has been automatically generated and should be regarded as a code template only.
3033    * // It will require modifications to work:
3034    * // - It may require correct/in-range values for request initialization.
3035    * // - It may require specifying regional endpoints when creating the service client as shown in
3036    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3037    * try (KeyManagementServiceClient keyManagementServiceClient =
3038    *     KeyManagementServiceClient.create()) {
3039    *   ResourceName name = CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
3040    *   ByteString plaintext = ByteString.EMPTY;
3041    *   EncryptResponse response = keyManagementServiceClient.encrypt(name, plaintext);
3042    * }
3043    * }</pre>
3044    *
3045    * @param name Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] or
3046    *     [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for encryption.
3047    *     <p>If a [CryptoKey][google.cloud.kms.v1.CryptoKey] is specified, the server will use its
3048    *     [primary version][google.cloud.kms.v1.CryptoKey.primary].
3049    * @param plaintext Required. The data to encrypt. Must be no larger than 64KiB.
3050    *     <p>The maximum size depends on the key version's
3051    *     [protection_level][google.cloud.kms.v1.CryptoKeyVersionTemplate.protection_level]. For
3052    *     [SOFTWARE][google.cloud.kms.v1.ProtectionLevel.SOFTWARE],
3053    *     [EXTERNAL][google.cloud.kms.v1.ProtectionLevel.EXTERNAL], and
3054    *     [EXTERNAL_VPC][google.cloud.kms.v1.ProtectionLevel.EXTERNAL_VPC] keys, the plaintext must
3055    *     be no larger than 64KiB. For [HSM][google.cloud.kms.v1.ProtectionLevel.HSM] keys, the
3056    *     combined length of the plaintext and additional_authenticated_data fields must be no larger
3057    *     than 8KiB.
3058    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
3059    */
encrypt(ResourceName name, ByteString plaintext)3060   public final EncryptResponse encrypt(ResourceName name, ByteString plaintext) {
3061     EncryptRequest request =
3062         EncryptRequest.newBuilder()
3063             .setName(name == null ? null : name.toString())
3064             .setPlaintext(plaintext)
3065             .build();
3066     return encrypt(request);
3067   }
3068 
3069   // ADDED BY SYNTH
3070   /**
3071    * Encrypts data, so that it can only be recovered by a call to
3072    * [Decrypt][google.cloud.kms.v1.KeyManagementService.Decrypt]. The
3073    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be
3074    * [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT].
3075    *
3076    * <p>Sample code:
3077    *
3078    * <pre><code>
3079    * try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
3080    *   CryptoKeyPathName name = CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
3081    *   ByteString plaintext = ByteString.copyFromUtf8("");
3082    *   EncryptResponse response = keyManagementServiceClient.encrypt(name, plaintext);
3083    * }
3084    * </code></pre>
3085    *
3086    * @param name Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] or
3087    *     [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for encryption.
3088    *     <p>If a [CryptoKey][google.cloud.kms.v1.CryptoKey] is specified, the server will use its
3089    *     [primary version][google.cloud.kms.v1.CryptoKey.primary].
3090    * @param plaintext Required. The data to encrypt. Must be no larger than 64KiB.
3091    *     <p>The maximum size depends on the key version's
3092    *     [protection_level][google.cloud.kms.v1.CryptoKeyVersionTemplate.protection_level]. For
3093    *     [SOFTWARE][google.cloud.kms.v1.ProtectionLevel.SOFTWARE] keys, the plaintext must be no
3094    *     larger than 64KiB. For [HSM][google.cloud.kms.v1.ProtectionLevel.HSM] keys, the combined
3095    *     length of the plaintext and additional_authenticated_data fields must be no larger than
3096    *     8KiB.
3097    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
3098    */
encrypt(CryptoKeyPathName name, ByteString plaintext)3099   public final EncryptResponse encrypt(CryptoKeyPathName name, ByteString plaintext) {
3100     EncryptRequest request =
3101         EncryptRequest.newBuilder()
3102             .setName(name == null ? null : name.toString())
3103             .setPlaintext(plaintext)
3104             .build();
3105     return encrypt(request);
3106   }
3107 
3108   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3109   /**
3110    * Encrypts data, so that it can only be recovered by a call to
3111    * [Decrypt][google.cloud.kms.v1.KeyManagementService.Decrypt]. The
3112    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be
3113    * [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT].
3114    *
3115    * <p>Sample code:
3116    *
3117    * <pre>{@code
3118    * // This snippet has been automatically generated and should be regarded as a code template only.
3119    * // It will require modifications to work:
3120    * // - It may require correct/in-range values for request initialization.
3121    * // - It may require specifying regional endpoints when creating the service client as shown in
3122    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3123    * try (KeyManagementServiceClient keyManagementServiceClient =
3124    *     KeyManagementServiceClient.create()) {
3125    *   String name =
3126    *       CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString();
3127    *   ByteString plaintext = ByteString.EMPTY;
3128    *   EncryptResponse response = keyManagementServiceClient.encrypt(name, plaintext);
3129    * }
3130    * }</pre>
3131    *
3132    * @param name Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] or
3133    *     [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for encryption.
3134    *     <p>If a [CryptoKey][google.cloud.kms.v1.CryptoKey] is specified, the server will use its
3135    *     [primary version][google.cloud.kms.v1.CryptoKey.primary].
3136    * @param plaintext Required. The data to encrypt. Must be no larger than 64KiB.
3137    *     <p>The maximum size depends on the key version's
3138    *     [protection_level][google.cloud.kms.v1.CryptoKeyVersionTemplate.protection_level]. For
3139    *     [SOFTWARE][google.cloud.kms.v1.ProtectionLevel.SOFTWARE],
3140    *     [EXTERNAL][google.cloud.kms.v1.ProtectionLevel.EXTERNAL], and
3141    *     [EXTERNAL_VPC][google.cloud.kms.v1.ProtectionLevel.EXTERNAL_VPC] keys, the plaintext must
3142    *     be no larger than 64KiB. For [HSM][google.cloud.kms.v1.ProtectionLevel.HSM] keys, the
3143    *     combined length of the plaintext and additional_authenticated_data fields must be no larger
3144    *     than 8KiB.
3145    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
3146    */
encrypt(String name, ByteString plaintext)3147   public final EncryptResponse encrypt(String name, ByteString plaintext) {
3148     EncryptRequest request =
3149         EncryptRequest.newBuilder().setName(name).setPlaintext(plaintext).build();
3150     return encrypt(request);
3151   }
3152 
3153   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3154   /**
3155    * Encrypts data, so that it can only be recovered by a call to
3156    * [Decrypt][google.cloud.kms.v1.KeyManagementService.Decrypt]. The
3157    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be
3158    * [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT].
3159    *
3160    * <p>Sample code:
3161    *
3162    * <pre>{@code
3163    * // This snippet has been automatically generated and should be regarded as a code template only.
3164    * // It will require modifications to work:
3165    * // - It may require correct/in-range values for request initialization.
3166    * // - It may require specifying regional endpoints when creating the service client as shown in
3167    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3168    * try (KeyManagementServiceClient keyManagementServiceClient =
3169    *     KeyManagementServiceClient.create()) {
3170    *   EncryptRequest request =
3171    *       EncryptRequest.newBuilder()
3172    *           .setName(
3173    *               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
3174    *                   .toString())
3175    *           .setPlaintext(ByteString.EMPTY)
3176    *           .setAdditionalAuthenticatedData(ByteString.EMPTY)
3177    *           .setPlaintextCrc32C(Int64Value.newBuilder().build())
3178    *           .setAdditionalAuthenticatedDataCrc32C(Int64Value.newBuilder().build())
3179    *           .build();
3180    *   EncryptResponse response = keyManagementServiceClient.encrypt(request);
3181    * }
3182    * }</pre>
3183    *
3184    * @param request The request object containing all of the parameters for the API call.
3185    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
3186    */
encrypt(EncryptRequest request)3187   public final EncryptResponse encrypt(EncryptRequest request) {
3188     return encryptCallable().call(request);
3189   }
3190 
3191   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3192   /**
3193    * Encrypts data, so that it can only be recovered by a call to
3194    * [Decrypt][google.cloud.kms.v1.KeyManagementService.Decrypt]. The
3195    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be
3196    * [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT].
3197    *
3198    * <p>Sample code:
3199    *
3200    * <pre>{@code
3201    * // This snippet has been automatically generated and should be regarded as a code template only.
3202    * // It will require modifications to work:
3203    * // - It may require correct/in-range values for request initialization.
3204    * // - It may require specifying regional endpoints when creating the service client as shown in
3205    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3206    * try (KeyManagementServiceClient keyManagementServiceClient =
3207    *     KeyManagementServiceClient.create()) {
3208    *   EncryptRequest request =
3209    *       EncryptRequest.newBuilder()
3210    *           .setName(
3211    *               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
3212    *                   .toString())
3213    *           .setPlaintext(ByteString.EMPTY)
3214    *           .setAdditionalAuthenticatedData(ByteString.EMPTY)
3215    *           .setPlaintextCrc32C(Int64Value.newBuilder().build())
3216    *           .setAdditionalAuthenticatedDataCrc32C(Int64Value.newBuilder().build())
3217    *           .build();
3218    *   ApiFuture<EncryptResponse> future =
3219    *       keyManagementServiceClient.encryptCallable().futureCall(request);
3220    *   // Do something.
3221    *   EncryptResponse response = future.get();
3222    * }
3223    * }</pre>
3224    */
encryptCallable()3225   public final UnaryCallable<EncryptRequest, EncryptResponse> encryptCallable() {
3226     return stub.encryptCallable();
3227   }
3228 
3229   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3230   /**
3231    * Decrypts data that was protected by
3232    * [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt]. The
3233    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be
3234    * [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT].
3235    *
3236    * <p>Sample code:
3237    *
3238    * <pre>{@code
3239    * // This snippet has been automatically generated and should be regarded as a code template only.
3240    * // It will require modifications to work:
3241    * // - It may require correct/in-range values for request initialization.
3242    * // - It may require specifying regional endpoints when creating the service client as shown in
3243    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3244    * try (KeyManagementServiceClient keyManagementServiceClient =
3245    *     KeyManagementServiceClient.create()) {
3246    *   CryptoKeyName name =
3247    *       CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
3248    *   ByteString ciphertext = ByteString.EMPTY;
3249    *   DecryptResponse response = keyManagementServiceClient.decrypt(name, ciphertext);
3250    * }
3251    * }</pre>
3252    *
3253    * @param name Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] to
3254    *     use for decryption. The server will choose the appropriate version.
3255    * @param ciphertext Required. The encrypted data originally returned in
3256    *     [EncryptResponse.ciphertext][google.cloud.kms.v1.EncryptResponse.ciphertext].
3257    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
3258    */
decrypt(CryptoKeyName name, ByteString ciphertext)3259   public final DecryptResponse decrypt(CryptoKeyName name, ByteString ciphertext) {
3260     DecryptRequest request =
3261         DecryptRequest.newBuilder()
3262             .setName(name == null ? null : name.toString())
3263             .setCiphertext(ciphertext)
3264             .build();
3265     return decrypt(request);
3266   }
3267 
3268   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3269   /**
3270    * Decrypts data that was protected by
3271    * [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt]. The
3272    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be
3273    * [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT].
3274    *
3275    * <p>Sample code:
3276    *
3277    * <pre>{@code
3278    * // This snippet has been automatically generated and should be regarded as a code template only.
3279    * // It will require modifications to work:
3280    * // - It may require correct/in-range values for request initialization.
3281    * // - It may require specifying regional endpoints when creating the service client as shown in
3282    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3283    * try (KeyManagementServiceClient keyManagementServiceClient =
3284    *     KeyManagementServiceClient.create()) {
3285    *   String name =
3286    *       CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString();
3287    *   ByteString ciphertext = ByteString.EMPTY;
3288    *   DecryptResponse response = keyManagementServiceClient.decrypt(name, ciphertext);
3289    * }
3290    * }</pre>
3291    *
3292    * @param name Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] to
3293    *     use for decryption. The server will choose the appropriate version.
3294    * @param ciphertext Required. The encrypted data originally returned in
3295    *     [EncryptResponse.ciphertext][google.cloud.kms.v1.EncryptResponse.ciphertext].
3296    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
3297    */
decrypt(String name, ByteString ciphertext)3298   public final DecryptResponse decrypt(String name, ByteString ciphertext) {
3299     DecryptRequest request =
3300         DecryptRequest.newBuilder().setName(name).setCiphertext(ciphertext).build();
3301     return decrypt(request);
3302   }
3303 
3304   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3305   /**
3306    * Decrypts data that was protected by
3307    * [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt]. The
3308    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be
3309    * [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT].
3310    *
3311    * <p>Sample code:
3312    *
3313    * <pre>{@code
3314    * // This snippet has been automatically generated and should be regarded as a code template only.
3315    * // It will require modifications to work:
3316    * // - It may require correct/in-range values for request initialization.
3317    * // - It may require specifying regional endpoints when creating the service client as shown in
3318    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3319    * try (KeyManagementServiceClient keyManagementServiceClient =
3320    *     KeyManagementServiceClient.create()) {
3321    *   DecryptRequest request =
3322    *       DecryptRequest.newBuilder()
3323    *           .setName(
3324    *               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
3325    *                   .toString())
3326    *           .setCiphertext(ByteString.EMPTY)
3327    *           .setAdditionalAuthenticatedData(ByteString.EMPTY)
3328    *           .setCiphertextCrc32C(Int64Value.newBuilder().build())
3329    *           .setAdditionalAuthenticatedDataCrc32C(Int64Value.newBuilder().build())
3330    *           .build();
3331    *   DecryptResponse response = keyManagementServiceClient.decrypt(request);
3332    * }
3333    * }</pre>
3334    *
3335    * @param request The request object containing all of the parameters for the API call.
3336    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
3337    */
decrypt(DecryptRequest request)3338   public final DecryptResponse decrypt(DecryptRequest request) {
3339     return decryptCallable().call(request);
3340   }
3341 
3342   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3343   /**
3344    * Decrypts data that was protected by
3345    * [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt]. The
3346    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be
3347    * [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT].
3348    *
3349    * <p>Sample code:
3350    *
3351    * <pre>{@code
3352    * // This snippet has been automatically generated and should be regarded as a code template only.
3353    * // It will require modifications to work:
3354    * // - It may require correct/in-range values for request initialization.
3355    * // - It may require specifying regional endpoints when creating the service client as shown in
3356    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3357    * try (KeyManagementServiceClient keyManagementServiceClient =
3358    *     KeyManagementServiceClient.create()) {
3359    *   DecryptRequest request =
3360    *       DecryptRequest.newBuilder()
3361    *           .setName(
3362    *               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
3363    *                   .toString())
3364    *           .setCiphertext(ByteString.EMPTY)
3365    *           .setAdditionalAuthenticatedData(ByteString.EMPTY)
3366    *           .setCiphertextCrc32C(Int64Value.newBuilder().build())
3367    *           .setAdditionalAuthenticatedDataCrc32C(Int64Value.newBuilder().build())
3368    *           .build();
3369    *   ApiFuture<DecryptResponse> future =
3370    *       keyManagementServiceClient.decryptCallable().futureCall(request);
3371    *   // Do something.
3372    *   DecryptResponse response = future.get();
3373    * }
3374    * }</pre>
3375    */
decryptCallable()3376   public final UnaryCallable<DecryptRequest, DecryptResponse> decryptCallable() {
3377     return stub.decryptCallable();
3378   }
3379 
3380   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3381   /**
3382    * Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with
3383    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] ASYMMETRIC_SIGN, producing a
3384    * signature that can be verified with the public key retrieved from
3385    * [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey].
3386    *
3387    * <p>Sample code:
3388    *
3389    * <pre>{@code
3390    * // This snippet has been automatically generated and should be regarded as a code template only.
3391    * // It will require modifications to work:
3392    * // - It may require correct/in-range values for request initialization.
3393    * // - It may require specifying regional endpoints when creating the service client as shown in
3394    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3395    * try (KeyManagementServiceClient keyManagementServiceClient =
3396    *     KeyManagementServiceClient.create()) {
3397    *   CryptoKeyVersionName name =
3398    *       CryptoKeyVersionName.of(
3399    *           "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]");
3400    *   Digest digest = Digest.newBuilder().build();
3401    *   AsymmetricSignResponse response = keyManagementServiceClient.asymmetricSign(name, digest);
3402    * }
3403    * }</pre>
3404    *
3405    * @param name Required. The resource name of the
3406    *     [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for signing.
3407    * @param digest Optional. The digest of the data to sign. The digest must be produced with the
3408    *     same digest algorithm as specified by the key version's
3409    *     [algorithm][google.cloud.kms.v1.CryptoKeyVersion.algorithm].
3410    *     <p>This field may not be supplied if
3411    *     [AsymmetricSignRequest.data][google.cloud.kms.v1.AsymmetricSignRequest.data] is supplied.
3412    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
3413    */
asymmetricSign(CryptoKeyVersionName name, Digest digest)3414   public final AsymmetricSignResponse asymmetricSign(CryptoKeyVersionName name, Digest digest) {
3415     AsymmetricSignRequest request =
3416         AsymmetricSignRequest.newBuilder()
3417             .setName(name == null ? null : name.toString())
3418             .setDigest(digest)
3419             .build();
3420     return asymmetricSign(request);
3421   }
3422 
3423   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3424   /**
3425    * Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with
3426    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] ASYMMETRIC_SIGN, producing a
3427    * signature that can be verified with the public key retrieved from
3428    * [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey].
3429    *
3430    * <p>Sample code:
3431    *
3432    * <pre>{@code
3433    * // This snippet has been automatically generated and should be regarded as a code template only.
3434    * // It will require modifications to work:
3435    * // - It may require correct/in-range values for request initialization.
3436    * // - It may require specifying regional endpoints when creating the service client as shown in
3437    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3438    * try (KeyManagementServiceClient keyManagementServiceClient =
3439    *     KeyManagementServiceClient.create()) {
3440    *   String name =
3441    *       CryptoKeyVersionName.of(
3442    *               "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]")
3443    *           .toString();
3444    *   Digest digest = Digest.newBuilder().build();
3445    *   AsymmetricSignResponse response = keyManagementServiceClient.asymmetricSign(name, digest);
3446    * }
3447    * }</pre>
3448    *
3449    * @param name Required. The resource name of the
3450    *     [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for signing.
3451    * @param digest Optional. The digest of the data to sign. The digest must be produced with the
3452    *     same digest algorithm as specified by the key version's
3453    *     [algorithm][google.cloud.kms.v1.CryptoKeyVersion.algorithm].
3454    *     <p>This field may not be supplied if
3455    *     [AsymmetricSignRequest.data][google.cloud.kms.v1.AsymmetricSignRequest.data] is supplied.
3456    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
3457    */
asymmetricSign(String name, Digest digest)3458   public final AsymmetricSignResponse asymmetricSign(String name, Digest digest) {
3459     AsymmetricSignRequest request =
3460         AsymmetricSignRequest.newBuilder().setName(name).setDigest(digest).build();
3461     return asymmetricSign(request);
3462   }
3463 
3464   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3465   /**
3466    * Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with
3467    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] ASYMMETRIC_SIGN, producing a
3468    * signature that can be verified with the public key retrieved from
3469    * [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey].
3470    *
3471    * <p>Sample code:
3472    *
3473    * <pre>{@code
3474    * // This snippet has been automatically generated and should be regarded as a code template only.
3475    * // It will require modifications to work:
3476    * // - It may require correct/in-range values for request initialization.
3477    * // - It may require specifying regional endpoints when creating the service client as shown in
3478    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3479    * try (KeyManagementServiceClient keyManagementServiceClient =
3480    *     KeyManagementServiceClient.create()) {
3481    *   AsymmetricSignRequest request =
3482    *       AsymmetricSignRequest.newBuilder()
3483    *           .setName(
3484    *               CryptoKeyVersionName.of(
3485    *                       "[PROJECT]",
3486    *                       "[LOCATION]",
3487    *                       "[KEY_RING]",
3488    *                       "[CRYPTO_KEY]",
3489    *                       "[CRYPTO_KEY_VERSION]")
3490    *                   .toString())
3491    *           .setDigest(Digest.newBuilder().build())
3492    *           .setDigestCrc32C(Int64Value.newBuilder().build())
3493    *           .setData(ByteString.EMPTY)
3494    *           .setDataCrc32C(Int64Value.newBuilder().build())
3495    *           .build();
3496    *   AsymmetricSignResponse response = keyManagementServiceClient.asymmetricSign(request);
3497    * }
3498    * }</pre>
3499    *
3500    * @param request The request object containing all of the parameters for the API call.
3501    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
3502    */
asymmetricSign(AsymmetricSignRequest request)3503   public final AsymmetricSignResponse asymmetricSign(AsymmetricSignRequest request) {
3504     return asymmetricSignCallable().call(request);
3505   }
3506 
3507   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3508   /**
3509    * Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with
3510    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] ASYMMETRIC_SIGN, producing a
3511    * signature that can be verified with the public key retrieved from
3512    * [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey].
3513    *
3514    * <p>Sample code:
3515    *
3516    * <pre>{@code
3517    * // This snippet has been automatically generated and should be regarded as a code template only.
3518    * // It will require modifications to work:
3519    * // - It may require correct/in-range values for request initialization.
3520    * // - It may require specifying regional endpoints when creating the service client as shown in
3521    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3522    * try (KeyManagementServiceClient keyManagementServiceClient =
3523    *     KeyManagementServiceClient.create()) {
3524    *   AsymmetricSignRequest request =
3525    *       AsymmetricSignRequest.newBuilder()
3526    *           .setName(
3527    *               CryptoKeyVersionName.of(
3528    *                       "[PROJECT]",
3529    *                       "[LOCATION]",
3530    *                       "[KEY_RING]",
3531    *                       "[CRYPTO_KEY]",
3532    *                       "[CRYPTO_KEY_VERSION]")
3533    *                   .toString())
3534    *           .setDigest(Digest.newBuilder().build())
3535    *           .setDigestCrc32C(Int64Value.newBuilder().build())
3536    *           .setData(ByteString.EMPTY)
3537    *           .setDataCrc32C(Int64Value.newBuilder().build())
3538    *           .build();
3539    *   ApiFuture<AsymmetricSignResponse> future =
3540    *       keyManagementServiceClient.asymmetricSignCallable().futureCall(request);
3541    *   // Do something.
3542    *   AsymmetricSignResponse response = future.get();
3543    * }
3544    * }</pre>
3545    */
3546   public final UnaryCallable<AsymmetricSignRequest, AsymmetricSignResponse>
asymmetricSignCallable()3547       asymmetricSignCallable() {
3548     return stub.asymmetricSignCallable();
3549   }
3550 
3551   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3552   /**
3553    * Decrypts data that was encrypted with a public key retrieved from
3554    * [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey] corresponding to a
3555    * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with
3556    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] ASYMMETRIC_DECRYPT.
3557    *
3558    * <p>Sample code:
3559    *
3560    * <pre>{@code
3561    * // This snippet has been automatically generated and should be regarded as a code template only.
3562    * // It will require modifications to work:
3563    * // - It may require correct/in-range values for request initialization.
3564    * // - It may require specifying regional endpoints when creating the service client as shown in
3565    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3566    * try (KeyManagementServiceClient keyManagementServiceClient =
3567    *     KeyManagementServiceClient.create()) {
3568    *   CryptoKeyVersionName name =
3569    *       CryptoKeyVersionName.of(
3570    *           "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]");
3571    *   ByteString ciphertext = ByteString.EMPTY;
3572    *   AsymmetricDecryptResponse response =
3573    *       keyManagementServiceClient.asymmetricDecrypt(name, ciphertext);
3574    * }
3575    * }</pre>
3576    *
3577    * @param name Required. The resource name of the
3578    *     [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for decryption.
3579    * @param ciphertext Required. The data encrypted with the named
3580    *     [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]'s public key using OAEP.
3581    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
3582    */
asymmetricDecrypt( CryptoKeyVersionName name, ByteString ciphertext)3583   public final AsymmetricDecryptResponse asymmetricDecrypt(
3584       CryptoKeyVersionName name, ByteString ciphertext) {
3585     AsymmetricDecryptRequest request =
3586         AsymmetricDecryptRequest.newBuilder()
3587             .setName(name == null ? null : name.toString())
3588             .setCiphertext(ciphertext)
3589             .build();
3590     return asymmetricDecrypt(request);
3591   }
3592 
3593   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3594   /**
3595    * Decrypts data that was encrypted with a public key retrieved from
3596    * [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey] corresponding to a
3597    * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with
3598    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] ASYMMETRIC_DECRYPT.
3599    *
3600    * <p>Sample code:
3601    *
3602    * <pre>{@code
3603    * // This snippet has been automatically generated and should be regarded as a code template only.
3604    * // It will require modifications to work:
3605    * // - It may require correct/in-range values for request initialization.
3606    * // - It may require specifying regional endpoints when creating the service client as shown in
3607    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3608    * try (KeyManagementServiceClient keyManagementServiceClient =
3609    *     KeyManagementServiceClient.create()) {
3610    *   String name =
3611    *       CryptoKeyVersionName.of(
3612    *               "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]")
3613    *           .toString();
3614    *   ByteString ciphertext = ByteString.EMPTY;
3615    *   AsymmetricDecryptResponse response =
3616    *       keyManagementServiceClient.asymmetricDecrypt(name, ciphertext);
3617    * }
3618    * }</pre>
3619    *
3620    * @param name Required. The resource name of the
3621    *     [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for decryption.
3622    * @param ciphertext Required. The data encrypted with the named
3623    *     [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]'s public key using OAEP.
3624    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
3625    */
asymmetricDecrypt(String name, ByteString ciphertext)3626   public final AsymmetricDecryptResponse asymmetricDecrypt(String name, ByteString ciphertext) {
3627     AsymmetricDecryptRequest request =
3628         AsymmetricDecryptRequest.newBuilder().setName(name).setCiphertext(ciphertext).build();
3629     return asymmetricDecrypt(request);
3630   }
3631 
3632   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3633   /**
3634    * Decrypts data that was encrypted with a public key retrieved from
3635    * [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey] corresponding to a
3636    * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with
3637    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] ASYMMETRIC_DECRYPT.
3638    *
3639    * <p>Sample code:
3640    *
3641    * <pre>{@code
3642    * // This snippet has been automatically generated and should be regarded as a code template only.
3643    * // It will require modifications to work:
3644    * // - It may require correct/in-range values for request initialization.
3645    * // - It may require specifying regional endpoints when creating the service client as shown in
3646    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3647    * try (KeyManagementServiceClient keyManagementServiceClient =
3648    *     KeyManagementServiceClient.create()) {
3649    *   AsymmetricDecryptRequest request =
3650    *       AsymmetricDecryptRequest.newBuilder()
3651    *           .setName(
3652    *               CryptoKeyVersionName.of(
3653    *                       "[PROJECT]",
3654    *                       "[LOCATION]",
3655    *                       "[KEY_RING]",
3656    *                       "[CRYPTO_KEY]",
3657    *                       "[CRYPTO_KEY_VERSION]")
3658    *                   .toString())
3659    *           .setCiphertext(ByteString.EMPTY)
3660    *           .setCiphertextCrc32C(Int64Value.newBuilder().build())
3661    *           .build();
3662    *   AsymmetricDecryptResponse response = keyManagementServiceClient.asymmetricDecrypt(request);
3663    * }
3664    * }</pre>
3665    *
3666    * @param request The request object containing all of the parameters for the API call.
3667    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
3668    */
asymmetricDecrypt(AsymmetricDecryptRequest request)3669   public final AsymmetricDecryptResponse asymmetricDecrypt(AsymmetricDecryptRequest request) {
3670     return asymmetricDecryptCallable().call(request);
3671   }
3672 
3673   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3674   /**
3675    * Decrypts data that was encrypted with a public key retrieved from
3676    * [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey] corresponding to a
3677    * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with
3678    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] ASYMMETRIC_DECRYPT.
3679    *
3680    * <p>Sample code:
3681    *
3682    * <pre>{@code
3683    * // This snippet has been automatically generated and should be regarded as a code template only.
3684    * // It will require modifications to work:
3685    * // - It may require correct/in-range values for request initialization.
3686    * // - It may require specifying regional endpoints when creating the service client as shown in
3687    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3688    * try (KeyManagementServiceClient keyManagementServiceClient =
3689    *     KeyManagementServiceClient.create()) {
3690    *   AsymmetricDecryptRequest request =
3691    *       AsymmetricDecryptRequest.newBuilder()
3692    *           .setName(
3693    *               CryptoKeyVersionName.of(
3694    *                       "[PROJECT]",
3695    *                       "[LOCATION]",
3696    *                       "[KEY_RING]",
3697    *                       "[CRYPTO_KEY]",
3698    *                       "[CRYPTO_KEY_VERSION]")
3699    *                   .toString())
3700    *           .setCiphertext(ByteString.EMPTY)
3701    *           .setCiphertextCrc32C(Int64Value.newBuilder().build())
3702    *           .build();
3703    *   ApiFuture<AsymmetricDecryptResponse> future =
3704    *       keyManagementServiceClient.asymmetricDecryptCallable().futureCall(request);
3705    *   // Do something.
3706    *   AsymmetricDecryptResponse response = future.get();
3707    * }
3708    * }</pre>
3709    */
3710   public final UnaryCallable<AsymmetricDecryptRequest, AsymmetricDecryptResponse>
asymmetricDecryptCallable()3711       asymmetricDecryptCallable() {
3712     return stub.asymmetricDecryptCallable();
3713   }
3714 
3715   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3716   /**
3717    * Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with
3718    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] MAC, producing a tag that can be
3719    * verified by another source with the same key.
3720    *
3721    * <p>Sample code:
3722    *
3723    * <pre>{@code
3724    * // This snippet has been automatically generated and should be regarded as a code template only.
3725    * // It will require modifications to work:
3726    * // - It may require correct/in-range values for request initialization.
3727    * // - It may require specifying regional endpoints when creating the service client as shown in
3728    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3729    * try (KeyManagementServiceClient keyManagementServiceClient =
3730    *     KeyManagementServiceClient.create()) {
3731    *   CryptoKeyVersionName name =
3732    *       CryptoKeyVersionName.of(
3733    *           "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]");
3734    *   ByteString data = ByteString.EMPTY;
3735    *   MacSignResponse response = keyManagementServiceClient.macSign(name, data);
3736    * }
3737    * }</pre>
3738    *
3739    * @param name Required. The resource name of the
3740    *     [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for signing.
3741    * @param data Required. The data to sign. The MAC tag is computed over this data field based on
3742    *     the specific algorithm.
3743    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
3744    */
macSign(CryptoKeyVersionName name, ByteString data)3745   public final MacSignResponse macSign(CryptoKeyVersionName name, ByteString data) {
3746     MacSignRequest request =
3747         MacSignRequest.newBuilder()
3748             .setName(name == null ? null : name.toString())
3749             .setData(data)
3750             .build();
3751     return macSign(request);
3752   }
3753 
3754   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3755   /**
3756    * Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with
3757    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] MAC, producing a tag that can be
3758    * verified by another source with the same key.
3759    *
3760    * <p>Sample code:
3761    *
3762    * <pre>{@code
3763    * // This snippet has been automatically generated and should be regarded as a code template only.
3764    * // It will require modifications to work:
3765    * // - It may require correct/in-range values for request initialization.
3766    * // - It may require specifying regional endpoints when creating the service client as shown in
3767    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3768    * try (KeyManagementServiceClient keyManagementServiceClient =
3769    *     KeyManagementServiceClient.create()) {
3770    *   String name =
3771    *       CryptoKeyVersionName.of(
3772    *               "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]")
3773    *           .toString();
3774    *   ByteString data = ByteString.EMPTY;
3775    *   MacSignResponse response = keyManagementServiceClient.macSign(name, data);
3776    * }
3777    * }</pre>
3778    *
3779    * @param name Required. The resource name of the
3780    *     [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for signing.
3781    * @param data Required. The data to sign. The MAC tag is computed over this data field based on
3782    *     the specific algorithm.
3783    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
3784    */
macSign(String name, ByteString data)3785   public final MacSignResponse macSign(String name, ByteString data) {
3786     MacSignRequest request = MacSignRequest.newBuilder().setName(name).setData(data).build();
3787     return macSign(request);
3788   }
3789 
3790   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3791   /**
3792    * Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with
3793    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] MAC, producing a tag that can be
3794    * verified by another source with the same key.
3795    *
3796    * <p>Sample code:
3797    *
3798    * <pre>{@code
3799    * // This snippet has been automatically generated and should be regarded as a code template only.
3800    * // It will require modifications to work:
3801    * // - It may require correct/in-range values for request initialization.
3802    * // - It may require specifying regional endpoints when creating the service client as shown in
3803    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3804    * try (KeyManagementServiceClient keyManagementServiceClient =
3805    *     KeyManagementServiceClient.create()) {
3806    *   MacSignRequest request =
3807    *       MacSignRequest.newBuilder()
3808    *           .setName(
3809    *               CryptoKeyVersionName.of(
3810    *                       "[PROJECT]",
3811    *                       "[LOCATION]",
3812    *                       "[KEY_RING]",
3813    *                       "[CRYPTO_KEY]",
3814    *                       "[CRYPTO_KEY_VERSION]")
3815    *                   .toString())
3816    *           .setData(ByteString.EMPTY)
3817    *           .setDataCrc32C(Int64Value.newBuilder().build())
3818    *           .build();
3819    *   MacSignResponse response = keyManagementServiceClient.macSign(request);
3820    * }
3821    * }</pre>
3822    *
3823    * @param request The request object containing all of the parameters for the API call.
3824    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
3825    */
macSign(MacSignRequest request)3826   public final MacSignResponse macSign(MacSignRequest request) {
3827     return macSignCallable().call(request);
3828   }
3829 
3830   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3831   /**
3832    * Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with
3833    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] MAC, producing a tag that can be
3834    * verified by another source with the same key.
3835    *
3836    * <p>Sample code:
3837    *
3838    * <pre>{@code
3839    * // This snippet has been automatically generated and should be regarded as a code template only.
3840    * // It will require modifications to work:
3841    * // - It may require correct/in-range values for request initialization.
3842    * // - It may require specifying regional endpoints when creating the service client as shown in
3843    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3844    * try (KeyManagementServiceClient keyManagementServiceClient =
3845    *     KeyManagementServiceClient.create()) {
3846    *   MacSignRequest request =
3847    *       MacSignRequest.newBuilder()
3848    *           .setName(
3849    *               CryptoKeyVersionName.of(
3850    *                       "[PROJECT]",
3851    *                       "[LOCATION]",
3852    *                       "[KEY_RING]",
3853    *                       "[CRYPTO_KEY]",
3854    *                       "[CRYPTO_KEY_VERSION]")
3855    *                   .toString())
3856    *           .setData(ByteString.EMPTY)
3857    *           .setDataCrc32C(Int64Value.newBuilder().build())
3858    *           .build();
3859    *   ApiFuture<MacSignResponse> future =
3860    *       keyManagementServiceClient.macSignCallable().futureCall(request);
3861    *   // Do something.
3862    *   MacSignResponse response = future.get();
3863    * }
3864    * }</pre>
3865    */
macSignCallable()3866   public final UnaryCallable<MacSignRequest, MacSignResponse> macSignCallable() {
3867     return stub.macSignCallable();
3868   }
3869 
3870   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3871   /**
3872    * Verifies MAC tag using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with
3873    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] MAC, and returns a response that
3874    * indicates whether or not the verification was successful.
3875    *
3876    * <p>Sample code:
3877    *
3878    * <pre>{@code
3879    * // This snippet has been automatically generated and should be regarded as a code template only.
3880    * // It will require modifications to work:
3881    * // - It may require correct/in-range values for request initialization.
3882    * // - It may require specifying regional endpoints when creating the service client as shown in
3883    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3884    * try (KeyManagementServiceClient keyManagementServiceClient =
3885    *     KeyManagementServiceClient.create()) {
3886    *   CryptoKeyVersionName name =
3887    *       CryptoKeyVersionName.of(
3888    *           "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]");
3889    *   ByteString data = ByteString.EMPTY;
3890    *   ByteString mac = ByteString.EMPTY;
3891    *   MacVerifyResponse response = keyManagementServiceClient.macVerify(name, data, mac);
3892    * }
3893    * }</pre>
3894    *
3895    * @param name Required. The resource name of the
3896    *     [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for verification.
3897    * @param data Required. The data used previously as a
3898    *     [MacSignRequest.data][google.cloud.kms.v1.MacSignRequest.data] to generate the MAC tag.
3899    * @param mac Required. The signature to verify.
3900    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
3901    */
macVerify( CryptoKeyVersionName name, ByteString data, ByteString mac)3902   public final MacVerifyResponse macVerify(
3903       CryptoKeyVersionName name, ByteString data, ByteString mac) {
3904     MacVerifyRequest request =
3905         MacVerifyRequest.newBuilder()
3906             .setName(name == null ? null : name.toString())
3907             .setData(data)
3908             .setMac(mac)
3909             .build();
3910     return macVerify(request);
3911   }
3912 
3913   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3914   /**
3915    * Verifies MAC tag using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with
3916    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] MAC, and returns a response that
3917    * indicates whether or not the verification was successful.
3918    *
3919    * <p>Sample code:
3920    *
3921    * <pre>{@code
3922    * // This snippet has been automatically generated and should be regarded as a code template only.
3923    * // It will require modifications to work:
3924    * // - It may require correct/in-range values for request initialization.
3925    * // - It may require specifying regional endpoints when creating the service client as shown in
3926    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3927    * try (KeyManagementServiceClient keyManagementServiceClient =
3928    *     KeyManagementServiceClient.create()) {
3929    *   String name =
3930    *       CryptoKeyVersionName.of(
3931    *               "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]")
3932    *           .toString();
3933    *   ByteString data = ByteString.EMPTY;
3934    *   ByteString mac = ByteString.EMPTY;
3935    *   MacVerifyResponse response = keyManagementServiceClient.macVerify(name, data, mac);
3936    * }
3937    * }</pre>
3938    *
3939    * @param name Required. The resource name of the
3940    *     [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for verification.
3941    * @param data Required. The data used previously as a
3942    *     [MacSignRequest.data][google.cloud.kms.v1.MacSignRequest.data] to generate the MAC tag.
3943    * @param mac Required. The signature to verify.
3944    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
3945    */
macVerify(String name, ByteString data, ByteString mac)3946   public final MacVerifyResponse macVerify(String name, ByteString data, ByteString mac) {
3947     MacVerifyRequest request =
3948         MacVerifyRequest.newBuilder().setName(name).setData(data).setMac(mac).build();
3949     return macVerify(request);
3950   }
3951 
3952   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3953   /**
3954    * Verifies MAC tag using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with
3955    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] MAC, and returns a response that
3956    * indicates whether or not the verification was successful.
3957    *
3958    * <p>Sample code:
3959    *
3960    * <pre>{@code
3961    * // This snippet has been automatically generated and should be regarded as a code template only.
3962    * // It will require modifications to work:
3963    * // - It may require correct/in-range values for request initialization.
3964    * // - It may require specifying regional endpoints when creating the service client as shown in
3965    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3966    * try (KeyManagementServiceClient keyManagementServiceClient =
3967    *     KeyManagementServiceClient.create()) {
3968    *   MacVerifyRequest request =
3969    *       MacVerifyRequest.newBuilder()
3970    *           .setName(
3971    *               CryptoKeyVersionName.of(
3972    *                       "[PROJECT]",
3973    *                       "[LOCATION]",
3974    *                       "[KEY_RING]",
3975    *                       "[CRYPTO_KEY]",
3976    *                       "[CRYPTO_KEY_VERSION]")
3977    *                   .toString())
3978    *           .setData(ByteString.EMPTY)
3979    *           .setDataCrc32C(Int64Value.newBuilder().build())
3980    *           .setMac(ByteString.EMPTY)
3981    *           .setMacCrc32C(Int64Value.newBuilder().build())
3982    *           .build();
3983    *   MacVerifyResponse response = keyManagementServiceClient.macVerify(request);
3984    * }
3985    * }</pre>
3986    *
3987    * @param request The request object containing all of the parameters for the API call.
3988    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
3989    */
macVerify(MacVerifyRequest request)3990   public final MacVerifyResponse macVerify(MacVerifyRequest request) {
3991     return macVerifyCallable().call(request);
3992   }
3993 
3994   // AUTO-GENERATED DOCUMENTATION AND METHOD.
3995   /**
3996    * Verifies MAC tag using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with
3997    * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] MAC, and returns a response that
3998    * indicates whether or not the verification was successful.
3999    *
4000    * <p>Sample code:
4001    *
4002    * <pre>{@code
4003    * // This snippet has been automatically generated and should be regarded as a code template only.
4004    * // It will require modifications to work:
4005    * // - It may require correct/in-range values for request initialization.
4006    * // - It may require specifying regional endpoints when creating the service client as shown in
4007    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
4008    * try (KeyManagementServiceClient keyManagementServiceClient =
4009    *     KeyManagementServiceClient.create()) {
4010    *   MacVerifyRequest request =
4011    *       MacVerifyRequest.newBuilder()
4012    *           .setName(
4013    *               CryptoKeyVersionName.of(
4014    *                       "[PROJECT]",
4015    *                       "[LOCATION]",
4016    *                       "[KEY_RING]",
4017    *                       "[CRYPTO_KEY]",
4018    *                       "[CRYPTO_KEY_VERSION]")
4019    *                   .toString())
4020    *           .setData(ByteString.EMPTY)
4021    *           .setDataCrc32C(Int64Value.newBuilder().build())
4022    *           .setMac(ByteString.EMPTY)
4023    *           .setMacCrc32C(Int64Value.newBuilder().build())
4024    *           .build();
4025    *   ApiFuture<MacVerifyResponse> future =
4026    *       keyManagementServiceClient.macVerifyCallable().futureCall(request);
4027    *   // Do something.
4028    *   MacVerifyResponse response = future.get();
4029    * }
4030    * }</pre>
4031    */
macVerifyCallable()4032   public final UnaryCallable<MacVerifyRequest, MacVerifyResponse> macVerifyCallable() {
4033     return stub.macVerifyCallable();
4034   }
4035 
4036   // AUTO-GENERATED DOCUMENTATION AND METHOD.
4037   /**
4038    * Generate random bytes using the Cloud KMS randomness source in the provided location.
4039    *
4040    * <p>Sample code:
4041    *
4042    * <pre>{@code
4043    * // This snippet has been automatically generated and should be regarded as a code template only.
4044    * // It will require modifications to work:
4045    * // - It may require correct/in-range values for request initialization.
4046    * // - It may require specifying regional endpoints when creating the service client as shown in
4047    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
4048    * try (KeyManagementServiceClient keyManagementServiceClient =
4049    *     KeyManagementServiceClient.create()) {
4050    *   String location = "location1901043637";
4051    *   int lengthBytes = -745661998;
4052    *   ProtectionLevel protectionLevel = ProtectionLevel.forNumber(0);
4053    *   GenerateRandomBytesResponse response =
4054    *       keyManagementServiceClient.generateRandomBytes(location, lengthBytes, protectionLevel);
4055    * }
4056    * }</pre>
4057    *
4058    * @param location The project-specific location in which to generate random bytes. For example,
4059    *     "projects/my-project/locations/us-central1".
4060    * @param lengthBytes The length in bytes of the amount of randomness to retrieve. Minimum 8
4061    *     bytes, maximum 1024 bytes.
4062    * @param protectionLevel The [ProtectionLevel][google.cloud.kms.v1.ProtectionLevel] to use when
4063    *     generating the random data. Currently, only [HSM][google.cloud.kms.v1.ProtectionLevel.HSM]
4064    *     protection level is supported.
4065    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
4066    */
generateRandomBytes( String location, int lengthBytes, ProtectionLevel protectionLevel)4067   public final GenerateRandomBytesResponse generateRandomBytes(
4068       String location, int lengthBytes, ProtectionLevel protectionLevel) {
4069     GenerateRandomBytesRequest request =
4070         GenerateRandomBytesRequest.newBuilder()
4071             .setLocation(location)
4072             .setLengthBytes(lengthBytes)
4073             .setProtectionLevel(protectionLevel)
4074             .build();
4075     return generateRandomBytes(request);
4076   }
4077 
4078   // AUTO-GENERATED DOCUMENTATION AND METHOD.
4079   /**
4080    * Generate random bytes using the Cloud KMS randomness source in the provided location.
4081    *
4082    * <p>Sample code:
4083    *
4084    * <pre>{@code
4085    * // This snippet has been automatically generated and should be regarded as a code template only.
4086    * // It will require modifications to work:
4087    * // - It may require correct/in-range values for request initialization.
4088    * // - It may require specifying regional endpoints when creating the service client as shown in
4089    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
4090    * try (KeyManagementServiceClient keyManagementServiceClient =
4091    *     KeyManagementServiceClient.create()) {
4092    *   GenerateRandomBytesRequest request =
4093    *       GenerateRandomBytesRequest.newBuilder()
4094    *           .setLocation("location1901043637")
4095    *           .setLengthBytes(-745661998)
4096    *           .setProtectionLevel(ProtectionLevel.forNumber(0))
4097    *           .build();
4098    *   GenerateRandomBytesResponse response =
4099    *       keyManagementServiceClient.generateRandomBytes(request);
4100    * }
4101    * }</pre>
4102    *
4103    * @param request The request object containing all of the parameters for the API call.
4104    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
4105    */
generateRandomBytes(GenerateRandomBytesRequest request)4106   public final GenerateRandomBytesResponse generateRandomBytes(GenerateRandomBytesRequest request) {
4107     return generateRandomBytesCallable().call(request);
4108   }
4109 
4110   // AUTO-GENERATED DOCUMENTATION AND METHOD.
4111   /**
4112    * Generate random bytes using the Cloud KMS randomness source in the provided location.
4113    *
4114    * <p>Sample code:
4115    *
4116    * <pre>{@code
4117    * // This snippet has been automatically generated and should be regarded as a code template only.
4118    * // It will require modifications to work:
4119    * // - It may require correct/in-range values for request initialization.
4120    * // - It may require specifying regional endpoints when creating the service client as shown in
4121    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
4122    * try (KeyManagementServiceClient keyManagementServiceClient =
4123    *     KeyManagementServiceClient.create()) {
4124    *   GenerateRandomBytesRequest request =
4125    *       GenerateRandomBytesRequest.newBuilder()
4126    *           .setLocation("location1901043637")
4127    *           .setLengthBytes(-745661998)
4128    *           .setProtectionLevel(ProtectionLevel.forNumber(0))
4129    *           .build();
4130    *   ApiFuture<GenerateRandomBytesResponse> future =
4131    *       keyManagementServiceClient.generateRandomBytesCallable().futureCall(request);
4132    *   // Do something.
4133    *   GenerateRandomBytesResponse response = future.get();
4134    * }
4135    * }</pre>
4136    */
4137   public final UnaryCallable<GenerateRandomBytesRequest, GenerateRandomBytesResponse>
generateRandomBytesCallable()4138       generateRandomBytesCallable() {
4139     return stub.generateRandomBytesCallable();
4140   }
4141 
4142   // AUTO-GENERATED DOCUMENTATION AND METHOD.
4143   /**
4144    * Lists information about the supported locations for this service.
4145    *
4146    * <p>Sample code:
4147    *
4148    * <pre>{@code
4149    * // This snippet has been automatically generated and should be regarded as a code template only.
4150    * // It will require modifications to work:
4151    * // - It may require correct/in-range values for request initialization.
4152    * // - It may require specifying regional endpoints when creating the service client as shown in
4153    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
4154    * try (KeyManagementServiceClient keyManagementServiceClient =
4155    *     KeyManagementServiceClient.create()) {
4156    *   ListLocationsRequest request =
4157    *       ListLocationsRequest.newBuilder()
4158    *           .setName("name3373707")
4159    *           .setFilter("filter-1274492040")
4160    *           .setPageSize(883849137)
4161    *           .setPageToken("pageToken873572522")
4162    *           .build();
4163    *   for (Location element : keyManagementServiceClient.listLocations(request).iterateAll()) {
4164    *     // doThingsWith(element);
4165    *   }
4166    * }
4167    * }</pre>
4168    *
4169    * @param request The request object containing all of the parameters for the API call.
4170    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
4171    */
listLocations(ListLocationsRequest request)4172   public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) {
4173     return listLocationsPagedCallable().call(request);
4174   }
4175 
4176   // AUTO-GENERATED DOCUMENTATION AND METHOD.
4177   /**
4178    * Lists information about the supported locations for this service.
4179    *
4180    * <p>Sample code:
4181    *
4182    * <pre>{@code
4183    * // This snippet has been automatically generated and should be regarded as a code template only.
4184    * // It will require modifications to work:
4185    * // - It may require correct/in-range values for request initialization.
4186    * // - It may require specifying regional endpoints when creating the service client as shown in
4187    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
4188    * try (KeyManagementServiceClient keyManagementServiceClient =
4189    *     KeyManagementServiceClient.create()) {
4190    *   ListLocationsRequest request =
4191    *       ListLocationsRequest.newBuilder()
4192    *           .setName("name3373707")
4193    *           .setFilter("filter-1274492040")
4194    *           .setPageSize(883849137)
4195    *           .setPageToken("pageToken873572522")
4196    *           .build();
4197    *   ApiFuture<Location> future =
4198    *       keyManagementServiceClient.listLocationsPagedCallable().futureCall(request);
4199    *   // Do something.
4200    *   for (Location element : future.get().iterateAll()) {
4201    *     // doThingsWith(element);
4202    *   }
4203    * }
4204    * }</pre>
4205    */
4206   public final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse>
listLocationsPagedCallable()4207       listLocationsPagedCallable() {
4208     return stub.listLocationsPagedCallable();
4209   }
4210 
4211   // AUTO-GENERATED DOCUMENTATION AND METHOD.
4212   /**
4213    * Lists information about the supported locations for this service.
4214    *
4215    * <p>Sample code:
4216    *
4217    * <pre>{@code
4218    * // This snippet has been automatically generated and should be regarded as a code template only.
4219    * // It will require modifications to work:
4220    * // - It may require correct/in-range values for request initialization.
4221    * // - It may require specifying regional endpoints when creating the service client as shown in
4222    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
4223    * try (KeyManagementServiceClient keyManagementServiceClient =
4224    *     KeyManagementServiceClient.create()) {
4225    *   ListLocationsRequest request =
4226    *       ListLocationsRequest.newBuilder()
4227    *           .setName("name3373707")
4228    *           .setFilter("filter-1274492040")
4229    *           .setPageSize(883849137)
4230    *           .setPageToken("pageToken873572522")
4231    *           .build();
4232    *   while (true) {
4233    *     ListLocationsResponse response =
4234    *         keyManagementServiceClient.listLocationsCallable().call(request);
4235    *     for (Location element : response.getLocationsList()) {
4236    *       // doThingsWith(element);
4237    *     }
4238    *     String nextPageToken = response.getNextPageToken();
4239    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
4240    *       request = request.toBuilder().setPageToken(nextPageToken).build();
4241    *     } else {
4242    *       break;
4243    *     }
4244    *   }
4245    * }
4246    * }</pre>
4247    */
listLocationsCallable()4248   public final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable() {
4249     return stub.listLocationsCallable();
4250   }
4251 
4252   // AUTO-GENERATED DOCUMENTATION AND METHOD.
4253   /**
4254    * Gets information about a location.
4255    *
4256    * <p>Sample code:
4257    *
4258    * <pre>{@code
4259    * // This snippet has been automatically generated and should be regarded as a code template only.
4260    * // It will require modifications to work:
4261    * // - It may require correct/in-range values for request initialization.
4262    * // - It may require specifying regional endpoints when creating the service client as shown in
4263    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
4264    * try (KeyManagementServiceClient keyManagementServiceClient =
4265    *     KeyManagementServiceClient.create()) {
4266    *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
4267    *   Location response = keyManagementServiceClient.getLocation(request);
4268    * }
4269    * }</pre>
4270    *
4271    * @param request The request object containing all of the parameters for the API call.
4272    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
4273    */
getLocation(GetLocationRequest request)4274   public final Location getLocation(GetLocationRequest request) {
4275     return getLocationCallable().call(request);
4276   }
4277 
4278   // AUTO-GENERATED DOCUMENTATION AND METHOD.
4279   /**
4280    * Gets information about a location.
4281    *
4282    * <p>Sample code:
4283    *
4284    * <pre>{@code
4285    * // This snippet has been automatically generated and should be regarded as a code template only.
4286    * // It will require modifications to work:
4287    * // - It may require correct/in-range values for request initialization.
4288    * // - It may require specifying regional endpoints when creating the service client as shown in
4289    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
4290    * try (KeyManagementServiceClient keyManagementServiceClient =
4291    *     KeyManagementServiceClient.create()) {
4292    *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
4293    *   ApiFuture<Location> future =
4294    *       keyManagementServiceClient.getLocationCallable().futureCall(request);
4295    *   // Do something.
4296    *   Location response = future.get();
4297    * }
4298    * }</pre>
4299    */
getLocationCallable()4300   public final UnaryCallable<GetLocationRequest, Location> getLocationCallable() {
4301     return stub.getLocationCallable();
4302   }
4303 
4304   // AUTO-GENERATED DOCUMENTATION AND METHOD.
4305   /**
4306    * Sets the access control policy on the specified resource. Replacesany existing policy.
4307    *
4308    * <p>Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors.
4309    *
4310    * <p>Sample code:
4311    *
4312    * <pre>{@code
4313    * // This snippet has been automatically generated and should be regarded as a code template only.
4314    * // It will require modifications to work:
4315    * // - It may require correct/in-range values for request initialization.
4316    * // - It may require specifying regional endpoints when creating the service client as shown in
4317    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
4318    * try (KeyManagementServiceClient keyManagementServiceClient =
4319    *     KeyManagementServiceClient.create()) {
4320    *   SetIamPolicyRequest request =
4321    *       SetIamPolicyRequest.newBuilder()
4322    *           .setResource(
4323    *               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
4324    *                   .toString())
4325    *           .setPolicy(Policy.newBuilder().build())
4326    *           .setUpdateMask(FieldMask.newBuilder().build())
4327    *           .build();
4328    *   Policy response = keyManagementServiceClient.setIamPolicy(request);
4329    * }
4330    * }</pre>
4331    *
4332    * @param request The request object containing all of the parameters for the API call.
4333    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
4334    */
setIamPolicy(SetIamPolicyRequest request)4335   public final Policy setIamPolicy(SetIamPolicyRequest request) {
4336     return setIamPolicyCallable().call(request);
4337   }
4338 
4339   // ADDED BY SYNTH
4340   /**
4341    * Sets the access control policy on the specified resource. Replaces any existing policy.
4342    *
4343    * <p>Can return Public Errors: NOT_FOUND, INVALID_ARGUMENT and PERMISSION_DENIED
4344    *
4345    * <p>Sample code:
4346    *
4347    * <pre><code>
4348    * try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
4349    *   KeyName resource = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
4350    *   Policy policy = Policy.newBuilder().build();
4351    *   Policy response = keyManagementServiceClient.setIamPolicy(resource, policy);
4352    * }
4353    * </code></pre>
4354    *
4355    * @param resource REQUIRED: The resource for which the policy is being specified. See the
4356    *     operation documentation for the appropriate value for this field.
4357    * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the
4358    *     policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud
4359    *     Platform services (such as Projects) might reject them.
4360    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
4361    */
setIamPolicy(KeyName resource, Policy policy)4362   public final Policy setIamPolicy(KeyName resource, Policy policy) {
4363     SetIamPolicyRequest request =
4364         SetIamPolicyRequest.newBuilder()
4365             .setResource(resource == null ? null : resource.toString())
4366             .setPolicy(policy)
4367             .build();
4368     return setIamPolicy(request);
4369   }
4370 
4371   // ADDED BY SYNTH
4372   /**
4373    * Sets the access control policy on the specified resource. Replaces any existing policy.
4374    *
4375    * <p>Can return Public Errors: NOT_FOUND, INVALID_ARGUMENT and PERMISSION_DENIED
4376    *
4377    * <p>Sample code:
4378    *
4379    * <pre><code>
4380    * try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
4381    *   KeyName resource = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
4382    *   Policy policy = Policy.newBuilder().build();
4383    *   Policy response = keyManagementServiceClient.setIamPolicy(resource.toString(), policy);
4384    * }
4385    * </code></pre>
4386    *
4387    * @param resource REQUIRED: The resource for which the policy is being specified. See the
4388    *     operation documentation for the appropriate value for this field.
4389    * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the
4390    *     policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud
4391    *     Platform services (such as Projects) might reject them.
4392    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
4393    */
setIamPolicy(String resource, Policy policy)4394   public final Policy setIamPolicy(String resource, Policy policy) {
4395     SetIamPolicyRequest request =
4396         SetIamPolicyRequest.newBuilder().setResource(resource).setPolicy(policy).build();
4397     return setIamPolicy(request);
4398   }
4399 
4400   // AUTO-GENERATED DOCUMENTATION AND METHOD.
4401   /**
4402    * Sets the access control policy on the specified resource. Replacesany existing policy.
4403    *
4404    * <p>Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors.
4405    *
4406    * <p>Sample code:
4407    *
4408    * <pre>{@code
4409    * // This snippet has been automatically generated and should be regarded as a code template only.
4410    * // It will require modifications to work:
4411    * // - It may require correct/in-range values for request initialization.
4412    * // - It may require specifying regional endpoints when creating the service client as shown in
4413    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
4414    * try (KeyManagementServiceClient keyManagementServiceClient =
4415    *     KeyManagementServiceClient.create()) {
4416    *   SetIamPolicyRequest request =
4417    *       SetIamPolicyRequest.newBuilder()
4418    *           .setResource(
4419    *               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
4420    *                   .toString())
4421    *           .setPolicy(Policy.newBuilder().build())
4422    *           .setUpdateMask(FieldMask.newBuilder().build())
4423    *           .build();
4424    *   ApiFuture<Policy> future =
4425    *       keyManagementServiceClient.setIamPolicyCallable().futureCall(request);
4426    *   // Do something.
4427    *   Policy response = future.get();
4428    * }
4429    * }</pre>
4430    */
setIamPolicyCallable()4431   public final UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() {
4432     return stub.setIamPolicyCallable();
4433   }
4434 
4435   // AUTO-GENERATED DOCUMENTATION AND METHOD.
4436   /**
4437    * Gets the access control policy for a resource. Returns an empty policyif the resource exists
4438    * and does not have a policy set.
4439    *
4440    * <p>Sample code:
4441    *
4442    * <pre>{@code
4443    * // This snippet has been automatically generated and should be regarded as a code template only.
4444    * // It will require modifications to work:
4445    * // - It may require correct/in-range values for request initialization.
4446    * // - It may require specifying regional endpoints when creating the service client as shown in
4447    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
4448    * try (KeyManagementServiceClient keyManagementServiceClient =
4449    *     KeyManagementServiceClient.create()) {
4450    *   GetIamPolicyRequest request =
4451    *       GetIamPolicyRequest.newBuilder()
4452    *           .setResource(
4453    *               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
4454    *                   .toString())
4455    *           .setOptions(GetPolicyOptions.newBuilder().build())
4456    *           .build();
4457    *   Policy response = keyManagementServiceClient.getIamPolicy(request);
4458    * }
4459    * }</pre>
4460    *
4461    * @param request The request object containing all of the parameters for the API call.
4462    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
4463    */
getIamPolicy(GetIamPolicyRequest request)4464   public final Policy getIamPolicy(GetIamPolicyRequest request) {
4465     return getIamPolicyCallable().call(request);
4466   }
4467 
4468   // ADDED BY SYNTH
4469   /**
4470    * Gets the access control policy for a resource. Returns an empty policy if the resource exists
4471    * and does not have a policy set.
4472    *
4473    * <p>Sample code:
4474    *
4475    * <pre><code>
4476    * try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
4477    *   KeyName resource = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
4478    *   Policy response = keyManagementServiceClient.getIamPolicy(resource);
4479    * }
4480    * </code></pre>
4481    *
4482    * @param resource REQUIRED: The resource for which the policy is being requested. See the
4483    *     operation documentation for the appropriate value for this field.
4484    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
4485    */
getIamPolicy(KeyName resource)4486   public final Policy getIamPolicy(KeyName resource) {
4487     GetIamPolicyRequest request =
4488         GetIamPolicyRequest.newBuilder()
4489             .setResource(resource == null ? null : resource.toString())
4490             .build();
4491     return getIamPolicy(request);
4492   }
4493 
4494   // ADDED BY SYNTH
4495   /**
4496    * Gets the access control policy for a resource. Returns an empty policy if the resource exists
4497    * and does not have a policy set.
4498    *
4499    * <p>Sample code:
4500    *
4501    * <pre><code>
4502    * try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
4503    *   KeyName resource = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
4504    *   Policy response = keyManagementServiceClient.getIamPolicy(resource.toString());
4505    * }
4506    * </code></pre>
4507    *
4508    * @param resource REQUIRED: The resource for which the policy is being requested. See the
4509    *     operation documentation for the appropriate value for this field.
4510    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
4511    */
getIamPolicy(String resource)4512   public final Policy getIamPolicy(String resource) {
4513     GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder().setResource(resource).build();
4514     return getIamPolicy(request);
4515   }
4516 
4517   // AUTO-GENERATED DOCUMENTATION AND METHOD.
4518   /**
4519    * Gets the access control policy for a resource. Returns an empty policyif the resource exists
4520    * and does not have a policy set.
4521    *
4522    * <p>Sample code:
4523    *
4524    * <pre>{@code
4525    * // This snippet has been automatically generated and should be regarded as a code template only.
4526    * // It will require modifications to work:
4527    * // - It may require correct/in-range values for request initialization.
4528    * // - It may require specifying regional endpoints when creating the service client as shown in
4529    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
4530    * try (KeyManagementServiceClient keyManagementServiceClient =
4531    *     KeyManagementServiceClient.create()) {
4532    *   GetIamPolicyRequest request =
4533    *       GetIamPolicyRequest.newBuilder()
4534    *           .setResource(
4535    *               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
4536    *                   .toString())
4537    *           .setOptions(GetPolicyOptions.newBuilder().build())
4538    *           .build();
4539    *   ApiFuture<Policy> future =
4540    *       keyManagementServiceClient.getIamPolicyCallable().futureCall(request);
4541    *   // Do something.
4542    *   Policy response = future.get();
4543    * }
4544    * }</pre>
4545    */
getIamPolicyCallable()4546   public final UnaryCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable() {
4547     return stub.getIamPolicyCallable();
4548   }
4549 
4550   // AUTO-GENERATED DOCUMENTATION AND METHOD.
4551   /**
4552    * Returns permissions that a caller has on the specified resource. If theresource does not exist,
4553    * this will return an empty set ofpermissions, not a `NOT_FOUND` error.
4554    *
4555    * <p>Note: This operation is designed to be used for buildingpermission-aware UIs and
4556    * command-line tools, not for authorizationchecking. This operation may "fail open" without
4557    * warning.
4558    *
4559    * <p>Sample code:
4560    *
4561    * <pre>{@code
4562    * // This snippet has been automatically generated and should be regarded as a code template only.
4563    * // It will require modifications to work:
4564    * // - It may require correct/in-range values for request initialization.
4565    * // - It may require specifying regional endpoints when creating the service client as shown in
4566    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
4567    * try (KeyManagementServiceClient keyManagementServiceClient =
4568    *     KeyManagementServiceClient.create()) {
4569    *   TestIamPermissionsRequest request =
4570    *       TestIamPermissionsRequest.newBuilder()
4571    *           .setResource(
4572    *               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
4573    *                   .toString())
4574    *           .addAllPermissions(new ArrayList<String>())
4575    *           .build();
4576    *   TestIamPermissionsResponse response = keyManagementServiceClient.testIamPermissions(request);
4577    * }
4578    * }</pre>
4579    *
4580    * @param request The request object containing all of the parameters for the API call.
4581    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
4582    */
testIamPermissions(TestIamPermissionsRequest request)4583   public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request) {
4584     return testIamPermissionsCallable().call(request);
4585   }
4586 
4587   // ADDED BY SYNTH
4588   /**
4589    * Returns permissions that a caller has on the specified resource. If the resource does not
4590    * exist, this will return an empty set of permissions, not a NOT_FOUND error.
4591    *
4592    * <p>Note: This operation is designed to be used for building permission-aware UIs and
4593    * command-line tools, not for authorization checking. This operation may "fail open" without
4594    * warning.
4595    *
4596    * <p>Sample code:
4597    *
4598    * <pre><code>
4599    * try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
4600    *   KeyName resource = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
4601    *   List&lt;String&gt; permissions = new ArrayList&lt;&gt;();
4602    *   TestIamPermissionsResponse response = keyManagementServiceClient.testIamPermissions(resource, permissions);
4603    * }
4604    * </code></pre>
4605    *
4606    * @param resource REQUIRED: The resource for which the policy detail is being requested. See the
4607    *     operation documentation for the appropriate value for this field.
4608    * @param permissions The set of permissions to check for the `resource`. Permissions with
4609    *     wildcards (such as '&#42;' or 'storage.&#42;') are not allowed. For more information see
4610    *     [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
4611    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
4612    */
testIamPermissions( KeyName resource, List<String> permissions)4613   public final TestIamPermissionsResponse testIamPermissions(
4614       KeyName resource, List<String> permissions) {
4615     TestIamPermissionsRequest request =
4616         TestIamPermissionsRequest.newBuilder()
4617             .setResource(resource == null ? null : resource.toString())
4618             .addAllPermissions(permissions)
4619             .build();
4620     return testIamPermissions(request);
4621   }
4622 
4623   // ADDED BY SYNTH
4624   /**
4625    * Returns permissions that a caller has on the specified resource. If the resource does not
4626    * exist, this will return an empty set of permissions, not a NOT_FOUND error.
4627    *
4628    * <p>Note: This operation is designed to be used for building permission-aware UIs and
4629    * command-line tools, not for authorization checking. This operation may "fail open" without
4630    * warning.
4631    *
4632    * <p>Sample code:
4633    *
4634    * <pre><code>
4635    * try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
4636    *   KeyName resource = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
4637    *   List&lt;String&gt; permissions = new ArrayList&lt;&gt;();
4638    *   TestIamPermissionsResponse response = keyManagementServiceClient.testIamPermissions(resource.toString(), permissions);
4639    * }
4640    * </code></pre>
4641    *
4642    * @param resource REQUIRED: The resource for which the policy detail is being requested. See the
4643    *     operation documentation for the appropriate value for this field.
4644    * @param permissions The set of permissions to check for the `resource`. Permissions with
4645    *     wildcards (such as '&#42;' or 'storage.&#42;') are not allowed. For more information see
4646    *     [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
4647    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
4648    */
testIamPermissions( String resource, List<String> permissions)4649   public final TestIamPermissionsResponse testIamPermissions(
4650       String resource, List<String> permissions) {
4651     TestIamPermissionsRequest request =
4652         TestIamPermissionsRequest.newBuilder()
4653             .setResource(resource)
4654             .addAllPermissions(permissions)
4655             .build();
4656     return testIamPermissions(request);
4657   }
4658 
4659   // AUTO-GENERATED DOCUMENTATION AND METHOD.
4660   /**
4661    * Returns permissions that a caller has on the specified resource. If theresource does not exist,
4662    * this will return an empty set ofpermissions, not a `NOT_FOUND` error.
4663    *
4664    * <p>Note: This operation is designed to be used for buildingpermission-aware UIs and
4665    * command-line tools, not for authorizationchecking. This operation may "fail open" without
4666    * warning.
4667    *
4668    * <p>Sample code:
4669    *
4670    * <pre>{@code
4671    * // This snippet has been automatically generated and should be regarded as a code template only.
4672    * // It will require modifications to work:
4673    * // - It may require correct/in-range values for request initialization.
4674    * // - It may require specifying regional endpoints when creating the service client as shown in
4675    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
4676    * try (KeyManagementServiceClient keyManagementServiceClient =
4677    *     KeyManagementServiceClient.create()) {
4678    *   TestIamPermissionsRequest request =
4679    *       TestIamPermissionsRequest.newBuilder()
4680    *           .setResource(
4681    *               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
4682    *                   .toString())
4683    *           .addAllPermissions(new ArrayList<String>())
4684    *           .build();
4685    *   ApiFuture<TestIamPermissionsResponse> future =
4686    *       keyManagementServiceClient.testIamPermissionsCallable().futureCall(request);
4687    *   // Do something.
4688    *   TestIamPermissionsResponse response = future.get();
4689    * }
4690    * }</pre>
4691    */
4692   public final UnaryCallable<TestIamPermissionsRequest, TestIamPermissionsResponse>
testIamPermissionsCallable()4693       testIamPermissionsCallable() {
4694     return stub.testIamPermissionsCallable();
4695   }
4696 
4697   @Override
close()4698   public final void close() {
4699     stub.close();
4700   }
4701 
4702   @Override
shutdown()4703   public void shutdown() {
4704     stub.shutdown();
4705   }
4706 
4707   @Override
isShutdown()4708   public boolean isShutdown() {
4709     return stub.isShutdown();
4710   }
4711 
4712   @Override
isTerminated()4713   public boolean isTerminated() {
4714     return stub.isTerminated();
4715   }
4716 
4717   @Override
shutdownNow()4718   public void shutdownNow() {
4719     stub.shutdownNow();
4720   }
4721 
4722   @Override
awaitTermination(long duration, TimeUnit unit)4723   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
4724     return stub.awaitTermination(duration, unit);
4725   }
4726 
4727   public static class ListKeyRingsPagedResponse
4728       extends AbstractPagedListResponse<
4729           ListKeyRingsRequest,
4730           ListKeyRingsResponse,
4731           KeyRing,
4732           ListKeyRingsPage,
4733           ListKeyRingsFixedSizeCollection> {
4734 
createAsync( PageContext<ListKeyRingsRequest, ListKeyRingsResponse, KeyRing> context, ApiFuture<ListKeyRingsResponse> futureResponse)4735     public static ApiFuture<ListKeyRingsPagedResponse> createAsync(
4736         PageContext<ListKeyRingsRequest, ListKeyRingsResponse, KeyRing> context,
4737         ApiFuture<ListKeyRingsResponse> futureResponse) {
4738       ApiFuture<ListKeyRingsPage> futurePage =
4739           ListKeyRingsPage.createEmptyPage().createPageAsync(context, futureResponse);
4740       return ApiFutures.transform(
4741           futurePage,
4742           input -> new ListKeyRingsPagedResponse(input),
4743           MoreExecutors.directExecutor());
4744     }
4745 
ListKeyRingsPagedResponse(ListKeyRingsPage page)4746     private ListKeyRingsPagedResponse(ListKeyRingsPage page) {
4747       super(page, ListKeyRingsFixedSizeCollection.createEmptyCollection());
4748     }
4749   }
4750 
4751   public static class ListKeyRingsPage
4752       extends AbstractPage<ListKeyRingsRequest, ListKeyRingsResponse, KeyRing, ListKeyRingsPage> {
4753 
ListKeyRingsPage( PageContext<ListKeyRingsRequest, ListKeyRingsResponse, KeyRing> context, ListKeyRingsResponse response)4754     private ListKeyRingsPage(
4755         PageContext<ListKeyRingsRequest, ListKeyRingsResponse, KeyRing> context,
4756         ListKeyRingsResponse response) {
4757       super(context, response);
4758     }
4759 
createEmptyPage()4760     private static ListKeyRingsPage createEmptyPage() {
4761       return new ListKeyRingsPage(null, null);
4762     }
4763 
4764     @Override
createPage( PageContext<ListKeyRingsRequest, ListKeyRingsResponse, KeyRing> context, ListKeyRingsResponse response)4765     protected ListKeyRingsPage createPage(
4766         PageContext<ListKeyRingsRequest, ListKeyRingsResponse, KeyRing> context,
4767         ListKeyRingsResponse response) {
4768       return new ListKeyRingsPage(context, response);
4769     }
4770 
4771     @Override
createPageAsync( PageContext<ListKeyRingsRequest, ListKeyRingsResponse, KeyRing> context, ApiFuture<ListKeyRingsResponse> futureResponse)4772     public ApiFuture<ListKeyRingsPage> createPageAsync(
4773         PageContext<ListKeyRingsRequest, ListKeyRingsResponse, KeyRing> context,
4774         ApiFuture<ListKeyRingsResponse> futureResponse) {
4775       return super.createPageAsync(context, futureResponse);
4776     }
4777   }
4778 
4779   public static class ListKeyRingsFixedSizeCollection
4780       extends AbstractFixedSizeCollection<
4781           ListKeyRingsRequest,
4782           ListKeyRingsResponse,
4783           KeyRing,
4784           ListKeyRingsPage,
4785           ListKeyRingsFixedSizeCollection> {
4786 
ListKeyRingsFixedSizeCollection(List<ListKeyRingsPage> pages, int collectionSize)4787     private ListKeyRingsFixedSizeCollection(List<ListKeyRingsPage> pages, int collectionSize) {
4788       super(pages, collectionSize);
4789     }
4790 
createEmptyCollection()4791     private static ListKeyRingsFixedSizeCollection createEmptyCollection() {
4792       return new ListKeyRingsFixedSizeCollection(null, 0);
4793     }
4794 
4795     @Override
createCollection( List<ListKeyRingsPage> pages, int collectionSize)4796     protected ListKeyRingsFixedSizeCollection createCollection(
4797         List<ListKeyRingsPage> pages, int collectionSize) {
4798       return new ListKeyRingsFixedSizeCollection(pages, collectionSize);
4799     }
4800   }
4801 
4802   public static class ListCryptoKeysPagedResponse
4803       extends AbstractPagedListResponse<
4804           ListCryptoKeysRequest,
4805           ListCryptoKeysResponse,
4806           CryptoKey,
4807           ListCryptoKeysPage,
4808           ListCryptoKeysFixedSizeCollection> {
4809 
createAsync( PageContext<ListCryptoKeysRequest, ListCryptoKeysResponse, CryptoKey> context, ApiFuture<ListCryptoKeysResponse> futureResponse)4810     public static ApiFuture<ListCryptoKeysPagedResponse> createAsync(
4811         PageContext<ListCryptoKeysRequest, ListCryptoKeysResponse, CryptoKey> context,
4812         ApiFuture<ListCryptoKeysResponse> futureResponse) {
4813       ApiFuture<ListCryptoKeysPage> futurePage =
4814           ListCryptoKeysPage.createEmptyPage().createPageAsync(context, futureResponse);
4815       return ApiFutures.transform(
4816           futurePage,
4817           input -> new ListCryptoKeysPagedResponse(input),
4818           MoreExecutors.directExecutor());
4819     }
4820 
ListCryptoKeysPagedResponse(ListCryptoKeysPage page)4821     private ListCryptoKeysPagedResponse(ListCryptoKeysPage page) {
4822       super(page, ListCryptoKeysFixedSizeCollection.createEmptyCollection());
4823     }
4824   }
4825 
4826   public static class ListCryptoKeysPage
4827       extends AbstractPage<
4828           ListCryptoKeysRequest, ListCryptoKeysResponse, CryptoKey, ListCryptoKeysPage> {
4829 
ListCryptoKeysPage( PageContext<ListCryptoKeysRequest, ListCryptoKeysResponse, CryptoKey> context, ListCryptoKeysResponse response)4830     private ListCryptoKeysPage(
4831         PageContext<ListCryptoKeysRequest, ListCryptoKeysResponse, CryptoKey> context,
4832         ListCryptoKeysResponse response) {
4833       super(context, response);
4834     }
4835 
createEmptyPage()4836     private static ListCryptoKeysPage createEmptyPage() {
4837       return new ListCryptoKeysPage(null, null);
4838     }
4839 
4840     @Override
createPage( PageContext<ListCryptoKeysRequest, ListCryptoKeysResponse, CryptoKey> context, ListCryptoKeysResponse response)4841     protected ListCryptoKeysPage createPage(
4842         PageContext<ListCryptoKeysRequest, ListCryptoKeysResponse, CryptoKey> context,
4843         ListCryptoKeysResponse response) {
4844       return new ListCryptoKeysPage(context, response);
4845     }
4846 
4847     @Override
createPageAsync( PageContext<ListCryptoKeysRequest, ListCryptoKeysResponse, CryptoKey> context, ApiFuture<ListCryptoKeysResponse> futureResponse)4848     public ApiFuture<ListCryptoKeysPage> createPageAsync(
4849         PageContext<ListCryptoKeysRequest, ListCryptoKeysResponse, CryptoKey> context,
4850         ApiFuture<ListCryptoKeysResponse> futureResponse) {
4851       return super.createPageAsync(context, futureResponse);
4852     }
4853   }
4854 
4855   public static class ListCryptoKeysFixedSizeCollection
4856       extends AbstractFixedSizeCollection<
4857           ListCryptoKeysRequest,
4858           ListCryptoKeysResponse,
4859           CryptoKey,
4860           ListCryptoKeysPage,
4861           ListCryptoKeysFixedSizeCollection> {
4862 
ListCryptoKeysFixedSizeCollection(List<ListCryptoKeysPage> pages, int collectionSize)4863     private ListCryptoKeysFixedSizeCollection(List<ListCryptoKeysPage> pages, int collectionSize) {
4864       super(pages, collectionSize);
4865     }
4866 
createEmptyCollection()4867     private static ListCryptoKeysFixedSizeCollection createEmptyCollection() {
4868       return new ListCryptoKeysFixedSizeCollection(null, 0);
4869     }
4870 
4871     @Override
createCollection( List<ListCryptoKeysPage> pages, int collectionSize)4872     protected ListCryptoKeysFixedSizeCollection createCollection(
4873         List<ListCryptoKeysPage> pages, int collectionSize) {
4874       return new ListCryptoKeysFixedSizeCollection(pages, collectionSize);
4875     }
4876   }
4877 
4878   public static class ListCryptoKeyVersionsPagedResponse
4879       extends AbstractPagedListResponse<
4880           ListCryptoKeyVersionsRequest,
4881           ListCryptoKeyVersionsResponse,
4882           CryptoKeyVersion,
4883           ListCryptoKeyVersionsPage,
4884           ListCryptoKeyVersionsFixedSizeCollection> {
4885 
createAsync( PageContext<ListCryptoKeyVersionsRequest, ListCryptoKeyVersionsResponse, CryptoKeyVersion> context, ApiFuture<ListCryptoKeyVersionsResponse> futureResponse)4886     public static ApiFuture<ListCryptoKeyVersionsPagedResponse> createAsync(
4887         PageContext<ListCryptoKeyVersionsRequest, ListCryptoKeyVersionsResponse, CryptoKeyVersion>
4888             context,
4889         ApiFuture<ListCryptoKeyVersionsResponse> futureResponse) {
4890       ApiFuture<ListCryptoKeyVersionsPage> futurePage =
4891           ListCryptoKeyVersionsPage.createEmptyPage().createPageAsync(context, futureResponse);
4892       return ApiFutures.transform(
4893           futurePage,
4894           input -> new ListCryptoKeyVersionsPagedResponse(input),
4895           MoreExecutors.directExecutor());
4896     }
4897 
ListCryptoKeyVersionsPagedResponse(ListCryptoKeyVersionsPage page)4898     private ListCryptoKeyVersionsPagedResponse(ListCryptoKeyVersionsPage page) {
4899       super(page, ListCryptoKeyVersionsFixedSizeCollection.createEmptyCollection());
4900     }
4901   }
4902 
4903   public static class ListCryptoKeyVersionsPage
4904       extends AbstractPage<
4905           ListCryptoKeyVersionsRequest,
4906           ListCryptoKeyVersionsResponse,
4907           CryptoKeyVersion,
4908           ListCryptoKeyVersionsPage> {
4909 
ListCryptoKeyVersionsPage( PageContext<ListCryptoKeyVersionsRequest, ListCryptoKeyVersionsResponse, CryptoKeyVersion> context, ListCryptoKeyVersionsResponse response)4910     private ListCryptoKeyVersionsPage(
4911         PageContext<ListCryptoKeyVersionsRequest, ListCryptoKeyVersionsResponse, CryptoKeyVersion>
4912             context,
4913         ListCryptoKeyVersionsResponse response) {
4914       super(context, response);
4915     }
4916 
createEmptyPage()4917     private static ListCryptoKeyVersionsPage createEmptyPage() {
4918       return new ListCryptoKeyVersionsPage(null, null);
4919     }
4920 
4921     @Override
createPage( PageContext<ListCryptoKeyVersionsRequest, ListCryptoKeyVersionsResponse, CryptoKeyVersion> context, ListCryptoKeyVersionsResponse response)4922     protected ListCryptoKeyVersionsPage createPage(
4923         PageContext<ListCryptoKeyVersionsRequest, ListCryptoKeyVersionsResponse, CryptoKeyVersion>
4924             context,
4925         ListCryptoKeyVersionsResponse response) {
4926       return new ListCryptoKeyVersionsPage(context, response);
4927     }
4928 
4929     @Override
createPageAsync( PageContext<ListCryptoKeyVersionsRequest, ListCryptoKeyVersionsResponse, CryptoKeyVersion> context, ApiFuture<ListCryptoKeyVersionsResponse> futureResponse)4930     public ApiFuture<ListCryptoKeyVersionsPage> createPageAsync(
4931         PageContext<ListCryptoKeyVersionsRequest, ListCryptoKeyVersionsResponse, CryptoKeyVersion>
4932             context,
4933         ApiFuture<ListCryptoKeyVersionsResponse> futureResponse) {
4934       return super.createPageAsync(context, futureResponse);
4935     }
4936   }
4937 
4938   public static class ListCryptoKeyVersionsFixedSizeCollection
4939       extends AbstractFixedSizeCollection<
4940           ListCryptoKeyVersionsRequest,
4941           ListCryptoKeyVersionsResponse,
4942           CryptoKeyVersion,
4943           ListCryptoKeyVersionsPage,
4944           ListCryptoKeyVersionsFixedSizeCollection> {
4945 
ListCryptoKeyVersionsFixedSizeCollection( List<ListCryptoKeyVersionsPage> pages, int collectionSize)4946     private ListCryptoKeyVersionsFixedSizeCollection(
4947         List<ListCryptoKeyVersionsPage> pages, int collectionSize) {
4948       super(pages, collectionSize);
4949     }
4950 
createEmptyCollection()4951     private static ListCryptoKeyVersionsFixedSizeCollection createEmptyCollection() {
4952       return new ListCryptoKeyVersionsFixedSizeCollection(null, 0);
4953     }
4954 
4955     @Override
createCollection( List<ListCryptoKeyVersionsPage> pages, int collectionSize)4956     protected ListCryptoKeyVersionsFixedSizeCollection createCollection(
4957         List<ListCryptoKeyVersionsPage> pages, int collectionSize) {
4958       return new ListCryptoKeyVersionsFixedSizeCollection(pages, collectionSize);
4959     }
4960   }
4961 
4962   public static class ListImportJobsPagedResponse
4963       extends AbstractPagedListResponse<
4964           ListImportJobsRequest,
4965           ListImportJobsResponse,
4966           ImportJob,
4967           ListImportJobsPage,
4968           ListImportJobsFixedSizeCollection> {
4969 
createAsync( PageContext<ListImportJobsRequest, ListImportJobsResponse, ImportJob> context, ApiFuture<ListImportJobsResponse> futureResponse)4970     public static ApiFuture<ListImportJobsPagedResponse> createAsync(
4971         PageContext<ListImportJobsRequest, ListImportJobsResponse, ImportJob> context,
4972         ApiFuture<ListImportJobsResponse> futureResponse) {
4973       ApiFuture<ListImportJobsPage> futurePage =
4974           ListImportJobsPage.createEmptyPage().createPageAsync(context, futureResponse);
4975       return ApiFutures.transform(
4976           futurePage,
4977           input -> new ListImportJobsPagedResponse(input),
4978           MoreExecutors.directExecutor());
4979     }
4980 
ListImportJobsPagedResponse(ListImportJobsPage page)4981     private ListImportJobsPagedResponse(ListImportJobsPage page) {
4982       super(page, ListImportJobsFixedSizeCollection.createEmptyCollection());
4983     }
4984   }
4985 
4986   public static class ListImportJobsPage
4987       extends AbstractPage<
4988           ListImportJobsRequest, ListImportJobsResponse, ImportJob, ListImportJobsPage> {
4989 
ListImportJobsPage( PageContext<ListImportJobsRequest, ListImportJobsResponse, ImportJob> context, ListImportJobsResponse response)4990     private ListImportJobsPage(
4991         PageContext<ListImportJobsRequest, ListImportJobsResponse, ImportJob> context,
4992         ListImportJobsResponse response) {
4993       super(context, response);
4994     }
4995 
createEmptyPage()4996     private static ListImportJobsPage createEmptyPage() {
4997       return new ListImportJobsPage(null, null);
4998     }
4999 
5000     @Override
createPage( PageContext<ListImportJobsRequest, ListImportJobsResponse, ImportJob> context, ListImportJobsResponse response)5001     protected ListImportJobsPage createPage(
5002         PageContext<ListImportJobsRequest, ListImportJobsResponse, ImportJob> context,
5003         ListImportJobsResponse response) {
5004       return new ListImportJobsPage(context, response);
5005     }
5006 
5007     @Override
createPageAsync( PageContext<ListImportJobsRequest, ListImportJobsResponse, ImportJob> context, ApiFuture<ListImportJobsResponse> futureResponse)5008     public ApiFuture<ListImportJobsPage> createPageAsync(
5009         PageContext<ListImportJobsRequest, ListImportJobsResponse, ImportJob> context,
5010         ApiFuture<ListImportJobsResponse> futureResponse) {
5011       return super.createPageAsync(context, futureResponse);
5012     }
5013   }
5014 
5015   public static class ListImportJobsFixedSizeCollection
5016       extends AbstractFixedSizeCollection<
5017           ListImportJobsRequest,
5018           ListImportJobsResponse,
5019           ImportJob,
5020           ListImportJobsPage,
5021           ListImportJobsFixedSizeCollection> {
5022 
ListImportJobsFixedSizeCollection(List<ListImportJobsPage> pages, int collectionSize)5023     private ListImportJobsFixedSizeCollection(List<ListImportJobsPage> pages, int collectionSize) {
5024       super(pages, collectionSize);
5025     }
5026 
createEmptyCollection()5027     private static ListImportJobsFixedSizeCollection createEmptyCollection() {
5028       return new ListImportJobsFixedSizeCollection(null, 0);
5029     }
5030 
5031     @Override
createCollection( List<ListImportJobsPage> pages, int collectionSize)5032     protected ListImportJobsFixedSizeCollection createCollection(
5033         List<ListImportJobsPage> pages, int collectionSize) {
5034       return new ListImportJobsFixedSizeCollection(pages, collectionSize);
5035     }
5036   }
5037 
5038   public static class ListLocationsPagedResponse
5039       extends AbstractPagedListResponse<
5040           ListLocationsRequest,
5041           ListLocationsResponse,
5042           Location,
5043           ListLocationsPage,
5044           ListLocationsFixedSizeCollection> {
5045 
createAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)5046     public static ApiFuture<ListLocationsPagedResponse> createAsync(
5047         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
5048         ApiFuture<ListLocationsResponse> futureResponse) {
5049       ApiFuture<ListLocationsPage> futurePage =
5050           ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse);
5051       return ApiFutures.transform(
5052           futurePage,
5053           input -> new ListLocationsPagedResponse(input),
5054           MoreExecutors.directExecutor());
5055     }
5056 
ListLocationsPagedResponse(ListLocationsPage page)5057     private ListLocationsPagedResponse(ListLocationsPage page) {
5058       super(page, ListLocationsFixedSizeCollection.createEmptyCollection());
5059     }
5060   }
5061 
5062   public static class ListLocationsPage
5063       extends AbstractPage<
5064           ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> {
5065 
ListLocationsPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)5066     private ListLocationsPage(
5067         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
5068         ListLocationsResponse response) {
5069       super(context, response);
5070     }
5071 
createEmptyPage()5072     private static ListLocationsPage createEmptyPage() {
5073       return new ListLocationsPage(null, null);
5074     }
5075 
5076     @Override
createPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)5077     protected ListLocationsPage createPage(
5078         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
5079         ListLocationsResponse response) {
5080       return new ListLocationsPage(context, response);
5081     }
5082 
5083     @Override
createPageAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)5084     public ApiFuture<ListLocationsPage> createPageAsync(
5085         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
5086         ApiFuture<ListLocationsResponse> futureResponse) {
5087       return super.createPageAsync(context, futureResponse);
5088     }
5089   }
5090 
5091   public static class ListLocationsFixedSizeCollection
5092       extends AbstractFixedSizeCollection<
5093           ListLocationsRequest,
5094           ListLocationsResponse,
5095           Location,
5096           ListLocationsPage,
5097           ListLocationsFixedSizeCollection> {
5098 
ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize)5099     private ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize) {
5100       super(pages, collectionSize);
5101     }
5102 
createEmptyCollection()5103     private static ListLocationsFixedSizeCollection createEmptyCollection() {
5104       return new ListLocationsFixedSizeCollection(null, 0);
5105     }
5106 
5107     @Override
createCollection( List<ListLocationsPage> pages, int collectionSize)5108     protected ListLocationsFixedSizeCollection createCollection(
5109         List<ListLocationsPage> pages, int collectionSize) {
5110       return new ListLocationsFixedSizeCollection(pages, collectionSize);
5111     }
5112   }
5113 }
5114