# Copyright 2019 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.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.Genomics.V2alpha1.Model.Action do
  @moduledoc """
  Specifies a single action that runs a Docker container.

  ## Attributes

  *   `commands` (*type:* `list(String.t)`, *default:* `nil`) - If specified, overrides the `CMD` specified in the container. If the container also has an `ENTRYPOINT` the values are used as entrypoint arguments. Otherwise, they are used as a command and arguments to run inside the container.
  *   `credentials` (*type:* `GoogleApi.Genomics.V2alpha1.Model.Secret.t`, *default:* `nil`) - If the specified image is hosted on a private registry other than Google Container Registry, the credentials required to pull the image must be specified here as an encrypted secret. The secret must decrypt to a JSON-encoded dictionary containing both `username` and `password` keys.
  *   `encryptedEnvironment` (*type:* `GoogleApi.Genomics.V2alpha1.Model.Secret.t`, *default:* `nil`) - The encrypted environment to pass into the container. This environment is merged with values specified in the google.genomics.v2alpha1.Pipeline message, overwriting any duplicate values. The secret must decrypt to a JSON-encoded dictionary where key-value pairs serve as environment variable names and their values. The decoded environment variables can overwrite the values specified by the `environment` field.
  *   `entrypoint` (*type:* `String.t`, *default:* `nil`) - If specified, overrides the `ENTRYPOINT` specified in the container.
  *   `environment` (*type:* `map()`, *default:* `nil`) - The environment to pass into the container. This environment is merged with values specified in the google.genomics.v2alpha1.Pipeline message, overwriting any duplicate values. In addition to the values passed here, a few other values are automatically injected into the environment. These cannot be hidden or overwritten. `GOOGLE_PIPELINE_FAILED` will be set to "1" if the pipeline failed because an action has exited with a non-zero status (and did not have the `IGNORE_EXIT_STATUS` flag set). This can be used to determine if additional debug or logging actions should execute. `GOOGLE_LAST_EXIT_STATUS` will be set to the exit status of the last non-background action that executed. This can be used by workflow engine authors to determine whether an individual action has succeeded or failed.
  *   `flags` (*type:* `list(String.t)`, *default:* `nil`) - The set of flags to apply to this action.
  *   `imageUri` (*type:* `String.t`, *default:* `nil`) - Required. The URI to pull the container image from. Note that all images referenced by actions in the pipeline are pulled before the first action runs. If multiple actions reference the same image, it is only pulled once, ensuring that the same image is used for all actions in a single pipeline. The image URI can be either a complete host and image specification (e.g., quay.io/biocontainers/samtools), a library and image name (e.g., google/cloud-sdk) or a bare image name ('bash') to pull from the default library. No schema is required in any of these cases. If the specified image is not public, the service account specified for the Virtual Machine must have access to pull the images from GCR, or appropriate credentials must be specified in the google.genomics.v2alpha1.Action.credentials field.
  *   `labels` (*type:* `map()`, *default:* `nil`) - Labels to associate with the action. This field is provided to assist workflow engine authors in identifying actions (for example, to indicate what sort of action they perform, such as localization or debugging). They are returned in the operation metadata, but are otherwise ignored.
  *   `mounts` (*type:* `list(GoogleApi.Genomics.V2alpha1.Model.Mount.t)`, *default:* `nil`) - A list of mounts to make available to the action. In addition to the values specified here, every action has a special virtual disk mounted under `/google` that contains log files and other operational components. - /google/logs All logs written during the pipeline execution. - /google/logs/output The combined standard output and standard error of all actions run as part of the pipeline execution. - /google/logs/action/*/stdout The complete contents of each individual action's standard output. - /google/logs/action/*/stderr The complete contents of each individual action's standard error output. 
  *   `name` (*type:* `String.t`, *default:* `nil`) - An optional name for the container. The container hostname will be set to this name, making it useful for inter-container communication. The name must contain only upper and lowercase alphanumeric characters and hyphens and cannot start with a hyphen.
  *   `pidNamespace` (*type:* `String.t`, *default:* `nil`) - An optional identifier for a PID namespace to run the action inside. Multiple actions should use the same string to share a namespace. If unspecified, a separate isolated namespace is used.
  *   `portMappings` (*type:* `map()`, *default:* `nil`) - A map of containers to host port mappings for this container. If the container already specifies exposed ports, use the `PUBLISH_EXPOSED_PORTS` flag instead. The host port number must be less than 65536. If it is zero, an unused random port is assigned. To determine the resulting port number, consult the `ContainerStartedEvent` in the operation metadata.
  *   `timeout` (*type:* `String.t`, *default:* `nil`) - The maximum amount of time to give the action to complete. If the action fails to complete before the timeout, it will be terminated and the exit status will be non-zero. The pipeline will continue or terminate based on the rules defined by the `ALWAYS_RUN` and `IGNORE_EXIT_STATUS` flags.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :commands => list(String.t()) | nil,
          :credentials => GoogleApi.Genomics.V2alpha1.Model.Secret.t() | nil,
          :encryptedEnvironment => GoogleApi.Genomics.V2alpha1.Model.Secret.t() | nil,
          :entrypoint => String.t() | nil,
          :environment => map() | nil,
          :flags => list(String.t()) | nil,
          :imageUri => String.t() | nil,
          :labels => map() | nil,
          :mounts => list(GoogleApi.Genomics.V2alpha1.Model.Mount.t()) | nil,
          :name => String.t() | nil,
          :pidNamespace => String.t() | nil,
          :portMappings => map() | nil,
          :timeout => String.t() | nil
        }

  field(:commands, type: :list)
  field(:credentials, as: GoogleApi.Genomics.V2alpha1.Model.Secret)
  field(:encryptedEnvironment, as: GoogleApi.Genomics.V2alpha1.Model.Secret)
  field(:entrypoint)
  field(:environment, type: :map)
  field(:flags, type: :list)
  field(:imageUri)
  field(:labels, type: :map)
  field(:mounts, as: GoogleApi.Genomics.V2alpha1.Model.Mount, type: :list)
  field(:name)
  field(:pidNamespace)
  field(:portMappings, type: :map)
  field(:timeout)
end

defimpl Poison.Decoder, for: GoogleApi.Genomics.V2alpha1.Model.Action do
  def decode(value, options) do
    GoogleApi.Genomics.V2alpha1.Model.Action.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.Genomics.V2alpha1.Model.Action do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
