diff --git a/roads_management_insights/rmi_cli_tools/README.md b/roads_management_insights/rmi_cli_tools/README.md index 6e019cb..ea05133 100644 --- a/roads_management_insights/rmi_cli_tools/README.md +++ b/roads_management_insights/rmi_cli_tools/README.md @@ -119,7 +119,7 @@ For custom integrations, use the bundled building blocks in the `clients/` direc ```bash source clients/roadsselection_v1_util.sh # List all routes in your project -roadsselection_v1_projects_selectedRoutes_list_all "projects/$PROJECT_RMI_ID" "100" "$PROJECT_RMI_ID" +roadsselection_v1_projects_selectedRoutes_list_all "$PROJECT_RMI_ID" "100" ``` ## License diff --git a/roads_management_insights/rmi_cli_tools/clients/analyticshub_v1.sh b/roads_management_insights/rmi_cli_tools/clients/analyticshub_v1.sh index 0da8b7f..7723699 100755 --- a/roads_management_insights/rmi_cli_tools/clients/analyticshub_v1.sh +++ b/roads_management_insights/rmi_cli_tools/clients/analyticshub_v1.sh @@ -273,16 +273,19 @@ ANALYTICSHUB_V1_BASE_URL="https://analyticshub.googleapis.com/v1" # Lists all data exchanges in a given project and location. # -# @param string parent Required. Format: projects/{project}/locations/{location} +# @param string project_id Required. +# @param string location Required. # @param integer page_size Optional. # @param string page_token Optional. -# @param string project_id Optional. +# @param string billing_project_id Optional. Defaults to project_id. analyticshub_v1_projects_locations_dataExchanges_list() { - local parent="$1" - local page_size="${2:-""}" - local page_token="${3:-""}" - local project_id="${4:-""}" + local project_id="$1" + local location="$2" + local page_size="${3:-""}" + local page_token="${4:-""}" + local billing_project_id="${5:-$project_id}" + local parent="projects/${project_id}/locations/${location}" local query_args=() if [[ -n "${page_size}" ]]; then query_args+=("pageSize=${page_size}"); fi if [[ -n "${page_token}" ]]; then query_args+=("pageToken=${page_token}"); fi @@ -291,64 +294,84 @@ analyticshub_v1_projects_locations_dataExchanges_list() { query_params=$(_build_query_params "${query_args[@]}") local url="${ANALYTICSHUB_V1_BASE_URL}/${parent}/dataExchanges${query_params}" - _call_api "GET" "${url}" "" "${project_id}" + _call_api "GET" "${url}" "" "${billing_project_id}" } # Creates a new data exchange. # -# @param string parent Required. Format: projects/{project}/locations/{location} +# @param string project_id Required. +# @param string location Required. # @param string request_body Required. DataExchange JSON. # @param string data_exchange_id Required. The ID of the data exchange. -# @param string project_id Optional. +# @param string billing_project_id Optional. Defaults to project_id. analyticshub_v1_projects_locations_dataExchanges_create() { - local parent="$1" - local request_body="$2" - local data_exchange_id="$3" - local project_id="${4:-""}" + local project_id="$1" + local location="$2" + local request_body="$3" + local data_exchange_id="$4" + local billing_project_id="${5:-$project_id}" + local parent="projects/${project_id}/locations/${location}" local query_params query_params=$(_build_query_params "dataExchangeId=${data_exchange_id}") local url="${ANALYTICSHUB_V1_BASE_URL}/${parent}/dataExchanges${query_params}" - _call_api "POST" "${url}" "${request_body}" "${project_id}" + _call_api "POST" "${url}" "${request_body}" "${billing_project_id}" } # Gets the details of a data exchange. # -# @param string name Required. Format: projects/{project}/locations/{location}/dataExchanges/{data_exchange} -# @param string project_id Optional. +# @param string project_id Required. +# @param string location Required. +# @param string data_exchange_id Required. +# @param string billing_project_id Optional. Defaults to project_id. analyticshub_v1_projects_locations_dataExchanges_get() { - local name="$1" - local project_id="${2:-""}" + local project_id="$1" + local location="$2" + local data_exchange_id="$3" + local billing_project_id="${4:-$project_id}" + + local name="projects/${project_id}/locations/${location}/dataExchanges/${data_exchange_id}" local url="${ANALYTICSHUB_V1_BASE_URL}/${name}" - _call_api "GET" "${url}" "" "${project_id}" + _call_api "GET" "${url}" "" "${billing_project_id}" } # Deletes an existing data exchange. # -# @param string name Required. Format: projects/{project}/locations/{location}/dataExchanges/{data_exchange} -# @param string project_id Optional. +# @param string project_id Required. +# @param string location Required. +# @param string data_exchange_id Required. +# @param string billing_project_id Optional. Defaults to project_id. analyticshub_v1_projects_locations_dataExchanges_delete() { - local name="$1" - local project_id="${2:-""}" + local project_id="$1" + local location="$2" + local data_exchange_id="$3" + local billing_project_id="${4:-$project_id}" + + local name="projects/${project_id}/locations/${location}/dataExchanges/${data_exchange_id}" local url="${ANALYTICSHUB_V1_BASE_URL}/${name}" - _call_api "DELETE" "${url}" "" "${project_id}" + _call_api "DELETE" "${url}" "" "${billing_project_id}" } # --- Listings --- # Lists all listings in a given project and location. # -# @param string parent Required. Format: projects/{project}/locations/{location}/dataExchanges/{data_exchange} +# @param string project_id Required. +# @param string location Required. +# @param string data_exchange_id Required. # @param integer page_size Optional. # @param string page_token Optional. -# @param string project_id Optional. +# @param string billing_project_id Optional. Defaults to project_id. analyticshub_v1_projects_locations_dataExchanges_listings_list() { - local parent="$1" - local page_size="${2:-""}" - local page_token="${3:-""}" - local project_id="${4:-""}" + local project_id="$1" + local location="$2" + local data_exchange_id="$3" + local page_size="${4:-""}" + local page_token="${5:-""}" + local billing_project_id="${6:-$project_id}" + local parent="projects/${project_id}/locations/${location}/dataExchanges/${data_exchange_id}" local query_args=() if [[ -n "${page_size}" ]]; then query_args+=("pageSize=${page_size}"); fi if [[ -n "${page_token}" ]]; then query_args+=("pageToken=${page_token}"); fi @@ -357,59 +380,88 @@ analyticshub_v1_projects_locations_dataExchanges_listings_list() { query_params=$(_build_query_params "${query_args[@]}") local url="${ANALYTICSHUB_V1_BASE_URL}/${parent}/listings${query_params}" - _call_api "GET" "${url}" "" "${project_id}" + _call_api "GET" "${url}" "" "${billing_project_id}" } # Creates a new listing. # -# @param string parent Required. Format: projects/{project}/locations/{location}/dataExchanges/{data_exchange} +# @param string project_id Required. +# @param string location Required. +# @param string data_exchange_id Required. # @param string request_body Required. Listing JSON. # @param string listing_id Required. The ID of the listing. -# @param string project_id Optional. +# @param string billing_project_id Optional. Defaults to project_id. analyticshub_v1_projects_locations_dataExchanges_listings_create() { - local parent="$1" - local request_body="$2" - local listing_id="$3" - local project_id="${4:-""}" + local project_id="$1" + local location="$2" + local data_exchange_id="$3" + local request_body="$4" + local listing_id="$5" + local billing_project_id="${6:-$project_id}" + local parent="projects/${project_id}/locations/${location}/dataExchanges/${data_exchange_id}" local query_params query_params=$(_build_query_params "listingId=${listing_id}") local url="${ANALYTICSHUB_V1_BASE_URL}/${parent}/listings${query_params}" - _call_api "POST" "${url}" "${request_body}" "${project_id}" + _call_api "POST" "${url}" "${request_body}" "${billing_project_id}" } # Gets the details of a listing. # -# @param string name Required. Format: projects/{project}/locations/{location}/dataExchanges/{data_exchange}/listings/{listing} -# @param string project_id Optional. +# @param string project_id Required. +# @param string location Required. +# @param string data_exchange_id Required. +# @param string listing_id Required. +# @param string billing_project_id Optional. Defaults to project_id. analyticshub_v1_projects_locations_dataExchanges_listings_get() { - local name="$1" - local project_id="${2:-""}" + local project_id="$1" + local location="$2" + local data_exchange_id="$3" + local listing_id="$4" + local billing_project_id="${5:-$project_id}" + + local name="projects/${project_id}/locations/${location}/dataExchanges/${data_exchange_id}/listings/${listing_id}" local url="${ANALYTICSHUB_V1_BASE_URL}/${name}" - _call_api "GET" "${url}" "" "${project_id}" + _call_api "GET" "${url}" "" "${billing_project_id}" } # Deletes a listing. # -# @param string name Required. Format: projects/{project}/locations/{location}/dataExchanges/{data_exchange}/listings/{listing} -# @param string project_id Optional. +# @param string project_id Required. +# @param string location Required. +# @param string data_exchange_id Required. +# @param string listing_id Required. +# @param string billing_project_id Optional. Defaults to project_id. analyticshub_v1_projects_locations_dataExchanges_listings_delete() { - local name="$1" - local project_id="${2:-""}" + local project_id="$1" + local location="$2" + local data_exchange_id="$3" + local listing_id="$4" + local billing_project_id="${5:-$project_id}" + + local name="projects/${project_id}/locations/${location}/dataExchanges/${data_exchange_id}/listings/${listing_id}" local url="${ANALYTICSHUB_V1_BASE_URL}/${name}" - _call_api "DELETE" "${url}" "" "${project_id}" + _call_api "DELETE" "${url}" "" "${billing_project_id}" } # Subscribes to a listing. # -# @param string name Required. Format: projects/{project}/locations/{location}/dataExchanges/{data_exchange}/listings/{listing} +# @param string project_id Required. +# @param string location Required. +# @param string data_exchange_id Required. +# @param string listing_id Required. # @param string request_body Required. SubscribeListingRequest JSON. -# @param string project_id Optional. +# @param string billing_project_id Optional. Defaults to project_id. analyticshub_v1_projects_locations_dataExchanges_listings_subscribe() { - local name="$1" - local request_body="$2" - local project_id="${3:-""}" + local project_id="$1" + local location="$2" + local data_exchange_id="$3" + local listing_id="$4" + local request_body="$5" + local billing_project_id="${6:-$project_id}" + + local name="projects/${project_id}/locations/${location}/dataExchanges/${data_exchange_id}/listings/${listing_id}" local url="${ANALYTICSHUB_V1_BASE_URL}/${name}:subscribe" - _call_api "POST" "${url}" "${request_body}" "${project_id}" + _call_api "POST" "${url}" "${request_body}" "${billing_project_id}" } diff --git a/roads_management_insights/rmi_cli_tools/clients/analyticshub_v1_util.sh b/roads_management_insights/rmi_cli_tools/clients/analyticshub_v1_util.sh index 60568b6..72879c2 100755 --- a/roads_management_insights/rmi_cli_tools/clients/analyticshub_v1_util.sh +++ b/roads_management_insights/rmi_cli_tools/clients/analyticshub_v1_util.sh @@ -33,18 +33,21 @@ source "${_SCRIPT_DIR}/analyticshub_v1.sh" # # Output: Stream of DataExchange resources in JSONL (Newline Delimited JSON) format. # -# @param string parent Required. +# @param string project_id Required. +# @param string location Required. # @param integer page_size Optional. -# @param string project_id Optional. +# @param string page_token Optional. +# @param string billing_project_id Optional. Defaults to project_id. analyticshub_v1_projects_locations_dataExchanges_list_all() { - local parent="$1" - local page_size="${2:-""}" - local project_id="${3:-""}" - local next_page_token="" + local project_id="$1" + local location="$2" + local page_size="${3:-""}" + local next_page_token="${4:-""}" + local billing_project_id="${5:-$project_id}" while true; do local response - response=$(analyticshub_v1_projects_locations_dataExchanges_list "${parent}" "${page_size}" "${next_page_token}" "${project_id}") + response=$(analyticshub_v1_projects_locations_dataExchanges_list "${project_id}" "${location}" "${page_size}" "${next_page_token}" "${billing_project_id}") if echo "$response" | jq --exit-status '.error' > /dev/null 2>&1; then echo "API Error: $(echo "$response" | jq --compact-output '.error')" >&2 @@ -62,18 +65,23 @@ analyticshub_v1_projects_locations_dataExchanges_list_all() { # # Output: Stream of Listing resources in JSONL (Newline Delimited JSON) format. # -# @param string parent Required. +# @param string project_id Required. +# @param string location Required. +# @param string data_exchange_id Required. # @param integer page_size Optional. -# @param string project_id Optional. +# @param string page_token Optional. +# @param string billing_project_id Optional. Defaults to project_id. analyticshub_v1_projects_locations_dataExchanges_listings_list_all() { - local parent="$1" - local page_size="${2:-""}" - local project_id="${3:-""}" - local next_page_token="" + local project_id="$1" + local location="$2" + local data_exchange_id="$3" + local page_size="${4:-""}" + local next_page_token="${5:-""}" + local billing_project_id="${6:-$project_id}" while true; do local response - response=$(analyticshub_v1_projects_locations_dataExchanges_listings_list "${parent}" "${page_size}" "${next_page_token}" "${project_id}") + response=$(analyticshub_v1_projects_locations_dataExchanges_listings_list "${project_id}" "${location}" "${data_exchange_id}" "${page_size}" "${next_page_token}" "${billing_project_id}") if echo "$response" | jq --exit-status '.error' > /dev/null 2>&1; then echo "API Error: $(echo "$response" | jq --compact-output '.error')" >&2 diff --git a/roads_management_insights/rmi_cli_tools/clients/roadsselection_v1.sh b/roads_management_insights/rmi_cli_tools/clients/roadsselection_v1.sh index 5dd3b3c..6fff954 100755 --- a/roads_management_insights/rmi_cli_tools/clients/roadsselection_v1.sh +++ b/roads_management_insights/rmi_cli_tools/clients/roadsselection_v1.sh @@ -223,81 +223,81 @@ ROADS_SELECTION_V1_BASE_URL="https://roads.googleapis.com/selection/v1" # Creates multiple SelectedRoutes and starts a schedule. # -# @param string parent Required. The project resource. Format: projects/{project} +# @param string project_id Required. # @param string request_body Required. The BatchCreateSelectedRoutesRequest JSON. -# @param string project_id Optional. Project ID for quota/billing. +# @param string billing_project_id Optional. Defaults to project_id. roadsselection_v1_projects_selectedRoutes_batchCreate() { - local parent="$1" + local project_id="$1" local request_body="$2" - local project_id="${3:-}" + local billing_project_id="${3:-$project_id}" + local parent="projects/${project_id}" local url="${ROADS_SELECTION_V1_BASE_URL}/${parent}/selectedRoutes:batchCreate" - _call_api "POST" "${url}" "${request_body}" "${project_id}" + _call_api "POST" "${url}" "${request_body}" "${billing_project_id}" } # Creates a SelectedRoute and starts a schedule. # -# @param string parent Required. The project resource. Format: projects/{project} +# @param string project_id Required. # @param string request_body Required. The SelectedRoute JSON. # @param string selected_route_id Optional. The ID to use for the SelectedRoute. -# @param string project_id Optional. Project ID for quota/billing. +# @param string billing_project_id Optional. Defaults to project_id. roadsselection_v1_projects_selectedRoutes_create() { - local parent="$1" + local project_id="$1" local request_body="$2" local selected_route_id="${3:-}" - local project_id="${4:-}" + local billing_project_id="${4:-$project_id}" + local parent="projects/${project_id}" local query_params="" if [[ -n "${selected_route_id}" ]]; then query_params=$(_build_query_params "selectedRouteId=${selected_route_id}") fi local url="${ROADS_SELECTION_V1_BASE_URL}/${parent}/selectedRoutes${query_params}" - _call_api "POST" "${url}" "${request_body}" "${project_id}" + _call_api "POST" "${url}" "${request_body}" "${billing_project_id}" } # Deletes the specified SelectedRoute. # -# @param string name Required. The name of the SelectedRoute to delete. -# @param string project_id Optional. Project ID for quota/billing. +# @param string project_id Required. +# @param string selected_route_id Required. +# @param string billing_project_id Optional. Defaults to project_id. roadsselection_v1_projects_selectedRoutes_delete() { - local name="$1" - local project_id="${2:-}" + local project_id="$1" + local selected_route_id="$2" + local billing_project_id="${3:-$project_id}" + local name="projects/${project_id}/selectedRoutes/${selected_route_id}" local url="${ROADS_SELECTION_V1_BASE_URL}/${name}" - _call_api "DELETE" "${url}" "" "${project_id}" + _call_api "DELETE" "${url}" "" "${billing_project_id}" } # Gets a SelectedRoute. # -# @param string name Required. The name of the SelectedRoute to retrieve. -# @param string project_id Optional. Project ID for quota/billing. +# @param string project_id Required. +# @param string selected_route_id Required. +# @param string billing_project_id Optional. Defaults to project_id. roadsselection_v1_projects_selectedRoutes_get() { - local name="$1" - local project_id="${2:-}" + local project_id="$1" + local selected_route_id="$2" + local billing_project_id="${3:-$project_id}" + local name="projects/${project_id}/selectedRoutes/${selected_route_id}" local url="${ROADS_SELECTION_V1_BASE_URL}/${name}" - _call_api "GET" "${url}" "" "${project_id}" + _call_api "GET" "${url}" "" "${billing_project_id}" } # Lists all SelectedRoutes for the specified project. # -# @param string parent Required. The parent project. Format: projects/{project}/selectedRoutes -# Note: Discovery doc says 'parent' is projects/{project}/selectedRoutes -# but usually list parent is just projects/{project}. -# Checking path: "selection/v1/{+parent}/selectedRoutes" -# This implies parent should be "projects/{project}" and the path appends "/selectedRoutes". -# However, the parameter pattern says "^projects/[^/]+$" which is projects/{project}. -# Wait, the discovery doc says: -# "path": "selection/v1/{+parent}/selectedRoutes" -# "parameter": "parent", "pattern": "^projects/[^/]+$" -# So 'parent' is indeed 'projects/my-project'. +# @param string project_id Required. # @param integer page_size Optional. # @param string page_token Optional. -# @param string project_id Optional. Project ID for quota/billing. +# @param string billing_project_id Optional. Defaults to project_id. roadsselection_v1_projects_selectedRoutes_list() { - local parent="$1" + local project_id="$1" local page_size="${2:-}" local page_token="${3:-}" - local project_id="${4:-}" + local billing_project_id="${4:-$project_id}" + local parent="projects/${project_id}" local query_args=() if [[ -n "${page_size}" ]]; then query_args+=("pageSize=${page_size}"); fi if [[ -n "${page_token}" ]]; then query_args+=("pageToken=${page_token}"); fi @@ -306,5 +306,5 @@ roadsselection_v1_projects_selectedRoutes_list() { query_params=$(_build_query_params "${query_args[@]}") local url="${ROADS_SELECTION_V1_BASE_URL}/${parent}/selectedRoutes${query_params}" - _call_api "GET" "${url}" "" "${project_id}" + _call_api "GET" "${url}" "" "${billing_project_id}" } diff --git a/roads_management_insights/rmi_cli_tools/clients/roadsselection_v1_util.sh b/roads_management_insights/rmi_cli_tools/clients/roadsselection_v1_util.sh index 715eeb1..9ef0022 100755 --- a/roads_management_insights/rmi_cli_tools/clients/roadsselection_v1_util.sh +++ b/roads_management_insights/rmi_cli_tools/clients/roadsselection_v1_util.sh @@ -36,18 +36,19 @@ source "${_SCRIPT_DIR}/roadsselection_v1.sh" # # Output: Stream of SelectedRoute resources in JSONL (Newline Delimited JSON) format. # -# @param string parent Required. The parent project. Format: projects/{project} -# @param integer page_size Optional. The number of results per page. -# @param string project_id Optional. Project ID for quota/billing. +# @param string project_id Required. +# @param integer page_size Optional. +# @param string page_token Optional. +# @param string billing_project_id Optional. Defaults to project_id. roadsselection_v1_projects_selectedRoutes_list_all() { - local parent="$1" + local project_id="$1" local page_size="${2:-""}" - local project_id="${3:-""}" - local next_page_token="" + local next_page_token="${3:-""}" + local billing_project_id="${4:-$project_id}" while true; do local response - response=$(roadsselection_v1_projects_selectedRoutes_list "${parent}" "${page_size}" "${next_page_token}" "${project_id}") + response=$(roadsselection_v1_projects_selectedRoutes_list "${project_id}" "${page_size}" "${next_page_token}" "${billing_project_id}") # Check for API Error if echo "$response" | jq --exit-status '.error' > /dev/null 2>&1; then diff --git a/roads_management_insights/rmi_cli_tools/scenarios/project_cloud_setup.sh b/roads_management_insights/rmi_cli_tools/scenarios/project_cloud_setup.sh index dd10646..97ba44d 100755 --- a/roads_management_insights/rmi_cli_tools/scenarios/project_cloud_setup.sh +++ b/roads_management_insights/rmi_cli_tools/scenarios/project_cloud_setup.sh @@ -162,12 +162,14 @@ run_all() { # Internal function to handle subscription logic to an Analytics Hub data exchange. _subscribe_to_exchange() { - local exchange_path="$1" - local project_cloud_id="$2" - local dest_dataset="$3" - local dest_location="$4" + local src_project="$1" + local src_location="$2" + local src_exchange="$3" + local project_cloud_id="$4" + local dest_dataset="$5" + local dest_location="$6" - echo "Target Exchange: $exchange_path" + echo "Target Exchange: projects/$src_project/locations/$src_location/dataExchanges/$src_exchange" if ! command -v analyticshub_v1_projects_locations_dataExchanges_listings_list &> /dev/null; then echo "Error: Analytics Hub client not found. Ensure you are running from the 'dist' folder." @@ -176,7 +178,7 @@ _subscribe_to_exchange() { echo "Fetching listings for exchange..." local listings_json - listings_json=$(analyticshub_v1_projects_locations_dataExchanges_listings_list "$exchange_path" "" "" "$project_cloud_id") + listings_json=$(analyticshub_v1_projects_locations_dataExchanges_listings_list "$src_project" "$src_location" "$src_exchange" "" "" "$project_cloud_id") local listing_name listing_name=$(echo "$listings_json" | jq -r '.listings[0].name // empty') @@ -186,7 +188,10 @@ _subscribe_to_exchange() { return 1 fi - echo "Found Listing: $listing_name" + local listing_id + listing_id=$(echo "$listing_name" | sed 's|.*/listings/||') + + echo "Found Listing: $listing_id" # Prepare Subscription Request local dest_ref @@ -197,7 +202,7 @@ _subscribe_to_exchange() { sub_req=$(create_subscribe_listing_request "$dest_ds") echo "Subscribing to listing..." - analyticshub_v1_projects_locations_dataExchanges_listings_subscribe "$listing_name" "$sub_req" "$project_cloud_id" + analyticshub_v1_projects_locations_dataExchanges_listings_subscribe "$src_project" "$src_location" "$src_exchange" "$listing_id" "$sub_req" "$project_cloud_id" } # Subscribes to a data exchange using a URL from the Google Cloud Console. @@ -212,9 +217,8 @@ subscribe_from_console_url() { local src_project="${BASH_REMATCH[1]}" local src_location="${BASH_REMATCH[2]}" local src_exchange="${BASH_REMATCH[3]}" - local exchange_path="projects/$src_project/locations/$src_location/dataExchanges/$src_exchange" - _subscribe_to_exchange "$exchange_path" "$project_cloud_id" "$dest_dataset" "$dest_location" + _subscribe_to_exchange "$src_project" "$src_location" "$src_exchange" "$project_cloud_id" "$dest_dataset" "$dest_location" else echo "Error: Could not parse Analytics Hub URL." echo "Expected format: https://console.cloud.google.com/bigquery/analytics-hub/exchanges/projects/.../locations/.../dataExchanges/..." @@ -230,8 +234,7 @@ subscribe_from_params() { local dest_dataset="${5:-rmi_data_dataset}" local dest_location="${6:-us}" - local exchange_path="projects/$src_project/locations/$src_location/dataExchanges/$src_exchange" - _subscribe_to_exchange "$exchange_path" "$project_cloud_id" "$dest_dataset" "$dest_location" + _subscribe_to_exchange "$src_project" "$src_location" "$src_exchange" "$project_cloud_id" "$dest_dataset" "$dest_location" } # Creates a Pub/Sub subscription to the RMI real-time topic in JSON format. diff --git a/roads_management_insights/rmi_cli_tools/scenarios/project_optional_vpcsc.sh b/roads_management_insights/rmi_cli_tools/scenarios/project_optional_vpcsc.sh index b02373b..5398997 100755 --- a/roads_management_insights/rmi_cli_tools/scenarios/project_optional_vpcsc.sh +++ b/roads_management_insights/rmi_cli_tools/scenarios/project_optional_vpcsc.sh @@ -43,6 +43,7 @@ step_show_restricted_services() { echo " - analyticshub.googleapis.com" echo " - bigquery.googleapis.com" echo " - pubsub.googleapis.com" + echo " - roads.googleapis.com" } # Generates the YAML snippet for a VPC-SC Ingress Rule. @@ -76,6 +77,9 @@ step_generate_ingress() { echo " - serviceName: pubsub.googleapis.com" echo " methodSelectors:" echo " - method: '*'" + echo " - serviceName: roads.googleapis.com" + echo " methodSelectors:" + echo " - method: '*'" echo " resources:" echo " - projects/$project_number" } @@ -97,6 +101,9 @@ step_generate_egress() { echo " - serviceName: pubsub.googleapis.com" echo " methodSelectors:" echo " - method: '*'" + echo " - serviceName: roads.googleapis.com" + echo " methodSelectors:" + echo " - method: '*'" echo " resources:" echo " - projects/maps-platform-roads-management" echo " egressFrom:" diff --git a/roads_management_insights/rmi_cli_tools/scenarios/project_rmi_setup.sh b/roads_management_insights/rmi_cli_tools/scenarios/project_rmi_setup.sh index 7c9f586..bd233e3 100755 --- a/roads_management_insights/rmi_cli_tools/scenarios/project_rmi_setup.sh +++ b/roads_management_insights/rmi_cli_tools/scenarios/project_rmi_setup.sh @@ -60,7 +60,7 @@ step_enable_apis() { local project_id="${1:-${PROJECT_RMI_ID:-}}" if [[ -z "$project_id" ]]; then echo "Error: PROJECT_RMI_ID required"; exit 1; fi echo "Enabling APIs for $project_id..." - gcloud services enable roadsselection.googleapis.com --project "$project_id" + gcloud services enable roads.googleapis.com --project "$project_id" gcloud services enable analyticshub.googleapis.com --project "$project_id" echo "APIs enabled." } @@ -70,7 +70,7 @@ step_verify_apis() { local project_id="${1:-${PROJECT_RMI_ID:-}}" if [[ -z "$project_id" ]]; then echo "Error: PROJECT_RMI_ID required"; exit 1; fi echo "Verifying enabled APIs for $project_id..." - gcloud services list --project "$project_id" --filter="config.name:roadsselection.googleapis.com" + gcloud services list --project "$project_id" --filter="config.name:roads.googleapis.com" gcloud services list --project "$project_id" --filter="config.name:analyticshub.googleapis.com" } diff --git a/roads_management_insights/rmi_cli_tools/scenarios/rmi_data_backup.sh b/roads_management_insights/rmi_cli_tools/scenarios/rmi_data_backup.sh index 065fbe9..568cca6 100755 --- a/roads_management_insights/rmi_cli_tools/scenarios/rmi_data_backup.sh +++ b/roads_management_insights/rmi_cli_tools/scenarios/rmi_data_backup.sh @@ -69,8 +69,7 @@ step_backup_routes() { return 1 fi - local parent="projects/$project_id" - roadsselection_v1_projects_selectedRoutes_list_all "$parent" "1000" "$project_id" > "$output_file" + roadsselection_v1_projects_selectedRoutes_list_all "$project_id" "1000" "" local count count=$(wc -l < "$output_file") diff --git a/roads_management_insights/rmi_cli_tools/scenarios/rmi_verify_api_access.sh b/roads_management_insights/rmi_cli_tools/scenarios/rmi_verify_api_access.sh index 37a505b..4cbbd6c 100755 --- a/roads_management_insights/rmi_cli_tools/scenarios/rmi_verify_api_access.sh +++ b/roads_management_insights/rmi_cli_tools/scenarios/rmi_verify_api_access.sh @@ -91,9 +91,8 @@ step_create_route() { if [[ -z "$SELECTED_ROUTE" ]]; then step_prepare_data; fi echo "--- Step 2: Create Selected Route in $project_id ---" - local parent="projects/$project_id" local response_create - response_create=$(roadsselection_v1_projects_selectedRoutes_create "$parent" "$SELECTED_ROUTE" "" "$project_id") + response_create=$(roadsselection_v1_projects_selectedRoutes_create "$project_id" "$SELECTED_ROUTE") # Check for errors if echo "$response_create" | jq -e '.error' >/dev/null; then @@ -112,9 +111,12 @@ step_get_route() { local route_name="${2:-$ROUTE_NAME}" if [[ -z "$project_id" || -z "$route_name" ]]; then echo "Usage: step_get_route "; exit 1; fi - echo "--- Step 3: Get Selected Route $route_name ---" + local route_id + route_id=$(echo "$route_name" | sed 's|.*/selectedRoutes/||') + + echo "--- Step 3: Get Selected Route $route_id ---" local response_get - response_get=$(roadsselection_v1_projects_selectedRoutes_get "$route_name" "$project_id") + response_get=$(roadsselection_v1_projects_selectedRoutes_get "$project_id" "$route_id") if echo "$response_get" | jq -e '.error' >/dev/null; then echo "Error Getting Route:" @@ -134,9 +136,8 @@ step_list_routes() { if [[ -z "$project_id" ]]; then echo "Error: PROJECT_RMI_ID required"; exit 1; fi echo "--- Step 4: List Selected Routes in $project_id ---" - local parent="projects/$project_id" local response_list - response_list=$(roadsselection_v1_projects_selectedRoutes_list "$parent" "100" "" "$project_id") + response_list=$(roadsselection_v1_projects_selectedRoutes_list "$project_id" "100") if echo "$response_list" | jq -e '.error' >/dev/null; then echo "Error Listing Routes:" @@ -161,9 +162,12 @@ step_delete_route() { local route_name="${2:-$ROUTE_NAME}" if [[ -z "$project_id" || -z "$route_name" ]]; then echo "Usage: step_delete_route "; exit 1; fi - echo "--- Step 5: Delete Selected Route $route_name ---" + local route_id + route_id=$(echo "$route_name" | sed 's|.*/selectedRoutes/||') + + echo "--- Step 5: Delete Selected Route $route_id ---" local response_delete - response_delete=$(roadsselection_v1_projects_selectedRoutes_delete "$route_name" "$project_id") + response_delete=$(roadsselection_v1_projects_selectedRoutes_delete "$project_id" "$route_id") if echo "$response_delete" | jq -e '.error' >/dev/null; then echo "Error Deleting Route:" @@ -180,9 +184,12 @@ step_verify_deletion() { local route_name="${2:-$ROUTE_NAME}" if [[ -z "$project_id" || -z "$route_name" ]]; then echo "Usage: step_verify_deletion "; exit 1; fi - echo "--- Step 6: Verify Deletion of $route_name ---" + local route_id + route_id=$(echo "$route_name" | sed 's|.*/selectedRoutes/||') + + echo "--- Step 6: Verify Deletion of $route_id ---" local response_get_again - response_get_again=$(roadsselection_v1_projects_selectedRoutes_get "$route_name" "$project_id") + response_get_again=$(roadsselection_v1_projects_selectedRoutes_get "$project_id" "$route_id") if echo "$response_get_again" | jq -e '.error.code == 404' >/dev/null; then echo "PASS: Route successfully deleted (Received 404 as expected)." @@ -216,13 +223,13 @@ if [[ $# -eq 0 ]]; then exit 0 fi -case "$1" in +case "" in all) shift run_all "$@" ;; step_*) - cmd="$1" + cmd="" shift "$cmd" "$@" ;;