Skip to content

Commit 1daa5fa

Browse files
Fixed inconsistent location arg in methods
1 parent 1905fbf commit 1daa5fa

6 files changed

+23
-23
lines changed

model_armor/snippets/create_template.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020

2121
def create_model_armor_template(
2222
project_id: str,
23-
location: str,
23+
location_id: str,
2424
template_id: str,
2525
) -> modelarmor_v1.Template:
2626
"""Create a new Model Armor template.
2727
2828
Args:
2929
project_id (str): Google Cloud project ID.
30-
location (str): Google Cloud location.
30+
location_id (str): Google Cloud location.
3131
template_id (str): ID for the template to create.
3232
3333
Returns:
@@ -40,14 +40,14 @@ def create_model_armor_template(
4040

4141
# TODO(Developer): Uncomment these variables.
4242
# project_id = "your-google-cloud-project-id"
43-
# location = "us-central1"
43+
# location_id = "us-central1"
4444
# template_id = "template_id"
4545

4646
# Create the Model Armor client.
4747
client = modelarmor_v1.ModelArmorClient(
4848
transport="rest",
4949
client_options=ClientOptions(
50-
api_endpoint=f"modelarmor.{location}.rep.googleapis.com"
50+
api_endpoint=f"modelarmor.{location_id}.rep.googleapis.com"
5151
),
5252
)
5353

@@ -68,7 +68,7 @@ def create_model_armor_template(
6868

6969
# Prepare the request for creating the template.
7070
request = modelarmor_v1.CreateTemplateRequest(
71-
parent=f"projects/{project_id}/locations/{location}",
71+
parent=f"projects/{project_id}/locations/{location_id}",
7272
template_id=template_id,
7373
template=template,
7474
)

model_armor/snippets/create_template_with_advanced_sdp.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def create_model_armor_template_with_advanced_sdp(
4343
returned as SdpFinding in SdpInsepctionResult e.g.
4444
`organizations/{organization}/inspectTemplates/{inspect_template}`,
4545
`projects/{project}/inspectTemplates/{inspect_template}`
46-
`organizations/{organization}/locations/{location}/inspectTemplates/{inspect_template}`
47-
`projects/{project}/locations/{location}/inspectTemplates/{inspect_template}`
46+
`organizations/{organization}/locations/{location_id}/inspectTemplates/{inspect_template}`
47+
`projects/{project}/locations/{location_id}/inspectTemplates/{inspect_template}`
4848
deidentify_template (str):
4949
Optional. Optional Sensitive Data Protection Deidentify
5050
template resource name.
@@ -56,8 +56,8 @@ def create_model_armor_template_with_advanced_sdp(
5656
e.g.
5757
`organizations/{organization}/deidentifyTemplates/{deidentify_template}`,
5858
`projects/{project}/deidentifyTemplates/{deidentify_template}`
59-
`organizations/{organization}/locations/{location}/deidentifyTemplates/{deidentify_template}`
60-
`projects/{project}/locations/{location}/deidentifyTemplates/{deidentify_template}`
59+
`organizations/{organization}/locations/{location_id}/deidentifyTemplates/{deidentify_template}`
60+
`projects/{project}/locations/{location_id}/deidentifyTemplates/{deidentify_template}`
6161
Example:
6262
# Create template with advance SDP configuration
6363
create_model_armor_template_with_advanced_sdp(

model_armor/snippets/delete_template.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818

1919
def delete_model_armor_template(
2020
project_id: str,
21-
location: str,
21+
location_id: str,
2222
template_id: str,
2323
) -> None:
2424
"""Delete a model armor template.
2525
2626
Args:
2727
project_id (str): Google Cloud project ID.
28-
location (str): Google Cloud location.
28+
location_id (str): Google Cloud location.
2929
template_id (str): ID for the template to be deleted.
3030
"""
3131
# [START modelarmor_delete_template]
@@ -35,20 +35,20 @@ def delete_model_armor_template(
3535

3636
# TODO(Developer): Uncomment these variables.
3737
# project_id = "YOUR_PROJECT_ID"
38-
# location = "us-central1"
38+
# location_id = "us-central1"
3939
# template_id = "template_id"
4040

4141
# Create the Model Armor client.
4242
client = modelarmor_v1.ModelArmorClient(
4343
transport="rest",
4444
client_options=ClientOptions(
45-
api_endpoint=f"modelarmor.{location}.rep.googleapis.com"
45+
api_endpoint=f"modelarmor.{location_id}.rep.googleapis.com"
4646
),
4747
)
4848

4949
# Build the request for deleting the template.
5050
request = modelarmor_v1.DeleteTemplateRequest(
51-
name=f"projects/{project_id}/locations/{location}/templates/{template_id}",
51+
name=f"projects/{project_id}/locations/{location_id}/templates/{template_id}",
5252
)
5353

5454
# Delete the template.

model_armor/snippets/get_template.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
def get_model_armor_template(
2222
project_id: str,
23-
location: str,
23+
location_id: str,
2424
template_id: str,
2525
) -> modelarmor_v1.Template:
2626
"""Get model armor template.
@@ -40,20 +40,20 @@ def get_model_armor_template(
4040

4141
# TODO(Developer): Uncomment these variables.
4242
# project_id = "YOUR_PROJECT_ID"
43-
# location = "us-central1"
43+
# location_id = "us-central1"
4444
# template_id = "template_id"
4545

4646
# Create the Model Armor client.
4747
client = modelarmor_v1.ModelArmorClient(
4848
transport="rest",
4949
client_options=ClientOptions(
50-
api_endpoint=f"modelarmor.{location}.rep.googleapis.com"
50+
api_endpoint=f"modelarmor.{location_id}.rep.googleapis.com"
5151
),
5252
)
5353

5454
# Initialize request arguments.
5555
request = modelarmor_v1.GetTemplateRequest(
56-
name=f"projects/{project_id}/locations/{location}/templates/{template_id}",
56+
name=f"projects/{project_id}/locations/{location_id}/templates/{template_id}",
5757
)
5858

5959
# Get the template.

model_armor/snippets/list_templates.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
def list_model_armor_templates(
2222
project_id: str,
23-
location: str,
23+
location_id: str,
2424
) -> pagers.ListTemplatesPager:
2525
"""List model armor templates.
2626
@@ -37,19 +37,19 @@ def list_model_armor_templates(
3737

3838
# TODO(Developer): Uncomment these variables.
3939
# project_id = "YOUR_PROJECT_ID"
40-
# location = "us-central1"
40+
# location_id = "us-central1"
4141

4242
# Create the Model Armor client.
4343
client = modelarmor_v1.ModelArmorClient(
4444
transport="rest",
4545
client_options=ClientOptions(
46-
api_endpoint=f"modelarmor.{location}.rep.googleapis.com"
46+
api_endpoint=f"modelarmor.{location_id}.rep.googleapis.com"
4747
),
4848
)
4949

5050
# Initialize request argument(s).
5151
request = modelarmor_v1.ListTemplatesRequest(
52-
parent=f"projects/{project_id}/locations/{location}"
52+
parent=f"projects/{project_id}/locations/{location_id}"
5353
)
5454

5555
# Get list of templates.

model_armor/snippets/sanitize_user_prompt.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def sanitize_user_prompt(
4343

4444
# TODO(Developer): Uncomment these variables.
4545
# project_id = "YOUR_PROJECT_ID"
46-
# location = "us-central1"
46+
# location_id = "us-central1"
4747
# template_id = "template_id"
4848
# user_prompt = "Prompt entered by the user"
4949

0 commit comments

Comments
 (0)