# 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.WorkspaceEvents.V1.Model.Subscription do
  @moduledoc """
  [Developer Preview](https://developers.google.com/workspace/preview). A subscription to receive events about a Google Workspace resource. To learn more about subscriptions, see the [Google Workspace Events API overview](https://developers.google.com/workspace/events).

  ## Attributes

  *   `authority` (*type:* `String.t`, *default:* `nil`) - Output only. The user who authorized the creation of the subscription. Format: `users/{user}` For Google Workspace users, the `{user}` value is the [`user.id`](https://developers.google.com/admin-sdk/directory/reference/rest/v1/users#User.FIELDS.ids) field from the Directory API.
  *   `createTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. The time when the subscription is created.
  *   `etag` (*type:* `String.t`, *default:* `nil`) - Optional. This checksum is computed by the server based on the value of other fields, and might be sent on update requests to ensure the client has an up-to-date value before proceeding.
  *   `eventTypes` (*type:* `list(String.t)`, *default:* `nil`) - Required. Unordered list. Input for creating a subscription. Otherwise, output only. One or more types of events to receive about the target resource. Formatted according to the CloudEvents specification. The supported event types depend on the target resource of your subscription. For details, see [Supported Google Workspace events](https://developers.google.com/workspace/events/guides#supported-events). By default, you also receive events about the [lifecycle of your subscription](https://developers.google.com/workspace/events/guides/events-lifecycle). You don't need to specify lifecycle events for this field. If you specify an event type that doesn't exist for the target resource, the request returns an HTTP `400 Bad Request` status code.
  *   `expireTime` (*type:* `DateTime.t`, *default:* `nil`) - Non-empty default. The timestamp in UTC when the subscription expires. Always displayed on output, regardless of what was used on input.
  *   `name` (*type:* `String.t`, *default:* `nil`) - Identifier. Resource name of the subscription. Format: `subscriptions/{subscription}`
  *   `notificationEndpoint` (*type:* `GoogleApi.WorkspaceEvents.V1.Model.NotificationEndpoint.t`, *default:* `nil`) - Required. Immutable. The endpoint where the subscription delivers events, such as a Pub/Sub topic.
  *   `payloadOptions` (*type:* `GoogleApi.WorkspaceEvents.V1.Model.PayloadOptions.t`, *default:* `nil`) - Optional. Options about what data to include in the event payload. Only supported for Google Chat events.
  *   `reconciling` (*type:* `boolean()`, *default:* `nil`) - Output only. If `true`, the subscription is in the process of being updated.
  *   `state` (*type:* `String.t`, *default:* `nil`) - Output only. The state of the subscription. Determines whether the subscription can receive events and deliver them to the notification endpoint.
  *   `suspensionReason` (*type:* `String.t`, *default:* `nil`) - Output only. The error that suspended the subscription. To reactivate the subscription, resolve the error and call the `ReactivateSubscription` method.
  *   `targetResource` (*type:* `String.t`, *default:* `nil`) - Required. Immutable. The Google Workspace resource that's monitored for events, formatted as the [full resource name](https://google.aip.dev/122#full-resource-names). To learn about target resources and the events that they support, see [Supported Google Workspace events](https://developers.google.com/workspace/events#supported-events). A user can only authorize your app to create one subscription for a given target resource. If your app tries to create another subscription with the same user credentials, the request returns an `ALREADY_EXISTS` error.
  *   `ttl` (*type:* `String.t`, *default:* `nil`) - Input only. The time-to-live (TTL) or duration for the subscription. If unspecified or set to `0`, uses the maximum possible duration.
  *   `uid` (*type:* `String.t`, *default:* `nil`) - Output only. System-assigned unique identifier for the subscription.
  *   `updateTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. The last time that the subscription is updated.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :authority => String.t() | nil,
          :createTime => DateTime.t() | nil,
          :etag => String.t() | nil,
          :eventTypes => list(String.t()) | nil,
          :expireTime => DateTime.t() | nil,
          :name => String.t() | nil,
          :notificationEndpoint =>
            GoogleApi.WorkspaceEvents.V1.Model.NotificationEndpoint.t() | nil,
          :payloadOptions => GoogleApi.WorkspaceEvents.V1.Model.PayloadOptions.t() | nil,
          :reconciling => boolean() | nil,
          :state => String.t() | nil,
          :suspensionReason => String.t() | nil,
          :targetResource => String.t() | nil,
          :ttl => String.t() | nil,
          :uid => String.t() | nil,
          :updateTime => DateTime.t() | nil
        }

  field(:authority)
  field(:createTime, as: DateTime)
  field(:etag)
  field(:eventTypes, type: :list)
  field(:expireTime, as: DateTime)
  field(:name)
  field(:notificationEndpoint, as: GoogleApi.WorkspaceEvents.V1.Model.NotificationEndpoint)
  field(:payloadOptions, as: GoogleApi.WorkspaceEvents.V1.Model.PayloadOptions)
  field(:reconciling)
  field(:state)
  field(:suspensionReason)
  field(:targetResource)
  field(:ttl)
  field(:uid)
  field(:updateTime, as: DateTime)
end

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

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