Search in sources :

Example 6 with RegistrationServiceClient

use of com.google.cloud.servicedirectory.v1.RegistrationServiceClient in project java-servicedirectory by googleapis.

the class NamespacesTests method tearDown.

@After
public void tearDown() throws Exception {
    System.setOut(null);
    bout.reset();
    // Deletes any namespaces created during these tests.
    try (RegistrationServiceClient client = RegistrationServiceClient.create()) {
        // List the namespaces.
        String locationPath = LocationName.format(PROJECT_ID, LOCATION_ID);
        ListNamespacesPagedResponse response = client.listNamespaces(locationPath);
        // Delete each namespace.
        for (Namespace ns : response.iterateAll()) {
            client.deleteNamespace(ns.getName());
        }
    }
}
Also used : Namespace(com.google.cloud.servicedirectory.v1.Namespace) RegistrationServiceClient(com.google.cloud.servicedirectory.v1.RegistrationServiceClient) ListNamespacesPagedResponse(com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListNamespacesPagedResponse) After(org.junit.After)

Example 7 with RegistrationServiceClient

use of com.google.cloud.servicedirectory.v1.RegistrationServiceClient in project java-servicedirectory by googleapis.

the class NamespacesCreate method createNamespace.

// Create a new namespace.
public static void createNamespace(String projectId, String locationId, String namespaceId) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (RegistrationServiceClient client = RegistrationServiceClient.create()) {
        // The project and location to create the namespace in.
        LocationName parent = LocationName.of(projectId, locationId);
        // The namespace object to create. Here, we use the default instance.
        Namespace namespace = Namespace.newBuilder().build();
        // Send the request to create the namespace.
        Namespace createdNamespace = client.createNamespace(parent, namespace, namespaceId);
        // Process the response.
        System.out.println("Created Namespace: " + createdNamespace.getName());
    }
}
Also used : Namespace(com.google.cloud.servicedirectory.v1.Namespace) RegistrationServiceClient(com.google.cloud.servicedirectory.v1.RegistrationServiceClient) LocationName(com.google.cloud.servicedirectory.v1.LocationName)

Example 8 with RegistrationServiceClient

use of com.google.cloud.servicedirectory.v1.RegistrationServiceClient in project java-servicedirectory by googleapis.

the class ServicesDelete method deleteService.

// Delete a service.
public static void deleteService(String projectId, String locationId, String namespaceId, String serviceId) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (RegistrationServiceClient client = RegistrationServiceClient.create()) {
        // The service to delete.
        ServiceName serviceName = ServiceName.of(projectId, locationId, namespaceId, serviceId);
        // Send the request to delete the service.
        client.deleteService(serviceName);
        // Log the action.
        System.out.println("Deleted Service: " + serviceName.toString());
    }
}
Also used : ServiceName(com.google.cloud.servicedirectory.v1.ServiceName) RegistrationServiceClient(com.google.cloud.servicedirectory.v1.RegistrationServiceClient)

Example 9 with RegistrationServiceClient

use of com.google.cloud.servicedirectory.v1.RegistrationServiceClient in project java-servicedirectory by googleapis.

the class EndpointsTests method tearDown.

@After
public void tearDown() throws Exception {
    System.setOut(null);
    bout.reset();
    // Deletes all resources created during these tests.
    try (RegistrationServiceClient client = RegistrationServiceClient.create()) {
        // List the namespaces.
        String locationPath = LocationName.format(PROJECT_ID, LOCATION_ID);
        ListNamespacesPagedResponse response = client.listNamespaces(locationPath);
        // Delete each namespace.
        for (Namespace namespace : response.iterateAll()) {
            client.deleteNamespace(namespace.getName());
        }
    }
}
Also used : Namespace(com.google.cloud.servicedirectory.v1.Namespace) RegistrationServiceClient(com.google.cloud.servicedirectory.v1.RegistrationServiceClient) ListNamespacesPagedResponse(com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListNamespacesPagedResponse) After(org.junit.After)

Example 10 with RegistrationServiceClient

use of com.google.cloud.servicedirectory.v1.RegistrationServiceClient in project java-servicedirectory by googleapis.

the class ServicesTests method tearDown.

@After
public void tearDown() throws Exception {
    System.setOut(null);
    bout.reset();
    // Deletes all resources created during these tests.
    try (RegistrationServiceClient client = RegistrationServiceClient.create()) {
        // List the namespaces.
        String locationPath = LocationName.format(PROJECT_ID, LOCATION_ID);
        ListNamespacesPagedResponse response = client.listNamespaces(locationPath);
        // Delete each namespace.
        for (Namespace namespace : response.iterateAll()) {
            client.deleteNamespace(namespace.getName());
        }
    }
}
Also used : Namespace(com.google.cloud.servicedirectory.v1.Namespace) RegistrationServiceClient(com.google.cloud.servicedirectory.v1.RegistrationServiceClient) ListNamespacesPagedResponse(com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListNamespacesPagedResponse) After(org.junit.After)

Aggregations

RegistrationServiceClient (com.google.cloud.servicedirectory.v1.RegistrationServiceClient)10 Namespace (com.google.cloud.servicedirectory.v1.Namespace)5 ListNamespacesPagedResponse (com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListNamespacesPagedResponse)4 After (org.junit.After)3 LocationName (com.google.cloud.servicedirectory.v1.LocationName)2 NamespaceName (com.google.cloud.servicedirectory.v1.NamespaceName)2 ServiceName (com.google.cloud.servicedirectory.v1.ServiceName)2 Endpoint (com.google.cloud.servicedirectory.v1.Endpoint)1 EndpointName (com.google.cloud.servicedirectory.v1.EndpointName)1 Service (com.google.cloud.servicedirectory.v1.Service)1