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.aiplatform.v1; 18 19 import com.google.api.HttpBody; 20 import com.google.api.core.ApiFuture; 21 import com.google.api.core.ApiFutures; 22 import com.google.api.gax.core.BackgroundResource; 23 import com.google.api.gax.paging.AbstractFixedSizeCollection; 24 import com.google.api.gax.paging.AbstractPage; 25 import com.google.api.gax.paging.AbstractPagedListResponse; 26 import com.google.api.gax.rpc.PageContext; 27 import com.google.api.gax.rpc.UnaryCallable; 28 import com.google.cloud.aiplatform.v1.stub.PredictionServiceStub; 29 import com.google.cloud.aiplatform.v1.stub.PredictionServiceStubSettings; 30 import com.google.cloud.location.GetLocationRequest; 31 import com.google.cloud.location.ListLocationsRequest; 32 import com.google.cloud.location.ListLocationsResponse; 33 import com.google.cloud.location.Location; 34 import com.google.common.util.concurrent.MoreExecutors; 35 import com.google.iam.v1.GetIamPolicyRequest; 36 import com.google.iam.v1.Policy; 37 import com.google.iam.v1.SetIamPolicyRequest; 38 import com.google.iam.v1.TestIamPermissionsRequest; 39 import com.google.iam.v1.TestIamPermissionsResponse; 40 import com.google.protobuf.Value; 41 import java.io.IOException; 42 import java.util.List; 43 import java.util.concurrent.TimeUnit; 44 import javax.annotation.Generated; 45 46 // AUTO-GENERATED DOCUMENTATION AND CLASS. 47 /** 48 * Service Description: A service for online predictions and explanations. 49 * 50 * <p>This class provides the ability to make remote calls to the backing service through method 51 * calls that map to API methods. Sample code to get started: 52 * 53 * <pre>{@code 54 * // This snippet has been automatically generated and should be regarded as a code template only. 55 * // It will require modifications to work: 56 * // - It may require correct/in-range values for request initialization. 57 * // - It may require specifying regional endpoints when creating the service client as shown in 58 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 59 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 60 * EndpointName endpoint = 61 * EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]"); 62 * List<Value> instances = new ArrayList<>(); 63 * Value parameters = Value.newBuilder().setBoolValue(true).build(); 64 * PredictResponse response = predictionServiceClient.predict(endpoint, instances, parameters); 65 * } 66 * }</pre> 67 * 68 * <p>Note: close() needs to be called on the PredictionServiceClient object to clean up resources 69 * such as threads. In the example above, try-with-resources is used, which automatically calls 70 * close(). 71 * 72 * <p>The surface of this class includes several types of Java methods for each of the API's 73 * methods: 74 * 75 * <ol> 76 * <li>A "flattened" method. With this type of method, the fields of the request type have been 77 * converted into function parameters. It may be the case that not all fields are available as 78 * parameters, and not every API method will have a flattened method entry point. 79 * <li>A "request object" method. This type of method only takes one parameter, a request object, 80 * which must be constructed before the call. Not every API method will have a request object 81 * method. 82 * <li>A "callable" method. This type of method takes no parameters and returns an immutable API 83 * callable object, which can be used to initiate calls to the service. 84 * </ol> 85 * 86 * <p>See the individual methods for example code. 87 * 88 * <p>Many parameters require resource names to be formatted in a particular way. To assist with 89 * these names, this class includes a format method for each type of name, and additionally a parse 90 * method to extract the individual identifiers contained within names that are returned. 91 * 92 * <p>This class can be customized by passing in a custom instance of PredictionServiceSettings to 93 * create(). For example: 94 * 95 * <p>To customize credentials: 96 * 97 * <pre>{@code 98 * // This snippet has been automatically generated and should be regarded as a code template only. 99 * // It will require modifications to work: 100 * // - It may require correct/in-range values for request initialization. 101 * // - It may require specifying regional endpoints when creating the service client as shown in 102 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 103 * PredictionServiceSettings predictionServiceSettings = 104 * PredictionServiceSettings.newBuilder() 105 * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) 106 * .build(); 107 * PredictionServiceClient predictionServiceClient = 108 * PredictionServiceClient.create(predictionServiceSettings); 109 * }</pre> 110 * 111 * <p>To customize the endpoint: 112 * 113 * <pre>{@code 114 * // This snippet has been automatically generated and should be regarded as a code template only. 115 * // It will require modifications to work: 116 * // - It may require correct/in-range values for request initialization. 117 * // - It may require specifying regional endpoints when creating the service client as shown in 118 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 119 * PredictionServiceSettings predictionServiceSettings = 120 * PredictionServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); 121 * PredictionServiceClient predictionServiceClient = 122 * PredictionServiceClient.create(predictionServiceSettings); 123 * }</pre> 124 * 125 * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. 126 */ 127 @Generated("by gapic-generator-java") 128 public class PredictionServiceClient implements BackgroundResource { 129 private final PredictionServiceSettings settings; 130 private final PredictionServiceStub stub; 131 132 /** Constructs an instance of PredictionServiceClient with default settings. */ create()133 public static final PredictionServiceClient create() throws IOException { 134 return create(PredictionServiceSettings.newBuilder().build()); 135 } 136 137 /** 138 * Constructs an instance of PredictionServiceClient, using the given settings. The channels are 139 * created based on the settings passed in, or defaults for any settings that are not set. 140 */ create(PredictionServiceSettings settings)141 public static final PredictionServiceClient create(PredictionServiceSettings settings) 142 throws IOException { 143 return new PredictionServiceClient(settings); 144 } 145 146 /** 147 * Constructs an instance of PredictionServiceClient, using the given stub for making calls. This 148 * is for advanced usage - prefer using create(PredictionServiceSettings). 149 */ create(PredictionServiceStub stub)150 public static final PredictionServiceClient create(PredictionServiceStub stub) { 151 return new PredictionServiceClient(stub); 152 } 153 154 /** 155 * Constructs an instance of PredictionServiceClient, using the given settings. This is protected 156 * so that it is easy to make a subclass, but otherwise, the static factory methods should be 157 * preferred. 158 */ PredictionServiceClient(PredictionServiceSettings settings)159 protected PredictionServiceClient(PredictionServiceSettings settings) throws IOException { 160 this.settings = settings; 161 this.stub = ((PredictionServiceStubSettings) settings.getStubSettings()).createStub(); 162 } 163 PredictionServiceClient(PredictionServiceStub stub)164 protected PredictionServiceClient(PredictionServiceStub stub) { 165 this.settings = null; 166 this.stub = stub; 167 } 168 getSettings()169 public final PredictionServiceSettings getSettings() { 170 return settings; 171 } 172 getStub()173 public PredictionServiceStub getStub() { 174 return stub; 175 } 176 177 // AUTO-GENERATED DOCUMENTATION AND METHOD. 178 /** 179 * Perform an online prediction. 180 * 181 * <p>Sample code: 182 * 183 * <pre>{@code 184 * // This snippet has been automatically generated and should be regarded as a code template only. 185 * // It will require modifications to work: 186 * // - It may require correct/in-range values for request initialization. 187 * // - It may require specifying regional endpoints when creating the service client as shown in 188 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 189 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 190 * EndpointName endpoint = 191 * EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]"); 192 * List<Value> instances = new ArrayList<>(); 193 * Value parameters = Value.newBuilder().setBoolValue(true).build(); 194 * PredictResponse response = predictionServiceClient.predict(endpoint, instances, parameters); 195 * } 196 * }</pre> 197 * 198 * @param endpoint Required. The name of the Endpoint requested to serve the prediction. Format: 199 * `projects/{project}/locations/{location}/endpoints/{endpoint}` 200 * @param instances Required. The instances that are the input to the prediction call. A 201 * DeployedModel may have an upper limit on the number of instances it supports per request, 202 * and when it is exceeded the prediction call errors in case of AutoML Models, or, in case of 203 * customer created Models, the behaviour is as documented by that Model. The schema of any 204 * single instance may be specified via Endpoint's DeployedModels' 205 * [Model's][google.cloud.aiplatform.v1.DeployedModel.model] 206 * [PredictSchemata's][google.cloud.aiplatform.v1.Model.predict_schemata] 207 * [instance_schema_uri][google.cloud.aiplatform.v1.PredictSchemata.instance_schema_uri]. 208 * @param parameters The parameters that govern the prediction. The schema of the parameters may 209 * be specified via Endpoint's DeployedModels' [Model's 210 * ][google.cloud.aiplatform.v1.DeployedModel.model] 211 * [PredictSchemata's][google.cloud.aiplatform.v1.Model.predict_schemata] 212 * [parameters_schema_uri][google.cloud.aiplatform.v1.PredictSchemata.parameters_schema_uri]. 213 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 214 */ predict( EndpointName endpoint, List<Value> instances, Value parameters)215 public final PredictResponse predict( 216 EndpointName endpoint, List<Value> instances, Value parameters) { 217 PredictRequest request = 218 PredictRequest.newBuilder() 219 .setEndpoint(endpoint == null ? null : endpoint.toString()) 220 .addAllInstances(instances) 221 .setParameters(parameters) 222 .build(); 223 return predict(request); 224 } 225 226 // AUTO-GENERATED DOCUMENTATION AND METHOD. 227 /** 228 * Perform an online prediction. 229 * 230 * <p>Sample code: 231 * 232 * <pre>{@code 233 * // This snippet has been automatically generated and should be regarded as a code template only. 234 * // It will require modifications to work: 235 * // - It may require correct/in-range values for request initialization. 236 * // - It may require specifying regional endpoints when creating the service client as shown in 237 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 238 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 239 * String endpoint = 240 * EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]") 241 * .toString(); 242 * List<Value> instances = new ArrayList<>(); 243 * Value parameters = Value.newBuilder().setBoolValue(true).build(); 244 * PredictResponse response = predictionServiceClient.predict(endpoint, instances, parameters); 245 * } 246 * }</pre> 247 * 248 * @param endpoint Required. The name of the Endpoint requested to serve the prediction. Format: 249 * `projects/{project}/locations/{location}/endpoints/{endpoint}` 250 * @param instances Required. The instances that are the input to the prediction call. A 251 * DeployedModel may have an upper limit on the number of instances it supports per request, 252 * and when it is exceeded the prediction call errors in case of AutoML Models, or, in case of 253 * customer created Models, the behaviour is as documented by that Model. The schema of any 254 * single instance may be specified via Endpoint's DeployedModels' 255 * [Model's][google.cloud.aiplatform.v1.DeployedModel.model] 256 * [PredictSchemata's][google.cloud.aiplatform.v1.Model.predict_schemata] 257 * [instance_schema_uri][google.cloud.aiplatform.v1.PredictSchemata.instance_schema_uri]. 258 * @param parameters The parameters that govern the prediction. The schema of the parameters may 259 * be specified via Endpoint's DeployedModels' [Model's 260 * ][google.cloud.aiplatform.v1.DeployedModel.model] 261 * [PredictSchemata's][google.cloud.aiplatform.v1.Model.predict_schemata] 262 * [parameters_schema_uri][google.cloud.aiplatform.v1.PredictSchemata.parameters_schema_uri]. 263 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 264 */ predict(String endpoint, List<Value> instances, Value parameters)265 public final PredictResponse predict(String endpoint, List<Value> instances, Value parameters) { 266 PredictRequest request = 267 PredictRequest.newBuilder() 268 .setEndpoint(endpoint) 269 .addAllInstances(instances) 270 .setParameters(parameters) 271 .build(); 272 return predict(request); 273 } 274 275 // AUTO-GENERATED DOCUMENTATION AND METHOD. 276 /** 277 * Perform an online prediction. 278 * 279 * <p>Sample code: 280 * 281 * <pre>{@code 282 * // This snippet has been automatically generated and should be regarded as a code template only. 283 * // It will require modifications to work: 284 * // - It may require correct/in-range values for request initialization. 285 * // - It may require specifying regional endpoints when creating the service client as shown in 286 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 287 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 288 * PredictRequest request = 289 * PredictRequest.newBuilder() 290 * .setEndpoint( 291 * EndpointName.ofProjectLocationEndpointName( 292 * "[PROJECT]", "[LOCATION]", "[ENDPOINT]") 293 * .toString()) 294 * .addAllInstances(new ArrayList<Value>()) 295 * .setParameters(Value.newBuilder().setBoolValue(true).build()) 296 * .build(); 297 * PredictResponse response = predictionServiceClient.predict(request); 298 * } 299 * }</pre> 300 * 301 * @param request The request object containing all of the parameters for the API call. 302 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 303 */ predict(PredictRequest request)304 public final PredictResponse predict(PredictRequest request) { 305 return predictCallable().call(request); 306 } 307 308 // AUTO-GENERATED DOCUMENTATION AND METHOD. 309 /** 310 * Perform an online prediction. 311 * 312 * <p>Sample code: 313 * 314 * <pre>{@code 315 * // This snippet has been automatically generated and should be regarded as a code template only. 316 * // It will require modifications to work: 317 * // - It may require correct/in-range values for request initialization. 318 * // - It may require specifying regional endpoints when creating the service client as shown in 319 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 320 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 321 * PredictRequest request = 322 * PredictRequest.newBuilder() 323 * .setEndpoint( 324 * EndpointName.ofProjectLocationEndpointName( 325 * "[PROJECT]", "[LOCATION]", "[ENDPOINT]") 326 * .toString()) 327 * .addAllInstances(new ArrayList<Value>()) 328 * .setParameters(Value.newBuilder().setBoolValue(true).build()) 329 * .build(); 330 * ApiFuture<PredictResponse> future = 331 * predictionServiceClient.predictCallable().futureCall(request); 332 * // Do something. 333 * PredictResponse response = future.get(); 334 * } 335 * }</pre> 336 */ predictCallable()337 public final UnaryCallable<PredictRequest, PredictResponse> predictCallable() { 338 return stub.predictCallable(); 339 } 340 341 // AUTO-GENERATED DOCUMENTATION AND METHOD. 342 /** 343 * Perform an online prediction with an arbitrary HTTP payload. 344 * 345 * <p>The response includes the following HTTP headers: 346 * 347 * <ul> 348 * <li>`X-Vertex-AI-Endpoint-Id`: ID of the [Endpoint][google.cloud.aiplatform.v1.Endpoint] that 349 * served this prediction. 350 * </ul> 351 * 352 * <ul> 353 * <li>`X-Vertex-AI-Deployed-Model-Id`: ID of the Endpoint's 354 * [DeployedModel][google.cloud.aiplatform.v1.DeployedModel] that served this prediction. 355 * </ul> 356 * 357 * <p>Sample code: 358 * 359 * <pre>{@code 360 * // This snippet has been automatically generated and should be regarded as a code template only. 361 * // It will require modifications to work: 362 * // - It may require correct/in-range values for request initialization. 363 * // - It may require specifying regional endpoints when creating the service client as shown in 364 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 365 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 366 * EndpointName endpoint = 367 * EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]"); 368 * HttpBody httpBody = HttpBody.newBuilder().build(); 369 * HttpBody response = predictionServiceClient.rawPredict(endpoint, httpBody); 370 * } 371 * }</pre> 372 * 373 * @param endpoint Required. The name of the Endpoint requested to serve the prediction. Format: 374 * `projects/{project}/locations/{location}/endpoints/{endpoint}` 375 * @param httpBody The prediction input. Supports HTTP headers and arbitrary data payload. 376 * <p>A [DeployedModel][google.cloud.aiplatform.v1.DeployedModel] may have an upper limit on 377 * the number of instances it supports per request. When this limit it is exceeded for an 378 * AutoML model, the [RawPredict][google.cloud.aiplatform.v1.PredictionService.RawPredict] 379 * method returns an error. When this limit is exceeded for a custom-trained model, the 380 * behavior varies depending on the model. 381 * <p>You can specify the schema for each instance in the 382 * [predict_schemata.instance_schema_uri][google.cloud.aiplatform.v1.PredictSchemata.instance_schema_uri] 383 * field when you create a [Model][google.cloud.aiplatform.v1.Model]. This schema applies when 384 * you deploy the `Model` as a `DeployedModel` to an 385 * [Endpoint][google.cloud.aiplatform.v1.Endpoint] and use the `RawPredict` method. 386 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 387 */ rawPredict(EndpointName endpoint, HttpBody httpBody)388 public final HttpBody rawPredict(EndpointName endpoint, HttpBody httpBody) { 389 RawPredictRequest request = 390 RawPredictRequest.newBuilder() 391 .setEndpoint(endpoint == null ? null : endpoint.toString()) 392 .setHttpBody(httpBody) 393 .build(); 394 return rawPredict(request); 395 } 396 397 // AUTO-GENERATED DOCUMENTATION AND METHOD. 398 /** 399 * Perform an online prediction with an arbitrary HTTP payload. 400 * 401 * <p>The response includes the following HTTP headers: 402 * 403 * <ul> 404 * <li>`X-Vertex-AI-Endpoint-Id`: ID of the [Endpoint][google.cloud.aiplatform.v1.Endpoint] that 405 * served this prediction. 406 * </ul> 407 * 408 * <ul> 409 * <li>`X-Vertex-AI-Deployed-Model-Id`: ID of the Endpoint's 410 * [DeployedModel][google.cloud.aiplatform.v1.DeployedModel] that served this prediction. 411 * </ul> 412 * 413 * <p>Sample code: 414 * 415 * <pre>{@code 416 * // This snippet has been automatically generated and should be regarded as a code template only. 417 * // It will require modifications to work: 418 * // - It may require correct/in-range values for request initialization. 419 * // - It may require specifying regional endpoints when creating the service client as shown in 420 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 421 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 422 * String endpoint = 423 * EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]") 424 * .toString(); 425 * HttpBody httpBody = HttpBody.newBuilder().build(); 426 * HttpBody response = predictionServiceClient.rawPredict(endpoint, httpBody); 427 * } 428 * }</pre> 429 * 430 * @param endpoint Required. The name of the Endpoint requested to serve the prediction. Format: 431 * `projects/{project}/locations/{location}/endpoints/{endpoint}` 432 * @param httpBody The prediction input. Supports HTTP headers and arbitrary data payload. 433 * <p>A [DeployedModel][google.cloud.aiplatform.v1.DeployedModel] may have an upper limit on 434 * the number of instances it supports per request. When this limit it is exceeded for an 435 * AutoML model, the [RawPredict][google.cloud.aiplatform.v1.PredictionService.RawPredict] 436 * method returns an error. When this limit is exceeded for a custom-trained model, the 437 * behavior varies depending on the model. 438 * <p>You can specify the schema for each instance in the 439 * [predict_schemata.instance_schema_uri][google.cloud.aiplatform.v1.PredictSchemata.instance_schema_uri] 440 * field when you create a [Model][google.cloud.aiplatform.v1.Model]. This schema applies when 441 * you deploy the `Model` as a `DeployedModel` to an 442 * [Endpoint][google.cloud.aiplatform.v1.Endpoint] and use the `RawPredict` method. 443 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 444 */ rawPredict(String endpoint, HttpBody httpBody)445 public final HttpBody rawPredict(String endpoint, HttpBody httpBody) { 446 RawPredictRequest request = 447 RawPredictRequest.newBuilder().setEndpoint(endpoint).setHttpBody(httpBody).build(); 448 return rawPredict(request); 449 } 450 451 // AUTO-GENERATED DOCUMENTATION AND METHOD. 452 /** 453 * Perform an online prediction with an arbitrary HTTP payload. 454 * 455 * <p>The response includes the following HTTP headers: 456 * 457 * <ul> 458 * <li>`X-Vertex-AI-Endpoint-Id`: ID of the [Endpoint][google.cloud.aiplatform.v1.Endpoint] that 459 * served this prediction. 460 * </ul> 461 * 462 * <ul> 463 * <li>`X-Vertex-AI-Deployed-Model-Id`: ID of the Endpoint's 464 * [DeployedModel][google.cloud.aiplatform.v1.DeployedModel] that served this prediction. 465 * </ul> 466 * 467 * <p>Sample code: 468 * 469 * <pre>{@code 470 * // This snippet has been automatically generated and should be regarded as a code template only. 471 * // It will require modifications to work: 472 * // - It may require correct/in-range values for request initialization. 473 * // - It may require specifying regional endpoints when creating the service client as shown in 474 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 475 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 476 * RawPredictRequest request = 477 * RawPredictRequest.newBuilder() 478 * .setEndpoint( 479 * EndpointName.ofProjectLocationEndpointName( 480 * "[PROJECT]", "[LOCATION]", "[ENDPOINT]") 481 * .toString()) 482 * .setHttpBody(HttpBody.newBuilder().build()) 483 * .build(); 484 * HttpBody response = predictionServiceClient.rawPredict(request); 485 * } 486 * }</pre> 487 * 488 * @param request The request object containing all of the parameters for the API call. 489 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 490 */ rawPredict(RawPredictRequest request)491 public final HttpBody rawPredict(RawPredictRequest request) { 492 return rawPredictCallable().call(request); 493 } 494 495 // AUTO-GENERATED DOCUMENTATION AND METHOD. 496 /** 497 * Perform an online prediction with an arbitrary HTTP payload. 498 * 499 * <p>The response includes the following HTTP headers: 500 * 501 * <ul> 502 * <li>`X-Vertex-AI-Endpoint-Id`: ID of the [Endpoint][google.cloud.aiplatform.v1.Endpoint] that 503 * served this prediction. 504 * </ul> 505 * 506 * <ul> 507 * <li>`X-Vertex-AI-Deployed-Model-Id`: ID of the Endpoint's 508 * [DeployedModel][google.cloud.aiplatform.v1.DeployedModel] that served this prediction. 509 * </ul> 510 * 511 * <p>Sample code: 512 * 513 * <pre>{@code 514 * // This snippet has been automatically generated and should be regarded as a code template only. 515 * // It will require modifications to work: 516 * // - It may require correct/in-range values for request initialization. 517 * // - It may require specifying regional endpoints when creating the service client as shown in 518 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 519 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 520 * RawPredictRequest request = 521 * RawPredictRequest.newBuilder() 522 * .setEndpoint( 523 * EndpointName.ofProjectLocationEndpointName( 524 * "[PROJECT]", "[LOCATION]", "[ENDPOINT]") 525 * .toString()) 526 * .setHttpBody(HttpBody.newBuilder().build()) 527 * .build(); 528 * ApiFuture<HttpBody> future = predictionServiceClient.rawPredictCallable().futureCall(request); 529 * // Do something. 530 * HttpBody response = future.get(); 531 * } 532 * }</pre> 533 */ rawPredictCallable()534 public final UnaryCallable<RawPredictRequest, HttpBody> rawPredictCallable() { 535 return stub.rawPredictCallable(); 536 } 537 538 // AUTO-GENERATED DOCUMENTATION AND METHOD. 539 /** 540 * Perform an online explanation. 541 * 542 * <p>If [deployed_model_id][google.cloud.aiplatform.v1.ExplainRequest.deployed_model_id] is 543 * specified, the corresponding DeployModel must have 544 * [explanation_spec][google.cloud.aiplatform.v1.DeployedModel.explanation_spec] populated. If 545 * [deployed_model_id][google.cloud.aiplatform.v1.ExplainRequest.deployed_model_id] is not 546 * specified, all DeployedModels must have 547 * [explanation_spec][google.cloud.aiplatform.v1.DeployedModel.explanation_spec] populated. Only 548 * deployed AutoML tabular Models have explanation_spec. 549 * 550 * <p>Sample code: 551 * 552 * <pre>{@code 553 * // This snippet has been automatically generated and should be regarded as a code template only. 554 * // It will require modifications to work: 555 * // - It may require correct/in-range values for request initialization. 556 * // - It may require specifying regional endpoints when creating the service client as shown in 557 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 558 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 559 * EndpointName endpoint = 560 * EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]"); 561 * List<Value> instances = new ArrayList<>(); 562 * Value parameters = Value.newBuilder().setBoolValue(true).build(); 563 * String deployedModelId = "deployedModelId-1817547906"; 564 * ExplainResponse response = 565 * predictionServiceClient.explain(endpoint, instances, parameters, deployedModelId); 566 * } 567 * }</pre> 568 * 569 * @param endpoint Required. The name of the Endpoint requested to serve the explanation. Format: 570 * `projects/{project}/locations/{location}/endpoints/{endpoint}` 571 * @param instances Required. The instances that are the input to the explanation call. A 572 * DeployedModel may have an upper limit on the number of instances it supports per request, 573 * and when it is exceeded the explanation call errors in case of AutoML Models, or, in case 574 * of customer created Models, the behaviour is as documented by that Model. The schema of any 575 * single instance may be specified via Endpoint's DeployedModels' 576 * [Model's][google.cloud.aiplatform.v1.DeployedModel.model] 577 * [PredictSchemata's][google.cloud.aiplatform.v1.Model.predict_schemata] 578 * [instance_schema_uri][google.cloud.aiplatform.v1.PredictSchemata.instance_schema_uri]. 579 * @param parameters The parameters that govern the prediction. The schema of the parameters may 580 * be specified via Endpoint's DeployedModels' [Model's 581 * ][google.cloud.aiplatform.v1.DeployedModel.model] 582 * [PredictSchemata's][google.cloud.aiplatform.v1.Model.predict_schemata] 583 * [parameters_schema_uri][google.cloud.aiplatform.v1.PredictSchemata.parameters_schema_uri]. 584 * @param deployedModelId If specified, this ExplainRequest will be served by the chosen 585 * DeployedModel, overriding 586 * [Endpoint.traffic_split][google.cloud.aiplatform.v1.Endpoint.traffic_split]. 587 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 588 */ explain( EndpointName endpoint, List<Value> instances, Value parameters, String deployedModelId)589 public final ExplainResponse explain( 590 EndpointName endpoint, List<Value> instances, Value parameters, String deployedModelId) { 591 ExplainRequest request = 592 ExplainRequest.newBuilder() 593 .setEndpoint(endpoint == null ? null : endpoint.toString()) 594 .addAllInstances(instances) 595 .setParameters(parameters) 596 .setDeployedModelId(deployedModelId) 597 .build(); 598 return explain(request); 599 } 600 601 // AUTO-GENERATED DOCUMENTATION AND METHOD. 602 /** 603 * Perform an online explanation. 604 * 605 * <p>If [deployed_model_id][google.cloud.aiplatform.v1.ExplainRequest.deployed_model_id] is 606 * specified, the corresponding DeployModel must have 607 * [explanation_spec][google.cloud.aiplatform.v1.DeployedModel.explanation_spec] populated. If 608 * [deployed_model_id][google.cloud.aiplatform.v1.ExplainRequest.deployed_model_id] is not 609 * specified, all DeployedModels must have 610 * [explanation_spec][google.cloud.aiplatform.v1.DeployedModel.explanation_spec] populated. Only 611 * deployed AutoML tabular Models have explanation_spec. 612 * 613 * <p>Sample code: 614 * 615 * <pre>{@code 616 * // This snippet has been automatically generated and should be regarded as a code template only. 617 * // It will require modifications to work: 618 * // - It may require correct/in-range values for request initialization. 619 * // - It may require specifying regional endpoints when creating the service client as shown in 620 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 621 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 622 * String endpoint = 623 * EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]") 624 * .toString(); 625 * List<Value> instances = new ArrayList<>(); 626 * Value parameters = Value.newBuilder().setBoolValue(true).build(); 627 * String deployedModelId = "deployedModelId-1817547906"; 628 * ExplainResponse response = 629 * predictionServiceClient.explain(endpoint, instances, parameters, deployedModelId); 630 * } 631 * }</pre> 632 * 633 * @param endpoint Required. The name of the Endpoint requested to serve the explanation. Format: 634 * `projects/{project}/locations/{location}/endpoints/{endpoint}` 635 * @param instances Required. The instances that are the input to the explanation call. A 636 * DeployedModel may have an upper limit on the number of instances it supports per request, 637 * and when it is exceeded the explanation call errors in case of AutoML Models, or, in case 638 * of customer created Models, the behaviour is as documented by that Model. The schema of any 639 * single instance may be specified via Endpoint's DeployedModels' 640 * [Model's][google.cloud.aiplatform.v1.DeployedModel.model] 641 * [PredictSchemata's][google.cloud.aiplatform.v1.Model.predict_schemata] 642 * [instance_schema_uri][google.cloud.aiplatform.v1.PredictSchemata.instance_schema_uri]. 643 * @param parameters The parameters that govern the prediction. The schema of the parameters may 644 * be specified via Endpoint's DeployedModels' [Model's 645 * ][google.cloud.aiplatform.v1.DeployedModel.model] 646 * [PredictSchemata's][google.cloud.aiplatform.v1.Model.predict_schemata] 647 * [parameters_schema_uri][google.cloud.aiplatform.v1.PredictSchemata.parameters_schema_uri]. 648 * @param deployedModelId If specified, this ExplainRequest will be served by the chosen 649 * DeployedModel, overriding 650 * [Endpoint.traffic_split][google.cloud.aiplatform.v1.Endpoint.traffic_split]. 651 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 652 */ explain( String endpoint, List<Value> instances, Value parameters, String deployedModelId)653 public final ExplainResponse explain( 654 String endpoint, List<Value> instances, Value parameters, String deployedModelId) { 655 ExplainRequest request = 656 ExplainRequest.newBuilder() 657 .setEndpoint(endpoint) 658 .addAllInstances(instances) 659 .setParameters(parameters) 660 .setDeployedModelId(deployedModelId) 661 .build(); 662 return explain(request); 663 } 664 665 // AUTO-GENERATED DOCUMENTATION AND METHOD. 666 /** 667 * Perform an online explanation. 668 * 669 * <p>If [deployed_model_id][google.cloud.aiplatform.v1.ExplainRequest.deployed_model_id] is 670 * specified, the corresponding DeployModel must have 671 * [explanation_spec][google.cloud.aiplatform.v1.DeployedModel.explanation_spec] populated. If 672 * [deployed_model_id][google.cloud.aiplatform.v1.ExplainRequest.deployed_model_id] is not 673 * specified, all DeployedModels must have 674 * [explanation_spec][google.cloud.aiplatform.v1.DeployedModel.explanation_spec] populated. Only 675 * deployed AutoML tabular Models have explanation_spec. 676 * 677 * <p>Sample code: 678 * 679 * <pre>{@code 680 * // This snippet has been automatically generated and should be regarded as a code template only. 681 * // It will require modifications to work: 682 * // - It may require correct/in-range values for request initialization. 683 * // - It may require specifying regional endpoints when creating the service client as shown in 684 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 685 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 686 * ExplainRequest request = 687 * ExplainRequest.newBuilder() 688 * .setEndpoint( 689 * EndpointName.ofProjectLocationEndpointName( 690 * "[PROJECT]", "[LOCATION]", "[ENDPOINT]") 691 * .toString()) 692 * .addAllInstances(new ArrayList<Value>()) 693 * .setParameters(Value.newBuilder().setBoolValue(true).build()) 694 * .setExplanationSpecOverride(ExplanationSpecOverride.newBuilder().build()) 695 * .setDeployedModelId("deployedModelId-1817547906") 696 * .build(); 697 * ExplainResponse response = predictionServiceClient.explain(request); 698 * } 699 * }</pre> 700 * 701 * @param request The request object containing all of the parameters for the API call. 702 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 703 */ explain(ExplainRequest request)704 public final ExplainResponse explain(ExplainRequest request) { 705 return explainCallable().call(request); 706 } 707 708 // AUTO-GENERATED DOCUMENTATION AND METHOD. 709 /** 710 * Perform an online explanation. 711 * 712 * <p>If [deployed_model_id][google.cloud.aiplatform.v1.ExplainRequest.deployed_model_id] is 713 * specified, the corresponding DeployModel must have 714 * [explanation_spec][google.cloud.aiplatform.v1.DeployedModel.explanation_spec] populated. If 715 * [deployed_model_id][google.cloud.aiplatform.v1.ExplainRequest.deployed_model_id] is not 716 * specified, all DeployedModels must have 717 * [explanation_spec][google.cloud.aiplatform.v1.DeployedModel.explanation_spec] populated. Only 718 * deployed AutoML tabular Models have explanation_spec. 719 * 720 * <p>Sample code: 721 * 722 * <pre>{@code 723 * // This snippet has been automatically generated and should be regarded as a code template only. 724 * // It will require modifications to work: 725 * // - It may require correct/in-range values for request initialization. 726 * // - It may require specifying regional endpoints when creating the service client as shown in 727 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 728 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 729 * ExplainRequest request = 730 * ExplainRequest.newBuilder() 731 * .setEndpoint( 732 * EndpointName.ofProjectLocationEndpointName( 733 * "[PROJECT]", "[LOCATION]", "[ENDPOINT]") 734 * .toString()) 735 * .addAllInstances(new ArrayList<Value>()) 736 * .setParameters(Value.newBuilder().setBoolValue(true).build()) 737 * .setExplanationSpecOverride(ExplanationSpecOverride.newBuilder().build()) 738 * .setDeployedModelId("deployedModelId-1817547906") 739 * .build(); 740 * ApiFuture<ExplainResponse> future = 741 * predictionServiceClient.explainCallable().futureCall(request); 742 * // Do something. 743 * ExplainResponse response = future.get(); 744 * } 745 * }</pre> 746 */ explainCallable()747 public final UnaryCallable<ExplainRequest, ExplainResponse> explainCallable() { 748 return stub.explainCallable(); 749 } 750 751 // AUTO-GENERATED DOCUMENTATION AND METHOD. 752 /** 753 * Lists information about the supported locations for this service. 754 * 755 * <p>Sample code: 756 * 757 * <pre>{@code 758 * // This snippet has been automatically generated and should be regarded as a code template only. 759 * // It will require modifications to work: 760 * // - It may require correct/in-range values for request initialization. 761 * // - It may require specifying regional endpoints when creating the service client as shown in 762 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 763 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 764 * ListLocationsRequest request = 765 * ListLocationsRequest.newBuilder() 766 * .setName("name3373707") 767 * .setFilter("filter-1274492040") 768 * .setPageSize(883849137) 769 * .setPageToken("pageToken873572522") 770 * .build(); 771 * for (Location element : predictionServiceClient.listLocations(request).iterateAll()) { 772 * // doThingsWith(element); 773 * } 774 * } 775 * }</pre> 776 * 777 * @param request The request object containing all of the parameters for the API call. 778 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 779 */ listLocations(ListLocationsRequest request)780 public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) { 781 return listLocationsPagedCallable().call(request); 782 } 783 784 // AUTO-GENERATED DOCUMENTATION AND METHOD. 785 /** 786 * Lists information about the supported locations for this service. 787 * 788 * <p>Sample code: 789 * 790 * <pre>{@code 791 * // This snippet has been automatically generated and should be regarded as a code template only. 792 * // It will require modifications to work: 793 * // - It may require correct/in-range values for request initialization. 794 * // - It may require specifying regional endpoints when creating the service client as shown in 795 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 796 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 797 * ListLocationsRequest request = 798 * ListLocationsRequest.newBuilder() 799 * .setName("name3373707") 800 * .setFilter("filter-1274492040") 801 * .setPageSize(883849137) 802 * .setPageToken("pageToken873572522") 803 * .build(); 804 * ApiFuture<Location> future = 805 * predictionServiceClient.listLocationsPagedCallable().futureCall(request); 806 * // Do something. 807 * for (Location element : future.get().iterateAll()) { 808 * // doThingsWith(element); 809 * } 810 * } 811 * }</pre> 812 */ 813 public final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse> listLocationsPagedCallable()814 listLocationsPagedCallable() { 815 return stub.listLocationsPagedCallable(); 816 } 817 818 // AUTO-GENERATED DOCUMENTATION AND METHOD. 819 /** 820 * Lists information about the supported locations for this service. 821 * 822 * <p>Sample code: 823 * 824 * <pre>{@code 825 * // This snippet has been automatically generated and should be regarded as a code template only. 826 * // It will require modifications to work: 827 * // - It may require correct/in-range values for request initialization. 828 * // - It may require specifying regional endpoints when creating the service client as shown in 829 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 830 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 831 * ListLocationsRequest request = 832 * ListLocationsRequest.newBuilder() 833 * .setName("name3373707") 834 * .setFilter("filter-1274492040") 835 * .setPageSize(883849137) 836 * .setPageToken("pageToken873572522") 837 * .build(); 838 * while (true) { 839 * ListLocationsResponse response = 840 * predictionServiceClient.listLocationsCallable().call(request); 841 * for (Location element : response.getLocationsList()) { 842 * // doThingsWith(element); 843 * } 844 * String nextPageToken = response.getNextPageToken(); 845 * if (!Strings.isNullOrEmpty(nextPageToken)) { 846 * request = request.toBuilder().setPageToken(nextPageToken).build(); 847 * } else { 848 * break; 849 * } 850 * } 851 * } 852 * }</pre> 853 */ listLocationsCallable()854 public final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable() { 855 return stub.listLocationsCallable(); 856 } 857 858 // AUTO-GENERATED DOCUMENTATION AND METHOD. 859 /** 860 * Gets information about a location. 861 * 862 * <p>Sample code: 863 * 864 * <pre>{@code 865 * // This snippet has been automatically generated and should be regarded as a code template only. 866 * // It will require modifications to work: 867 * // - It may require correct/in-range values for request initialization. 868 * // - It may require specifying regional endpoints when creating the service client as shown in 869 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 870 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 871 * GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); 872 * Location response = predictionServiceClient.getLocation(request); 873 * } 874 * }</pre> 875 * 876 * @param request The request object containing all of the parameters for the API call. 877 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 878 */ getLocation(GetLocationRequest request)879 public final Location getLocation(GetLocationRequest request) { 880 return getLocationCallable().call(request); 881 } 882 883 // AUTO-GENERATED DOCUMENTATION AND METHOD. 884 /** 885 * Gets information about a location. 886 * 887 * <p>Sample code: 888 * 889 * <pre>{@code 890 * // This snippet has been automatically generated and should be regarded as a code template only. 891 * // It will require modifications to work: 892 * // - It may require correct/in-range values for request initialization. 893 * // - It may require specifying regional endpoints when creating the service client as shown in 894 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 895 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 896 * GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); 897 * ApiFuture<Location> future = 898 * predictionServiceClient.getLocationCallable().futureCall(request); 899 * // Do something. 900 * Location response = future.get(); 901 * } 902 * }</pre> 903 */ getLocationCallable()904 public final UnaryCallable<GetLocationRequest, Location> getLocationCallable() { 905 return stub.getLocationCallable(); 906 } 907 908 // AUTO-GENERATED DOCUMENTATION AND METHOD. 909 /** 910 * Sets the access control policy on the specified resource. Replacesany existing policy. 911 * 912 * <p>Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors. 913 * 914 * <p>Sample code: 915 * 916 * <pre>{@code 917 * // This snippet has been automatically generated and should be regarded as a code template only. 918 * // It will require modifications to work: 919 * // - It may require correct/in-range values for request initialization. 920 * // - It may require specifying regional endpoints when creating the service client as shown in 921 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 922 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 923 * SetIamPolicyRequest request = 924 * SetIamPolicyRequest.newBuilder() 925 * .setResource( 926 * EndpointName.ofProjectLocationEndpointName( 927 * "[PROJECT]", "[LOCATION]", "[ENDPOINT]") 928 * .toString()) 929 * .setPolicy(Policy.newBuilder().build()) 930 * .setUpdateMask(FieldMask.newBuilder().build()) 931 * .build(); 932 * Policy response = predictionServiceClient.setIamPolicy(request); 933 * } 934 * }</pre> 935 * 936 * @param request The request object containing all of the parameters for the API call. 937 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 938 */ setIamPolicy(SetIamPolicyRequest request)939 public final Policy setIamPolicy(SetIamPolicyRequest request) { 940 return setIamPolicyCallable().call(request); 941 } 942 943 // AUTO-GENERATED DOCUMENTATION AND METHOD. 944 /** 945 * Sets the access control policy on the specified resource. Replacesany existing policy. 946 * 947 * <p>Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors. 948 * 949 * <p>Sample code: 950 * 951 * <pre>{@code 952 * // This snippet has been automatically generated and should be regarded as a code template only. 953 * // It will require modifications to work: 954 * // - It may require correct/in-range values for request initialization. 955 * // - It may require specifying regional endpoints when creating the service client as shown in 956 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 957 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 958 * SetIamPolicyRequest request = 959 * SetIamPolicyRequest.newBuilder() 960 * .setResource( 961 * EndpointName.ofProjectLocationEndpointName( 962 * "[PROJECT]", "[LOCATION]", "[ENDPOINT]") 963 * .toString()) 964 * .setPolicy(Policy.newBuilder().build()) 965 * .setUpdateMask(FieldMask.newBuilder().build()) 966 * .build(); 967 * ApiFuture<Policy> future = predictionServiceClient.setIamPolicyCallable().futureCall(request); 968 * // Do something. 969 * Policy response = future.get(); 970 * } 971 * }</pre> 972 */ setIamPolicyCallable()973 public final UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() { 974 return stub.setIamPolicyCallable(); 975 } 976 977 // AUTO-GENERATED DOCUMENTATION AND METHOD. 978 /** 979 * Gets the access control policy for a resource. Returns an empty policyif the resource exists 980 * and does not have a policy set. 981 * 982 * <p>Sample code: 983 * 984 * <pre>{@code 985 * // This snippet has been automatically generated and should be regarded as a code template only. 986 * // It will require modifications to work: 987 * // - It may require correct/in-range values for request initialization. 988 * // - It may require specifying regional endpoints when creating the service client as shown in 989 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 990 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 991 * GetIamPolicyRequest request = 992 * GetIamPolicyRequest.newBuilder() 993 * .setResource( 994 * EndpointName.ofProjectLocationEndpointName( 995 * "[PROJECT]", "[LOCATION]", "[ENDPOINT]") 996 * .toString()) 997 * .setOptions(GetPolicyOptions.newBuilder().build()) 998 * .build(); 999 * Policy response = predictionServiceClient.getIamPolicy(request); 1000 * } 1001 * }</pre> 1002 * 1003 * @param request The request object containing all of the parameters for the API call. 1004 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1005 */ getIamPolicy(GetIamPolicyRequest request)1006 public final Policy getIamPolicy(GetIamPolicyRequest request) { 1007 return getIamPolicyCallable().call(request); 1008 } 1009 1010 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1011 /** 1012 * Gets the access control policy for a resource. Returns an empty policyif the resource exists 1013 * and does not have a policy set. 1014 * 1015 * <p>Sample code: 1016 * 1017 * <pre>{@code 1018 * // This snippet has been automatically generated and should be regarded as a code template only. 1019 * // It will require modifications to work: 1020 * // - It may require correct/in-range values for request initialization. 1021 * // - It may require specifying regional endpoints when creating the service client as shown in 1022 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1023 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 1024 * GetIamPolicyRequest request = 1025 * GetIamPolicyRequest.newBuilder() 1026 * .setResource( 1027 * EndpointName.ofProjectLocationEndpointName( 1028 * "[PROJECT]", "[LOCATION]", "[ENDPOINT]") 1029 * .toString()) 1030 * .setOptions(GetPolicyOptions.newBuilder().build()) 1031 * .build(); 1032 * ApiFuture<Policy> future = predictionServiceClient.getIamPolicyCallable().futureCall(request); 1033 * // Do something. 1034 * Policy response = future.get(); 1035 * } 1036 * }</pre> 1037 */ getIamPolicyCallable()1038 public final UnaryCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable() { 1039 return stub.getIamPolicyCallable(); 1040 } 1041 1042 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1043 /** 1044 * Returns permissions that a caller has on the specified resource. If theresource does not exist, 1045 * this will return an empty set ofpermissions, not a `NOT_FOUND` error. 1046 * 1047 * <p>Note: This operation is designed to be used for buildingpermission-aware UIs and 1048 * command-line tools, not for authorizationchecking. This operation may "fail open" without 1049 * warning. 1050 * 1051 * <p>Sample code: 1052 * 1053 * <pre>{@code 1054 * // This snippet has been automatically generated and should be regarded as a code template only. 1055 * // It will require modifications to work: 1056 * // - It may require correct/in-range values for request initialization. 1057 * // - It may require specifying regional endpoints when creating the service client as shown in 1058 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1059 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 1060 * TestIamPermissionsRequest request = 1061 * TestIamPermissionsRequest.newBuilder() 1062 * .setResource( 1063 * EndpointName.ofProjectLocationEndpointName( 1064 * "[PROJECT]", "[LOCATION]", "[ENDPOINT]") 1065 * .toString()) 1066 * .addAllPermissions(new ArrayList<String>()) 1067 * .build(); 1068 * TestIamPermissionsResponse response = predictionServiceClient.testIamPermissions(request); 1069 * } 1070 * }</pre> 1071 * 1072 * @param request The request object containing all of the parameters for the API call. 1073 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1074 */ testIamPermissions(TestIamPermissionsRequest request)1075 public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request) { 1076 return testIamPermissionsCallable().call(request); 1077 } 1078 1079 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1080 /** 1081 * Returns permissions that a caller has on the specified resource. If theresource does not exist, 1082 * this will return an empty set ofpermissions, not a `NOT_FOUND` error. 1083 * 1084 * <p>Note: This operation is designed to be used for buildingpermission-aware UIs and 1085 * command-line tools, not for authorizationchecking. This operation may "fail open" without 1086 * warning. 1087 * 1088 * <p>Sample code: 1089 * 1090 * <pre>{@code 1091 * // This snippet has been automatically generated and should be regarded as a code template only. 1092 * // It will require modifications to work: 1093 * // - It may require correct/in-range values for request initialization. 1094 * // - It may require specifying regional endpoints when creating the service client as shown in 1095 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1096 * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { 1097 * TestIamPermissionsRequest request = 1098 * TestIamPermissionsRequest.newBuilder() 1099 * .setResource( 1100 * EndpointName.ofProjectLocationEndpointName( 1101 * "[PROJECT]", "[LOCATION]", "[ENDPOINT]") 1102 * .toString()) 1103 * .addAllPermissions(new ArrayList<String>()) 1104 * .build(); 1105 * ApiFuture<TestIamPermissionsResponse> future = 1106 * predictionServiceClient.testIamPermissionsCallable().futureCall(request); 1107 * // Do something. 1108 * TestIamPermissionsResponse response = future.get(); 1109 * } 1110 * }</pre> 1111 */ 1112 public final UnaryCallable<TestIamPermissionsRequest, TestIamPermissionsResponse> testIamPermissionsCallable()1113 testIamPermissionsCallable() { 1114 return stub.testIamPermissionsCallable(); 1115 } 1116 1117 @Override close()1118 public final void close() { 1119 stub.close(); 1120 } 1121 1122 @Override shutdown()1123 public void shutdown() { 1124 stub.shutdown(); 1125 } 1126 1127 @Override isShutdown()1128 public boolean isShutdown() { 1129 return stub.isShutdown(); 1130 } 1131 1132 @Override isTerminated()1133 public boolean isTerminated() { 1134 return stub.isTerminated(); 1135 } 1136 1137 @Override shutdownNow()1138 public void shutdownNow() { 1139 stub.shutdownNow(); 1140 } 1141 1142 @Override awaitTermination(long duration, TimeUnit unit)1143 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 1144 return stub.awaitTermination(duration, unit); 1145 } 1146 1147 public static class ListLocationsPagedResponse 1148 extends AbstractPagedListResponse< 1149 ListLocationsRequest, 1150 ListLocationsResponse, 1151 Location, 1152 ListLocationsPage, 1153 ListLocationsFixedSizeCollection> { 1154 createAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)1155 public static ApiFuture<ListLocationsPagedResponse> createAsync( 1156 PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, 1157 ApiFuture<ListLocationsResponse> futureResponse) { 1158 ApiFuture<ListLocationsPage> futurePage = 1159 ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse); 1160 return ApiFutures.transform( 1161 futurePage, 1162 input -> new ListLocationsPagedResponse(input), 1163 MoreExecutors.directExecutor()); 1164 } 1165 ListLocationsPagedResponse(ListLocationsPage page)1166 private ListLocationsPagedResponse(ListLocationsPage page) { 1167 super(page, ListLocationsFixedSizeCollection.createEmptyCollection()); 1168 } 1169 } 1170 1171 public static class ListLocationsPage 1172 extends AbstractPage< 1173 ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> { 1174 ListLocationsPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)1175 private ListLocationsPage( 1176 PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, 1177 ListLocationsResponse response) { 1178 super(context, response); 1179 } 1180 createEmptyPage()1181 private static ListLocationsPage createEmptyPage() { 1182 return new ListLocationsPage(null, null); 1183 } 1184 1185 @Override createPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)1186 protected ListLocationsPage createPage( 1187 PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, 1188 ListLocationsResponse response) { 1189 return new ListLocationsPage(context, response); 1190 } 1191 1192 @Override createPageAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)1193 public ApiFuture<ListLocationsPage> createPageAsync( 1194 PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, 1195 ApiFuture<ListLocationsResponse> futureResponse) { 1196 return super.createPageAsync(context, futureResponse); 1197 } 1198 } 1199 1200 public static class ListLocationsFixedSizeCollection 1201 extends AbstractFixedSizeCollection< 1202 ListLocationsRequest, 1203 ListLocationsResponse, 1204 Location, 1205 ListLocationsPage, 1206 ListLocationsFixedSizeCollection> { 1207 ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize)1208 private ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize) { 1209 super(pages, collectionSize); 1210 } 1211 createEmptyCollection()1212 private static ListLocationsFixedSizeCollection createEmptyCollection() { 1213 return new ListLocationsFixedSizeCollection(null, 0); 1214 } 1215 1216 @Override createCollection( List<ListLocationsPage> pages, int collectionSize)1217 protected ListLocationsFixedSizeCollection createCollection( 1218 List<ListLocationsPage> pages, int collectionSize) { 1219 return new ListLocationsFixedSizeCollection(pages, collectionSize); 1220 } 1221 } 1222 } 1223