{-# 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.DescribeComplianceByResource
-- 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 Amazon Web Services resources are
-- compliant. If a resource is noncompliant, this action returns the number
-- of Config rules that the resource does not comply with.
--
-- A resource is compliant if it complies with all the Config rules that
-- evaluate it. It is noncompliant if it does not comply with one or more
-- of these rules.
--
-- If Config has no current evaluation results for the resource, it returns
-- @INSUFFICIENT_DATA@. This result might indicate one of the following
-- conditions about the rules that evaluate the resource:
--
-- -   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 that 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.DescribeComplianceByResource
  ( -- * Creating a Request
    DescribeComplianceByResource (..),
    newDescribeComplianceByResource,

    -- * Request Lenses
    describeComplianceByResource_resourceId,
    describeComplianceByResource_resourceType,
    describeComplianceByResource_complianceTypes,
    describeComplianceByResource_nextToken,
    describeComplianceByResource_limit,

    -- * Destructuring the Response
    DescribeComplianceByResourceResponse (..),
    newDescribeComplianceByResourceResponse,

    -- * Response Lenses
    describeComplianceByResourceResponse_complianceByResources,
    describeComplianceByResourceResponse_nextToken,
    describeComplianceByResourceResponse_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:/ 'newDescribeComplianceByResource' smart constructor.
data DescribeComplianceByResource = DescribeComplianceByResource'
  { -- | The ID of the Amazon Web Services resource for which you want compliance
    -- information. You can specify only one resource ID. If you specify a
    -- resource ID, you must also specify a type for @ResourceType@.
    DescribeComplianceByResource -> Maybe Text
resourceId :: Prelude.Maybe Prelude.Text,
    -- | The types of Amazon Web Services resources for which you want compliance
    -- information (for example, @AWS::EC2::Instance@). For this action, you
    -- can specify that the resource type is an Amazon Web Services account by
    -- specifying @AWS::::Account@.
    DescribeComplianceByResource -> Maybe Text
resourceType :: Prelude.Maybe Prelude.Text,
    -- | Filters the results by compliance.
    --
    -- The allowed values are @COMPLIANT@, @NON_COMPLIANT@, and
    -- @INSUFFICIENT_DATA@.
    DescribeComplianceByResource -> 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.
    DescribeComplianceByResource -> 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.
    DescribeComplianceByResource -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural
  }
  deriving (DescribeComplianceByResource
-> DescribeComplianceByResource -> Bool
(DescribeComplianceByResource
 -> DescribeComplianceByResource -> Bool)
-> (DescribeComplianceByResource
    -> DescribeComplianceByResource -> Bool)
-> Eq DescribeComplianceByResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeComplianceByResource
-> DescribeComplianceByResource -> Bool
$c/= :: DescribeComplianceByResource
-> DescribeComplianceByResource -> Bool
== :: DescribeComplianceByResource
-> DescribeComplianceByResource -> Bool
$c== :: DescribeComplianceByResource
-> DescribeComplianceByResource -> Bool
Prelude.Eq, ReadPrec [DescribeComplianceByResource]
ReadPrec DescribeComplianceByResource
Int -> ReadS DescribeComplianceByResource
ReadS [DescribeComplianceByResource]
(Int -> ReadS DescribeComplianceByResource)
-> ReadS [DescribeComplianceByResource]
-> ReadPrec DescribeComplianceByResource
-> ReadPrec [DescribeComplianceByResource]
-> Read DescribeComplianceByResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeComplianceByResource]
$creadListPrec :: ReadPrec [DescribeComplianceByResource]
readPrec :: ReadPrec DescribeComplianceByResource
$creadPrec :: ReadPrec DescribeComplianceByResource
readList :: ReadS [DescribeComplianceByResource]
$creadList :: ReadS [DescribeComplianceByResource]
readsPrec :: Int -> ReadS DescribeComplianceByResource
$creadsPrec :: Int -> ReadS DescribeComplianceByResource
Prelude.Read, Int -> DescribeComplianceByResource -> ShowS
[DescribeComplianceByResource] -> ShowS
DescribeComplianceByResource -> String
(Int -> DescribeComplianceByResource -> ShowS)
-> (DescribeComplianceByResource -> String)
-> ([DescribeComplianceByResource] -> ShowS)
-> Show DescribeComplianceByResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeComplianceByResource] -> ShowS
$cshowList :: [DescribeComplianceByResource] -> ShowS
show :: DescribeComplianceByResource -> String
$cshow :: DescribeComplianceByResource -> String
showsPrec :: Int -> DescribeComplianceByResource -> ShowS
$cshowsPrec :: Int -> DescribeComplianceByResource -> ShowS
Prelude.Show, (forall x.
 DescribeComplianceByResource -> Rep DescribeComplianceByResource x)
-> (forall x.
    Rep DescribeComplianceByResource x -> DescribeComplianceByResource)
-> Generic DescribeComplianceByResource
forall x.
Rep DescribeComplianceByResource x -> DescribeComplianceByResource
forall x.
DescribeComplianceByResource -> Rep DescribeComplianceByResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeComplianceByResource x -> DescribeComplianceByResource
$cfrom :: forall x.
DescribeComplianceByResource -> Rep DescribeComplianceByResource x
Prelude.Generic)

-- |
-- Create a value of 'DescribeComplianceByResource' 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:
--
-- 'resourceId', 'describeComplianceByResource_resourceId' - The ID of the Amazon Web Services resource for which you want compliance
-- information. You can specify only one resource ID. If you specify a
-- resource ID, you must also specify a type for @ResourceType@.
--
-- 'resourceType', 'describeComplianceByResource_resourceType' - The types of Amazon Web Services resources for which you want compliance
-- information (for example, @AWS::EC2::Instance@). For this action, you
-- can specify that the resource type is an Amazon Web Services account by
-- specifying @AWS::::Account@.
--
-- 'complianceTypes', 'describeComplianceByResource_complianceTypes' - Filters the results by compliance.
--
-- The allowed values are @COMPLIANT@, @NON_COMPLIANT@, and
-- @INSUFFICIENT_DATA@.
--
-- 'nextToken', 'describeComplianceByResource_nextToken' - The @nextToken@ string returned on a previous page that you use to get
-- the next page of results in a paginated response.
--
-- 'limit', 'describeComplianceByResource_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.
newDescribeComplianceByResource ::
  DescribeComplianceByResource
newDescribeComplianceByResource :: DescribeComplianceByResource
newDescribeComplianceByResource =
  DescribeComplianceByResource' :: Maybe Text
-> Maybe Text
-> Maybe [ComplianceType]
-> Maybe Text
-> Maybe Natural
-> DescribeComplianceByResource
DescribeComplianceByResource'
    { $sel:resourceId:DescribeComplianceByResource' :: Maybe Text
resourceId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:DescribeComplianceByResource' :: Maybe Text
resourceType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:complianceTypes:DescribeComplianceByResource' :: Maybe [ComplianceType]
complianceTypes = Maybe [ComplianceType]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeComplianceByResource' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:limit:DescribeComplianceByResource' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the Amazon Web Services resource for which you want compliance
-- information. You can specify only one resource ID. If you specify a
-- resource ID, you must also specify a type for @ResourceType@.
describeComplianceByResource_resourceId :: Lens.Lens' DescribeComplianceByResource (Prelude.Maybe Prelude.Text)
describeComplianceByResource_resourceId :: (Maybe Text -> f (Maybe Text))
-> DescribeComplianceByResource -> f DescribeComplianceByResource
describeComplianceByResource_resourceId = (DescribeComplianceByResource -> Maybe Text)
-> (DescribeComplianceByResource
    -> Maybe Text -> DescribeComplianceByResource)
-> Lens
     DescribeComplianceByResource
     DescribeComplianceByResource
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeComplianceByResource' {Maybe Text
resourceId :: Maybe Text
$sel:resourceId:DescribeComplianceByResource' :: DescribeComplianceByResource -> Maybe Text
resourceId} -> Maybe Text
resourceId) (\s :: DescribeComplianceByResource
s@DescribeComplianceByResource' {} Maybe Text
a -> DescribeComplianceByResource
s {$sel:resourceId:DescribeComplianceByResource' :: Maybe Text
resourceId = Maybe Text
a} :: DescribeComplianceByResource)

-- | The types of Amazon Web Services resources for which you want compliance
-- information (for example, @AWS::EC2::Instance@). For this action, you
-- can specify that the resource type is an Amazon Web Services account by
-- specifying @AWS::::Account@.
describeComplianceByResource_resourceType :: Lens.Lens' DescribeComplianceByResource (Prelude.Maybe Prelude.Text)
describeComplianceByResource_resourceType :: (Maybe Text -> f (Maybe Text))
-> DescribeComplianceByResource -> f DescribeComplianceByResource
describeComplianceByResource_resourceType = (DescribeComplianceByResource -> Maybe Text)
-> (DescribeComplianceByResource
    -> Maybe Text -> DescribeComplianceByResource)
-> Lens
     DescribeComplianceByResource
     DescribeComplianceByResource
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeComplianceByResource' {Maybe Text
resourceType :: Maybe Text
$sel:resourceType:DescribeComplianceByResource' :: DescribeComplianceByResource -> Maybe Text
resourceType} -> Maybe Text
resourceType) (\s :: DescribeComplianceByResource
s@DescribeComplianceByResource' {} Maybe Text
a -> DescribeComplianceByResource
s {$sel:resourceType:DescribeComplianceByResource' :: Maybe Text
resourceType = Maybe Text
a} :: DescribeComplianceByResource)

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

-- | 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.
describeComplianceByResource_limit :: Lens.Lens' DescribeComplianceByResource (Prelude.Maybe Prelude.Natural)
describeComplianceByResource_limit :: (Maybe Natural -> f (Maybe Natural))
-> DescribeComplianceByResource -> f DescribeComplianceByResource
describeComplianceByResource_limit = (DescribeComplianceByResource -> Maybe Natural)
-> (DescribeComplianceByResource
    -> Maybe Natural -> DescribeComplianceByResource)
-> Lens
     DescribeComplianceByResource
     DescribeComplianceByResource
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeComplianceByResource' {Maybe Natural
limit :: Maybe Natural
$sel:limit:DescribeComplianceByResource' :: DescribeComplianceByResource -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: DescribeComplianceByResource
s@DescribeComplianceByResource' {} Maybe Natural
a -> DescribeComplianceByResource
s {$sel:limit:DescribeComplianceByResource' :: Maybe Natural
limit = Maybe Natural
a} :: DescribeComplianceByResource)

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

instance Prelude.NFData DescribeComplianceByResource

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

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

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

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

-- |
-- Create a value of 'DescribeComplianceByResourceResponse' 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:
--
-- 'complianceByResources', 'describeComplianceByResourceResponse_complianceByResources' - Indicates whether the specified Amazon Web Services resource complies
-- with all of the Config rules that evaluate it.
--
-- 'nextToken', 'describeComplianceByResourceResponse_nextToken' - The string that you use in a subsequent request to get the next page of
-- results in a paginated response.
--
-- 'httpStatus', 'describeComplianceByResourceResponse_httpStatus' - The response's http status code.
newDescribeComplianceByResourceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeComplianceByResourceResponse
newDescribeComplianceByResourceResponse :: Int -> DescribeComplianceByResourceResponse
newDescribeComplianceByResourceResponse Int
pHttpStatus_ =
  DescribeComplianceByResourceResponse' :: Maybe [ComplianceByResource]
-> Maybe Text -> Int -> DescribeComplianceByResourceResponse
DescribeComplianceByResourceResponse'
    { $sel:complianceByResources:DescribeComplianceByResourceResponse' :: Maybe [ComplianceByResource]
complianceByResources =
        Maybe [ComplianceByResource]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeComplianceByResourceResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeComplianceByResourceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Indicates whether the specified Amazon Web Services resource complies
-- with all of the Config rules that evaluate it.
describeComplianceByResourceResponse_complianceByResources :: Lens.Lens' DescribeComplianceByResourceResponse (Prelude.Maybe [ComplianceByResource])
describeComplianceByResourceResponse_complianceByResources :: (Maybe [ComplianceByResource] -> f (Maybe [ComplianceByResource]))
-> DescribeComplianceByResourceResponse
-> f DescribeComplianceByResourceResponse
describeComplianceByResourceResponse_complianceByResources = (DescribeComplianceByResourceResponse
 -> Maybe [ComplianceByResource])
-> (DescribeComplianceByResourceResponse
    -> Maybe [ComplianceByResource]
    -> DescribeComplianceByResourceResponse)
-> Lens'
     DescribeComplianceByResourceResponse (Maybe [ComplianceByResource])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeComplianceByResourceResponse' {Maybe [ComplianceByResource]
complianceByResources :: Maybe [ComplianceByResource]
$sel:complianceByResources:DescribeComplianceByResourceResponse' :: DescribeComplianceByResourceResponse
-> Maybe [ComplianceByResource]
complianceByResources} -> Maybe [ComplianceByResource]
complianceByResources) (\s :: DescribeComplianceByResourceResponse
s@DescribeComplianceByResourceResponse' {} Maybe [ComplianceByResource]
a -> DescribeComplianceByResourceResponse
s {$sel:complianceByResources:DescribeComplianceByResourceResponse' :: Maybe [ComplianceByResource]
complianceByResources = Maybe [ComplianceByResource]
a} :: DescribeComplianceByResourceResponse) ((Maybe [ComplianceByResource] -> f (Maybe [ComplianceByResource]))
 -> DescribeComplianceByResourceResponse
 -> f DescribeComplianceByResourceResponse)
-> ((Maybe [ComplianceByResource]
     -> f (Maybe [ComplianceByResource]))
    -> Maybe [ComplianceByResource]
    -> f (Maybe [ComplianceByResource]))
-> (Maybe [ComplianceByResource]
    -> f (Maybe [ComplianceByResource]))
-> DescribeComplianceByResourceResponse
-> f DescribeComplianceByResourceResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ComplianceByResource]
  [ComplianceByResource]
  [ComplianceByResource]
  [ComplianceByResource]
-> Iso
     (Maybe [ComplianceByResource])
     (Maybe [ComplianceByResource])
     (Maybe [ComplianceByResource])
     (Maybe [ComplianceByResource])
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
  [ComplianceByResource]
  [ComplianceByResource]
  [ComplianceByResource]
  [ComplianceByResource]
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.
describeComplianceByResourceResponse_nextToken :: Lens.Lens' DescribeComplianceByResourceResponse (Prelude.Maybe Prelude.Text)
describeComplianceByResourceResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeComplianceByResourceResponse
-> f DescribeComplianceByResourceResponse
describeComplianceByResourceResponse_nextToken = (DescribeComplianceByResourceResponse -> Maybe Text)
-> (DescribeComplianceByResourceResponse
    -> Maybe Text -> DescribeComplianceByResourceResponse)
-> Lens' DescribeComplianceByResourceResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeComplianceByResourceResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeComplianceByResourceResponse' :: DescribeComplianceByResourceResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeComplianceByResourceResponse
s@DescribeComplianceByResourceResponse' {} Maybe Text
a -> DescribeComplianceByResourceResponse
s {$sel:nextToken:DescribeComplianceByResourceResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeComplianceByResourceResponse)

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

instance
  Prelude.NFData
    DescribeComplianceByResourceResponse