# 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.CloudTasks.V2beta2.Model.Queue do
  @moduledoc """
  A queue is a container of related tasks. Queues are configured to manage how those tasks are dispatched. Configurable properties include rate limits, retry options, target types, and others.

  ## Attributes

  *   `appEngineHttpTarget` (*type:* `GoogleApi.CloudTasks.V2beta2.Model.AppEngineHttpTarget.t`, *default:* `nil`) - App Engine HTTP target. An App Engine queue is a queue that has an AppEngineHttpTarget.
  *   `httpTarget` (*type:* `GoogleApi.CloudTasks.V2beta2.Model.HttpTarget.t`, *default:* `nil`) - An http_target is used to override the target values for HTTP tasks.
  *   `name` (*type:* `String.t`, *default:* `nil`) - Caller-specified and required in CreateQueue, after which it becomes output only. The queue name. The queue name must have the following format: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]), hyphens (-), colons (:), or periods (.). For more information, see [Identifying projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects) * `LOCATION_ID` is the canonical ID for the queue's location. The list of available locations can be obtained by calling ListLocations. For more information, see https://cloud.google.com/about/locations/. * `QUEUE_ID` can contain letters ([A-Za-z]), numbers ([0-9]), or hyphens (-). The maximum length is 100 characters.
  *   `pullTarget` (*type:* `GoogleApi.CloudTasks.V2beta2.Model.PullTarget.t`, *default:* `nil`) - Pull target. A pull queue is a queue that has a PullTarget.
  *   `purgeTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. The last time this queue was purged. All tasks that were created before this time were purged. A queue can be purged using PurgeQueue, the [App Engine Task Queue SDK, or the Cloud Console](https://cloud.google.com/appengine/docs/standard/python/taskqueue/push/deleting-tasks-and-queues#purging_all_tasks_from_a_queue). Purge time will be truncated to the nearest microsecond. Purge time will be unset if the queue has never been purged.
  *   `rateLimits` (*type:* `GoogleApi.CloudTasks.V2beta2.Model.RateLimits.t`, *default:* `nil`) - Rate limits for task dispatches. rate_limits and retry_config are related because they both control task attempts however they control how tasks are attempted in different ways: * rate_limits controls the total rate of dispatches from a queue (i.e. all traffic dispatched from the queue, regardless of whether the dispatch is from a first attempt or a retry). * retry_config controls what happens to particular a task after its first attempt fails. That is, retry_config controls task retries (the second attempt, third attempt, etc).
  *   `retryConfig` (*type:* `GoogleApi.CloudTasks.V2beta2.Model.RetryConfig.t`, *default:* `nil`) - Settings that determine the retry behavior. * For tasks created using Cloud Tasks: the queue-level retry settings apply to all tasks in the queue that were created using Cloud Tasks. Retry settings cannot be set on individual tasks. * For tasks created using the App Engine SDK: the queue-level retry settings apply to all tasks in the queue which do not have retry settings explicitly set on the task and were created by the App Engine SDK. See [App Engine documentation](https://cloud.google.com/appengine/docs/standard/python/taskqueue/push/retrying-tasks).
  *   `state` (*type:* `String.t`, *default:* `nil`) - Output only. The state of the queue. `state` can only be changed by called PauseQueue, ResumeQueue, or uploading [queue.yaml/xml](https://cloud.google.com/appengine/docs/python/config/queueref). UpdateQueue cannot be used to change `state`.
  *   `stats` (*type:* `GoogleApi.CloudTasks.V2beta2.Model.QueueStats.t`, *default:* `nil`) - Output only. The realtime, informational statistics for a queue. In order to receive the statistics the caller should include this field in the FieldMask.
  *   `taskTtl` (*type:* `String.t`, *default:* `nil`) - The maximum amount of time that a task will be retained in this queue. Queues created by Cloud Tasks have a default `task_ttl` of 31 days. After a task has lived for `task_ttl`, the task will be deleted regardless of whether it was dispatched or not. The `task_ttl` for queues created via queue.yaml/xml is equal to the maximum duration because there is a [storage quota](https://cloud.google.com/appengine/quotas#Task_Queue) for these queues. To view the maximum valid duration, see the documentation for Duration.
  *   `tombstoneTtl` (*type:* `String.t`, *default:* `nil`) - The task tombstone time to live (TTL). After a task is deleted or completed, the task's tombstone is retained for the length of time specified by `tombstone_ttl`. The tombstone is used by task de-duplication; another task with the same name can't be created until the tombstone has expired. For more information about task de-duplication, see the documentation for CreateTaskRequest. Queues created by Cloud Tasks have a default `tombstone_ttl` of 1 hour.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :appEngineHttpTarget =>
            GoogleApi.CloudTasks.V2beta2.Model.AppEngineHttpTarget.t() | nil,
          :httpTarget => GoogleApi.CloudTasks.V2beta2.Model.HttpTarget.t() | nil,
          :name => String.t() | nil,
          :pullTarget => GoogleApi.CloudTasks.V2beta2.Model.PullTarget.t() | nil,
          :purgeTime => DateTime.t() | nil,
          :rateLimits => GoogleApi.CloudTasks.V2beta2.Model.RateLimits.t() | nil,
          :retryConfig => GoogleApi.CloudTasks.V2beta2.Model.RetryConfig.t() | nil,
          :state => String.t() | nil,
          :stats => GoogleApi.CloudTasks.V2beta2.Model.QueueStats.t() | nil,
          :taskTtl => String.t() | nil,
          :tombstoneTtl => String.t() | nil
        }

  field(:appEngineHttpTarget, as: GoogleApi.CloudTasks.V2beta2.Model.AppEngineHttpTarget)
  field(:httpTarget, as: GoogleApi.CloudTasks.V2beta2.Model.HttpTarget)
  field(:name)
  field(:pullTarget, as: GoogleApi.CloudTasks.V2beta2.Model.PullTarget)
  field(:purgeTime, as: DateTime)
  field(:rateLimits, as: GoogleApi.CloudTasks.V2beta2.Model.RateLimits)
  field(:retryConfig, as: GoogleApi.CloudTasks.V2beta2.Model.RetryConfig)
  field(:state)
  field(:stats, as: GoogleApi.CloudTasks.V2beta2.Model.QueueStats)
  field(:taskTtl)
  field(:tombstoneTtl)
end

defimpl Poison.Decoder, for: GoogleApi.CloudTasks.V2beta2.Model.Queue do
  def decode(value, options) do
    GoogleApi.CloudTasks.V2beta2.Model.Queue.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.CloudTasks.V2beta2.Model.Queue do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
