{-# 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.GetResourceConfigHistory
-- 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)
--
-- Returns a list of @ConfigurationItems@ for the specified resource. The
-- list contains details about each state of the resource during the
-- specified time interval. If you specified a retention period to retain
-- your @ConfigurationItems@ between a minimum of 30 days and a maximum of
-- 7 years (2557 days), Config returns the @ConfigurationItems@ for the
-- specified retention period.
--
-- The response is paginated. By default, Config returns a limit of 10
-- configuration items per page. You can customize this number with the
-- @limit@ parameter. The response includes a @nextToken@ string. To get
-- the next page of results, run the request again and specify the string
-- for the @nextToken@ parameter.
--
-- Each call to the API is limited to span a duration of seven days. It is
-- likely that the number of records returned is smaller than the specified
-- @limit@. In such cases, you can make another call, using the
-- @nextToken@.
--
-- This operation returns paginated results.
module Amazonka.Config.GetResourceConfigHistory
  ( -- * Creating a Request
    GetResourceConfigHistory (..),
    newGetResourceConfigHistory,

    -- * Request Lenses
    getResourceConfigHistory_chronologicalOrder,
    getResourceConfigHistory_nextToken,
    getResourceConfigHistory_limit,
    getResourceConfigHistory_laterTime,
    getResourceConfigHistory_earlierTime,
    getResourceConfigHistory_resourceType,
    getResourceConfigHistory_resourceId,

    -- * Destructuring the Response
    GetResourceConfigHistoryResponse (..),
    newGetResourceConfigHistoryResponse,

    -- * Response Lenses
    getResourceConfigHistoryResponse_nextToken,
    getResourceConfigHistoryResponse_configurationItems,
    getResourceConfigHistoryResponse_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

-- | The input for the GetResourceConfigHistory action.
--
-- /See:/ 'newGetResourceConfigHistory' smart constructor.
data GetResourceConfigHistory = GetResourceConfigHistory'
  { -- | The chronological order for configuration items listed. By default, the
    -- results are listed in reverse chronological order.
    GetResourceConfigHistory -> Maybe ChronologicalOrder
chronologicalOrder :: Prelude.Maybe ChronologicalOrder,
    -- | The @nextToken@ string returned on a previous page that you use to get
    -- the next page of results in a paginated response.
    GetResourceConfigHistory -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of configuration items returned on each page. The
    -- default is 10. You cannot specify a number greater than 100. If you
    -- specify 0, Config uses the default.
    GetResourceConfigHistory -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | The time stamp that indicates a later time. If not specified, current
    -- time is taken.
    GetResourceConfigHistory -> Maybe POSIX
laterTime :: Prelude.Maybe Core.POSIX,
    -- | The time stamp that indicates an earlier time. If not specified, the
    -- action returns paginated results that contain configuration items that
    -- start when the first configuration item was recorded.
    GetResourceConfigHistory -> Maybe POSIX
earlierTime :: Prelude.Maybe Core.POSIX,
    -- | The resource type.
    GetResourceConfigHistory -> ResourceType
resourceType :: ResourceType,
    -- | The ID of the resource (for example., @sg-xxxxxx@).
    GetResourceConfigHistory -> Text
resourceId :: Prelude.Text
  }
  deriving (GetResourceConfigHistory -> GetResourceConfigHistory -> Bool
(GetResourceConfigHistory -> GetResourceConfigHistory -> Bool)
-> (GetResourceConfigHistory -> GetResourceConfigHistory -> Bool)
-> Eq GetResourceConfigHistory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetResourceConfigHistory -> GetResourceConfigHistory -> Bool
$c/= :: GetResourceConfigHistory -> GetResourceConfigHistory -> Bool
== :: GetResourceConfigHistory -> GetResourceConfigHistory -> Bool
$c== :: GetResourceConfigHistory -> GetResourceConfigHistory -> Bool
Prelude.Eq, ReadPrec [GetResourceConfigHistory]
ReadPrec GetResourceConfigHistory
Int -> ReadS GetResourceConfigHistory
ReadS [GetResourceConfigHistory]
(Int -> ReadS GetResourceConfigHistory)
-> ReadS [GetResourceConfigHistory]
-> ReadPrec GetResourceConfigHistory
-> ReadPrec [GetResourceConfigHistory]
-> Read GetResourceConfigHistory
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetResourceConfigHistory]
$creadListPrec :: ReadPrec [GetResourceConfigHistory]
readPrec :: ReadPrec GetResourceConfigHistory
$creadPrec :: ReadPrec GetResourceConfigHistory
readList :: ReadS [GetResourceConfigHistory]
$creadList :: ReadS [GetResourceConfigHistory]
readsPrec :: Int -> ReadS GetResourceConfigHistory
$creadsPrec :: Int -> ReadS GetResourceConfigHistory
Prelude.Read, Int -> GetResourceConfigHistory -> ShowS
[GetResourceConfigHistory] -> ShowS
GetResourceConfigHistory -> String
(Int -> GetResourceConfigHistory -> ShowS)
-> (GetResourceConfigHistory -> String)
-> ([GetResourceConfigHistory] -> ShowS)
-> Show GetResourceConfigHistory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetResourceConfigHistory] -> ShowS
$cshowList :: [GetResourceConfigHistory] -> ShowS
show :: GetResourceConfigHistory -> String
$cshow :: GetResourceConfigHistory -> String
showsPrec :: Int -> GetResourceConfigHistory -> ShowS
$cshowsPrec :: Int -> GetResourceConfigHistory -> ShowS
Prelude.Show, (forall x.
 GetResourceConfigHistory -> Rep GetResourceConfigHistory x)
-> (forall x.
    Rep GetResourceConfigHistory x -> GetResourceConfigHistory)
-> Generic GetResourceConfigHistory
forall x.
Rep GetResourceConfigHistory x -> GetResourceConfigHistory
forall x.
GetResourceConfigHistory -> Rep GetResourceConfigHistory x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetResourceConfigHistory x -> GetResourceConfigHistory
$cfrom :: forall x.
GetResourceConfigHistory -> Rep GetResourceConfigHistory x
Prelude.Generic)

-- |
-- Create a value of 'GetResourceConfigHistory' 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:
--
-- 'chronologicalOrder', 'getResourceConfigHistory_chronologicalOrder' - The chronological order for configuration items listed. By default, the
-- results are listed in reverse chronological order.
--
-- 'nextToken', 'getResourceConfigHistory_nextToken' - The @nextToken@ string returned on a previous page that you use to get
-- the next page of results in a paginated response.
--
-- 'limit', 'getResourceConfigHistory_limit' - The maximum number of configuration items returned on each page. The
-- default is 10. You cannot specify a number greater than 100. If you
-- specify 0, Config uses the default.
--
-- 'laterTime', 'getResourceConfigHistory_laterTime' - The time stamp that indicates a later time. If not specified, current
-- time is taken.
--
-- 'earlierTime', 'getResourceConfigHistory_earlierTime' - The time stamp that indicates an earlier time. If not specified, the
-- action returns paginated results that contain configuration items that
-- start when the first configuration item was recorded.
--
-- 'resourceType', 'getResourceConfigHistory_resourceType' - The resource type.
--
-- 'resourceId', 'getResourceConfigHistory_resourceId' - The ID of the resource (for example., @sg-xxxxxx@).
newGetResourceConfigHistory ::
  -- | 'resourceType'
  ResourceType ->
  -- | 'resourceId'
  Prelude.Text ->
  GetResourceConfigHistory
newGetResourceConfigHistory :: ResourceType -> Text -> GetResourceConfigHistory
newGetResourceConfigHistory
  ResourceType
pResourceType_
  Text
pResourceId_ =
    GetResourceConfigHistory' :: Maybe ChronologicalOrder
-> Maybe Text
-> Maybe Natural
-> Maybe POSIX
-> Maybe POSIX
-> ResourceType
-> Text
-> GetResourceConfigHistory
GetResourceConfigHistory'
      { $sel:chronologicalOrder:GetResourceConfigHistory' :: Maybe ChronologicalOrder
chronologicalOrder =
          Maybe ChronologicalOrder
forall a. Maybe a
Prelude.Nothing,
        $sel:nextToken:GetResourceConfigHistory' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:limit:GetResourceConfigHistory' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:laterTime:GetResourceConfigHistory' :: Maybe POSIX
laterTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
        $sel:earlierTime:GetResourceConfigHistory' :: Maybe POSIX
earlierTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
        $sel:resourceType:GetResourceConfigHistory' :: ResourceType
resourceType = ResourceType
pResourceType_,
        $sel:resourceId:GetResourceConfigHistory' :: Text
resourceId = Text
pResourceId_
      }

-- | The chronological order for configuration items listed. By default, the
-- results are listed in reverse chronological order.
getResourceConfigHistory_chronologicalOrder :: Lens.Lens' GetResourceConfigHistory (Prelude.Maybe ChronologicalOrder)
getResourceConfigHistory_chronologicalOrder :: (Maybe ChronologicalOrder -> f (Maybe ChronologicalOrder))
-> GetResourceConfigHistory -> f GetResourceConfigHistory
getResourceConfigHistory_chronologicalOrder = (GetResourceConfigHistory -> Maybe ChronologicalOrder)
-> (GetResourceConfigHistory
    -> Maybe ChronologicalOrder -> GetResourceConfigHistory)
-> Lens
     GetResourceConfigHistory
     GetResourceConfigHistory
     (Maybe ChronologicalOrder)
     (Maybe ChronologicalOrder)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceConfigHistory' {Maybe ChronologicalOrder
chronologicalOrder :: Maybe ChronologicalOrder
$sel:chronologicalOrder:GetResourceConfigHistory' :: GetResourceConfigHistory -> Maybe ChronologicalOrder
chronologicalOrder} -> Maybe ChronologicalOrder
chronologicalOrder) (\s :: GetResourceConfigHistory
s@GetResourceConfigHistory' {} Maybe ChronologicalOrder
a -> GetResourceConfigHistory
s {$sel:chronologicalOrder:GetResourceConfigHistory' :: Maybe ChronologicalOrder
chronologicalOrder = Maybe ChronologicalOrder
a} :: GetResourceConfigHistory)

-- | The @nextToken@ string returned on a previous page that you use to get
-- the next page of results in a paginated response.
getResourceConfigHistory_nextToken :: Lens.Lens' GetResourceConfigHistory (Prelude.Maybe Prelude.Text)
getResourceConfigHistory_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetResourceConfigHistory -> f GetResourceConfigHistory
getResourceConfigHistory_nextToken = (GetResourceConfigHistory -> Maybe Text)
-> (GetResourceConfigHistory
    -> Maybe Text -> GetResourceConfigHistory)
-> Lens
     GetResourceConfigHistory
     GetResourceConfigHistory
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceConfigHistory' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetResourceConfigHistory' :: GetResourceConfigHistory -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetResourceConfigHistory
s@GetResourceConfigHistory' {} Maybe Text
a -> GetResourceConfigHistory
s {$sel:nextToken:GetResourceConfigHistory' :: Maybe Text
nextToken = Maybe Text
a} :: GetResourceConfigHistory)

-- | The maximum number of configuration items returned on each page. The
-- default is 10. You cannot specify a number greater than 100. If you
-- specify 0, Config uses the default.
getResourceConfigHistory_limit :: Lens.Lens' GetResourceConfigHistory (Prelude.Maybe Prelude.Natural)
getResourceConfigHistory_limit :: (Maybe Natural -> f (Maybe Natural))
-> GetResourceConfigHistory -> f GetResourceConfigHistory
getResourceConfigHistory_limit = (GetResourceConfigHistory -> Maybe Natural)
-> (GetResourceConfigHistory
    -> Maybe Natural -> GetResourceConfigHistory)
-> Lens
     GetResourceConfigHistory
     GetResourceConfigHistory
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceConfigHistory' {Maybe Natural
limit :: Maybe Natural
$sel:limit:GetResourceConfigHistory' :: GetResourceConfigHistory -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: GetResourceConfigHistory
s@GetResourceConfigHistory' {} Maybe Natural
a -> GetResourceConfigHistory
s {$sel:limit:GetResourceConfigHistory' :: Maybe Natural
limit = Maybe Natural
a} :: GetResourceConfigHistory)

-- | The time stamp that indicates a later time. If not specified, current
-- time is taken.
getResourceConfigHistory_laterTime :: Lens.Lens' GetResourceConfigHistory (Prelude.Maybe Prelude.UTCTime)
getResourceConfigHistory_laterTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> GetResourceConfigHistory -> f GetResourceConfigHistory
getResourceConfigHistory_laterTime = (GetResourceConfigHistory -> Maybe POSIX)
-> (GetResourceConfigHistory
    -> Maybe POSIX -> GetResourceConfigHistory)
-> Lens
     GetResourceConfigHistory
     GetResourceConfigHistory
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceConfigHistory' {Maybe POSIX
laterTime :: Maybe POSIX
$sel:laterTime:GetResourceConfigHistory' :: GetResourceConfigHistory -> Maybe POSIX
laterTime} -> Maybe POSIX
laterTime) (\s :: GetResourceConfigHistory
s@GetResourceConfigHistory' {} Maybe POSIX
a -> GetResourceConfigHistory
s {$sel:laterTime:GetResourceConfigHistory' :: Maybe POSIX
laterTime = Maybe POSIX
a} :: GetResourceConfigHistory) ((Maybe POSIX -> f (Maybe POSIX))
 -> GetResourceConfigHistory -> f GetResourceConfigHistory)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> GetResourceConfigHistory
-> f GetResourceConfigHistory
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 time stamp that indicates an earlier time. If not specified, the
-- action returns paginated results that contain configuration items that
-- start when the first configuration item was recorded.
getResourceConfigHistory_earlierTime :: Lens.Lens' GetResourceConfigHistory (Prelude.Maybe Prelude.UTCTime)
getResourceConfigHistory_earlierTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> GetResourceConfigHistory -> f GetResourceConfigHistory
getResourceConfigHistory_earlierTime = (GetResourceConfigHistory -> Maybe POSIX)
-> (GetResourceConfigHistory
    -> Maybe POSIX -> GetResourceConfigHistory)
-> Lens
     GetResourceConfigHistory
     GetResourceConfigHistory
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceConfigHistory' {Maybe POSIX
earlierTime :: Maybe POSIX
$sel:earlierTime:GetResourceConfigHistory' :: GetResourceConfigHistory -> Maybe POSIX
earlierTime} -> Maybe POSIX
earlierTime) (\s :: GetResourceConfigHistory
s@GetResourceConfigHistory' {} Maybe POSIX
a -> GetResourceConfigHistory
s {$sel:earlierTime:GetResourceConfigHistory' :: Maybe POSIX
earlierTime = Maybe POSIX
a} :: GetResourceConfigHistory) ((Maybe POSIX -> f (Maybe POSIX))
 -> GetResourceConfigHistory -> f GetResourceConfigHistory)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> GetResourceConfigHistory
-> f GetResourceConfigHistory
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 resource type.
getResourceConfigHistory_resourceType :: Lens.Lens' GetResourceConfigHistory ResourceType
getResourceConfigHistory_resourceType :: (ResourceType -> f ResourceType)
-> GetResourceConfigHistory -> f GetResourceConfigHistory
getResourceConfigHistory_resourceType = (GetResourceConfigHistory -> ResourceType)
-> (GetResourceConfigHistory
    -> ResourceType -> GetResourceConfigHistory)
-> Lens
     GetResourceConfigHistory
     GetResourceConfigHistory
     ResourceType
     ResourceType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceConfigHistory' {ResourceType
resourceType :: ResourceType
$sel:resourceType:GetResourceConfigHistory' :: GetResourceConfigHistory -> ResourceType
resourceType} -> ResourceType
resourceType) (\s :: GetResourceConfigHistory
s@GetResourceConfigHistory' {} ResourceType
a -> GetResourceConfigHistory
s {$sel:resourceType:GetResourceConfigHistory' :: ResourceType
resourceType = ResourceType
a} :: GetResourceConfigHistory)

-- | The ID of the resource (for example., @sg-xxxxxx@).
getResourceConfigHistory_resourceId :: Lens.Lens' GetResourceConfigHistory Prelude.Text
getResourceConfigHistory_resourceId :: (Text -> f Text)
-> GetResourceConfigHistory -> f GetResourceConfigHistory
getResourceConfigHistory_resourceId = (GetResourceConfigHistory -> Text)
-> (GetResourceConfigHistory -> Text -> GetResourceConfigHistory)
-> Lens GetResourceConfigHistory GetResourceConfigHistory Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceConfigHistory' {Text
resourceId :: Text
$sel:resourceId:GetResourceConfigHistory' :: GetResourceConfigHistory -> Text
resourceId} -> Text
resourceId) (\s :: GetResourceConfigHistory
s@GetResourceConfigHistory' {} Text
a -> GetResourceConfigHistory
s {$sel:resourceId:GetResourceConfigHistory' :: Text
resourceId = Text
a} :: GetResourceConfigHistory)

instance Core.AWSPager GetResourceConfigHistory where
  page :: GetResourceConfigHistory
-> AWSResponse GetResourceConfigHistory
-> Maybe GetResourceConfigHistory
page GetResourceConfigHistory
rq AWSResponse GetResourceConfigHistory
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetResourceConfigHistory
GetResourceConfigHistoryResponse
rs
            GetResourceConfigHistoryResponse
-> Getting (First Text) GetResourceConfigHistoryResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetResourceConfigHistoryResponse
-> Const (First Text) GetResourceConfigHistoryResponse
Lens' GetResourceConfigHistoryResponse (Maybe Text)
getResourceConfigHistoryResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetResourceConfigHistoryResponse
 -> Const (First Text) GetResourceConfigHistoryResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetResourceConfigHistoryResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe GetResourceConfigHistory
forall a. Maybe a
Prelude.Nothing
    | Maybe [ConfigurationItem] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetResourceConfigHistory
GetResourceConfigHistoryResponse
rs
            GetResourceConfigHistoryResponse
-> Getting
     (First [ConfigurationItem])
     GetResourceConfigHistoryResponse
     [ConfigurationItem]
-> Maybe [ConfigurationItem]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [ConfigurationItem]
 -> Const (First [ConfigurationItem]) (Maybe [ConfigurationItem]))
-> GetResourceConfigHistoryResponse
-> Const
     (First [ConfigurationItem]) GetResourceConfigHistoryResponse
Lens' GetResourceConfigHistoryResponse (Maybe [ConfigurationItem])
getResourceConfigHistoryResponse_configurationItems
              ((Maybe [ConfigurationItem]
  -> Const (First [ConfigurationItem]) (Maybe [ConfigurationItem]))
 -> GetResourceConfigHistoryResponse
 -> Const
      (First [ConfigurationItem]) GetResourceConfigHistoryResponse)
-> (([ConfigurationItem]
     -> Const (First [ConfigurationItem]) [ConfigurationItem])
    -> Maybe [ConfigurationItem]
    -> Const (First [ConfigurationItem]) (Maybe [ConfigurationItem]))
-> Getting
     (First [ConfigurationItem])
     GetResourceConfigHistoryResponse
     [ConfigurationItem]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ConfigurationItem]
 -> Const (First [ConfigurationItem]) [ConfigurationItem])
-> Maybe [ConfigurationItem]
-> Const (First [ConfigurationItem]) (Maybe [ConfigurationItem])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe GetResourceConfigHistory
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      GetResourceConfigHistory -> Maybe GetResourceConfigHistory
forall a. a -> Maybe a
Prelude.Just (GetResourceConfigHistory -> Maybe GetResourceConfigHistory)
-> GetResourceConfigHistory -> Maybe GetResourceConfigHistory
forall a b. (a -> b) -> a -> b
Prelude.$
        GetResourceConfigHistory
rq
          GetResourceConfigHistory
-> (GetResourceConfigHistory -> GetResourceConfigHistory)
-> GetResourceConfigHistory
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> GetResourceConfigHistory -> Identity GetResourceConfigHistory
Lens
  GetResourceConfigHistory
  GetResourceConfigHistory
  (Maybe Text)
  (Maybe Text)
getResourceConfigHistory_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> GetResourceConfigHistory -> Identity GetResourceConfigHistory)
-> Maybe Text
-> GetResourceConfigHistory
-> GetResourceConfigHistory
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetResourceConfigHistory
GetResourceConfigHistoryResponse
rs
          GetResourceConfigHistoryResponse
-> Getting (First Text) GetResourceConfigHistoryResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetResourceConfigHistoryResponse
-> Const (First Text) GetResourceConfigHistoryResponse
Lens' GetResourceConfigHistoryResponse (Maybe Text)
getResourceConfigHistoryResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetResourceConfigHistoryResponse
 -> Const (First Text) GetResourceConfigHistoryResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetResourceConfigHistoryResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest GetResourceConfigHistory where
  type
    AWSResponse GetResourceConfigHistory =
      GetResourceConfigHistoryResponse
  request :: GetResourceConfigHistory -> Request GetResourceConfigHistory
request = Service
-> GetResourceConfigHistory -> Request GetResourceConfigHistory
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetResourceConfigHistory
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetResourceConfigHistory)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetResourceConfigHistory))
-> Logger
-> Service
-> Proxy GetResourceConfigHistory
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetResourceConfigHistory)))
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 Text
-> Maybe [ConfigurationItem]
-> Int
-> GetResourceConfigHistoryResponse
GetResourceConfigHistoryResponse'
            (Maybe Text
 -> Maybe [ConfigurationItem]
 -> Int
 -> GetResourceConfigHistoryResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [ConfigurationItem]
      -> Int -> GetResourceConfigHistoryResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"nextToken")
            Either
  String
  (Maybe [ConfigurationItem]
   -> Int -> GetResourceConfigHistoryResponse)
-> Either String (Maybe [ConfigurationItem])
-> Either String (Int -> GetResourceConfigHistoryResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Either String (Maybe (Maybe [ConfigurationItem]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"configurationItems"
                            Either String (Maybe (Maybe [ConfigurationItem]))
-> Maybe [ConfigurationItem]
-> Either String (Maybe [ConfigurationItem])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ConfigurationItem]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Int -> GetResourceConfigHistoryResponse)
-> Either String Int
-> Either String GetResourceConfigHistoryResponse
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 GetResourceConfigHistory

instance Prelude.NFData GetResourceConfigHistory

instance Core.ToHeaders GetResourceConfigHistory where
  toHeaders :: GetResourceConfigHistory -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetResourceConfigHistory -> 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.GetResourceConfigHistory" ::
                          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 GetResourceConfigHistory where
  toJSON :: GetResourceConfigHistory -> Value
toJSON GetResourceConfigHistory' {Maybe Natural
Maybe Text
Maybe POSIX
Maybe ChronologicalOrder
Text
ResourceType
resourceId :: Text
resourceType :: ResourceType
earlierTime :: Maybe POSIX
laterTime :: Maybe POSIX
limit :: Maybe Natural
nextToken :: Maybe Text
chronologicalOrder :: Maybe ChronologicalOrder
$sel:resourceId:GetResourceConfigHistory' :: GetResourceConfigHistory -> Text
$sel:resourceType:GetResourceConfigHistory' :: GetResourceConfigHistory -> ResourceType
$sel:earlierTime:GetResourceConfigHistory' :: GetResourceConfigHistory -> Maybe POSIX
$sel:laterTime:GetResourceConfigHistory' :: GetResourceConfigHistory -> Maybe POSIX
$sel:limit:GetResourceConfigHistory' :: GetResourceConfigHistory -> Maybe Natural
$sel:nextToken:GetResourceConfigHistory' :: GetResourceConfigHistory -> Maybe Text
$sel:chronologicalOrder:GetResourceConfigHistory' :: GetResourceConfigHistory -> Maybe ChronologicalOrder
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"chronologicalOrder" Text -> ChronologicalOrder -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ChronologicalOrder -> Pair)
-> Maybe ChronologicalOrder -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ChronologicalOrder
chronologicalOrder,
            (Text
"nextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"limit" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
limit,
            (Text
"laterTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
laterTime,
            (Text
"earlierTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
earlierTime,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"resourceType" Text -> ResourceType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ResourceType
resourceType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"resourceId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resourceId)
          ]
      )

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

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

-- | The output for the GetResourceConfigHistory action.
--
-- /See:/ 'newGetResourceConfigHistoryResponse' smart constructor.
data GetResourceConfigHistoryResponse = GetResourceConfigHistoryResponse'
  { -- | The string that you use in a subsequent request to get the next page of
    -- results in a paginated response.
    GetResourceConfigHistoryResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A list that contains the configuration history of one or more resources.
    GetResourceConfigHistoryResponse -> Maybe [ConfigurationItem]
configurationItems :: Prelude.Maybe [ConfigurationItem],
    -- | The response's http status code.
    GetResourceConfigHistoryResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetResourceConfigHistoryResponse
-> GetResourceConfigHistoryResponse -> Bool
(GetResourceConfigHistoryResponse
 -> GetResourceConfigHistoryResponse -> Bool)
-> (GetResourceConfigHistoryResponse
    -> GetResourceConfigHistoryResponse -> Bool)
-> Eq GetResourceConfigHistoryResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetResourceConfigHistoryResponse
-> GetResourceConfigHistoryResponse -> Bool
$c/= :: GetResourceConfigHistoryResponse
-> GetResourceConfigHistoryResponse -> Bool
== :: GetResourceConfigHistoryResponse
-> GetResourceConfigHistoryResponse -> Bool
$c== :: GetResourceConfigHistoryResponse
-> GetResourceConfigHistoryResponse -> Bool
Prelude.Eq, ReadPrec [GetResourceConfigHistoryResponse]
ReadPrec GetResourceConfigHistoryResponse
Int -> ReadS GetResourceConfigHistoryResponse
ReadS [GetResourceConfigHistoryResponse]
(Int -> ReadS GetResourceConfigHistoryResponse)
-> ReadS [GetResourceConfigHistoryResponse]
-> ReadPrec GetResourceConfigHistoryResponse
-> ReadPrec [GetResourceConfigHistoryResponse]
-> Read GetResourceConfigHistoryResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetResourceConfigHistoryResponse]
$creadListPrec :: ReadPrec [GetResourceConfigHistoryResponse]
readPrec :: ReadPrec GetResourceConfigHistoryResponse
$creadPrec :: ReadPrec GetResourceConfigHistoryResponse
readList :: ReadS [GetResourceConfigHistoryResponse]
$creadList :: ReadS [GetResourceConfigHistoryResponse]
readsPrec :: Int -> ReadS GetResourceConfigHistoryResponse
$creadsPrec :: Int -> ReadS GetResourceConfigHistoryResponse
Prelude.Read, Int -> GetResourceConfigHistoryResponse -> ShowS
[GetResourceConfigHistoryResponse] -> ShowS
GetResourceConfigHistoryResponse -> String
(Int -> GetResourceConfigHistoryResponse -> ShowS)
-> (GetResourceConfigHistoryResponse -> String)
-> ([GetResourceConfigHistoryResponse] -> ShowS)
-> Show GetResourceConfigHistoryResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetResourceConfigHistoryResponse] -> ShowS
$cshowList :: [GetResourceConfigHistoryResponse] -> ShowS
show :: GetResourceConfigHistoryResponse -> String
$cshow :: GetResourceConfigHistoryResponse -> String
showsPrec :: Int -> GetResourceConfigHistoryResponse -> ShowS
$cshowsPrec :: Int -> GetResourceConfigHistoryResponse -> ShowS
Prelude.Show, (forall x.
 GetResourceConfigHistoryResponse
 -> Rep GetResourceConfigHistoryResponse x)
-> (forall x.
    Rep GetResourceConfigHistoryResponse x
    -> GetResourceConfigHistoryResponse)
-> Generic GetResourceConfigHistoryResponse
forall x.
Rep GetResourceConfigHistoryResponse x
-> GetResourceConfigHistoryResponse
forall x.
GetResourceConfigHistoryResponse
-> Rep GetResourceConfigHistoryResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetResourceConfigHistoryResponse x
-> GetResourceConfigHistoryResponse
$cfrom :: forall x.
GetResourceConfigHistoryResponse
-> Rep GetResourceConfigHistoryResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetResourceConfigHistoryResponse' 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:
--
-- 'nextToken', 'getResourceConfigHistoryResponse_nextToken' - The string that you use in a subsequent request to get the next page of
-- results in a paginated response.
--
-- 'configurationItems', 'getResourceConfigHistoryResponse_configurationItems' - A list that contains the configuration history of one or more resources.
--
-- 'httpStatus', 'getResourceConfigHistoryResponse_httpStatus' - The response's http status code.
newGetResourceConfigHistoryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetResourceConfigHistoryResponse
newGetResourceConfigHistoryResponse :: Int -> GetResourceConfigHistoryResponse
newGetResourceConfigHistoryResponse Int
pHttpStatus_ =
  GetResourceConfigHistoryResponse' :: Maybe Text
-> Maybe [ConfigurationItem]
-> Int
-> GetResourceConfigHistoryResponse
GetResourceConfigHistoryResponse'
    { $sel:nextToken:GetResourceConfigHistoryResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:configurationItems:GetResourceConfigHistoryResponse' :: Maybe [ConfigurationItem]
configurationItems = Maybe [ConfigurationItem]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetResourceConfigHistoryResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The string that you use in a subsequent request to get the next page of
-- results in a paginated response.
getResourceConfigHistoryResponse_nextToken :: Lens.Lens' GetResourceConfigHistoryResponse (Prelude.Maybe Prelude.Text)
getResourceConfigHistoryResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetResourceConfigHistoryResponse
-> f GetResourceConfigHistoryResponse
getResourceConfigHistoryResponse_nextToken = (GetResourceConfigHistoryResponse -> Maybe Text)
-> (GetResourceConfigHistoryResponse
    -> Maybe Text -> GetResourceConfigHistoryResponse)
-> Lens' GetResourceConfigHistoryResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceConfigHistoryResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetResourceConfigHistoryResponse' :: GetResourceConfigHistoryResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetResourceConfigHistoryResponse
s@GetResourceConfigHistoryResponse' {} Maybe Text
a -> GetResourceConfigHistoryResponse
s {$sel:nextToken:GetResourceConfigHistoryResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetResourceConfigHistoryResponse)

-- | A list that contains the configuration history of one or more resources.
getResourceConfigHistoryResponse_configurationItems :: Lens.Lens' GetResourceConfigHistoryResponse (Prelude.Maybe [ConfigurationItem])
getResourceConfigHistoryResponse_configurationItems :: (Maybe [ConfigurationItem] -> f (Maybe [ConfigurationItem]))
-> GetResourceConfigHistoryResponse
-> f GetResourceConfigHistoryResponse
getResourceConfigHistoryResponse_configurationItems = (GetResourceConfigHistoryResponse -> Maybe [ConfigurationItem])
-> (GetResourceConfigHistoryResponse
    -> Maybe [ConfigurationItem] -> GetResourceConfigHistoryResponse)
-> Lens'
     GetResourceConfigHistoryResponse (Maybe [ConfigurationItem])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceConfigHistoryResponse' {Maybe [ConfigurationItem]
configurationItems :: Maybe [ConfigurationItem]
$sel:configurationItems:GetResourceConfigHistoryResponse' :: GetResourceConfigHistoryResponse -> Maybe [ConfigurationItem]
configurationItems} -> Maybe [ConfigurationItem]
configurationItems) (\s :: GetResourceConfigHistoryResponse
s@GetResourceConfigHistoryResponse' {} Maybe [ConfigurationItem]
a -> GetResourceConfigHistoryResponse
s {$sel:configurationItems:GetResourceConfigHistoryResponse' :: Maybe [ConfigurationItem]
configurationItems = Maybe [ConfigurationItem]
a} :: GetResourceConfigHistoryResponse) ((Maybe [ConfigurationItem] -> f (Maybe [ConfigurationItem]))
 -> GetResourceConfigHistoryResponse
 -> f GetResourceConfigHistoryResponse)
-> ((Maybe [ConfigurationItem] -> f (Maybe [ConfigurationItem]))
    -> Maybe [ConfigurationItem] -> f (Maybe [ConfigurationItem]))
-> (Maybe [ConfigurationItem] -> f (Maybe [ConfigurationItem]))
-> GetResourceConfigHistoryResponse
-> f GetResourceConfigHistoryResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ConfigurationItem]
  [ConfigurationItem]
  [ConfigurationItem]
  [ConfigurationItem]
-> Iso
     (Maybe [ConfigurationItem])
     (Maybe [ConfigurationItem])
     (Maybe [ConfigurationItem])
     (Maybe [ConfigurationItem])
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
  [ConfigurationItem]
  [ConfigurationItem]
  [ConfigurationItem]
  [ConfigurationItem]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    GetResourceConfigHistoryResponse