Search in sources :

Example 16 with Operation

use of com.google.cloud.compute.v1.Operation in project java-docs-samples by GoogleCloudPlatform.

the class SnippetsIT method createImage.

private static Image createImage(Disk srcDisk) throws IOException, InterruptedException, ExecutionException {
    try (ImagesClient imagesClient = ImagesClient.create()) {
        Image image = Image.newBuilder().setName("test-img-" + UUID.randomUUID()).setSourceDisk(srcDisk.getSelfLink()).build();
        OperationFuture<Operation, Operation> operation = imagesClient.insertAsync(PROJECT_ID, image);
        operation.get();
        return imagesClient.get(PROJECT_ID, image.getName());
    }
}
Also used : Operation(com.google.cloud.compute.v1.Operation) ImagesClient(com.google.cloud.compute.v1.ImagesClient) Image(com.google.cloud.compute.v1.Image)

Example 17 with Operation

use of com.google.cloud.compute.v1.Operation in project java-docs-samples by GoogleCloudPlatform.

the class SnippetsIT method createSourceDisk.

private static Disk createSourceDisk() throws IOException, ExecutionException, InterruptedException {
    try (DisksClient disksClient = DisksClient.create()) {
        Disk disk = Disk.newBuilder().setSourceImage(getActiveDebian().getSelfLink()).setName("test-disk-" + UUID.randomUUID()).build();
        OperationFuture<Operation, Operation> operation = disksClient.insertAsync(PROJECT_ID, ZONE, disk);
        // Wait for the operation to complete.
        operation.get();
        return disksClient.get(PROJECT_ID, ZONE, disk.getName());
    }
}
Also used : Operation(com.google.cloud.compute.v1.Operation) Disk(com.google.cloud.compute.v1.Disk) DisksClient(com.google.cloud.compute.v1.DisksClient)

Example 18 with Operation

use of com.google.cloud.compute.v1.Operation in project java-docs-samples by GoogleCloudPlatform.

the class SnippetsIT method deleteDisk.

private static void deleteDisk(Disk disk) throws IOException, InterruptedException, ExecutionException {
    try (DisksClient disksClient = DisksClient.create()) {
        OperationFuture<Operation, Operation> operation = disksClient.deleteAsync(PROJECT_ID, ZONE, disk.getName());
        operation.get();
    }
}
Also used : Operation(com.google.cloud.compute.v1.Operation) DisksClient(com.google.cloud.compute.v1.DisksClient)

Example 19 with Operation

use of com.google.cloud.compute.v1.Operation in project ddf by codice.

the class CswEndpoint method buildOperationsMetadata.

/**
 * Creates the OperationsMetadata portion of the GetCapabilities response TODO: As these
 * operations are implemented or added, update their descriptions to ensure they match up with the
 * functionality
 *
 * @return The constructed OperationsMetadata object
 */
private OperationsMetadata buildOperationsMetadata() {
    List<String> typeNames = getTypeNames();
    OperationsMetadata om = new OperationsMetadata();
    List<QName> getAndPost = Arrays.asList(CswConstants.GET, CswConstants.POST);
    Set<String> schemasSet = new HashSet<>(schemaTransformerManager.getAvailableSchemas());
    List<String> availableSchemas = new ArrayList<>(schemasSet);
    // Builds GetCapabilities operation metadata
    Operation getCapabilitiesOp = buildOperation(CswConstants.GET_CAPABILITIES, getAndPost);
    addOperationParameter("sections", GET_CAPABILITIES_PARAMS, getCapabilitiesOp);
    // Builds DescribeRecord operation metadata
    Operation describeRecordOp = buildOperation(CswConstants.DESCRIBE_RECORD, getAndPost);
    addOperationParameter(CswConstants.TYPE_NAME_PARAMETER, typeNames, describeRecordOp);
    Set<String> mimeTypeSet = new HashSet<>();
    mimeTypeSet.add(DEFAULT_OUTPUT_FORMAT);
    mimeTypeSet.addAll(mimeTypeTransformerManager.getAvailableMimeTypes());
    List<String> mimeTypes = new ArrayList<>(mimeTypeSet);
    addOperationParameter(CswConstants.OUTPUT_FORMAT_PARAMETER, mimeTypes, describeRecordOp);
    addOperationParameter("schemaLanguage", CswConstants.VALID_SCHEMA_LANGUAGES, describeRecordOp);
    // Builds GetRecords operation metadata
    Operation getRecordsOp = buildOperation(CswConstants.GET_RECORDS, getAndPost);
    addOperationParameter(CswConstants.RESULT_TYPE_PARAMETER, Arrays.asList("hits", "results", "validate"), getRecordsOp);
    addOperationParameter(CswConstants.OUTPUT_FORMAT_PARAMETER, mimeTypes, getRecordsOp);
    addOperationParameter(CswConstants.OUTPUT_SCHEMA_PARAMETER, availableSchemas, getRecordsOp);
    addOperationParameter(CswConstants.TYPE_NAMES_PARAMETER, typeNames, getRecordsOp);
    addOperationParameter(CswConstants.CONSTRAINT_LANGUAGE_PARAMETER, CswConstants.CONSTRAINT_LANGUAGES, getRecordsOp);
    addFederatedCatalogs(getRecordsOp);
    // Builds GetRecordById operation metadata
    mimeTypes.add(MediaType.APPLICATION_OCTET_STREAM);
    List<String> supportedSchemas = new ArrayList<>(availableSchemas);
    supportedSchemas.add(OCTET_STREAM_OUTPUT_SCHEMA);
    Operation getRecordByIdOp = buildOperation(CswConstants.GET_RECORD_BY_ID, getAndPost);
    addOperationParameter(CswConstants.OUTPUT_SCHEMA_PARAMETER, supportedSchemas, getRecordByIdOp);
    addOperationParameter(CswConstants.OUTPUT_FORMAT_PARAMETER, mimeTypes, getRecordByIdOp);
    addOperationParameter(CswConstants.RESULT_TYPE_PARAMETER, Arrays.asList("hits", "results", "validate"), getRecordByIdOp);
    addOperationParameter(CswConstants.ELEMENT_SET_NAME_PARAMETER, ELEMENT_NAMES, getRecordByIdOp);
    // Builds Transactions operation metadata
    Operation transactionOp = buildOperation(CswConstants.TRANSACTION, Collections.singletonList(CswConstants.POST));
    addOperationParameter(CswConstants.TYPE_NAMES_PARAMETER, inputTransformerManager.getAvailableIds(), transactionOp);
    addOperationParameter(CswConstants.CONSTRAINT_LANGUAGE_PARAMETER, CswConstants.CONSTRAINT_LANGUAGES, transactionOp);
    List<Operation> ops = Arrays.asList(getCapabilitiesOp, describeRecordOp, getRecordsOp, getRecordByIdOp, transactionOp);
    om.setOperation(ops);
    om.getParameter().add(createDomainType(CswConstants.SERVICE, CswConstants.CSW));
    om.getParameter().add(createDomainType(CswConstants.VERSION, CswConstants.VERSION_2_0_2));
    return om;
}
Also used : OperationsMetadata(net.opengis.ows.v_1_0_0.OperationsMetadata) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Operation(net.opengis.ows.v_1_0_0.Operation) HashSet(java.util.HashSet)

Example 20 with Operation

use of com.google.cloud.compute.v1.Operation in project ddf by codice.

the class CswEndpointTest method verifyOperationsMetadata.

/**
 * Helper method to verify the OperationsMetadata section matches the endpoint's definition
 *
 * @param ct The CapabilitiesType to verify
 */
private void verifyOperationsMetadata(CapabilitiesType ct) {
    OperationsMetadata om = ct.getOperationsMetadata();
    List<Operation> opList = om.getOperation();
    ArrayList<String> opNames = new ArrayList<>();
    for (Operation op : opList) {
        opNames.add(op.getName());
        if (StringUtils.equals(CswConstants.TRANSACTION, op.getName()) || StringUtils.equals(CswConstants.GET_RECORDS, op.getName())) {
            for (DomainType parameter : op.getParameter()) {
                if (StringUtils.equals(CswConstants.CONSTRAINT_LANGUAGE_PARAMETER, parameter.getName())) {
                    assertThat(parameter.getValue(), contains(CswConstants.CONSTRAINT_LANGUAGE_FILTER, CswConstants.CONSTRAINT_LANGUAGE_CQL));
                } else if (StringUtils.equals(CswConstants.TYPE_NAMES_PARAMETER, parameter.getName())) {
                    if (StringUtils.equals(op.getName(), CswConstants.TRANSACTION)) {
                        assertThat(parameter.getValue(), contains(CswConstants.CSW_RECORD));
                    } else {
                        assertThat(parameter.getValue(), hasItems(CswConstants.CSW_RECORD, THIRD_PARTY_TYPE_NAME));
                    }
                }
            }
        }
    }
    assertThat(opNames.contains(CswConstants.GET_CAPABILITIES), is(true));
    assertThat(opNames.contains(CswConstants.DESCRIBE_RECORD), is(true));
    assertThat(opNames.contains(CswConstants.GET_RECORDS), is(true));
    assertThat(opNames.contains(CswConstants.GET_RECORD_BY_ID), is(true));
    assertThat(opNames.contains(CswConstants.TRANSACTION), is(true));
}
Also used : OperationsMetadata(net.opengis.ows.v_1_0_0.OperationsMetadata) DomainType(net.opengis.ows.v_1_0_0.DomainType) ArrayList(java.util.ArrayList) Operation(net.opengis.ows.v_1_0_0.Operation) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString)

Aggregations

ArrayList (java.util.ArrayList)81 Test (org.junit.Test)79 AbstractMessage (com.google.protobuf.AbstractMessage)65 Operation (com.google.cloud.compute.v1.Operation)49 Operation (com.google.container.v1.Operation)43 StatusCondition (com.google.container.v1.StatusCondition)40 Operation (com.google.container.v1beta1.Operation)24 StatusCondition (com.google.container.v1beta1.StatusCondition)23 InstancesClient (com.google.cloud.compute.v1.InstancesClient)20 Operation (com.reprezen.kaizen.oasparser.model3.Operation)16 Path (com.reprezen.kaizen.oasparser.model3.Path)15 Operation (net.opengis.ows.v_1_0_0.Operation)15 Instance (com.google.cloud.compute.v1.Instance)13 Parameter (com.reprezen.kaizen.oasparser.model3.Parameter)13 DomainType (net.opengis.ows.v_1_0_0.DomainType)13 AttachedDisk (com.google.cloud.compute.v1.AttachedDisk)12 InsertInstanceRequest (com.google.cloud.compute.v1.InsertInstanceRequest)11 Operation (org.osate.aadl2.Operation)8 NetworkInterface (com.google.cloud.compute.v1.NetworkInterface)7 BooleanLiteral (org.osate.aadl2.BooleanLiteral)7