/*
 * 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.spanner.v1.model;

/**
 * A transaction.
 *
 * <p> This is the Java data model class that specifies how to parse/serialize into the JSON that is
 * transmitted over HTTP when working with the Cloud Spanner API. For a detailed explanation see:
 * <a href="https://developers.google.com/api-client-library/java/google-http-java-client/json">https://developers.google.com/api-client-library/java/google-http-java-client/json</a>
 * </p>
 *
 * @author Google, Inc.
 */
@SuppressWarnings("javadoc")
public final class Transaction extends com.google.api.client.json.GenericJson {

  /**
   * `id` may be used to identify the transaction in subsequent Read, ExecuteSql, Commit, or
   * Rollback calls. Single-use read-only transactions do not have IDs, because single-use
   * transactions do not support multiple requests.
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private java.lang.String id;

  /**
   * For snapshot read-only transactions, the read timestamp chosen for the transaction. Not
   * returned by default: see TransactionOptions.ReadOnly.return_read_timestamp. A timestamp in
   * RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. Example:
   * `"2014-10-02T15:01:23.045123456Z"`.
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private String readTimestamp;

  /**
   * `id` may be used to identify the transaction in subsequent Read, ExecuteSql, Commit, or
   * Rollback calls. Single-use read-only transactions do not have IDs, because single-use
   * transactions do not support multiple requests.
   * @see #decodeId()
   * @return value or {@code null} for none
   */
  public java.lang.String getId() {
    return id;
  }

  /**
   * `id` may be used to identify the transaction in subsequent Read, ExecuteSql, Commit, or
   * Rollback calls. Single-use read-only transactions do not have IDs, because single-use
   * transactions do not support multiple requests.
   * @see #getId()
   * @return Base64 decoded value or {@code null} for none
   *
   * @since 1.14
   */
  public byte[] decodeId() {
    return com.google.api.client.util.Base64.decodeBase64(id);
  }

  /**
   * `id` may be used to identify the transaction in subsequent Read, ExecuteSql, Commit, or
   * Rollback calls. Single-use read-only transactions do not have IDs, because single-use
   * transactions do not support multiple requests.
   * @see #encodeId()
   * @param id id or {@code null} for none
   */
  public Transaction setId(java.lang.String id) {
    this.id = id;
    return this;
  }

  /**
   * `id` may be used to identify the transaction in subsequent Read, ExecuteSql, Commit, or
   * Rollback calls. Single-use read-only transactions do not have IDs, because single-use
   * transactions do not support multiple requests.
   * @see #setId()
   *
   * <p>
   * The value is encoded Base64 or {@code null} for none.
   * </p>
   *
   * @since 1.14
   */
  public Transaction encodeId(byte[] id) {
    this.id = com.google.api.client.util.Base64.encodeBase64URLSafeString(id);
    return this;
  }

  /**
   * For snapshot read-only transactions, the read timestamp chosen for the transaction. Not
   * returned by default: see TransactionOptions.ReadOnly.return_read_timestamp. A timestamp in
   * RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. Example:
   * `"2014-10-02T15:01:23.045123456Z"`.
   * @return value or {@code null} for none
   */
  public String getReadTimestamp() {
    return readTimestamp;
  }

  /**
   * For snapshot read-only transactions, the read timestamp chosen for the transaction. Not
   * returned by default: see TransactionOptions.ReadOnly.return_read_timestamp. A timestamp in
   * RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. Example:
   * `"2014-10-02T15:01:23.045123456Z"`.
   * @param readTimestamp readTimestamp or {@code null} for none
   */
  public Transaction setReadTimestamp(String readTimestamp) {
    this.readTimestamp = readTimestamp;
    return this;
  }

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

  @Override
  public Transaction clone() {
    return (Transaction) super.clone();
  }

}
