Search in sources :

Example 31 with Operation

use of com.google.container.v1beta1.Operation in project ets-ogcapi-edr10 by opengeospatial.

the class CollectionsTime method resolutionzParameterDefinition.

/**
 * <pre>
 * Requirement A.30: /req/edr/resolution-z-definition Parameter resolution-z definition
 * </pre>
 * NOTE: Not referenced by ATS
 *
 * @param testPoint the testPoint under test, never <code>null</code>
 * @param model api definition, never <code>null</code>
 */
public void resolutionzParameterDefinition(TestPoint testPoint, OpenApi3 model) {
    Parameter resolutionz = null;
    String paramName = "resolution-z";
    for (Path path : model.getPaths().values()) {
        if (testPoint.getPath().equals(path.getPathString())) {
            for (Operation op : path.getOperations().values()) {
                for (Parameter param : op.getParameters()) {
                    if (hasName(param)) {
                        if (param.getName().equals(paramName)) {
                            resolutionz = param;
                        }
                    }
                }
            }
        }
    }
    if (resolutionz != null) {
        String msg = "Expected property '%s' with value '%s' but was '%s'";
        assertEquals(resolutionz.getName(), paramName, String.format(msg, "name", paramName, resolutionz.getName()));
        assertEquals(resolutionz.getIn(), "query", String.format(msg, "in", "query", resolutionz.getIn()));
        assertFalse(isRequired(resolutionz), String.format(msg, "required", "false", resolutionz.getRequired()));
        assertEquals(resolutionz.getStyle(), "form", String.format(msg, "style", "form", resolutionz.getStyle()));
        assertFalse(isExplode(resolutionz), String.format(msg, "explode", "false", resolutionz.getExplode()));
    }
}
Also used : Path(com.reprezen.kaizen.oasparser.model3.Path) Parameter(com.reprezen.kaizen.oasparser.model3.Parameter) Operation(com.reprezen.kaizen.oasparser.model3.Operation)

Example 32 with Operation

use of com.google.container.v1beta1.Operation in project oracle-db-examples by oracle-samples.

the class MultiOperation method processChildRowOperation.

/**
 * Process next resultset. Get the child operation from the queue (if any submitted) and pass
 * the resultset to it for the processing. If no child operation in the queue then process resultset
 * with the help of user supplied row handler or the default one. Wait for the child operation or
 * the handler to process all rows of a resultset.
 *
 * @return the completion stage of the child operation.
 * @throws SQLException
 */
private CompletionStage<T> processChildRowOperation() throws SQLException {
    // Get the result set
    ResultSet resultSet = jdbcStatement.getResultSet();
    // Remove child operation, if any exist
    Operation operationFromQueue = resultOperations.poll();
    // Keep as effective final, because it uses in lambda expression
    Operation operation;
    boolean onRowsHandler = (operationFromQueue == null);
    if (onRowsHandler) {
        // Handle using onRows handler.
        operation = new MultiRowOperation<T>(session, group, true);
    } else
        operation = operationFromQueue;
    if (!(operation instanceof ChildRowOperation)) {
        // Throw invalid state
        throw new IllegalStateException("TODO");
    }
    // Trigger child operation to process the resultset
    resultStage = ((ChildRowOperation) operation).setResultSet(resultSet, resultStage);
    if (onRowsHandler)
        resultStage = resultStage.thenRun(() -> rowsHandler.accept(resultNum, (RowOperation<T>) operation));
    // Then again move to moreResult stage to process next resultset.
    return resultStage.thenComposeAsync(((ChildRowOperation) operation)::resultProcessed, getExecutor()).thenComposeAsync(this::checkForMoreResults, getExecutor());
}
Also used : ResultSet(java.sql.ResultSet) RowOperation(jdk.incubator.sql2.RowOperation) RowPublisherOperation(jdk.incubator.sql2.RowPublisherOperation) Operation(jdk.incubator.sql2.Operation) RowCountOperation(jdk.incubator.sql2.RowCountOperation) RowOperation(jdk.incubator.sql2.RowOperation)

Example 33 with Operation

use of com.google.container.v1beta1.Operation in project oracle-db-examples by oracle-samples.

the class MultiOperation method processChildRowCountOperation.

/**
 * Process next update count. Get the child operation from the queue (if any submitted) and pass
 * the update count to it for the processing. If no child operation in the queue then process update count
 * with the help of user supplied rowcount handler or the default one. Wait for the child operation or
 * the handler to process the update count.
 *
 * @param updateCount
 * @return the completion stage of the child operation.
 */
private CompletionStage<T> processChildRowCountOperation(long updateCount) {
    // Remove child operation, if any exist
    Operation operationFromQueue = resultOperations.poll();
    // Keep as effective final, because it uses in lambda expression
    Operation operation;
    boolean onCountHandler = (operationFromQueue == null);
    if (onCountHandler) {
        // Handle using onCount handler
        operation = new MultiRowCountOperation<T>(session, group, true);
    } else
        operation = operationFromQueue;
    if (!(operation instanceof ChildRowCountOperation)) {
        // Throw invalid state
        throw new IllegalStateException("TODO");
    }
    resultStage = ((ChildRowCountOperation) operation).setRowCount(updateCount, resultStage);
    if (onCountHandler)
        resultStage = resultStage.thenRun(() -> countHandler.accept(resultNum, (RowCountOperation<T>) operation));
    return resultStage.thenComposeAsync(((ChildRowCountOperation) operation)::resultCountProcessed, getExecutor()).thenComposeAsync(this::checkForMoreResults, getExecutor());
}
Also used : RowCountOperation(jdk.incubator.sql2.RowCountOperation) RowOperation(jdk.incubator.sql2.RowOperation) RowPublisherOperation(jdk.incubator.sql2.RowPublisherOperation) Operation(jdk.incubator.sql2.Operation) RowCountOperation(jdk.incubator.sql2.RowCountOperation)

Example 34 with Operation

use of com.google.container.v1beta1.Operation in project java-docs-samples by GoogleCloudPlatform.

the class PreemptibleIT method testListZoneOperations.

@Test
public void testListZoneOperations() throws IOException {
    String filter = String.format("targetLink=\"https://www.googleapis.com/compute/v1/projects/%s/zones/%s/instances/%s\"", PROJECT_ID, ZONE, INSTANCE_NAME);
    ListPagedResponse response = ListZoneOperations.listZoneOperations(PROJECT_ID, ZONE, filter);
    boolean elementPresent = false;
    for (Operation operation : response.iterateAll()) {
        elementPresent = true;
        break;
    }
    assertWithMessage("There should be at least one operation for this instance at this point.").that(elementPresent).isTrue();
}
Also used : ListPagedResponse(com.google.cloud.compute.v1.ZoneOperationsClient.ListPagedResponse) Operation(com.google.cloud.compute.v1.Operation) Test(org.junit.jupiter.api.Test)

Example 35 with Operation

use of com.google.container.v1beta1.Operation in project java-docs-samples by GoogleCloudPlatform.

the class WindowsOsImageIT method setup.

@BeforeAll
public static void setup() throws IOException, ExecutionException, InterruptedException, TimeoutException {
    final PrintStream out = System.out;
    ByteArrayOutputStream stdOut = new ByteArrayOutputStream();
    System.setOut(new PrintStream(stdOut));
    requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
    requireEnvVar("GOOGLE_CLOUD_PROJECT");
    // Cleanup existing test instances.
    Util.cleanUpExistingInstances("windowsimage-test-instance-", PROJECT_ID, ZONE);
    String randomUUID = UUID.randomUUID().toString().split("-")[0];
    INSTANCE_NAME = "windowsimage-test-instance-" + randomUUID;
    DISK_NAME = "windowsimage-test-disk-" + randomUUID;
    IMAGE_NAME = "windowsimage-test-image-" + randomUUID;
    // Create Instance with Windows source image.
    try (InstancesClient instancesClient = InstancesClient.create()) {
        AttachedDisk attachedDisk = AttachedDisk.newBuilder().setDeviceName(DISK_NAME).setAutoDelete(true).setBoot(true).setType(AttachedDisk.Type.PERSISTENT.name()).setInitializeParams(AttachedDiskInitializeParams.newBuilder().setDiskName(DISK_NAME).setDiskSizeGb(64).setSourceImage("projects/windows-cloud/global/images/windows-server-2012-r2-dc-core-v20220314").build()).build();
        Instance instance = Instance.newBuilder().setName(INSTANCE_NAME).setMachineType(String.format("zones/%s/machineTypes/n1-standard-1", ZONE)).addNetworkInterfaces(NetworkInterface.newBuilder().setName("global/networks/default").build()).addDisks(attachedDisk).build();
        InsertInstanceRequest request = InsertInstanceRequest.newBuilder().setProject(PROJECT_ID).setZone(ZONE).setInstanceResource(instance).build();
        Operation response = instancesClient.insertAsync(request).get();
        Assert.assertFalse(response.hasError());
    }
    stdOut.close();
    System.setOut(out);
}
Also used : InsertInstanceRequest(com.google.cloud.compute.v1.InsertInstanceRequest) PrintStream(java.io.PrintStream) Instance(com.google.cloud.compute.v1.Instance) DeleteInstance(compute.DeleteInstance) InstancesClient(com.google.cloud.compute.v1.InstancesClient) AttachedDisk(com.google.cloud.compute.v1.AttachedDisk) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Operation(com.google.cloud.compute.v1.Operation) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

ArrayList (java.util.ArrayList)81 Test (org.junit.Test)75 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