# 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.Batch.V1.Model.Container do
  @moduledoc """
  Container runnable.

  ## Attributes

  *   `blockExternalNetwork` (*type:* `boolean()`, *default:* `nil`) - If set to true, external network access to and from container will be blocked, containers that are with block_external_network as true can still communicate with each other, network cannot be specified in the `container.options` field.
  *   `commands` (*type:* `list(String.t)`, *default:* `nil`) - Required for some container images. Overrides the `CMD` specified in the container. If there is an `ENTRYPOINT` (either in the container image or with the `entrypoint` field below) then these commands are appended as arguments to the `ENTRYPOINT`.
  *   `enableImageStreaming` (*type:* `boolean()`, *default:* `nil`) - Optional. If set to true, this container runnable uses Image streaming. Use Image streaming to allow the runnable to initialize without waiting for the entire container image to download, which can significantly reduce startup time for large container images. When `enableImageStreaming` is set to true, the container runtime is [containerd](https://containerd.io/) instead of Docker. Additionally, this container runnable only supports the following `container` subfields: `imageUri`, `commands[]`, `entrypoint`, and `volumes[]`; any other `container` subfields are ignored. For more information about the requirements and limitations for using Image streaming with Batch, see the [`image-streaming` sample on GitHub](https://github.com/GoogleCloudPlatform/batch-samples/tree/main/api-samples/image-streaming).
  *   `entrypoint` (*type:* `String.t`, *default:* `nil`) - Required for some container images. Overrides the `ENTRYPOINT` specified in the container.
  *   `imageUri` (*type:* `String.t`, *default:* `nil`) - Required. The URI to pull the container image from.
  *   `options` (*type:* `String.t`, *default:* `nil`) - Required for some container images. Arbitrary additional options to include in the `docker run` command when running this container—for example, `--network host`. For the `--volume` option, use the `volumes` field for the container.
  *   `password` (*type:* `String.t`, *default:* `nil`) - Required if the container image is from a private Docker registry. The password to login to the Docker registry that contains the image. For security, it is strongly recommended to specify an encrypted password by using a Secret Manager secret: `projects/*/secrets/*/versions/*`. Warning: If you specify the password using plain text, you risk the password being exposed to any users who can view the job or its logs. To avoid this risk, specify a secret that contains the password instead. Learn more about [Secret Manager](https://cloud.google.com/secret-manager/docs/) and [using Secret Manager with Batch](https://cloud.google.com/batch/docs/create-run-job-secret-manager).
  *   `username` (*type:* `String.t`, *default:* `nil`) - Required if the container image is from a private Docker registry. The username to login to the Docker registry that contains the image. You can either specify the username directly by using plain text or specify an encrypted username by using a Secret Manager secret: `projects/*/secrets/*/versions/*`. However, using a secret is recommended for enhanced security. Caution: If you specify the username using plain text, you risk the username being exposed to any users who can view the job or its logs. To avoid this risk, specify a secret that contains the username instead. Learn more about [Secret Manager](https://cloud.google.com/secret-manager/docs/) and [using Secret Manager with Batch](https://cloud.google.com/batch/docs/create-run-job-secret-manager).
  *   `volumes` (*type:* `list(String.t)`, *default:* `nil`) - Volumes to mount (bind mount) from the host machine files or directories into the container, formatted to match `--volume` option for the `docker run` command—for example, `/foo:/bar` or `/foo:/bar:ro`. If the `TaskSpec.Volumes` field is specified but this field is not, Batch will mount each volume from the host machine to the container with the same mount path by default. In this case, the default mount option for containers will be read-only (`ro`) for existing persistent disks and read-write (`rw`) for other volume types, regardless of the original mount options specified in `TaskSpec.Volumes`. If you need different mount settings, you can explicitly configure them in this field.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :blockExternalNetwork => boolean() | nil,
          :commands => list(String.t()) | nil,
          :enableImageStreaming => boolean() | nil,
          :entrypoint => String.t() | nil,
          :imageUri => String.t() | nil,
          :options => String.t() | nil,
          :password => String.t() | nil,
          :username => String.t() | nil,
          :volumes => list(String.t()) | nil
        }

  field(:blockExternalNetwork)
  field(:commands, type: :list)
  field(:enableImageStreaming)
  field(:entrypoint)
  field(:imageUri)
  field(:options)
  field(:password)
  field(:username)
  field(:volumes, type: :list)
end

defimpl Poison.Decoder, for: GoogleApi.Batch.V1.Model.Container do
  def decode(value, options) do
    GoogleApi.Batch.V1.Model.Container.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.Batch.V1.Model.Container do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
