{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.FMS.Types
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
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]
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
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. 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'
    { $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 :: Lens' GetComplianceDetail Text
getComplianceDetail_policyId = 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 :: Lens' GetComplianceDetail Text
getComplianceDetail_memberAccount = 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 :: (Service -> Service)
-> GetComplianceDetail -> Request GetComplianceDetail
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetComplianceDetail
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetComplianceDetail)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe PolicyComplianceDetail -> Int -> GetComplianceDetailResponse
GetComplianceDetailResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"PolicyComplianceDetail")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetComplianceDetail where
  hashWithSalt :: Int -> GetComplianceDetail -> Int
hashWithSalt Int
_salt GetComplianceDetail' {Text
memberAccount :: Text
policyId :: Text
$sel:memberAccount:GetComplianceDetail' :: GetComplianceDetail -> Text
$sel:policyId:GetComplianceDetail' :: GetComplianceDetail -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
policyId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
memberAccount

instance Prelude.NFData GetComplianceDetail where
  rnf :: GetComplianceDetail -> ()
rnf GetComplianceDetail' {Text
memberAccount :: Text
policyId :: Text
$sel:memberAccount:GetComplianceDetail' :: GetComplianceDetail -> Text
$sel:policyId:GetComplianceDetail' :: GetComplianceDetail -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
policyId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
memberAccount

instance Data.ToHeaders GetComplianceDetail where
  toHeaders :: GetComplianceDetail -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSFMS_20180101.GetComplianceDetail" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"PolicyId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
policyId),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"MemberAccount" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
memberAccount)
          ]
      )

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

instance Data.ToQuery GetComplianceDetail where
  toQuery :: GetComplianceDetail -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:policyComplianceDetail:GetComplianceDetailResponse' :: Maybe PolicyComplianceDetail
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 :: Lens' GetComplianceDetailResponse (Maybe PolicyComplianceDetail)
getComplianceDetailResponse_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 :: Lens' GetComplianceDetailResponse Int
getComplianceDetailResponse_httpStatus = 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 where
  rnf :: GetComplianceDetailResponse -> ()
rnf GetComplianceDetailResponse' {Int
Maybe PolicyComplianceDetail
httpStatus :: Int
policyComplianceDetail :: Maybe PolicyComplianceDetail
$sel:httpStatus:GetComplianceDetailResponse' :: GetComplianceDetailResponse -> Int
$sel:policyComplianceDetail:GetComplianceDetailResponse' :: GetComplianceDetailResponse -> Maybe PolicyComplianceDetail
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe PolicyComplianceDetail
policyComplianceDetail
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus