From f963641fc14ab4ec152d7dc9c220fce4f5f0ae3a Mon Sep 17 00:00:00 2001 From: tetiana-karasova <62887365+tetiana-karasova@users.noreply.github.com> Date: Fri, 18 Feb 2022 20:44:48 +0100 Subject: [PATCH] docs(samples): remove project_number in interactive-tutorials (#158) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-retail/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) Fixes # 🦕 --- generated_samples/interactive-tutorials/README.md | 10 +++------- .../TEST_RESOURCES_SETUP_CLEANUP.md | 1 - .../product/import_products_inline_source.py | 2 +- .../search/search_simple_query.py | 4 ++-- .../search/search_with_boost_spec.py | 4 ++-- .../search/search_with_facet_spec.py | 4 ++-- .../search/search_with_filtering.py | 4 ++-- .../search/search_with_ordering.py | 4 ++-- .../search/search_with_pagination.py | 4 ++-- .../search/search_with_query_expansion_spec.py | 4 ++-- .../test_resources_recovery/create_test_resources.py | 3 +-- .../test_resources_recovery/remove_test_resources.py | 3 +-- 12 files changed, 20 insertions(+), 27 deletions(-) diff --git a/generated_samples/interactive-tutorials/README.md b/generated_samples/interactive-tutorials/README.md index 70fb2f3cd806..123abd84872f 100644 --- a/generated_samples/interactive-tutorials/README.md +++ b/generated_samples/interactive-tutorials/README.md @@ -72,16 +72,12 @@ To run a code sample from the Cloud Shell, you need to be authenticated using th export GOOGLE_APPLICATION_CREDENTIALS=~/key.json ``` -### Set the GOOGLE_CLOUD_PROJECT_NUMBER and GOOGLE_CLOUD_PROJECT environment variables +### Set the GOOGLE_CLOUD_PROJECT environment variable -You will run the code samples in your own Google Cloud project. To use the **project_number** and **project_id** in every request to the Retail API, you should first specify them as environment variables. +You will run the code samples in your own Google Cloud project. To use the **project_id** in every request to the Retail API, you should first specify them as environment variables. -1. Find the project number and project ID in the Project Info card displayed on **Home/Dashboard**. +1. Find the project ID in the Project Info card displayed on **Home/Dashboard**. -1. Set the **project_number** with the following command: - ```bash - export GOOGLE_CLOUD_PROJECT_NUMBER= - ``` 1. Set the **project_id** with the following command: ```bash export GOOGLE_CLOUD_PROJECT= diff --git a/generated_samples/interactive-tutorials/TEST_RESOURCES_SETUP_CLEANUP.md b/generated_samples/interactive-tutorials/TEST_RESOURCES_SETUP_CLEANUP.md index 89b1cf130731..772257f86e50 100644 --- a/generated_samples/interactive-tutorials/TEST_RESOURCES_SETUP_CLEANUP.md +++ b/generated_samples/interactive-tutorials/TEST_RESOURCES_SETUP_CLEANUP.md @@ -3,7 +3,6 @@ ## Required environment variables To successfully import the catalog data for tests, the following environment variables should be set: - - GOOGLE_CLOUD_PROJECT_NUMBER - GOOGLE_CLOUD_PROJECT - BUCKET_NAME - EVENTS_BUCKET_NAME diff --git a/generated_samples/interactive-tutorials/product/import_products_inline_source.py b/generated_samples/interactive-tutorials/product/import_products_inline_source.py index f0fbeef0cd80..f0b952d40913 100644 --- a/generated_samples/interactive-tutorials/product/import_products_inline_source.py +++ b/generated_samples/interactive-tutorials/product/import_products_inline_source.py @@ -32,7 +32,7 @@ ) from google.protobuf.field_mask_pb2 import FieldMask -# Read the project number from the environment variable +# Read the project ID from the environment variable project_id = os.environ["GOOGLE_CLOUD_PROJECT"] default_catalog = f"projects/{project_id}/locations/global/catalogs/default_catalog/branches/default_branch" diff --git a/generated_samples/interactive-tutorials/search/search_simple_query.py b/generated_samples/interactive-tutorials/search/search_simple_query.py index f145dd1dda7a..30a69b858516 100644 --- a/generated_samples/interactive-tutorials/search/search_simple_query.py +++ b/generated_samples/interactive-tutorials/search/search_simple_query.py @@ -19,14 +19,14 @@ from google.cloud.retail import SearchRequest, SearchServiceClient -project_number = os.environ["GOOGLE_CLOUD_PROJECT_NUMBER"] +project_id = os.environ["GOOGLE_CLOUD_PROJECT"] # get search service request: def get_search_request(query: str): default_search_placement = ( "projects/" - + project_number + + project_id + "/locations/global/catalogs/default_catalog/placements/default_search" ) diff --git a/generated_samples/interactive-tutorials/search/search_with_boost_spec.py b/generated_samples/interactive-tutorials/search/search_with_boost_spec.py index 10495b3edccb..d41063d5809c 100644 --- a/generated_samples/interactive-tutorials/search/search_with_boost_spec.py +++ b/generated_samples/interactive-tutorials/search/search_with_boost_spec.py @@ -20,14 +20,14 @@ from google.cloud.retail import SearchRequest, SearchServiceClient -project_number = os.environ["GOOGLE_CLOUD_PROJECT_NUMBER"] +project_id = os.environ["GOOGLE_CLOUD_PROJECT"] # get search service request: def get_search_request(query: str, condition: str, boost_strength: float): default_search_placement = ( "projects/" - + project_number + + project_id + "/locations/global/catalogs/default_catalog/placements/default_search" ) diff --git a/generated_samples/interactive-tutorials/search/search_with_facet_spec.py b/generated_samples/interactive-tutorials/search/search_with_facet_spec.py index 958631807a14..fb850b107266 100644 --- a/generated_samples/interactive-tutorials/search/search_with_facet_spec.py +++ b/generated_samples/interactive-tutorials/search/search_with_facet_spec.py @@ -18,14 +18,14 @@ from google.cloud.retail import SearchRequest, SearchServiceClient -project_number = os.environ["GOOGLE_CLOUD_PROJECT_NUMBER"] +project_id = os.environ["GOOGLE_CLOUD_PROJECT"] # get search service request: def get_search_request(query: str, facet_key_param: str): default_search_placement = ( "projects/" - + project_number + + project_id + "/locations/global/catalogs/default_catalog/placements/default_search" ) # PUT THE INTERVALS HERE: diff --git a/generated_samples/interactive-tutorials/search/search_with_filtering.py b/generated_samples/interactive-tutorials/search/search_with_filtering.py index fd14f8716483..d9c40a563528 100644 --- a/generated_samples/interactive-tutorials/search/search_with_filtering.py +++ b/generated_samples/interactive-tutorials/search/search_with_filtering.py @@ -19,14 +19,14 @@ from google.cloud.retail import SearchRequest, SearchServiceClient -project_number = os.environ["GOOGLE_CLOUD_PROJECT_NUMBER"] +project_id = os.environ["GOOGLE_CLOUD_PROJECT"] # get search service request: def get_search_request(query: str, _filter: str): default_search_placement = ( "projects/" - + project_number + + project_id + "/locations/global/catalogs/default_catalog/placements/default_search" ) diff --git a/generated_samples/interactive-tutorials/search/search_with_ordering.py b/generated_samples/interactive-tutorials/search/search_with_ordering.py index 85a7ee0e8e49..0863c44adb45 100644 --- a/generated_samples/interactive-tutorials/search/search_with_ordering.py +++ b/generated_samples/interactive-tutorials/search/search_with_ordering.py @@ -19,14 +19,14 @@ from google.cloud.retail import SearchRequest, SearchServiceClient -project_number = os.environ["GOOGLE_CLOUD_PROJECT_NUMBER"] +project_id = os.environ["GOOGLE_CLOUD_PROJECT"] # get search service request: def get_search_request(query: str, order: str): default_search_placement = ( "projects/" - + project_number + + project_id + "/locations/global/catalogs/default_catalog/placements/default_search" ) diff --git a/generated_samples/interactive-tutorials/search/search_with_pagination.py b/generated_samples/interactive-tutorials/search/search_with_pagination.py index a81604754114..994797e70fa5 100644 --- a/generated_samples/interactive-tutorials/search/search_with_pagination.py +++ b/generated_samples/interactive-tutorials/search/search_with_pagination.py @@ -21,14 +21,14 @@ from google.cloud.retail import SearchRequest, SearchServiceClient -project_number = os.environ["GOOGLE_CLOUD_PROJECT_NUMBER"] +project_id = os.environ["GOOGLE_CLOUD_PROJECT"] # get search service request: def get_search_request(query: str, page_size: int, offset: int, next_page_token: str): default_search_placement = ( "projects/" - + project_number + + project_id + "/locations/global/catalogs/default_catalog/placements/default_search" ) diff --git a/generated_samples/interactive-tutorials/search/search_with_query_expansion_spec.py b/generated_samples/interactive-tutorials/search/search_with_query_expansion_spec.py index f530a7c91d71..a21287b851f1 100644 --- a/generated_samples/interactive-tutorials/search/search_with_query_expansion_spec.py +++ b/generated_samples/interactive-tutorials/search/search_with_query_expansion_spec.py @@ -20,7 +20,7 @@ from google.cloud.retail import SearchRequest, SearchServiceClient -project_number = os.environ["GOOGLE_CLOUD_PROJECT_NUMBER"] +project_id = os.environ["GOOGLE_CLOUD_PROJECT"] # get search service request: @@ -29,7 +29,7 @@ def get_search_request( ): default_search_placement = ( "projects/" - + project_number + + project_id + "/locations/global/catalogs/default_catalog/placements/default_search" ) diff --git a/generated_samples/interactive-tutorials/test_resources_recovery/create_test_resources.py b/generated_samples/interactive-tutorials/test_resources_recovery/create_test_resources.py index c8822075f3b3..715d0163d59b 100644 --- a/generated_samples/interactive-tutorials/test_resources_recovery/create_test_resources.py +++ b/generated_samples/interactive-tutorials/test_resources_recovery/create_test_resources.py @@ -24,7 +24,6 @@ from google.cloud.retail import ProductServiceClient from google.cloud.storage.bucket import Bucket -project_number = os.environ["GOOGLE_CLOUD_PROJECT_NUMBER"] products_bucket_name = os.environ['BUCKET_NAME'] events_bucket_name = os.environ['EVENTS_BUCKET_NAME'] project_id = os.environ["GOOGLE_CLOUD_PROJECT"] @@ -40,7 +39,7 @@ events_schema = "../resources/events_schema.json" object_name = re.search('resources/(.*?)$', product_resource_file).group(1) -default_catalog = f"projects/{project_number}/locations/global/catalogs/default_catalog/branches/default_branch" +default_catalog = f"projects/{project_id}/locations/global/catalogs/default_catalog/branches/default_branch" storage_client = storage.Client() diff --git a/generated_samples/interactive-tutorials/test_resources_recovery/remove_test_resources.py b/generated_samples/interactive-tutorials/test_resources_recovery/remove_test_resources.py index a82cc67d4238..a025f3f35843 100644 --- a/generated_samples/interactive-tutorials/test_resources_recovery/remove_test_resources.py +++ b/generated_samples/interactive-tutorials/test_resources_recovery/remove_test_resources.py @@ -23,7 +23,6 @@ from google.cloud.storage.bucket import Bucket -project_number = os.environ["GOOGLE_CLOUD_PROJECT_NUMBER"] project_id = os.environ["GOOGLE_CLOUD_PROJECT"] product_bucket_name = os.environ['BUCKET_NAME'] events_bucket_name = os.environ['EVENTS_BUCKET_NAME'] @@ -31,7 +30,7 @@ product_dataset = "products" events_dataset = "user_events" -default_catalog = f"projects/{project_number}/locations/global/catalogs/default_catalog/branches/default_branch" +default_catalog = f"projects/{project_id}/locations/global/catalogs/default_catalog/branches/default_branch" storage_client = storage.Client()