/*
 * Copyright (C) 2021 Google LLC
 *
 * 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.
 */
package com.google.cloud.teleport.v2.options;

import com.google.cloud.teleport.v2.transforms.GenericRecordsToGcsPartitioned.OutputFileFormat;
import com.google.cloud.teleport.v2.transforms.GenericRecordsToGcsPartitioned.PartitioningSchema;
import org.apache.beam.sdk.extensions.gcp.options.GcpOptions;
import org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.Write.WriteDisposition;
import org.apache.beam.sdk.options.Default;
import org.apache.beam.sdk.options.Description;
import org.apache.beam.sdk.options.PipelineOptions;
import org.apache.beam.sdk.options.Validation;

/**
 * The {@link Options} class provides the custom execution options passed by the executor at the
 * command-line.
 */
public interface DataplexJdbcIngestionOptions extends GcpOptions, PipelineOptions {
  @Description(
      "Comma separate list of driver class/dependency jar file GCS paths "
          + "for example "
          + "gs://<some-bucket>/driver_jar1.jar,gs://<some_bucket>/driver_jar2.jar")
  @Validation.Required
  String getDriverJars();

  void setDriverJars(String driverJar);

  @Description("The JDBC driver class name. " + "for example: com.mysql.jdbc.Driver")
  @Validation.Required
  String getDriverClassName();

  void setDriverClassName(String driverClassName);

  @Description(
      "The JDBC connection URL string. " + "for example: jdbc:mysql://some-host:3306/sampledb")
  @Validation.Required
  String getConnectionURL();

  void setConnectionURL(String connectionURL);

  @Description(
      "JDBC connection property string. " + "for example: unicode=true&characterEncoding=UTF-8")
  String getConnectionProperties();

  void setConnectionProperties(String connectionProperties);

  @Description("JDBC connection user name. ")
  String getUsername();

  void setUsername(String username);

  @Description("JDBC connection password. ")
  String getPassword();

  void setPassword(String password);

  @Description("Source data query string. " + "for example: select * from sampledb.sample_table")
  @Validation.Required
  String getQuery();

  void setQuery(String query);

  @Description(
      "BigQuery Table spec to write the output to"
          + "for example: some-project-id:somedataset.sometable")
  String getOutputTable();

  void setOutputTable(String value);

  @Description(
      "Optional KMS Encryption Key to decrypt the 'username', 'password' and 'url' parameters. If"
          + " not set, username/password/url have to be provided unencrypted. Should be in the"
          + " format of"
          + " projects/{gcp_project}/locations/{key_region}/keyRings/{key_ring}/cryptoKeys/{kms_key_name}")
  String getKMSEncryptionKey();

  void setKMSEncryptionKey(String keyName);

  @Description(
      "Dataplex output asset ID to which the results are stored to. Should be in the format of"
          + " projects/<name>/locations/<loc>/lakes/<lake-name>/zones/<zone-name>/assets/<asset"
          + " name>")
  String getOutputAsset();

  void setOutputAsset(String outputAsset);

  @Description(
      "The partition scheme when writing the file. Default: daily. "
          + "Allowed formats are: "
          + "DAILY, MONTHLY, HOURLY")
  @Default.Enum("DAILY")
  PartitioningSchema getPartitioningScheme();

  void setPartitioningScheme(PartitioningSchema partitioningScheme);

  @Description(
      "The partition column on which the partition is based. "
          + "Must be of "
          + "timestamp / date format")
  String getParitionColumn();

  void setParitionColumn(String partitionColumn);

  @Description(
      "If the table exists - should it overwrite / append or fail the load. "
          + "Default: WRITE_APPEND. "
          + "This currently only supports writing to BigQuery."
          + "Allowed formats are: "
          + "WRITE_APPEND / WRITE_TRUNCATE / WRITE_EMPTY")
  @Default.Enum("WRITE_APPEND")
  WriteDisposition getWriteDisposition();

  void setWriteDisposition(WriteDisposition writeDisposition);

  @Description("Output file format in GCS. Format: PARQUET, AVRO, or ORC. Default: PARQUET.")
  @Default.Enum("PARQUET")
  OutputFileFormat getFileFormat();

  void setFileFormat(OutputFileFormat fileFormat);
}

@@ -2181,16 +2181,39 @@
 UTF-8%22)%0A
+  @Validation.Required%0A
   String

Update required option in Dataplex JDBC Template.