### Python Setup for Gemini Enterprise Source: https://docs.cloud.google.com/gemini/enterprise/docs/answer Before running the sample, follow the Python setup instructions in the Gemini Enterprise quickstart using client libraries. Ensure Application Default Credentials are set up for authentication. ```python from google.api_core.client_options import ClientOptions from google.cloud import discoveryengine_v1 as discoveryengine # TODO(developer): Uncomment these variables before running the sample. ``` -------------------------------- ### Example Get Identity Mapping Store Source: https://docs.cloud.google.com/gemini/enterprise/docs/identity-mapping An example command to retrieve the configuration of an identity mapping store named 'test-id-mapping-store' from a project named 'example-project'. ```bash curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ -H "X-Goog-User-Project: example-project" \ "https://discoveryengine.googleapis.com/v1/projects/example-project/locations/global/identityMappingStores/test-id-mapping-store" ``` -------------------------------- ### Python Setup for Gemini Enterprise API Source: https://docs.cloud.google.com/gemini/enterprise/docs/delete-datastores This Python snippet shows necessary imports and client options for authenticating and interacting with the Gemini Enterprise API. Follow the quickstart guide for full setup. ```python from google.api_core.client_options import ClientOptions from google.cloud import discoveryengine ``` -------------------------------- ### Install Node.js Client Library Source: https://docs.cloud.google.com/gemini/enterprise/docs/libraries Use npm to install the @google-cloud/discoveryengine package for Node.js projects. ```javascript npm install @google-cloud/discoveryengine ``` -------------------------------- ### Install Ruby Client Library Source: https://docs.cloud.google.com/gemini/enterprise/docs/libraries Use gem to install the google-cloud-discovery_engine-v1beta gem for Ruby projects. ```ruby gem install google-cloud-discovery_engine-v1beta ``` -------------------------------- ### Python Setup for Discovery Engine Source: https://docs.cloud.google.com/gemini/enterprise/docs/answer This Python code snippet outlines the necessary imports and variable declarations for using the Discovery Engine client library. Ensure you have followed the Gemini Enterprise quickstart and set up Application Default Credentials. ```python from google.api_core.client_options import ClientOptions from google.cloud import discoveryengine_v1 as discoveryengine # TODO(developer): Uncomment these variables before running the sample. # project_id = "YOUR_PROJECT_ID" # location = "YOUR_LOCATION" # Values: "global", "us", "eu" ``` -------------------------------- ### Install Python Client Library Source: https://docs.cloud.google.com/gemini/enterprise/docs/libraries Use pip to install or upgrade the google-cloud-discoveryengine package for Python projects. ```python pip install --upgrade google-cloud-discoveryengine ``` -------------------------------- ### Clone Repository and Navigate to Sample Directory Source: https://docs.cloud.google.com/gemini/enterprise/docs/a2ui-agents/tutorial-host-agent-cloud-run Clone the A2UI repository and navigate to the cloud_run sample directory to begin the tutorial. ```bash git clone https://github.com/google/A2UI.git cd A2UI/samples/agent/adk/gemini_enterprise/cloud_run ``` -------------------------------- ### Get Operation Status (Example with Specifics) Source: https://docs.cloud.google.com/gemini/enterprise/docs/view-analytics An example of how to get the status of an export metrics operation using specific project and engine details. ```bash curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://discoveryengine.googleapis.com/v1alpha/projects/my-project-123/locations/global/collections/default_collection/engines/my-app/operations/export-metrics-123456789012345678901" ``` -------------------------------- ### Install C# Client Library Source: https://docs.cloud.google.com/gemini/enterprise/docs/libraries Use this command to install the Google.Cloud.DiscoveryEngine.V1Beta package for C# projects. It is recommended to use the -Pre flag for pre-release versions. ```csharp Install-Package Google.Cloud.DiscoveryEngine.V1Beta -Pre ``` -------------------------------- ### Example Get CMEK Configuration Source: https://docs.cloud.google.com/gemini/enterprise/docs/cmek An example of calling the GetCmekConfig method and its expected JSON response. ```curl $ curl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)" "https://us-discoveryengine.googleapis.com/v1/projects/my-ai-app-project-123/locations/us/cmekConfigs/default_cmek_config" ``` ```json { "name": "projects/my-ai-app-project-123/locations/us/cmekConfigs/default_cmek_config", "kmsKey": "projects/key-project-456/locations/us/keyRings/my-key-ring/cryptoKeys/my-key" "state": "ACTIVE" "isDefault": true } ``` -------------------------------- ### Answer Query with Default Settings Source: https://docs.cloud.google.com/gemini/enterprise/docs/answer This sample demonstrates how to call the `answer_query` method with basic configurations. It sets up the client, defines the serving config, and initializes a request with a sample query. ```Python def answer_query_sample( project_id: str, location: str, engine_id: str, ) -> discoveryengine.AnswerQueryResponse: # For more information, refer to: # https://cloud.google.com/generative-ai-app-builder/docs/locations#specify_a_multi-region_for_your_data_store client_options = ( ClientOptions(api_endpoint=f"{location}-discoveryengine.googleapis.com") if location != "global" else None ) # Create a client client = discoveryengine.ConversationalSearchServiceClient( client_options=client_options ) # The full resource name of the Search serving config serving_config = f"projects/{project_id}/locations/{location}/collections/default_collection/engines/{engine_id}/servingConfigs/default_serving_config" # Optional: Options for query phase # The `query_understanding_spec` below includes all available query phase options. # For more details, refer to https://cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1/QueryUnderstandingSpec query_understanding_spec = discoveryengine.AnswerQueryRequest.QueryUnderstandingSpec( query_rephraser_spec=discoveryengine.AnswerQueryRequest.QueryUnderstandingSpec.QueryRephraserSpec( disable=False, # Optional: Disable query rephraser max_rephrase_steps=1, # Optional: Number of rephrase steps ), # Optional: Classify query types query_classification_spec=discoveryengine.AnswerQueryRequest.QueryUnderstandingSpec.QueryClassificationSpec( types=[ discoveryengine.AnswerQueryRequest.QueryUnderstandingSpec.QueryClassificationSpec.Type.ADVERSARIAL_QUERY, discoveryengine.AnswerQueryRequest.QueryUnderstandingSpec.QueryClassificationSpec.Type.NON_ANSWER_SEEKING_QUERY, ] # Options: ADVERSARIAL_QUERY, NON_ANSWER_SEEKING_QUERY or both ), ) # Optional: Options for answer phase # The `answer_generation_spec` below includes all available query phase options. # For more details, refer to https://cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1/AnswerGenerationSpec answer_generation_spec = discoveryengine.AnswerQueryRequest.AnswerGenerationSpec( ignore_adversarial_query=False, # Optional: Ignore adversarial query ignore_non_answer_seeking_query=False, # Optional: Ignore non-answer seeking query ignore_low_relevant_content=False, # Optional: Return fallback answer when content is not relevant model_spec=discoveryengine.AnswerQueryRequest.AnswerGenerationSpec.ModelSpec( # Use the 2026 stable production model for answer generation model_version="gemini-2.5-flash/answer_gen/stable", ), prompt_spec=discoveryengine.AnswerQueryRequest.AnswerGenerationSpec.PromptSpec( preamble="Give a detailed answer.", # Optional: Natural language instructions for customizing the answer. ), include_citations=True, # Optional: Include citations in the response answer_language_code="en", # Optional: Language code of the answer ) # Initialize request argument(s) request = discoveryengine.AnswerQueryRequest( serving_config=serving_config, query=discoveryengine.Query(text="What is Vertex AI Search?"), session=None, # Optional: include previous session ID to continue a conversation query_understanding_spec=query_understanding_spec, answer_generation_spec=answer_generation_spec, user_pseudo_id="user-pseudo-id", # Optional: Add user pseudo-identifier for queries. ) # Make the request response = client.answer_query(request) # Handle the response print(response) return response ``` -------------------------------- ### Workforce Identity Federation Audit Log Example Source: https://docs.cloud.google.com/gemini/enterprise/docs/configure-identity-provider Example of mapped attributes in audit logs for verifying Workforce Identity Federation setup. ```json "metadata": { "mapped_attributes": { "attributes.as_user_identifier_1": "alex@admin.altostrat.com" "google.subject": "alex@altostrat.com" "google.groups": "[123abc-456d, efg-h789-ijk]" } }, ``` -------------------------------- ### discoveryengine.ideaForgeInstances.start Source: https://docs.cloud.google.com/gemini/enterprise/docs/access-control Starts an idea forge instance. ```APIDOC ## POST /v1/projects/{projectId}/locations/{locationId}/ideaForgeInstances/{ideaForgeInstanceId}:start ### Description Starts an idea forge instance. ### Method POST ### Endpoint `/v1/projects/{projectId}/locations/{locationId}/ideaForgeInstances/{ideaForgeInstanceId}:start` ``` -------------------------------- ### Get Schema Definition in Ruby Source: https://docs.cloud.google.com/gemini/enterprise/docs/get-schema-definition This Ruby snippet demonstrates how to get a schema. It requires authentication setup and may need regional endpoint specification for the client. ```ruby require "google/cloud/discovery_engine/v1" ## # Snippet for the get_schema call in the SchemaService service # # 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/ruby/docs/reference. # # This is an auto-generated example demonstrating basic usage of # Google::Cloud::DiscoveryEngine::V1::SchemaService::Client#get_schema. # def get_schema # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::DiscoveryEngine::V1::SchemaService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::DiscoveryEngine::V1::GetSchemaRequest.new # Call the get_schema method. result = client.get_schema request # The returned object is of type Google::Cloud::DiscoveryEngine::V1::Schema. p result end ``` -------------------------------- ### Example: Get IAM Policy Command and Result Source: https://docs.cloud.google.com/gemini/enterprise/docs/delete-app Demonstrates an example of the `getIamPolicy` command and its expected JSON response, including the crucial 'etag' value needed for subsequent policy updates. ```curl curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://global-discoveryengine.googleapis.com/v1/projects/my-project-123/locations/global/collections/default_collection/engines/my-app:getIamPolicy" ``` ```json { "version": 1, "etag": "1234567890" } ``` -------------------------------- ### discoveryengine.sampleQueries.import Source: https://docs.cloud.google.com/gemini/enterprise/docs/access-control Imports sample queries. ```APIDOC ## POST /v1/projects/{projectId}/locations/{locationId}/dataStores/{dataStoreId}/sampleQueries:import ### Description Imports sample queries. ### Method POST ### Endpoint `/v1/projects/{projectId}/locations/{locationId}/dataStores/{dataStoreId}/sampleQueries:import` ``` -------------------------------- ### Example A2A Agent Registration Command Source: https://docs.cloud.google.com/gemini/enterprise/docs/register-and-manage-an-a2a-agent This is a concrete example of the registration command with sample values. It demonstrates how to populate the fields for a basic 'Hello World' agent. ```bash curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ https://global-discoveryengine.googleapis.com/v1alpha/projects/123456/locations/global/collections/default_collection/engines/my-app/assistants/default_assistant/agents \ -d ' { "name": "Hello World Agent", "displayName": "Hello World Agent", "description": "Just a hello world agent", "a2aAgentDefinition": { "jsonAgentCard": "{\"protocolVersion\":\"0.3.0\",\"name\":\"Hello World Agent\",\"description\":\"Just a hello world agent\",\"url\":\"https://example.com/myagent\",\"version\":\"1.0.0\",\"defaultInputModes\":[\"text\"],\"defaultOutputModes\":[\"text\"],\"capabilities\":{},\"skills\":[{\"description\":\"Chat with the Gemini agent.\",\"examples\":[\"Hello, world!\"],\"id\":\"chat\",\"name\":\"Chat Skill\",\"tags\":[\"chat\"]}]}" } }' ``` -------------------------------- ### View Guided Search Results Source: https://docs.cloud.google.com/gemini/enterprise/docs/preview-search-results This JSON structure shows an example of guided search results, including refinement attributes like color and category. These attributes can be used to filter subsequent search queries. ```json { "guidedSearchResult": { "refinementAttributes": [ { "attributeKey": "_gs.color", "attributeValue": "green" }, { "attributeKey": "_gs.category", "attributeValue": "shoe" } ] } } ``` -------------------------------- ### discoveryengine.sampleQueries.create Source: https://docs.cloud.google.com/gemini/enterprise/docs/access-control Creates a sample query. ```APIDOC ## POST /v1/projects/{projectId}/locations/{locationId}/dataStores/{dataStoreId}/sampleQueries ### Description Creates a sample query. ### Method POST ### Endpoint `/v1/projects/{projectId}/locations/{locationId}/dataStores/{dataStoreId}/sampleQueries` ``` -------------------------------- ### Example Command to Import Autocomplete Suggestions Source: https://docs.cloud.google.com/gemini/enterprise/docs/configure-autocomplete An example cURL command demonstrating how to import autocomplete suggestions from a specific BigQuery table. This includes sample project and data store IDs. ```bash curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ -H "X-Goog-User-Project: my-project-123" \ "https://discoveryengine.googleapis.com/v1/projects/my-project-123/locations/global/dataStores/my-data-store/completionSuggestions:import" \ -d '{ "bigquery_source": {"project_id": "my-project-123", "dataset_id": "autocomplete", "table_id": "import_suggestion2"} }' ``` -------------------------------- ### projects.locations.collections.engines.controls.get Source: https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/projects.locations.collections.engines.controls/get Gets a Control. This method allows you to retrieve the details of a specific control within your Discovery Engine setup. ```APIDOC ## GET projects.locations.collections.engines.controls.get ### Description Gets a Control. This method allows you to retrieve the details of a specific control within your Discovery Engine setup. ### Method GET ### Endpoint `https://discoveryengine.googleapis.com/v1/{name=projects/*/locations/*/collections/*/engines/*/controls/*}` ### Parameters #### Path Parameters - **name** (string) - Required. The resource name of the Control to get. Format: `projects/{project}/locations/{location}/collections/{collectionId}/engines/{engineId}/controls/{controlId}` ### Request Body The request body must be empty. ### Response Body If successful, the response body contains an instance of `Control`. ``` -------------------------------- ### Install PHP Client Library Source: https://docs.cloud.google.com/gemini/enterprise/docs/libraries Use composer to require the google/cloud-discoveryengine package for PHP projects. ```php composer require google/cloud-discoveryengine ``` -------------------------------- ### Example cURL Command for Search and Answer Source: https://docs.cloud.google.com/gemini/enterprise/docs/answer This is a concrete example of the cURL command to search and get results with a generated answer, allowing up to five rephrasing steps. It demonstrates the structure for specifying the query and the maximum rephrase steps. ```bash curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/my-project-123/locations/global/collections/default_collection/engines/my-app/servingConfigs/default_search:answer" \ -d '{ \ "query": { "text": "How much longer does it take to train a recommendations model than a search model"}, \ "queryUnderstandingSpec": { \ "queryRephraserSpec": { \ "maxRephraseSteps": 5 \ } \ } \ }' ``` -------------------------------- ### Send Autocomplete Request with Imported Suggestions Source: https://docs.cloud.google.com/gemini/enterprise/docs/configure-autocomplete Send a GET request to the completeQuery method, setting query_model to 'imported-suggestion' to retrieve suggestions from your imported list. This example uses sample project and data store IDs. ```bash curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "X-Goog-User-Project: my-project-123" \ "https://discoveryengine.googleapis.com/v1/projects/my-project-123/locations/global/collections/default_collection/dataStores/my-data-store:completeQuery?query=t&query_model=imported-suggestion" ``` -------------------------------- ### Get Schema using Go Client Library Source: https://docs.cloud.google.com/gemini/enterprise/docs/get-schema-definition Provides a Go code snippet for fetching a schema definition using the Gemini Enterprise Go client library. It includes client creation and request setup. ```Go package main import ( "context" discoveryengine "cloud.google.com/go/discoveryengine/apiv1" discoveryenginepb "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb" ) func main() { ctx := context.Background() // 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://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := discoveryengine.NewSchemaClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &discoveryenginepb.GetSchemaRequest{ // TODO: Fill request struct fields. } } ``` -------------------------------- ### Retrieve Access Token and Call IAM API with PowerShell Source: https://docs.cloud.google.com/gemini/enterprise/docs/authentication Use this PowerShell command to get an access token and then call the IAM API to list service accounts for a project. Ensure you have the gcloud CLI installed and authenticated. ```powershell $cred = gcloud auth print-access-token $headers = @{ "Authorization" = "Bearer $cred" } Invoke-WebRequest ` -Method GET ` -Headers $headers ` -Uri "https://iam.googleapis.com/v1/projects/PROJECT_ID/serviceAccounts" | Select-Object -Expand Content ``` -------------------------------- ### Create Compute Engine Instance with Service Account Source: https://docs.cloud.google.com/gemini/enterprise/docs/authentication Create a Compute Engine instance and attach a service account to it for authentication. Replace INSTANCE_NAME, ZONE, and SERVICE_ACCOUNT_EMAIL with your specific details. ```bash gcloud compute instances create INSTANCE_NAME --zone=ZONE --service-account=SERVICE_ACCOUNT_EMAIL ``` -------------------------------- ### Example Prompt for Ad Campaign Generation Source: https://docs.cloud.google.com/gemini/enterprise/docs/use-case-ad-messaging Use this prompt structure to guide Gemini Enterprise in generating ad campaign content. Specify the product, target audience, pain points, desired number of creative angles, and the tone of voice. ```plaintext We are launching a new ad campaign for [product/feature]. Our target audience is [target audience], and we want to focus on their primary pain points: [List of pain points] Please generate [number] different creative angles for this campaign. For each angle, provide 2-3 headlines and a short paragraph of ad copy that adopts a [tone of voice, e.g. professional, witty, empathetic] tone. ``` -------------------------------- ### Python Sample for Answering Queries Source: https://docs.cloud.google.com/gemini/enterprise/docs/answer?hl=pt-BR This snippet shows how to set up the client, define query and answer generation specifications, and make an answer query request. It includes optional configurations for query rephrasing, classification, and answer customization. ```python from google.api_core.client_options import ClientOptions from google.cloud import discoveryengine def answer_query_sample( project_id: str, location: str, engine_id: str, ) -> discoveryengine.AnswerQueryResponse: # For more information, refer to: # https://cloud.google.com/generative-ai-app-builder/docs/locations#specify_a_multi-region_for_your_data_store client_options = ( ClientOptions(api_endpoint=f"{location}-discoveryengine.googleapis.com") if location != "global" else None ) # Create a client client = discoveryengine.ConversationalSearchServiceClient( client_options=client_options ) # The full resource name of the Search serving config serving_config = f"projects/{project_id}/locations/{location}/collections/default_collection/engines/{engine_id}/servingConfigs/default_serving_config" # Optional: Options for query phase # The `query_understanding_spec` below includes all available query phase options. # For more details, refer to https://cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1/QueryUnderstandingSpec query_understanding_spec = discoveryengine.AnswerQueryRequest.QueryUnderstandingSpec( query_rephraser_spec=discoveryengine.AnswerQueryRequest.QueryUnderstandingSpec.QueryRephraserSpec( disable=False, # Optional: Disable query rephraser max_rephrase_steps=1, # Optional: Number of rephrase steps ), # Optional: Classify query types query_classification_spec=discoveryengine.AnswerQueryRequest.QueryUnderstandingSpec.QueryClassificationSpec( types=[ discoveryengine.AnswerQueryRequest.QueryUnderstandingSpec.QueryClassificationSpec.Type.ADVERSARIAL_QUERY, discoveryengine.AnswerQueryRequest.QueryUnderstandingSpec.QueryClassificationSpec.Type.NON_ANSWER_SEEKING_QUERY, ] # Options: ADVERSARIAL_QUERY, NON_ANSWER_SEEKING_QUERY or both ), ) # Optional: Options for answer phase # The `answer_generation_spec` below includes all available query phase options. # For more details, refer to https://cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1/AnswerGenerationSpec answer_generation_spec = discoveryengine.AnswerQueryRequest.AnswerGenerationSpec( ignore_adversarial_query=False, # Optional: Ignore adversarial query ignore_non_answer_seeking_query=False, # Optional: Ignore non-answer seeking query ignore_low_relevant_content=False, # Optional: Return fallback answer when content is not relevant model_spec=discoveryengine.AnswerQueryRequest.AnswerGenerationSpec.ModelSpec( # Use the 2026 stable production model for answer generation model_version="gemini-2.5-flash/answer_gen/stable", ), prompt_spec=discoveryengine.AnswerQueryRequest.AnswerGenerationSpec.PromptSpec( preamble="Give a detailed answer.", # Optional: Natural language instructions for customizing the answer. ), include_citations=True, # Optional: Include citations in the response answer_language_code="en", # Optional: Language code of the answer ) # Initialize request argument(s) request = discoveryengine.AnswerQueryRequest( serving_config=serving_config, query=discoveryengine.Query(text="What is Vertex AI Search?"), session=None, # Optional: include previous session ID to continue a conversation query_understanding_spec=query_understanding_spec, answer_generation_spec=answer_generation_spec, user_pseudo_id="user-pseudo-id", # Optional: Add user pseudo-identifier for queries. ) # Make the request response = client.answer_query(request) # Handle the response print(response) return response ``` -------------------------------- ### discoveryengine.sampleQueries.list Source: https://docs.cloud.google.com/gemini/enterprise/docs/access-control Lists sample queries. ```APIDOC ## GET /v1/projects/{projectId}/locations/{locationId}/dataStores/{dataStoreId}/sampleQueries ### Description Lists sample queries. ### Method GET ### Endpoint `/v1/projects/{projectId}/locations/{locationId}/dataStores/{dataStoreId}/sampleQueries` ``` -------------------------------- ### v1alpha.projects.locations.collections.dataConnector Source: https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest Provides methods for interacting with DataConnectors, including acquiring access tokens and refresh tokens, building action invocations, checking refresh tokens, executing actions, fetching entity types, getting connector secrets, serving MCP requests, and starting connector runs. ```APIDOC ## POST /v1alpha/{name=projects/*/locations/*/collections/*/dataConnector}:acquireAccessToken ### Description Uses the per-user refresh token minted with `AcquireAndStoreRefreshToken` to generate and return a new access token and its details. ### Method POST ### Endpoint /v1alpha/{name=projects/*/locations/*/collections/*/dataConnector}:acquireAccessToken ## POST /v1alpha/{name=projects/*/locations/*/collections/*/dataConnector}:acquireAndStoreRefreshToken ### Description Exchanges OAuth authorization credentials for a refresh token and stores the refresh token and the scopes. ### Method POST ### Endpoint /v1alpha/{name=projects/*/locations/*/collections/*/dataConnector}:acquireAndStoreRefreshToken ## POST /v1alpha/{name=projects/*/locations/*/collections/*/dataConnector}:buildActionInvocation ### Description Builds an action invocation using the `DataConnector`. ### Method POST ### Endpoint /v1alpha/{name=projects/*/locations/*/collections/*/dataConnector}:buildActionInvocation ## GET /v1alpha/{name=projects/*/locations/*/collections/*/dataConnector}:checkRefreshToken ### Description Deprecated: Checks the existence of a refresh token for the EUC user for a given connection and returns its details. ### Method GET ### Endpoint /v1alpha/{name=projects/*/locations/*/collections/*/dataConnector}:checkRefreshToken ## POST /v1alpha/{name=projects/*/locations/*/collections/*/dataConnector}:executeAction ### Description Executes a 3rd party action using the `DataConnector`. ### Method POST ### Endpoint /v1alpha/{name=projects/*/locations/*/collections/*/dataConnector}:executeAction ## GET /v1alpha/{name=projects/*/locations/*/collections/*/dataConnector}:FetchEntitiesTypes ### Description Fetch the entities types for a `DataConnector`. ### Method GET ### Endpoint /v1alpha/{name=projects/*/locations/*/collections/*/dataConnector}:FetchEntitiesTypes ## GET /v1alpha/{name=projects/*/locations/*/collections/*/dataConnector}:getConnectorSecret ### Description Get the secret for the associated connector. ### Method GET ### Endpoint /v1alpha/{name=projects/*/locations/*/collections/*/dataConnector}:getConnectorSecret ## DELETE /v1alpha/projects/*/locations/*/collections/*/dataConnector/mcp ### Description ServeMcpDeleteRequest serves a MCP DELETE request. ### Method DELETE ### Endpoint /v1alpha/projects/*/locations/*/collections/*/dataConnector/mcp ## POST /v1alpha/{parent=projects/*/locations/*/collections/*/dataConnector}:startConnectorRun ### Description Starts an immediate synchronization process for a `DataConnector`. ### Method POST ### Endpoint /v1alpha/{parent=projects/*/locations/*/collections/*/dataConnector}:startConnectorRun ``` -------------------------------- ### get Source: https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest Gets a Evaluation. ```APIDOC ## GET /v1beta/{name=projects/*/locations/*/evaluations/*} ### Description Gets a `Evaluation`. ### Method GET ### Endpoint /v1beta/{name=projects/*/locations/*/evaluations/*} ``` -------------------------------- ### discoveryengine.sampleQueries.create Source: https://docs.cloud.google.com/gemini/enterprise/docs/access-control Creates a SampleQuery resource. ```APIDOC ## discoveryengine.sampleQueries.create ### Description Creates a SampleQuery resource. ### Method POST ### Endpoint /v1/{parent=projects/*/locations/*/collections/*/dataStores/*}/sampleQueries ### Parameters #### Path Parameters * **parent** (string) - Required - The parent resource name. #### Request Body * **sampleQuery** (object) - Required - The SampleQuery to create. ``` -------------------------------- ### get Source: https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest Gets the CmekConfig. ```APIDOC ## GET /v1beta/{name=projects/*/locations/*/cmekConfigs/*} ### Description Gets the `CmekConfig`. ### Method GET ### Endpoint /v1beta/{name=projects/*/locations/*/cmekConfigs/*} ``` -------------------------------- ### Install Required Python Libraries Source: https://docs.cloud.google.com/gemini/enterprise/docs/connectors/create-custom-connector Install the necessary Python libraries for creating a custom connector. This includes the Google Cloud Discovery Engine and requests libraries. ```bash pip install google-cloud-discoveryengine requests ``` -------------------------------- ### Python Setup for Gemini Enterprise Client Libraries Source: https://docs.cloud.google.com/gemini/enterprise/docs/refresh-data This snippet shows the initial Python setup for using the Gemini Enterprise client libraries. Ensure you have authenticated using Application Default Credentials. ```python from google.api_core.client_options import ClientOptions from google.cloud import discoveryengine ``` -------------------------------- ### get Chunk Source: https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest Gets a `Document`. ```APIDOC ## GET /v1alpha/{name=projects/*/locations/*/dataStores/*/branches/*/documents/*/chunks/*} ### Description Gets a `Document`. ### Method GET ### Endpoint /v1alpha/{name=projects/*/locations/*/dataStores/*/branches/*/documents/*/chunks/*} ### Parameters #### Path Parameters - **name** (string) - Required - The name of the `Chunk` to retrieve. ### Request Body (Not specified in source) ### Response #### Success Response (200) (Not specified in source) #### Response Example (Not specified in source) ``` -------------------------------- ### Example Prompt for VPN Troubleshooting Source: https://docs.cloud.google.com/gemini/enterprise/docs/use-case-it-helpdesk-automation Use this prompt when experiencing issues connecting to the company VPN. ```text I'm having trouble connecting to the company VPN. My password seems to be correct, but it's not working. Can you help me troubleshoot? ``` -------------------------------- ### get Document Source: https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest Gets a `Document`. ```APIDOC ## GET /v1alpha/{name=projects/*/locations/*/dataStores/*/branches/*/documents/*} ### Description Gets a `Document`. ### Method GET ### Endpoint /v1alpha/{name=projects/*/locations/*/dataStores/*/branches/*/documents/*} ### Parameters #### Path Parameters - **name** (string) - Required - The name of the `Document` to retrieve. ### Request Body (Not specified in source) ### Response #### Success Response (200) (Not specified in source) #### Response Example (Not specified in source) ``` -------------------------------- ### get CompletionConfig Source: https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest Gets a `CompletionConfig`. ```APIDOC ## GET /v1alpha/{name=projects/*/locations/*/dataStores/*/completionConfig} ### Description Gets a `CompletionConfig`. ### Method GET ### Endpoint /v1alpha/{name=projects/*/locations/*/dataStores/*/completionConfig} ### Parameters #### Path Parameters - **name** (string) - Required - The name of the `CompletionConfig` to retrieve. ### Request Body (Not specified in source) ### Response #### Success Response (200) (Not specified in source) #### Response Example (Not specified in source) ``` -------------------------------- ### Example Prompt for Onboarding Information Source: https://docs.cloud.google.com/gemini/enterprise/docs/use-case-onboarding-training Use this prompt to ask Gemini Enterprise for company organizational charts and directories. Ensure you are in the chat box when entering the prompt. ```text I'm a new employee and I need to know where to find the company's organizational chart and directory. ``` -------------------------------- ### Initialize Terraform Source: https://docs.cloud.google.com/gemini/enterprise/docs/connectors/connect-terraform Run this command to download the necessary provider plugins and initialize your Terraform working directory. ```bash terraform init -upgrade ``` -------------------------------- ### get DataStore Source: https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest Gets a `DataStore`. ```APIDOC ## GET /v1alpha/{name=projects/*/locations/*/dataStores/*} ### Description Gets a `DataStore`. ### Method GET ### Endpoint /v1alpha/{name=projects/*/locations/*/dataStores/*} ### Parameters #### Path Parameters - **name** (string) - Required - The name of the `DataStore` to retrieve. ### Request Body (Not specified in source) ### Response #### Success Response (200) (Not specified in source) #### Response Example (Not specified in source) ``` -------------------------------- ### Python Sample for Answering Queries Source: https://docs.cloud.google.com/gemini/enterprise/docs/answer?hl=zh-CN This snippet shows how to set up the Discovery Engine client, define request parameters for query understanding and answer generation, and make the `answer_query` call. It includes optional configurations for query rephrasing, classification, and answer generation models. ```python # TODO(developer): Uncomment these variables before running the sample. # project_id = "YOUR_PROJECT_ID" # location = "YOUR_LOCATION" # Values: "global", "us", "eu" # engine_id = "YOUR_APP_ID" def answer_query_sample( project_id: str, location: str, engine_id: str, ) -> discoveryengine.AnswerQueryResponse: # For more information, refer to: # https://cloud.google.com/generative-ai-app-builder/docs/locations#specify_a_multi-region_for_your_data_store client_options = ( ClientOptions(api_endpoint=f"{location}-discoveryengine.googleapis.com") if location != "global" else None ) # Create a client client = discoveryengine.ConversationalSearchServiceClient( client_options=client_options ) # The full resource name of the Search serving config serving_config = f"projects/{project_id}/locations/{location}/collections/default_collection/engines/{engine_id}/servingConfigs/default_serving_config" # Optional: Options for query phase # The `query_understanding_spec` below includes all available query phase options. # For more details, refer to https://cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1/QueryUnderstandingSpec query_understanding_spec = discoveryengine.AnswerQueryRequest.QueryUnderstandingSpec( query_rephraser_spec=discoveryengine.AnswerQueryRequest.QueryUnderstandingSpec.QueryRephraserSpec( disable=False, # Optional: Disable query rephraser max_rephrase_steps=1, # Optional: Number of rephrase steps ), # Optional: Classify query types query_classification_spec=discoveryengine.AnswerQueryRequest.QueryUnderstandingSpec.QueryClassificationSpec( types=[ discoveryengine.AnswerQueryRequest.QueryUnderstandingSpec.QueryClassificationSpec.Type.ADVERSARIAL_QUERY, discoveryengine.AnswerQueryRequest.QueryUnderstandingSpec.QueryClassificationSpec.Type.NON_ANSWER_SEEKING_QUERY, ] # Options: ADVERSARIAL_QUERY, NON_ANSWER_SEEKING_QUERY or both ), ) # Optional: Options for answer phase # The `answer_generation_spec` below includes all available query phase options. # For more details, refer to https://cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1/AnswerGenerationSpec answer_generation_spec = discoveryengine.AnswerQueryRequest.AnswerGenerationSpec( ignore_adversarial_query=False, # Optional: Ignore adversarial query ignore_non_answer_seeking_query=False, # Optional: Ignore non-answer seeking query ignore_low_relevant_content=False, # Optional: Return fallback answer when content is not relevant model_spec=discoveryengine.AnswerQueryRequest.AnswerGenerationSpec.ModelSpec( model_version="gemini-2.0-flash-001/answer_gen/v1", # Optional: Model to use for answer generation ), prompt_spec=discoveryengine.AnswerQueryRequest.AnswerGenerationSpec.PromptSpec( preamble="Give a detailed answer.", # Optional: Natural language instructions for customizing the answer. ), include_citations=True, # Optional: Include citations in the response answer_language_code="en", # Optional: Language code of the answer ) # Initialize request argument(s) request = discoveryengine.AnswerQueryRequest( serving_config=serving_config, query=discoveryengine.Query(text="What is Vertex AI Search?"), session=None, # Optional: include previous session ID to continue a conversation query_understanding_spec=query_understanding_spec, answer_generation_spec=answer_generation_spec, user_pseudo_id="user-pseudo-id", # Optional: Add user pseudo-identifier for queries. ) # Make the request response = client.answer_query(request) # Handle the response print(response) return response ``` -------------------------------- ### Get Schema Source: https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest Gets a `Schema`. ```APIDOC ## GET /v1alpha/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*} ### Description Gets a `Schema`. ### Method GET ### Endpoint /v1alpha/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*} ``` -------------------------------- ### discoveryengine.sampleQuerySets.create Source: https://docs.cloud.google.com/gemini/enterprise/docs/access-control Creates a sample query set. ```APIDOC ## POST /v1/projects/{projectId}/locations/{locationId}/sampleQuerySets ### Description Creates a sample query set. ### Method POST ### Endpoint `/v1/projects/{projectId}/locations/{locationId}/sampleQuerySets` ``` -------------------------------- ### Get Conversation Source: https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest Gets a Conversation. ```APIDOC ## GET /v1alpha/{name=projects/*/locations/*/collections/*/dataStores/*/conversations/*} ### Description Gets a Conversation. ### Method GET ### Endpoint /v1alpha/{name=projects/*/locations/*/collections/*/dataStores/*/conversations/*} ``` -------------------------------- ### Get Control Source: https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest Gets a Control. ```APIDOC ## GET /v1alpha/{name=projects/*/locations/*/collections/*/dataStores/*/controls/*} ### Description Gets a Control. ### Method GET ### Endpoint /v1alpha/{name=projects/*/locations/*/collections/*/dataStores/*/controls/*} ``` -------------------------------- ### Data Connector Parameters Example Source: https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/DataConnector Example of how to structure key-value pairs for data connector parameters, including instance URI, user account, and API token for authentication. ```json { "instance_uri": "https://xxx.atlassian.net", "user_account": "xxxx.xxx@xxx.com", "api_token": "test-token" } ``` -------------------------------- ### discoveryengine.sampleQueries.import Source: https://docs.cloud.google.com/gemini/enterprise/docs/access-control Imports SampleQueries into a DataStore. ```APIDOC ## discoveryengine.sampleQueries.import ### Description Imports SampleQueries into a DataStore. ### Method POST ### Endpoint /v1/{parent=projects/*/locations/*/collections/*/dataStores/*}/sampleQueries:import ### Parameters #### Path Parameters * **parent** (string) - Required - The name of the DataStore to import SampleQueries into. #### Request Body * **inputConfig** (object) - Required - The input configuration for the import. ``` -------------------------------- ### get Source: https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/projects.locations.userStores Gets the User Store. ```APIDOC ## get ### Description Gets the User Store. ### Method GET ### Endpoint /v1/projects/{project}/locations/{location}/userStores/{userStore} ### Parameters #### Path Parameters - **project** (string) - Required - The project ID. - **location** (string) - Required - The location ID. - **userStore** (string) - Required - The user store ID. ### Response #### Success Response (200) - **name** (string) - Immutable. The full resource name of the User Store. - **displayName** (string) - The display name of the User Store. - **defaultLicenseConfig** (string) - Optional. The default subscription `LicenseConfig` for the UserStore. - **enableLicenseAutoRegister** (boolean) - Optional. Whether to enable license auto register for users in this User Store. - **enableExpiredLicenseAutoUpdate** (boolean) - Optional. Whether to enable license auto update for users in this User Store. ``` -------------------------------- ### Example Command and Result for Viewing Agent Details Source: https://docs.cloud.google.com/gemini/enterprise/docs/register-and-manage-an-a2a-agent This example demonstrates the `curl` command to fetch details for a specific agent and its detailed JSON response, including agent definition and configuration. ```bash curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://global-discoveryengine.googleapis.com/v1alpha/projects/my-project-123/locations/global/collections/default_collection/engines/my-app/assistants/default_assistant/agents/12345678901234567890" ``` ```json { "name": "projects/123456/locations/global/collections/default_collection/engines/my-app/assistants/default_assistant/agents/12345678901234567890", "displayName": "Hello World Agent", "description": "Just a hello world agent", "createTime": "2025-10-20T20:53:35.490600996Z", "state": "ENABLED", "a2aAgentDefinition": { "jsonAgentCard": "{\"name\":\"Hello World Agent\",\"description\":\"Just a hello world agent\",\"url\":\"https://example.com/myagent\",\"version\":\"1.0.0\",\"capabilities\":{},\"default_input_modes\":[\"text\"],\"default_output_modes\":[\"text\"],\"skills\":[{\"id\":\"chat\",\"name\":\"Chat Skill\",\"description\":\"Chat with the Gemini agent.\",\"tags\":[\"chat\"],\"examples\":[\"Hello, world!\"]}]}" } } ``` -------------------------------- ### get Source: https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/projects.locations.collections.dataStores.siteSearchEngine.targetSites Gets a TargetSite resource. ```APIDOC ## get ### Description Gets a `TargetSite` resource. ### Method GET ### Endpoint `/v1/{name=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine/targetSites/*}` ### Parameters #### Path Parameters - **name** (string) - Required - The name of the `TargetSite` to retrieve. Format: `projects/{project_id}/locations/{location_id}/collections/{collection_id}/dataStores/{data_store_id}/siteSearchEngine/targetSites/{target_site_id}`. ### Response #### Success Response (200) - **name** (string) - The resource name of the Target Site. - **displayName** (string) - The display name of the Target Site. - **uriPatterns** (array) - The URI patterns for the Target Site. #### Response Example ```json { "name": "projects/your-project/locations/your-location/collections/your-collection/dataStores/your-datastore/siteSearchEngine/targetSites/your-target-site-id", "displayName": "Example Target Site", "uriPatterns": ["https://example.com/*"] } ``` ``` -------------------------------- ### v1.projects.locations.setUpDataConnectorV2 Source: https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest Creates a collection and sets up a data connector for it using the V2 API within a specified project location. ```APIDOC ## POST /v1/{parent=projects/*/locations/*}:setUpDataConnectorV2 ### Description Creates a `Collection` and sets up the `DataConnector` for it. ### Method POST ### Endpoint /v1/{parent=projects/*/locations/*}:setUpDataConnectorV2 ``` -------------------------------- ### identityMappingStores get Source: https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest Gets the Identity Mapping Store. ```APIDOC ## GET /v1/{name=projects/*/locations/*/identityMappingStores/*} ### Description Gets the Identity Mapping Store. ### Method GET ### Endpoint /v1/{name=projects/*/locations/*/identityMappingStores/*} ``` -------------------------------- ### get Source: https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/projects.locations.dataStores.models.operations Gets the latest state of a long-running operation. ```APIDOC ## GET projects.locations.dataStores.models.operations.get ### Description Gets the latest state of a long-running operation. ### Method GET ### Endpoint projects/{projectId}/locations/{locationId}/dataStores/{dataStoreId}/models/operations/{operationId} ``` -------------------------------- ### setUpDataConnectorV2 Source: https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest Creates a Collection and sets up the DataConnector for it using version 2. This is an updated method for data connector setup. ```APIDOC ## POST /v1alpha/{parent=projects/*/locations/*}:setUpDataConnectorV2 ### Description Creates a `Collection` and sets up the `DataConnector` for it. ### Method POST ### Endpoint /v1alpha/{parent=projects/*/locations/*}:setUpDataConnectorV2 ``` -------------------------------- ### get (Operations) Source: https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest Gets the latest state of a long-running operation. ```APIDOC ## get (Operations) ### Description Gets the latest state of a long-running operation. ### Method GET ### Endpoint /v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/operations/*} ### Parameters #### Path Parameters - **name** (string) - Required - The name of the operation to get. ``` -------------------------------- ### Example Sample Query Set Source: https://docs.cloud.google.com/gemini/enterprise/docs/evaluate-search-quality An example of a complete sample query set in JSON format, demonstrating queries for revenue information with specific PDF targets. ```json { "inlineSource": { "sampleQueries": [ { "queryEntry": { "query": "2018 Q4 Google revenue", "targets": [ { "uri": "gs://cloud-samples-data/gen-app-builder/search/alphabet-investor-pdfs/2018Q4_alphabet_earnings_release.pdf" }, { "uri": "gs://cloud-samples-data/gen-app-builder/search/alphabet-investor-pdfs/201802024_alphabet_10K.pdf" } ] } }, { "queryEntry": { "query": "2019 Q4 Google revenue", "targets": [ { "uri": "gs://cloud-samples-data/gen-app-builder/search/alphabet-investor-pdfs/2019Q4_alphabet_earnings_release.pdf" } ] } } ] } } ```