{-# 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.GetComplianceDetailsByResource
-- 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 Amazon Web Services
-- resource. The results indicate which Config rules were used to evaluate
-- the resource, when each rule was last used, and whether the resource
-- complies with each rule.
--
-- This operation returns paginated results.
module Amazonka.Config.GetComplianceDetailsByResource
  ( -- * Creating a Request
    GetComplianceDetailsByResource (..),
    newGetComplianceDetailsByResource,

    -- * Request Lenses
    getComplianceDetailsByResource_complianceTypes,
    getComplianceDetailsByResource_nextToken,
    getComplianceDetailsByResource_resourceType,
    getComplianceDetailsByResource_resourceId,

    -- * Destructuring the Response
    GetComplianceDetailsByResourceResponse (..),
    newGetComplianceDetailsByResourceResponse,

    -- * Response Lenses
    getComplianceDetailsByResourceResponse_evaluationResults,
    getComplianceDetailsByResourceResponse_nextToken,
    getComplianceDetailsByResourceResponse_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:/ 'newGetComplianceDetailsByResource' smart constructor.
data GetComplianceDetailsByResource = GetComplianceDetailsByResource'
  { -- | Filters the results by compliance.
    --
    -- The allowed values are @COMPLIANT@, @NON_COMPLIANT@, and
    -- @NOT_APPLICABLE@.
    GetComplianceDetailsByResource -> 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.
    GetComplianceDetailsByResource -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The type of the Amazon Web Services resource for which you want
    -- compliance information.
    GetComplianceDetailsByResource -> Text
resourceType :: Prelude.Text,
    -- | The ID of the Amazon Web Services resource for which you want compliance
    -- information.
    GetComplianceDetailsByResource -> Text
resourceId :: Prelude.Text
  }
  deriving (GetComplianceDetailsByResource
-> GetComplianceDetailsByResource -> Bool
(GetComplianceDetailsByResource
 -> GetComplianceDetailsByResource -> Bool)
-> (GetComplianceDetailsByResource
    -> GetComplianceDetailsByResource -> Bool)
-> Eq GetComplianceDetailsByResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetComplianceDetailsByResource
-> GetComplianceDetailsByResource -> Bool
$c/= :: GetComplianceDetailsByResource
-> GetComplianceDetailsByResource -> Bool
== :: GetComplianceDetailsByResource
-> GetComplianceDetailsByResource -> Bool
$c== :: GetComplianceDetailsByResource
-> GetComplianceDetailsByResource -> Bool
Prelude.Eq, ReadPrec [GetComplianceDetailsByResource]
ReadPrec GetComplianceDetailsByResource
Int -> ReadS GetComplianceDetailsByResource
ReadS [GetComplianceDetailsByResource]
(Int -> ReadS GetComplianceDetailsByResource)
-> ReadS [GetComplianceDetailsByResource]
-> ReadPrec GetComplianceDetailsByResource
-> ReadPrec [GetComplianceDetailsByResource]
-> Read GetComplianceDetailsByResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetComplianceDetailsByResource]
$creadListPrec :: ReadPrec [GetComplianceDetailsByResource]
readPrec :: ReadPrec GetComplianceDetailsByResource
$creadPrec :: ReadPrec GetComplianceDetailsByResource
readList :: ReadS [GetComplianceDetailsByResource]
$creadList :: ReadS [GetComplianceDetailsByResource]
readsPrec :: Int -> ReadS GetComplianceDetailsByResource
$creadsPrec :: Int -> ReadS GetComplianceDetailsByResource
Prelude.Read, Int -> GetComplianceDetailsByResource -> ShowS
[GetComplianceDetailsByResource] -> ShowS
GetComplianceDetailsByResource -> String
(Int -> GetComplianceDetailsByResource -> ShowS)
-> (GetComplianceDetailsByResource -> String)
-> ([GetComplianceDetailsByResource] -> ShowS)
-> Show GetComplianceDetailsByResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetComplianceDetailsByResource] -> ShowS
$cshowList :: [GetComplianceDetailsByResource] -> ShowS
show :: GetComplianceDetailsByResource -> String
$cshow :: GetComplianceDetailsByResource -> String
showsPrec :: Int -> GetComplianceDetailsByResource -> ShowS
$cshowsPrec :: Int -> GetComplianceDetailsByResource -> ShowS
Prelude.Show, (forall x.
 GetComplianceDetailsByResource
 -> Rep GetComplianceDetailsByResource x)
-> (forall x.
    Rep GetComplianceDetailsByResource x
    -> GetComplianceDetailsByResource)
-> Generic GetComplianceDetailsByResource
forall x.
Rep GetComplianceDetailsByResource x
-> GetComplianceDetailsByResource
forall x.
GetComplianceDetailsByResource
-> Rep GetComplianceDetailsByResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetComplianceDetailsByResource x
-> GetComplianceDetailsByResource
$cfrom :: forall x.
GetComplianceDetailsByResource
-> Rep GetComplianceDetailsByResource x
Prelude.Generic)

-- |
-- Create a value of 'GetComplianceDetailsByResource' 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', 'getComplianceDetailsByResource_complianceTypes' - Filters the results by compliance.
--
-- The allowed values are @COMPLIANT@, @NON_COMPLIANT@, and
-- @NOT_APPLICABLE@.
--
-- 'nextToken', 'getComplianceDetailsByResource_nextToken' - The @nextToken@ string returned on a previous page that you use to get
-- the next page of results in a paginated response.
--
-- 'resourceType', 'getComplianceDetailsByResource_resourceType' - The type of the Amazon Web Services resource for which you want
-- compliance information.
--
-- 'resourceId', 'getComplianceDetailsByResource_resourceId' - The ID of the Amazon Web Services resource for which you want compliance
-- information.
newGetComplianceDetailsByResource ::
  -- | 'resourceType'
  Prelude.Text ->
  -- | 'resourceId'
  Prelude.Text ->
  GetComplianceDetailsByResource
newGetComplianceDetailsByResource :: Text -> Text -> GetComplianceDetailsByResource
newGetComplianceDetailsByResource
  Text
pResourceType_
  Text
pResourceId_ =
    GetComplianceDetailsByResource' :: Maybe [ComplianceType]
-> Maybe Text -> Text -> Text -> GetComplianceDetailsByResource
GetComplianceDetailsByResource'
      { $sel:complianceTypes:GetComplianceDetailsByResource' :: Maybe [ComplianceType]
complianceTypes =
          Maybe [ComplianceType]
forall a. Maybe a
Prelude.Nothing,
        $sel:nextToken:GetComplianceDetailsByResource' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:resourceType:GetComplianceDetailsByResource' :: Text
resourceType = Text
pResourceType_,
        $sel:resourceId:GetComplianceDetailsByResource' :: Text
resourceId = Text
pResourceId_
      }

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

-- | The type of the Amazon Web Services resource for which you want
-- compliance information.
getComplianceDetailsByResource_resourceType :: Lens.Lens' GetComplianceDetailsByResource Prelude.Text
getComplianceDetailsByResource_resourceType :: (Text -> f Text)
-> GetComplianceDetailsByResource
-> f GetComplianceDetailsByResource
getComplianceDetailsByResource_resourceType = (GetComplianceDetailsByResource -> Text)
-> (GetComplianceDetailsByResource
    -> Text -> GetComplianceDetailsByResource)
-> Lens
     GetComplianceDetailsByResource
     GetComplianceDetailsByResource
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetComplianceDetailsByResource' {Text
resourceType :: Text
$sel:resourceType:GetComplianceDetailsByResource' :: GetComplianceDetailsByResource -> Text
resourceType} -> Text
resourceType) (\s :: GetComplianceDetailsByResource
s@GetComplianceDetailsByResource' {} Text
a -> GetComplianceDetailsByResource
s {$sel:resourceType:GetComplianceDetailsByResource' :: Text
resourceType = Text
a} :: GetComplianceDetailsByResource)

-- | The ID of the Amazon Web Services resource for which you want compliance
-- information.
getComplianceDetailsByResource_resourceId :: Lens.Lens' GetComplianceDetailsByResource Prelude.Text
getComplianceDetailsByResource_resourceId :: (Text -> f Text)
-> GetComplianceDetailsByResource
-> f GetComplianceDetailsByResource
getComplianceDetailsByResource_resourceId = (GetComplianceDetailsByResource -> Text)
-> (GetComplianceDetailsByResource
    -> Text -> GetComplianceDetailsByResource)
-> Lens
     GetComplianceDetailsByResource
     GetComplianceDetailsByResource
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetComplianceDetailsByResource' {Text
resourceId :: Text
$sel:resourceId:GetComplianceDetailsByResource' :: GetComplianceDetailsByResource -> Text
resourceId} -> Text
resourceId) (\s :: GetComplianceDetailsByResource
s@GetComplianceDetailsByResource' {} Text
a -> GetComplianceDetailsByResource
s {$sel:resourceId:GetComplianceDetailsByResource' :: Text
resourceId = Text
a} :: GetComplianceDetailsByResource)

instance Core.AWSPager GetComplianceDetailsByResource where
  page :: GetComplianceDetailsByResource
-> AWSResponse GetComplianceDetailsByResource
-> Maybe GetComplianceDetailsByResource
page GetComplianceDetailsByResource
rq AWSResponse GetComplianceDetailsByResource
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetComplianceDetailsByResource
GetComplianceDetailsByResourceResponse
rs
            GetComplianceDetailsByResourceResponse
-> Getting (First Text) GetComplianceDetailsByResourceResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetComplianceDetailsByResourceResponse
-> Const (First Text) GetComplianceDetailsByResourceResponse
Lens' GetComplianceDetailsByResourceResponse (Maybe Text)
getComplianceDetailsByResourceResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetComplianceDetailsByResourceResponse
 -> Const (First Text) GetComplianceDetailsByResourceResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetComplianceDetailsByResourceResponse 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 GetComplianceDetailsByResource
forall a. Maybe a
Prelude.Nothing
    | Maybe [EvaluationResult] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetComplianceDetailsByResource
GetComplianceDetailsByResourceResponse
rs
            GetComplianceDetailsByResourceResponse
-> Getting
     (First [EvaluationResult])
     GetComplianceDetailsByResourceResponse
     [EvaluationResult]
-> Maybe [EvaluationResult]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [EvaluationResult]
 -> Const (First [EvaluationResult]) (Maybe [EvaluationResult]))
-> GetComplianceDetailsByResourceResponse
-> Const
     (First [EvaluationResult]) GetComplianceDetailsByResourceResponse
Lens'
  GetComplianceDetailsByResourceResponse (Maybe [EvaluationResult])
getComplianceDetailsByResourceResponse_evaluationResults
              ((Maybe [EvaluationResult]
  -> Const (First [EvaluationResult]) (Maybe [EvaluationResult]))
 -> GetComplianceDetailsByResourceResponse
 -> Const
      (First [EvaluationResult]) GetComplianceDetailsByResourceResponse)
-> (([EvaluationResult]
     -> Const (First [EvaluationResult]) [EvaluationResult])
    -> Maybe [EvaluationResult]
    -> Const (First [EvaluationResult]) (Maybe [EvaluationResult]))
-> Getting
     (First [EvaluationResult])
     GetComplianceDetailsByResourceResponse
     [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 GetComplianceDetailsByResource
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      GetComplianceDetailsByResource
-> Maybe GetComplianceDetailsByResource
forall a. a -> Maybe a
Prelude.Just (GetComplianceDetailsByResource
 -> Maybe GetComplianceDetailsByResource)
-> GetComplianceDetailsByResource
-> Maybe GetComplianceDetailsByResource
forall a b. (a -> b) -> a -> b
Prelude.$
        GetComplianceDetailsByResource
rq
          GetComplianceDetailsByResource
-> (GetComplianceDetailsByResource
    -> GetComplianceDetailsByResource)
-> GetComplianceDetailsByResource
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> GetComplianceDetailsByResource
-> Identity GetComplianceDetailsByResource
Lens
  GetComplianceDetailsByResource
  GetComplianceDetailsByResource
  (Maybe Text)
  (Maybe Text)
getComplianceDetailsByResource_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> GetComplianceDetailsByResource
 -> Identity GetComplianceDetailsByResource)
-> Maybe Text
-> GetComplianceDetailsByResource
-> GetComplianceDetailsByResource
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetComplianceDetailsByResource
GetComplianceDetailsByResourceResponse
rs
          GetComplianceDetailsByResourceResponse
-> Getting (First Text) GetComplianceDetailsByResourceResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetComplianceDetailsByResourceResponse
-> Const (First Text) GetComplianceDetailsByResourceResponse
Lens' GetComplianceDetailsByResourceResponse (Maybe Text)
getComplianceDetailsByResourceResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetComplianceDetailsByResourceResponse
 -> Const (First Text) GetComplianceDetailsByResourceResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetComplianceDetailsByResourceResponse 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
    GetComplianceDetailsByResource
  where
  type
    AWSResponse GetComplianceDetailsByResource =
      GetComplianceDetailsByResourceResponse
  request :: GetComplianceDetailsByResource
-> Request GetComplianceDetailsByResource
request = Service
-> GetComplianceDetailsByResource
-> Request GetComplianceDetailsByResource
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetComplianceDetailsByResource
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse GetComplianceDetailsByResource)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetComplianceDetailsByResource))
-> Logger
-> Service
-> Proxy GetComplianceDetailsByResource
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse GetComplianceDetailsByResource)))
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 -> GetComplianceDetailsByResourceResponse
GetComplianceDetailsByResourceResponse'
            (Maybe [EvaluationResult]
 -> Maybe Text -> Int -> GetComplianceDetailsByResourceResponse)
-> Either String (Maybe [EvaluationResult])
-> Either
     String
     (Maybe Text -> Int -> GetComplianceDetailsByResourceResponse)
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 -> GetComplianceDetailsByResourceResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetComplianceDetailsByResourceResponse)
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 -> GetComplianceDetailsByResourceResponse)
-> Either String Int
-> Either String GetComplianceDetailsByResourceResponse
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
    GetComplianceDetailsByResource

instance
  Prelude.NFData
    GetComplianceDetailsByResource

instance
  Core.ToHeaders
    GetComplianceDetailsByResource
  where
  toHeaders :: GetComplianceDetailsByResource -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> GetComplianceDetailsByResource -> 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.GetComplianceDetailsByResource" ::
                          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 GetComplianceDetailsByResource where
  toJSON :: GetComplianceDetailsByResource -> Value
toJSON GetComplianceDetailsByResource' {Maybe [ComplianceType]
Maybe Text
Text
resourceId :: Text
resourceType :: Text
nextToken :: Maybe Text
complianceTypes :: Maybe [ComplianceType]
$sel:resourceId:GetComplianceDetailsByResource' :: GetComplianceDetailsByResource -> Text
$sel:resourceType:GetComplianceDetailsByResource' :: GetComplianceDetailsByResource -> Text
$sel:nextToken:GetComplianceDetailsByResource' :: GetComplianceDetailsByResource -> Maybe Text
$sel:complianceTypes:GetComplianceDetailsByResource' :: GetComplianceDetailsByResource -> 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,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ResourceType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resourceType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ResourceId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resourceId)
          ]
      )

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

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

-- |
--
-- /See:/ 'newGetComplianceDetailsByResourceResponse' smart constructor.
data GetComplianceDetailsByResourceResponse = GetComplianceDetailsByResourceResponse'
  { -- | Indicates whether the specified Amazon Web Services resource complies
    -- each Config rule.
    GetComplianceDetailsByResourceResponse -> 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.
    GetComplianceDetailsByResourceResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetComplianceDetailsByResourceResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetComplianceDetailsByResourceResponse
-> GetComplianceDetailsByResourceResponse -> Bool
(GetComplianceDetailsByResourceResponse
 -> GetComplianceDetailsByResourceResponse -> Bool)
-> (GetComplianceDetailsByResourceResponse
    -> GetComplianceDetailsByResourceResponse -> Bool)
-> Eq GetComplianceDetailsByResourceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetComplianceDetailsByResourceResponse
-> GetComplianceDetailsByResourceResponse -> Bool
$c/= :: GetComplianceDetailsByResourceResponse
-> GetComplianceDetailsByResourceResponse -> Bool
== :: GetComplianceDetailsByResourceResponse
-> GetComplianceDetailsByResourceResponse -> Bool
$c== :: GetComplianceDetailsByResourceResponse
-> GetComplianceDetailsByResourceResponse -> Bool
Prelude.Eq, ReadPrec [GetComplianceDetailsByResourceResponse]
ReadPrec GetComplianceDetailsByResourceResponse
Int -> ReadS GetComplianceDetailsByResourceResponse
ReadS [GetComplianceDetailsByResourceResponse]
(Int -> ReadS GetComplianceDetailsByResourceResponse)
-> ReadS [GetComplianceDetailsByResourceResponse]
-> ReadPrec GetComplianceDetailsByResourceResponse
-> ReadPrec [GetComplianceDetailsByResourceResponse]
-> Read GetComplianceDetailsByResourceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetComplianceDetailsByResourceResponse]
$creadListPrec :: ReadPrec [GetComplianceDetailsByResourceResponse]
readPrec :: ReadPrec GetComplianceDetailsByResourceResponse
$creadPrec :: ReadPrec GetComplianceDetailsByResourceResponse
readList :: ReadS [GetComplianceDetailsByResourceResponse]
$creadList :: ReadS [GetComplianceDetailsByResourceResponse]
readsPrec :: Int -> ReadS GetComplianceDetailsByResourceResponse
$creadsPrec :: Int -> ReadS GetComplianceDetailsByResourceResponse
Prelude.Read, Int -> GetComplianceDetailsByResourceResponse -> ShowS
[GetComplianceDetailsByResourceResponse] -> ShowS
GetComplianceDetailsByResourceResponse -> String
(Int -> GetComplianceDetailsByResourceResponse -> ShowS)
-> (GetComplianceDetailsByResourceResponse -> String)
-> ([GetComplianceDetailsByResourceResponse] -> ShowS)
-> Show GetComplianceDetailsByResourceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetComplianceDetailsByResourceResponse] -> ShowS
$cshowList :: [GetComplianceDetailsByResourceResponse] -> ShowS
show :: GetComplianceDetailsByResourceResponse -> String
$cshow :: GetComplianceDetailsByResourceResponse -> String
showsPrec :: Int -> GetComplianceDetailsByResourceResponse -> ShowS
$cshowsPrec :: Int -> GetComplianceDetailsByResourceResponse -> ShowS
Prelude.Show, (forall x.
 GetComplianceDetailsByResourceResponse
 -> Rep GetComplianceDetailsByResourceResponse x)
-> (forall x.
    Rep GetComplianceDetailsByResourceResponse x
    -> GetComplianceDetailsByResourceResponse)
-> Generic GetComplianceDetailsByResourceResponse
forall x.
Rep GetComplianceDetailsByResourceResponse x
-> GetComplianceDetailsByResourceResponse
forall x.
GetComplianceDetailsByResourceResponse
-> Rep GetComplianceDetailsByResourceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetComplianceDetailsByResourceResponse x
-> GetComplianceDetailsByResourceResponse
$cfrom :: forall x.
GetComplianceDetailsByResourceResponse
-> Rep GetComplianceDetailsByResourceResponse x
Prelude.Generic)

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

-- | Indicates whether the specified Amazon Web Services resource complies
-- each Config rule.
getComplianceDetailsByResourceResponse_evaluationResults :: Lens.Lens' GetComplianceDetailsByResourceResponse (Prelude.Maybe [EvaluationResult])
getComplianceDetailsByResourceResponse_evaluationResults :: (Maybe [EvaluationResult] -> f (Maybe [EvaluationResult]))
-> GetComplianceDetailsByResourceResponse
-> f GetComplianceDetailsByResourceResponse
getComplianceDetailsByResourceResponse_evaluationResults = (GetComplianceDetailsByResourceResponse
 -> Maybe [EvaluationResult])
-> (GetComplianceDetailsByResourceResponse
    -> Maybe [EvaluationResult]
    -> GetComplianceDetailsByResourceResponse)
-> Lens'
     GetComplianceDetailsByResourceResponse (Maybe [EvaluationResult])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetComplianceDetailsByResourceResponse' {Maybe [EvaluationResult]
evaluationResults :: Maybe [EvaluationResult]
$sel:evaluationResults:GetComplianceDetailsByResourceResponse' :: GetComplianceDetailsByResourceResponse -> Maybe [EvaluationResult]
evaluationResults} -> Maybe [EvaluationResult]
evaluationResults) (\s :: GetComplianceDetailsByResourceResponse
s@GetComplianceDetailsByResourceResponse' {} Maybe [EvaluationResult]
a -> GetComplianceDetailsByResourceResponse
s {$sel:evaluationResults:GetComplianceDetailsByResourceResponse' :: Maybe [EvaluationResult]
evaluationResults = Maybe [EvaluationResult]
a} :: GetComplianceDetailsByResourceResponse) ((Maybe [EvaluationResult] -> f (Maybe [EvaluationResult]))
 -> GetComplianceDetailsByResourceResponse
 -> f GetComplianceDetailsByResourceResponse)
-> ((Maybe [EvaluationResult] -> f (Maybe [EvaluationResult]))
    -> Maybe [EvaluationResult] -> f (Maybe [EvaluationResult]))
-> (Maybe [EvaluationResult] -> f (Maybe [EvaluationResult]))
-> GetComplianceDetailsByResourceResponse
-> f GetComplianceDetailsByResourceResponse
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.
getComplianceDetailsByResourceResponse_nextToken :: Lens.Lens' GetComplianceDetailsByResourceResponse (Prelude.Maybe Prelude.Text)
getComplianceDetailsByResourceResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetComplianceDetailsByResourceResponse
-> f GetComplianceDetailsByResourceResponse
getComplianceDetailsByResourceResponse_nextToken = (GetComplianceDetailsByResourceResponse -> Maybe Text)
-> (GetComplianceDetailsByResourceResponse
    -> Maybe Text -> GetComplianceDetailsByResourceResponse)
-> Lens' GetComplianceDetailsByResourceResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetComplianceDetailsByResourceResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetComplianceDetailsByResourceResponse' :: GetComplianceDetailsByResourceResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetComplianceDetailsByResourceResponse
s@GetComplianceDetailsByResourceResponse' {} Maybe Text
a -> GetComplianceDetailsByResourceResponse
s {$sel:nextToken:GetComplianceDetailsByResourceResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetComplianceDetailsByResourceResponse)

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

instance
  Prelude.NFData
    GetComplianceDetailsByResourceResponse