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());
}
}
}
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());
}
}
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());
}
}
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());
}
}
}
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());
}
}
}
Aggregations