{-# 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.GetComplianceSummaryByConfigRule
-- 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 number of Config rules that are compliant and noncompliant,
-- up to a maximum of 25 for each.
module Amazonka.Config.GetComplianceSummaryByConfigRule
  ( -- * Creating a Request
    GetComplianceSummaryByConfigRule (..),
    newGetComplianceSummaryByConfigRule,

    -- * Destructuring the Response
    GetComplianceSummaryByConfigRuleResponse (..),
    newGetComplianceSummaryByConfigRuleResponse,

    -- * Response Lenses
    getComplianceSummaryByConfigRuleResponse_complianceSummary,
    getComplianceSummaryByConfigRuleResponse_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:/ 'newGetComplianceSummaryByConfigRule' smart constructor.
data GetComplianceSummaryByConfigRule = GetComplianceSummaryByConfigRule'
  {
  }
  deriving (GetComplianceSummaryByConfigRule
-> GetComplianceSummaryByConfigRule -> Bool
(GetComplianceSummaryByConfigRule
 -> GetComplianceSummaryByConfigRule -> Bool)
-> (GetComplianceSummaryByConfigRule
    -> GetComplianceSummaryByConfigRule -> Bool)
-> Eq GetComplianceSummaryByConfigRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetComplianceSummaryByConfigRule
-> GetComplianceSummaryByConfigRule -> Bool
$c/= :: GetComplianceSummaryByConfigRule
-> GetComplianceSummaryByConfigRule -> Bool
== :: GetComplianceSummaryByConfigRule
-> GetComplianceSummaryByConfigRule -> Bool
$c== :: GetComplianceSummaryByConfigRule
-> GetComplianceSummaryByConfigRule -> Bool
Prelude.Eq, ReadPrec [GetComplianceSummaryByConfigRule]
ReadPrec GetComplianceSummaryByConfigRule
Int -> ReadS GetComplianceSummaryByConfigRule
ReadS [GetComplianceSummaryByConfigRule]
(Int -> ReadS GetComplianceSummaryByConfigRule)
-> ReadS [GetComplianceSummaryByConfigRule]
-> ReadPrec GetComplianceSummaryByConfigRule
-> ReadPrec [GetComplianceSummaryByConfigRule]
-> Read GetComplianceSummaryByConfigRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetComplianceSummaryByConfigRule]
$creadListPrec :: ReadPrec [GetComplianceSummaryByConfigRule]
readPrec :: ReadPrec GetComplianceSummaryByConfigRule
$creadPrec :: ReadPrec GetComplianceSummaryByConfigRule
readList :: ReadS [GetComplianceSummaryByConfigRule]
$creadList :: ReadS [GetComplianceSummaryByConfigRule]
readsPrec :: Int -> ReadS GetComplianceSummaryByConfigRule
$creadsPrec :: Int -> ReadS GetComplianceSummaryByConfigRule
Prelude.Read, Int -> GetComplianceSummaryByConfigRule -> ShowS
[GetComplianceSummaryByConfigRule] -> ShowS
GetComplianceSummaryByConfigRule -> String
(Int -> GetComplianceSummaryByConfigRule -> ShowS)
-> (GetComplianceSummaryByConfigRule -> String)
-> ([GetComplianceSummaryByConfigRule] -> ShowS)
-> Show GetComplianceSummaryByConfigRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetComplianceSummaryByConfigRule] -> ShowS
$cshowList :: [GetComplianceSummaryByConfigRule] -> ShowS
show :: GetComplianceSummaryByConfigRule -> String
$cshow :: GetComplianceSummaryByConfigRule -> String
showsPrec :: Int -> GetComplianceSummaryByConfigRule -> ShowS
$cshowsPrec :: Int -> GetComplianceSummaryByConfigRule -> ShowS
Prelude.Show, (forall x.
 GetComplianceSummaryByConfigRule
 -> Rep GetComplianceSummaryByConfigRule x)
-> (forall x.
    Rep GetComplianceSummaryByConfigRule x
    -> GetComplianceSummaryByConfigRule)
-> Generic GetComplianceSummaryByConfigRule
forall x.
Rep GetComplianceSummaryByConfigRule x
-> GetComplianceSummaryByConfigRule
forall x.
GetComplianceSummaryByConfigRule
-> Rep GetComplianceSummaryByConfigRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetComplianceSummaryByConfigRule x
-> GetComplianceSummaryByConfigRule
$cfrom :: forall x.
GetComplianceSummaryByConfigRule
-> Rep GetComplianceSummaryByConfigRule x
Prelude.Generic)

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

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

instance
  Prelude.NFData
    GetComplianceSummaryByConfigRule

instance
  Core.ToHeaders
    GetComplianceSummaryByConfigRule
  where
  toHeaders :: GetComplianceSummaryByConfigRule -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> GetComplianceSummaryByConfigRule -> 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.GetComplianceSummaryByConfigRule" ::
                          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 GetComplianceSummaryByConfigRule where
  toJSON :: GetComplianceSummaryByConfigRule -> Value
toJSON = Value -> GetComplianceSummaryByConfigRule -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

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

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

-- |
--
-- /See:/ 'newGetComplianceSummaryByConfigRuleResponse' smart constructor.
data GetComplianceSummaryByConfigRuleResponse = GetComplianceSummaryByConfigRuleResponse'
  { -- | The number of Config rules that are compliant and the number that are
    -- noncompliant, up to a maximum of 25 for each.
    GetComplianceSummaryByConfigRuleResponse -> Maybe ComplianceSummary
complianceSummary :: Prelude.Maybe ComplianceSummary,
    -- | The response's http status code.
    GetComplianceSummaryByConfigRuleResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetComplianceSummaryByConfigRuleResponse
-> GetComplianceSummaryByConfigRuleResponse -> Bool
(GetComplianceSummaryByConfigRuleResponse
 -> GetComplianceSummaryByConfigRuleResponse -> Bool)
-> (GetComplianceSummaryByConfigRuleResponse
    -> GetComplianceSummaryByConfigRuleResponse -> Bool)
-> Eq GetComplianceSummaryByConfigRuleResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetComplianceSummaryByConfigRuleResponse
-> GetComplianceSummaryByConfigRuleResponse -> Bool
$c/= :: GetComplianceSummaryByConfigRuleResponse
-> GetComplianceSummaryByConfigRuleResponse -> Bool
== :: GetComplianceSummaryByConfigRuleResponse
-> GetComplianceSummaryByConfigRuleResponse -> Bool
$c== :: GetComplianceSummaryByConfigRuleResponse
-> GetComplianceSummaryByConfigRuleResponse -> Bool
Prelude.Eq, ReadPrec [GetComplianceSummaryByConfigRuleResponse]
ReadPrec GetComplianceSummaryByConfigRuleResponse
Int -> ReadS GetComplianceSummaryByConfigRuleResponse
ReadS [GetComplianceSummaryByConfigRuleResponse]
(Int -> ReadS GetComplianceSummaryByConfigRuleResponse)
-> ReadS [GetComplianceSummaryByConfigRuleResponse]
-> ReadPrec GetComplianceSummaryByConfigRuleResponse
-> ReadPrec [GetComplianceSummaryByConfigRuleResponse]
-> Read GetComplianceSummaryByConfigRuleResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetComplianceSummaryByConfigRuleResponse]
$creadListPrec :: ReadPrec [GetComplianceSummaryByConfigRuleResponse]
readPrec :: ReadPrec GetComplianceSummaryByConfigRuleResponse
$creadPrec :: ReadPrec GetComplianceSummaryByConfigRuleResponse
readList :: ReadS [GetComplianceSummaryByConfigRuleResponse]
$creadList :: ReadS [GetComplianceSummaryByConfigRuleResponse]
readsPrec :: Int -> ReadS GetComplianceSummaryByConfigRuleResponse
$creadsPrec :: Int -> ReadS GetComplianceSummaryByConfigRuleResponse
Prelude.Read, Int -> GetComplianceSummaryByConfigRuleResponse -> ShowS
[GetComplianceSummaryByConfigRuleResponse] -> ShowS
GetComplianceSummaryByConfigRuleResponse -> String
(Int -> GetComplianceSummaryByConfigRuleResponse -> ShowS)
-> (GetComplianceSummaryByConfigRuleResponse -> String)
-> ([GetComplianceSummaryByConfigRuleResponse] -> ShowS)
-> Show GetComplianceSummaryByConfigRuleResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetComplianceSummaryByConfigRuleResponse] -> ShowS
$cshowList :: [GetComplianceSummaryByConfigRuleResponse] -> ShowS
show :: GetComplianceSummaryByConfigRuleResponse -> String
$cshow :: GetComplianceSummaryByConfigRuleResponse -> String
showsPrec :: Int -> GetComplianceSummaryByConfigRuleResponse -> ShowS
$cshowsPrec :: Int -> GetComplianceSummaryByConfigRuleResponse -> ShowS
Prelude.Show, (forall x.
 GetComplianceSummaryByConfigRuleResponse
 -> Rep GetComplianceSummaryByConfigRuleResponse x)
-> (forall x.
    Rep GetComplianceSummaryByConfigRuleResponse x
    -> GetComplianceSummaryByConfigRuleResponse)
-> Generic GetComplianceSummaryByConfigRuleResponse
forall x.
Rep GetComplianceSummaryByConfigRuleResponse x
-> GetComplianceSummaryByConfigRuleResponse
forall x.
GetComplianceSummaryByConfigRuleResponse
-> Rep GetComplianceSummaryByConfigRuleResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetComplianceSummaryByConfigRuleResponse x
-> GetComplianceSummaryByConfigRuleResponse
$cfrom :: forall x.
GetComplianceSummaryByConfigRuleResponse
-> Rep GetComplianceSummaryByConfigRuleResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetComplianceSummaryByConfigRuleResponse' 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:
--
-- 'complianceSummary', 'getComplianceSummaryByConfigRuleResponse_complianceSummary' - The number of Config rules that are compliant and the number that are
-- noncompliant, up to a maximum of 25 for each.
--
-- 'httpStatus', 'getComplianceSummaryByConfigRuleResponse_httpStatus' - The response's http status code.
newGetComplianceSummaryByConfigRuleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetComplianceSummaryByConfigRuleResponse
newGetComplianceSummaryByConfigRuleResponse :: Int -> GetComplianceSummaryByConfigRuleResponse
newGetComplianceSummaryByConfigRuleResponse
  Int
pHttpStatus_ =
    GetComplianceSummaryByConfigRuleResponse' :: Maybe ComplianceSummary
-> Int -> GetComplianceSummaryByConfigRuleResponse
GetComplianceSummaryByConfigRuleResponse'
      { $sel:complianceSummary:GetComplianceSummaryByConfigRuleResponse' :: Maybe ComplianceSummary
complianceSummary =
          Maybe ComplianceSummary
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:GetComplianceSummaryByConfigRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | The number of Config rules that are compliant and the number that are
-- noncompliant, up to a maximum of 25 for each.
getComplianceSummaryByConfigRuleResponse_complianceSummary :: Lens.Lens' GetComplianceSummaryByConfigRuleResponse (Prelude.Maybe ComplianceSummary)
getComplianceSummaryByConfigRuleResponse_complianceSummary :: (Maybe ComplianceSummary -> f (Maybe ComplianceSummary))
-> GetComplianceSummaryByConfigRuleResponse
-> f GetComplianceSummaryByConfigRuleResponse
getComplianceSummaryByConfigRuleResponse_complianceSummary = (GetComplianceSummaryByConfigRuleResponse
 -> Maybe ComplianceSummary)
-> (GetComplianceSummaryByConfigRuleResponse
    -> Maybe ComplianceSummary
    -> GetComplianceSummaryByConfigRuleResponse)
-> Lens
     GetComplianceSummaryByConfigRuleResponse
     GetComplianceSummaryByConfigRuleResponse
     (Maybe ComplianceSummary)
     (Maybe ComplianceSummary)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetComplianceSummaryByConfigRuleResponse' {Maybe ComplianceSummary
complianceSummary :: Maybe ComplianceSummary
$sel:complianceSummary:GetComplianceSummaryByConfigRuleResponse' :: GetComplianceSummaryByConfigRuleResponse -> Maybe ComplianceSummary
complianceSummary} -> Maybe ComplianceSummary
complianceSummary) (\s :: GetComplianceSummaryByConfigRuleResponse
s@GetComplianceSummaryByConfigRuleResponse' {} Maybe ComplianceSummary
a -> GetComplianceSummaryByConfigRuleResponse
s {$sel:complianceSummary:GetComplianceSummaryByConfigRuleResponse' :: Maybe ComplianceSummary
complianceSummary = Maybe ComplianceSummary
a} :: GetComplianceSummaryByConfigRuleResponse)

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

instance
  Prelude.NFData
    GetComplianceSummaryByConfigRuleResponse