17
17
from google .cloud import servicedirectory_v1beta1
18
18
19
19
20
+ # [START servicedirectory_create_namespace]
20
21
def create_namespace (project_id , location_id , namespace_id ):
21
22
"""Creates a namespace in the given location."""
22
23
@@ -34,8 +35,10 @@ def create_namespace(project_id, location_id, namespace_id):
34
35
print (f'Created namespace { response .name } .' )
35
36
36
37
return response
38
+ # [END servicedirectory_create_namespace]
37
39
38
40
41
+ # [START servicedirectory_delete_namespace]
39
42
def delete_namespace (project_id , location_id , namespace_id ):
40
43
"""Deletes a namespace in the given location."""
41
44
@@ -46,8 +49,10 @@ def delete_namespace(project_id, location_id, namespace_id):
46
49
client .delete_namespace (name = namespace_name )
47
50
48
51
print (f'Deleted namespace { namespace_name } .' )
52
+ # [END servicedirectory_delete_namespace]
49
53
50
54
55
+ # [START servicedirectory_create_service]
51
56
def create_service (project_id , location_id , namespace_id , service_id ):
52
57
"""Creates a service in the given namespace."""
53
58
@@ -66,8 +71,10 @@ def create_service(project_id, location_id, namespace_id, service_id):
66
71
print (f'Created service { response .name } .' )
67
72
68
73
return response
74
+ # [END servicedirectory_create_service]
69
75
70
76
77
+ # [START servicedirectory_delete_service]
71
78
def delete_service (project_id , location_id , namespace_id , service_id ):
72
79
"""Deletes a service in the given namespace."""
73
80
@@ -79,8 +86,10 @@ def delete_service(project_id, location_id, namespace_id, service_id):
79
86
client .delete_service (name = service_name )
80
87
81
88
print (f'Deleted service { service_name } .' )
89
+ # [END servicedirectory_delete_service]
82
90
83
91
92
+ # [START servicedirectory_resolve_service]
84
93
def resolve_service (project_id , location_id , namespace_id , service_id ):
85
94
"""Resolves a service in the given namespace."""
86
95
@@ -97,8 +106,10 @@ def resolve_service(project_id, location_id, namespace_id, service_id):
97
106
print (f'{ endpoint .name } -- { endpoint .address } :{ endpoint .port } ' )
98
107
99
108
return response
109
+ # [END servicedirectory_resolve_service]
100
110
101
111
112
+ # [START servicedirectory_create_endpoint]
102
113
def create_endpoint (project_id , location_id , namespace_id , service_id ,
103
114
endpoint_id , address , port ):
104
115
"""Creates a endpoint in the given service."""
@@ -121,8 +132,10 @@ def create_endpoint(project_id, location_id, namespace_id, service_id,
121
132
print (f'Created endpoint { response .name } .' )
122
133
123
134
return response
135
+ # [END servicedirectory_create_endpoint]
124
136
125
137
138
+ # [START servicedirectory_delete_endpoint]
126
139
def delete_endpoint (project_id , location_id , namespace_id , service_id ,
127
140
endpoint_id ):
128
141
"""Deletes a endpoin in the given service."""
@@ -135,3 +148,4 @@ def delete_endpoint(project_id, location_id, namespace_id, service_id,
135
148
client .delete_endpoint (name = endpoint_name )
136
149
137
150
print (f'Deleted endpoint { endpoint_name } .' )
151
+ # [END servicedirectory_delete_endpoint]
0 commit comments