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