{-# 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.FMS.GetComplianceDetail
-- 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 detailed compliance information about the specified member
-- account. Details include resources that are in and out of compliance
-- with the specified policy.
--
-- -   Resources are considered noncompliant for WAF and Shield Advanced
--     policies if the specified policy has not been applied to them.
--
-- -   Resources are considered noncompliant for security group policies if
--     they are in scope of the policy, they violate one or more of the
--     policy rules, and remediation is disabled or not possible.
--
-- -   Resources are considered noncompliant for Network Firewall policies
--     if a firewall is missing in the VPC, if the firewall endpoint isn\'t
--     set up in an expected Availability Zone and subnet, if a subnet
--     created by the Firewall Manager doesn\'t have the expected route
--     table, and for modifications to a firewall policy that violate the
--     Firewall Manager policy\'s rules.
--
-- -   Resources are considered noncompliant for DNS Firewall policies if a
--     DNS Firewall rule group is missing from the rule group associations
--     for the VPC.
module Amazonka.FMS.GetComplianceDetail
  ( -- * Creating a Request
    GetComplianceDetail (..),
    newGetComplianceDetail,

    -- * Request Lenses
    getComplianceDetail_policyId,
    getComplianceDetail_memberAccount,

    -- * Destructuring the Response
    GetComplianceDetailResponse (..),
    newGetComplianceDetailResponse,

    -- * Response Lenses
    getComplianceDetailResponse_policyComplianceDetail,
    getComplianceDetailResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.FMS.Types
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:/ 'newGetComplianceDetail' smart constructor.
data GetComplianceDetail = GetComplianceDetail'
  { -- | The ID of the policy that you want to get the details for. @PolicyId@ is
    -- returned by @PutPolicy@ and by @ListPolicies@.
    GetComplianceDetail -> Text
policyId :: Prelude.Text,
    -- | The Amazon Web Services account that owns the resources that you want to
    -- get the details for.
    GetComplianceDetail -> Text
memberAccount :: Prelude.Text
  }
  deriving (GetComplianceDetail -> GetComplianceDetail -> Bool
(GetComplianceDetail -> GetComplianceDetail -> Bool)
-> (GetComplianceDetail -> GetComplianceDetail -> Bool)
-> Eq GetComplianceDetail
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetComplianceDetail -> GetComplianceDetail -> Bool
$c/= :: GetComplianceDetail -> GetComplianceDetail -> Bool
== :: GetComplianceDetail -> GetComplianceDetail -> Bool
$c== :: GetComplianceDetail -> GetComplianceDetail -> Bool
Prelude.Eq, ReadPrec [GetComplianceDetail]
ReadPrec GetComplianceDetail
Int -> ReadS GetComplianceDetail
ReadS [GetComplianceDetail]
(Int -> ReadS GetComplianceDetail)
-> ReadS [GetComplianceDetail]
-> ReadPrec GetComplianceDetail
-> ReadPrec [GetComplianceDetail]
-> Read GetComplianceDetail
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetComplianceDetail]
$creadListPrec :: ReadPrec [GetComplianceDetail]
readPrec :: ReadPrec GetComplianceDetail
$creadPrec :: ReadPrec GetComplianceDetail
readList :: ReadS [GetComplianceDetail]
$creadList :: ReadS [GetComplianceDetail]
readsPrec :: Int -> ReadS GetComplianceDetail
$creadsPrec :: Int -> ReadS GetComplianceDetail
Prelude.Read, Int -> GetComplianceDetail -> ShowS
[GetComplianceDetail] -> ShowS
GetComplianceDetail -> String
(Int -> GetComplianceDetail -> ShowS)
-> (GetComplianceDetail -> String)
-> ([GetComplianceDetail] -> ShowS)
-> Show GetComplianceDetail
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetComplianceDetail] -> ShowS
$cshowList :: [GetComplianceDetail] -> ShowS
show :: GetComplianceDetail -> String
$cshow :: GetComplianceDetail -> String
showsPrec :: Int -> GetComplianceDetail -> ShowS
$cshowsPrec :: Int -> GetComplianceDetail -> ShowS
Prelude.Show, (forall x. GetComplianceDetail -> Rep GetComplianceDetail x)
-> (forall x. Rep GetComplianceDetail x -> GetComplianceDetail)
-> Generic GetComplianceDetail
forall x. Rep GetComplianceDetail x -> GetComplianceDetail
forall x. GetComplianceDetail -> Rep GetComplianceDetail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetComplianceDetail x -> GetComplianceDetail
$cfrom :: forall x. GetComplianceDetail -> Rep GetComplianceDetail x
Prelude.Generic)

-- |
-- Create a value of 'GetComplianceDetail' 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:
--
-- 'policyId', 'getComplianceDetail_policyId' - The ID of the policy that you want to get the details for. @PolicyId@ is
-- returned by @PutPolicy@ and by @ListPolicies@.
--
-- 'memberAccount', 'getComplianceDetail_memberAccount' - The Amazon Web Services account that owns the resources that you want to
-- get the details for.
newGetComplianceDetail ::
  -- | 'policyId'
  Prelude.Text ->
  -- | 'memberAccount'
  Prelude.Text ->
  GetComplianceDetail
newGetComplianceDetail :: Text -> Text -> GetComplianceDetail
newGetComplianceDetail Text
pPolicyId_ Text
pMemberAccount_ =
  GetComplianceDetail' :: Text -> Text -> GetComplianceDetail
GetComplianceDetail'
    { $sel:policyId:GetComplianceDetail' :: Text
policyId = Text
pPolicyId_,
      $sel:memberAccount:GetComplianceDetail' :: Text
memberAccount = Text
pMemberAccount_
    }

-- | The ID of the policy that you want to get the details for. @PolicyId@ is
-- returned by @PutPolicy@ and by @ListPolicies@.
getComplianceDetail_policyId :: Lens.Lens' GetComplianceDetail Prelude.Text
getComplianceDetail_policyId :: (Text -> f Text) -> GetComplianceDetail -> f GetComplianceDetail
getComplianceDetail_policyId = (GetComplianceDetail -> Text)
-> (GetComplianceDetail -> Text -> GetComplianceDetail)
-> Lens GetComplianceDetail GetComplianceDetail Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetComplianceDetail' {Text
policyId :: Text
$sel:policyId:GetComplianceDetail' :: GetComplianceDetail -> Text
policyId} -> Text
policyId) (\s :: GetComplianceDetail
s@GetComplianceDetail' {} Text
a -> GetComplianceDetail
s {$sel:policyId:GetComplianceDetail' :: Text
policyId = Text
a} :: GetComplianceDetail)

-- | The Amazon Web Services account that owns the resources that you want to
-- get the details for.
getComplianceDetail_memberAccount :: Lens.Lens' GetComplianceDetail Prelude.Text
getComplianceDetail_memberAccount :: (Text -> f Text) -> GetComplianceDetail -> f GetComplianceDetail
getComplianceDetail_memberAccount = (GetComplianceDetail -> Text)
-> (GetComplianceDetail -> Text -> GetComplianceDetail)
-> Lens GetComplianceDetail GetComplianceDetail Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetComplianceDetail' {Text
memberAccount :: Text
$sel:memberAccount:GetComplianceDetail' :: GetComplianceDetail -> Text
memberAccount} -> Text
memberAccount) (\s :: GetComplianceDetail
s@GetComplianceDetail' {} Text
a -> GetComplianceDetail
s {$sel:memberAccount:GetComplianceDetail' :: Text
memberAccount = Text
a} :: GetComplianceDetail)

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

instance Prelude.NFData GetComplianceDetail

instance Core.ToHeaders GetComplianceDetail where
  toHeaders :: GetComplianceDetail -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetComplianceDetail -> 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
"AWSFMS_20180101.GetComplianceDetail" ::
                          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 GetComplianceDetail where
  toJSON :: GetComplianceDetail -> Value
toJSON GetComplianceDetail' {Text
memberAccount :: Text
policyId :: Text
$sel:memberAccount:GetComplianceDetail' :: GetComplianceDetail -> Text
$sel:policyId:GetComplianceDetail' :: GetComplianceDetail -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"PolicyId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
policyId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"MemberAccount" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
memberAccount)
          ]
      )

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

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

-- | /See:/ 'newGetComplianceDetailResponse' smart constructor.
data GetComplianceDetailResponse = GetComplianceDetailResponse'
  { -- | Information about the resources and the policy that you specified in the
    -- @GetComplianceDetail@ request.
    GetComplianceDetailResponse -> Maybe PolicyComplianceDetail
policyComplianceDetail :: Prelude.Maybe PolicyComplianceDetail,
    -- | The response's http status code.
    GetComplianceDetailResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetComplianceDetailResponse -> GetComplianceDetailResponse -> Bool
(GetComplianceDetailResponse
 -> GetComplianceDetailResponse -> Bool)
-> (GetComplianceDetailResponse
    -> GetComplianceDetailResponse -> Bool)
-> Eq GetComplianceDetailResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetComplianceDetailResponse -> GetComplianceDetailResponse -> Bool
$c/= :: GetComplianceDetailResponse -> GetComplianceDetailResponse -> Bool
== :: GetComplianceDetailResponse -> GetComplianceDetailResponse -> Bool
$c== :: GetComplianceDetailResponse -> GetComplianceDetailResponse -> Bool
Prelude.Eq, ReadPrec [GetComplianceDetailResponse]
ReadPrec GetComplianceDetailResponse
Int -> ReadS GetComplianceDetailResponse
ReadS [GetComplianceDetailResponse]
(Int -> ReadS GetComplianceDetailResponse)
-> ReadS [GetComplianceDetailResponse]
-> ReadPrec GetComplianceDetailResponse
-> ReadPrec [GetComplianceDetailResponse]
-> Read GetComplianceDetailResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetComplianceDetailResponse]
$creadListPrec :: ReadPrec [GetComplianceDetailResponse]
readPrec :: ReadPrec GetComplianceDetailResponse
$creadPrec :: ReadPrec GetComplianceDetailResponse
readList :: ReadS [GetComplianceDetailResponse]
$creadList :: ReadS [GetComplianceDetailResponse]
readsPrec :: Int -> ReadS GetComplianceDetailResponse
$creadsPrec :: Int -> ReadS GetComplianceDetailResponse
Prelude.Read, Int -> GetComplianceDetailResponse -> ShowS
[GetComplianceDetailResponse] -> ShowS
GetComplianceDetailResponse -> String
(Int -> GetComplianceDetailResponse -> ShowS)
-> (GetComplianceDetailResponse -> String)
-> ([GetComplianceDetailResponse] -> ShowS)
-> Show GetComplianceDetailResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetComplianceDetailResponse] -> ShowS
$cshowList :: [GetComplianceDetailResponse] -> ShowS
show :: GetComplianceDetailResponse -> String
$cshow :: GetComplianceDetailResponse -> String
showsPrec :: Int -> GetComplianceDetailResponse -> ShowS
$cshowsPrec :: Int -> GetComplianceDetailResponse -> ShowS
Prelude.Show, (forall x.
 GetComplianceDetailResponse -> Rep GetComplianceDetailResponse x)
-> (forall x.
    Rep GetComplianceDetailResponse x -> GetComplianceDetailResponse)
-> Generic GetComplianceDetailResponse
forall x.
Rep GetComplianceDetailResponse x -> GetComplianceDetailResponse
forall x.
GetComplianceDetailResponse -> Rep GetComplianceDetailResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetComplianceDetailResponse x -> GetComplianceDetailResponse
$cfrom :: forall x.
GetComplianceDetailResponse -> Rep GetComplianceDetailResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetComplianceDetailResponse' 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:
--
-- 'policyComplianceDetail', 'getComplianceDetailResponse_policyComplianceDetail' - Information about the resources and the policy that you specified in the
-- @GetComplianceDetail@ request.
--
-- 'httpStatus', 'getComplianceDetailResponse_httpStatus' - The response's http status code.
newGetComplianceDetailResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetComplianceDetailResponse
newGetComplianceDetailResponse :: Int -> GetComplianceDetailResponse
newGetComplianceDetailResponse Int
pHttpStatus_ =
  GetComplianceDetailResponse' :: Maybe PolicyComplianceDetail -> Int -> GetComplianceDetailResponse
GetComplianceDetailResponse'
    { $sel:policyComplianceDetail:GetComplianceDetailResponse' :: Maybe PolicyComplianceDetail
policyComplianceDetail =
        Maybe PolicyComplianceDetail
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetComplianceDetailResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the resources and the policy that you specified in the
-- @GetComplianceDetail@ request.
getComplianceDetailResponse_policyComplianceDetail :: Lens.Lens' GetComplianceDetailResponse (Prelude.Maybe PolicyComplianceDetail)
getComplianceDetailResponse_policyComplianceDetail :: (Maybe PolicyComplianceDetail -> f (Maybe PolicyComplianceDetail))
-> GetComplianceDetailResponse -> f GetComplianceDetailResponse
getComplianceDetailResponse_policyComplianceDetail = (GetComplianceDetailResponse -> Maybe PolicyComplianceDetail)
-> (GetComplianceDetailResponse
    -> Maybe PolicyComplianceDetail -> GetComplianceDetailResponse)
-> Lens
     GetComplianceDetailResponse
     GetComplianceDetailResponse
     (Maybe PolicyComplianceDetail)
     (Maybe PolicyComplianceDetail)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetComplianceDetailResponse' {Maybe PolicyComplianceDetail
policyComplianceDetail :: Maybe PolicyComplianceDetail
$sel:policyComplianceDetail:GetComplianceDetailResponse' :: GetComplianceDetailResponse -> Maybe PolicyComplianceDetail
policyComplianceDetail} -> Maybe PolicyComplianceDetail
policyComplianceDetail) (\s :: GetComplianceDetailResponse
s@GetComplianceDetailResponse' {} Maybe PolicyComplianceDetail
a -> GetComplianceDetailResponse
s {$sel:policyComplianceDetail:GetComplianceDetailResponse' :: Maybe PolicyComplianceDetail
policyComplianceDetail = Maybe PolicyComplianceDetail
a} :: GetComplianceDetailResponse)

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

instance Prelude.NFData GetComplianceDetailResponse