Classe LlmUtilityServiceClient (0.4.0)

public class LlmUtilityServiceClient implements BackgroundResource

Descrizione servizio: servizio per funzioni di utilità correlate a LLM.

Questa classe offre la possibilità di effettuare chiamate remote al servizio di supporto tramite chiamate di metodi mappate ai metodi API. Codice campione per iniziare:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
   EndpointName endpoint =
       EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]");
   List<Value> instances = new ArrayList<>();
   CountTokensResponse response = llmUtilityServiceClient.countTokens(endpoint, instances);
 }
 

Nota: chiudi() deve essere chiamato nell'oggetto LlmUtilityServiceClient per pulire risorse come i thread. Nell'esempio precedente, viene utilizzato provi-with-resources, che chiama automaticamente chiudi().

La superficie di questa classe include diversi tipi di metodi Java per ciascuno dei metodi dell'API:

  1. Un metodo "appiattito". Con questo tipo di metodo, i campi del tipo di richiesta sono stati convertiti in parametri di funzione. È possibile che non tutti i campi siano disponibili come parametri e che non tutti i metodi API abbiano un punto di ingresso del metodo suddiviso.
  2. Un metodo "request Object". Questo tipo di metodo accetta un solo parametro, un oggetto richiesta, che deve essere creato prima della chiamata. Non tutti i metodi API hanno un metodo dell'oggetto di richiesta.
  3. Un metodo "chiamabile". Questo tipo di metodo non accetta parametri e restituisce un oggetto richiamabile API immutabile, che può essere utilizzato per avviare chiamate al servizio.

Consulta i singoli metodi per vedere il codice di esempio.

Molti parametri richiedono che i nomi delle risorse siano formattati in un determinato modo. Per facilitare questi nomi, questa classe include un metodo di formattazione per ogni tipo di nome e un metodo di analisi per estrarre i singoli identificatori contenuti all'interno dei nomi che vengono restituiti.

Questa classe può essere personalizzata passando un'istanza personalizzata di LlmUtilityServiceSettings a create(). Ad esempio:

Per personalizzare le credenziali:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 LlmUtilityServiceSettings llmUtilityServiceSettings =
     LlmUtilityServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 LlmUtilityServiceClient llmUtilityServiceClient =
     LlmUtilityServiceClient.create(llmUtilityServiceSettings);
 

Per personalizzare l'endpoint:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 LlmUtilityServiceSettings llmUtilityServiceSettings =
     LlmUtilityServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 LlmUtilityServiceClient llmUtilityServiceClient =
     LlmUtilityServiceClient.create(llmUtilityServiceSettings);
 

Per utilizzare il trasporto REST (HTTP1.1/JSON) (invece di gRPC) per l'invio e la ricezione delle richieste via rete:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 LlmUtilityServiceSettings llmUtilityServiceSettings =
     LlmUtilityServiceSettings.newHttpJsonBuilder().build();
 LlmUtilityServiceClient llmUtilityServiceClient =
     LlmUtilityServiceClient.create(llmUtilityServiceSettings);
 

Fai riferimento agli esempi del repository GitHub per altri snippet di codice per la guida rapida.

Ereditarietà

java.lang.Object > LlmUtilityServiceClient

Implementa

BackgroundResource

Metodi statici

creare()

public static final LlmUtilityServiceClient create()

Crea un'istanza di LlmUtilityServiceClient con impostazioni predefinite.

Restituisce
Tipo Description
LlmUtilityServiceClient
Eccezioni
Tipo Description
IOException

create(impostazioni LlmUtilityServiceSettings)

public static final LlmUtilityServiceClient create(LlmUtilityServiceSettings settings)

Crea un'istanza di LlmUtilityServiceClient utilizzando le impostazioni specificate. I canali vengono creati in base alle impostazioni trasmesse o ai valori predefiniti di qualsiasi impostazione non configurata.

Parametro
Nome Description
settings LlmUtilityServiceSettings
Restituisce
Tipo Description
LlmUtilityServiceClient
Eccezioni
Tipo Description
IOException

create(stub LlmUtilityServiceStub)

public static final LlmUtilityServiceClient create(LlmUtilityServiceStub stub)

Crea un'istanza di LlmUtilityServiceClient, utilizzando lo stub specificato per effettuare chiamate. Questa opzione è per un utilizzo avanzato; è preferibile utilizzare create(LlmUtilityServiceSettings).

Parametro
Nome Description
stub LlmUtilityServiceStub
Restituisce
Tipo Description
LlmUtilityServiceClient

Costruttori

LlmUtilityServiceClient(LlmUtilityServiceSettings settings)

protected LlmUtilityServiceClient(LlmUtilityServiceSettings settings)

Crea un'istanza di LlmUtilityServiceClient utilizzando le impostazioni specificate. Questo è protetto in modo da semplificare la creazione di una sottoclasse, ma altrimenti i metodi di fabbrica statici sono preferibili.

Parametro
Nome Description
settings LlmUtilityServiceSettings

LlmUtilityServiceClient(LlmUtilityServiceStub stub)

protected LlmUtilityServiceClient(LlmUtilityServiceStub stub)
Parametro
Nome Description
stub LlmUtilityServiceStub

Metodi

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parametri
Nome Description
duration long
unit TimeUnit
Restituisce
Tipo Description
boolean
Eccezioni
Tipo Description
InterruptedException

chiudi()

public final void close()

computeTokens(ComputeTokensRequest request)

public final ComputeTokensResponse computeTokens(ComputeTokensRequest request)

Restituisce un elenco di token in base al testo di input.

Codice campione:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
   ComputeTokensRequest request =
       ComputeTokensRequest.newBuilder()
           .setEndpoint(
               EndpointName.ofProjectLocationEndpointName(
                       "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
                   .toString())
           .addAllInstances(new ArrayList<Value>())
           .build();
   ComputeTokensResponse response = llmUtilityServiceClient.computeTokens(request);
 }
 
Parametro
Nome Description
request ComputeTokensRequest

L'oggetto della richiesta contenente tutti i parametri per la chiamata API.

Restituisce
Tipo Description
ComputeTokensResponse

computeTokens(EndpointName endpoint, List<Value> instances)

public final ComputeTokensResponse computeTokens(EndpointName endpoint, List<Value> instances)

Restituisce un elenco di token in base al testo di input.

Codice campione:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
   EndpointName endpoint =
       EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]");
   List<Value> instances = new ArrayList<>();
   ComputeTokensResponse response = llmUtilityServiceClient.computeTokens(endpoint, instances);
 }
 
Parametri
Nome Description
endpoint EndpointName

Obbligatorio. Il nome dell'endpoint richiesto per ottenere elenchi di token e ID token.

instances List<Value>

Obbligatorio. Le istanze che costituiscono l'input della chiamata API per il calcolo del token. Lo schema è identico a quello di previsione del modello di testo, anche per i modelli non testuali, come i modelli di chat o i modelli Codey.

Restituisce
Tipo Description
ComputeTokensResponse

computeTokens(String endpoint, List<Value> instances)

public final ComputeTokensResponse computeTokens(String endpoint, List<Value> instances)

Restituisce un elenco di token in base al testo di input.

Codice campione:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
   String endpoint =
       EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
           .toString();
   List<Value> instances = new ArrayList<>();
   ComputeTokensResponse response = llmUtilityServiceClient.computeTokens(endpoint, instances);
 }
 
Parametri
Nome Description
endpoint String

Obbligatorio. Il nome dell'endpoint richiesto per ottenere elenchi di token e ID token.

instances List<Value>

Obbligatorio. Le istanze che costituiscono l'input della chiamata API per il calcolo del token. Lo schema è identico a quello di previsione del modello di testo, anche per i modelli non testuali, come i modelli di chat o i modelli Codey.

Restituisce
Tipo Description
ComputeTokensResponse

computeTokensCallable()

public final UnaryCallable<ComputeTokensRequest,ComputeTokensResponse> computeTokensCallable()

Restituisce un elenco di token in base al testo di input.

Codice campione:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
   ComputeTokensRequest request =
       ComputeTokensRequest.newBuilder()
           .setEndpoint(
               EndpointName.ofProjectLocationEndpointName(
                       "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
                   .toString())
           .addAllInstances(new ArrayList<Value>())
           .build();
   ApiFuture<ComputeTokensResponse> future =
       llmUtilityServiceClient.computeTokensCallable().futureCall(request);
   // Do something.
   ComputeTokensResponse response = future.get();
 }
 
Restituisce
Tipo Description
UnaryCallable<ComputeTokensRequest,ComputeTokensResponse>

countTokens(CountTokensRequest request)

public final CountTokensResponse countTokens(CountTokensRequest request)

Esegui un conteggio di token.

Codice campione:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
   CountTokensRequest request =
       CountTokensRequest.newBuilder()
           .setEndpoint(
               EndpointName.ofProjectLocationEndpointName(
                       "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
                   .toString())
           .setModel("model104069929")
           .addAllInstances(new ArrayList<Value>())
           .addAllContents(new ArrayList<Content>())
           .build();
   CountTokensResponse response = llmUtilityServiceClient.countTokens(request);
 }
 
Parametro
Nome Description
request CountTokensRequest

L'oggetto della richiesta contenente tutti i parametri per la chiamata API.

Restituisce
Tipo Description
CountTokensResponse

countTokens(EndpointName endpoint, List<Value> instances)

public final CountTokensResponse countTokens(EndpointName endpoint, List<Value> instances)

Esegui un conteggio di token.

Codice campione:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
   EndpointName endpoint =
       EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]");
   List<Value> instances = new ArrayList<>();
   CountTokensResponse response = llmUtilityServiceClient.countTokens(endpoint, instances);
 }
 
Parametri
Nome Description
endpoint EndpointName

Obbligatorio. Il nome dell'endpoint per cui è stato richiesto il conteggio dei token. Formato: projects/{project}/locations/{location}/endpoints/{endpoint}

instances List<Value>

Obbligatorio. Le istanze che costituiscono l'input della chiamata di conteggio dei token. Lo schema è identico a quello di previsione del modello sottostante.

Restituisce
Tipo Description
CountTokensResponse

countTokens(String endpoint, List<Value> instances)

public final CountTokensResponse countTokens(String endpoint, List<Value> instances)

Esegui un conteggio di token.

Codice campione:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
   String endpoint =
       EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
           .toString();
   List<Value> instances = new ArrayList<>();
   CountTokensResponse response = llmUtilityServiceClient.countTokens(endpoint, instances);
 }
 
Parametri
Nome Description
endpoint String

Obbligatorio. Il nome dell'endpoint per cui è stato richiesto il conteggio dei token. Formato: projects/{project}/locations/{location}/endpoints/{endpoint}

instances List<Value>

Obbligatorio. Le istanze che costituiscono l'input della chiamata di conteggio dei token. Lo schema è identico a quello di previsione del modello sottostante.

Restituisce
Tipo Description
CountTokensResponse

countTokensCallable()

public final UnaryCallable<CountTokensRequest,CountTokensResponse> countTokensCallable()

Esegui un conteggio di token.

Codice campione:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
   CountTokensRequest request =
       CountTokensRequest.newBuilder()
           .setEndpoint(
               EndpointName.ofProjectLocationEndpointName(
                       "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
                   .toString())
           .setModel("model104069929")
           .addAllInstances(new ArrayList<Value>())
           .addAllContents(new ArrayList<Content>())
           .build();
   ApiFuture<CountTokensResponse> future =
       llmUtilityServiceClient.countTokensCallable().futureCall(request);
   // Do something.
   CountTokensResponse response = future.get();
 }
 
Restituisce
Tipo Description
UnaryCallable<CountTokensRequest,CountTokensResponse>

getIamPolicy(GetIamPolicyRequest request)

public final Policy getIamPolicy(GetIamPolicyRequest request)

Ottieni il criterio di controllo dell'accesso per una risorsa. Restituisce un criterio vuoto se la risorsa esiste e non è stato impostato un criterio.

Codice campione:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
   GetIamPolicyRequest request =
       GetIamPolicyRequest.newBuilder()
           .setResource(
               EndpointName.ofProjectLocationEndpointName(
                       "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
                   .toString())
           .setOptions(GetPolicyOptions.newBuilder().build())
           .build();
   Policy response = llmUtilityServiceClient.getIamPolicy(request);
 }
 
Parametro
Nome Description
request com.google.iam.v1.GetIamPolicyRequest

L'oggetto della richiesta contenente tutti i parametri per la chiamata API.

Restituisce
Tipo Description
com.google.iam.v1.Policy

getIamPolicyCallable()

public final UnaryCallable<GetIamPolicyRequest,Policy> getIamPolicyCallable()

Ottieni il criterio di controllo dell'accesso per una risorsa. Restituisce un criterio vuoto se la risorsa esiste e non è stato impostato un criterio.

Codice campione:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
   GetIamPolicyRequest request =
       GetIamPolicyRequest.newBuilder()
           .setResource(
               EndpointName.ofProjectLocationEndpointName(
                       "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
                   .toString())
           .setOptions(GetPolicyOptions.newBuilder().build())
           .build();
   ApiFuture<Policy> future = llmUtilityServiceClient.getIamPolicyCallable().futureCall(request);
   // Do something.
   Policy response = future.get();
 }
 
Restituisce
Tipo Description
UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy>

getLocation(GetLocationRequest request)

public final Location getLocation(GetLocationRequest request)

Recupera le informazioni su una posizione.

Codice campione:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
   Location response = llmUtilityServiceClient.getLocation(request);
 }
 
Parametro
Nome Description
request com.google.cloud.location.GetLocationRequest

L'oggetto della richiesta contenente tutti i parametri per la chiamata API.

Restituisce
Tipo Description
com.google.cloud.location.Location

getLocationCallable()

public final UnaryCallable<GetLocationRequest,Location> getLocationCallable()

Recupera le informazioni su una posizione.

Codice campione:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
   ApiFuture<Location> future =
       llmUtilityServiceClient.getLocationCallable().futureCall(request);
   // Do something.
   Location response = future.get();
 }
 
Restituisce
Tipo Description
UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location>

getSettings()

public final LlmUtilityServiceSettings getSettings()
Restituisce
Tipo Description
LlmUtilityServiceSettings

getStub()

public LlmUtilityServiceStub getStub()
Restituisce
Tipo Description
LlmUtilityServiceStub

isShutdown()

public boolean isShutdown()
Restituisce
Tipo Description
boolean

isTerminated()

public boolean isTerminated()
Restituisce
Tipo Description
boolean

listLocations(ListLocationsRequest request)

public final LlmUtilityServiceClient.ListLocationsPagedResponse listLocations(ListLocationsRequest request)

Elenca le informazioni sulle località supportate per questo servizio.

Codice campione:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
   ListLocationsRequest request =
       ListLocationsRequest.newBuilder()
           .setName("name3373707")
           .setFilter("filter-1274492040")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (Location element : llmUtilityServiceClient.listLocations(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parametro
Nome Description
request com.google.cloud.location.ListLocationsRequest

L'oggetto della richiesta contenente tutti i parametri per la chiamata API.

Restituisce
Tipo Description
LlmUtilityServiceClient.ListLocationsPagedResponse

listLocationsCallable()

public final UnaryCallable<ListLocationsRequest,ListLocationsResponse> listLocationsCallable()

Elenca le informazioni sulle località supportate per questo servizio.

Codice campione:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
   ListLocationsRequest request =
       ListLocationsRequest.newBuilder()
           .setName("name3373707")
           .setFilter("filter-1274492040")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     ListLocationsResponse response =
         llmUtilityServiceClient.listLocationsCallable().call(request);
     for (Location element : response.getLocationsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Restituisce
Tipo Description
UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse>

listLocationsPagedCallable()

public final UnaryCallable<ListLocationsRequest,LlmUtilityServiceClient.ListLocationsPagedResponse> listLocationsPagedCallable()

Elenca le informazioni sulle località supportate per questo servizio.

Codice campione:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
   ListLocationsRequest request =
       ListLocationsRequest.newBuilder()
           .setName("name3373707")
           .setFilter("filter-1274492040")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<Location> future =
       llmUtilityServiceClient.listLocationsPagedCallable().futureCall(request);
   // Do something.
   for (Location element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Restituisce
Tipo Description
UnaryCallable<com.google.cloud.location.ListLocationsRequest,ListLocationsPagedResponse>

setIamPolicy(SetIamPolicyRequest request)

public final Policy setIamPolicy(SetIamPolicyRequest request)

Imposta il criterio di controllo dell'accesso sulla risorsa specificata. Sostituisce qualsiasi criterio esistente.

Può restituire errori NOT_FOUND, INVALID_ARGUMENT e PERMISSION_DENIED.

Codice campione:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
   SetIamPolicyRequest request =
       SetIamPolicyRequest.newBuilder()
           .setResource(
               EndpointName.ofProjectLocationEndpointName(
                       "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
                   .toString())
           .setPolicy(Policy.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   Policy response = llmUtilityServiceClient.setIamPolicy(request);
 }
 
Parametro
Nome Description
request com.google.iam.v1.SetIamPolicyRequest

L'oggetto della richiesta contenente tutti i parametri per la chiamata API.

Restituisce
Tipo Description
com.google.iam.v1.Policy

setIamPolicyCallable()

public final UnaryCallable<SetIamPolicyRequest,Policy> setIamPolicyCallable()

Imposta il criterio di controllo dell'accesso sulla risorsa specificata. Sostituisce qualsiasi criterio esistente.

Può restituire errori NOT_FOUND, INVALID_ARGUMENT e PERMISSION_DENIED.

Codice campione:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
   SetIamPolicyRequest request =
       SetIamPolicyRequest.newBuilder()
           .setResource(
               EndpointName.ofProjectLocationEndpointName(
                       "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
                   .toString())
           .setPolicy(Policy.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<Policy> future = llmUtilityServiceClient.setIamPolicyCallable().futureCall(request);
   // Do something.
   Policy response = future.get();
 }
 
Restituisce
Tipo Description
UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy>

stop()

public void shutdown()

stopNow()

public void shutdownNow()

testIamPermissions(TestIamPermissionsRequest request)

public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request)

Restituisce le autorizzazioni di cui un chiamante dispone per la risorsa specificata. Se la risorsa non esiste, verrà restituito un set di autorizzazioni vuoto, non un errore NOT_FOUND.

Nota: questa operazione è progettata per essere utilizzata per UI e strumenti a riga di comando che supportano la creazione di autorizzazioni, non per il controllo delle autorizzazioni. Questa operazione potrebbe non riuscire ad aprirsi senza avviso.

Codice campione:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
   TestIamPermissionsRequest request =
       TestIamPermissionsRequest.newBuilder()
           .setResource(
               EndpointName.ofProjectLocationEndpointName(
                       "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
                   .toString())
           .addAllPermissions(new ArrayList<String>())
           .build();
   TestIamPermissionsResponse response = llmUtilityServiceClient.testIamPermissions(request);
 }
 
Parametro
Nome Description
request com.google.iam.v1.TestIamPermissionsRequest

L'oggetto della richiesta contenente tutti i parametri per la chiamata API.

Restituisce
Tipo Description
com.google.iam.v1.TestIamPermissionsResponse

testIamPermissionsCallable()

public final UnaryCallable<TestIamPermissionsRequest,TestIamPermissionsResponse> testIamPermissionsCallable()

Restituisce le autorizzazioni di cui un chiamante dispone per la risorsa specificata. Se la risorsa non esiste, verrà restituito un set di autorizzazioni vuoto, non un errore NOT_FOUND.

Nota: questa operazione è progettata per essere utilizzata per UI e strumenti a riga di comando che supportano la creazione di autorizzazioni, non per il controllo delle autorizzazioni. Questa operazione potrebbe non riuscire ad aprirsi senza avviso.

Codice campione:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
   TestIamPermissionsRequest request =
       TestIamPermissionsRequest.newBuilder()
           .setResource(
               EndpointName.ofProjectLocationEndpointName(
                       "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
                   .toString())
           .addAllPermissions(new ArrayList<String>())
           .build();
   ApiFuture<TestIamPermissionsResponse> future =
       llmUtilityServiceClient.testIamPermissionsCallable().futureCall(request);
   // Do something.
   TestIamPermissionsResponse response = future.get();
 }
 
Restituisce
Tipo Description
UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse>