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