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.recommender.v1; 18 19 import com.google.api.core.ApiFuture; 20 import com.google.api.core.ApiFutures; 21 import com.google.api.gax.core.BackgroundResource; 22 import com.google.api.gax.paging.AbstractFixedSizeCollection; 23 import com.google.api.gax.paging.AbstractPage; 24 import com.google.api.gax.paging.AbstractPagedListResponse; 25 import com.google.api.gax.rpc.PageContext; 26 import com.google.api.gax.rpc.UnaryCallable; 27 import com.google.cloud.recommender.v1.stub.RecommenderStub; 28 import com.google.cloud.recommender.v1.stub.RecommenderStubSettings; 29 import com.google.common.util.concurrent.MoreExecutors; 30 import com.google.protobuf.FieldMask; 31 import java.io.IOException; 32 import java.util.List; 33 import java.util.Map; 34 import java.util.concurrent.TimeUnit; 35 import javax.annotation.Generated; 36 37 // AUTO-GENERATED DOCUMENTATION AND CLASS. 38 /** 39 * Service Description: Provides insights and recommendations for cloud customers for various 40 * categories like performance optimization, cost savings, reliability, feature discovery, etc. 41 * Insights and recommendations are generated automatically based on analysis of user resources, 42 * configuration and monitoring metrics. 43 * 44 * <p>This class provides the ability to make remote calls to the backing service through method 45 * calls that map to API methods. Sample code to get started: 46 * 47 * <pre>{@code 48 * // This snippet has been automatically generated and should be regarded as a code template only. 49 * // It will require modifications to work: 50 * // - It may require correct/in-range values for request initialization. 51 * // - It may require specifying regional endpoints when creating the service client as shown in 52 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 53 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 54 * InsightName name = 55 * InsightName.ofProjectLocationInsightTypeInsightName( 56 * "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]"); 57 * Insight response = recommenderClient.getInsight(name); 58 * } 59 * }</pre> 60 * 61 * <p>Note: close() needs to be called on the RecommenderClient object to clean up resources such as 62 * threads. In the example above, try-with-resources is used, which automatically calls close(). 63 * 64 * <p>The surface of this class includes several types of Java methods for each of the API's 65 * methods: 66 * 67 * <ol> 68 * <li>A "flattened" method. With this type of method, the fields of the request type have been 69 * converted into function parameters. It may be the case that not all fields are available as 70 * parameters, and not every API method will have a flattened method entry point. 71 * <li>A "request object" method. This type of method only takes one parameter, a request object, 72 * which must be constructed before the call. Not every API method will have a request object 73 * method. 74 * <li>A "callable" method. This type of method takes no parameters and returns an immutable API 75 * callable object, which can be used to initiate calls to the service. 76 * </ol> 77 * 78 * <p>See the individual methods for example code. 79 * 80 * <p>Many parameters require resource names to be formatted in a particular way. To assist with 81 * these names, this class includes a format method for each type of name, and additionally a parse 82 * method to extract the individual identifiers contained within names that are returned. 83 * 84 * <p>This class can be customized by passing in a custom instance of RecommenderSettings to 85 * create(). For example: 86 * 87 * <p>To customize credentials: 88 * 89 * <pre>{@code 90 * // This snippet has been automatically generated and should be regarded as a code template only. 91 * // It will require modifications to work: 92 * // - It may require correct/in-range values for request initialization. 93 * // - It may require specifying regional endpoints when creating the service client as shown in 94 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 95 * RecommenderSettings recommenderSettings = 96 * RecommenderSettings.newBuilder() 97 * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) 98 * .build(); 99 * RecommenderClient recommenderClient = RecommenderClient.create(recommenderSettings); 100 * }</pre> 101 * 102 * <p>To customize the endpoint: 103 * 104 * <pre>{@code 105 * // This snippet has been automatically generated and should be regarded as a code template only. 106 * // It will require modifications to work: 107 * // - It may require correct/in-range values for request initialization. 108 * // - It may require specifying regional endpoints when creating the service client as shown in 109 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 110 * RecommenderSettings recommenderSettings = 111 * RecommenderSettings.newBuilder().setEndpoint(myEndpoint).build(); 112 * RecommenderClient recommenderClient = RecommenderClient.create(recommenderSettings); 113 * }</pre> 114 * 115 * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over 116 * the wire: 117 * 118 * <pre>{@code 119 * // This snippet has been automatically generated and should be regarded as a code template only. 120 * // It will require modifications to work: 121 * // - It may require correct/in-range values for request initialization. 122 * // - It may require specifying regional endpoints when creating the service client as shown in 123 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 124 * RecommenderSettings recommenderSettings = RecommenderSettings.newHttpJsonBuilder().build(); 125 * RecommenderClient recommenderClient = RecommenderClient.create(recommenderSettings); 126 * }</pre> 127 * 128 * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. 129 */ 130 @Generated("by gapic-generator-java") 131 public class RecommenderClient implements BackgroundResource { 132 private final RecommenderSettings settings; 133 private final RecommenderStub stub; 134 135 /** Constructs an instance of RecommenderClient with default settings. */ create()136 public static final RecommenderClient create() throws IOException { 137 return create(RecommenderSettings.newBuilder().build()); 138 } 139 140 /** 141 * Constructs an instance of RecommenderClient, using the given settings. The channels are created 142 * based on the settings passed in, or defaults for any settings that are not set. 143 */ create(RecommenderSettings settings)144 public static final RecommenderClient create(RecommenderSettings settings) throws IOException { 145 return new RecommenderClient(settings); 146 } 147 148 /** 149 * Constructs an instance of RecommenderClient, using the given stub for making calls. This is for 150 * advanced usage - prefer using create(RecommenderSettings). 151 */ create(RecommenderStub stub)152 public static final RecommenderClient create(RecommenderStub stub) { 153 return new RecommenderClient(stub); 154 } 155 156 /** 157 * Constructs an instance of RecommenderClient, using the given settings. This is protected so 158 * that it is easy to make a subclass, but otherwise, the static factory methods should be 159 * preferred. 160 */ RecommenderClient(RecommenderSettings settings)161 protected RecommenderClient(RecommenderSettings settings) throws IOException { 162 this.settings = settings; 163 this.stub = ((RecommenderStubSettings) settings.getStubSettings()).createStub(); 164 } 165 RecommenderClient(RecommenderStub stub)166 protected RecommenderClient(RecommenderStub stub) { 167 this.settings = null; 168 this.stub = stub; 169 } 170 getSettings()171 public final RecommenderSettings getSettings() { 172 return settings; 173 } 174 getStub()175 public RecommenderStub getStub() { 176 return stub; 177 } 178 179 // AUTO-GENERATED DOCUMENTATION AND METHOD. 180 /** 181 * Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM 182 * permission for the specified insight type. 183 * 184 * <p>Sample code: 185 * 186 * <pre>{@code 187 * // This snippet has been automatically generated and should be regarded as a code template only. 188 * // It will require modifications to work: 189 * // - It may require correct/in-range values for request initialization. 190 * // - It may require specifying regional endpoints when creating the service client as shown in 191 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 192 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 193 * InsightTypeName parent = 194 * InsightTypeName.ofProjectLocationInsightTypeName( 195 * "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]"); 196 * for (Insight element : recommenderClient.listInsights(parent).iterateAll()) { 197 * // doThingsWith(element); 198 * } 199 * } 200 * }</pre> 201 * 202 * @param parent Required. The container resource on which to execute the request. Acceptable 203 * formats: 204 * <ul> 205 * <li>`projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` 206 * </ul> 207 * <ul> 208 * <li>`projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` 209 * </ul> 210 * <ul> 211 * <li>`billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` 212 * </ul> 213 * <ul> 214 * <li>`folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` 215 * </ul> 216 * <ul> 217 * <li>`organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` 218 * </ul> 219 * <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ 220 * INSIGHT_TYPE_ID refers to supported insight types: 221 * https://cloud.google.com/recommender/docs/insights/insight-types. 222 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 223 */ listInsights(InsightTypeName parent)224 public final ListInsightsPagedResponse listInsights(InsightTypeName parent) { 225 ListInsightsRequest request = 226 ListInsightsRequest.newBuilder() 227 .setParent(parent == null ? null : parent.toString()) 228 .build(); 229 return listInsights(request); 230 } 231 232 // AUTO-GENERATED DOCUMENTATION AND METHOD. 233 /** 234 * Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM 235 * permission for the specified insight type. 236 * 237 * <p>Sample code: 238 * 239 * <pre>{@code 240 * // This snippet has been automatically generated and should be regarded as a code template only. 241 * // It will require modifications to work: 242 * // - It may require correct/in-range values for request initialization. 243 * // - It may require specifying regional endpoints when creating the service client as shown in 244 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 245 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 246 * String parent = 247 * InsightTypeName.ofProjectLocationInsightTypeName( 248 * "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]") 249 * .toString(); 250 * for (Insight element : recommenderClient.listInsights(parent).iterateAll()) { 251 * // doThingsWith(element); 252 * } 253 * } 254 * }</pre> 255 * 256 * @param parent Required. The container resource on which to execute the request. Acceptable 257 * formats: 258 * <ul> 259 * <li>`projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` 260 * </ul> 261 * <ul> 262 * <li>`projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` 263 * </ul> 264 * <ul> 265 * <li>`billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` 266 * </ul> 267 * <ul> 268 * <li>`folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` 269 * </ul> 270 * <ul> 271 * <li>`organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` 272 * </ul> 273 * <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ 274 * INSIGHT_TYPE_ID refers to supported insight types: 275 * https://cloud.google.com/recommender/docs/insights/insight-types. 276 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 277 */ listInsights(String parent)278 public final ListInsightsPagedResponse listInsights(String parent) { 279 ListInsightsRequest request = ListInsightsRequest.newBuilder().setParent(parent).build(); 280 return listInsights(request); 281 } 282 283 // AUTO-GENERATED DOCUMENTATION AND METHOD. 284 /** 285 * Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM 286 * permission for the specified insight type. 287 * 288 * <p>Sample code: 289 * 290 * <pre>{@code 291 * // This snippet has been automatically generated and should be regarded as a code template only. 292 * // It will require modifications to work: 293 * // - It may require correct/in-range values for request initialization. 294 * // - It may require specifying regional endpoints when creating the service client as shown in 295 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 296 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 297 * ListInsightsRequest request = 298 * ListInsightsRequest.newBuilder() 299 * .setParent( 300 * InsightTypeName.ofProjectLocationInsightTypeName( 301 * "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]") 302 * .toString()) 303 * .setPageSize(883849137) 304 * .setPageToken("pageToken873572522") 305 * .setFilter("filter-1274492040") 306 * .build(); 307 * for (Insight element : recommenderClient.listInsights(request).iterateAll()) { 308 * // doThingsWith(element); 309 * } 310 * } 311 * }</pre> 312 * 313 * @param request The request object containing all of the parameters for the API call. 314 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 315 */ listInsights(ListInsightsRequest request)316 public final ListInsightsPagedResponse listInsights(ListInsightsRequest request) { 317 return listInsightsPagedCallable().call(request); 318 } 319 320 // AUTO-GENERATED DOCUMENTATION AND METHOD. 321 /** 322 * Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM 323 * permission for the specified insight type. 324 * 325 * <p>Sample code: 326 * 327 * <pre>{@code 328 * // This snippet has been automatically generated and should be regarded as a code template only. 329 * // It will require modifications to work: 330 * // - It may require correct/in-range values for request initialization. 331 * // - It may require specifying regional endpoints when creating the service client as shown in 332 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 333 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 334 * ListInsightsRequest request = 335 * ListInsightsRequest.newBuilder() 336 * .setParent( 337 * InsightTypeName.ofProjectLocationInsightTypeName( 338 * "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]") 339 * .toString()) 340 * .setPageSize(883849137) 341 * .setPageToken("pageToken873572522") 342 * .setFilter("filter-1274492040") 343 * .build(); 344 * ApiFuture<Insight> future = recommenderClient.listInsightsPagedCallable().futureCall(request); 345 * // Do something. 346 * for (Insight element : future.get().iterateAll()) { 347 * // doThingsWith(element); 348 * } 349 * } 350 * }</pre> 351 */ 352 public final UnaryCallable<ListInsightsRequest, ListInsightsPagedResponse> listInsightsPagedCallable()353 listInsightsPagedCallable() { 354 return stub.listInsightsPagedCallable(); 355 } 356 357 // AUTO-GENERATED DOCUMENTATION AND METHOD. 358 /** 359 * Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM 360 * permission for the specified insight type. 361 * 362 * <p>Sample code: 363 * 364 * <pre>{@code 365 * // This snippet has been automatically generated and should be regarded as a code template only. 366 * // It will require modifications to work: 367 * // - It may require correct/in-range values for request initialization. 368 * // - It may require specifying regional endpoints when creating the service client as shown in 369 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 370 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 371 * ListInsightsRequest request = 372 * ListInsightsRequest.newBuilder() 373 * .setParent( 374 * InsightTypeName.ofProjectLocationInsightTypeName( 375 * "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]") 376 * .toString()) 377 * .setPageSize(883849137) 378 * .setPageToken("pageToken873572522") 379 * .setFilter("filter-1274492040") 380 * .build(); 381 * while (true) { 382 * ListInsightsResponse response = recommenderClient.listInsightsCallable().call(request); 383 * for (Insight element : response.getInsightsList()) { 384 * // doThingsWith(element); 385 * } 386 * String nextPageToken = response.getNextPageToken(); 387 * if (!Strings.isNullOrEmpty(nextPageToken)) { 388 * request = request.toBuilder().setPageToken(nextPageToken).build(); 389 * } else { 390 * break; 391 * } 392 * } 393 * } 394 * }</pre> 395 */ listInsightsCallable()396 public final UnaryCallable<ListInsightsRequest, ListInsightsResponse> listInsightsCallable() { 397 return stub.listInsightsCallable(); 398 } 399 400 // AUTO-GENERATED DOCUMENTATION AND METHOD. 401 /** 402 * Gets the requested insight. Requires the recommender.*.get IAM permission for the specified 403 * insight type. 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 (RecommenderClient recommenderClient = RecommenderClient.create()) { 414 * InsightName name = 415 * InsightName.ofProjectLocationInsightTypeInsightName( 416 * "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]"); 417 * Insight response = recommenderClient.getInsight(name); 418 * } 419 * }</pre> 420 * 421 * @param name Required. Name of the insight. 422 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 423 */ getInsight(InsightName name)424 public final Insight getInsight(InsightName name) { 425 GetInsightRequest request = 426 GetInsightRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 427 return getInsight(request); 428 } 429 430 // AUTO-GENERATED DOCUMENTATION AND METHOD. 431 /** 432 * Gets the requested insight. Requires the recommender.*.get IAM permission for the specified 433 * insight type. 434 * 435 * <p>Sample code: 436 * 437 * <pre>{@code 438 * // This snippet has been automatically generated and should be regarded as a code template only. 439 * // It will require modifications to work: 440 * // - It may require correct/in-range values for request initialization. 441 * // - It may require specifying regional endpoints when creating the service client as shown in 442 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 443 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 444 * String name = 445 * InsightName.ofProjectLocationInsightTypeInsightName( 446 * "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") 447 * .toString(); 448 * Insight response = recommenderClient.getInsight(name); 449 * } 450 * }</pre> 451 * 452 * @param name Required. Name of the insight. 453 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 454 */ getInsight(String name)455 public final Insight getInsight(String name) { 456 GetInsightRequest request = GetInsightRequest.newBuilder().setName(name).build(); 457 return getInsight(request); 458 } 459 460 // AUTO-GENERATED DOCUMENTATION AND METHOD. 461 /** 462 * Gets the requested insight. Requires the recommender.*.get IAM permission for the specified 463 * insight type. 464 * 465 * <p>Sample code: 466 * 467 * <pre>{@code 468 * // This snippet has been automatically generated and should be regarded as a code template only. 469 * // It will require modifications to work: 470 * // - It may require correct/in-range values for request initialization. 471 * // - It may require specifying regional endpoints when creating the service client as shown in 472 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 473 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 474 * GetInsightRequest request = 475 * GetInsightRequest.newBuilder() 476 * .setName( 477 * InsightName.ofProjectLocationInsightTypeInsightName( 478 * "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") 479 * .toString()) 480 * .build(); 481 * Insight response = recommenderClient.getInsight(request); 482 * } 483 * }</pre> 484 * 485 * @param request The request object containing all of the parameters for the API call. 486 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 487 */ getInsight(GetInsightRequest request)488 public final Insight getInsight(GetInsightRequest request) { 489 return getInsightCallable().call(request); 490 } 491 492 // AUTO-GENERATED DOCUMENTATION AND METHOD. 493 /** 494 * Gets the requested insight. Requires the recommender.*.get IAM permission for the specified 495 * insight type. 496 * 497 * <p>Sample code: 498 * 499 * <pre>{@code 500 * // This snippet has been automatically generated and should be regarded as a code template only. 501 * // It will require modifications to work: 502 * // - It may require correct/in-range values for request initialization. 503 * // - It may require specifying regional endpoints when creating the service client as shown in 504 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 505 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 506 * GetInsightRequest request = 507 * GetInsightRequest.newBuilder() 508 * .setName( 509 * InsightName.ofProjectLocationInsightTypeInsightName( 510 * "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") 511 * .toString()) 512 * .build(); 513 * ApiFuture<Insight> future = recommenderClient.getInsightCallable().futureCall(request); 514 * // Do something. 515 * Insight response = future.get(); 516 * } 517 * }</pre> 518 */ getInsightCallable()519 public final UnaryCallable<GetInsightRequest, Insight> getInsightCallable() { 520 return stub.getInsightCallable(); 521 } 522 523 // AUTO-GENERATED DOCUMENTATION AND METHOD. 524 /** 525 * Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender 526 * API that they have applied some action based on the insight. This stops the insight content 527 * from being updated. 528 * 529 * <p>MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the 530 * recommender.*.update IAM permission for the specified insight. 531 * 532 * <p>Sample code: 533 * 534 * <pre>{@code 535 * // This snippet has been automatically generated and should be regarded as a code template only. 536 * // It will require modifications to work: 537 * // - It may require correct/in-range values for request initialization. 538 * // - It may require specifying regional endpoints when creating the service client as shown in 539 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 540 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 541 * InsightName name = 542 * InsightName.ofProjectLocationInsightTypeInsightName( 543 * "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]"); 544 * Map<String, String> stateMetadata = new HashMap<>(); 545 * String etag = "etag3123477"; 546 * Insight response = recommenderClient.markInsightAccepted(name, stateMetadata, etag); 547 * } 548 * }</pre> 549 * 550 * @param name Required. Name of the insight. 551 * @param stateMetadata Optional. State properties user wish to include with this state. Full 552 * replace of the current state_metadata. 553 * @param etag Required. Fingerprint of the Insight. Provides optimistic locking. 554 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 555 */ markInsightAccepted( InsightName name, Map<String, String> stateMetadata, String etag)556 public final Insight markInsightAccepted( 557 InsightName name, Map<String, String> stateMetadata, String etag) { 558 MarkInsightAcceptedRequest request = 559 MarkInsightAcceptedRequest.newBuilder() 560 .setName(name == null ? null : name.toString()) 561 .putAllStateMetadata(stateMetadata) 562 .setEtag(etag) 563 .build(); 564 return markInsightAccepted(request); 565 } 566 567 // AUTO-GENERATED DOCUMENTATION AND METHOD. 568 /** 569 * Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender 570 * API that they have applied some action based on the insight. This stops the insight content 571 * from being updated. 572 * 573 * <p>MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the 574 * recommender.*.update IAM permission for the specified insight. 575 * 576 * <p>Sample code: 577 * 578 * <pre>{@code 579 * // This snippet has been automatically generated and should be regarded as a code template only. 580 * // It will require modifications to work: 581 * // - It may require correct/in-range values for request initialization. 582 * // - It may require specifying regional endpoints when creating the service client as shown in 583 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 584 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 585 * String name = 586 * InsightName.ofProjectLocationInsightTypeInsightName( 587 * "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") 588 * .toString(); 589 * Map<String, String> stateMetadata = new HashMap<>(); 590 * String etag = "etag3123477"; 591 * Insight response = recommenderClient.markInsightAccepted(name, stateMetadata, etag); 592 * } 593 * }</pre> 594 * 595 * @param name Required. Name of the insight. 596 * @param stateMetadata Optional. State properties user wish to include with this state. Full 597 * replace of the current state_metadata. 598 * @param etag Required. Fingerprint of the Insight. Provides optimistic locking. 599 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 600 */ markInsightAccepted( String name, Map<String, String> stateMetadata, String etag)601 public final Insight markInsightAccepted( 602 String name, Map<String, String> stateMetadata, String etag) { 603 MarkInsightAcceptedRequest request = 604 MarkInsightAcceptedRequest.newBuilder() 605 .setName(name) 606 .putAllStateMetadata(stateMetadata) 607 .setEtag(etag) 608 .build(); 609 return markInsightAccepted(request); 610 } 611 612 // AUTO-GENERATED DOCUMENTATION AND METHOD. 613 /** 614 * Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender 615 * API that they have applied some action based on the insight. This stops the insight content 616 * from being updated. 617 * 618 * <p>MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the 619 * recommender.*.update IAM permission for the specified insight. 620 * 621 * <p>Sample code: 622 * 623 * <pre>{@code 624 * // This snippet has been automatically generated and should be regarded as a code template only. 625 * // It will require modifications to work: 626 * // - It may require correct/in-range values for request initialization. 627 * // - It may require specifying regional endpoints when creating the service client as shown in 628 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 629 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 630 * MarkInsightAcceptedRequest request = 631 * MarkInsightAcceptedRequest.newBuilder() 632 * .setName( 633 * InsightName.ofProjectLocationInsightTypeInsightName( 634 * "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") 635 * .toString()) 636 * .putAllStateMetadata(new HashMap<String, String>()) 637 * .setEtag("etag3123477") 638 * .build(); 639 * Insight response = recommenderClient.markInsightAccepted(request); 640 * } 641 * }</pre> 642 * 643 * @param request The request object containing all of the parameters for the API call. 644 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 645 */ markInsightAccepted(MarkInsightAcceptedRequest request)646 public final Insight markInsightAccepted(MarkInsightAcceptedRequest request) { 647 return markInsightAcceptedCallable().call(request); 648 } 649 650 // AUTO-GENERATED DOCUMENTATION AND METHOD. 651 /** 652 * Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender 653 * API that they have applied some action based on the insight. This stops the insight content 654 * from being updated. 655 * 656 * <p>MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the 657 * recommender.*.update IAM permission for the specified insight. 658 * 659 * <p>Sample code: 660 * 661 * <pre>{@code 662 * // This snippet has been automatically generated and should be regarded as a code template only. 663 * // It will require modifications to work: 664 * // - It may require correct/in-range values for request initialization. 665 * // - It may require specifying regional endpoints when creating the service client as shown in 666 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 667 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 668 * MarkInsightAcceptedRequest request = 669 * MarkInsightAcceptedRequest.newBuilder() 670 * .setName( 671 * InsightName.ofProjectLocationInsightTypeInsightName( 672 * "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") 673 * .toString()) 674 * .putAllStateMetadata(new HashMap<String, String>()) 675 * .setEtag("etag3123477") 676 * .build(); 677 * ApiFuture<Insight> future = 678 * recommenderClient.markInsightAcceptedCallable().futureCall(request); 679 * // Do something. 680 * Insight response = future.get(); 681 * } 682 * }</pre> 683 */ markInsightAcceptedCallable()684 public final UnaryCallable<MarkInsightAcceptedRequest, Insight> markInsightAcceptedCallable() { 685 return stub.markInsightAcceptedCallable(); 686 } 687 688 // AUTO-GENERATED DOCUMENTATION AND METHOD. 689 /** 690 * Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM 691 * permission for the specified recommender. 692 * 693 * <p>Sample code: 694 * 695 * <pre>{@code 696 * // This snippet has been automatically generated and should be regarded as a code template only. 697 * // It will require modifications to work: 698 * // - It may require correct/in-range values for request initialization. 699 * // - It may require specifying regional endpoints when creating the service client as shown in 700 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 701 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 702 * RecommenderName parent = 703 * RecommenderName.ofProjectLocationRecommenderName( 704 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]"); 705 * for (Recommendation element : recommenderClient.listRecommendations(parent).iterateAll()) { 706 * // doThingsWith(element); 707 * } 708 * } 709 * }</pre> 710 * 711 * @param parent Required. The container resource on which to execute the request. Acceptable 712 * formats: 713 * <ul> 714 * <li>`projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` 715 * </ul> 716 * <ul> 717 * <li>`projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` 718 * </ul> 719 * <ul> 720 * <li>`billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` 721 * </ul> 722 * <ul> 723 * <li>`folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` 724 * </ul> 725 * <ul> 726 * <li>`organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` 727 * </ul> 728 * <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ 729 * RECOMMENDER_ID refers to supported recommenders: 730 * https://cloud.google.com/recommender/docs/recommenders. 731 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 732 */ listRecommendations(RecommenderName parent)733 public final ListRecommendationsPagedResponse listRecommendations(RecommenderName parent) { 734 ListRecommendationsRequest request = 735 ListRecommendationsRequest.newBuilder() 736 .setParent(parent == null ? null : parent.toString()) 737 .build(); 738 return listRecommendations(request); 739 } 740 741 // AUTO-GENERATED DOCUMENTATION AND METHOD. 742 /** 743 * Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM 744 * permission for the specified recommender. 745 * 746 * <p>Sample code: 747 * 748 * <pre>{@code 749 * // This snippet has been automatically generated and should be regarded as a code template only. 750 * // It will require modifications to work: 751 * // - It may require correct/in-range values for request initialization. 752 * // - It may require specifying regional endpoints when creating the service client as shown in 753 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 754 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 755 * String parent = 756 * RecommenderName.ofProjectLocationRecommenderName( 757 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") 758 * .toString(); 759 * for (Recommendation element : recommenderClient.listRecommendations(parent).iterateAll()) { 760 * // doThingsWith(element); 761 * } 762 * } 763 * }</pre> 764 * 765 * @param parent Required. The container resource on which to execute the request. Acceptable 766 * formats: 767 * <ul> 768 * <li>`projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` 769 * </ul> 770 * <ul> 771 * <li>`projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` 772 * </ul> 773 * <ul> 774 * <li>`billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` 775 * </ul> 776 * <ul> 777 * <li>`folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` 778 * </ul> 779 * <ul> 780 * <li>`organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` 781 * </ul> 782 * <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ 783 * RECOMMENDER_ID refers to supported recommenders: 784 * https://cloud.google.com/recommender/docs/recommenders. 785 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 786 */ listRecommendations(String parent)787 public final ListRecommendationsPagedResponse listRecommendations(String parent) { 788 ListRecommendationsRequest request = 789 ListRecommendationsRequest.newBuilder().setParent(parent).build(); 790 return listRecommendations(request); 791 } 792 793 // AUTO-GENERATED DOCUMENTATION AND METHOD. 794 /** 795 * Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM 796 * permission for the specified recommender. 797 * 798 * <p>Sample code: 799 * 800 * <pre>{@code 801 * // This snippet has been automatically generated and should be regarded as a code template only. 802 * // It will require modifications to work: 803 * // - It may require correct/in-range values for request initialization. 804 * // - It may require specifying regional endpoints when creating the service client as shown in 805 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 806 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 807 * RecommenderName parent = 808 * RecommenderName.ofProjectLocationRecommenderName( 809 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]"); 810 * String filter = "filter-1274492040"; 811 * for (Recommendation element : 812 * recommenderClient.listRecommendations(parent, filter).iterateAll()) { 813 * // doThingsWith(element); 814 * } 815 * } 816 * }</pre> 817 * 818 * @param parent Required. The container resource on which to execute the request. Acceptable 819 * formats: 820 * <ul> 821 * <li>`projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` 822 * </ul> 823 * <ul> 824 * <li>`projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` 825 * </ul> 826 * <ul> 827 * <li>`billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` 828 * </ul> 829 * <ul> 830 * <li>`folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` 831 * </ul> 832 * <ul> 833 * <li>`organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` 834 * </ul> 835 * <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ 836 * RECOMMENDER_ID refers to supported recommenders: 837 * https://cloud.google.com/recommender/docs/recommenders. 838 * @param filter Filter expression to restrict the recommendations returned. Supported filter 839 * fields: 840 * <ul> 841 * <li>`state_info.state` 842 * </ul> 843 * <ul> 844 * <li>`recommenderSubtype` 845 * </ul> 846 * <ul> 847 * <li>`priority` 848 * </ul> 849 * <p>Examples: 850 * <ul> 851 * <li>`stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` 852 * </ul> 853 * <ul> 854 * <li>`recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` 855 * </ul> 856 * <ul> 857 * <li>`priority = P1 OR priority = P2` 858 * </ul> 859 * <ul> 860 * <li>`stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` 861 * </ul> 862 * <p>(These expressions are based on the filter language described at 863 * https://google.aip.dev/160) 864 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 865 */ listRecommendations( RecommenderName parent, String filter)866 public final ListRecommendationsPagedResponse listRecommendations( 867 RecommenderName parent, String filter) { 868 ListRecommendationsRequest request = 869 ListRecommendationsRequest.newBuilder() 870 .setParent(parent == null ? null : parent.toString()) 871 .setFilter(filter) 872 .build(); 873 return listRecommendations(request); 874 } 875 876 // AUTO-GENERATED DOCUMENTATION AND METHOD. 877 /** 878 * Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM 879 * permission for the specified recommender. 880 * 881 * <p>Sample code: 882 * 883 * <pre>{@code 884 * // This snippet has been automatically generated and should be regarded as a code template only. 885 * // It will require modifications to work: 886 * // - It may require correct/in-range values for request initialization. 887 * // - It may require specifying regional endpoints when creating the service client as shown in 888 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 889 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 890 * String parent = 891 * RecommenderName.ofProjectLocationRecommenderName( 892 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") 893 * .toString(); 894 * String filter = "filter-1274492040"; 895 * for (Recommendation element : 896 * recommenderClient.listRecommendations(parent, filter).iterateAll()) { 897 * // doThingsWith(element); 898 * } 899 * } 900 * }</pre> 901 * 902 * @param parent Required. The container resource on which to execute the request. Acceptable 903 * formats: 904 * <ul> 905 * <li>`projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` 906 * </ul> 907 * <ul> 908 * <li>`projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` 909 * </ul> 910 * <ul> 911 * <li>`billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` 912 * </ul> 913 * <ul> 914 * <li>`folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` 915 * </ul> 916 * <ul> 917 * <li>`organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` 918 * </ul> 919 * <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ 920 * RECOMMENDER_ID refers to supported recommenders: 921 * https://cloud.google.com/recommender/docs/recommenders. 922 * @param filter Filter expression to restrict the recommendations returned. Supported filter 923 * fields: 924 * <ul> 925 * <li>`state_info.state` 926 * </ul> 927 * <ul> 928 * <li>`recommenderSubtype` 929 * </ul> 930 * <ul> 931 * <li>`priority` 932 * </ul> 933 * <p>Examples: 934 * <ul> 935 * <li>`stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` 936 * </ul> 937 * <ul> 938 * <li>`recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` 939 * </ul> 940 * <ul> 941 * <li>`priority = P1 OR priority = P2` 942 * </ul> 943 * <ul> 944 * <li>`stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` 945 * </ul> 946 * <p>(These expressions are based on the filter language described at 947 * https://google.aip.dev/160) 948 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 949 */ listRecommendations(String parent, String filter)950 public final ListRecommendationsPagedResponse listRecommendations(String parent, String filter) { 951 ListRecommendationsRequest request = 952 ListRecommendationsRequest.newBuilder().setParent(parent).setFilter(filter).build(); 953 return listRecommendations(request); 954 } 955 956 // AUTO-GENERATED DOCUMENTATION AND METHOD. 957 /** 958 * Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM 959 * permission for the specified recommender. 960 * 961 * <p>Sample code: 962 * 963 * <pre>{@code 964 * // This snippet has been automatically generated and should be regarded as a code template only. 965 * // It will require modifications to work: 966 * // - It may require correct/in-range values for request initialization. 967 * // - It may require specifying regional endpoints when creating the service client as shown in 968 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 969 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 970 * ListRecommendationsRequest request = 971 * ListRecommendationsRequest.newBuilder() 972 * .setParent( 973 * RecommenderName.ofProjectLocationRecommenderName( 974 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") 975 * .toString()) 976 * .setPageSize(883849137) 977 * .setPageToken("pageToken873572522") 978 * .setFilter("filter-1274492040") 979 * .build(); 980 * for (Recommendation element : recommenderClient.listRecommendations(request).iterateAll()) { 981 * // doThingsWith(element); 982 * } 983 * } 984 * }</pre> 985 * 986 * @param request The request object containing all of the parameters for the API call. 987 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 988 */ listRecommendations( ListRecommendationsRequest request)989 public final ListRecommendationsPagedResponse listRecommendations( 990 ListRecommendationsRequest request) { 991 return listRecommendationsPagedCallable().call(request); 992 } 993 994 // AUTO-GENERATED DOCUMENTATION AND METHOD. 995 /** 996 * Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM 997 * permission for the specified recommender. 998 * 999 * <p>Sample code: 1000 * 1001 * <pre>{@code 1002 * // This snippet has been automatically generated and should be regarded as a code template only. 1003 * // It will require modifications to work: 1004 * // - It may require correct/in-range values for request initialization. 1005 * // - It may require specifying regional endpoints when creating the service client as shown in 1006 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1007 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1008 * ListRecommendationsRequest request = 1009 * ListRecommendationsRequest.newBuilder() 1010 * .setParent( 1011 * RecommenderName.ofProjectLocationRecommenderName( 1012 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") 1013 * .toString()) 1014 * .setPageSize(883849137) 1015 * .setPageToken("pageToken873572522") 1016 * .setFilter("filter-1274492040") 1017 * .build(); 1018 * ApiFuture<Recommendation> future = 1019 * recommenderClient.listRecommendationsPagedCallable().futureCall(request); 1020 * // Do something. 1021 * for (Recommendation element : future.get().iterateAll()) { 1022 * // doThingsWith(element); 1023 * } 1024 * } 1025 * }</pre> 1026 */ 1027 public final UnaryCallable<ListRecommendationsRequest, ListRecommendationsPagedResponse> listRecommendationsPagedCallable()1028 listRecommendationsPagedCallable() { 1029 return stub.listRecommendationsPagedCallable(); 1030 } 1031 1032 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1033 /** 1034 * Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM 1035 * permission for the specified recommender. 1036 * 1037 * <p>Sample code: 1038 * 1039 * <pre>{@code 1040 * // This snippet has been automatically generated and should be regarded as a code template only. 1041 * // It will require modifications to work: 1042 * // - It may require correct/in-range values for request initialization. 1043 * // - It may require specifying regional endpoints when creating the service client as shown in 1044 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1045 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1046 * ListRecommendationsRequest request = 1047 * ListRecommendationsRequest.newBuilder() 1048 * .setParent( 1049 * RecommenderName.ofProjectLocationRecommenderName( 1050 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") 1051 * .toString()) 1052 * .setPageSize(883849137) 1053 * .setPageToken("pageToken873572522") 1054 * .setFilter("filter-1274492040") 1055 * .build(); 1056 * while (true) { 1057 * ListRecommendationsResponse response = 1058 * recommenderClient.listRecommendationsCallable().call(request); 1059 * for (Recommendation element : response.getRecommendationsList()) { 1060 * // doThingsWith(element); 1061 * } 1062 * String nextPageToken = response.getNextPageToken(); 1063 * if (!Strings.isNullOrEmpty(nextPageToken)) { 1064 * request = request.toBuilder().setPageToken(nextPageToken).build(); 1065 * } else { 1066 * break; 1067 * } 1068 * } 1069 * } 1070 * }</pre> 1071 */ 1072 public final UnaryCallable<ListRecommendationsRequest, ListRecommendationsResponse> listRecommendationsCallable()1073 listRecommendationsCallable() { 1074 return stub.listRecommendationsCallable(); 1075 } 1076 1077 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1078 /** 1079 * Gets the requested recommendation. Requires the recommender.*.get IAM permission for the 1080 * specified recommender. 1081 * 1082 * <p>Sample code: 1083 * 1084 * <pre>{@code 1085 * // This snippet has been automatically generated and should be regarded as a code template only. 1086 * // It will require modifications to work: 1087 * // - It may require correct/in-range values for request initialization. 1088 * // - It may require specifying regional endpoints when creating the service client as shown in 1089 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1090 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1091 * RecommendationName name = 1092 * RecommendationName.ofProjectLocationRecommenderRecommendationName( 1093 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); 1094 * Recommendation response = recommenderClient.getRecommendation(name); 1095 * } 1096 * }</pre> 1097 * 1098 * @param name Required. Name of the recommendation. 1099 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1100 */ getRecommendation(RecommendationName name)1101 public final Recommendation getRecommendation(RecommendationName name) { 1102 GetRecommendationRequest request = 1103 GetRecommendationRequest.newBuilder() 1104 .setName(name == null ? null : name.toString()) 1105 .build(); 1106 return getRecommendation(request); 1107 } 1108 1109 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1110 /** 1111 * Gets the requested recommendation. Requires the recommender.*.get IAM permission for the 1112 * specified recommender. 1113 * 1114 * <p>Sample code: 1115 * 1116 * <pre>{@code 1117 * // This snippet has been automatically generated and should be regarded as a code template only. 1118 * // It will require modifications to work: 1119 * // - It may require correct/in-range values for request initialization. 1120 * // - It may require specifying regional endpoints when creating the service client as shown in 1121 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1122 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1123 * String name = 1124 * RecommendationName.ofProjectLocationRecommenderRecommendationName( 1125 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") 1126 * .toString(); 1127 * Recommendation response = recommenderClient.getRecommendation(name); 1128 * } 1129 * }</pre> 1130 * 1131 * @param name Required. Name of the recommendation. 1132 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1133 */ getRecommendation(String name)1134 public final Recommendation getRecommendation(String name) { 1135 GetRecommendationRequest request = GetRecommendationRequest.newBuilder().setName(name).build(); 1136 return getRecommendation(request); 1137 } 1138 1139 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1140 /** 1141 * Gets the requested recommendation. Requires the recommender.*.get IAM permission for the 1142 * specified recommender. 1143 * 1144 * <p>Sample code: 1145 * 1146 * <pre>{@code 1147 * // This snippet has been automatically generated and should be regarded as a code template only. 1148 * // It will require modifications to work: 1149 * // - It may require correct/in-range values for request initialization. 1150 * // - It may require specifying regional endpoints when creating the service client as shown in 1151 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1152 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1153 * GetRecommendationRequest request = 1154 * GetRecommendationRequest.newBuilder() 1155 * .setName( 1156 * RecommendationName.ofProjectLocationRecommenderRecommendationName( 1157 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") 1158 * .toString()) 1159 * .build(); 1160 * Recommendation response = recommenderClient.getRecommendation(request); 1161 * } 1162 * }</pre> 1163 * 1164 * @param request The request object containing all of the parameters for the API call. 1165 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1166 */ getRecommendation(GetRecommendationRequest request)1167 public final Recommendation getRecommendation(GetRecommendationRequest request) { 1168 return getRecommendationCallable().call(request); 1169 } 1170 1171 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1172 /** 1173 * Gets the requested recommendation. Requires the recommender.*.get IAM permission for the 1174 * specified recommender. 1175 * 1176 * <p>Sample code: 1177 * 1178 * <pre>{@code 1179 * // This snippet has been automatically generated and should be regarded as a code template only. 1180 * // It will require modifications to work: 1181 * // - It may require correct/in-range values for request initialization. 1182 * // - It may require specifying regional endpoints when creating the service client as shown in 1183 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1184 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1185 * GetRecommendationRequest request = 1186 * GetRecommendationRequest.newBuilder() 1187 * .setName( 1188 * RecommendationName.ofProjectLocationRecommenderRecommendationName( 1189 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") 1190 * .toString()) 1191 * .build(); 1192 * ApiFuture<Recommendation> future = 1193 * recommenderClient.getRecommendationCallable().futureCall(request); 1194 * // Do something. 1195 * Recommendation response = future.get(); 1196 * } 1197 * }</pre> 1198 */ getRecommendationCallable()1199 public final UnaryCallable<GetRecommendationRequest, Recommendation> getRecommendationCallable() { 1200 return stub.getRecommendationCallable(); 1201 } 1202 1203 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1204 /** 1205 * Marks the Recommendation State as Claimed. Users can use this method to indicate to the 1206 * Recommender API that they are starting to apply the recommendation themselves. This stops the 1207 * recommendation content from being updated. Associated insights are frozen and placed in the 1208 * ACCEPTED state. 1209 * 1210 * <p>MarkRecommendationClaimed can be applied to recommendations in CLAIMED, SUCCEEDED, FAILED, 1211 * or ACTIVE state. 1212 * 1213 * <p>Requires the recommender.*.update IAM permission for the specified recommender. 1214 * 1215 * <p>Sample code: 1216 * 1217 * <pre>{@code 1218 * // This snippet has been automatically generated and should be regarded as a code template only. 1219 * // It will require modifications to work: 1220 * // - It may require correct/in-range values for request initialization. 1221 * // - It may require specifying regional endpoints when creating the service client as shown in 1222 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1223 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1224 * RecommendationName name = 1225 * RecommendationName.ofProjectLocationRecommenderRecommendationName( 1226 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); 1227 * Map<String, String> stateMetadata = new HashMap<>(); 1228 * String etag = "etag3123477"; 1229 * Recommendation response = 1230 * recommenderClient.markRecommendationClaimed(name, stateMetadata, etag); 1231 * } 1232 * }</pre> 1233 * 1234 * @param name Required. Name of the recommendation. 1235 * @param stateMetadata State properties to include with this state. Overwrites any existing 1236 * `state_metadata`. Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. Values must 1237 * match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. 1238 * @param etag Required. Fingerprint of the Recommendation. Provides optimistic locking. 1239 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1240 */ markRecommendationClaimed( RecommendationName name, Map<String, String> stateMetadata, String etag)1241 public final Recommendation markRecommendationClaimed( 1242 RecommendationName name, Map<String, String> stateMetadata, String etag) { 1243 MarkRecommendationClaimedRequest request = 1244 MarkRecommendationClaimedRequest.newBuilder() 1245 .setName(name == null ? null : name.toString()) 1246 .putAllStateMetadata(stateMetadata) 1247 .setEtag(etag) 1248 .build(); 1249 return markRecommendationClaimed(request); 1250 } 1251 1252 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1253 /** 1254 * Marks the Recommendation State as Claimed. Users can use this method to indicate to the 1255 * Recommender API that they are starting to apply the recommendation themselves. This stops the 1256 * recommendation content from being updated. Associated insights are frozen and placed in the 1257 * ACCEPTED state. 1258 * 1259 * <p>MarkRecommendationClaimed can be applied to recommendations in CLAIMED, SUCCEEDED, FAILED, 1260 * or ACTIVE state. 1261 * 1262 * <p>Requires the recommender.*.update IAM permission for the specified recommender. 1263 * 1264 * <p>Sample code: 1265 * 1266 * <pre>{@code 1267 * // This snippet has been automatically generated and should be regarded as a code template only. 1268 * // It will require modifications to work: 1269 * // - It may require correct/in-range values for request initialization. 1270 * // - It may require specifying regional endpoints when creating the service client as shown in 1271 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1272 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1273 * String name = 1274 * RecommendationName.ofProjectLocationRecommenderRecommendationName( 1275 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") 1276 * .toString(); 1277 * Map<String, String> stateMetadata = new HashMap<>(); 1278 * String etag = "etag3123477"; 1279 * Recommendation response = 1280 * recommenderClient.markRecommendationClaimed(name, stateMetadata, etag); 1281 * } 1282 * }</pre> 1283 * 1284 * @param name Required. Name of the recommendation. 1285 * @param stateMetadata State properties to include with this state. Overwrites any existing 1286 * `state_metadata`. Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. Values must 1287 * match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. 1288 * @param etag Required. Fingerprint of the Recommendation. Provides optimistic locking. 1289 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1290 */ markRecommendationClaimed( String name, Map<String, String> stateMetadata, String etag)1291 public final Recommendation markRecommendationClaimed( 1292 String name, Map<String, String> stateMetadata, String etag) { 1293 MarkRecommendationClaimedRequest request = 1294 MarkRecommendationClaimedRequest.newBuilder() 1295 .setName(name) 1296 .putAllStateMetadata(stateMetadata) 1297 .setEtag(etag) 1298 .build(); 1299 return markRecommendationClaimed(request); 1300 } 1301 1302 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1303 /** 1304 * Marks the Recommendation State as Claimed. Users can use this method to indicate to the 1305 * Recommender API that they are starting to apply the recommendation themselves. This stops the 1306 * recommendation content from being updated. Associated insights are frozen and placed in the 1307 * ACCEPTED state. 1308 * 1309 * <p>MarkRecommendationClaimed can be applied to recommendations in CLAIMED, SUCCEEDED, FAILED, 1310 * or ACTIVE state. 1311 * 1312 * <p>Requires the recommender.*.update IAM permission for the specified recommender. 1313 * 1314 * <p>Sample code: 1315 * 1316 * <pre>{@code 1317 * // This snippet has been automatically generated and should be regarded as a code template only. 1318 * // It will require modifications to work: 1319 * // - It may require correct/in-range values for request initialization. 1320 * // - It may require specifying regional endpoints when creating the service client as shown in 1321 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1322 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1323 * MarkRecommendationClaimedRequest request = 1324 * MarkRecommendationClaimedRequest.newBuilder() 1325 * .setName( 1326 * RecommendationName.ofProjectLocationRecommenderRecommendationName( 1327 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") 1328 * .toString()) 1329 * .putAllStateMetadata(new HashMap<String, String>()) 1330 * .setEtag("etag3123477") 1331 * .build(); 1332 * Recommendation response = recommenderClient.markRecommendationClaimed(request); 1333 * } 1334 * }</pre> 1335 * 1336 * @param request The request object containing all of the parameters for the API call. 1337 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1338 */ markRecommendationClaimed(MarkRecommendationClaimedRequest request)1339 public final Recommendation markRecommendationClaimed(MarkRecommendationClaimedRequest request) { 1340 return markRecommendationClaimedCallable().call(request); 1341 } 1342 1343 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1344 /** 1345 * Marks the Recommendation State as Claimed. Users can use this method to indicate to the 1346 * Recommender API that they are starting to apply the recommendation themselves. This stops the 1347 * recommendation content from being updated. Associated insights are frozen and placed in the 1348 * ACCEPTED state. 1349 * 1350 * <p>MarkRecommendationClaimed can be applied to recommendations in CLAIMED, SUCCEEDED, FAILED, 1351 * or ACTIVE state. 1352 * 1353 * <p>Requires the recommender.*.update IAM permission for the specified recommender. 1354 * 1355 * <p>Sample code: 1356 * 1357 * <pre>{@code 1358 * // This snippet has been automatically generated and should be regarded as a code template only. 1359 * // It will require modifications to work: 1360 * // - It may require correct/in-range values for request initialization. 1361 * // - It may require specifying regional endpoints when creating the service client as shown in 1362 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1363 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1364 * MarkRecommendationClaimedRequest request = 1365 * MarkRecommendationClaimedRequest.newBuilder() 1366 * .setName( 1367 * RecommendationName.ofProjectLocationRecommenderRecommendationName( 1368 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") 1369 * .toString()) 1370 * .putAllStateMetadata(new HashMap<String, String>()) 1371 * .setEtag("etag3123477") 1372 * .build(); 1373 * ApiFuture<Recommendation> future = 1374 * recommenderClient.markRecommendationClaimedCallable().futureCall(request); 1375 * // Do something. 1376 * Recommendation response = future.get(); 1377 * } 1378 * }</pre> 1379 */ 1380 public final UnaryCallable<MarkRecommendationClaimedRequest, Recommendation> markRecommendationClaimedCallable()1381 markRecommendationClaimedCallable() { 1382 return stub.markRecommendationClaimedCallable(); 1383 } 1384 1385 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1386 /** 1387 * Marks the Recommendation State as Succeeded. Users can use this method to indicate to the 1388 * Recommender API that they have applied the recommendation themselves, and the operation was 1389 * successful. This stops the recommendation content from being updated. Associated insights are 1390 * frozen and placed in the ACCEPTED state. 1391 * 1392 * <p>MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, 1393 * or FAILED state. 1394 * 1395 * <p>Requires the recommender.*.update IAM permission for the specified recommender. 1396 * 1397 * <p>Sample code: 1398 * 1399 * <pre>{@code 1400 * // This snippet has been automatically generated and should be regarded as a code template only. 1401 * // It will require modifications to work: 1402 * // - It may require correct/in-range values for request initialization. 1403 * // - It may require specifying regional endpoints when creating the service client as shown in 1404 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1405 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1406 * RecommendationName name = 1407 * RecommendationName.ofProjectLocationRecommenderRecommendationName( 1408 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); 1409 * Map<String, String> stateMetadata = new HashMap<>(); 1410 * String etag = "etag3123477"; 1411 * Recommendation response = 1412 * recommenderClient.markRecommendationSucceeded(name, stateMetadata, etag); 1413 * } 1414 * }</pre> 1415 * 1416 * @param name Required. Name of the recommendation. 1417 * @param stateMetadata State properties to include with this state. Overwrites any existing 1418 * `state_metadata`. Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. Values must 1419 * match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. 1420 * @param etag Required. Fingerprint of the Recommendation. Provides optimistic locking. 1421 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1422 */ markRecommendationSucceeded( RecommendationName name, Map<String, String> stateMetadata, String etag)1423 public final Recommendation markRecommendationSucceeded( 1424 RecommendationName name, Map<String, String> stateMetadata, String etag) { 1425 MarkRecommendationSucceededRequest request = 1426 MarkRecommendationSucceededRequest.newBuilder() 1427 .setName(name == null ? null : name.toString()) 1428 .putAllStateMetadata(stateMetadata) 1429 .setEtag(etag) 1430 .build(); 1431 return markRecommendationSucceeded(request); 1432 } 1433 1434 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1435 /** 1436 * Marks the Recommendation State as Succeeded. Users can use this method to indicate to the 1437 * Recommender API that they have applied the recommendation themselves, and the operation was 1438 * successful. This stops the recommendation content from being updated. Associated insights are 1439 * frozen and placed in the ACCEPTED state. 1440 * 1441 * <p>MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, 1442 * or FAILED state. 1443 * 1444 * <p>Requires the recommender.*.update IAM permission for the specified recommender. 1445 * 1446 * <p>Sample code: 1447 * 1448 * <pre>{@code 1449 * // This snippet has been automatically generated and should be regarded as a code template only. 1450 * // It will require modifications to work: 1451 * // - It may require correct/in-range values for request initialization. 1452 * // - It may require specifying regional endpoints when creating the service client as shown in 1453 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1454 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1455 * String name = 1456 * RecommendationName.ofProjectLocationRecommenderRecommendationName( 1457 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") 1458 * .toString(); 1459 * Map<String, String> stateMetadata = new HashMap<>(); 1460 * String etag = "etag3123477"; 1461 * Recommendation response = 1462 * recommenderClient.markRecommendationSucceeded(name, stateMetadata, etag); 1463 * } 1464 * }</pre> 1465 * 1466 * @param name Required. Name of the recommendation. 1467 * @param stateMetadata State properties to include with this state. Overwrites any existing 1468 * `state_metadata`. Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. Values must 1469 * match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. 1470 * @param etag Required. Fingerprint of the Recommendation. Provides optimistic locking. 1471 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1472 */ markRecommendationSucceeded( String name, Map<String, String> stateMetadata, String etag)1473 public final Recommendation markRecommendationSucceeded( 1474 String name, Map<String, String> stateMetadata, String etag) { 1475 MarkRecommendationSucceededRequest request = 1476 MarkRecommendationSucceededRequest.newBuilder() 1477 .setName(name) 1478 .putAllStateMetadata(stateMetadata) 1479 .setEtag(etag) 1480 .build(); 1481 return markRecommendationSucceeded(request); 1482 } 1483 1484 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1485 /** 1486 * Marks the Recommendation State as Succeeded. Users can use this method to indicate to the 1487 * Recommender API that they have applied the recommendation themselves, and the operation was 1488 * successful. This stops the recommendation content from being updated. Associated insights are 1489 * frozen and placed in the ACCEPTED state. 1490 * 1491 * <p>MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, 1492 * or FAILED state. 1493 * 1494 * <p>Requires the recommender.*.update IAM permission for the specified recommender. 1495 * 1496 * <p>Sample code: 1497 * 1498 * <pre>{@code 1499 * // This snippet has been automatically generated and should be regarded as a code template only. 1500 * // It will require modifications to work: 1501 * // - It may require correct/in-range values for request initialization. 1502 * // - It may require specifying regional endpoints when creating the service client as shown in 1503 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1504 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1505 * MarkRecommendationSucceededRequest request = 1506 * MarkRecommendationSucceededRequest.newBuilder() 1507 * .setName( 1508 * RecommendationName.ofProjectLocationRecommenderRecommendationName( 1509 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") 1510 * .toString()) 1511 * .putAllStateMetadata(new HashMap<String, String>()) 1512 * .setEtag("etag3123477") 1513 * .build(); 1514 * Recommendation response = recommenderClient.markRecommendationSucceeded(request); 1515 * } 1516 * }</pre> 1517 * 1518 * @param request The request object containing all of the parameters for the API call. 1519 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1520 */ markRecommendationSucceeded( MarkRecommendationSucceededRequest request)1521 public final Recommendation markRecommendationSucceeded( 1522 MarkRecommendationSucceededRequest request) { 1523 return markRecommendationSucceededCallable().call(request); 1524 } 1525 1526 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1527 /** 1528 * Marks the Recommendation State as Succeeded. Users can use this method to indicate to the 1529 * Recommender API that they have applied the recommendation themselves, and the operation was 1530 * successful. This stops the recommendation content from being updated. Associated insights are 1531 * frozen and placed in the ACCEPTED state. 1532 * 1533 * <p>MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, 1534 * or FAILED state. 1535 * 1536 * <p>Requires the recommender.*.update IAM permission for the specified recommender. 1537 * 1538 * <p>Sample code: 1539 * 1540 * <pre>{@code 1541 * // This snippet has been automatically generated and should be regarded as a code template only. 1542 * // It will require modifications to work: 1543 * // - It may require correct/in-range values for request initialization. 1544 * // - It may require specifying regional endpoints when creating the service client as shown in 1545 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1546 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1547 * MarkRecommendationSucceededRequest request = 1548 * MarkRecommendationSucceededRequest.newBuilder() 1549 * .setName( 1550 * RecommendationName.ofProjectLocationRecommenderRecommendationName( 1551 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") 1552 * .toString()) 1553 * .putAllStateMetadata(new HashMap<String, String>()) 1554 * .setEtag("etag3123477") 1555 * .build(); 1556 * ApiFuture<Recommendation> future = 1557 * recommenderClient.markRecommendationSucceededCallable().futureCall(request); 1558 * // Do something. 1559 * Recommendation response = future.get(); 1560 * } 1561 * }</pre> 1562 */ 1563 public final UnaryCallable<MarkRecommendationSucceededRequest, Recommendation> markRecommendationSucceededCallable()1564 markRecommendationSucceededCallable() { 1565 return stub.markRecommendationSucceededCallable(); 1566 } 1567 1568 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1569 /** 1570 * Marks the Recommendation State as Failed. Users can use this method to indicate to the 1571 * Recommender API that they have applied the recommendation themselves, and the operation failed. 1572 * This stops the recommendation content from being updated. Associated insights are frozen and 1573 * placed in the ACCEPTED state. 1574 * 1575 * <p>MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or 1576 * FAILED state. 1577 * 1578 * <p>Requires the recommender.*.update IAM permission for the specified recommender. 1579 * 1580 * <p>Sample code: 1581 * 1582 * <pre>{@code 1583 * // This snippet has been automatically generated and should be regarded as a code template only. 1584 * // It will require modifications to work: 1585 * // - It may require correct/in-range values for request initialization. 1586 * // - It may require specifying regional endpoints when creating the service client as shown in 1587 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1588 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1589 * RecommendationName name = 1590 * RecommendationName.ofProjectLocationRecommenderRecommendationName( 1591 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); 1592 * Map<String, String> stateMetadata = new HashMap<>(); 1593 * String etag = "etag3123477"; 1594 * Recommendation response = 1595 * recommenderClient.markRecommendationFailed(name, stateMetadata, etag); 1596 * } 1597 * }</pre> 1598 * 1599 * @param name Required. Name of the recommendation. 1600 * @param stateMetadata State properties to include with this state. Overwrites any existing 1601 * `state_metadata`. Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. Values must 1602 * match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. 1603 * @param etag Required. Fingerprint of the Recommendation. Provides optimistic locking. 1604 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1605 */ markRecommendationFailed( RecommendationName name, Map<String, String> stateMetadata, String etag)1606 public final Recommendation markRecommendationFailed( 1607 RecommendationName name, Map<String, String> stateMetadata, String etag) { 1608 MarkRecommendationFailedRequest request = 1609 MarkRecommendationFailedRequest.newBuilder() 1610 .setName(name == null ? null : name.toString()) 1611 .putAllStateMetadata(stateMetadata) 1612 .setEtag(etag) 1613 .build(); 1614 return markRecommendationFailed(request); 1615 } 1616 1617 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1618 /** 1619 * Marks the Recommendation State as Failed. Users can use this method to indicate to the 1620 * Recommender API that they have applied the recommendation themselves, and the operation failed. 1621 * This stops the recommendation content from being updated. Associated insights are frozen and 1622 * placed in the ACCEPTED state. 1623 * 1624 * <p>MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or 1625 * FAILED state. 1626 * 1627 * <p>Requires the recommender.*.update IAM permission for the specified recommender. 1628 * 1629 * <p>Sample code: 1630 * 1631 * <pre>{@code 1632 * // This snippet has been automatically generated and should be regarded as a code template only. 1633 * // It will require modifications to work: 1634 * // - It may require correct/in-range values for request initialization. 1635 * // - It may require specifying regional endpoints when creating the service client as shown in 1636 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1637 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1638 * String name = 1639 * RecommendationName.ofProjectLocationRecommenderRecommendationName( 1640 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") 1641 * .toString(); 1642 * Map<String, String> stateMetadata = new HashMap<>(); 1643 * String etag = "etag3123477"; 1644 * Recommendation response = 1645 * recommenderClient.markRecommendationFailed(name, stateMetadata, etag); 1646 * } 1647 * }</pre> 1648 * 1649 * @param name Required. Name of the recommendation. 1650 * @param stateMetadata State properties to include with this state. Overwrites any existing 1651 * `state_metadata`. Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. Values must 1652 * match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. 1653 * @param etag Required. Fingerprint of the Recommendation. Provides optimistic locking. 1654 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1655 */ markRecommendationFailed( String name, Map<String, String> stateMetadata, String etag)1656 public final Recommendation markRecommendationFailed( 1657 String name, Map<String, String> stateMetadata, String etag) { 1658 MarkRecommendationFailedRequest request = 1659 MarkRecommendationFailedRequest.newBuilder() 1660 .setName(name) 1661 .putAllStateMetadata(stateMetadata) 1662 .setEtag(etag) 1663 .build(); 1664 return markRecommendationFailed(request); 1665 } 1666 1667 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1668 /** 1669 * Marks the Recommendation State as Failed. Users can use this method to indicate to the 1670 * Recommender API that they have applied the recommendation themselves, and the operation failed. 1671 * This stops the recommendation content from being updated. Associated insights are frozen and 1672 * placed in the ACCEPTED state. 1673 * 1674 * <p>MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or 1675 * FAILED state. 1676 * 1677 * <p>Requires the recommender.*.update IAM permission for the specified recommender. 1678 * 1679 * <p>Sample code: 1680 * 1681 * <pre>{@code 1682 * // This snippet has been automatically generated and should be regarded as a code template only. 1683 * // It will require modifications to work: 1684 * // - It may require correct/in-range values for request initialization. 1685 * // - It may require specifying regional endpoints when creating the service client as shown in 1686 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1687 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1688 * MarkRecommendationFailedRequest request = 1689 * MarkRecommendationFailedRequest.newBuilder() 1690 * .setName( 1691 * RecommendationName.ofProjectLocationRecommenderRecommendationName( 1692 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") 1693 * .toString()) 1694 * .putAllStateMetadata(new HashMap<String, String>()) 1695 * .setEtag("etag3123477") 1696 * .build(); 1697 * Recommendation response = recommenderClient.markRecommendationFailed(request); 1698 * } 1699 * }</pre> 1700 * 1701 * @param request The request object containing all of the parameters for the API call. 1702 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1703 */ markRecommendationFailed(MarkRecommendationFailedRequest request)1704 public final Recommendation markRecommendationFailed(MarkRecommendationFailedRequest request) { 1705 return markRecommendationFailedCallable().call(request); 1706 } 1707 1708 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1709 /** 1710 * Marks the Recommendation State as Failed. Users can use this method to indicate to the 1711 * Recommender API that they have applied the recommendation themselves, and the operation failed. 1712 * This stops the recommendation content from being updated. Associated insights are frozen and 1713 * placed in the ACCEPTED state. 1714 * 1715 * <p>MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or 1716 * FAILED state. 1717 * 1718 * <p>Requires the recommender.*.update IAM permission for the specified recommender. 1719 * 1720 * <p>Sample code: 1721 * 1722 * <pre>{@code 1723 * // This snippet has been automatically generated and should be regarded as a code template only. 1724 * // It will require modifications to work: 1725 * // - It may require correct/in-range values for request initialization. 1726 * // - It may require specifying regional endpoints when creating the service client as shown in 1727 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1728 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1729 * MarkRecommendationFailedRequest request = 1730 * MarkRecommendationFailedRequest.newBuilder() 1731 * .setName( 1732 * RecommendationName.ofProjectLocationRecommenderRecommendationName( 1733 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") 1734 * .toString()) 1735 * .putAllStateMetadata(new HashMap<String, String>()) 1736 * .setEtag("etag3123477") 1737 * .build(); 1738 * ApiFuture<Recommendation> future = 1739 * recommenderClient.markRecommendationFailedCallable().futureCall(request); 1740 * // Do something. 1741 * Recommendation response = future.get(); 1742 * } 1743 * }</pre> 1744 */ 1745 public final UnaryCallable<MarkRecommendationFailedRequest, Recommendation> markRecommendationFailedCallable()1746 markRecommendationFailedCallable() { 1747 return stub.markRecommendationFailedCallable(); 1748 } 1749 1750 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1751 /** 1752 * Gets the requested Recommender Config. There is only one instance of the config for each 1753 * Recommender. 1754 * 1755 * <p>Sample code: 1756 * 1757 * <pre>{@code 1758 * // This snippet has been automatically generated and should be regarded as a code template only. 1759 * // It will require modifications to work: 1760 * // - It may require correct/in-range values for request initialization. 1761 * // - It may require specifying regional endpoints when creating the service client as shown in 1762 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1763 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1764 * RecommenderConfigName name = 1765 * RecommenderConfigName.ofProjectLocationRecommenderName( 1766 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]"); 1767 * RecommenderConfig response = recommenderClient.getRecommenderConfig(name); 1768 * } 1769 * }</pre> 1770 * 1771 * @param name Required. Name of the Recommendation Config to get. 1772 * <p>Acceptable formats: 1773 * <ul> 1774 * <li>`projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` 1775 * </ul> 1776 * <ul> 1777 * <li>`projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` 1778 * </ul> 1779 * <ul> 1780 * <li>`organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` 1781 * </ul> 1782 * 1783 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1784 */ getRecommenderConfig(RecommenderConfigName name)1785 public final RecommenderConfig getRecommenderConfig(RecommenderConfigName name) { 1786 GetRecommenderConfigRequest request = 1787 GetRecommenderConfigRequest.newBuilder() 1788 .setName(name == null ? null : name.toString()) 1789 .build(); 1790 return getRecommenderConfig(request); 1791 } 1792 1793 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1794 /** 1795 * Gets the requested Recommender Config. There is only one instance of the config for each 1796 * Recommender. 1797 * 1798 * <p>Sample code: 1799 * 1800 * <pre>{@code 1801 * // This snippet has been automatically generated and should be regarded as a code template only. 1802 * // It will require modifications to work: 1803 * // - It may require correct/in-range values for request initialization. 1804 * // - It may require specifying regional endpoints when creating the service client as shown in 1805 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1806 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1807 * String name = 1808 * RecommenderConfigName.ofProjectLocationRecommenderName( 1809 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") 1810 * .toString(); 1811 * RecommenderConfig response = recommenderClient.getRecommenderConfig(name); 1812 * } 1813 * }</pre> 1814 * 1815 * @param name Required. Name of the Recommendation Config to get. 1816 * <p>Acceptable formats: 1817 * <ul> 1818 * <li>`projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` 1819 * </ul> 1820 * <ul> 1821 * <li>`projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` 1822 * </ul> 1823 * <ul> 1824 * <li>`organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` 1825 * </ul> 1826 * 1827 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1828 */ getRecommenderConfig(String name)1829 public final RecommenderConfig getRecommenderConfig(String name) { 1830 GetRecommenderConfigRequest request = 1831 GetRecommenderConfigRequest.newBuilder().setName(name).build(); 1832 return getRecommenderConfig(request); 1833 } 1834 1835 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1836 /** 1837 * Gets the requested Recommender Config. There is only one instance of the config for each 1838 * Recommender. 1839 * 1840 * <p>Sample code: 1841 * 1842 * <pre>{@code 1843 * // This snippet has been automatically generated and should be regarded as a code template only. 1844 * // It will require modifications to work: 1845 * // - It may require correct/in-range values for request initialization. 1846 * // - It may require specifying regional endpoints when creating the service client as shown in 1847 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1848 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1849 * GetRecommenderConfigRequest request = 1850 * GetRecommenderConfigRequest.newBuilder() 1851 * .setName( 1852 * RecommenderConfigName.ofProjectLocationRecommenderName( 1853 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") 1854 * .toString()) 1855 * .build(); 1856 * RecommenderConfig response = recommenderClient.getRecommenderConfig(request); 1857 * } 1858 * }</pre> 1859 * 1860 * @param request The request object containing all of the parameters for the API call. 1861 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1862 */ getRecommenderConfig(GetRecommenderConfigRequest request)1863 public final RecommenderConfig getRecommenderConfig(GetRecommenderConfigRequest request) { 1864 return getRecommenderConfigCallable().call(request); 1865 } 1866 1867 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1868 /** 1869 * Gets the requested Recommender Config. There is only one instance of the config for each 1870 * Recommender. 1871 * 1872 * <p>Sample code: 1873 * 1874 * <pre>{@code 1875 * // This snippet has been automatically generated and should be regarded as a code template only. 1876 * // It will require modifications to work: 1877 * // - It may require correct/in-range values for request initialization. 1878 * // - It may require specifying regional endpoints when creating the service client as shown in 1879 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1880 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1881 * GetRecommenderConfigRequest request = 1882 * GetRecommenderConfigRequest.newBuilder() 1883 * .setName( 1884 * RecommenderConfigName.ofProjectLocationRecommenderName( 1885 * "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") 1886 * .toString()) 1887 * .build(); 1888 * ApiFuture<RecommenderConfig> future = 1889 * recommenderClient.getRecommenderConfigCallable().futureCall(request); 1890 * // Do something. 1891 * RecommenderConfig response = future.get(); 1892 * } 1893 * }</pre> 1894 */ 1895 public final UnaryCallable<GetRecommenderConfigRequest, RecommenderConfig> getRecommenderConfigCallable()1896 getRecommenderConfigCallable() { 1897 return stub.getRecommenderConfigCallable(); 1898 } 1899 1900 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1901 /** 1902 * Updates a Recommender Config. This will create a new revision of the config. 1903 * 1904 * <p>Sample code: 1905 * 1906 * <pre>{@code 1907 * // This snippet has been automatically generated and should be regarded as a code template only. 1908 * // It will require modifications to work: 1909 * // - It may require correct/in-range values for request initialization. 1910 * // - It may require specifying regional endpoints when creating the service client as shown in 1911 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1912 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1913 * RecommenderConfig recommenderConfig = RecommenderConfig.newBuilder().build(); 1914 * FieldMask updateMask = FieldMask.newBuilder().build(); 1915 * RecommenderConfig response = 1916 * recommenderClient.updateRecommenderConfig(recommenderConfig, updateMask); 1917 * } 1918 * }</pre> 1919 * 1920 * @param recommenderConfig Required. The RecommenderConfig to update. 1921 * @param updateMask The list of fields to be updated. 1922 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1923 */ updateRecommenderConfig( RecommenderConfig recommenderConfig, FieldMask updateMask)1924 public final RecommenderConfig updateRecommenderConfig( 1925 RecommenderConfig recommenderConfig, FieldMask updateMask) { 1926 UpdateRecommenderConfigRequest request = 1927 UpdateRecommenderConfigRequest.newBuilder() 1928 .setRecommenderConfig(recommenderConfig) 1929 .setUpdateMask(updateMask) 1930 .build(); 1931 return updateRecommenderConfig(request); 1932 } 1933 1934 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1935 /** 1936 * Updates a Recommender Config. This will create a new revision of the config. 1937 * 1938 * <p>Sample code: 1939 * 1940 * <pre>{@code 1941 * // This snippet has been automatically generated and should be regarded as a code template only. 1942 * // It will require modifications to work: 1943 * // - It may require correct/in-range values for request initialization. 1944 * // - It may require specifying regional endpoints when creating the service client as shown in 1945 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1946 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1947 * UpdateRecommenderConfigRequest request = 1948 * UpdateRecommenderConfigRequest.newBuilder() 1949 * .setRecommenderConfig(RecommenderConfig.newBuilder().build()) 1950 * .setUpdateMask(FieldMask.newBuilder().build()) 1951 * .setValidateOnly(true) 1952 * .build(); 1953 * RecommenderConfig response = recommenderClient.updateRecommenderConfig(request); 1954 * } 1955 * }</pre> 1956 * 1957 * @param request The request object containing all of the parameters for the API call. 1958 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1959 */ updateRecommenderConfig(UpdateRecommenderConfigRequest request)1960 public final RecommenderConfig updateRecommenderConfig(UpdateRecommenderConfigRequest request) { 1961 return updateRecommenderConfigCallable().call(request); 1962 } 1963 1964 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1965 /** 1966 * Updates a Recommender Config. This will create a new revision of the config. 1967 * 1968 * <p>Sample code: 1969 * 1970 * <pre>{@code 1971 * // This snippet has been automatically generated and should be regarded as a code template only. 1972 * // It will require modifications to work: 1973 * // - It may require correct/in-range values for request initialization. 1974 * // - It may require specifying regional endpoints when creating the service client as shown in 1975 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1976 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 1977 * UpdateRecommenderConfigRequest request = 1978 * UpdateRecommenderConfigRequest.newBuilder() 1979 * .setRecommenderConfig(RecommenderConfig.newBuilder().build()) 1980 * .setUpdateMask(FieldMask.newBuilder().build()) 1981 * .setValidateOnly(true) 1982 * .build(); 1983 * ApiFuture<RecommenderConfig> future = 1984 * recommenderClient.updateRecommenderConfigCallable().futureCall(request); 1985 * // Do something. 1986 * RecommenderConfig response = future.get(); 1987 * } 1988 * }</pre> 1989 */ 1990 public final UnaryCallable<UpdateRecommenderConfigRequest, RecommenderConfig> updateRecommenderConfigCallable()1991 updateRecommenderConfigCallable() { 1992 return stub.updateRecommenderConfigCallable(); 1993 } 1994 1995 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1996 /** 1997 * Gets the requested InsightTypeConfig. There is only one instance of the config for each 1998 * InsightType. 1999 * 2000 * <p>Sample code: 2001 * 2002 * <pre>{@code 2003 * // This snippet has been automatically generated and should be regarded as a code template only. 2004 * // It will require modifications to work: 2005 * // - It may require correct/in-range values for request initialization. 2006 * // - It may require specifying regional endpoints when creating the service client as shown in 2007 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2008 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 2009 * InsightTypeConfigName name = 2010 * InsightTypeConfigName.ofProjectLocationInsightTypeName( 2011 * "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]"); 2012 * InsightTypeConfig response = recommenderClient.getInsightTypeConfig(name); 2013 * } 2014 * }</pre> 2015 * 2016 * @param name Required. Name of the InsightTypeConfig to get. 2017 * <p>Acceptable formats: 2018 * <ul> 2019 * <li>`projects/[PROJECT_NUMBER]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` 2020 * </ul> 2021 * <ul> 2022 * <li>`projects/[PROJECT_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` 2023 * </ul> 2024 * <ul> 2025 * <li>`organizations/[ORGANIZATION_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` 2026 * </ul> 2027 * 2028 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2029 */ getInsightTypeConfig(InsightTypeConfigName name)2030 public final InsightTypeConfig getInsightTypeConfig(InsightTypeConfigName name) { 2031 GetInsightTypeConfigRequest request = 2032 GetInsightTypeConfigRequest.newBuilder() 2033 .setName(name == null ? null : name.toString()) 2034 .build(); 2035 return getInsightTypeConfig(request); 2036 } 2037 2038 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2039 /** 2040 * Gets the requested InsightTypeConfig. There is only one instance of the config for each 2041 * InsightType. 2042 * 2043 * <p>Sample code: 2044 * 2045 * <pre>{@code 2046 * // This snippet has been automatically generated and should be regarded as a code template only. 2047 * // It will require modifications to work: 2048 * // - It may require correct/in-range values for request initialization. 2049 * // - It may require specifying regional endpoints when creating the service client as shown in 2050 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2051 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 2052 * String name = 2053 * InsightTypeConfigName.ofProjectLocationInsightTypeName( 2054 * "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]") 2055 * .toString(); 2056 * InsightTypeConfig response = recommenderClient.getInsightTypeConfig(name); 2057 * } 2058 * }</pre> 2059 * 2060 * @param name Required. Name of the InsightTypeConfig to get. 2061 * <p>Acceptable formats: 2062 * <ul> 2063 * <li>`projects/[PROJECT_NUMBER]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` 2064 * </ul> 2065 * <ul> 2066 * <li>`projects/[PROJECT_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` 2067 * </ul> 2068 * <ul> 2069 * <li>`organizations/[ORGANIZATION_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` 2070 * </ul> 2071 * 2072 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2073 */ getInsightTypeConfig(String name)2074 public final InsightTypeConfig getInsightTypeConfig(String name) { 2075 GetInsightTypeConfigRequest request = 2076 GetInsightTypeConfigRequest.newBuilder().setName(name).build(); 2077 return getInsightTypeConfig(request); 2078 } 2079 2080 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2081 /** 2082 * Gets the requested InsightTypeConfig. There is only one instance of the config for each 2083 * InsightType. 2084 * 2085 * <p>Sample code: 2086 * 2087 * <pre>{@code 2088 * // This snippet has been automatically generated and should be regarded as a code template only. 2089 * // It will require modifications to work: 2090 * // - It may require correct/in-range values for request initialization. 2091 * // - It may require specifying regional endpoints when creating the service client as shown in 2092 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2093 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 2094 * GetInsightTypeConfigRequest request = 2095 * GetInsightTypeConfigRequest.newBuilder() 2096 * .setName( 2097 * InsightTypeConfigName.ofProjectLocationInsightTypeName( 2098 * "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]") 2099 * .toString()) 2100 * .build(); 2101 * InsightTypeConfig response = recommenderClient.getInsightTypeConfig(request); 2102 * } 2103 * }</pre> 2104 * 2105 * @param request The request object containing all of the parameters for the API call. 2106 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2107 */ getInsightTypeConfig(GetInsightTypeConfigRequest request)2108 public final InsightTypeConfig getInsightTypeConfig(GetInsightTypeConfigRequest request) { 2109 return getInsightTypeConfigCallable().call(request); 2110 } 2111 2112 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2113 /** 2114 * Gets the requested InsightTypeConfig. There is only one instance of the config for each 2115 * InsightType. 2116 * 2117 * <p>Sample code: 2118 * 2119 * <pre>{@code 2120 * // This snippet has been automatically generated and should be regarded as a code template only. 2121 * // It will require modifications to work: 2122 * // - It may require correct/in-range values for request initialization. 2123 * // - It may require specifying regional endpoints when creating the service client as shown in 2124 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2125 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 2126 * GetInsightTypeConfigRequest request = 2127 * GetInsightTypeConfigRequest.newBuilder() 2128 * .setName( 2129 * InsightTypeConfigName.ofProjectLocationInsightTypeName( 2130 * "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]") 2131 * .toString()) 2132 * .build(); 2133 * ApiFuture<InsightTypeConfig> future = 2134 * recommenderClient.getInsightTypeConfigCallable().futureCall(request); 2135 * // Do something. 2136 * InsightTypeConfig response = future.get(); 2137 * } 2138 * }</pre> 2139 */ 2140 public final UnaryCallable<GetInsightTypeConfigRequest, InsightTypeConfig> getInsightTypeConfigCallable()2141 getInsightTypeConfigCallable() { 2142 return stub.getInsightTypeConfigCallable(); 2143 } 2144 2145 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2146 /** 2147 * Updates an InsightTypeConfig change. This will create a new revision of the config. 2148 * 2149 * <p>Sample code: 2150 * 2151 * <pre>{@code 2152 * // This snippet has been automatically generated and should be regarded as a code template only. 2153 * // It will require modifications to work: 2154 * // - It may require correct/in-range values for request initialization. 2155 * // - It may require specifying regional endpoints when creating the service client as shown in 2156 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2157 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 2158 * InsightTypeConfig insightTypeConfig = InsightTypeConfig.newBuilder().build(); 2159 * FieldMask updateMask = FieldMask.newBuilder().build(); 2160 * InsightTypeConfig response = 2161 * recommenderClient.updateInsightTypeConfig(insightTypeConfig, updateMask); 2162 * } 2163 * }</pre> 2164 * 2165 * @param insightTypeConfig Required. The InsightTypeConfig to update. 2166 * @param updateMask The list of fields to be updated. 2167 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2168 */ updateInsightTypeConfig( InsightTypeConfig insightTypeConfig, FieldMask updateMask)2169 public final InsightTypeConfig updateInsightTypeConfig( 2170 InsightTypeConfig insightTypeConfig, FieldMask updateMask) { 2171 UpdateInsightTypeConfigRequest request = 2172 UpdateInsightTypeConfigRequest.newBuilder() 2173 .setInsightTypeConfig(insightTypeConfig) 2174 .setUpdateMask(updateMask) 2175 .build(); 2176 return updateInsightTypeConfig(request); 2177 } 2178 2179 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2180 /** 2181 * Updates an InsightTypeConfig change. This will create a new revision of the config. 2182 * 2183 * <p>Sample code: 2184 * 2185 * <pre>{@code 2186 * // This snippet has been automatically generated and should be regarded as a code template only. 2187 * // It will require modifications to work: 2188 * // - It may require correct/in-range values for request initialization. 2189 * // - It may require specifying regional endpoints when creating the service client as shown in 2190 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2191 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 2192 * UpdateInsightTypeConfigRequest request = 2193 * UpdateInsightTypeConfigRequest.newBuilder() 2194 * .setInsightTypeConfig(InsightTypeConfig.newBuilder().build()) 2195 * .setUpdateMask(FieldMask.newBuilder().build()) 2196 * .setValidateOnly(true) 2197 * .build(); 2198 * InsightTypeConfig response = recommenderClient.updateInsightTypeConfig(request); 2199 * } 2200 * }</pre> 2201 * 2202 * @param request The request object containing all of the parameters for the API call. 2203 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2204 */ updateInsightTypeConfig(UpdateInsightTypeConfigRequest request)2205 public final InsightTypeConfig updateInsightTypeConfig(UpdateInsightTypeConfigRequest request) { 2206 return updateInsightTypeConfigCallable().call(request); 2207 } 2208 2209 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2210 /** 2211 * Updates an InsightTypeConfig change. This will create a new revision of the config. 2212 * 2213 * <p>Sample code: 2214 * 2215 * <pre>{@code 2216 * // This snippet has been automatically generated and should be regarded as a code template only. 2217 * // It will require modifications to work: 2218 * // - It may require correct/in-range values for request initialization. 2219 * // - It may require specifying regional endpoints when creating the service client as shown in 2220 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2221 * try (RecommenderClient recommenderClient = RecommenderClient.create()) { 2222 * UpdateInsightTypeConfigRequest request = 2223 * UpdateInsightTypeConfigRequest.newBuilder() 2224 * .setInsightTypeConfig(InsightTypeConfig.newBuilder().build()) 2225 * .setUpdateMask(FieldMask.newBuilder().build()) 2226 * .setValidateOnly(true) 2227 * .build(); 2228 * ApiFuture<InsightTypeConfig> future = 2229 * recommenderClient.updateInsightTypeConfigCallable().futureCall(request); 2230 * // Do something. 2231 * InsightTypeConfig response = future.get(); 2232 * } 2233 * }</pre> 2234 */ 2235 public final UnaryCallable<UpdateInsightTypeConfigRequest, InsightTypeConfig> updateInsightTypeConfigCallable()2236 updateInsightTypeConfigCallable() { 2237 return stub.updateInsightTypeConfigCallable(); 2238 } 2239 2240 @Override close()2241 public final void close() { 2242 stub.close(); 2243 } 2244 2245 @Override shutdown()2246 public void shutdown() { 2247 stub.shutdown(); 2248 } 2249 2250 @Override isShutdown()2251 public boolean isShutdown() { 2252 return stub.isShutdown(); 2253 } 2254 2255 @Override isTerminated()2256 public boolean isTerminated() { 2257 return stub.isTerminated(); 2258 } 2259 2260 @Override shutdownNow()2261 public void shutdownNow() { 2262 stub.shutdownNow(); 2263 } 2264 2265 @Override awaitTermination(long duration, TimeUnit unit)2266 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 2267 return stub.awaitTermination(duration, unit); 2268 } 2269 2270 public static class ListInsightsPagedResponse 2271 extends AbstractPagedListResponse< 2272 ListInsightsRequest, 2273 ListInsightsResponse, 2274 Insight, 2275 ListInsightsPage, 2276 ListInsightsFixedSizeCollection> { 2277 createAsync( PageContext<ListInsightsRequest, ListInsightsResponse, Insight> context, ApiFuture<ListInsightsResponse> futureResponse)2278 public static ApiFuture<ListInsightsPagedResponse> createAsync( 2279 PageContext<ListInsightsRequest, ListInsightsResponse, Insight> context, 2280 ApiFuture<ListInsightsResponse> futureResponse) { 2281 ApiFuture<ListInsightsPage> futurePage = 2282 ListInsightsPage.createEmptyPage().createPageAsync(context, futureResponse); 2283 return ApiFutures.transform( 2284 futurePage, 2285 input -> new ListInsightsPagedResponse(input), 2286 MoreExecutors.directExecutor()); 2287 } 2288 ListInsightsPagedResponse(ListInsightsPage page)2289 private ListInsightsPagedResponse(ListInsightsPage page) { 2290 super(page, ListInsightsFixedSizeCollection.createEmptyCollection()); 2291 } 2292 } 2293 2294 public static class ListInsightsPage 2295 extends AbstractPage<ListInsightsRequest, ListInsightsResponse, Insight, ListInsightsPage> { 2296 ListInsightsPage( PageContext<ListInsightsRequest, ListInsightsResponse, Insight> context, ListInsightsResponse response)2297 private ListInsightsPage( 2298 PageContext<ListInsightsRequest, ListInsightsResponse, Insight> context, 2299 ListInsightsResponse response) { 2300 super(context, response); 2301 } 2302 createEmptyPage()2303 private static ListInsightsPage createEmptyPage() { 2304 return new ListInsightsPage(null, null); 2305 } 2306 2307 @Override createPage( PageContext<ListInsightsRequest, ListInsightsResponse, Insight> context, ListInsightsResponse response)2308 protected ListInsightsPage createPage( 2309 PageContext<ListInsightsRequest, ListInsightsResponse, Insight> context, 2310 ListInsightsResponse response) { 2311 return new ListInsightsPage(context, response); 2312 } 2313 2314 @Override createPageAsync( PageContext<ListInsightsRequest, ListInsightsResponse, Insight> context, ApiFuture<ListInsightsResponse> futureResponse)2315 public ApiFuture<ListInsightsPage> createPageAsync( 2316 PageContext<ListInsightsRequest, ListInsightsResponse, Insight> context, 2317 ApiFuture<ListInsightsResponse> futureResponse) { 2318 return super.createPageAsync(context, futureResponse); 2319 } 2320 } 2321 2322 public static class ListInsightsFixedSizeCollection 2323 extends AbstractFixedSizeCollection< 2324 ListInsightsRequest, 2325 ListInsightsResponse, 2326 Insight, 2327 ListInsightsPage, 2328 ListInsightsFixedSizeCollection> { 2329 ListInsightsFixedSizeCollection(List<ListInsightsPage> pages, int collectionSize)2330 private ListInsightsFixedSizeCollection(List<ListInsightsPage> pages, int collectionSize) { 2331 super(pages, collectionSize); 2332 } 2333 createEmptyCollection()2334 private static ListInsightsFixedSizeCollection createEmptyCollection() { 2335 return new ListInsightsFixedSizeCollection(null, 0); 2336 } 2337 2338 @Override createCollection( List<ListInsightsPage> pages, int collectionSize)2339 protected ListInsightsFixedSizeCollection createCollection( 2340 List<ListInsightsPage> pages, int collectionSize) { 2341 return new ListInsightsFixedSizeCollection(pages, collectionSize); 2342 } 2343 } 2344 2345 public static class ListRecommendationsPagedResponse 2346 extends AbstractPagedListResponse< 2347 ListRecommendationsRequest, 2348 ListRecommendationsResponse, 2349 Recommendation, 2350 ListRecommendationsPage, 2351 ListRecommendationsFixedSizeCollection> { 2352 createAsync( PageContext<ListRecommendationsRequest, ListRecommendationsResponse, Recommendation> context, ApiFuture<ListRecommendationsResponse> futureResponse)2353 public static ApiFuture<ListRecommendationsPagedResponse> createAsync( 2354 PageContext<ListRecommendationsRequest, ListRecommendationsResponse, Recommendation> 2355 context, 2356 ApiFuture<ListRecommendationsResponse> futureResponse) { 2357 ApiFuture<ListRecommendationsPage> futurePage = 2358 ListRecommendationsPage.createEmptyPage().createPageAsync(context, futureResponse); 2359 return ApiFutures.transform( 2360 futurePage, 2361 input -> new ListRecommendationsPagedResponse(input), 2362 MoreExecutors.directExecutor()); 2363 } 2364 ListRecommendationsPagedResponse(ListRecommendationsPage page)2365 private ListRecommendationsPagedResponse(ListRecommendationsPage page) { 2366 super(page, ListRecommendationsFixedSizeCollection.createEmptyCollection()); 2367 } 2368 } 2369 2370 public static class ListRecommendationsPage 2371 extends AbstractPage< 2372 ListRecommendationsRequest, 2373 ListRecommendationsResponse, 2374 Recommendation, 2375 ListRecommendationsPage> { 2376 ListRecommendationsPage( PageContext<ListRecommendationsRequest, ListRecommendationsResponse, Recommendation> context, ListRecommendationsResponse response)2377 private ListRecommendationsPage( 2378 PageContext<ListRecommendationsRequest, ListRecommendationsResponse, Recommendation> 2379 context, 2380 ListRecommendationsResponse response) { 2381 super(context, response); 2382 } 2383 createEmptyPage()2384 private static ListRecommendationsPage createEmptyPage() { 2385 return new ListRecommendationsPage(null, null); 2386 } 2387 2388 @Override createPage( PageContext<ListRecommendationsRequest, ListRecommendationsResponse, Recommendation> context, ListRecommendationsResponse response)2389 protected ListRecommendationsPage createPage( 2390 PageContext<ListRecommendationsRequest, ListRecommendationsResponse, Recommendation> 2391 context, 2392 ListRecommendationsResponse response) { 2393 return new ListRecommendationsPage(context, response); 2394 } 2395 2396 @Override createPageAsync( PageContext<ListRecommendationsRequest, ListRecommendationsResponse, Recommendation> context, ApiFuture<ListRecommendationsResponse> futureResponse)2397 public ApiFuture<ListRecommendationsPage> createPageAsync( 2398 PageContext<ListRecommendationsRequest, ListRecommendationsResponse, Recommendation> 2399 context, 2400 ApiFuture<ListRecommendationsResponse> futureResponse) { 2401 return super.createPageAsync(context, futureResponse); 2402 } 2403 } 2404 2405 public static class ListRecommendationsFixedSizeCollection 2406 extends AbstractFixedSizeCollection< 2407 ListRecommendationsRequest, 2408 ListRecommendationsResponse, 2409 Recommendation, 2410 ListRecommendationsPage, 2411 ListRecommendationsFixedSizeCollection> { 2412 ListRecommendationsFixedSizeCollection( List<ListRecommendationsPage> pages, int collectionSize)2413 private ListRecommendationsFixedSizeCollection( 2414 List<ListRecommendationsPage> pages, int collectionSize) { 2415 super(pages, collectionSize); 2416 } 2417 createEmptyCollection()2418 private static ListRecommendationsFixedSizeCollection createEmptyCollection() { 2419 return new ListRecommendationsFixedSizeCollection(null, 0); 2420 } 2421 2422 @Override createCollection( List<ListRecommendationsPage> pages, int collectionSize)2423 protected ListRecommendationsFixedSizeCollection createCollection( 2424 List<ListRecommendationsPage> pages, int collectionSize) { 2425 return new ListRecommendationsFixedSizeCollection(pages, collectionSize); 2426 } 2427 } 2428 } 2429