{-# 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.GetComplianceDetailsByConfigRule
-- 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 the evaluation results for the specified Config rule. The
-- results indicate which Amazon Web Services resources were evaluated by
-- the rule, when each resource was last evaluated, and whether each
-- resource complies with the rule.
--
-- This operation returns paginated results.
module Amazonka.Config.GetComplianceDetailsByConfigRule
  ( -- * Creating a Request
    GetComplianceDetailsByConfigRule (..),
    newGetComplianceDetailsByConfigRule,

    -- * Request Lenses
    getComplianceDetailsByConfigRule_complianceTypes,
    getComplianceDetailsByConfigRule_nextToken,
    getComplianceDetailsByConfigRule_limit,
    getComplianceDetailsByConfigRule_configRuleName,

    -- * Destructuring the Response
    GetComplianceDetailsByConfigRuleResponse (..),
    newGetComplianceDetailsByConfigRuleResponse,

    -- * Response Lenses
    getComplianceDetailsByConfigRuleResponse_evaluationResults,
    getComplianceDetailsByConfigRuleResponse_nextToken,
    getComplianceDetailsByConfigRuleResponse_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:/ 'newGetComplianceDetailsByConfigRule' smart constructor.
data GetComplianceDetailsByConfigRule = GetComplianceDetailsByConfigRule'
  { -- | Filters the results by compliance.
    --
    -- The allowed values are @COMPLIANT@, @NON_COMPLIANT@, and
    -- @NOT_APPLICABLE@.
    GetComplianceDetailsByConfigRule -> Maybe [ComplianceType]
complianceTypes :: Prelude.Maybe [ComplianceType],
    -- | The @nextToken@ string returned on a previous page that you use to get
    -- the next page of results in a paginated response.
    GetComplianceDetailsByConfigRule -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of evaluation results returned on each page. The
    -- default is 10. You cannot specify a number greater than 100. If you
    -- specify 0, Config uses the default.
    GetComplianceDetailsByConfigRule -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | The name of the Config rule for which you want compliance information.
    GetComplianceDetailsByConfigRule -> Text
configRuleName :: Prelude.Text
  }
  deriving (GetComplianceDetailsByConfigRule
-> GetComplianceDetailsByConfigRule -> Bool
(GetComplianceDetailsByConfigRule
 -> GetComplianceDetailsByConfigRule -> Bool)
-> (GetComplianceDetailsByConfigRule
    -> GetComplianceDetailsByConfigRule -> Bool)
-> Eq GetComplianceDetailsByConfigRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetComplianceDetailsByConfigRule
-> GetComplianceDetailsByConfigRule -> Bool
$c/= :: GetComplianceDetailsByConfigRule
-> GetComplianceDetailsByConfigRule -> Bool
== :: GetComplianceDetailsByConfigRule
-> GetComplianceDetailsByConfigRule -> Bool
$c== :: GetComplianceDetailsByConfigRule
-> GetComplianceDetailsByConfigRule -> Bool
Prelude.Eq, ReadPrec [GetComplianceDetailsByConfigRule]
ReadPrec GetComplianceDetailsByConfigRule
Int -> ReadS GetComplianceDetailsByConfigRule
ReadS [GetComplianceDetailsByConfigRule]
(Int -> ReadS GetComplianceDetailsByConfigRule)
-> ReadS [GetComplianceDetailsByConfigRule]
-> ReadPrec GetComplianceDetailsByConfigRule
-> ReadPrec [GetComplianceDetailsByConfigRule]
-> Read GetComplianceDetailsByConfigRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetComplianceDetailsByConfigRule]
$creadListPrec :: ReadPrec [GetComplianceDetailsByConfigRule]
readPrec :: ReadPrec GetComplianceDetailsByConfigRule
$creadPrec :: ReadPrec GetComplianceDetailsByConfigRule
readList :: ReadS [GetComplianceDetailsByConfigRule]
$creadList :: ReadS [GetComplianceDetailsByConfigRule]
readsPrec :: Int -> ReadS GetComplianceDetailsByConfigRule
$creadsPrec :: Int -> ReadS GetComplianceDetailsByConfigRule
Prelude.Read, Int -> GetComplianceDetailsByConfigRule -> ShowS
[GetComplianceDetailsByConfigRule] -> ShowS
GetComplianceDetailsByConfigRule -> String
(Int -> GetComplianceDetailsByConfigRule -> ShowS)
-> (GetComplianceDetailsByConfigRule -> String)
-> ([GetComplianceDetailsByConfigRule] -> ShowS)
-> Show GetComplianceDetailsByConfigRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetComplianceDetailsByConfigRule] -> ShowS
$cshowList :: [GetComplianceDetailsByConfigRule] -> ShowS
show :: GetComplianceDetailsByConfigRule -> String
$cshow :: GetComplianceDetailsByConfigRule -> String
showsPrec :: Int -> GetComplianceDetailsByConfigRule -> ShowS
$cshowsPrec :: Int -> GetComplianceDetailsByConfigRule -> ShowS
Prelude.Show, (forall x.
 GetComplianceDetailsByConfigRule
 -> Rep GetComplianceDetailsByConfigRule x)
-> (forall x.
    Rep GetComplianceDetailsByConfigRule x
    -> GetComplianceDetailsByConfigRule)
-> Generic GetComplianceDetailsByConfigRule
forall x.
Rep GetComplianceDetailsByConfigRule x
-> GetComplianceDetailsByConfigRule
forall x.
GetComplianceDetailsByConfigRule
-> Rep GetComplianceDetailsByConfigRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetComplianceDetailsByConfigRule x
-> GetComplianceDetailsByConfigRule
$cfrom :: forall x.
GetComplianceDetailsByConfigRule
-> Rep GetComplianceDetailsByConfigRule x
Prelude.Generic)

-- |
-- Create a value of 'GetComplianceDetailsByConfigRule' 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:
--
-- 'complianceTypes', 'getComplianceDetailsByConfigRule_complianceTypes' - Filters the results by compliance.
--
-- The allowed values are @COMPLIANT@, @NON_COMPLIANT@, and
-- @NOT_APPLICABLE@.
--
-- 'nextToken', 'getComplianceDetailsByConfigRule_nextToken' - The @nextToken@ string returned on a previous page that you use to get
-- the next page of results in a paginated response.
--
-- 'limit', 'getComplianceDetailsByConfigRule_limit' - The maximum number of evaluation results returned on each page. The
-- default is 10. You cannot specify a number greater than 100. If you
-- specify 0, Config uses the default.
--
-- 'configRuleName', 'getComplianceDetailsByConfigRule_configRuleName' - The name of the Config rule for which you want compliance information.
newGetComplianceDetailsByConfigRule ::
  -- | 'configRuleName'
  Prelude.Text ->
  GetComplianceDetailsByConfigRule
newGetComplianceDetailsByConfigRule :: Text -> GetComplianceDetailsByConfigRule
newGetComplianceDetailsByConfigRule Text
pConfigRuleName_ =
  GetComplianceDetailsByConfigRule' :: Maybe [ComplianceType]
-> Maybe Text
-> Maybe Natural
-> Text
-> GetComplianceDetailsByConfigRule
GetComplianceDetailsByConfigRule'
    { $sel:complianceTypes:GetComplianceDetailsByConfigRule' :: Maybe [ComplianceType]
complianceTypes =
        Maybe [ComplianceType]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetComplianceDetailsByConfigRule' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:limit:GetComplianceDetailsByConfigRule' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:configRuleName:GetComplianceDetailsByConfigRule' :: Text
configRuleName = Text
pConfigRuleName_
    }

-- | Filters the results by compliance.
--
-- The allowed values are @COMPLIANT@, @NON_COMPLIANT@, and
-- @NOT_APPLICABLE@.
getComplianceDetailsByConfigRule_complianceTypes :: Lens.Lens' GetComplianceDetailsByConfigRule (Prelude.Maybe [ComplianceType])
getComplianceDetailsByConfigRule_complianceTypes :: (Maybe [ComplianceType] -> f (Maybe [ComplianceType]))
-> GetComplianceDetailsByConfigRule
-> f GetComplianceDetailsByConfigRule
getComplianceDetailsByConfigRule_complianceTypes = (GetComplianceDetailsByConfigRule -> Maybe [ComplianceType])
-> (GetComplianceDetailsByConfigRule
    -> Maybe [ComplianceType] -> GetComplianceDetailsByConfigRule)
-> Lens
     GetComplianceDetailsByConfigRule
     GetComplianceDetailsByConfigRule
     (Maybe [ComplianceType])
     (Maybe [ComplianceType])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetComplianceDetailsByConfigRule' {Maybe [ComplianceType]
complianceTypes :: Maybe [ComplianceType]
$sel:complianceTypes:GetComplianceDetailsByConfigRule' :: GetComplianceDetailsByConfigRule -> Maybe [ComplianceType]
complianceTypes} -> Maybe [ComplianceType]
complianceTypes) (\s :: GetComplianceDetailsByConfigRule
s@GetComplianceDetailsByConfigRule' {} Maybe [ComplianceType]
a -> GetComplianceDetailsByConfigRule
s {$sel:complianceTypes:GetComplianceDetailsByConfigRule' :: Maybe [ComplianceType]
complianceTypes = Maybe [ComplianceType]
a} :: GetComplianceDetailsByConfigRule) ((Maybe [ComplianceType] -> f (Maybe [ComplianceType]))
 -> GetComplianceDetailsByConfigRule
 -> f GetComplianceDetailsByConfigRule)
-> ((Maybe [ComplianceType] -> f (Maybe [ComplianceType]))
    -> Maybe [ComplianceType] -> f (Maybe [ComplianceType]))
-> (Maybe [ComplianceType] -> f (Maybe [ComplianceType]))
-> GetComplianceDetailsByConfigRule
-> f GetComplianceDetailsByConfigRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ComplianceType] [ComplianceType] [ComplianceType] [ComplianceType]
-> Iso
     (Maybe [ComplianceType])
     (Maybe [ComplianceType])
     (Maybe [ComplianceType])
     (Maybe [ComplianceType])
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
  [ComplianceType] [ComplianceType] [ComplianceType] [ComplianceType]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

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

-- | The name of the Config rule for which you want compliance information.
getComplianceDetailsByConfigRule_configRuleName :: Lens.Lens' GetComplianceDetailsByConfigRule Prelude.Text
getComplianceDetailsByConfigRule_configRuleName :: (Text -> f Text)
-> GetComplianceDetailsByConfigRule
-> f GetComplianceDetailsByConfigRule
getComplianceDetailsByConfigRule_configRuleName = (GetComplianceDetailsByConfigRule -> Text)
-> (GetComplianceDetailsByConfigRule
    -> Text -> GetComplianceDetailsByConfigRule)
-> Lens
     GetComplianceDetailsByConfigRule
     GetComplianceDetailsByConfigRule
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetComplianceDetailsByConfigRule' {Text
configRuleName :: Text
$sel:configRuleName:GetComplianceDetailsByConfigRule' :: GetComplianceDetailsByConfigRule -> Text
configRuleName} -> Text
configRuleName) (\s :: GetComplianceDetailsByConfigRule
s@GetComplianceDetailsByConfigRule' {} Text
a -> GetComplianceDetailsByConfigRule
s {$sel:configRuleName:GetComplianceDetailsByConfigRule' :: Text
configRuleName = Text
a} :: GetComplianceDetailsByConfigRule)

instance
  Core.AWSPager
    GetComplianceDetailsByConfigRule
  where
  page :: GetComplianceDetailsByConfigRule
-> AWSResponse GetComplianceDetailsByConfigRule
-> Maybe GetComplianceDetailsByConfigRule
page GetComplianceDetailsByConfigRule
rq AWSResponse GetComplianceDetailsByConfigRule
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetComplianceDetailsByConfigRule
GetComplianceDetailsByConfigRuleResponse
rs
            GetComplianceDetailsByConfigRuleResponse
-> Getting
     (First Text) GetComplianceDetailsByConfigRuleResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetComplianceDetailsByConfigRuleResponse
-> Const (First Text) GetComplianceDetailsByConfigRuleResponse
Lens' GetComplianceDetailsByConfigRuleResponse (Maybe Text)
getComplianceDetailsByConfigRuleResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetComplianceDetailsByConfigRuleResponse
 -> Const (First Text) GetComplianceDetailsByConfigRuleResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting
     (First Text) GetComplianceDetailsByConfigRuleResponse 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 GetComplianceDetailsByConfigRule
forall a. Maybe a
Prelude.Nothing
    | Maybe [EvaluationResult] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetComplianceDetailsByConfigRule
GetComplianceDetailsByConfigRuleResponse
rs
            GetComplianceDetailsByConfigRuleResponse
-> Getting
     (First [EvaluationResult])
     GetComplianceDetailsByConfigRuleResponse
     [EvaluationResult]
-> Maybe [EvaluationResult]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [EvaluationResult]
 -> Const (First [EvaluationResult]) (Maybe [EvaluationResult]))
-> GetComplianceDetailsByConfigRuleResponse
-> Const
     (First [EvaluationResult]) GetComplianceDetailsByConfigRuleResponse
Lens'
  GetComplianceDetailsByConfigRuleResponse (Maybe [EvaluationResult])
getComplianceDetailsByConfigRuleResponse_evaluationResults
              ((Maybe [EvaluationResult]
  -> Const (First [EvaluationResult]) (Maybe [EvaluationResult]))
 -> GetComplianceDetailsByConfigRuleResponse
 -> Const
      (First [EvaluationResult])
      GetComplianceDetailsByConfigRuleResponse)
-> (([EvaluationResult]
     -> Const (First [EvaluationResult]) [EvaluationResult])
    -> Maybe [EvaluationResult]
    -> Const (First [EvaluationResult]) (Maybe [EvaluationResult]))
-> Getting
     (First [EvaluationResult])
     GetComplianceDetailsByConfigRuleResponse
     [EvaluationResult]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([EvaluationResult]
 -> Const (First [EvaluationResult]) [EvaluationResult])
-> Maybe [EvaluationResult]
-> Const (First [EvaluationResult]) (Maybe [EvaluationResult])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe GetComplianceDetailsByConfigRule
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      GetComplianceDetailsByConfigRule
-> Maybe GetComplianceDetailsByConfigRule
forall a. a -> Maybe a
Prelude.Just (GetComplianceDetailsByConfigRule
 -> Maybe GetComplianceDetailsByConfigRule)
-> GetComplianceDetailsByConfigRule
-> Maybe GetComplianceDetailsByConfigRule
forall a b. (a -> b) -> a -> b
Prelude.$
        GetComplianceDetailsByConfigRule
rq
          GetComplianceDetailsByConfigRule
-> (GetComplianceDetailsByConfigRule
    -> GetComplianceDetailsByConfigRule)
-> GetComplianceDetailsByConfigRule
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> GetComplianceDetailsByConfigRule
-> Identity GetComplianceDetailsByConfigRule
Lens
  GetComplianceDetailsByConfigRule
  GetComplianceDetailsByConfigRule
  (Maybe Text)
  (Maybe Text)
getComplianceDetailsByConfigRule_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> GetComplianceDetailsByConfigRule
 -> Identity GetComplianceDetailsByConfigRule)
-> Maybe Text
-> GetComplianceDetailsByConfigRule
-> GetComplianceDetailsByConfigRule
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetComplianceDetailsByConfigRule
GetComplianceDetailsByConfigRuleResponse
rs
          GetComplianceDetailsByConfigRuleResponse
-> Getting
     (First Text) GetComplianceDetailsByConfigRuleResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetComplianceDetailsByConfigRuleResponse
-> Const (First Text) GetComplianceDetailsByConfigRuleResponse
Lens' GetComplianceDetailsByConfigRuleResponse (Maybe Text)
getComplianceDetailsByConfigRuleResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetComplianceDetailsByConfigRuleResponse
 -> Const (First Text) GetComplianceDetailsByConfigRuleResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting
     (First Text) GetComplianceDetailsByConfigRuleResponse 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
    GetComplianceDetailsByConfigRule
  where
  type
    AWSResponse GetComplianceDetailsByConfigRule =
      GetComplianceDetailsByConfigRuleResponse
  request :: GetComplianceDetailsByConfigRule
-> Request GetComplianceDetailsByConfigRule
request = Service
-> GetComplianceDetailsByConfigRule
-> Request GetComplianceDetailsByConfigRule
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetComplianceDetailsByConfigRule
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse GetComplianceDetailsByConfigRule)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetComplianceDetailsByConfigRule))
-> Logger
-> Service
-> Proxy GetComplianceDetailsByConfigRule
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse GetComplianceDetailsByConfigRule)))
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 [EvaluationResult]
-> Maybe Text -> Int -> GetComplianceDetailsByConfigRuleResponse
GetComplianceDetailsByConfigRuleResponse'
            (Maybe [EvaluationResult]
 -> Maybe Text -> Int -> GetComplianceDetailsByConfigRuleResponse)
-> Either String (Maybe [EvaluationResult])
-> Either
     String
     (Maybe Text -> Int -> GetComplianceDetailsByConfigRuleResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Either String (Maybe (Maybe [EvaluationResult]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"EvaluationResults"
                            Either String (Maybe (Maybe [EvaluationResult]))
-> Maybe [EvaluationResult]
-> Either String (Maybe [EvaluationResult])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [EvaluationResult]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either
  String
  (Maybe Text -> Int -> GetComplianceDetailsByConfigRuleResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetComplianceDetailsByConfigRuleResponse)
forall (f :: * -> *) a b. Applicative f => 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 (Int -> GetComplianceDetailsByConfigRuleResponse)
-> Either String Int
-> Either String GetComplianceDetailsByConfigRuleResponse
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
    GetComplianceDetailsByConfigRule

instance
  Prelude.NFData
    GetComplianceDetailsByConfigRule

instance
  Core.ToHeaders
    GetComplianceDetailsByConfigRule
  where
  toHeaders :: GetComplianceDetailsByConfigRule -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> GetComplianceDetailsByConfigRule -> 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.GetComplianceDetailsByConfigRule" ::
                          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 GetComplianceDetailsByConfigRule where
  toJSON :: GetComplianceDetailsByConfigRule -> Value
toJSON GetComplianceDetailsByConfigRule' {Maybe Natural
Maybe [ComplianceType]
Maybe Text
Text
configRuleName :: Text
limit :: Maybe Natural
nextToken :: Maybe Text
complianceTypes :: Maybe [ComplianceType]
$sel:configRuleName:GetComplianceDetailsByConfigRule' :: GetComplianceDetailsByConfigRule -> Text
$sel:limit:GetComplianceDetailsByConfigRule' :: GetComplianceDetailsByConfigRule -> Maybe Natural
$sel:nextToken:GetComplianceDetailsByConfigRule' :: GetComplianceDetailsByConfigRule -> Maybe Text
$sel:complianceTypes:GetComplianceDetailsByConfigRule' :: GetComplianceDetailsByConfigRule -> Maybe [ComplianceType]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ComplianceTypes" Text -> [ComplianceType] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([ComplianceType] -> Pair) -> Maybe [ComplianceType] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ComplianceType]
complianceTypes,
            (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,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ConfigRuleName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
configRuleName)
          ]
      )

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

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

-- |
--
-- /See:/ 'newGetComplianceDetailsByConfigRuleResponse' smart constructor.
data GetComplianceDetailsByConfigRuleResponse = GetComplianceDetailsByConfigRuleResponse'
  { -- | Indicates whether the Amazon Web Services resource complies with the
    -- specified Config rule.
    GetComplianceDetailsByConfigRuleResponse
-> Maybe [EvaluationResult]
evaluationResults :: Prelude.Maybe [EvaluationResult],
    -- | The string that you use in a subsequent request to get the next page of
    -- results in a paginated response.
    GetComplianceDetailsByConfigRuleResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetComplianceDetailsByConfigRuleResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetComplianceDetailsByConfigRuleResponse
-> GetComplianceDetailsByConfigRuleResponse -> Bool
(GetComplianceDetailsByConfigRuleResponse
 -> GetComplianceDetailsByConfigRuleResponse -> Bool)
-> (GetComplianceDetailsByConfigRuleResponse
    -> GetComplianceDetailsByConfigRuleResponse -> Bool)
-> Eq GetComplianceDetailsByConfigRuleResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetComplianceDetailsByConfigRuleResponse
-> GetComplianceDetailsByConfigRuleResponse -> Bool
$c/= :: GetComplianceDetailsByConfigRuleResponse
-> GetComplianceDetailsByConfigRuleResponse -> Bool
== :: GetComplianceDetailsByConfigRuleResponse
-> GetComplianceDetailsByConfigRuleResponse -> Bool
$c== :: GetComplianceDetailsByConfigRuleResponse
-> GetComplianceDetailsByConfigRuleResponse -> Bool
Prelude.Eq, ReadPrec [GetComplianceDetailsByConfigRuleResponse]
ReadPrec GetComplianceDetailsByConfigRuleResponse
Int -> ReadS GetComplianceDetailsByConfigRuleResponse
ReadS [GetComplianceDetailsByConfigRuleResponse]
(Int -> ReadS GetComplianceDetailsByConfigRuleResponse)
-> ReadS [GetComplianceDetailsByConfigRuleResponse]
-> ReadPrec GetComplianceDetailsByConfigRuleResponse
-> ReadPrec [GetComplianceDetailsByConfigRuleResponse]
-> Read GetComplianceDetailsByConfigRuleResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetComplianceDetailsByConfigRuleResponse]
$creadListPrec :: ReadPrec [GetComplianceDetailsByConfigRuleResponse]
readPrec :: ReadPrec GetComplianceDetailsByConfigRuleResponse
$creadPrec :: ReadPrec GetComplianceDetailsByConfigRuleResponse
readList :: ReadS [GetComplianceDetailsByConfigRuleResponse]
$creadList :: ReadS [GetComplianceDetailsByConfigRuleResponse]
readsPrec :: Int -> ReadS GetComplianceDetailsByConfigRuleResponse
$creadsPrec :: Int -> ReadS GetComplianceDetailsByConfigRuleResponse
Prelude.Read, Int -> GetComplianceDetailsByConfigRuleResponse -> ShowS
[GetComplianceDetailsByConfigRuleResponse] -> ShowS
GetComplianceDetailsByConfigRuleResponse -> String
(Int -> GetComplianceDetailsByConfigRuleResponse -> ShowS)
-> (GetComplianceDetailsByConfigRuleResponse -> String)
-> ([GetComplianceDetailsByConfigRuleResponse] -> ShowS)
-> Show GetComplianceDetailsByConfigRuleResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetComplianceDetailsByConfigRuleResponse] -> ShowS
$cshowList :: [GetComplianceDetailsByConfigRuleResponse] -> ShowS
show :: GetComplianceDetailsByConfigRuleResponse -> String
$cshow :: GetComplianceDetailsByConfigRuleResponse -> String
showsPrec :: Int -> GetComplianceDetailsByConfigRuleResponse -> ShowS
$cshowsPrec :: Int -> GetComplianceDetailsByConfigRuleResponse -> ShowS
Prelude.Show, (forall x.
 GetComplianceDetailsByConfigRuleResponse
 -> Rep GetComplianceDetailsByConfigRuleResponse x)
-> (forall x.
    Rep GetComplianceDetailsByConfigRuleResponse x
    -> GetComplianceDetailsByConfigRuleResponse)
-> Generic GetComplianceDetailsByConfigRuleResponse
forall x.
Rep GetComplianceDetailsByConfigRuleResponse x
-> GetComplianceDetailsByConfigRuleResponse
forall x.
GetComplianceDetailsByConfigRuleResponse
-> Rep GetComplianceDetailsByConfigRuleResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetComplianceDetailsByConfigRuleResponse x
-> GetComplianceDetailsByConfigRuleResponse
$cfrom :: forall x.
GetComplianceDetailsByConfigRuleResponse
-> Rep GetComplianceDetailsByConfigRuleResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetComplianceDetailsByConfigRuleResponse' 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:
--
-- 'evaluationResults', 'getComplianceDetailsByConfigRuleResponse_evaluationResults' - Indicates whether the Amazon Web Services resource complies with the
-- specified Config rule.
--
-- 'nextToken', 'getComplianceDetailsByConfigRuleResponse_nextToken' - The string that you use in a subsequent request to get the next page of
-- results in a paginated response.
--
-- 'httpStatus', 'getComplianceDetailsByConfigRuleResponse_httpStatus' - The response's http status code.
newGetComplianceDetailsByConfigRuleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetComplianceDetailsByConfigRuleResponse
newGetComplianceDetailsByConfigRuleResponse :: Int -> GetComplianceDetailsByConfigRuleResponse
newGetComplianceDetailsByConfigRuleResponse
  Int
pHttpStatus_ =
    GetComplianceDetailsByConfigRuleResponse' :: Maybe [EvaluationResult]
-> Maybe Text -> Int -> GetComplianceDetailsByConfigRuleResponse
GetComplianceDetailsByConfigRuleResponse'
      { $sel:evaluationResults:GetComplianceDetailsByConfigRuleResponse' :: Maybe [EvaluationResult]
evaluationResults =
          Maybe [EvaluationResult]
forall a. Maybe a
Prelude.Nothing,
        $sel:nextToken:GetComplianceDetailsByConfigRuleResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:GetComplianceDetailsByConfigRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | Indicates whether the Amazon Web Services resource complies with the
-- specified Config rule.
getComplianceDetailsByConfigRuleResponse_evaluationResults :: Lens.Lens' GetComplianceDetailsByConfigRuleResponse (Prelude.Maybe [EvaluationResult])
getComplianceDetailsByConfigRuleResponse_evaluationResults :: (Maybe [EvaluationResult] -> f (Maybe [EvaluationResult]))
-> GetComplianceDetailsByConfigRuleResponse
-> f GetComplianceDetailsByConfigRuleResponse
getComplianceDetailsByConfigRuleResponse_evaluationResults = (GetComplianceDetailsByConfigRuleResponse
 -> Maybe [EvaluationResult])
-> (GetComplianceDetailsByConfigRuleResponse
    -> Maybe [EvaluationResult]
    -> GetComplianceDetailsByConfigRuleResponse)
-> Lens'
     GetComplianceDetailsByConfigRuleResponse (Maybe [EvaluationResult])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetComplianceDetailsByConfigRuleResponse' {Maybe [EvaluationResult]
evaluationResults :: Maybe [EvaluationResult]
$sel:evaluationResults:GetComplianceDetailsByConfigRuleResponse' :: GetComplianceDetailsByConfigRuleResponse
-> Maybe [EvaluationResult]
evaluationResults} -> Maybe [EvaluationResult]
evaluationResults) (\s :: GetComplianceDetailsByConfigRuleResponse
s@GetComplianceDetailsByConfigRuleResponse' {} Maybe [EvaluationResult]
a -> GetComplianceDetailsByConfigRuleResponse
s {$sel:evaluationResults:GetComplianceDetailsByConfigRuleResponse' :: Maybe [EvaluationResult]
evaluationResults = Maybe [EvaluationResult]
a} :: GetComplianceDetailsByConfigRuleResponse) ((Maybe [EvaluationResult] -> f (Maybe [EvaluationResult]))
 -> GetComplianceDetailsByConfigRuleResponse
 -> f GetComplianceDetailsByConfigRuleResponse)
-> ((Maybe [EvaluationResult] -> f (Maybe [EvaluationResult]))
    -> Maybe [EvaluationResult] -> f (Maybe [EvaluationResult]))
-> (Maybe [EvaluationResult] -> f (Maybe [EvaluationResult]))
-> GetComplianceDetailsByConfigRuleResponse
-> f GetComplianceDetailsByConfigRuleResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [EvaluationResult]
  [EvaluationResult]
  [EvaluationResult]
  [EvaluationResult]
-> Iso
     (Maybe [EvaluationResult])
     (Maybe [EvaluationResult])
     (Maybe [EvaluationResult])
     (Maybe [EvaluationResult])
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
  [EvaluationResult]
  [EvaluationResult]
  [EvaluationResult]
  [EvaluationResult]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

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

instance
  Prelude.NFData
    GetComplianceDetailsByConfigRuleResponse