• 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.compute.v1;
18 
19 import com.google.api.core.ApiFuture;
20 import com.google.api.core.ApiFutures;
21 import com.google.api.core.BetaApi;
22 import com.google.api.gax.core.BackgroundResource;
23 import com.google.api.gax.longrunning.OperationFuture;
24 import com.google.api.gax.paging.AbstractFixedSizeCollection;
25 import com.google.api.gax.paging.AbstractPage;
26 import com.google.api.gax.paging.AbstractPagedListResponse;
27 import com.google.api.gax.rpc.OperationCallable;
28 import com.google.api.gax.rpc.PageContext;
29 import com.google.api.gax.rpc.UnaryCallable;
30 import com.google.cloud.compute.v1.stub.LicensesStub;
31 import com.google.cloud.compute.v1.stub.LicensesStubSettings;
32 import com.google.common.util.concurrent.MoreExecutors;
33 import java.io.IOException;
34 import java.util.List;
35 import java.util.concurrent.TimeUnit;
36 import javax.annotation.Generated;
37 
38 // AUTO-GENERATED DOCUMENTATION AND CLASS.
39 /**
40  * Service Description: The Licenses API.
41  *
42  * <p>This class provides the ability to make remote calls to the backing service through method
43  * calls that map to API methods. Sample code to get started:
44  *
45  * <pre>{@code
46  * // This snippet has been automatically generated and should be regarded as a code template only.
47  * // It will require modifications to work:
48  * // - It may require correct/in-range values for request initialization.
49  * // - It may require specifying regional endpoints when creating the service client as shown in
50  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
51  * try (LicensesClient licensesClient = LicensesClient.create()) {
52  *   String project = "project-309310695";
53  *   String license = "license166757441";
54  *   License response = licensesClient.get(project, license);
55  * }
56  * }</pre>
57  *
58  * <p>Note: close() needs to be called on the LicensesClient object to clean up resources such as
59  * threads. In the example above, try-with-resources is used, which automatically calls close().
60  *
61  * <p>The surface of this class includes several types of Java methods for each of the API's
62  * methods:
63  *
64  * <ol>
65  *   <li>A "flattened" method. With this type of method, the fields of the request type have been
66  *       converted into function parameters. It may be the case that not all fields are available as
67  *       parameters, and not every API method will have a flattened method entry point.
68  *   <li>A "request object" method. This type of method only takes one parameter, a request object,
69  *       which must be constructed before the call. Not every API method will have a request object
70  *       method.
71  *   <li>A "callable" method. This type of method takes no parameters and returns an immutable API
72  *       callable object, which can be used to initiate calls to the service.
73  * </ol>
74  *
75  * <p>See the individual methods for example code.
76  *
77  * <p>Many parameters require resource names to be formatted in a particular way. To assist with
78  * these names, this class includes a format method for each type of name, and additionally a parse
79  * method to extract the individual identifiers contained within names that are returned.
80  *
81  * <p>This class can be customized by passing in a custom instance of LicensesSettings to create().
82  * For example:
83  *
84  * <p>To customize credentials:
85  *
86  * <pre>{@code
87  * // This snippet has been automatically generated and should be regarded as a code template only.
88  * // It will require modifications to work:
89  * // - It may require correct/in-range values for request initialization.
90  * // - It may require specifying regional endpoints when creating the service client as shown in
91  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
92  * LicensesSettings licensesSettings =
93  *     LicensesSettings.newBuilder()
94  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
95  *         .build();
96  * LicensesClient licensesClient = LicensesClient.create(licensesSettings);
97  * }</pre>
98  *
99  * <p>To customize the endpoint:
100  *
101  * <pre>{@code
102  * // This snippet has been automatically generated and should be regarded as a code template only.
103  * // It will require modifications to work:
104  * // - It may require correct/in-range values for request initialization.
105  * // - It may require specifying regional endpoints when creating the service client as shown in
106  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
107  * LicensesSettings licensesSettings =
108  *     LicensesSettings.newBuilder().setEndpoint(myEndpoint).build();
109  * LicensesClient licensesClient = LicensesClient.create(licensesSettings);
110  * }</pre>
111  *
112  * <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
113  */
114 @Generated("by gapic-generator-java")
115 public class LicensesClient implements BackgroundResource {
116   private final LicensesSettings settings;
117   private final LicensesStub stub;
118 
119   /** Constructs an instance of LicensesClient with default settings. */
create()120   public static final LicensesClient create() throws IOException {
121     return create(LicensesSettings.newBuilder().build());
122   }
123 
124   /**
125    * Constructs an instance of LicensesClient, using the given settings. The channels are created
126    * based on the settings passed in, or defaults for any settings that are not set.
127    */
create(LicensesSettings settings)128   public static final LicensesClient create(LicensesSettings settings) throws IOException {
129     return new LicensesClient(settings);
130   }
131 
132   /**
133    * Constructs an instance of LicensesClient, using the given stub for making calls. This is for
134    * advanced usage - prefer using create(LicensesSettings).
135    */
create(LicensesStub stub)136   public static final LicensesClient create(LicensesStub stub) {
137     return new LicensesClient(stub);
138   }
139 
140   /**
141    * Constructs an instance of LicensesClient, using the given settings. This is protected so that
142    * it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
143    */
LicensesClient(LicensesSettings settings)144   protected LicensesClient(LicensesSettings settings) throws IOException {
145     this.settings = settings;
146     this.stub = ((LicensesStubSettings) settings.getStubSettings()).createStub();
147   }
148 
LicensesClient(LicensesStub stub)149   protected LicensesClient(LicensesStub stub) {
150     this.settings = null;
151     this.stub = stub;
152   }
153 
getSettings()154   public final LicensesSettings getSettings() {
155     return settings;
156   }
157 
getStub()158   public LicensesStub getStub() {
159     return stub;
160   }
161 
162   // AUTO-GENERATED DOCUMENTATION AND METHOD.
163   /**
164    * Deletes the specified license. &#42;Caution&#42; This resource is intended for use only by
165    * third-party partners who are creating Cloud Marketplace images.
166    *
167    * <p>Sample code:
168    *
169    * <pre>{@code
170    * // This snippet has been automatically generated and should be regarded as a code template only.
171    * // It will require modifications to work:
172    * // - It may require correct/in-range values for request initialization.
173    * // - It may require specifying regional endpoints when creating the service client as shown in
174    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
175    * try (LicensesClient licensesClient = LicensesClient.create()) {
176    *   String project = "project-309310695";
177    *   String license = "license166757441";
178    *   Operation response = licensesClient.deleteAsync(project, license).get();
179    * }
180    * }</pre>
181    *
182    * @param project Project ID for this request.
183    * @param license Name of the license resource to delete.
184    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
185    */
deleteAsync(String project, String license)186   public final OperationFuture<Operation, Operation> deleteAsync(String project, String license) {
187     DeleteLicenseRequest request =
188         DeleteLicenseRequest.newBuilder().setProject(project).setLicense(license).build();
189     return deleteAsync(request);
190   }
191 
192   // AUTO-GENERATED DOCUMENTATION AND METHOD.
193   /**
194    * Deletes the specified license. &#42;Caution&#42; This resource is intended for use only by
195    * third-party partners who are creating Cloud Marketplace images.
196    *
197    * <p>Sample code:
198    *
199    * <pre>{@code
200    * // This snippet has been automatically generated and should be regarded as a code template only.
201    * // It will require modifications to work:
202    * // - It may require correct/in-range values for request initialization.
203    * // - It may require specifying regional endpoints when creating the service client as shown in
204    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
205    * try (LicensesClient licensesClient = LicensesClient.create()) {
206    *   DeleteLicenseRequest request =
207    *       DeleteLicenseRequest.newBuilder()
208    *           .setLicense("license166757441")
209    *           .setProject("project-309310695")
210    *           .setRequestId("requestId693933066")
211    *           .build();
212    *   Operation response = licensesClient.deleteAsync(request).get();
213    * }
214    * }</pre>
215    *
216    * @param request The request object containing all of the parameters for the API call.
217    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
218    */
219   @BetaApi(
220       "The surface for long-running operations is not stable yet and may change in the future.")
deleteAsync(DeleteLicenseRequest request)221   public final OperationFuture<Operation, Operation> deleteAsync(DeleteLicenseRequest request) {
222     return deleteOperationCallable().futureCall(request);
223   }
224 
225   // AUTO-GENERATED DOCUMENTATION AND METHOD.
226   /**
227    * Deletes the specified license. &#42;Caution&#42; This resource is intended for use only by
228    * third-party partners who are creating Cloud Marketplace images.
229    *
230    * <p>Sample code:
231    *
232    * <pre>{@code
233    * // This snippet has been automatically generated and should be regarded as a code template only.
234    * // It will require modifications to work:
235    * // - It may require correct/in-range values for request initialization.
236    * // - It may require specifying regional endpoints when creating the service client as shown in
237    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
238    * try (LicensesClient licensesClient = LicensesClient.create()) {
239    *   DeleteLicenseRequest request =
240    *       DeleteLicenseRequest.newBuilder()
241    *           .setLicense("license166757441")
242    *           .setProject("project-309310695")
243    *           .setRequestId("requestId693933066")
244    *           .build();
245    *   OperationFuture<Operation, Operation> future =
246    *       licensesClient.deleteOperationCallable().futureCall(request);
247    *   // Do something.
248    *   Operation response = future.get();
249    * }
250    * }</pre>
251    */
252   public final OperationCallable<DeleteLicenseRequest, Operation, Operation>
deleteOperationCallable()253       deleteOperationCallable() {
254     return stub.deleteOperationCallable();
255   }
256 
257   // AUTO-GENERATED DOCUMENTATION AND METHOD.
258   /**
259    * Deletes the specified license. &#42;Caution&#42; This resource is intended for use only by
260    * third-party partners who are creating Cloud Marketplace images.
261    *
262    * <p>Sample code:
263    *
264    * <pre>{@code
265    * // This snippet has been automatically generated and should be regarded as a code template only.
266    * // It will require modifications to work:
267    * // - It may require correct/in-range values for request initialization.
268    * // - It may require specifying regional endpoints when creating the service client as shown in
269    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
270    * try (LicensesClient licensesClient = LicensesClient.create()) {
271    *   DeleteLicenseRequest request =
272    *       DeleteLicenseRequest.newBuilder()
273    *           .setLicense("license166757441")
274    *           .setProject("project-309310695")
275    *           .setRequestId("requestId693933066")
276    *           .build();
277    *   ApiFuture<Operation> future = licensesClient.deleteCallable().futureCall(request);
278    *   // Do something.
279    *   Operation response = future.get();
280    * }
281    * }</pre>
282    */
deleteCallable()283   public final UnaryCallable<DeleteLicenseRequest, Operation> deleteCallable() {
284     return stub.deleteCallable();
285   }
286 
287   // AUTO-GENERATED DOCUMENTATION AND METHOD.
288   /**
289    * Returns the specified License resource. &#42;Caution&#42; This resource is intended for use
290    * only by third-party partners who are creating Cloud Marketplace images.
291    *
292    * <p>Sample code:
293    *
294    * <pre>{@code
295    * // This snippet has been automatically generated and should be regarded as a code template only.
296    * // It will require modifications to work:
297    * // - It may require correct/in-range values for request initialization.
298    * // - It may require specifying regional endpoints when creating the service client as shown in
299    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
300    * try (LicensesClient licensesClient = LicensesClient.create()) {
301    *   String project = "project-309310695";
302    *   String license = "license166757441";
303    *   License response = licensesClient.get(project, license);
304    * }
305    * }</pre>
306    *
307    * @param project Project ID for this request.
308    * @param license Name of the License resource to return.
309    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
310    */
get(String project, String license)311   public final License get(String project, String license) {
312     GetLicenseRequest request =
313         GetLicenseRequest.newBuilder().setProject(project).setLicense(license).build();
314     return get(request);
315   }
316 
317   // AUTO-GENERATED DOCUMENTATION AND METHOD.
318   /**
319    * Returns the specified License resource. &#42;Caution&#42; This resource is intended for use
320    * only by third-party partners who are creating Cloud Marketplace images.
321    *
322    * <p>Sample code:
323    *
324    * <pre>{@code
325    * // This snippet has been automatically generated and should be regarded as a code template only.
326    * // It will require modifications to work:
327    * // - It may require correct/in-range values for request initialization.
328    * // - It may require specifying regional endpoints when creating the service client as shown in
329    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
330    * try (LicensesClient licensesClient = LicensesClient.create()) {
331    *   GetLicenseRequest request =
332    *       GetLicenseRequest.newBuilder()
333    *           .setLicense("license166757441")
334    *           .setProject("project-309310695")
335    *           .build();
336    *   License response = licensesClient.get(request);
337    * }
338    * }</pre>
339    *
340    * @param request The request object containing all of the parameters for the API call.
341    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
342    */
get(GetLicenseRequest request)343   public final License get(GetLicenseRequest request) {
344     return getCallable().call(request);
345   }
346 
347   // AUTO-GENERATED DOCUMENTATION AND METHOD.
348   /**
349    * Returns the specified License resource. &#42;Caution&#42; This resource is intended for use
350    * only by third-party partners who are creating Cloud Marketplace images.
351    *
352    * <p>Sample code:
353    *
354    * <pre>{@code
355    * // This snippet has been automatically generated and should be regarded as a code template only.
356    * // It will require modifications to work:
357    * // - It may require correct/in-range values for request initialization.
358    * // - It may require specifying regional endpoints when creating the service client as shown in
359    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
360    * try (LicensesClient licensesClient = LicensesClient.create()) {
361    *   GetLicenseRequest request =
362    *       GetLicenseRequest.newBuilder()
363    *           .setLicense("license166757441")
364    *           .setProject("project-309310695")
365    *           .build();
366    *   ApiFuture<License> future = licensesClient.getCallable().futureCall(request);
367    *   // Do something.
368    *   License response = future.get();
369    * }
370    * }</pre>
371    */
getCallable()372   public final UnaryCallable<GetLicenseRequest, License> getCallable() {
373     return stub.getCallable();
374   }
375 
376   // AUTO-GENERATED DOCUMENTATION AND METHOD.
377   /**
378    * Gets the access control policy for a resource. May be empty if no such policy or resource
379    * exists. &#42;Caution&#42; This resource is intended for use only by third-party partners who
380    * are creating Cloud Marketplace images.
381    *
382    * <p>Sample code:
383    *
384    * <pre>{@code
385    * // This snippet has been automatically generated and should be regarded as a code template only.
386    * // It will require modifications to work:
387    * // - It may require correct/in-range values for request initialization.
388    * // - It may require specifying regional endpoints when creating the service client as shown in
389    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
390    * try (LicensesClient licensesClient = LicensesClient.create()) {
391    *   String project = "project-309310695";
392    *   String resource = "resource-341064690";
393    *   Policy response = licensesClient.getIamPolicy(project, resource);
394    * }
395    * }</pre>
396    *
397    * @param project Project ID for this request.
398    * @param resource Name or id of the resource for this request.
399    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
400    */
getIamPolicy(String project, String resource)401   public final Policy getIamPolicy(String project, String resource) {
402     GetIamPolicyLicenseRequest request =
403         GetIamPolicyLicenseRequest.newBuilder().setProject(project).setResource(resource).build();
404     return getIamPolicy(request);
405   }
406 
407   // AUTO-GENERATED DOCUMENTATION AND METHOD.
408   /**
409    * Gets the access control policy for a resource. May be empty if no such policy or resource
410    * exists. &#42;Caution&#42; This resource is intended for use only by third-party partners who
411    * are creating Cloud Marketplace images.
412    *
413    * <p>Sample code:
414    *
415    * <pre>{@code
416    * // This snippet has been automatically generated and should be regarded as a code template only.
417    * // It will require modifications to work:
418    * // - It may require correct/in-range values for request initialization.
419    * // - It may require specifying regional endpoints when creating the service client as shown in
420    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
421    * try (LicensesClient licensesClient = LicensesClient.create()) {
422    *   GetIamPolicyLicenseRequest request =
423    *       GetIamPolicyLicenseRequest.newBuilder()
424    *           .setOptionsRequestedPolicyVersion(-574521795)
425    *           .setProject("project-309310695")
426    *           .setResource("resource-341064690")
427    *           .build();
428    *   Policy response = licensesClient.getIamPolicy(request);
429    * }
430    * }</pre>
431    *
432    * @param request The request object containing all of the parameters for the API call.
433    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
434    */
getIamPolicy(GetIamPolicyLicenseRequest request)435   public final Policy getIamPolicy(GetIamPolicyLicenseRequest request) {
436     return getIamPolicyCallable().call(request);
437   }
438 
439   // AUTO-GENERATED DOCUMENTATION AND METHOD.
440   /**
441    * Gets the access control policy for a resource. May be empty if no such policy or resource
442    * exists. &#42;Caution&#42; This resource is intended for use only by third-party partners who
443    * are creating Cloud Marketplace images.
444    *
445    * <p>Sample code:
446    *
447    * <pre>{@code
448    * // This snippet has been automatically generated and should be regarded as a code template only.
449    * // It will require modifications to work:
450    * // - It may require correct/in-range values for request initialization.
451    * // - It may require specifying regional endpoints when creating the service client as shown in
452    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
453    * try (LicensesClient licensesClient = LicensesClient.create()) {
454    *   GetIamPolicyLicenseRequest request =
455    *       GetIamPolicyLicenseRequest.newBuilder()
456    *           .setOptionsRequestedPolicyVersion(-574521795)
457    *           .setProject("project-309310695")
458    *           .setResource("resource-341064690")
459    *           .build();
460    *   ApiFuture<Policy> future = licensesClient.getIamPolicyCallable().futureCall(request);
461    *   // Do something.
462    *   Policy response = future.get();
463    * }
464    * }</pre>
465    */
getIamPolicyCallable()466   public final UnaryCallable<GetIamPolicyLicenseRequest, Policy> getIamPolicyCallable() {
467     return stub.getIamPolicyCallable();
468   }
469 
470   // AUTO-GENERATED DOCUMENTATION AND METHOD.
471   /**
472    * Create a License resource in the specified project. &#42;Caution&#42; This resource is intended
473    * for use only by third-party partners who are creating Cloud Marketplace images.
474    *
475    * <p>Sample code:
476    *
477    * <pre>{@code
478    * // This snippet has been automatically generated and should be regarded as a code template only.
479    * // It will require modifications to work:
480    * // - It may require correct/in-range values for request initialization.
481    * // - It may require specifying regional endpoints when creating the service client as shown in
482    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
483    * try (LicensesClient licensesClient = LicensesClient.create()) {
484    *   String project = "project-309310695";
485    *   License licenseResource = License.newBuilder().build();
486    *   Operation response = licensesClient.insertAsync(project, licenseResource).get();
487    * }
488    * }</pre>
489    *
490    * @param project Project ID for this request.
491    * @param licenseResource The body resource for this request
492    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
493    */
insertAsync( String project, License licenseResource)494   public final OperationFuture<Operation, Operation> insertAsync(
495       String project, License licenseResource) {
496     InsertLicenseRequest request =
497         InsertLicenseRequest.newBuilder()
498             .setProject(project)
499             .setLicenseResource(licenseResource)
500             .build();
501     return insertAsync(request);
502   }
503 
504   // AUTO-GENERATED DOCUMENTATION AND METHOD.
505   /**
506    * Create a License resource in the specified project. &#42;Caution&#42; This resource is intended
507    * for use only by third-party partners who are creating Cloud Marketplace images.
508    *
509    * <p>Sample code:
510    *
511    * <pre>{@code
512    * // This snippet has been automatically generated and should be regarded as a code template only.
513    * // It will require modifications to work:
514    * // - It may require correct/in-range values for request initialization.
515    * // - It may require specifying regional endpoints when creating the service client as shown in
516    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
517    * try (LicensesClient licensesClient = LicensesClient.create()) {
518    *   InsertLicenseRequest request =
519    *       InsertLicenseRequest.newBuilder()
520    *           .setLicenseResource(License.newBuilder().build())
521    *           .setProject("project-309310695")
522    *           .setRequestId("requestId693933066")
523    *           .build();
524    *   Operation response = licensesClient.insertAsync(request).get();
525    * }
526    * }</pre>
527    *
528    * @param request The request object containing all of the parameters for the API call.
529    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
530    */
531   @BetaApi(
532       "The surface for long-running operations is not stable yet and may change in the future.")
insertAsync(InsertLicenseRequest request)533   public final OperationFuture<Operation, Operation> insertAsync(InsertLicenseRequest request) {
534     return insertOperationCallable().futureCall(request);
535   }
536 
537   // AUTO-GENERATED DOCUMENTATION AND METHOD.
538   /**
539    * Create a License resource in the specified project. &#42;Caution&#42; This resource is intended
540    * for use only by third-party partners who are creating Cloud Marketplace images.
541    *
542    * <p>Sample code:
543    *
544    * <pre>{@code
545    * // This snippet has been automatically generated and should be regarded as a code template only.
546    * // It will require modifications to work:
547    * // - It may require correct/in-range values for request initialization.
548    * // - It may require specifying regional endpoints when creating the service client as shown in
549    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
550    * try (LicensesClient licensesClient = LicensesClient.create()) {
551    *   InsertLicenseRequest request =
552    *       InsertLicenseRequest.newBuilder()
553    *           .setLicenseResource(License.newBuilder().build())
554    *           .setProject("project-309310695")
555    *           .setRequestId("requestId693933066")
556    *           .build();
557    *   OperationFuture<Operation, Operation> future =
558    *       licensesClient.insertOperationCallable().futureCall(request);
559    *   // Do something.
560    *   Operation response = future.get();
561    * }
562    * }</pre>
563    */
564   public final OperationCallable<InsertLicenseRequest, Operation, Operation>
insertOperationCallable()565       insertOperationCallable() {
566     return stub.insertOperationCallable();
567   }
568 
569   // AUTO-GENERATED DOCUMENTATION AND METHOD.
570   /**
571    * Create a License resource in the specified project. &#42;Caution&#42; This resource is intended
572    * for use only by third-party partners who are creating Cloud Marketplace images.
573    *
574    * <p>Sample code:
575    *
576    * <pre>{@code
577    * // This snippet has been automatically generated and should be regarded as a code template only.
578    * // It will require modifications to work:
579    * // - It may require correct/in-range values for request initialization.
580    * // - It may require specifying regional endpoints when creating the service client as shown in
581    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
582    * try (LicensesClient licensesClient = LicensesClient.create()) {
583    *   InsertLicenseRequest request =
584    *       InsertLicenseRequest.newBuilder()
585    *           .setLicenseResource(License.newBuilder().build())
586    *           .setProject("project-309310695")
587    *           .setRequestId("requestId693933066")
588    *           .build();
589    *   ApiFuture<Operation> future = licensesClient.insertCallable().futureCall(request);
590    *   // Do something.
591    *   Operation response = future.get();
592    * }
593    * }</pre>
594    */
insertCallable()595   public final UnaryCallable<InsertLicenseRequest, Operation> insertCallable() {
596     return stub.insertCallable();
597   }
598 
599   // AUTO-GENERATED DOCUMENTATION AND METHOD.
600   /**
601    * Retrieves the list of licenses available in the specified project. This method does not get any
602    * licenses that belong to other projects, including licenses attached to publicly-available
603    * images, like Debian 9. If you want to get a list of publicly-available licenses, use this
604    * method to make a request to the respective image project, such as debian-cloud or
605    * windows-cloud. &#42;Caution&#42; This resource is intended for use only by third-party partners
606    * who are creating Cloud Marketplace images.
607    *
608    * <p>Sample code:
609    *
610    * <pre>{@code
611    * // This snippet has been automatically generated and should be regarded as a code template only.
612    * // It will require modifications to work:
613    * // - It may require correct/in-range values for request initialization.
614    * // - It may require specifying regional endpoints when creating the service client as shown in
615    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
616    * try (LicensesClient licensesClient = LicensesClient.create()) {
617    *   String project = "project-309310695";
618    *   for (License element : licensesClient.list(project).iterateAll()) {
619    *     // doThingsWith(element);
620    *   }
621    * }
622    * }</pre>
623    *
624    * @param project Project ID for this request.
625    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
626    */
list(String project)627   public final ListPagedResponse list(String project) {
628     ListLicensesRequest request = ListLicensesRequest.newBuilder().setProject(project).build();
629     return list(request);
630   }
631 
632   // AUTO-GENERATED DOCUMENTATION AND METHOD.
633   /**
634    * Retrieves the list of licenses available in the specified project. This method does not get any
635    * licenses that belong to other projects, including licenses attached to publicly-available
636    * images, like Debian 9. If you want to get a list of publicly-available licenses, use this
637    * method to make a request to the respective image project, such as debian-cloud or
638    * windows-cloud. &#42;Caution&#42; This resource is intended for use only by third-party partners
639    * who are creating Cloud Marketplace images.
640    *
641    * <p>Sample code:
642    *
643    * <pre>{@code
644    * // This snippet has been automatically generated and should be regarded as a code template only.
645    * // It will require modifications to work:
646    * // - It may require correct/in-range values for request initialization.
647    * // - It may require specifying regional endpoints when creating the service client as shown in
648    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
649    * try (LicensesClient licensesClient = LicensesClient.create()) {
650    *   ListLicensesRequest request =
651    *       ListLicensesRequest.newBuilder()
652    *           .setFilter("filter-1274492040")
653    *           .setMaxResults(1128457243)
654    *           .setOrderBy("orderBy-1207110587")
655    *           .setPageToken("pageToken873572522")
656    *           .setProject("project-309310695")
657    *           .setReturnPartialSuccess(true)
658    *           .build();
659    *   for (License element : licensesClient.list(request).iterateAll()) {
660    *     // doThingsWith(element);
661    *   }
662    * }
663    * }</pre>
664    *
665    * @param request The request object containing all of the parameters for the API call.
666    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
667    */
list(ListLicensesRequest request)668   public final ListPagedResponse list(ListLicensesRequest request) {
669     return listPagedCallable().call(request);
670   }
671 
672   // AUTO-GENERATED DOCUMENTATION AND METHOD.
673   /**
674    * Retrieves the list of licenses available in the specified project. This method does not get any
675    * licenses that belong to other projects, including licenses attached to publicly-available
676    * images, like Debian 9. If you want to get a list of publicly-available licenses, use this
677    * method to make a request to the respective image project, such as debian-cloud or
678    * windows-cloud. &#42;Caution&#42; This resource is intended for use only by third-party partners
679    * who are creating Cloud Marketplace images.
680    *
681    * <p>Sample code:
682    *
683    * <pre>{@code
684    * // This snippet has been automatically generated and should be regarded as a code template only.
685    * // It will require modifications to work:
686    * // - It may require correct/in-range values for request initialization.
687    * // - It may require specifying regional endpoints when creating the service client as shown in
688    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
689    * try (LicensesClient licensesClient = LicensesClient.create()) {
690    *   ListLicensesRequest request =
691    *       ListLicensesRequest.newBuilder()
692    *           .setFilter("filter-1274492040")
693    *           .setMaxResults(1128457243)
694    *           .setOrderBy("orderBy-1207110587")
695    *           .setPageToken("pageToken873572522")
696    *           .setProject("project-309310695")
697    *           .setReturnPartialSuccess(true)
698    *           .build();
699    *   ApiFuture<License> future = licensesClient.listPagedCallable().futureCall(request);
700    *   // Do something.
701    *   for (License element : future.get().iterateAll()) {
702    *     // doThingsWith(element);
703    *   }
704    * }
705    * }</pre>
706    */
listPagedCallable()707   public final UnaryCallable<ListLicensesRequest, ListPagedResponse> listPagedCallable() {
708     return stub.listPagedCallable();
709   }
710 
711   // AUTO-GENERATED DOCUMENTATION AND METHOD.
712   /**
713    * Retrieves the list of licenses available in the specified project. This method does not get any
714    * licenses that belong to other projects, including licenses attached to publicly-available
715    * images, like Debian 9. If you want to get a list of publicly-available licenses, use this
716    * method to make a request to the respective image project, such as debian-cloud or
717    * windows-cloud. &#42;Caution&#42; This resource is intended for use only by third-party partners
718    * who are creating Cloud Marketplace images.
719    *
720    * <p>Sample code:
721    *
722    * <pre>{@code
723    * // This snippet has been automatically generated and should be regarded as a code template only.
724    * // It will require modifications to work:
725    * // - It may require correct/in-range values for request initialization.
726    * // - It may require specifying regional endpoints when creating the service client as shown in
727    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
728    * try (LicensesClient licensesClient = LicensesClient.create()) {
729    *   ListLicensesRequest request =
730    *       ListLicensesRequest.newBuilder()
731    *           .setFilter("filter-1274492040")
732    *           .setMaxResults(1128457243)
733    *           .setOrderBy("orderBy-1207110587")
734    *           .setPageToken("pageToken873572522")
735    *           .setProject("project-309310695")
736    *           .setReturnPartialSuccess(true)
737    *           .build();
738    *   while (true) {
739    *     LicensesListResponse response = licensesClient.listCallable().call(request);
740    *     for (License element : response.getItemsList()) {
741    *       // doThingsWith(element);
742    *     }
743    *     String nextPageToken = response.getNextPageToken();
744    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
745    *       request = request.toBuilder().setPageToken(nextPageToken).build();
746    *     } else {
747    *       break;
748    *     }
749    *   }
750    * }
751    * }</pre>
752    */
listCallable()753   public final UnaryCallable<ListLicensesRequest, LicensesListResponse> listCallable() {
754     return stub.listCallable();
755   }
756 
757   // AUTO-GENERATED DOCUMENTATION AND METHOD.
758   /**
759    * Sets the access control policy on the specified resource. Replaces any existing policy.
760    * &#42;Caution&#42; This resource is intended for use only by third-party partners who are
761    * creating Cloud Marketplace images.
762    *
763    * <p>Sample code:
764    *
765    * <pre>{@code
766    * // This snippet has been automatically generated and should be regarded as a code template only.
767    * // It will require modifications to work:
768    * // - It may require correct/in-range values for request initialization.
769    * // - It may require specifying regional endpoints when creating the service client as shown in
770    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
771    * try (LicensesClient licensesClient = LicensesClient.create()) {
772    *   String project = "project-309310695";
773    *   String resource = "resource-341064690";
774    *   GlobalSetPolicyRequest globalSetPolicyRequestResource =
775    *       GlobalSetPolicyRequest.newBuilder().build();
776    *   Policy response =
777    *       licensesClient.setIamPolicy(project, resource, globalSetPolicyRequestResource);
778    * }
779    * }</pre>
780    *
781    * @param project Project ID for this request.
782    * @param resource Name or id of the resource for this request.
783    * @param globalSetPolicyRequestResource The body resource for this request
784    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
785    */
setIamPolicy( String project, String resource, GlobalSetPolicyRequest globalSetPolicyRequestResource)786   public final Policy setIamPolicy(
787       String project, String resource, GlobalSetPolicyRequest globalSetPolicyRequestResource) {
788     SetIamPolicyLicenseRequest request =
789         SetIamPolicyLicenseRequest.newBuilder()
790             .setProject(project)
791             .setResource(resource)
792             .setGlobalSetPolicyRequestResource(globalSetPolicyRequestResource)
793             .build();
794     return setIamPolicy(request);
795   }
796 
797   // AUTO-GENERATED DOCUMENTATION AND METHOD.
798   /**
799    * Sets the access control policy on the specified resource. Replaces any existing policy.
800    * &#42;Caution&#42; This resource is intended for use only by third-party partners who are
801    * creating Cloud Marketplace images.
802    *
803    * <p>Sample code:
804    *
805    * <pre>{@code
806    * // This snippet has been automatically generated and should be regarded as a code template only.
807    * // It will require modifications to work:
808    * // - It may require correct/in-range values for request initialization.
809    * // - It may require specifying regional endpoints when creating the service client as shown in
810    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
811    * try (LicensesClient licensesClient = LicensesClient.create()) {
812    *   SetIamPolicyLicenseRequest request =
813    *       SetIamPolicyLicenseRequest.newBuilder()
814    *           .setGlobalSetPolicyRequestResource(GlobalSetPolicyRequest.newBuilder().build())
815    *           .setProject("project-309310695")
816    *           .setResource("resource-341064690")
817    *           .build();
818    *   Policy response = licensesClient.setIamPolicy(request);
819    * }
820    * }</pre>
821    *
822    * @param request The request object containing all of the parameters for the API call.
823    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
824    */
setIamPolicy(SetIamPolicyLicenseRequest request)825   public final Policy setIamPolicy(SetIamPolicyLicenseRequest request) {
826     return setIamPolicyCallable().call(request);
827   }
828 
829   // AUTO-GENERATED DOCUMENTATION AND METHOD.
830   /**
831    * Sets the access control policy on the specified resource. Replaces any existing policy.
832    * &#42;Caution&#42; This resource is intended for use only by third-party partners who are
833    * creating Cloud Marketplace images.
834    *
835    * <p>Sample code:
836    *
837    * <pre>{@code
838    * // This snippet has been automatically generated and should be regarded as a code template only.
839    * // It will require modifications to work:
840    * // - It may require correct/in-range values for request initialization.
841    * // - It may require specifying regional endpoints when creating the service client as shown in
842    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
843    * try (LicensesClient licensesClient = LicensesClient.create()) {
844    *   SetIamPolicyLicenseRequest request =
845    *       SetIamPolicyLicenseRequest.newBuilder()
846    *           .setGlobalSetPolicyRequestResource(GlobalSetPolicyRequest.newBuilder().build())
847    *           .setProject("project-309310695")
848    *           .setResource("resource-341064690")
849    *           .build();
850    *   ApiFuture<Policy> future = licensesClient.setIamPolicyCallable().futureCall(request);
851    *   // Do something.
852    *   Policy response = future.get();
853    * }
854    * }</pre>
855    */
setIamPolicyCallable()856   public final UnaryCallable<SetIamPolicyLicenseRequest, Policy> setIamPolicyCallable() {
857     return stub.setIamPolicyCallable();
858   }
859 
860   // AUTO-GENERATED DOCUMENTATION AND METHOD.
861   /**
862    * Returns permissions that a caller has on the specified resource. &#42;Caution&#42; This
863    * resource is intended for use only by third-party partners who are creating Cloud Marketplace
864    * images.
865    *
866    * <p>Sample code:
867    *
868    * <pre>{@code
869    * // This snippet has been automatically generated and should be regarded as a code template only.
870    * // It will require modifications to work:
871    * // - It may require correct/in-range values for request initialization.
872    * // - It may require specifying regional endpoints when creating the service client as shown in
873    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
874    * try (LicensesClient licensesClient = LicensesClient.create()) {
875    *   String project = "project-309310695";
876    *   String resource = "resource-341064690";
877    *   TestPermissionsRequest testPermissionsRequestResource =
878    *       TestPermissionsRequest.newBuilder().build();
879    *   TestPermissionsResponse response =
880    *       licensesClient.testIamPermissions(project, resource, testPermissionsRequestResource);
881    * }
882    * }</pre>
883    *
884    * @param project Project ID for this request.
885    * @param resource Name or id of the resource for this request.
886    * @param testPermissionsRequestResource The body resource for this request
887    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
888    */
testIamPermissions( String project, String resource, TestPermissionsRequest testPermissionsRequestResource)889   public final TestPermissionsResponse testIamPermissions(
890       String project, String resource, TestPermissionsRequest testPermissionsRequestResource) {
891     TestIamPermissionsLicenseRequest request =
892         TestIamPermissionsLicenseRequest.newBuilder()
893             .setProject(project)
894             .setResource(resource)
895             .setTestPermissionsRequestResource(testPermissionsRequestResource)
896             .build();
897     return testIamPermissions(request);
898   }
899 
900   // AUTO-GENERATED DOCUMENTATION AND METHOD.
901   /**
902    * Returns permissions that a caller has on the specified resource. &#42;Caution&#42; This
903    * resource is intended for use only by third-party partners who are creating Cloud Marketplace
904    * images.
905    *
906    * <p>Sample code:
907    *
908    * <pre>{@code
909    * // This snippet has been automatically generated and should be regarded as a code template only.
910    * // It will require modifications to work:
911    * // - It may require correct/in-range values for request initialization.
912    * // - It may require specifying regional endpoints when creating the service client as shown in
913    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
914    * try (LicensesClient licensesClient = LicensesClient.create()) {
915    *   TestIamPermissionsLicenseRequest request =
916    *       TestIamPermissionsLicenseRequest.newBuilder()
917    *           .setProject("project-309310695")
918    *           .setResource("resource-341064690")
919    *           .setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build())
920    *           .build();
921    *   TestPermissionsResponse response = licensesClient.testIamPermissions(request);
922    * }
923    * }</pre>
924    *
925    * @param request The request object containing all of the parameters for the API call.
926    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
927    */
testIamPermissions( TestIamPermissionsLicenseRequest request)928   public final TestPermissionsResponse testIamPermissions(
929       TestIamPermissionsLicenseRequest request) {
930     return testIamPermissionsCallable().call(request);
931   }
932 
933   // AUTO-GENERATED DOCUMENTATION AND METHOD.
934   /**
935    * Returns permissions that a caller has on the specified resource. &#42;Caution&#42; This
936    * resource is intended for use only by third-party partners who are creating Cloud Marketplace
937    * images.
938    *
939    * <p>Sample code:
940    *
941    * <pre>{@code
942    * // This snippet has been automatically generated and should be regarded as a code template only.
943    * // It will require modifications to work:
944    * // - It may require correct/in-range values for request initialization.
945    * // - It may require specifying regional endpoints when creating the service client as shown in
946    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
947    * try (LicensesClient licensesClient = LicensesClient.create()) {
948    *   TestIamPermissionsLicenseRequest request =
949    *       TestIamPermissionsLicenseRequest.newBuilder()
950    *           .setProject("project-309310695")
951    *           .setResource("resource-341064690")
952    *           .setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build())
953    *           .build();
954    *   ApiFuture<TestPermissionsResponse> future =
955    *       licensesClient.testIamPermissionsCallable().futureCall(request);
956    *   // Do something.
957    *   TestPermissionsResponse response = future.get();
958    * }
959    * }</pre>
960    */
961   public final UnaryCallable<TestIamPermissionsLicenseRequest, TestPermissionsResponse>
testIamPermissionsCallable()962       testIamPermissionsCallable() {
963     return stub.testIamPermissionsCallable();
964   }
965 
966   @Override
close()967   public final void close() {
968     stub.close();
969   }
970 
971   @Override
shutdown()972   public void shutdown() {
973     stub.shutdown();
974   }
975 
976   @Override
isShutdown()977   public boolean isShutdown() {
978     return stub.isShutdown();
979   }
980 
981   @Override
isTerminated()982   public boolean isTerminated() {
983     return stub.isTerminated();
984   }
985 
986   @Override
shutdownNow()987   public void shutdownNow() {
988     stub.shutdownNow();
989   }
990 
991   @Override
awaitTermination(long duration, TimeUnit unit)992   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
993     return stub.awaitTermination(duration, unit);
994   }
995 
996   public static class ListPagedResponse
997       extends AbstractPagedListResponse<
998           ListLicensesRequest, LicensesListResponse, License, ListPage, ListFixedSizeCollection> {
999 
createAsync( PageContext<ListLicensesRequest, LicensesListResponse, License> context, ApiFuture<LicensesListResponse> futureResponse)1000     public static ApiFuture<ListPagedResponse> createAsync(
1001         PageContext<ListLicensesRequest, LicensesListResponse, License> context,
1002         ApiFuture<LicensesListResponse> futureResponse) {
1003       ApiFuture<ListPage> futurePage =
1004           ListPage.createEmptyPage().createPageAsync(context, futureResponse);
1005       return ApiFutures.transform(
1006           futurePage, input -> new ListPagedResponse(input), MoreExecutors.directExecutor());
1007     }
1008 
ListPagedResponse(ListPage page)1009     private ListPagedResponse(ListPage page) {
1010       super(page, ListFixedSizeCollection.createEmptyCollection());
1011     }
1012   }
1013 
1014   public static class ListPage
1015       extends AbstractPage<ListLicensesRequest, LicensesListResponse, License, ListPage> {
1016 
ListPage( PageContext<ListLicensesRequest, LicensesListResponse, License> context, LicensesListResponse response)1017     private ListPage(
1018         PageContext<ListLicensesRequest, LicensesListResponse, License> context,
1019         LicensesListResponse response) {
1020       super(context, response);
1021     }
1022 
createEmptyPage()1023     private static ListPage createEmptyPage() {
1024       return new ListPage(null, null);
1025     }
1026 
1027     @Override
createPage( PageContext<ListLicensesRequest, LicensesListResponse, License> context, LicensesListResponse response)1028     protected ListPage createPage(
1029         PageContext<ListLicensesRequest, LicensesListResponse, License> context,
1030         LicensesListResponse response) {
1031       return new ListPage(context, response);
1032     }
1033 
1034     @Override
createPageAsync( PageContext<ListLicensesRequest, LicensesListResponse, License> context, ApiFuture<LicensesListResponse> futureResponse)1035     public ApiFuture<ListPage> createPageAsync(
1036         PageContext<ListLicensesRequest, LicensesListResponse, License> context,
1037         ApiFuture<LicensesListResponse> futureResponse) {
1038       return super.createPageAsync(context, futureResponse);
1039     }
1040   }
1041 
1042   public static class ListFixedSizeCollection
1043       extends AbstractFixedSizeCollection<
1044           ListLicensesRequest, LicensesListResponse, License, ListPage, ListFixedSizeCollection> {
1045 
ListFixedSizeCollection(List<ListPage> pages, int collectionSize)1046     private ListFixedSizeCollection(List<ListPage> pages, int collectionSize) {
1047       super(pages, collectionSize);
1048     }
1049 
createEmptyCollection()1050     private static ListFixedSizeCollection createEmptyCollection() {
1051       return new ListFixedSizeCollection(null, 0);
1052     }
1053 
1054     @Override
createCollection(List<ListPage> pages, int collectionSize)1055     protected ListFixedSizeCollection createCollection(List<ListPage> pages, int collectionSize) {
1056       return new ListFixedSizeCollection(pages, collectionSize);
1057     }
1058   }
1059 }
1060