All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl.topicus.jdbc.shaded.com.google.longrunning.stub.GrpcOperationsStub Maven / Gradle / Ivy

There is a newer version: 1.1.6
Show newest version
/*
 * Copyright 2017, Google Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 *     * Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 * copyright notice, this list of conditions and the following disclaimer
 * in the documentation and/or other materials provided with the
 * distribution.
 *     * Neither the name of Google Inc. nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package nl.topicus.jdbc.shaded.com.google.longrunning.stub;

import static nl.topicus.jdbc.shaded.com.google.longrunning.PagedResponseWrappers.ListOperationsPagedResponse;

import nl.topicus.jdbc.shaded.com.google.api.core.BetaApi;
import nl.topicus.jdbc.shaded.com.google.api.gax.core.BackgroundResource;
import nl.topicus.jdbc.shaded.com.google.api.gax.core.BackgroundResourceAggregation;
import nl.topicus.jdbc.shaded.com.google.api.gax.grpc.GrpcCallableFactory;
import nl.topicus.jdbc.shaded.com.google.api.gax.rpc.ClientContext;
import nl.topicus.jdbc.shaded.com.google.api.gax.rpc.UnaryCallable;
import nl.topicus.jdbc.shaded.com.google.longrunning.CancelOperationRequest;
import nl.topicus.jdbc.shaded.com.google.longrunning.DeleteOperationRequest;
import nl.topicus.jdbc.shaded.com.google.longrunning.GetOperationRequest;
import nl.topicus.jdbc.shaded.com.google.longrunning.ListOperationsRequest;
import nl.topicus.jdbc.shaded.com.google.longrunning.ListOperationsResponse;
import nl.topicus.jdbc.shaded.com.google.longrunning.Operation;
import nl.topicus.jdbc.shaded.com.google.longrunning.OperationsSettings;
import nl.topicus.jdbc.shaded.com.google.protobuf.Empty;
import java.nl.topicus.jdbc.shaded.io.IOException;
import java.util.concurrent.TimeUnit;
import nl.topicus.jdbc.shaded.javax.annotation.Generated;

// AUTO-GENERATED DOCUMENTATION AND CLASS
@Generated("by GAPIC v0.0.5")
@BetaApi
public class GrpcOperationsStub extends OperationsStub {
  private static final UnaryCallable directGetOperationCallable =
      GrpcCallableFactory.createDirectCallable(
          nl.topicus.jdbc.shaded.io.grpc.MethodDescriptor.create(
              nl.topicus.jdbc.shaded.io.grpc.MethodDescriptor.MethodType.UNARY,
              "google.longrunning.Operations/GetOperation",
              nl.topicus.jdbc.shaded.io.grpc.protobuf.ProtoUtils.marshaller(GetOperationRequest.getDefaultInstance()),
              nl.topicus.jdbc.shaded.io.grpc.protobuf.ProtoUtils.marshaller(Operation.getDefaultInstance())));
  private static final UnaryCallable
      directListOperationsCallable =
          GrpcCallableFactory.createDirectCallable(
              nl.topicus.jdbc.shaded.io.grpc.MethodDescriptor.create(
                  nl.topicus.jdbc.shaded.io.grpc.MethodDescriptor.MethodType.UNARY,
                  "google.longrunning.Operations/ListOperations",
                  nl.topicus.jdbc.shaded.io.grpc.protobuf.ProtoUtils.marshaller(
                      ListOperationsRequest.getDefaultInstance()),
                  nl.topicus.jdbc.shaded.io.grpc.protobuf.ProtoUtils.marshaller(
                      ListOperationsResponse.getDefaultInstance())));
  private static final UnaryCallable directCancelOperationCallable =
      GrpcCallableFactory.createDirectCallable(
          nl.topicus.jdbc.shaded.io.grpc.MethodDescriptor.create(
              nl.topicus.jdbc.shaded.io.grpc.MethodDescriptor.MethodType.UNARY,
              "google.longrunning.Operations/CancelOperation",
              nl.topicus.jdbc.shaded.io.grpc.protobuf.ProtoUtils.marshaller(CancelOperationRequest.getDefaultInstance()),
              nl.topicus.jdbc.shaded.io.grpc.protobuf.ProtoUtils.marshaller(Empty.getDefaultInstance())));
  private static final UnaryCallable directDeleteOperationCallable =
      GrpcCallableFactory.createDirectCallable(
          nl.topicus.jdbc.shaded.io.grpc.MethodDescriptor.create(
              nl.topicus.jdbc.shaded.io.grpc.MethodDescriptor.MethodType.UNARY,
              "google.longrunning.Operations/DeleteOperation",
              nl.topicus.jdbc.shaded.io.grpc.protobuf.ProtoUtils.marshaller(DeleteOperationRequest.getDefaultInstance()),
              nl.topicus.jdbc.shaded.io.grpc.protobuf.ProtoUtils.marshaller(Empty.getDefaultInstance())));
  private final BackgroundResource backgroundResources;

  private final UnaryCallable getOperationCallable;
  private final UnaryCallable listOperationsCallable;
  private final UnaryCallable
      listOperationsPagedCallable;
  private final UnaryCallable cancelOperationCallable;
  private final UnaryCallable deleteOperationCallable;

  public static final GrpcOperationsStub create(OperationsSettings settings) throws IOException {
    return new GrpcOperationsStub(settings, ClientContext.create(settings));
  }

  public static final GrpcOperationsStub create(ClientContext clientContext) throws IOException {
    return new GrpcOperationsStub(OperationsSettings.defaultBuilder().build(), clientContext);
  }

  /**
   * Constructs an instance of GrpcOperationsStub, using the given settings. This is protected so
   * that it easy to make a subclass, but otherwise, the static factory methods should be preferred.
   */
  protected GrpcOperationsStub(OperationsSettings settings, ClientContext clientContext)
      throws IOException {

    this.getOperationCallable =
        GrpcCallableFactory.create(
            directGetOperationCallable, settings.getOperationSettings(), clientContext);
    this.listOperationsCallable =
        GrpcCallableFactory.create(
            directListOperationsCallable, settings.listOperationsSettings(), clientContext);
    this.listOperationsPagedCallable =
        GrpcCallableFactory.createPagedVariant(
            directListOperationsCallable, settings.listOperationsSettings(), clientContext);
    this.cancelOperationCallable =
        GrpcCallableFactory.create(
            directCancelOperationCallable, settings.cancelOperationSettings(), clientContext);
    this.deleteOperationCallable =
        GrpcCallableFactory.create(
            directDeleteOperationCallable, settings.deleteOperationSettings(), clientContext);

    backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources());
  }

  public UnaryCallable getOperationCallable() {
    return getOperationCallable;
  }

  public UnaryCallable
      listOperationsPagedCallable() {
    return listOperationsPagedCallable;
  }

  public UnaryCallable listOperationsCallable() {
    return listOperationsCallable;
  }

  public UnaryCallable cancelOperationCallable() {
    return cancelOperationCallable;
  }

  public UnaryCallable deleteOperationCallable() {
    return deleteOperationCallable;
  }

  /**
   * Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately
   * cancelled.
   */
  @Override
  public final void close() throws Exception {
    shutdown();
  }

  @Override
  public void shutdown() {
    backgroundResources.shutdown();
  }

  @Override
  public boolean isShutdown() {
    return backgroundResources.isShutdown();
  }

  @Override
  public boolean isTerminated() {
    return backgroundResources.isTerminated();
  }

  @Override
  public void shutdownNow() {
    backgroundResources.shutdownNow();
  }

  @Override
  public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
    return backgroundResources.awaitTermination(duration, unit);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy