{-# 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.Config.PutRetentionConfiguration
-- 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)
--
-- Creates and updates the retention configuration with details about
-- retention period (number of days) that Config stores your historical
-- information. The API creates the @RetentionConfiguration@ object and
-- names the object as __default__. When you have a
-- @RetentionConfiguration@ object named __default__, calling the API
-- modifies the default object.
--
-- Currently, Config supports only one retention configuration per region
-- in your account.
module Amazonka.Config.PutRetentionConfiguration
  ( -- * Creating a Request
    PutRetentionConfiguration (..),
    newPutRetentionConfiguration,

    -- * Request Lenses
    putRetentionConfiguration_retentionPeriodInDays,

    -- * Destructuring the Response
    PutRetentionConfigurationResponse (..),
    newPutRetentionConfigurationResponse,

    -- * Response Lenses
    putRetentionConfigurationResponse_retentionConfiguration,
    putRetentionConfigurationResponse_httpStatus,
  )
where

import Amazonka.Config.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:/ 'newPutRetentionConfiguration' smart constructor.
data PutRetentionConfiguration = PutRetentionConfiguration'
  { -- | Number of days Config stores your historical information.
    --
    -- Currently, only applicable to the configuration item history.
    PutRetentionConfiguration -> Natural
retentionPeriodInDays :: Prelude.Natural
  }
  deriving (PutRetentionConfiguration -> PutRetentionConfiguration -> Bool
(PutRetentionConfiguration -> PutRetentionConfiguration -> Bool)
-> (PutRetentionConfiguration -> PutRetentionConfiguration -> Bool)
-> Eq PutRetentionConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutRetentionConfiguration -> PutRetentionConfiguration -> Bool
$c/= :: PutRetentionConfiguration -> PutRetentionConfiguration -> Bool
== :: PutRetentionConfiguration -> PutRetentionConfiguration -> Bool
$c== :: PutRetentionConfiguration -> PutRetentionConfiguration -> Bool
Prelude.Eq, ReadPrec [PutRetentionConfiguration]
ReadPrec PutRetentionConfiguration
Int -> ReadS PutRetentionConfiguration
ReadS [PutRetentionConfiguration]
(Int -> ReadS PutRetentionConfiguration)
-> ReadS [PutRetentionConfiguration]
-> ReadPrec PutRetentionConfiguration
-> ReadPrec [PutRetentionConfiguration]
-> Read PutRetentionConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutRetentionConfiguration]
$creadListPrec :: ReadPrec [PutRetentionConfiguration]
readPrec :: ReadPrec PutRetentionConfiguration
$creadPrec :: ReadPrec PutRetentionConfiguration
readList :: ReadS [PutRetentionConfiguration]
$creadList :: ReadS [PutRetentionConfiguration]
readsPrec :: Int -> ReadS PutRetentionConfiguration
$creadsPrec :: Int -> ReadS PutRetentionConfiguration
Prelude.Read, Int -> PutRetentionConfiguration -> ShowS
[PutRetentionConfiguration] -> ShowS
PutRetentionConfiguration -> String
(Int -> PutRetentionConfiguration -> ShowS)
-> (PutRetentionConfiguration -> String)
-> ([PutRetentionConfiguration] -> ShowS)
-> Show PutRetentionConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutRetentionConfiguration] -> ShowS
$cshowList :: [PutRetentionConfiguration] -> ShowS
show :: PutRetentionConfiguration -> String
$cshow :: PutRetentionConfiguration -> String
showsPrec :: Int -> PutRetentionConfiguration -> ShowS
$cshowsPrec :: Int -> PutRetentionConfiguration -> ShowS
Prelude.Show, (forall x.
 PutRetentionConfiguration -> Rep PutRetentionConfiguration x)
-> (forall x.
    Rep PutRetentionConfiguration x -> PutRetentionConfiguration)
-> Generic PutRetentionConfiguration
forall x.
Rep PutRetentionConfiguration x -> PutRetentionConfiguration
forall x.
PutRetentionConfiguration -> Rep PutRetentionConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutRetentionConfiguration x -> PutRetentionConfiguration
$cfrom :: forall x.
PutRetentionConfiguration -> Rep PutRetentionConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'PutRetentionConfiguration' 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:
--
-- 'retentionPeriodInDays', 'putRetentionConfiguration_retentionPeriodInDays' - Number of days Config stores your historical information.
--
-- Currently, only applicable to the configuration item history.
newPutRetentionConfiguration ::
  -- | 'retentionPeriodInDays'
  Prelude.Natural ->
  PutRetentionConfiguration
newPutRetentionConfiguration :: Natural -> PutRetentionConfiguration
newPutRetentionConfiguration Natural
pRetentionPeriodInDays_ =
  PutRetentionConfiguration' :: Natural -> PutRetentionConfiguration
PutRetentionConfiguration'
    { $sel:retentionPeriodInDays:PutRetentionConfiguration' :: Natural
retentionPeriodInDays =
        Natural
pRetentionPeriodInDays_
    }

-- | Number of days Config stores your historical information.
--
-- Currently, only applicable to the configuration item history.
putRetentionConfiguration_retentionPeriodInDays :: Lens.Lens' PutRetentionConfiguration Prelude.Natural
putRetentionConfiguration_retentionPeriodInDays :: (Natural -> f Natural)
-> PutRetentionConfiguration -> f PutRetentionConfiguration
putRetentionConfiguration_retentionPeriodInDays = (PutRetentionConfiguration -> Natural)
-> (PutRetentionConfiguration
    -> Natural -> PutRetentionConfiguration)
-> Lens
     PutRetentionConfiguration PutRetentionConfiguration Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRetentionConfiguration' {Natural
retentionPeriodInDays :: Natural
$sel:retentionPeriodInDays:PutRetentionConfiguration' :: PutRetentionConfiguration -> Natural
retentionPeriodInDays} -> Natural
retentionPeriodInDays) (\s :: PutRetentionConfiguration
s@PutRetentionConfiguration' {} Natural
a -> PutRetentionConfiguration
s {$sel:retentionPeriodInDays:PutRetentionConfiguration' :: Natural
retentionPeriodInDays = Natural
a} :: PutRetentionConfiguration)

instance Core.AWSRequest PutRetentionConfiguration where
  type
    AWSResponse PutRetentionConfiguration =
      PutRetentionConfigurationResponse
  request :: PutRetentionConfiguration -> Request PutRetentionConfiguration
request = Service
-> PutRetentionConfiguration -> Request PutRetentionConfiguration
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutRetentionConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutRetentionConfiguration)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse PutRetentionConfiguration))
-> Logger
-> Service
-> Proxy PutRetentionConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutRetentionConfiguration)))
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 RetentionConfiguration
-> Int -> PutRetentionConfigurationResponse
PutRetentionConfigurationResponse'
            (Maybe RetentionConfiguration
 -> Int -> PutRetentionConfigurationResponse)
-> Either String (Maybe RetentionConfiguration)
-> Either String (Int -> PutRetentionConfigurationResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Key -> Either String (Maybe RetentionConfiguration)
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"RetentionConfiguration")
            Either String (Int -> PutRetentionConfigurationResponse)
-> Either String Int
-> Either String PutRetentionConfigurationResponse
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 PutRetentionConfiguration

instance Prelude.NFData PutRetentionConfiguration

instance Core.ToHeaders PutRetentionConfiguration where
  toHeaders :: PutRetentionConfiguration -> ResponseHeaders
toHeaders =
    ResponseHeaders -> PutRetentionConfiguration -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"StarlingDoveService.PutRetentionConfiguration" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON PutRetentionConfiguration where
  toJSON :: PutRetentionConfiguration -> Value
toJSON PutRetentionConfiguration' {Natural
retentionPeriodInDays :: Natural
$sel:retentionPeriodInDays:PutRetentionConfiguration' :: PutRetentionConfiguration -> Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Key
"RetentionPeriodInDays"
                  Key -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Core..= Natural
retentionPeriodInDays
              )
          ]
      )

instance Core.ToPath PutRetentionConfiguration where
  toPath :: PutRetentionConfiguration -> ByteString
toPath = ByteString -> PutRetentionConfiguration -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newPutRetentionConfigurationResponse' smart constructor.
data PutRetentionConfigurationResponse = PutRetentionConfigurationResponse'
  { -- | Returns a retention configuration object.
    PutRetentionConfigurationResponse -> Maybe RetentionConfiguration
retentionConfiguration :: Prelude.Maybe RetentionConfiguration,
    -- | The response's http status code.
    PutRetentionConfigurationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutRetentionConfigurationResponse
-> PutRetentionConfigurationResponse -> Bool
(PutRetentionConfigurationResponse
 -> PutRetentionConfigurationResponse -> Bool)
-> (PutRetentionConfigurationResponse
    -> PutRetentionConfigurationResponse -> Bool)
-> Eq PutRetentionConfigurationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutRetentionConfigurationResponse
-> PutRetentionConfigurationResponse -> Bool
$c/= :: PutRetentionConfigurationResponse
-> PutRetentionConfigurationResponse -> Bool
== :: PutRetentionConfigurationResponse
-> PutRetentionConfigurationResponse -> Bool
$c== :: PutRetentionConfigurationResponse
-> PutRetentionConfigurationResponse -> Bool
Prelude.Eq, ReadPrec [PutRetentionConfigurationResponse]
ReadPrec PutRetentionConfigurationResponse
Int -> ReadS PutRetentionConfigurationResponse
ReadS [PutRetentionConfigurationResponse]
(Int -> ReadS PutRetentionConfigurationResponse)
-> ReadS [PutRetentionConfigurationResponse]
-> ReadPrec PutRetentionConfigurationResponse
-> ReadPrec [PutRetentionConfigurationResponse]
-> Read PutRetentionConfigurationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutRetentionConfigurationResponse]
$creadListPrec :: ReadPrec [PutRetentionConfigurationResponse]
readPrec :: ReadPrec PutRetentionConfigurationResponse
$creadPrec :: ReadPrec PutRetentionConfigurationResponse
readList :: ReadS [PutRetentionConfigurationResponse]
$creadList :: ReadS [PutRetentionConfigurationResponse]
readsPrec :: Int -> ReadS PutRetentionConfigurationResponse
$creadsPrec :: Int -> ReadS PutRetentionConfigurationResponse
Prelude.Read, Int -> PutRetentionConfigurationResponse -> ShowS
[PutRetentionConfigurationResponse] -> ShowS
PutRetentionConfigurationResponse -> String
(Int -> PutRetentionConfigurationResponse -> ShowS)
-> (PutRetentionConfigurationResponse -> String)
-> ([PutRetentionConfigurationResponse] -> ShowS)
-> Show PutRetentionConfigurationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutRetentionConfigurationResponse] -> ShowS
$cshowList :: [PutRetentionConfigurationResponse] -> ShowS
show :: PutRetentionConfigurationResponse -> String
$cshow :: PutRetentionConfigurationResponse -> String
showsPrec :: Int -> PutRetentionConfigurationResponse -> ShowS
$cshowsPrec :: Int -> PutRetentionConfigurationResponse -> ShowS
Prelude.Show, (forall x.
 PutRetentionConfigurationResponse
 -> Rep PutRetentionConfigurationResponse x)
-> (forall x.
    Rep PutRetentionConfigurationResponse x
    -> PutRetentionConfigurationResponse)
-> Generic PutRetentionConfigurationResponse
forall x.
Rep PutRetentionConfigurationResponse x
-> PutRetentionConfigurationResponse
forall x.
PutRetentionConfigurationResponse
-> Rep PutRetentionConfigurationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutRetentionConfigurationResponse x
-> PutRetentionConfigurationResponse
$cfrom :: forall x.
PutRetentionConfigurationResponse
-> Rep PutRetentionConfigurationResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutRetentionConfigurationResponse' 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:
--
-- 'retentionConfiguration', 'putRetentionConfigurationResponse_retentionConfiguration' - Returns a retention configuration object.
--
-- 'httpStatus', 'putRetentionConfigurationResponse_httpStatus' - The response's http status code.
newPutRetentionConfigurationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutRetentionConfigurationResponse
newPutRetentionConfigurationResponse :: Int -> PutRetentionConfigurationResponse
newPutRetentionConfigurationResponse Int
pHttpStatus_ =
  PutRetentionConfigurationResponse' :: Maybe RetentionConfiguration
-> Int -> PutRetentionConfigurationResponse
PutRetentionConfigurationResponse'
    { $sel:retentionConfiguration:PutRetentionConfigurationResponse' :: Maybe RetentionConfiguration
retentionConfiguration =
        Maybe RetentionConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:PutRetentionConfigurationResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Returns a retention configuration object.
putRetentionConfigurationResponse_retentionConfiguration :: Lens.Lens' PutRetentionConfigurationResponse (Prelude.Maybe RetentionConfiguration)
putRetentionConfigurationResponse_retentionConfiguration :: (Maybe RetentionConfiguration -> f (Maybe RetentionConfiguration))
-> PutRetentionConfigurationResponse
-> f PutRetentionConfigurationResponse
putRetentionConfigurationResponse_retentionConfiguration = (PutRetentionConfigurationResponse -> Maybe RetentionConfiguration)
-> (PutRetentionConfigurationResponse
    -> Maybe RetentionConfiguration
    -> PutRetentionConfigurationResponse)
-> Lens
     PutRetentionConfigurationResponse
     PutRetentionConfigurationResponse
     (Maybe RetentionConfiguration)
     (Maybe RetentionConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRetentionConfigurationResponse' {Maybe RetentionConfiguration
retentionConfiguration :: Maybe RetentionConfiguration
$sel:retentionConfiguration:PutRetentionConfigurationResponse' :: PutRetentionConfigurationResponse -> Maybe RetentionConfiguration
retentionConfiguration} -> Maybe RetentionConfiguration
retentionConfiguration) (\s :: PutRetentionConfigurationResponse
s@PutRetentionConfigurationResponse' {} Maybe RetentionConfiguration
a -> PutRetentionConfigurationResponse
s {$sel:retentionConfiguration:PutRetentionConfigurationResponse' :: Maybe RetentionConfiguration
retentionConfiguration = Maybe RetentionConfiguration
a} :: PutRetentionConfigurationResponse)

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

instance
  Prelude.NFData
    PutRetentionConfigurationResponse