/*
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
/*
 * This code was generated by https://github.com/googleapis/google-api-java-client-services/
 * Modify at your own risk.
 */

package com.google.api.services.videointelligence.v1p1beta1;

/**
 * Service definition for CloudVideoIntelligence (v1p1beta1).
 *
 * <p>
 * Detects objects, explicit content, and scene changes in videos. It also specifies the region for annotation and transcribes speech to text. Supports both asynchronous API and streaming API.
 * </p>
 *
 * <p>
 * For more information about this service, see the
 * <a href="https://cloud.google.com/video-intelligence/docs/" target="_blank">API Documentation</a>
 * </p>
 *
 * <p>
 * This service uses {@link CloudVideoIntelligenceRequestInitializer} to initialize global parameters via its
 * {@link Builder}.
 * </p>
 *
 * @since 1.3
 * @author Google, Inc.
 */
@SuppressWarnings("javadoc")
public class CloudVideoIntelligence extends com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient {

  // Note: Leave this static initializer at the top of the file.
  static {
    com.google.api.client.util.Preconditions.checkState(
        (com.google.api.client.googleapis.GoogleUtils.MAJOR_VERSION == 1 &&
        (com.google.api.client.googleapis.GoogleUtils.MINOR_VERSION >= 32 ||
        (com.google.api.client.googleapis.GoogleUtils.MINOR_VERSION == 31 &&
        com.google.api.client.googleapis.GoogleUtils.BUGFIX_VERSION >= 1))) ||
        com.google.api.client.googleapis.GoogleUtils.MAJOR_VERSION >= 2,
        "You are currently running with version %s of google-api-client. " +
        "You need at least version 1.31.1 of google-api-client to run version " +
        "2.0.0 of the Cloud Video Intelligence API library.", com.google.api.client.googleapis.GoogleUtils.VERSION);
  }

  /**
   * The default encoded root URL of the service. This is determined when the library is generated
   * and normally should not be changed.
   *
   * @since 1.7
   */
  public static final String DEFAULT_ROOT_URL = "https://videointelligence.googleapis.com/";

  /**
   * The default encoded mTLS root URL of the service. This is determined when the library is generated
   * and normally should not be changed.
   *
   * @since 1.31
   */
  public static final String DEFAULT_MTLS_ROOT_URL = "https://videointelligence.mtls.googleapis.com/";

  /**
   * The default encoded service path of the service. This is determined when the library is
   * generated and normally should not be changed.
   *
   * @since 1.7
   */
  public static final String DEFAULT_SERVICE_PATH = "";

  /**
   * The default encoded batch path of the service. This is determined when the library is
   * generated and normally should not be changed.
   *
   * @since 1.23
   */
  public static final String DEFAULT_BATCH_PATH = "batch";

  /**
   * The default encoded base URL of the service. This is determined when the library is generated
   * and normally should not be changed.
   */
  public static final String DEFAULT_BASE_URL = DEFAULT_ROOT_URL + DEFAULT_SERVICE_PATH;

  /**
   * Constructor.
   *
   * <p>
   * Use {@link Builder} if you need to specify any of the optional parameters.
   * </p>
   *
   * @param transport HTTP transport, which should normally be:
   *        <ul>
   *        <li>Google App Engine:
   *        {@code com.google.api.client.extensions.appengine.http.UrlFetchTransport}</li>
   *        <li>Android: {@code newCompatibleTransport} from
   *        {@code com.google.api.client.extensions.android.http.AndroidHttp}</li>
   *        <li>Java: {@link com.google.api.client.googleapis.javanet.GoogleNetHttpTransport#newTrustedTransport()}
   *        </li>
   *        </ul>
   * @param jsonFactory JSON factory, which may be:
   *        <ul>
   *        <li>Jackson: {@code com.google.api.client.json.jackson2.JacksonFactory}</li>
   *        <li>Google GSON: {@code com.google.api.client.json.gson.GsonFactory}</li>
   *        <li>Android Honeycomb or higher:
   *        {@code com.google.api.client.extensions.android.json.AndroidJsonFactory}</li>
   *        </ul>
   * @param httpRequestInitializer HTTP request initializer or {@code null} for none
   * @since 1.7
   */
  public CloudVideoIntelligence(com.google.api.client.http.HttpTransport transport, com.google.api.client.json.JsonFactory jsonFactory,
      com.google.api.client.http.HttpRequestInitializer httpRequestInitializer) {
    this(new Builder(transport, jsonFactory, httpRequestInitializer));
  }

  /**
   * @param builder builder
   */
  CloudVideoIntelligence(Builder builder) {
    super(builder);
  }

  @Override
  protected void initialize(com.google.api.client.googleapis.services.AbstractGoogleClientRequest<?> httpClientRequest) throws java.io.IOException {
    super.initialize(httpClientRequest);
  }

  /**
   * An accessor for creating requests from the Videos collection.
   *
   * <p>The typical use is:</p>
   * <pre>
   *   {@code CloudVideoIntelligence videointelligence = new CloudVideoIntelligence(...);}
   *   {@code CloudVideoIntelligence.Videos.List request = videointelligence.videos().list(parameters ...)}
   * </pre>
   *
   * @return the resource collection
   */
  public Videos videos() {
    return new Videos();
  }

  /**
   * The "videos" collection of methods.
   */
  public class Videos {

    /**
     * Performs asynchronous video annotation. Progress and results can be retrieved through the
     * `google.longrunning.Operations` interface. `Operation.metadata` contains `AnnotateVideoProgress`
     * (progress). `Operation.response` contains `AnnotateVideoResponse` (results).
     *
     * Create a request for the method "videos.annotate".
     *
     * This request holds the parameters needed by the videointelligence server.  After setting any
     * optional parameters, call the {@link Annotate#execute()} method to invoke the remote operation.
     *
     * @param content the {@link com.google.api.services.videointelligence.v1p1beta1.model.GoogleCloudVideointelligenceV1p1beta1AnnotateVideoRequest}
     * @return the request
     */
    public Annotate annotate(com.google.api.services.videointelligence.v1p1beta1.model.GoogleCloudVideointelligenceV1p1beta1AnnotateVideoRequest content) throws java.io.IOException {
      Annotate result = new Annotate(content);
      initialize(result);
      return result;
    }

    public class Annotate extends CloudVideoIntelligenceRequest<com.google.api.services.videointelligence.v1p1beta1.model.GoogleLongrunningOperation> {

      private static final String REST_PATH = "v1p1beta1/videos:annotate";

      /**
       * Performs asynchronous video annotation. Progress and results can be retrieved through the
       * `google.longrunning.Operations` interface. `Operation.metadata` contains
       * `AnnotateVideoProgress` (progress). `Operation.response` contains `AnnotateVideoResponse`
       * (results).
       *
       * Create a request for the method "videos.annotate".
       *
       * This request holds the parameters needed by the the videointelligence server.  After setting
       * any optional parameters, call the {@link Annotate#execute()} method to invoke the remote
       * operation. <p> {@link
       * Annotate#initialize(com.google.api.client.googleapis.services.AbstractGoogleClientRequest)}
       * must be called to initialize this instance immediately after invoking the constructor. </p>
       *
       * @param content the {@link com.google.api.services.videointelligence.v1p1beta1.model.GoogleCloudVideointelligenceV1p1beta1AnnotateVideoRequest}
       * @since 1.13
       */
      protected Annotate(com.google.api.services.videointelligence.v1p1beta1.model.GoogleCloudVideointelligenceV1p1beta1AnnotateVideoRequest content) {
        super(CloudVideoIntelligence.this, "POST", REST_PATH, content, com.google.api.services.videointelligence.v1p1beta1.model.GoogleLongrunningOperation.class);
      }

      @Override
      public Annotate set$Xgafv(java.lang.String $Xgafv) {
        return (Annotate) super.set$Xgafv($Xgafv);
      }

      @Override
      public Annotate setAccessToken(java.lang.String accessToken) {
        return (Annotate) super.setAccessToken(accessToken);
      }

      @Override
      public Annotate setAlt(java.lang.String alt) {
        return (Annotate) super.setAlt(alt);
      }

      @Override
      public Annotate setCallback(java.lang.String callback) {
        return (Annotate) super.setCallback(callback);
      }

      @Override
      public Annotate setFields(java.lang.String fields) {
        return (Annotate) super.setFields(fields);
      }

      @Override
      public Annotate setKey(java.lang.String key) {
        return (Annotate) super.setKey(key);
      }

      @Override
      public Annotate setOauthToken(java.lang.String oauthToken) {
        return (Annotate) super.setOauthToken(oauthToken);
      }

      @Override
      public Annotate setPrettyPrint(java.lang.Boolean prettyPrint) {
        return (Annotate) super.setPrettyPrint(prettyPrint);
      }

      @Override
      public Annotate setQuotaUser(java.lang.String quotaUser) {
        return (Annotate) super.setQuotaUser(quotaUser);
      }

      @Override
      public Annotate setUploadType(java.lang.String uploadType) {
        return (Annotate) super.setUploadType(uploadType);
      }

      @Override
      public Annotate setUploadProtocol(java.lang.String uploadProtocol) {
        return (Annotate) super.setUploadProtocol(uploadProtocol);
      }

      @Override
      public Annotate set(String parameterName, Object value) {
        return (Annotate) super.set(parameterName, value);
      }
    }

  }

  /**
   * Builder for {@link CloudVideoIntelligence}.
   *
   * <p>
   * Implementation is not thread-safe.
   * </p>
   *
   * @since 1.3.0
   */
  public static final class Builder extends com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient.Builder {

    private static String chooseEndpoint(com.google.api.client.http.HttpTransport transport) {
      // If the GOOGLE_API_USE_MTLS_ENDPOINT environment variable value is "always", use mTLS endpoint.
      // If the env variable is "auto", use mTLS endpoint if and only if the transport is mTLS.
      // Use the regular endpoint for all other cases.
      String useMtlsEndpoint = System.getenv("GOOGLE_API_USE_MTLS_ENDPOINT");
      useMtlsEndpoint = useMtlsEndpoint == null ? "auto" : useMtlsEndpoint;
      if ("always".equals(useMtlsEndpoint) || ("auto".equals(useMtlsEndpoint) && transport != null && transport.isMtls())) {
        return DEFAULT_MTLS_ROOT_URL;
      }
      return DEFAULT_ROOT_URL;
    }

    /**
     * Returns an instance of a new builder.
     *
     * @param transport HTTP transport, which should normally be:
     *        <ul>
     *        <li>Google App Engine:
     *        {@code com.google.api.client.extensions.appengine.http.UrlFetchTransport}</li>
     *        <li>Android: {@code newCompatibleTransport} from
     *        {@code com.google.api.client.extensions.android.http.AndroidHttp}</li>
     *        <li>Java: {@link com.google.api.client.googleapis.javanet.GoogleNetHttpTransport#newTrustedTransport()}
     *        </li>
     *        </ul>
     * @param jsonFactory JSON factory, which may be:
     *        <ul>
     *        <li>Jackson: {@code com.google.api.client.json.jackson2.JacksonFactory}</li>
     *        <li>Google GSON: {@code com.google.api.client.json.gson.GsonFactory}</li>
     *        <li>Android Honeycomb or higher:
     *        {@code com.google.api.client.extensions.android.json.AndroidJsonFactory}</li>
     *        </ul>
     * @param httpRequestInitializer HTTP request initializer or {@code null} for none
     * @since 1.7
     */
    public Builder(com.google.api.client.http.HttpTransport transport, com.google.api.client.json.JsonFactory jsonFactory,
        com.google.api.client.http.HttpRequestInitializer httpRequestInitializer) {
      super(
          transport,
          jsonFactory,
          Builder.chooseEndpoint(transport),
          DEFAULT_SERVICE_PATH,
          httpRequestInitializer,
          false);
      setBatchPath(DEFAULT_BATCH_PATH);
    }

    /** Builds a new instance of {@link CloudVideoIntelligence}. */
    @Override
    public CloudVideoIntelligence build() {
      return new CloudVideoIntelligence(this);
    }

    @Override
    public Builder setRootUrl(String rootUrl) {
      return (Builder) super.setRootUrl(rootUrl);
    }

    @Override
    public Builder setServicePath(String servicePath) {
      return (Builder) super.setServicePath(servicePath);
    }

    @Override
    public Builder setBatchPath(String batchPath) {
      return (Builder) super.setBatchPath(batchPath);
    }

    @Override
    public Builder setHttpRequestInitializer(com.google.api.client.http.HttpRequestInitializer httpRequestInitializer) {
      return (Builder) super.setHttpRequestInitializer(httpRequestInitializer);
    }

    @Override
    public Builder setApplicationName(String applicationName) {
      return (Builder) super.setApplicationName(applicationName);
    }

    @Override
    public Builder setSuppressPatternChecks(boolean suppressPatternChecks) {
      return (Builder) super.setSuppressPatternChecks(suppressPatternChecks);
    }

    @Override
    public Builder setSuppressRequiredParameterChecks(boolean suppressRequiredParameterChecks) {
      return (Builder) super.setSuppressRequiredParameterChecks(suppressRequiredParameterChecks);
    }

    @Override
    public Builder setSuppressAllChecks(boolean suppressAllChecks) {
      return (Builder) super.setSuppressAllChecks(suppressAllChecks);
    }

    /**
     * Set the {@link CloudVideoIntelligenceRequestInitializer}.
     *
     * @since 1.12
     */
    public Builder setCloudVideoIntelligenceRequestInitializer(
        CloudVideoIntelligenceRequestInitializer cloudvideointelligenceRequestInitializer) {
      return (Builder) super.setGoogleClientRequestInitializer(cloudvideointelligenceRequestInitializer);
    }

    @Override
    public Builder setGoogleClientRequestInitializer(
        com.google.api.client.googleapis.services.GoogleClientRequestInitializer googleClientRequestInitializer) {
      return (Builder) super.setGoogleClientRequestInitializer(googleClientRequestInitializer);
    }
  }
}
