{-# 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.DescribeComplianceByConfigRule
-- 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)
--
-- Indicates whether the specified Config rules are compliant. If a rule is
-- noncompliant, this action returns the number of Amazon Web Services
-- resources that do not comply with the rule.
--
-- A rule is compliant if all of the evaluated resources comply with it. It
-- is noncompliant if any of these resources do not comply.
--
-- If Config has no current evaluation results for the rule, it returns
-- @INSUFFICIENT_DATA@. This result might indicate one of the following
-- conditions:
--
-- -   Config has never invoked an evaluation for the rule. To check
--     whether it has, use the @DescribeConfigRuleEvaluationStatus@ action
--     to get the @LastSuccessfulInvocationTime@ and
--     @LastFailedInvocationTime@.
--
-- -   The rule\'s Lambda function is failing to send evaluation results to
--     Config. Verify that the role you assigned to your configuration
--     recorder includes the @config:PutEvaluations@ permission. If the
--     rule is a custom rule, verify that the Lambda execution role
--     includes the @config:PutEvaluations@ permission.
--
-- -   The rule\'s Lambda function has returned @NOT_APPLICABLE@ for all
--     evaluation results. This can occur if the resources were deleted or
--     removed from the rule\'s scope.
--
-- This operation returns paginated results.
module Amazonka.Config.DescribeComplianceByConfigRule
  ( -- * Creating a Request
    DescribeComplianceByConfigRule (..),
    newDescribeComplianceByConfigRule,

    -- * Request Lenses
    describeComplianceByConfigRule_configRuleNames,
    describeComplianceByConfigRule_complianceTypes,
    describeComplianceByConfigRule_nextToken,

    -- * Destructuring the Response
    DescribeComplianceByConfigRuleResponse (..),
    newDescribeComplianceByConfigRuleResponse,

    -- * Response Lenses
    describeComplianceByConfigRuleResponse_complianceByConfigRules,
    describeComplianceByConfigRuleResponse_nextToken,
    describeComplianceByConfigRuleResponse_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:/ 'newDescribeComplianceByConfigRule' smart constructor.
data DescribeComplianceByConfigRule = DescribeComplianceByConfigRule'
  { -- | Specify one or more Config rule names to filter the results by rule.
    DescribeComplianceByConfigRule -> Maybe [Text]
configRuleNames :: Prelude.Maybe [Prelude.Text],
    -- | Filters the results by compliance.
    --
    -- The allowed values are @COMPLIANT@ and @NON_COMPLIANT@.
    DescribeComplianceByConfigRule -> 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.
    DescribeComplianceByConfigRule -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (DescribeComplianceByConfigRule
-> DescribeComplianceByConfigRule -> Bool
(DescribeComplianceByConfigRule
 -> DescribeComplianceByConfigRule -> Bool)
-> (DescribeComplianceByConfigRule
    -> DescribeComplianceByConfigRule -> Bool)
-> Eq DescribeComplianceByConfigRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeComplianceByConfigRule
-> DescribeComplianceByConfigRule -> Bool
$c/= :: DescribeComplianceByConfigRule
-> DescribeComplianceByConfigRule -> Bool
== :: DescribeComplianceByConfigRule
-> DescribeComplianceByConfigRule -> Bool
$c== :: DescribeComplianceByConfigRule
-> DescribeComplianceByConfigRule -> Bool
Prelude.Eq, ReadPrec [DescribeComplianceByConfigRule]
ReadPrec DescribeComplianceByConfigRule
Int -> ReadS DescribeComplianceByConfigRule
ReadS [DescribeComplianceByConfigRule]
(Int -> ReadS DescribeComplianceByConfigRule)
-> ReadS [DescribeComplianceByConfigRule]
-> ReadPrec DescribeComplianceByConfigRule
-> ReadPrec [DescribeComplianceByConfigRule]
-> Read DescribeComplianceByConfigRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeComplianceByConfigRule]
$creadListPrec :: ReadPrec [DescribeComplianceByConfigRule]
readPrec :: ReadPrec DescribeComplianceByConfigRule
$creadPrec :: ReadPrec DescribeComplianceByConfigRule
readList :: ReadS [DescribeComplianceByConfigRule]
$creadList :: ReadS [DescribeComplianceByConfigRule]
readsPrec :: Int -> ReadS DescribeComplianceByConfigRule
$creadsPrec :: Int -> ReadS DescribeComplianceByConfigRule
Prelude.Read, Int -> DescribeComplianceByConfigRule -> ShowS
[DescribeComplianceByConfigRule] -> ShowS
DescribeComplianceByConfigRule -> String
(Int -> DescribeComplianceByConfigRule -> ShowS)
-> (DescribeComplianceByConfigRule -> String)
-> ([DescribeComplianceByConfigRule] -> ShowS)
-> Show DescribeComplianceByConfigRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeComplianceByConfigRule] -> ShowS
$cshowList :: [DescribeComplianceByConfigRule] -> ShowS
show :: DescribeComplianceByConfigRule -> String
$cshow :: DescribeComplianceByConfigRule -> String
showsPrec :: Int -> DescribeComplianceByConfigRule -> ShowS
$cshowsPrec :: Int -> DescribeComplianceByConfigRule -> ShowS
Prelude.Show, (forall x.
 DescribeComplianceByConfigRule
 -> Rep DescribeComplianceByConfigRule x)
-> (forall x.
    Rep DescribeComplianceByConfigRule x
    -> DescribeComplianceByConfigRule)
-> Generic DescribeComplianceByConfigRule
forall x.
Rep DescribeComplianceByConfigRule x
-> DescribeComplianceByConfigRule
forall x.
DescribeComplianceByConfigRule
-> Rep DescribeComplianceByConfigRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeComplianceByConfigRule x
-> DescribeComplianceByConfigRule
$cfrom :: forall x.
DescribeComplianceByConfigRule
-> Rep DescribeComplianceByConfigRule x
Prelude.Generic)

-- |
-- Create a value of 'DescribeComplianceByConfigRule' 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:
--
-- 'configRuleNames', 'describeComplianceByConfigRule_configRuleNames' - Specify one or more Config rule names to filter the results by rule.
--
-- 'complianceTypes', 'describeComplianceByConfigRule_complianceTypes' - Filters the results by compliance.
--
-- The allowed values are @COMPLIANT@ and @NON_COMPLIANT@.
--
-- 'nextToken', 'describeComplianceByConfigRule_nextToken' - The @nextToken@ string returned on a previous page that you use to get
-- the next page of results in a paginated response.
newDescribeComplianceByConfigRule ::
  DescribeComplianceByConfigRule
newDescribeComplianceByConfigRule :: DescribeComplianceByConfigRule
newDescribeComplianceByConfigRule =
  DescribeComplianceByConfigRule' :: Maybe [Text]
-> Maybe [ComplianceType]
-> Maybe Text
-> DescribeComplianceByConfigRule
DescribeComplianceByConfigRule'
    { $sel:configRuleNames:DescribeComplianceByConfigRule' :: Maybe [Text]
configRuleNames =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:complianceTypes:DescribeComplianceByConfigRule' :: Maybe [ComplianceType]
complianceTypes = Maybe [ComplianceType]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeComplianceByConfigRule' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Specify one or more Config rule names to filter the results by rule.
describeComplianceByConfigRule_configRuleNames :: Lens.Lens' DescribeComplianceByConfigRule (Prelude.Maybe [Prelude.Text])
describeComplianceByConfigRule_configRuleNames :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribeComplianceByConfigRule
-> f DescribeComplianceByConfigRule
describeComplianceByConfigRule_configRuleNames = (DescribeComplianceByConfigRule -> Maybe [Text])
-> (DescribeComplianceByConfigRule
    -> Maybe [Text] -> DescribeComplianceByConfigRule)
-> Lens
     DescribeComplianceByConfigRule
     DescribeComplianceByConfigRule
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeComplianceByConfigRule' {Maybe [Text]
configRuleNames :: Maybe [Text]
$sel:configRuleNames:DescribeComplianceByConfigRule' :: DescribeComplianceByConfigRule -> Maybe [Text]
configRuleNames} -> Maybe [Text]
configRuleNames) (\s :: DescribeComplianceByConfigRule
s@DescribeComplianceByConfigRule' {} Maybe [Text]
a -> DescribeComplianceByConfigRule
s {$sel:configRuleNames:DescribeComplianceByConfigRule' :: Maybe [Text]
configRuleNames = Maybe [Text]
a} :: DescribeComplianceByConfigRule) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribeComplianceByConfigRule
 -> f DescribeComplianceByConfigRule)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribeComplianceByConfigRule
-> f DescribeComplianceByConfigRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Filters the results by compliance.
--
-- The allowed values are @COMPLIANT@ and @NON_COMPLIANT@.
describeComplianceByConfigRule_complianceTypes :: Lens.Lens' DescribeComplianceByConfigRule (Prelude.Maybe [ComplianceType])
describeComplianceByConfigRule_complianceTypes :: (Maybe [ComplianceType] -> f (Maybe [ComplianceType]))
-> DescribeComplianceByConfigRule
-> f DescribeComplianceByConfigRule
describeComplianceByConfigRule_complianceTypes = (DescribeComplianceByConfigRule -> Maybe [ComplianceType])
-> (DescribeComplianceByConfigRule
    -> Maybe [ComplianceType] -> DescribeComplianceByConfigRule)
-> Lens
     DescribeComplianceByConfigRule
     DescribeComplianceByConfigRule
     (Maybe [ComplianceType])
     (Maybe [ComplianceType])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeComplianceByConfigRule' {Maybe [ComplianceType]
complianceTypes :: Maybe [ComplianceType]
$sel:complianceTypes:DescribeComplianceByConfigRule' :: DescribeComplianceByConfigRule -> Maybe [ComplianceType]
complianceTypes} -> Maybe [ComplianceType]
complianceTypes) (\s :: DescribeComplianceByConfigRule
s@DescribeComplianceByConfigRule' {} Maybe [ComplianceType]
a -> DescribeComplianceByConfigRule
s {$sel:complianceTypes:DescribeComplianceByConfigRule' :: Maybe [ComplianceType]
complianceTypes = Maybe [ComplianceType]
a} :: DescribeComplianceByConfigRule) ((Maybe [ComplianceType] -> f (Maybe [ComplianceType]))
 -> DescribeComplianceByConfigRule
 -> f DescribeComplianceByConfigRule)
-> ((Maybe [ComplianceType] -> f (Maybe [ComplianceType]))
    -> Maybe [ComplianceType] -> f (Maybe [ComplianceType]))
-> (Maybe [ComplianceType] -> f (Maybe [ComplianceType]))
-> DescribeComplianceByConfigRule
-> f DescribeComplianceByConfigRule
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.
describeComplianceByConfigRule_nextToken :: Lens.Lens' DescribeComplianceByConfigRule (Prelude.Maybe Prelude.Text)
describeComplianceByConfigRule_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeComplianceByConfigRule
-> f DescribeComplianceByConfigRule
describeComplianceByConfigRule_nextToken = (DescribeComplianceByConfigRule -> Maybe Text)
-> (DescribeComplianceByConfigRule
    -> Maybe Text -> DescribeComplianceByConfigRule)
-> Lens
     DescribeComplianceByConfigRule
     DescribeComplianceByConfigRule
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeComplianceByConfigRule' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeComplianceByConfigRule' :: DescribeComplianceByConfigRule -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeComplianceByConfigRule
s@DescribeComplianceByConfigRule' {} Maybe Text
a -> DescribeComplianceByConfigRule
s {$sel:nextToken:DescribeComplianceByConfigRule' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeComplianceByConfigRule)

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

instance
  Prelude.NFData
    DescribeComplianceByConfigRule

instance
  Core.ToHeaders
    DescribeComplianceByConfigRule
  where
  toHeaders :: DescribeComplianceByConfigRule -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> DescribeComplianceByConfigRule -> 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.DescribeComplianceByConfigRule" ::
                          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 DescribeComplianceByConfigRule where
  toJSON :: DescribeComplianceByConfigRule -> Value
toJSON DescribeComplianceByConfigRule' {Maybe [Text]
Maybe [ComplianceType]
Maybe Text
nextToken :: Maybe Text
complianceTypes :: Maybe [ComplianceType]
configRuleNames :: Maybe [Text]
$sel:nextToken:DescribeComplianceByConfigRule' :: DescribeComplianceByConfigRule -> Maybe Text
$sel:complianceTypes:DescribeComplianceByConfigRule' :: DescribeComplianceByConfigRule -> Maybe [ComplianceType]
$sel:configRuleNames:DescribeComplianceByConfigRule' :: DescribeComplianceByConfigRule -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ConfigRuleNames" 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]
configRuleNames,
            (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
          ]
      )

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

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

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

-- |
-- Create a value of 'DescribeComplianceByConfigRuleResponse' 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:
--
-- 'complianceByConfigRules', 'describeComplianceByConfigRuleResponse_complianceByConfigRules' - Indicates whether each of the specified Config rules is compliant.
--
-- 'nextToken', 'describeComplianceByConfigRuleResponse_nextToken' - The string that you use in a subsequent request to get the next page of
-- results in a paginated response.
--
-- 'httpStatus', 'describeComplianceByConfigRuleResponse_httpStatus' - The response's http status code.
newDescribeComplianceByConfigRuleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeComplianceByConfigRuleResponse
newDescribeComplianceByConfigRuleResponse :: Int -> DescribeComplianceByConfigRuleResponse
newDescribeComplianceByConfigRuleResponse
  Int
pHttpStatus_ =
    DescribeComplianceByConfigRuleResponse' :: Maybe [ComplianceByConfigRule]
-> Maybe Text -> Int -> DescribeComplianceByConfigRuleResponse
DescribeComplianceByConfigRuleResponse'
      { $sel:complianceByConfigRules:DescribeComplianceByConfigRuleResponse' :: Maybe [ComplianceByConfigRule]
complianceByConfigRules =
          Maybe [ComplianceByConfigRule]
forall a. Maybe a
Prelude.Nothing,
        $sel:nextToken:DescribeComplianceByConfigRuleResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:DescribeComplianceByConfigRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | Indicates whether each of the specified Config rules is compliant.
describeComplianceByConfigRuleResponse_complianceByConfigRules :: Lens.Lens' DescribeComplianceByConfigRuleResponse (Prelude.Maybe [ComplianceByConfigRule])
describeComplianceByConfigRuleResponse_complianceByConfigRules :: (Maybe [ComplianceByConfigRule]
 -> f (Maybe [ComplianceByConfigRule]))
-> DescribeComplianceByConfigRuleResponse
-> f DescribeComplianceByConfigRuleResponse
describeComplianceByConfigRuleResponse_complianceByConfigRules = (DescribeComplianceByConfigRuleResponse
 -> Maybe [ComplianceByConfigRule])
-> (DescribeComplianceByConfigRuleResponse
    -> Maybe [ComplianceByConfigRule]
    -> DescribeComplianceByConfigRuleResponse)
-> Lens'
     DescribeComplianceByConfigRuleResponse
     (Maybe [ComplianceByConfigRule])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeComplianceByConfigRuleResponse' {Maybe [ComplianceByConfigRule]
complianceByConfigRules :: Maybe [ComplianceByConfigRule]
$sel:complianceByConfigRules:DescribeComplianceByConfigRuleResponse' :: DescribeComplianceByConfigRuleResponse
-> Maybe [ComplianceByConfigRule]
complianceByConfigRules} -> Maybe [ComplianceByConfigRule]
complianceByConfigRules) (\s :: DescribeComplianceByConfigRuleResponse
s@DescribeComplianceByConfigRuleResponse' {} Maybe [ComplianceByConfigRule]
a -> DescribeComplianceByConfigRuleResponse
s {$sel:complianceByConfigRules:DescribeComplianceByConfigRuleResponse' :: Maybe [ComplianceByConfigRule]
complianceByConfigRules = Maybe [ComplianceByConfigRule]
a} :: DescribeComplianceByConfigRuleResponse) ((Maybe [ComplianceByConfigRule]
  -> f (Maybe [ComplianceByConfigRule]))
 -> DescribeComplianceByConfigRuleResponse
 -> f DescribeComplianceByConfigRuleResponse)
-> ((Maybe [ComplianceByConfigRule]
     -> f (Maybe [ComplianceByConfigRule]))
    -> Maybe [ComplianceByConfigRule]
    -> f (Maybe [ComplianceByConfigRule]))
-> (Maybe [ComplianceByConfigRule]
    -> f (Maybe [ComplianceByConfigRule]))
-> DescribeComplianceByConfigRuleResponse
-> f DescribeComplianceByConfigRuleResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ComplianceByConfigRule]
  [ComplianceByConfigRule]
  [ComplianceByConfigRule]
  [ComplianceByConfigRule]
-> Iso
     (Maybe [ComplianceByConfigRule])
     (Maybe [ComplianceByConfigRule])
     (Maybe [ComplianceByConfigRule])
     (Maybe [ComplianceByConfigRule])
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
  [ComplianceByConfigRule]
  [ComplianceByConfigRule]
  [ComplianceByConfigRule]
  [ComplianceByConfigRule]
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.
describeComplianceByConfigRuleResponse_nextToken :: Lens.Lens' DescribeComplianceByConfigRuleResponse (Prelude.Maybe Prelude.Text)
describeComplianceByConfigRuleResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeComplianceByConfigRuleResponse
-> f DescribeComplianceByConfigRuleResponse
describeComplianceByConfigRuleResponse_nextToken = (DescribeComplianceByConfigRuleResponse -> Maybe Text)
-> (DescribeComplianceByConfigRuleResponse
    -> Maybe Text -> DescribeComplianceByConfigRuleResponse)
-> Lens' DescribeComplianceByConfigRuleResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeComplianceByConfigRuleResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeComplianceByConfigRuleResponse' :: DescribeComplianceByConfigRuleResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeComplianceByConfigRuleResponse
s@DescribeComplianceByConfigRuleResponse' {} Maybe Text
a -> DescribeComplianceByConfigRuleResponse
s {$sel:nextToken:DescribeComplianceByConfigRuleResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeComplianceByConfigRuleResponse)

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

instance
  Prelude.NFData
    DescribeComplianceByConfigRuleResponse