Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update service directory python samples to v1 #5230

Merged
merged 6 commits into from Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions servicedirectory/quickstart.py
Expand Up @@ -15,13 +15,13 @@
# limitations under the License.

# [START servicedirectory_quickstart]
from google.cloud import servicedirectory_v1beta1
from google.cloud import servicedirectory_v1


def list_namespaces(project_id, location_id):
"""Lists all namespaces in the given location."""

client = servicedirectory_v1beta1.RegistrationServiceClient()
client = servicedirectory_v1.RegistrationServiceClient()

response = client.list_namespaces(
parent=f'projects/{project_id}/locations/{location_id}')
Expand Down
6 changes: 3 additions & 3 deletions servicedirectory/quickstart_test.py
Expand Up @@ -17,7 +17,7 @@
from os import environ
import uuid

from google.cloud import servicedirectory_v1beta1
from google.cloud import servicedirectory_v1

import pytest

Expand All @@ -30,12 +30,12 @@

@pytest.fixture(scope='module')
def client():
return servicedirectory_v1beta1.RegistrationServiceClient()
return servicedirectory_v1.RegistrationServiceClient()


@pytest.fixture(scope='module')
def namespace(client):
namespace = servicedirectory_v1beta1.Namespace(
namespace = servicedirectory_v1.Namespace(
name=client.namespace_path(PROJECT_ID, LOCATION_ID, NAMESPACE_ID))

client.create_namespace(
Expand Down
26 changes: 13 additions & 13 deletions servicedirectory/snippets.py
Expand Up @@ -14,16 +14,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from google.cloud import servicedirectory_v1beta1
from google.cloud import servicedirectory_v1


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

client = servicedirectory_v1beta1.RegistrationServiceClient()
client = servicedirectory_v1.RegistrationServiceClient()

namespace = servicedirectory_v1beta1.Namespace(
namespace = servicedirectory_v1.Namespace(
name=client.namespace_path(project_id, location_id, namespace_id))

response = client.create_namespace(
Expand All @@ -42,7 +42,7 @@ def create_namespace(project_id, location_id, namespace_id):
def delete_namespace(project_id, location_id, namespace_id):
"""Deletes a namespace in the given location."""

client = servicedirectory_v1beta1.RegistrationServiceClient()
client = servicedirectory_v1.RegistrationServiceClient()

namespace_name = client.namespace_path(project_id, location_id, namespace_id)

Expand All @@ -56,9 +56,9 @@ def delete_namespace(project_id, location_id, namespace_id):
def create_service(project_id, location_id, namespace_id, service_id):
"""Creates a service in the given namespace."""

client = servicedirectory_v1beta1.RegistrationServiceClient()
client = servicedirectory_v1.RegistrationServiceClient()

service = servicedirectory_v1beta1.Service(
service = servicedirectory_v1.Service(
name=client.service_path(project_id, location_id, namespace_id,
service_id))

Expand All @@ -78,7 +78,7 @@ def create_service(project_id, location_id, namespace_id, service_id):
def delete_service(project_id, location_id, namespace_id, service_id):
"""Deletes a service in the given namespace."""

client = servicedirectory_v1beta1.RegistrationServiceClient()
client = servicedirectory_v1.RegistrationServiceClient()

service_name = client.service_path(project_id, location_id, namespace_id,
service_id)
Expand All @@ -93,10 +93,10 @@ def delete_service(project_id, location_id, namespace_id, service_id):
def resolve_service(project_id, location_id, namespace_id, service_id):
"""Resolves a service in the given namespace."""

client = servicedirectory_v1beta1.LookupServiceClient()
client = servicedirectory_v1.LookupServiceClient()

request = servicedirectory_v1beta1.ResolveServiceRequest(
name=servicedirectory_v1beta1.RegistrationServiceClient().service_path(
request = servicedirectory_v1.ResolveServiceRequest(
name=servicedirectory_v1.RegistrationServiceClient().service_path(
project_id, location_id, namespace_id, service_id))

response = client.resolve_service(request=request)
Expand All @@ -114,9 +114,9 @@ def create_endpoint(project_id, location_id, namespace_id, service_id,
endpoint_id, address, port):
"""Creates a endpoint in the given service."""

client = servicedirectory_v1beta1.RegistrationServiceClient()
client = servicedirectory_v1.RegistrationServiceClient()

endpoint = servicedirectory_v1beta1.Endpoint(
endpoint = servicedirectory_v1.Endpoint(
name=client.endpoint_path(project_id, location_id, namespace_id,
service_id, endpoint_id),
address=address,
Expand All @@ -140,7 +140,7 @@ def delete_endpoint(project_id, location_id, namespace_id, service_id,
endpoint_id):
"""Deletes a endpoin in the given service."""

client = servicedirectory_v1beta1.RegistrationServiceClient()
client = servicedirectory_v1.RegistrationServiceClient()

endpoint_name = client.endpoint_path(project_id, location_id, namespace_id,
service_id, endpoint_id)
Expand Down
4 changes: 2 additions & 2 deletions servicedirectory/snippets_test.py
Expand Up @@ -18,7 +18,7 @@
import uuid

from google.api_core import exceptions
from google.cloud import servicedirectory_v1beta1
from google.cloud import servicedirectory_v1

import snippets

Expand All @@ -32,7 +32,7 @@


def teardown_module():
client = servicedirectory_v1beta1.RegistrationServiceClient()
client = servicedirectory_v1.RegistrationServiceClient()
namespace_name = client.namespace_path(PROJECT_ID, LOCATION_ID, NAMESPACE_ID)
try:
namespace = client.get_namespace(name=namespace_name)
Expand Down