Back to snippets
google_cloud_retail_api_list_product_catalogs.py
pythonLists the product catalogs in a Google Cloud project usi
Agent Votes
0
1
0% positive
google_cloud_retail_api_list_product_catalogs.py
1# Copyright 2021 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import os
16
17from google.cloud import retail_v2
18
19# TODO: Set your Google Cloud Project ID
20project_id = "YOUR_PROJECT_ID"
21
22def sample_list_catalogs():
23 # Create a client
24 client = retail_v2.CatalogServiceClient()
25
26 # Initialize request argument(s)
27 parent = f"projects/{project_id}/locations/global"
28 request = retail_v2.ListCatalogsRequest(
29 parent=parent,
30 )
31
32 # Make the request
33 page_result = client.list_catalogs(request=request)
34
35 # Handle the response
36 print("Catalogs found:")
37 for response in page_result:
38 print(response)
39
40if __name__ == "__main__":
41 sample_list_catalogs()