Skip to content

Commit 5db506e

Browse files
authored
Merge pull request #30 from googlemaps-samples/update-rmi-cli-tools-20260225-010721
chore: update RMI CLI client scripts
2 parents aff1ea8 + 7404151 commit 5db506e

10 files changed

Lines changed: 215 additions & 138 deletions

roads_management_insights/rmi_cli_tools/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ For custom integrations, use the bundled building blocks in the `clients/` direc
119119
```bash
120120
source clients/roadsselection_v1_util.sh
121121
# List all routes in your project
122-
roadsselection_v1_projects_selectedRoutes_list_all "projects/$PROJECT_RMI_ID" "100" "$PROJECT_RMI_ID"
122+
roadsselection_v1_projects_selectedRoutes_list_all "$PROJECT_RMI_ID" "100"
123123
```
124124
125125
## License

roads_management_insights/rmi_cli_tools/clients/analyticshub_v1.sh

Lines changed: 106 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -273,16 +273,19 @@ ANALYTICSHUB_V1_BASE_URL="https://analyticshub.googleapis.com/v1"
273273

274274
# Lists all data exchanges in a given project and location.
275275
#
276-
# @param string parent Required. Format: projects/{project}/locations/{location}
276+
# @param string project_id Required.
277+
# @param string location Required.
277278
# @param integer page_size Optional.
278279
# @param string page_token Optional.
279-
# @param string project_id Optional.
280+
# @param string billing_project_id Optional. Defaults to project_id.
280281
analyticshub_v1_projects_locations_dataExchanges_list() {
281-
local parent="$1"
282-
local page_size="${2:-""}"
283-
local page_token="${3:-""}"
284-
local project_id="${4:-""}"
282+
local project_id="$1"
283+
local location="$2"
284+
local page_size="${3:-""}"
285+
local page_token="${4:-""}"
286+
local billing_project_id="${5:-$project_id}"
285287

288+
local parent="projects/${project_id}/locations/${location}"
286289
local query_args=()
287290
if [[ -n "${page_size}" ]]; then query_args+=("pageSize=${page_size}"); fi
288291
if [[ -n "${page_token}" ]]; then query_args+=("pageToken=${page_token}"); fi
@@ -291,64 +294,84 @@ analyticshub_v1_projects_locations_dataExchanges_list() {
291294
query_params=$(_build_query_params "${query_args[@]}")
292295

293296
local url="${ANALYTICSHUB_V1_BASE_URL}/${parent}/dataExchanges${query_params}"
294-
_call_api "GET" "${url}" "" "${project_id}"
297+
_call_api "GET" "${url}" "" "${billing_project_id}"
295298
}
296299

297300
# Creates a new data exchange.
298301
#
299-
# @param string parent Required. Format: projects/{project}/locations/{location}
302+
# @param string project_id Required.
303+
# @param string location Required.
300304
# @param string request_body Required. DataExchange JSON.
301305
# @param string data_exchange_id Required. The ID of the data exchange.
302-
# @param string project_id Optional.
306+
# @param string billing_project_id Optional. Defaults to project_id.
303307
analyticshub_v1_projects_locations_dataExchanges_create() {
304-
local parent="$1"
305-
local request_body="$2"
306-
local data_exchange_id="$3"
307-
local project_id="${4:-""}"
308+
local project_id="$1"
309+
local location="$2"
310+
local request_body="$3"
311+
local data_exchange_id="$4"
312+
local billing_project_id="${5:-$project_id}"
308313

314+
local parent="projects/${project_id}/locations/${location}"
309315
local query_params
310316
query_params=$(_build_query_params "dataExchangeId=${data_exchange_id}")
311317

312318
local url="${ANALYTICSHUB_V1_BASE_URL}/${parent}/dataExchanges${query_params}"
313-
_call_api "POST" "${url}" "${request_body}" "${project_id}"
319+
_call_api "POST" "${url}" "${request_body}" "${billing_project_id}"
314320
}
315321

316322
# Gets the details of a data exchange.
317323
#
318-
# @param string name Required. Format: projects/{project}/locations/{location}/dataExchanges/{data_exchange}
319-
# @param string project_id Optional.
324+
# @param string project_id Required.
325+
# @param string location Required.
326+
# @param string data_exchange_id Required.
327+
# @param string billing_project_id Optional. Defaults to project_id.
320328
analyticshub_v1_projects_locations_dataExchanges_get() {
321-
local name="$1"
322-
local project_id="${2:-""}"
329+
local project_id="$1"
330+
local location="$2"
331+
local data_exchange_id="$3"
332+
local billing_project_id="${4:-$project_id}"
333+
334+
local name="projects/${project_id}/locations/${location}/dataExchanges/${data_exchange_id}"
323335
local url="${ANALYTICSHUB_V1_BASE_URL}/${name}"
324-
_call_api "GET" "${url}" "" "${project_id}"
336+
_call_api "GET" "${url}" "" "${billing_project_id}"
325337
}
326338

327339
# Deletes an existing data exchange.
328340
#
329-
# @param string name Required. Format: projects/{project}/locations/{location}/dataExchanges/{data_exchange}
330-
# @param string project_id Optional.
341+
# @param string project_id Required.
342+
# @param string location Required.
343+
# @param string data_exchange_id Required.
344+
# @param string billing_project_id Optional. Defaults to project_id.
331345
analyticshub_v1_projects_locations_dataExchanges_delete() {
332-
local name="$1"
333-
local project_id="${2:-""}"
346+
local project_id="$1"
347+
local location="$2"
348+
local data_exchange_id="$3"
349+
local billing_project_id="${4:-$project_id}"
350+
351+
local name="projects/${project_id}/locations/${location}/dataExchanges/${data_exchange_id}"
334352
local url="${ANALYTICSHUB_V1_BASE_URL}/${name}"
335-
_call_api "DELETE" "${url}" "" "${project_id}"
353+
_call_api "DELETE" "${url}" "" "${billing_project_id}"
336354
}
337355

338356
# --- Listings ---
339357

340358
# Lists all listings in a given project and location.
341359
#
342-
# @param string parent Required. Format: projects/{project}/locations/{location}/dataExchanges/{data_exchange}
360+
# @param string project_id Required.
361+
# @param string location Required.
362+
# @param string data_exchange_id Required.
343363
# @param integer page_size Optional.
344364
# @param string page_token Optional.
345-
# @param string project_id Optional.
365+
# @param string billing_project_id Optional. Defaults to project_id.
346366
analyticshub_v1_projects_locations_dataExchanges_listings_list() {
347-
local parent="$1"
348-
local page_size="${2:-""}"
349-
local page_token="${3:-""}"
350-
local project_id="${4:-""}"
367+
local project_id="$1"
368+
local location="$2"
369+
local data_exchange_id="$3"
370+
local page_size="${4:-""}"
371+
local page_token="${5:-""}"
372+
local billing_project_id="${6:-$project_id}"
351373

374+
local parent="projects/${project_id}/locations/${location}/dataExchanges/${data_exchange_id}"
352375
local query_args=()
353376
if [[ -n "${page_size}" ]]; then query_args+=("pageSize=${page_size}"); fi
354377
if [[ -n "${page_token}" ]]; then query_args+=("pageToken=${page_token}"); fi
@@ -357,59 +380,88 @@ analyticshub_v1_projects_locations_dataExchanges_listings_list() {
357380
query_params=$(_build_query_params "${query_args[@]}")
358381

359382
local url="${ANALYTICSHUB_V1_BASE_URL}/${parent}/listings${query_params}"
360-
_call_api "GET" "${url}" "" "${project_id}"
383+
_call_api "GET" "${url}" "" "${billing_project_id}"
361384
}
362385

363386
# Creates a new listing.
364387
#
365-
# @param string parent Required. Format: projects/{project}/locations/{location}/dataExchanges/{data_exchange}
388+
# @param string project_id Required.
389+
# @param string location Required.
390+
# @param string data_exchange_id Required.
366391
# @param string request_body Required. Listing JSON.
367392
# @param string listing_id Required. The ID of the listing.
368-
# @param string project_id Optional.
393+
# @param string billing_project_id Optional. Defaults to project_id.
369394
analyticshub_v1_projects_locations_dataExchanges_listings_create() {
370-
local parent="$1"
371-
local request_body="$2"
372-
local listing_id="$3"
373-
local project_id="${4:-""}"
395+
local project_id="$1"
396+
local location="$2"
397+
local data_exchange_id="$3"
398+
local request_body="$4"
399+
local listing_id="$5"
400+
local billing_project_id="${6:-$project_id}"
374401

402+
local parent="projects/${project_id}/locations/${location}/dataExchanges/${data_exchange_id}"
375403
local query_params
376404
query_params=$(_build_query_params "listingId=${listing_id}")
377405

378406
local url="${ANALYTICSHUB_V1_BASE_URL}/${parent}/listings${query_params}"
379-
_call_api "POST" "${url}" "${request_body}" "${project_id}"
407+
_call_api "POST" "${url}" "${request_body}" "${billing_project_id}"
380408
}
381409

382410
# Gets the details of a listing.
383411
#
384-
# @param string name Required. Format: projects/{project}/locations/{location}/dataExchanges/{data_exchange}/listings/{listing}
385-
# @param string project_id Optional.
412+
# @param string project_id Required.
413+
# @param string location Required.
414+
# @param string data_exchange_id Required.
415+
# @param string listing_id Required.
416+
# @param string billing_project_id Optional. Defaults to project_id.
386417
analyticshub_v1_projects_locations_dataExchanges_listings_get() {
387-
local name="$1"
388-
local project_id="${2:-""}"
418+
local project_id="$1"
419+
local location="$2"
420+
local data_exchange_id="$3"
421+
local listing_id="$4"
422+
local billing_project_id="${5:-$project_id}"
423+
424+
local name="projects/${project_id}/locations/${location}/dataExchanges/${data_exchange_id}/listings/${listing_id}"
389425
local url="${ANALYTICSHUB_V1_BASE_URL}/${name}"
390-
_call_api "GET" "${url}" "" "${project_id}"
426+
_call_api "GET" "${url}" "" "${billing_project_id}"
391427
}
392428

393429
# Deletes a listing.
394430
#
395-
# @param string name Required. Format: projects/{project}/locations/{location}/dataExchanges/{data_exchange}/listings/{listing}
396-
# @param string project_id Optional.
431+
# @param string project_id Required.
432+
# @param string location Required.
433+
# @param string data_exchange_id Required.
434+
# @param string listing_id Required.
435+
# @param string billing_project_id Optional. Defaults to project_id.
397436
analyticshub_v1_projects_locations_dataExchanges_listings_delete() {
398-
local name="$1"
399-
local project_id="${2:-""}"
437+
local project_id="$1"
438+
local location="$2"
439+
local data_exchange_id="$3"
440+
local listing_id="$4"
441+
local billing_project_id="${5:-$project_id}"
442+
443+
local name="projects/${project_id}/locations/${location}/dataExchanges/${data_exchange_id}/listings/${listing_id}"
400444
local url="${ANALYTICSHUB_V1_BASE_URL}/${name}"
401-
_call_api "DELETE" "${url}" "" "${project_id}"
445+
_call_api "DELETE" "${url}" "" "${billing_project_id}"
402446
}
403447

404448
# Subscribes to a listing.
405449
#
406-
# @param string name Required. Format: projects/{project}/locations/{location}/dataExchanges/{data_exchange}/listings/{listing}
450+
# @param string project_id Required.
451+
# @param string location Required.
452+
# @param string data_exchange_id Required.
453+
# @param string listing_id Required.
407454
# @param string request_body Required. SubscribeListingRequest JSON.
408-
# @param string project_id Optional.
455+
# @param string billing_project_id Optional. Defaults to project_id.
409456
analyticshub_v1_projects_locations_dataExchanges_listings_subscribe() {
410-
local name="$1"
411-
local request_body="$2"
412-
local project_id="${3:-""}"
457+
local project_id="$1"
458+
local location="$2"
459+
local data_exchange_id="$3"
460+
local listing_id="$4"
461+
local request_body="$5"
462+
local billing_project_id="${6:-$project_id}"
463+
464+
local name="projects/${project_id}/locations/${location}/dataExchanges/${data_exchange_id}/listings/${listing_id}"
413465
local url="${ANALYTICSHUB_V1_BASE_URL}/${name}:subscribe"
414-
_call_api "POST" "${url}" "${request_body}" "${project_id}"
466+
_call_api "POST" "${url}" "${request_body}" "${billing_project_id}"
415467
}

roads_management_insights/rmi_cli_tools/clients/analyticshub_v1_util.sh

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,21 @@ source "${_SCRIPT_DIR}/analyticshub_v1.sh"
3333
#
3434
# Output: Stream of DataExchange resources in JSONL (Newline Delimited JSON) format.
3535
#
36-
# @param string parent Required.
36+
# @param string project_id Required.
37+
# @param string location Required.
3738
# @param integer page_size Optional.
38-
# @param string project_id Optional.
39+
# @param string page_token Optional.
40+
# @param string billing_project_id Optional. Defaults to project_id.
3941
analyticshub_v1_projects_locations_dataExchanges_list_all() {
40-
local parent="$1"
41-
local page_size="${2:-""}"
42-
local project_id="${3:-""}"
43-
local next_page_token=""
42+
local project_id="$1"
43+
local location="$2"
44+
local page_size="${3:-""}"
45+
local next_page_token="${4:-""}"
46+
local billing_project_id="${5:-$project_id}"
4447

4548
while true; do
4649
local response
47-
response=$(analyticshub_v1_projects_locations_dataExchanges_list "${parent}" "${page_size}" "${next_page_token}" "${project_id}")
50+
response=$(analyticshub_v1_projects_locations_dataExchanges_list "${project_id}" "${location}" "${page_size}" "${next_page_token}" "${billing_project_id}")
4851

4952
if echo "$response" | jq --exit-status '.error' > /dev/null 2>&1; then
5053
echo "API Error: $(echo "$response" | jq --compact-output '.error')" >&2
@@ -62,18 +65,23 @@ analyticshub_v1_projects_locations_dataExchanges_list_all() {
6265
#
6366
# Output: Stream of Listing resources in JSONL (Newline Delimited JSON) format.
6467
#
65-
# @param string parent Required.
68+
# @param string project_id Required.
69+
# @param string location Required.
70+
# @param string data_exchange_id Required.
6671
# @param integer page_size Optional.
67-
# @param string project_id Optional.
72+
# @param string page_token Optional.
73+
# @param string billing_project_id Optional. Defaults to project_id.
6874
analyticshub_v1_projects_locations_dataExchanges_listings_list_all() {
69-
local parent="$1"
70-
local page_size="${2:-""}"
71-
local project_id="${3:-""}"
72-
local next_page_token=""
75+
local project_id="$1"
76+
local location="$2"
77+
local data_exchange_id="$3"
78+
local page_size="${4:-""}"
79+
local next_page_token="${5:-""}"
80+
local billing_project_id="${6:-$project_id}"
7381

7482
while true; do
7583
local response
76-
response=$(analyticshub_v1_projects_locations_dataExchanges_listings_list "${parent}" "${page_size}" "${next_page_token}" "${project_id}")
84+
response=$(analyticshub_v1_projects_locations_dataExchanges_listings_list "${project_id}" "${location}" "${data_exchange_id}" "${page_size}" "${next_page_token}" "${billing_project_id}")
7785

7886
if echo "$response" | jq --exit-status '.error' > /dev/null 2>&1; then
7987
echo "API Error: $(echo "$response" | jq --compact-output '.error')" >&2

0 commit comments

Comments
 (0)