{-# 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.Kinesis.DecreaseStreamRetentionPeriod
-- 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)
--
-- Decreases the Kinesis data stream\'s retention period, which is the
-- length of time data records are accessible after they are added to the
-- stream. The minimum value of a stream\'s retention period is 24 hours.
--
-- This operation may result in lost data. For example, if the stream\'s
-- retention period is 48 hours and is decreased to 24 hours, any data
-- already in the stream that is older than 24 hours is inaccessible.
module Amazonka.Kinesis.DecreaseStreamRetentionPeriod
  ( -- * Creating a Request
    DecreaseStreamRetentionPeriod (..),
    newDecreaseStreamRetentionPeriod,

    -- * Request Lenses
    decreaseStreamRetentionPeriod_streamName,
    decreaseStreamRetentionPeriod_retentionPeriodHours,

    -- * Destructuring the Response
    DecreaseStreamRetentionPeriodResponse (..),
    newDecreaseStreamRetentionPeriodResponse,
  )
where

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

-- | Represents the input for DecreaseStreamRetentionPeriod.
--
-- /See:/ 'newDecreaseStreamRetentionPeriod' smart constructor.
data DecreaseStreamRetentionPeriod = DecreaseStreamRetentionPeriod'
  { -- | The name of the stream to modify.
    DecreaseStreamRetentionPeriod -> Text
streamName :: Prelude.Text,
    -- | The new retention period of the stream, in hours. Must be less than the
    -- current retention period.
    DecreaseStreamRetentionPeriod -> Int
retentionPeriodHours :: Prelude.Int
  }
  deriving (DecreaseStreamRetentionPeriod
-> DecreaseStreamRetentionPeriod -> Bool
(DecreaseStreamRetentionPeriod
 -> DecreaseStreamRetentionPeriod -> Bool)
-> (DecreaseStreamRetentionPeriod
    -> DecreaseStreamRetentionPeriod -> Bool)
-> Eq DecreaseStreamRetentionPeriod
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DecreaseStreamRetentionPeriod
-> DecreaseStreamRetentionPeriod -> Bool
$c/= :: DecreaseStreamRetentionPeriod
-> DecreaseStreamRetentionPeriod -> Bool
== :: DecreaseStreamRetentionPeriod
-> DecreaseStreamRetentionPeriod -> Bool
$c== :: DecreaseStreamRetentionPeriod
-> DecreaseStreamRetentionPeriod -> Bool
Prelude.Eq, ReadPrec [DecreaseStreamRetentionPeriod]
ReadPrec DecreaseStreamRetentionPeriod
Int -> ReadS DecreaseStreamRetentionPeriod
ReadS [DecreaseStreamRetentionPeriod]
(Int -> ReadS DecreaseStreamRetentionPeriod)
-> ReadS [DecreaseStreamRetentionPeriod]
-> ReadPrec DecreaseStreamRetentionPeriod
-> ReadPrec [DecreaseStreamRetentionPeriod]
-> Read DecreaseStreamRetentionPeriod
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DecreaseStreamRetentionPeriod]
$creadListPrec :: ReadPrec [DecreaseStreamRetentionPeriod]
readPrec :: ReadPrec DecreaseStreamRetentionPeriod
$creadPrec :: ReadPrec DecreaseStreamRetentionPeriod
readList :: ReadS [DecreaseStreamRetentionPeriod]
$creadList :: ReadS [DecreaseStreamRetentionPeriod]
readsPrec :: Int -> ReadS DecreaseStreamRetentionPeriod
$creadsPrec :: Int -> ReadS DecreaseStreamRetentionPeriod
Prelude.Read, Int -> DecreaseStreamRetentionPeriod -> ShowS
[DecreaseStreamRetentionPeriod] -> ShowS
DecreaseStreamRetentionPeriod -> String
(Int -> DecreaseStreamRetentionPeriod -> ShowS)
-> (DecreaseStreamRetentionPeriod -> String)
-> ([DecreaseStreamRetentionPeriod] -> ShowS)
-> Show DecreaseStreamRetentionPeriod
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DecreaseStreamRetentionPeriod] -> ShowS
$cshowList :: [DecreaseStreamRetentionPeriod] -> ShowS
show :: DecreaseStreamRetentionPeriod -> String
$cshow :: DecreaseStreamRetentionPeriod -> String
showsPrec :: Int -> DecreaseStreamRetentionPeriod -> ShowS
$cshowsPrec :: Int -> DecreaseStreamRetentionPeriod -> ShowS
Prelude.Show, (forall x.
 DecreaseStreamRetentionPeriod
 -> Rep DecreaseStreamRetentionPeriod x)
-> (forall x.
    Rep DecreaseStreamRetentionPeriod x
    -> DecreaseStreamRetentionPeriod)
-> Generic DecreaseStreamRetentionPeriod
forall x.
Rep DecreaseStreamRetentionPeriod x
-> DecreaseStreamRetentionPeriod
forall x.
DecreaseStreamRetentionPeriod
-> Rep DecreaseStreamRetentionPeriod x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DecreaseStreamRetentionPeriod x
-> DecreaseStreamRetentionPeriod
$cfrom :: forall x.
DecreaseStreamRetentionPeriod
-> Rep DecreaseStreamRetentionPeriod x
Prelude.Generic)

-- |
-- Create a value of 'DecreaseStreamRetentionPeriod' 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:
--
-- 'streamName', 'decreaseStreamRetentionPeriod_streamName' - The name of the stream to modify.
--
-- 'retentionPeriodHours', 'decreaseStreamRetentionPeriod_retentionPeriodHours' - The new retention period of the stream, in hours. Must be less than the
-- current retention period.
newDecreaseStreamRetentionPeriod ::
  -- | 'streamName'
  Prelude.Text ->
  -- | 'retentionPeriodHours'
  Prelude.Int ->
  DecreaseStreamRetentionPeriod
newDecreaseStreamRetentionPeriod :: Text -> Int -> DecreaseStreamRetentionPeriod
newDecreaseStreamRetentionPeriod
  Text
pStreamName_
  Int
pRetentionPeriodHours_ =
    DecreaseStreamRetentionPeriod' :: Text -> Int -> DecreaseStreamRetentionPeriod
DecreaseStreamRetentionPeriod'
      { $sel:streamName:DecreaseStreamRetentionPeriod' :: Text
streamName =
          Text
pStreamName_,
        $sel:retentionPeriodHours:DecreaseStreamRetentionPeriod' :: Int
retentionPeriodHours =
          Int
pRetentionPeriodHours_
      }

-- | The name of the stream to modify.
decreaseStreamRetentionPeriod_streamName :: Lens.Lens' DecreaseStreamRetentionPeriod Prelude.Text
decreaseStreamRetentionPeriod_streamName :: (Text -> f Text)
-> DecreaseStreamRetentionPeriod -> f DecreaseStreamRetentionPeriod
decreaseStreamRetentionPeriod_streamName = (DecreaseStreamRetentionPeriod -> Text)
-> (DecreaseStreamRetentionPeriod
    -> Text -> DecreaseStreamRetentionPeriod)
-> Lens
     DecreaseStreamRetentionPeriod
     DecreaseStreamRetentionPeriod
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DecreaseStreamRetentionPeriod' {Text
streamName :: Text
$sel:streamName:DecreaseStreamRetentionPeriod' :: DecreaseStreamRetentionPeriod -> Text
streamName} -> Text
streamName) (\s :: DecreaseStreamRetentionPeriod
s@DecreaseStreamRetentionPeriod' {} Text
a -> DecreaseStreamRetentionPeriod
s {$sel:streamName:DecreaseStreamRetentionPeriod' :: Text
streamName = Text
a} :: DecreaseStreamRetentionPeriod)

-- | The new retention period of the stream, in hours. Must be less than the
-- current retention period.
decreaseStreamRetentionPeriod_retentionPeriodHours :: Lens.Lens' DecreaseStreamRetentionPeriod Prelude.Int
decreaseStreamRetentionPeriod_retentionPeriodHours :: (Int -> f Int)
-> DecreaseStreamRetentionPeriod -> f DecreaseStreamRetentionPeriod
decreaseStreamRetentionPeriod_retentionPeriodHours = (DecreaseStreamRetentionPeriod -> Int)
-> (DecreaseStreamRetentionPeriod
    -> Int -> DecreaseStreamRetentionPeriod)
-> Lens
     DecreaseStreamRetentionPeriod DecreaseStreamRetentionPeriod Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DecreaseStreamRetentionPeriod' {Int
retentionPeriodHours :: Int
$sel:retentionPeriodHours:DecreaseStreamRetentionPeriod' :: DecreaseStreamRetentionPeriod -> Int
retentionPeriodHours} -> Int
retentionPeriodHours) (\s :: DecreaseStreamRetentionPeriod
s@DecreaseStreamRetentionPeriod' {} Int
a -> DecreaseStreamRetentionPeriod
s {$sel:retentionPeriodHours:DecreaseStreamRetentionPeriod' :: Int
retentionPeriodHours = Int
a} :: DecreaseStreamRetentionPeriod)

instance
  Core.AWSRequest
    DecreaseStreamRetentionPeriod
  where
  type
    AWSResponse DecreaseStreamRetentionPeriod =
      DecreaseStreamRetentionPeriodResponse
  request :: DecreaseStreamRetentionPeriod
-> Request DecreaseStreamRetentionPeriod
request = Service
-> DecreaseStreamRetentionPeriod
-> Request DecreaseStreamRetentionPeriod
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DecreaseStreamRetentionPeriod
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DecreaseStreamRetentionPeriod)))
response =
    AWSResponse DecreaseStreamRetentionPeriod
-> Logger
-> Service
-> Proxy DecreaseStreamRetentionPeriod
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DecreaseStreamRetentionPeriod)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse DecreaseStreamRetentionPeriod
DecreaseStreamRetentionPeriodResponse
DecreaseStreamRetentionPeriodResponse'

instance
  Prelude.Hashable
    DecreaseStreamRetentionPeriod

instance Prelude.NFData DecreaseStreamRetentionPeriod

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

instance Core.ToJSON DecreaseStreamRetentionPeriod where
  toJSON :: DecreaseStreamRetentionPeriod -> Value
toJSON DecreaseStreamRetentionPeriod' {Int
Text
retentionPeriodHours :: Int
streamName :: Text
$sel:retentionPeriodHours:DecreaseStreamRetentionPeriod' :: DecreaseStreamRetentionPeriod -> Int
$sel:streamName:DecreaseStreamRetentionPeriod' :: DecreaseStreamRetentionPeriod -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"StreamName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
streamName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"RetentionPeriodHours"
                  Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Int
retentionPeriodHours
              )
          ]
      )

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

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

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

-- |
-- Create a value of 'DecreaseStreamRetentionPeriodResponse' 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.
newDecreaseStreamRetentionPeriodResponse ::
  DecreaseStreamRetentionPeriodResponse
newDecreaseStreamRetentionPeriodResponse :: DecreaseStreamRetentionPeriodResponse
newDecreaseStreamRetentionPeriodResponse =
  DecreaseStreamRetentionPeriodResponse
DecreaseStreamRetentionPeriodResponse'

instance
  Prelude.NFData
    DecreaseStreamRetentionPeriodResponse