Search in sources :

Example 6 with Operation

use of com.google.api.services.compute.model.Operation in project platformlayer by platformlayer.

the class GoogleComputeClient method createFirewallRule.

public void createFirewallRule(Firewall rule) throws OpsException {
    try {
        log.debug("Inserting firewall rule: " + rule);
        Operation operation = compute.firewalls().insert(projectId, rule).execute();
        waitComplete(operation, 5, TimeUnit.MINUTES);
    // TODO: Check success of operation?
    } catch (IOException e) {
        throw new OpsException("Error creating firewall", e);
    } catch (TimeoutException e) {
        throw new OpsException("Timeout while waiting for firewall creation", e);
    }
}
Also used : OpsException(org.platformlayer.ops.OpsException) Operation(com.google.api.services.compute.model.Operation) IOException(java.io.IOException) TimeoutException(java.util.concurrent.TimeoutException)

Example 7 with Operation

use of com.google.api.services.compute.model.Operation in project google-cloud-java by GoogleCloudPlatform.

the class HttpComputeRpc method listGlobalOperations.

@Override
public Tuple<String, Iterable<Operation>> listGlobalOperations(Map<Option, ?> options) {
    try {
        OperationList operationsList = compute.globalOperations().list(this.options.getProjectId()).setFilter(Option.FILTER.getString(options)).setMaxResults(Option.MAX_RESULTS.getLong(options)).setPageToken(Option.PAGE_TOKEN.getString(options)).setFields(Option.FIELDS.getString(options)).execute();
        Iterable<Operation> operations = operationsList.getItems();
        return Tuple.of(operationsList.getNextPageToken(), operations);
    } catch (IOException ex) {
        throw translate(ex);
    }
}
Also used : OperationList(com.google.api.services.compute.model.OperationList) Operation(com.google.api.services.compute.model.Operation) IOException(java.io.IOException)

Example 8 with Operation

use of com.google.api.services.compute.model.Operation in project google-cloud-java by GoogleCloudPlatform.

the class HttpComputeRpc method listRegionOperations.

@Override
public Tuple<String, Iterable<Operation>> listRegionOperations(String region, Map<Option, ?> options) {
    try {
        OperationList operationsList = compute.regionOperations().list(this.options.getProjectId(), region).setFilter(Option.FILTER.getString(options)).setMaxResults(Option.MAX_RESULTS.getLong(options)).setPageToken(Option.PAGE_TOKEN.getString(options)).setFields(Option.FIELDS.getString(options)).execute();
        Iterable<Operation> operations = operationsList.getItems();
        return Tuple.of(operationsList.getNextPageToken(), operations);
    } catch (IOException ex) {
        throw translate(ex);
    }
}
Also used : OperationList(com.google.api.services.compute.model.OperationList) Operation(com.google.api.services.compute.model.Operation) IOException(java.io.IOException)

Example 9 with Operation

use of com.google.api.services.compute.model.Operation in project google-cloud-java by GoogleCloudPlatform.

the class HttpComputeRpc method listZoneOperations.

@Override
public Tuple<String, Iterable<Operation>> listZoneOperations(String zone, Map<Option, ?> options) {
    try {
        OperationList operationsList = compute.zoneOperations().list(this.options.getProjectId(), zone).setFilter(Option.FILTER.getString(options)).setMaxResults(Option.MAX_RESULTS.getLong(options)).setPageToken(Option.PAGE_TOKEN.getString(options)).setFields(Option.FIELDS.getString(options)).execute();
        Iterable<Operation> operations = operationsList.getItems();
        return Tuple.of(operationsList.getNextPageToken(), operations);
    } catch (IOException ex) {
        throw translate(ex);
    }
}
Also used : OperationList(com.google.api.services.compute.model.OperationList) Operation(com.google.api.services.compute.model.Operation) IOException(java.io.IOException)

Aggregations

Operation (com.google.api.services.compute.model.Operation)9 IOException (java.io.IOException)7 OpsException (org.platformlayer.ops.OpsException)6 TimeoutException (java.util.concurrent.TimeoutException)5 OperationList (com.google.api.services.compute.model.OperationList)3 Instance (com.google.api.services.compute.model.Instance)2 Tag (org.platformlayer.core.model.Tag)2 AccessConfig (com.google.api.services.compute.model.AccessConfig)1 Image (com.google.api.services.compute.model.Image)1 MachineType (com.google.api.services.compute.model.MachineType)1 Metadata (com.google.api.services.compute.model.Metadata)1 Items (com.google.api.services.compute.model.Metadata.Items)1 NetworkInterface (com.google.api.services.compute.model.NetworkInterface)1 PublicKey (java.security.PublicKey)1 Set (java.util.Set)1 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)1 Tags (org.platformlayer.core.model.Tags)1 DiskImageRecipe (org.platformlayer.images.model.DiskImageRecipe)1 OperatingSystemRecipe (org.platformlayer.images.model.OperatingSystemRecipe)1 Handler (org.platformlayer.ops.Handler)1