Skip to content

Commit 945de0c

Browse files
rebeccawshawTakashi Matsuo
and
Takashi Matsuo
authored
chore(servicedirectory): add region tags (#4403)
* Update snippets.py add region tags to so we can upload code snippets in our docs: https://cloud.devsite.corp.google.com/service-directory/docs/configuring-service-directory * Update quickstart.py add region tags for quickstart.py to add the code to our documentation * Update snippets.py fix spacing Co-authored-by: Takashi Matsuo <[email protected]>
1 parent 32436e6 commit 945de0c

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

servicedirectory/quickstart.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
# [START servicedirectory_quickstart]
1718
from google.cloud import servicedirectory_v1beta1
1819

1920

@@ -30,3 +31,4 @@ def list_namespaces(project_id, location_id):
3031
print(f'Namespace: {namespace.name}')
3132

3233
return response
34+
# [END servicedirectory_quickstart]

servicedirectory/snippets.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from google.cloud import servicedirectory_v1beta1
1818

1919

20+
# [START servicedirectory_create_namespace]
2021
def create_namespace(project_id, location_id, namespace_id):
2122
"""Creates a namespace in the given location."""
2223

@@ -34,8 +35,10 @@ def create_namespace(project_id, location_id, namespace_id):
3435
print(f'Created namespace {response.name}.')
3536

3637
return response
38+
# [END servicedirectory_create_namespace]
3739

3840

41+
# [START servicedirectory_delete_namespace]
3942
def delete_namespace(project_id, location_id, namespace_id):
4043
"""Deletes a namespace in the given location."""
4144

@@ -46,8 +49,10 @@ def delete_namespace(project_id, location_id, namespace_id):
4649
client.delete_namespace(name=namespace_name)
4750

4851
print(f'Deleted namespace {namespace_name}.')
52+
# [END servicedirectory_delete_namespace]
4953

5054

55+
# [START servicedirectory_create_service]
5156
def create_service(project_id, location_id, namespace_id, service_id):
5257
"""Creates a service in the given namespace."""
5358

@@ -66,8 +71,10 @@ def create_service(project_id, location_id, namespace_id, service_id):
6671
print(f'Created service {response.name}.')
6772

6873
return response
74+
# [END servicedirectory_create_service]
6975

7076

77+
# [START servicedirectory_delete_service]
7178
def delete_service(project_id, location_id, namespace_id, service_id):
7279
"""Deletes a service in the given namespace."""
7380

@@ -79,8 +86,10 @@ def delete_service(project_id, location_id, namespace_id, service_id):
7986
client.delete_service(name=service_name)
8087

8188
print(f'Deleted service {service_name}.')
89+
# [END servicedirectory_delete_service]
8290

8391

92+
# [START servicedirectory_resolve_service]
8493
def resolve_service(project_id, location_id, namespace_id, service_id):
8594
"""Resolves a service in the given namespace."""
8695

@@ -97,8 +106,10 @@ def resolve_service(project_id, location_id, namespace_id, service_id):
97106
print(f'{endpoint.name} -- {endpoint.address}:{endpoint.port}')
98107

99108
return response
109+
# [END servicedirectory_resolve_service]
100110

101111

112+
# [START servicedirectory_create_endpoint]
102113
def create_endpoint(project_id, location_id, namespace_id, service_id,
103114
endpoint_id, address, port):
104115
"""Creates a endpoint in the given service."""
@@ -121,8 +132,10 @@ def create_endpoint(project_id, location_id, namespace_id, service_id,
121132
print(f'Created endpoint {response.name}.')
122133

123134
return response
135+
# [END servicedirectory_create_endpoint]
124136

125137

138+
# [START servicedirectory_delete_endpoint]
126139
def delete_endpoint(project_id, location_id, namespace_id, service_id,
127140
endpoint_id):
128141
"""Deletes a endpoin in the given service."""
@@ -135,3 +148,4 @@ def delete_endpoint(project_id, location_id, namespace_id, service_id,
135148
client.delete_endpoint(name=endpoint_name)
136149

137150
print(f'Deleted endpoint {endpoint_name}.')
151+
# [END servicedirectory_delete_endpoint]

0 commit comments

Comments
 (0)