use of com.reprezen.kaizen.oasparser.model3.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());
}
}
use of com.reprezen.kaizen.oasparser.model3.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();
}
}
use of com.reprezen.kaizen.oasparser.model3.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;
}
use of com.reprezen.kaizen.oasparser.model3.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));
}
use of com.reprezen.kaizen.oasparser.model3.Operation in project ddf by codice.
the class CswEndpointTest method testCapabilitiesFederatedCatalogs.
@Test
public void testCapabilitiesFederatedCatalogs() {
GetCapabilitiesRequest gcr = createDefaultGetCapabilitiesRequest();
CapabilitiesType ct = null;
try {
ct = csw.getCapabilities(gcr);
} catch (CswException e) {
fail("CswException caught during getCapabilities GET request: " + e.getMessage());
}
assertThat(ct, notNullValue());
assertThat(ct.getOperationsMetadata(), notNullValue());
for (Operation operation : ct.getOperationsMetadata().getOperation()) {
if (StringUtils.equals(operation.getName(), CswConstants.GET_RECORDS)) {
for (DomainType constraint : operation.getConstraint()) {
if (StringUtils.equals(constraint.getName(), CswConstants.FEDERATED_CATALOGS)) {
assertThat(constraint.getValue().size(), is(3));
return;
}
}
}
}
fail("Didn't find [" + CswConstants.FEDERATED_CATALOGS + "] in request [" + CswConstants.GET_RECORDS + "]");
}
Aggregations