use of org.geotoolkit.ows.xml.v110.Operation in project java-docs-samples by GoogleCloudPlatform.
the class StartInstance method startInstance.
// Starts a stopped Google Compute Engine instance (with unencrypted disks).
public static void startInstance(String project, String zone, String instanceName) throws IOException, ExecutionException, InterruptedException {
/* Initialize client that will be used to send requests. This client only needs to be created
once, and can be reused for multiple requests. After completing all of your requests, call
the `instancesClient.close()` method on the client to safely
clean up any remaining background resources. */
try (InstancesClient instancesClient = InstancesClient.create()) {
// Create the request.
StartInstanceRequest startInstanceRequest = StartInstanceRequest.newBuilder().setProject(project).setZone(zone).setInstance(instanceName).build();
OperationFuture<Operation, Operation> operation = instancesClient.startAsync(startInstanceRequest);
// Wait for the operation to complete.
Operation response = operation.get();
if (response.getStatus() == Status.DONE) {
System.out.println("Instance started successfully ! ");
}
}
}
use of org.geotoolkit.ows.xml.v110.Operation in project java-docs-samples by GoogleCloudPlatform.
the class WaitForOperation method waitForOperation.
// Waits for the specified operation to complete.
public static void waitForOperation(String project, Operation operation) throws IOException {
try (ZoneOperationsClient zoneOperationsClient = ZoneOperationsClient.create()) {
// Check if the operation hasn't been completed already.
if (operation.getStatus() != Status.DONE) {
String zone = operation.getZone();
zone = zone.substring(zone.lastIndexOf("/") + 1);
// Wait for the operation to complete.
Operation response = zoneOperationsClient.wait(project, zone, operation.getName());
// Check if the operation has errors.
if (response.hasError()) {
System.out.println("Error in executing the operation ! ! " + response.getError());
return;
}
System.out.println("Operation Status: " + response.getStatus());
return;
}
System.out.println("Operation Status: " + operation.getStatus());
}
}
use of org.geotoolkit.ows.xml.v110.Operation in project java-docs-samples by GoogleCloudPlatform.
the class CreateTemplateWithSubnet method createTemplateWithSubnet.
// Create an instance template that uses a provided subnet.
public static void createTemplateWithSubnet(String projectId, String network, String subnetwork, String templateName) throws IOException, ExecutionException, InterruptedException {
try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create();
GlobalOperationsClient globalOperationsClient = GlobalOperationsClient.create()) {
AttachedDisk disk = AttachedDisk.newBuilder().setInitializeParams(AttachedDiskInitializeParams.newBuilder().setSourceImage(String.format("projects/%s/global/images/family/%s", "debian-cloud", "debian-11")).setDiskSizeGb(250).build()).setAutoDelete(true).setBoot(true).build();
InstanceProperties instanceProperties = InstanceProperties.newBuilder().addDisks(disk).setMachineType("e2-standard-4").addNetworkInterfaces(NetworkInterface.newBuilder().setNetwork(network).setSubnetwork(subnetwork).build()).build();
InstanceTemplate instanceTemplate = InstanceTemplate.newBuilder().setName(templateName).setProperties(instanceProperties).build();
InsertInstanceTemplateRequest insertInstanceTemplateRequest = InsertInstanceTemplateRequest.newBuilder().setProject(projectId).setInstanceTemplateResource(instanceTemplate).build();
Operation operation = instanceTemplatesClient.insertCallable().futureCall(insertInstanceTemplateRequest).get();
Operation response = globalOperationsClient.wait(projectId, operation.getName());
if (response.hasError()) {
System.out.println("Template creation from subnet failed ! ! " + response);
return;
}
System.out.printf("Template creation from subnet operation status %s: %s", templateName, response.getStatus());
}
}
use of org.geotoolkit.ows.xml.v110.Operation in project java-docs-samples by GoogleCloudPlatform.
the class ResetInstance method resetInstance.
// Resets a running Google Compute Engine instance (with unencrypted disks).
public static void resetInstance(String project, String zone, String instanceName) throws IOException, ExecutionException, InterruptedException {
/* Initialize client that will be used to send requests. This client only needs to be created
once, and can be reused for multiple requests. After completing all of your requests, call
the `instancesClient.close()` method on the client to safely
clean up any remaining background resources. */
try (InstancesClient instancesClient = InstancesClient.create()) {
ResetInstanceRequest resetInstanceRequest = ResetInstanceRequest.newBuilder().setProject(project).setZone(zone).setInstance(instanceName).build();
OperationFuture<Operation, Operation> operation = instancesClient.resetAsync(resetInstanceRequest);
Operation response = operation.get();
if (response.getStatus() == Status.DONE) {
System.out.println("Instance reset successfully ! ");
}
}
}
use of org.geotoolkit.ows.xml.v110.Operation in project geo-platform by geosdi.
the class GPCSWOutputSchemaFinder method retrieveRequestOutputSchemas.
/**
* Retrieve for a Catalog server the OutputSchema supported from Request
* operation. This information in present into GetCapabilities request.
*/
private List<String> retrieveRequestOutputSchemas(GPCatalogConnectorStore serverConnector, String requestType) throws Exception {
List<String> schemas = null;
try {
CatalogGetCapabilitiesRequest<CapabilitiesType> request = serverConnector.createGetCapabilitiesRequest();
CapabilitiesType response = request.getResponse();
List<Operation> operationList = response.getOperationsMetadata().getOperation();
for (Operation operation : operationList) {
if (requestType.equals(operation.getName())) {
List<DomainType> parameterList = operation.getParameter();
schemas = new ArrayList<>(parameterList.size());
for (DomainType parameter : parameterList) {
if ("outputSchema".equals(parameter.getName())) {
for (String outputSchemaValue : parameter.getValue()) {
logger.trace("\n*** outputSchema available: {}", outputSchemaValue);
schemas.add(outputSchemaValue.trim());
}
break;
}
}
break;
}
}
} catch (IOException ex) {
logger.error("### IOException: {}", ex.getMessage());
throw new IllegalParameterFault("Error on parse response stream");
}
return schemas;
}
Aggregations