# 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.Chat.V1.Model.Space do
  @moduledoc """
  A space in Google Chat. Spaces are conversations between two or more users or 1:1 messages between a user and a Chat app.

  ## Attributes

  *   `accessSettings` (*type:* `GoogleApi.Chat.V1.Model.AccessSettings.t`, *default:* `nil`) - Optional. Specifies the [access setting](https://support.google.com/chat/answer/11971020) of the space. Only populated when the `space_type` is `SPACE`.
  *   `adminInstalled` (*type:* `boolean()`, *default:* `nil`) - Output only. For direct message (DM) spaces with a Chat app, whether the space was created by a Google Workspace administrator. Administrators can install and set up a direct message with a Chat app on behalf of users in their organization. To support admin install, your Chat app must feature direct messaging.
  *   `createTime` (*type:* `DateTime.t`, *default:* `nil`) - Optional. Immutable. For spaces created in Chat, the time the space was created. This field is output only, except when used in import mode spaces. For import mode spaces, set this field to the historical timestamp at which the space was created in the source in order to preserve the original creation time. Only populated in the output when `spaceType` is `GROUP_CHAT` or `SPACE`.
  *   `displayName` (*type:* `String.t`, *default:* `nil`) - Optional. The space's display name. Required when [creating a space](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces/create) with a `spaceType` of `SPACE`. If you receive the error message `ALREADY_EXISTS` when creating a space or updating the `displayName`, try a different `displayName`. An existing space within the Google Workspace organization might already use this display name. For direct messages, this field might be empty. Supports up to 128 characters.
  *   `externalUserAllowed` (*type:* `boolean()`, *default:* `nil`) - Optional. Immutable. Whether this space permits any Google Chat user as a member. Input when creating a space in a Google Workspace organization. Omit this field when creating spaces in the following conditions: * The authenticated user uses a consumer account (unmanaged user account). By default, a space created by a consumer account permits any Google Chat user. For existing spaces, this field is output only.
  *   `importMode` (*type:* `boolean()`, *default:* `nil`) - Optional. Whether this space is created in `Import Mode` as part of a data migration into Google Workspace. While spaces are being imported, they aren't visible to users until the import is complete. Creating a space in `Import Mode`requires [user authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
  *   `importModeExpireTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. The time when the space will be automatically deleted by the system if it remains in import mode. Each space created in import mode must exit this mode before this expire time using `spaces.completeImport`. This field is only populated for spaces that were created with import mode.
  *   `lastActiveTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. Timestamp of the last message in the space.
  *   `membershipCount` (*type:* `GoogleApi.Chat.V1.Model.MembershipCount.t`, *default:* `nil`) - Output only. The count of joined memberships grouped by member type. Populated when the `space_type` is `SPACE`, `DIRECT_MESSAGE` or `GROUP_CHAT`.
  *   `name` (*type:* `String.t`, *default:* `nil`) - Identifier. Resource name of the space. Format: `spaces/{space}` Where `{space}` represents the system-assigned ID for the space. You can obtain the space ID by calling the [`spaces.list()`](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces/list) method or from the space URL. For example, if the space URL is `https://mail.google.com/mail/u/0/#chat/space/AAAAAAAAA`, the space ID is `AAAAAAAAA`.
  *   `permissionSettings` (*type:* `GoogleApi.Chat.V1.Model.PermissionSettings.t`, *default:* `nil`) - Optional. Space permission settings for existing spaces. Input for updating exact space permission settings, where existing permission settings are replaced. Output lists current permission settings. Reading and updating permission settings supports: - In [Developer Preview](https://developers.google.com/workspace/preview), [App authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app) with [administrator approval](https://support.google.com/a?p=chat-app-auth) with the `chat.app.spaces` scope. Only populated and settable when the Chat app created the space. - [User authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
  *   `predefinedPermissionSettings` (*type:* `String.t`, *default:* `nil`) - Optional. Input only. Predefined space permission settings, input only when creating a space. If the field is not set, a collaboration space is created. After you create the space, settings are populated in the `PermissionSettings` field. Setting predefined permission settings supports: - In [Developer Preview](https://developers.google.com/workspace/preview), [App authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app) with [administrator approval](https://support.google.com/a?p=chat-app-auth) with the `chat.app.spaces` or `chat.app.spaces.create` scopes. - [User authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
  *   `singleUserBotDm` (*type:* `boolean()`, *default:* `nil`) - Optional. Whether the space is a DM between a Chat app and a single human.
  *   `spaceDetails` (*type:* `GoogleApi.Chat.V1.Model.SpaceDetails.t`, *default:* `nil`) - Optional. Details about the space including description and rules.
  *   `spaceHistoryState` (*type:* `String.t`, *default:* `nil`) - Optional. The message history state for messages and threads in this space.
  *   `spaceThreadingState` (*type:* `String.t`, *default:* `nil`) - Output only. The threading state in the Chat space.
  *   `spaceType` (*type:* `String.t`, *default:* `nil`) - Optional. The type of space. Required when creating a space or updating the space type of a space. Output only for other usage.
  *   `spaceUri` (*type:* `String.t`, *default:* `nil`) - Output only. The URI for a user to access the space.
  *   `threaded` (*type:* `boolean()`, *default:* `nil`) - Output only. Deprecated: Use `spaceThreadingState` instead. Whether messages are threaded in this space.
  *   `type` (*type:* `String.t`, *default:* `nil`) - Output only. Deprecated: Use `space_type` instead. The type of a space.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :accessSettings => GoogleApi.Chat.V1.Model.AccessSettings.t() | nil,
          :adminInstalled => boolean() | nil,
          :createTime => DateTime.t() | nil,
          :displayName => String.t() | nil,
          :externalUserAllowed => boolean() | nil,
          :importMode => boolean() | nil,
          :importModeExpireTime => DateTime.t() | nil,
          :lastActiveTime => DateTime.t() | nil,
          :membershipCount => GoogleApi.Chat.V1.Model.MembershipCount.t() | nil,
          :name => String.t() | nil,
          :permissionSettings => GoogleApi.Chat.V1.Model.PermissionSettings.t() | nil,
          :predefinedPermissionSettings => String.t() | nil,
          :singleUserBotDm => boolean() | nil,
          :spaceDetails => GoogleApi.Chat.V1.Model.SpaceDetails.t() | nil,
          :spaceHistoryState => String.t() | nil,
          :spaceThreadingState => String.t() | nil,
          :spaceType => String.t() | nil,
          :spaceUri => String.t() | nil,
          :threaded => boolean() | nil,
          :type => String.t() | nil
        }

  field(:accessSettings, as: GoogleApi.Chat.V1.Model.AccessSettings)
  field(:adminInstalled)
  field(:createTime, as: DateTime)
  field(:displayName)
  field(:externalUserAllowed)
  field(:importMode)
  field(:importModeExpireTime, as: DateTime)
  field(:lastActiveTime, as: DateTime)
  field(:membershipCount, as: GoogleApi.Chat.V1.Model.MembershipCount)
  field(:name)
  field(:permissionSettings, as: GoogleApi.Chat.V1.Model.PermissionSettings)
  field(:predefinedPermissionSettings)
  field(:singleUserBotDm)
  field(:spaceDetails, as: GoogleApi.Chat.V1.Model.SpaceDetails)
  field(:spaceHistoryState)
  field(:spaceThreadingState)
  field(:spaceType)
  field(:spaceUri)
  field(:threaded)
  field(:type)
end

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

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