{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Chime.GetRetentionSettings
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets the retention settings for the specified Amazon Chime Enterprise
-- account. For more information about retention settings, see
-- <https://docs.aws.amazon.com/chime/latest/ag/chat-retention.html Managing Chat Retention Policies>
-- in the /Amazon Chime Administration Guide/.
module Amazonka.Chime.GetRetentionSettings
  ( -- * Creating a Request
    GetRetentionSettings (..),
    newGetRetentionSettings,

    -- * Request Lenses
    getRetentionSettings_accountId,

    -- * Destructuring the Response
    GetRetentionSettingsResponse (..),
    newGetRetentionSettingsResponse,

    -- * Response Lenses
    getRetentionSettingsResponse_retentionSettings,
    getRetentionSettingsResponse_initiateDeletionTimestamp,
    getRetentionSettingsResponse_httpStatus,
  )
where

import Amazonka.Chime.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetRetentionSettings' smart constructor.
data GetRetentionSettings = GetRetentionSettings'
  { -- | The Amazon Chime account ID.
    GetRetentionSettings -> Text
accountId :: Prelude.Text
  }
  deriving (GetRetentionSettings -> GetRetentionSettings -> Bool
(GetRetentionSettings -> GetRetentionSettings -> Bool)
-> (GetRetentionSettings -> GetRetentionSettings -> Bool)
-> Eq GetRetentionSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRetentionSettings -> GetRetentionSettings -> Bool
$c/= :: GetRetentionSettings -> GetRetentionSettings -> Bool
== :: GetRetentionSettings -> GetRetentionSettings -> Bool
$c== :: GetRetentionSettings -> GetRetentionSettings -> Bool
Prelude.Eq, ReadPrec [GetRetentionSettings]
ReadPrec GetRetentionSettings
Int -> ReadS GetRetentionSettings
ReadS [GetRetentionSettings]
(Int -> ReadS GetRetentionSettings)
-> ReadS [GetRetentionSettings]
-> ReadPrec GetRetentionSettings
-> ReadPrec [GetRetentionSettings]
-> Read GetRetentionSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRetentionSettings]
$creadListPrec :: ReadPrec [GetRetentionSettings]
readPrec :: ReadPrec GetRetentionSettings
$creadPrec :: ReadPrec GetRetentionSettings
readList :: ReadS [GetRetentionSettings]
$creadList :: ReadS [GetRetentionSettings]
readsPrec :: Int -> ReadS GetRetentionSettings
$creadsPrec :: Int -> ReadS GetRetentionSettings
Prelude.Read, Int -> GetRetentionSettings -> ShowS
[GetRetentionSettings] -> ShowS
GetRetentionSettings -> String
(Int -> GetRetentionSettings -> ShowS)
-> (GetRetentionSettings -> String)
-> ([GetRetentionSettings] -> ShowS)
-> Show GetRetentionSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRetentionSettings] -> ShowS
$cshowList :: [GetRetentionSettings] -> ShowS
show :: GetRetentionSettings -> String
$cshow :: GetRetentionSettings -> String
showsPrec :: Int -> GetRetentionSettings -> ShowS
$cshowsPrec :: Int -> GetRetentionSettings -> ShowS
Prelude.Show, (forall x. GetRetentionSettings -> Rep GetRetentionSettings x)
-> (forall x. Rep GetRetentionSettings x -> GetRetentionSettings)
-> Generic GetRetentionSettings
forall x. Rep GetRetentionSettings x -> GetRetentionSettings
forall x. GetRetentionSettings -> Rep GetRetentionSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetRetentionSettings x -> GetRetentionSettings
$cfrom :: forall x. GetRetentionSettings -> Rep GetRetentionSettings x
Prelude.Generic)

-- |
-- Create a value of 'GetRetentionSettings' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'accountId', 'getRetentionSettings_accountId' - The Amazon Chime account ID.
newGetRetentionSettings ::
  -- | 'accountId'
  Prelude.Text ->
  GetRetentionSettings
newGetRetentionSettings :: Text -> GetRetentionSettings
newGetRetentionSettings Text
pAccountId_ =
  GetRetentionSettings' :: Text -> GetRetentionSettings
GetRetentionSettings' {$sel:accountId:GetRetentionSettings' :: Text
accountId = Text
pAccountId_}

-- | The Amazon Chime account ID.
getRetentionSettings_accountId :: Lens.Lens' GetRetentionSettings Prelude.Text
getRetentionSettings_accountId :: (Text -> f Text) -> GetRetentionSettings -> f GetRetentionSettings
getRetentionSettings_accountId = (GetRetentionSettings -> Text)
-> (GetRetentionSettings -> Text -> GetRetentionSettings)
-> Lens GetRetentionSettings GetRetentionSettings Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRetentionSettings' {Text
accountId :: Text
$sel:accountId:GetRetentionSettings' :: GetRetentionSettings -> Text
accountId} -> Text
accountId) (\s :: GetRetentionSettings
s@GetRetentionSettings' {} Text
a -> GetRetentionSettings
s {$sel:accountId:GetRetentionSettings' :: Text
accountId = Text
a} :: GetRetentionSettings)

instance Core.AWSRequest GetRetentionSettings where
  type
    AWSResponse GetRetentionSettings =
      GetRetentionSettingsResponse
  request :: GetRetentionSettings -> Request GetRetentionSettings
request = Service -> GetRetentionSettings -> Request GetRetentionSettings
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetRetentionSettings
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetRetentionSettings)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetRetentionSettings))
-> Logger
-> Service
-> Proxy GetRetentionSettings
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetRetentionSettings)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe RetentionSettings
-> Maybe POSIX -> Int -> GetRetentionSettingsResponse
GetRetentionSettingsResponse'
            (Maybe RetentionSettings
 -> Maybe POSIX -> Int -> GetRetentionSettingsResponse)
-> Either String (Maybe RetentionSettings)
-> Either
     String (Maybe POSIX -> Int -> GetRetentionSettingsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe RetentionSettings)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"RetentionSettings")
            Either String (Maybe POSIX -> Int -> GetRetentionSettingsResponse)
-> Either String (Maybe POSIX)
-> Either String (Int -> GetRetentionSettingsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"InitiateDeletionTimestamp")
            Either String (Int -> GetRetentionSettingsResponse)
-> Either String Int -> Either String GetRetentionSettingsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetRetentionSettings

instance Prelude.NFData GetRetentionSettings

instance Core.ToHeaders GetRetentionSettings where
  toHeaders :: GetRetentionSettings -> ResponseHeaders
toHeaders = ResponseHeaders -> GetRetentionSettings -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath GetRetentionSettings where
  toPath :: GetRetentionSettings -> ByteString
toPath GetRetentionSettings' {Text
accountId :: Text
$sel:accountId:GetRetentionSettings' :: GetRetentionSettings -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/accounts/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
accountId,
        ByteString
"/retention-settings"
      ]

instance Core.ToQuery GetRetentionSettings where
  toQuery :: GetRetentionSettings -> QueryString
toQuery = QueryString -> GetRetentionSettings -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newGetRetentionSettingsResponse' smart constructor.
data GetRetentionSettingsResponse = GetRetentionSettingsResponse'
  { -- | The retention settings.
    GetRetentionSettingsResponse -> Maybe RetentionSettings
retentionSettings :: Prelude.Maybe RetentionSettings,
    -- | The timestamp representing the time at which the specified items are
    -- permanently deleted, in ISO 8601 format.
    GetRetentionSettingsResponse -> Maybe POSIX
initiateDeletionTimestamp :: Prelude.Maybe Core.POSIX,
    -- | The response's http status code.
    GetRetentionSettingsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetRetentionSettingsResponse
-> GetRetentionSettingsResponse -> Bool
(GetRetentionSettingsResponse
 -> GetRetentionSettingsResponse -> Bool)
-> (GetRetentionSettingsResponse
    -> GetRetentionSettingsResponse -> Bool)
-> Eq GetRetentionSettingsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRetentionSettingsResponse
-> GetRetentionSettingsResponse -> Bool
$c/= :: GetRetentionSettingsResponse
-> GetRetentionSettingsResponse -> Bool
== :: GetRetentionSettingsResponse
-> GetRetentionSettingsResponse -> Bool
$c== :: GetRetentionSettingsResponse
-> GetRetentionSettingsResponse -> Bool
Prelude.Eq, ReadPrec [GetRetentionSettingsResponse]
ReadPrec GetRetentionSettingsResponse
Int -> ReadS GetRetentionSettingsResponse
ReadS [GetRetentionSettingsResponse]
(Int -> ReadS GetRetentionSettingsResponse)
-> ReadS [GetRetentionSettingsResponse]
-> ReadPrec GetRetentionSettingsResponse
-> ReadPrec [GetRetentionSettingsResponse]
-> Read GetRetentionSettingsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRetentionSettingsResponse]
$creadListPrec :: ReadPrec [GetRetentionSettingsResponse]
readPrec :: ReadPrec GetRetentionSettingsResponse
$creadPrec :: ReadPrec GetRetentionSettingsResponse
readList :: ReadS [GetRetentionSettingsResponse]
$creadList :: ReadS [GetRetentionSettingsResponse]
readsPrec :: Int -> ReadS GetRetentionSettingsResponse
$creadsPrec :: Int -> ReadS GetRetentionSettingsResponse
Prelude.Read, Int -> GetRetentionSettingsResponse -> ShowS
[GetRetentionSettingsResponse] -> ShowS
GetRetentionSettingsResponse -> String
(Int -> GetRetentionSettingsResponse -> ShowS)
-> (GetRetentionSettingsResponse -> String)
-> ([GetRetentionSettingsResponse] -> ShowS)
-> Show GetRetentionSettingsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRetentionSettingsResponse] -> ShowS
$cshowList :: [GetRetentionSettingsResponse] -> ShowS
show :: GetRetentionSettingsResponse -> String
$cshow :: GetRetentionSettingsResponse -> String
showsPrec :: Int -> GetRetentionSettingsResponse -> ShowS
$cshowsPrec :: Int -> GetRetentionSettingsResponse -> ShowS
Prelude.Show, (forall x.
 GetRetentionSettingsResponse -> Rep GetRetentionSettingsResponse x)
-> (forall x.
    Rep GetRetentionSettingsResponse x -> GetRetentionSettingsResponse)
-> Generic GetRetentionSettingsResponse
forall x.
Rep GetRetentionSettingsResponse x -> GetRetentionSettingsResponse
forall x.
GetRetentionSettingsResponse -> Rep GetRetentionSettingsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetRetentionSettingsResponse x -> GetRetentionSettingsResponse
$cfrom :: forall x.
GetRetentionSettingsResponse -> Rep GetRetentionSettingsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetRetentionSettingsResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'retentionSettings', 'getRetentionSettingsResponse_retentionSettings' - The retention settings.
--
-- 'initiateDeletionTimestamp', 'getRetentionSettingsResponse_initiateDeletionTimestamp' - The timestamp representing the time at which the specified items are
-- permanently deleted, in ISO 8601 format.
--
-- 'httpStatus', 'getRetentionSettingsResponse_httpStatus' - The response's http status code.
newGetRetentionSettingsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetRetentionSettingsResponse
newGetRetentionSettingsResponse :: Int -> GetRetentionSettingsResponse
newGetRetentionSettingsResponse Int
pHttpStatus_ =
  GetRetentionSettingsResponse' :: Maybe RetentionSettings
-> Maybe POSIX -> Int -> GetRetentionSettingsResponse
GetRetentionSettingsResponse'
    { $sel:retentionSettings:GetRetentionSettingsResponse' :: Maybe RetentionSettings
retentionSettings =
        Maybe RetentionSettings
forall a. Maybe a
Prelude.Nothing,
      $sel:initiateDeletionTimestamp:GetRetentionSettingsResponse' :: Maybe POSIX
initiateDeletionTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetRetentionSettingsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The retention settings.
getRetentionSettingsResponse_retentionSettings :: Lens.Lens' GetRetentionSettingsResponse (Prelude.Maybe RetentionSettings)
getRetentionSettingsResponse_retentionSettings :: (Maybe RetentionSettings -> f (Maybe RetentionSettings))
-> GetRetentionSettingsResponse -> f GetRetentionSettingsResponse
getRetentionSettingsResponse_retentionSettings = (GetRetentionSettingsResponse -> Maybe RetentionSettings)
-> (GetRetentionSettingsResponse
    -> Maybe RetentionSettings -> GetRetentionSettingsResponse)
-> Lens
     GetRetentionSettingsResponse
     GetRetentionSettingsResponse
     (Maybe RetentionSettings)
     (Maybe RetentionSettings)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRetentionSettingsResponse' {Maybe RetentionSettings
retentionSettings :: Maybe RetentionSettings
$sel:retentionSettings:GetRetentionSettingsResponse' :: GetRetentionSettingsResponse -> Maybe RetentionSettings
retentionSettings} -> Maybe RetentionSettings
retentionSettings) (\s :: GetRetentionSettingsResponse
s@GetRetentionSettingsResponse' {} Maybe RetentionSettings
a -> GetRetentionSettingsResponse
s {$sel:retentionSettings:GetRetentionSettingsResponse' :: Maybe RetentionSettings
retentionSettings = Maybe RetentionSettings
a} :: GetRetentionSettingsResponse)

-- | The timestamp representing the time at which the specified items are
-- permanently deleted, in ISO 8601 format.
getRetentionSettingsResponse_initiateDeletionTimestamp :: Lens.Lens' GetRetentionSettingsResponse (Prelude.Maybe Prelude.UTCTime)
getRetentionSettingsResponse_initiateDeletionTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> GetRetentionSettingsResponse -> f GetRetentionSettingsResponse
getRetentionSettingsResponse_initiateDeletionTimestamp = (GetRetentionSettingsResponse -> Maybe POSIX)
-> (GetRetentionSettingsResponse
    -> Maybe POSIX -> GetRetentionSettingsResponse)
-> Lens
     GetRetentionSettingsResponse
     GetRetentionSettingsResponse
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRetentionSettingsResponse' {Maybe POSIX
initiateDeletionTimestamp :: Maybe POSIX
$sel:initiateDeletionTimestamp:GetRetentionSettingsResponse' :: GetRetentionSettingsResponse -> Maybe POSIX
initiateDeletionTimestamp} -> Maybe POSIX
initiateDeletionTimestamp) (\s :: GetRetentionSettingsResponse
s@GetRetentionSettingsResponse' {} Maybe POSIX
a -> GetRetentionSettingsResponse
s {$sel:initiateDeletionTimestamp:GetRetentionSettingsResponse' :: Maybe POSIX
initiateDeletionTimestamp = Maybe POSIX
a} :: GetRetentionSettingsResponse) ((Maybe POSIX -> f (Maybe POSIX))
 -> GetRetentionSettingsResponse -> f GetRetentionSettingsResponse)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> GetRetentionSettingsResponse
-> f GetRetentionSettingsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The response's http status code.
getRetentionSettingsResponse_httpStatus :: Lens.Lens' GetRetentionSettingsResponse Prelude.Int
getRetentionSettingsResponse_httpStatus :: (Int -> f Int)
-> GetRetentionSettingsResponse -> f GetRetentionSettingsResponse
getRetentionSettingsResponse_httpStatus = (GetRetentionSettingsResponse -> Int)
-> (GetRetentionSettingsResponse
    -> Int -> GetRetentionSettingsResponse)
-> Lens
     GetRetentionSettingsResponse GetRetentionSettingsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRetentionSettingsResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetRetentionSettingsResponse' :: GetRetentionSettingsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetRetentionSettingsResponse
s@GetRetentionSettingsResponse' {} Int
a -> GetRetentionSettingsResponse
s {$sel:httpStatus:GetRetentionSettingsResponse' :: Int
httpStatus = Int
a} :: GetRetentionSettingsResponse)

instance Prelude.NFData GetRetentionSettingsResponse