### get Source: https://docs.cloud.google.com/retail/docs/reference/rest/v2/projects.locations.catalogs.branches.products Gets a Product. ```APIDOC ## get ### Description Gets a `Product`. ### Method [Method details not specified in source] ### Endpoint [Endpoint details not specified in source] ### Parameters [Parameter details not specified in source] ### Request Example [Request example not specified in source] ### Response #### Success Response (200) [Success response details not specified in source] #### Response Example [Response example not specified in source] ``` -------------------------------- ### Example Condition: Boosting Products by ID and Color Source: https://docs.cloud.google.com/retail/docs/reference/rest/v2/ConditionBoostSpec This example demonstrates how to boost products that match specific product IDs and color families using a filter expression. ```json (id: ANY("product_1", "product_2")) AND (colorFamilies: ANY("Red","Blue")) ``` -------------------------------- ### Java Example for Importing User Events Source: https://docs.cloud.google.com/retail/docs/import-user-events A Java method signature for importing user events from a BigQuery source. This serves as a starting point for programmatic integration. ```java public static String importUserEventsFromBigQuerySource(){ ``` -------------------------------- ### Suggestion Facet with Product Counts Example Source: https://docs.cloud.google.com/retail/docs/completion-overview Example of a `completeQuery` response including product counts for suggestions and facet values like color. ```json { "completion_results": [{ "suggestion": "womens shoes" "facets": [ { "key": "color" "values": [ { "value": "black" "count": 10 } { "value": "taupe" "count": 16 } { "value": "white" "count": 10 } ] } ] "total_product_count": 32 }, (...) ], } ``` -------------------------------- ### Attribute Suggestions Response Example Source: https://docs.cloud.google.com/retail/docs/completion-overview Example of a `completeQuery` response showing attribute suggestions for brands and categories. ```json { "completionResults": [ { "suggestion": "shoe", "attributes": {} } ], "attributionToken": "example_attribution_token", "attributeResults": { "brands": { "suggestions": [ "Nike", "Adidas" ] }, "categories": { "suggestions": [ "Shoes", "Men's Shoes" ] } } } ``` -------------------------------- ### get Product Source: https://docs.cloud.google.com/retail/docs/reference/rest Gets a Product. ```APIDOC ## GET /v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/products/**} ### Description Gets a `Product`. ### Method GET ### Endpoint /v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/products/**} ``` -------------------------------- ### Product Retrieval Response Example Source: https://docs.cloud.google.com/retail/docs/manage-catalog This is an example of a successful response when retrieving a product. It returns the product object with its details. ```json { "name": "projects/PROJECT_NUMBER/locations/global/catalogs/default_catalog/branches/0/products/PRODUCT_ID" "id": "PRODUCT_ID", "primaryProductId": "PRODUCT_ID", "type": "PRIMARY", "categories": [ "Parent category > Child category" ], "title": "product title", "availability": "IN_STOCK" } ``` -------------------------------- ### Product Update Response Example Source: https://docs.cloud.google.com/retail/docs/manage-catalog This is an example of a successful response when updating a product. It returns the updated product object with its current details. ```json { "name": "projects/PROJECT_NUMBER/locations/global/catalogs/default_catalog/branches/0/products/PRODUCT_ID", "id": "PRODUCT_ID", "primaryProductId": "PRODUCT_ID", "type": "PRIMARY", "categories": [ "Parent category > Child category" ], "title": "new product title", "availability": "IN_STOCK" } ``` -------------------------------- ### HTTP Request Example Source: https://docs.cloud.google.com/retail/docs/reference/rest/v2/projects.locations.catalogs.userEvents/write This is an example of the HTTP request structure for writing a user event. It includes the parent catalog and the writeAsync query parameter. ```http POST https://retail.googleapis.com/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:write ``` -------------------------------- ### Example Request Body with Input Configuration Source: https://docs.cloud.google.com/retail/docs/reference/rest/v2/projects.locations.catalogs.completionData/import An example of a request body for the completion data import API, demonstrating how to specify the input configuration for the data. ```JSON { "inputConfig": { "bigQuerySource": { "datasetId": "my_dataset", "tableId": "my_table" } }, "notificationPubsubTopic": "projects/my_project/topics/my_topic" } ``` -------------------------------- ### Example successful product creation response Source: https://docs.cloud.google.com/retail/docs/manage-catalog This is an example of a successful response when creating a product item. It includes details like the product's name, ID, categories, title, and availability. ```json { "name": "projects/PROJECT_NUMBER/locations/global/catalogs/default_catalog/branches/0/products/PRODUCT_ID", "id": "PRODUCT_ID", "primaryProductId": "PRODUCT_ID", "type": "PRIMARY", "categories": [ "CATEGORY" ], "title": "PRODUCT_TITLE", "availability": "IN_STOCK" } ``` -------------------------------- ### JSON Request Example for User Attributes Source: https://docs.cloud.google.com/retail/docs/crm-personalization Illustrates how to structure user attributes within a JSON search request, showing examples for 'pets' and 'state'. Note that values must be hashed. ```json { ... user_attributes: [ { key: "pets" # note keys can be hashed or unhashed value { values: "dog" # Note: these values MUST be hashed values: "cat" } }, { key: "state" value { values: "CA" } } ] } ``` -------------------------------- ### Example: Custom Facet for Ship-to-Store Availability Source: https://docs.cloud.google.com/retail/docs/reference/rest/v2/FacetSpec This example demonstrates how to create a custom facet for products that are both in stock and available for store '123'. The `query` field overrides default facet computation. ```json { "key": "customizedShipToStore", "query": "availability: ANY(\"IN_STOCK\") AND shipToStore: ANY(\"123\")" } ``` -------------------------------- ### list Source: https://docs.cloud.google.com/retail/docs/reference/rest/v2/projects.locations.catalogs.branches.products Gets a list of Products. ```APIDOC ## list ### Description Gets a list of `Product`s. ### Method [Method details not specified in source] ### Endpoint [Endpoint details not specified in source] ### Parameters [Parameter details not specified in source] ### Request Example [Request example not specified in source] ### Response #### Success Response (200) [Success response details not specified in source] #### Response Example [Response example not specified in source] ``` -------------------------------- ### list Products Source: https://docs.cloud.google.com/retail/docs/reference/rest Gets a list of Products. ```APIDOC ## GET /v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products ### Description Gets a list of `Product`s. ### Method GET ### Endpoint /v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products ``` -------------------------------- ### Perform a basic search query in Java Source: https://docs.cloud.google.com/retail/docs/search-basic This Java example demonstrates how to perform a product search using a query phrase with the Retail Search API. Ensure the Google Cloud client library for Retail is included in your project and authentication is configured. ```java import com.google.cloud.ServiceOptions; import com.google.cloud.retail.v2.SearchRequest; import com.google.cloud.retail.v2.SearchResponse; import com.google.cloud.retail.v2.SearchServiceClient; import java.io.IOException; import java.util.UUID; public class SearchSimpleQuery { public static void main(String[] args) throws IOException { String projectId = ServiceOptions.getDefaultProjectId(); String defaultCatalogName = String.format("projects/%s/locations/global/catalogs/default_catalog", projectId); String defaultSearchPlacementName = defaultCatalogName + "/placements/default_search"; searchResponse(defaultSearchPlacementName); } public static void searchResponse(String defaultSearchPlacementName) throws IOException { // TRY DIFFERENT QUERY PHRASES HERE: String queryPhrase = "Hoodie"; String visitorId = UUID.randomUUID().toString(); int pageSize = 10; SearchRequest searchRequest = SearchRequest.newBuilder() .setPlacement(defaultSearchPlacementName) .setQuery(queryPhrase) .setVisitorId(visitorId) .setPageSize(pageSize) .build(); System.out.println("Search request: " + searchRequest); // Initialize client that will be used to send requests. This client only // needs to be created once, and can be reused for multiple requests. After // completing all of your requests, call the "close" method on the client to // safely clean up any remaining background resources. try (SearchServiceClient client = SearchServiceClient.create()) { SearchResponse searchResponse = client.search(searchRequest).getPage().getResponse(); if (searchResponse.getTotalSize() == 0) { System.out.println("The search operation returned no matching results."); } else { System.out.println("Search response: " + searchResponse); } } } } ``` -------------------------------- ### Set up cloud_retail data layer Source: https://docs.cloud.google.com/retail/docs/record-events This code initializes the dataLayer and pushes a 'cloud_retail' event with associated user and event details. Ensure this is present in your HTML or served via server-side code. ```javascript dataLayer = dataLayer || []; dataLayer.push({ 'cloud_retail': { 'eventType': 'home-page-view', 'visitorId': 'visitor_a', 'userInfo': { 'userId': '789' }, } }); ``` -------------------------------- ### get servingConfig Source: https://docs.cloud.google.com/retail/docs/reference/rest Gets a ServingConfig. ```APIDOC ## GET /v2beta/{name=projects/*/locations/*/catalogs/*/servingConfigs/*} ### Description Gets a ServingConfig. ### Method GET ### Endpoint /v2beta/{name=projects/*/locations/*/catalogs/*/servingConfigs/*} ### Parameters #### Path Parameters - **name** (string) - Required - The name of the ServingConfig to retrieve. ``` -------------------------------- ### Example Boost Specification by Price Source: https://docs.cloud.google.com/retail/docs/boosting This JSON snippet demonstrates how to boost products under a certain price and bury products over that price. Products under 95 US dollars receive a promotion (0.5), while those over 95 US dollars are demoted (-0.5). ```json { "condition_boost_specs": [ { "condition": "price: IN(*, 95.0e)", "boost": 0.5 }, { "condition": "price: IN(95.0e, *)", "boost": -0.5 } ] } ``` -------------------------------- ### get Model Source: https://docs.cloud.google.com/retail/docs/reference/rest Gets a model. ```APIDOC ## GET /v2beta/{name=projects/*/locations/*/catalogs/*/models/*} ### Description Gets a model. ### Method GET ### Endpoint /v2beta/{name=projects/*/locations/*/catalogs/*/models/*} ``` -------------------------------- ### get Control Source: https://docs.cloud.google.com/retail/docs/reference/rest Gets a Control. ```APIDOC ## GET /v2beta/{name=projects/*/locations/*/catalogs/*/controls/*} ### Description Gets a Control. ### Method GET ### Endpoint /v2beta/{name=projects/*/locations/*/catalogs/*/controls/*} ``` -------------------------------- ### Java: Call Retail Search and Handle First Page Source: https://docs.cloud.google.com/retail/docs/search-basic?hl=es-419 This snippet shows how to initialize the SearchServiceClient, make a search request, and process the first page of the response. Ensure to close the client to clean up resources. ```java // completing all of your requests, call the "close" method on the client to // safely clean up any remaining background resources. try (SearchServiceClient client = SearchServiceClient.create()) { SearchResponse searchResponseFirstPage = client.search(searchRequest).getPage().getResponse(); if (searchResponseFirstPage.getTotalSize() == 0) { System.out.println("The search operation returned no matching results."); } else { System.out.println("Search response: " + searchResponseFirstPage); } // PASTE CALL WITH NEXT PAGE TOKEN HERE: // PASTE CALL WITH OFFSET HERE: } } } ``` -------------------------------- ### Create Compute Engine Instance with Service Account Source: https://docs.cloud.google.com/retail/docs/authentication Create a Compute Engine instance and attach a service account to it for authentication. Ensure to replace INSTANCE_NAME, ZONE, and SERVICE_ACCOUNT_EMAIL with your specific values. ```bash gcloud compute instances create INSTANCE_NAME --zone=ZONE --service-account=SERVICE_ACCOUNT_EMAIL ``` -------------------------------- ### Initiate Product Import via REST API Source: https://docs.cloud.google.com/retail/docs/upload-catalog Use the Products:import REST method to start the catalog import process. Requires authentication and a JSON payload specifying the data source. ```bash curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" -d @./input.json \ "https://retail.googleapis.com/v2/projects/PROJECT_NUMBER/locations/global/catalogs/default_catalog/branches/0/products:import" ``` -------------------------------- ### get Source: https://docs.cloud.google.com/retail/docs/reference/rest/v2/projects.locations.catalogs.branches.products Gets a product by its ID. ```APIDOC ## get ### Description Gets a product by its ID. ### Method GET ### Endpoint projects.locations.catalogs.branches.products/{productId} ### Parameters #### Path Parameters - **name** (string) - Required - The name of the product to retrieve. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/branches/{branch_id}/products/{product_id}` ### Response #### Success Response (200) - **product** (object) - The requested product. ``` -------------------------------- ### get Source: https://docs.cloud.google.com/retail/docs/reference/rest/v2/projects.locations.operations Gets the latest state of a long-running operation. ```APIDOC ## GET projects.locations.operations.get ### Description Gets the latest state of a long-running operation. ### Method GET ### Endpoint `projects.locations.operations.get` ``` -------------------------------- ### ProductService.ListServingConfigs Source: https://docs.cloud.google.com/retail/docs/reference/rpc/google.cloud.retail.v2alpha Lists all serving configurations for a given catalog. Supports pagination. ```APIDOC ## ListServingConfigs ### Description Lists all serving configurations for a given catalog. Supports pagination. ### Method POST ### Endpoint /v1/servingConfigs:list ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **parent** (string) - Required - The catalog resource name. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` - **page_size** (int32) - Optional - Maximum number of results to return. Defaults to 100. If greater than 100, at most 100 results are returned. - **page_token** (string) - Optional - A page token, received from a previous `ListServingConfigs` call. Provide this to retrieve the subsequent page. ### Request Example { "parent": "projects/12345/locations/us-central1/catalogs/default_catalog", "pageSize": 50 } ### Response #### Success Response (200) - **serving_configs[]** (ServingConfig) - All the ServingConfigs for a given catalog. - **next_page_token** (string) - Pagination token, if not returned indicates the last page. #### Response Example { "servingConfigs": [ { "name": "projects/12345/locations/us-central1/catalogs/default_catalog/servingConfigs/config1", "id": "config1", "displayName": "Default Serving Config" } ], "nextPageToken": "token456" } ``` -------------------------------- ### get Operation Source: https://docs.cloud.google.com/retail/docs/reference/rest Gets the latest state of a long-running operation. ```APIDOC ## GET /v2/{name=projects/*/locations/*/catalogs/*/operations/*} ### Description Gets the latest state of a long-running operation. ### Method GET ### Endpoint /v2/{name=projects/*/locations/*/catalogs/*/operations/*} ``` -------------------------------- ### Create Cloud Storage Bucket and Upload Data Source: https://docs.cloud.google.com/retail/docs/movie-rec-tutorial These commands create a Cloud Storage bucket and copy the MovieLens data files into it. ```bash gcloud storage buckets create gs://PROJECT_ID-movielens-data gcloud storage cp ml-latest/movies.csv ml-latest/ratings.csv \ gs://PROJECT_ID-movielens-data ``` -------------------------------- ### get operation Source: https://docs.cloud.google.com/retail/docs/reference/rest Gets the latest state of a long-running operation for projects. ```APIDOC ## GET /v2beta/{name=projects/*/operations/*} ### Description Gets the latest state of a long-running operation. ### Method GET ### Endpoint /v2beta/{name=projects/*/operations/*} ### Parameters #### Path Parameters - **name** (string) - Required - The name of the operation resource. ``` -------------------------------- ### create Product Source: https://docs.cloud.google.com/retail/docs/reference/rest Creates a Product. ```APIDOC ## POST /v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products ### Description Creates a `Product`. ### Method POST ### Endpoint /v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products ``` -------------------------------- ### get operation Source: https://docs.cloud.google.com/retail/docs/reference/rest Gets the latest state of a long-running operation for catalogs. ```APIDOC ## GET /v2beta/{name=projects/*/locations/*/catalogs/*/operations/*} ### Description Gets the latest state of a long-running operation. ### Method GET ### Endpoint /v2beta/{name=projects/*/locations/*/catalogs/*/operations/*} ### Parameters #### Path Parameters - **name** (string) - Required - The name of the operation resource. ``` -------------------------------- ### projects.locations.catalogs.servingConfigs.create Source: https://docs.cloud.google.com/retail/docs/reference/rest/v2/projects.locations.catalogs.servingConfigs/create Creates a ServingConfig. A maximum of 100 `ServingConfig`s are allowed in a `Catalog`, otherwise a FAILED_PRECONDITION error is returned. ```APIDOC ## POST projects.locations.catalogs.servingConfigs.create ### Description Creates a ServingConfig. A maximum of 100 `ServingConfig`s are allowed in a `Catalog`, otherwise a FAILED_PRECONDITION error is returned. ### Method POST ### Endpoint `https://retail.googleapis.com/v2/{parent=projects/*/locations/*/catalogs/*}/servingConfigs` ### Parameters #### Path Parameters - **parent** (string) - Required. Full resource name of parent. Format: `projects/{projectNumber}/locations/{locationId}/catalogs/{catalogId}` #### Query Parameters - **servingConfigId** (string) - Required. The ID to use for the ServingConfig, which will become the final component of the ServingConfig's resource name.This value should be 4-63 characters, and valid characters are /[a-z][0-9]-_/. ### Request Body The request body contains an instance of `ServingConfig`. ### Response #### Success Response (200) If successful, the response body contains a newly created instance of `ServingConfig`. ### Authorization scopes Requires the following OAuth scope: * `https://www.googleapis.com/auth/cloud-platform` ### IAM Permissions Requires the following IAM permission on the `parent` resource: * `retail.servingConfigs.create` ``` -------------------------------- ### Example Source: https://docs.cloud.google.com/retail/docs/reference/rpc/google.cloud.retail.v2alpha Represents an example for intent classification, including the query, intent type, reason, and classification result. ```APIDOC ## Example ### Description An example for intent classification. ### Fields * `query` (string) - Required. Example query. * `intent_type` (string) - Optional. The intent_type must match one of the predefined intent types defined at https://cloud.google.com/retail/docs/reference/rpc/google.cloud.retail.v2alpha#querytype * `reason` (string) - Optional. The reason for the intent classification. This is used to explain the intent classification decision. * `classified_positive` (bool) - Required. Whether the example is classified positively. ``` -------------------------------- ### Example Predict API Response Source: https://docs.cloud.google.com/retail/docs/predict This is an example of the JSON response you can expect from a successful predict API call. ```json { "results": [{"id": "sample-id-1"}, {"id": "sample-id-2"}], "attribution_token": "sample-atr-token" } ``` -------------------------------- ### create Source: https://docs.cloud.google.com/retail/docs/reference/rest/v2/projects.locations.catalogs.branches.products Creates a new product. ```APIDOC ## create ### Description Creates a new product. ### Method POST ### Endpoint projects.locations.catalogs.branches.products ### Parameters #### Path Parameters - **parent** (string) - Required - The parent resource name. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/branches/{branch_id}` #### Query Parameters - **validateOnly** (boolean) - Optional - Whether to perform a dry run. #### Request Body - **product** (object) - Required - The product to create. - **id** (string) - Optional - The ID of the product. - **type** (string) - Optional - The type of the product. - **priceInfo** (object) - Optional - Price information for the product. - **tags** (array of strings) - Optional - Tags for the product. - **uri** (string) - Optional - The URI of the product. - **name** (string) - Optional - The name of the product. - **categories** (array of strings) - Optional - Categories of the product. - **title** (string) - Optional - The title of the product. - **brands** (array of strings) - Optional - Brands of the product. - **description** (string) - Optional - Description of the product. - **images** (array of objects) - Optional - Images of the product. - **attributes** (object) - Optional - Attributes of the product. - **fulfillmentInfo** (object) - Optional - Fulfillment information for the product. - **availableQuantity** (integer) - Optional - Available quantity of the product. - **pickupSla** (string) - Optional - Pickup SLA for the product. - **localInventory** (object) - Optional - Local inventory information for the product. ### Response #### Success Response (200) - **product** (object) - The created product. ``` -------------------------------- ### Create a Basic Search Request (Python) Source: https://docs.cloud.google.com/retail/docs/search-basic Demonstrates how to construct a `SearchRequest` object in Python. This includes setting the placement, query, visitor ID, and page size. ```python import google.auth from google.cloud.retail import SearchRequest, SearchServiceClient project_id = google.auth.default()[1] # get search service request: def get_search_request(query: str): default_search_placement = ( "projects/" + project_id + "/locations/global/catalogs/default_catalog/placements/default_search" ) search_request = SearchRequest() search_request.placement = default_search_placement # Placement is used to identify the Serving Config name. search_request.query = query search_request.visitor_id = "123456" # A unique identifier to track visitors search_request.page_size = 10 print("---"search request:---") print(search_request) return search_request ``` -------------------------------- ### get (v2.projects.locations.operations) Source: https://docs.cloud.google.com/retail/docs/reference/rest Gets the latest state of a long-running operation. This method is part of the operations resource for a specific location. ```APIDOC ## GET /v2/{name=projects/*/locations/*/operations/*} ### Description Gets the latest state of a long-running operation. ### Method GET ### Endpoint /v2/{name=projects/*/locations/*/operations/*} ``` -------------------------------- ### Get Serving Config Source: https://docs.cloud.google.com/retail/docs/manage-configs Retrieves a single serving configuration by its ID. This operation uses an HTTP GET request. ```APIDOC ## GET /v2beta/projects/{PROJECT_NUMBER}/locations/global/catalogs/default_catalog/servingConfigs/{SERVING_CONFIG_ID} ### Description Retrieves a single serving configuration. ### Method GET ### Endpoint `https://retail.googleapis.com/v2beta/projects/PROJECT_NUMBER/locations/global/catalogs/default_catalog/servingConfigs/SERVING_CONFIG_ID` ### Response #### Success Response (200) - **servingConfig** (object) - Details of the serving configuration. ``` -------------------------------- ### Search Products with Query Expansion (Java) Source: https://docs.cloud.google.com/retail/docs/result-size Use this Java snippet to perform product searches with query expansion enabled. Configure the expansion condition to control how queries are broadened. Ensure you have the necessary Google Cloud Retail client libraries imported. ```java import com.google.cloud.retail.v2.SearchRequest; import com.google.cloud.retail.v2.SearchRequest.QueryExpansionSpec; import com.google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.Condition; import com.google.cloud.retail.v2.SearchResponse; import com.google.cloud.retail.v2.SearchServiceClient; public static void searchProductsWithQueryExpansion(String query, int pageSize, Condition condition) throws IOException, InterruptedException { QueryExpansionSpec queryExpansionSpec = QueryExpansionSpec.newBuilder() .setCondition(condition) .build(); SearchRequest searchRequest = SearchRequest.newBuilder() .setPlacement(DEFAULT_SEARCH_PLACEMENT_NAME) .setBranch(DEFAULT_BRANCH_NAME) .setVisitorId(VISITOR_ID) .setQuery(query) .setPageSize(pageSize) .setQueryExpansionSpec(queryExpansionSpec) .build(); try (SearchServiceClient searchClient = SearchServiceClient.create()) { SearchResponse response = searchClient.search(searchRequest).getPage().getResponse(); System.out.println("Search response: " + searchResponse); } } ``` -------------------------------- ### ProjectService Methods (v2beta) Source: https://docs.cloud.google.com/retail/docs/audit-logging?hl=id Methods for managing project-level settings in the Retail API v2beta. ```APIDOC ## UpdateAlertConfig ### Description Updates the alert configuration for a project. ### Method PATCH ### Endpoint /v2beta/{name=projects/*/alertConfig} ### Parameters #### Path Parameters - **name** (string) - Required - The name of the alert configuration to update. Format: `projects/{project_number}/alertConfig`. #### Request Body - **alertConfig** (AlertConfig) - Required - The alert configuration to update. - **updateMask** (FieldMask) - Optional - The `FieldMask` that contains a list of field names to be updated. If empty, all fields will be updated. ### Request Example ```json { "alertConfig": { "enableProductLevelErrorAlert": true }, "updateMask": "enableProductLevelErrorAlert" } ``` ### Response #### Success Response (200) - **AlertConfig** (AlertConfig) - The updated alert configuration. #### Response Example ```json { "enableProductLevelErrorAlert": true } ``` ``` ```APIDOC ## UpdateLoggingConfig ### Description Updates the logging configuration for a project. ### Method PATCH ### Endpoint /v2beta/{name=projects/*/loggingConfig} ### Parameters #### Path Parameters - **name** (string) - Required - The name of the logging configuration to update. Format: `projects/{project_number}/loggingConfig`. #### Request Body - **loggingConfig** (LoggingConfig) - Required - The logging configuration to update. - **updateMask** (FieldMask) - Optional - The `FieldMask` that contains a list of field names to be updated. If empty, all fields will be updated. ### Request Example ```json { "loggingConfig": { "enabled": true }, "updateMask": "enabled" } ``` ### Response #### Success Response (200) - **LoggingConfig** (LoggingConfig) - The updated logging configuration. #### Response Example ```json { "enabled": true } ``` ``` -------------------------------- ### Attribute-based Filter Examples (filterSyntaxV2) Source: https://docs.cloud.google.com/retail/docs/reference/rest/v2/projects.locations.catalogs.placements/predict Shows examples of attribute-based filtering using the filterSyntaxV2 option, allowing for more complex filtering logic. ```string (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) ``` ```string (availability: ANY("IN_STOCK")) AND (colors: ANY("Red") OR categories: ANY("Phones")) ``` -------------------------------- ### Import Products from Inline Source using Java Source: https://docs.cloud.google.com/retail/docs/upload-catalog This Java code snippet demonstrates how to import products from an inline source using the ProductServiceClient. Ensure you have the necessary client library and authentication set up. ```java public static String importProductsFromInlineSource( List productsToImport) throws IOException, InterruptedException, ExecutionException { ProductServiceClient productClient = getProductServiceClient(); ProductInlineSource inlineSource = ProductInlineSource.newBuilder() .addAllProducts(productsToImport) .build(); ProductInputConfig inputConfig = ProductInputConfig.newBuilder() .setProductInlineSource(inlineSource) .build(); ImportProductsRequest importRequest = ImportProductsRequest.newBuilder() .setParent(IMPORT_PARENT) .setRequestId(REQUEST_ID) .setReconciliationMode(ReconciliationMode.INCREMENTAL) .setInputConfig(inputConfig) .build(); String operationName = productClient .importProductsAsync(importRequest).getName(); productClient.shutdownNow(); productClient.awaitTermination(2, TimeUnit.SECONDS); return operationName; } ``` -------------------------------- ### ProductService.CreateProduct Source: https://docs.cloud.google.com/retail/docs/reference/rpc/google.cloud.retail.v2alpha Creates a Product. Requires the `retail.products.create` IAM permission. ```APIDOC ## ProductService.CreateProduct ### Description Creates a `Product`. ### Method RPC ### Endpoint `rpc CreateProduct(CreateProductRequest) returns (Product)` ### Authorization Requires the following OAuth scope: `https://www.googleapis.com/auth/cloud-platform` ### IAM Permissions Requires the following IAM permission on the `parent` resource: `retail.products.create` ``` -------------------------------- ### Set Default Branch - Example Request Body Source: https://docs.cloud.google.com/retail/docs/reference/rest/v2/projects.locations.catalogs/setDefaultBranch Example of a request body to set the default branch to '1' and force the update. ```json { "branchId": "1", "force": true } ``` -------------------------------- ### Product Categories Example Source: https://docs.cloud.google.com/retail/docs/reference/rest/v2/projects.locations.catalogs.branches.products Illustrates how to represent a product belonging to multiple categories using the '>' separator for hierarchical paths. Ensure categories are properly formatted to enhance search and recommendation quality. ```json { "categories": [ "Shoes & Accessories > Shoes", "Sports & Fitness > Athletic Clothing > Shoes" ] } ``` -------------------------------- ### Example Request Body with Attribute Key Source: https://docs.cloud.google.com/retail/docs/reference/rest/v2/projects.locations.catalogs.attributesConfig/removeCatalogAttribute This example shows how to structure the request body to remove a specific catalog attribute by its key. ```json { "key": "attribute_key_to_remove" } ``` -------------------------------- ### Create a Browse-Triggered Search Boost/Bury Control Source: https://docs.cloud.google.com/retail/docs/create-controls Use this example to create a control that boosts or buries products when a user browses specific categories. It requires setting the `searchSolutionUseCase` to `SEARCH_SOLUTION_USE_CASE_BROWSE` and defining category triggers and time ranges. ```curl curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ --data '{ \ "displayName": "DISPLAY_NAME", \ "solutionTypes": [ "SOLUTION_TYPE_SEARCH" ], \ "searchSolutionUseCase": [ \ "SEARCH_SOLUTION_USE_CASE_BROWSE" \ ], \ "rule": { \ "condition": { \ "pageCategories": [ \ "CATEGORY_ABC", \ "CATEGORY_XYZ" \ ], \ "activeTimeRange": [ \ { \ "startTime": "START_TIMESTAMP_1", \ "endTime": "END_TIMESTAMP_1" \ }, \ { \ "startTime": "START_TIMESTAMP_2", \ "endTime": "END_TIMESTAMP_2" \ } \ ] \ }, \ "boostAction": { \ "boost": BOOST_NUMBER, \ "productsFilter": "FILTER_EXPRESSION" \ } \ } \ }' \ "https://retail.googleapis.com/v2beta/projects/PROJECT_NUMBER/locations/global/catalogs/default_catalog/controls?controlId=CONTROL_ID" ``` -------------------------------- ### Create Product Request Body Example Source: https://docs.cloud.google.com/retail/docs/reference/rest/v2/projects.locations.catalogs.branches.products/create This snippet shows the structure of the request body for creating a Product. You need to fill in the product details within the `Product` object. ```json { "productId": "YOUR_PRODUCT_ID", "product": { "title": "Example Product Title", "categories": [ "your_category_id" ], "type": "PRIMARY", "brands": [ "your_brand" ] } } ```