{-# 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.CloudFormation.DetectStackResourceDrift
-- 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 information about whether a resource\'s actual configuration
-- differs, or has /drifted/, from it\'s expected configuration, as defined
-- in the stack template and any values specified as template parameters.
-- This information includes actual and expected property values for
-- resources in which CloudFormation detects drift. Only resource
-- properties explicitly defined in the stack template are checked for
-- drift. For more information about stack and resource drift, see
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-stack-drift.html Detecting Unregulated Configuration Changes to Stacks and Resources>.
--
-- Use @DetectStackResourceDrift@ to detect drift on individual resources,
-- or DetectStackDrift to detect drift on all resources in a given stack
-- that support drift detection.
--
-- Resources that do not currently support drift detection cannot be
-- checked. For a list of resources that support drift detection, see
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-stack-drift-resource-list.html Resources that Support Drift Detection>.
module Amazonka.CloudFormation.DetectStackResourceDrift
  ( -- * Creating a Request
    DetectStackResourceDrift (..),
    newDetectStackResourceDrift,

    -- * Request Lenses
    detectStackResourceDrift_stackName,
    detectStackResourceDrift_logicalResourceId,

    -- * Destructuring the Response
    DetectStackResourceDriftResponse (..),
    newDetectStackResourceDriftResponse,

    -- * Response Lenses
    detectStackResourceDriftResponse_httpStatus,
    detectStackResourceDriftResponse_stackResourceDrift,
  )
where

import Amazonka.CloudFormation.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:/ 'newDetectStackResourceDrift' smart constructor.
data DetectStackResourceDrift = DetectStackResourceDrift'
  { -- | The name of the stack to which the resource belongs.
    DetectStackResourceDrift -> Text
stackName :: Prelude.Text,
    -- | The logical name of the resource for which to return drift information.
    DetectStackResourceDrift -> Text
logicalResourceId :: Prelude.Text
  }
  deriving (DetectStackResourceDrift -> DetectStackResourceDrift -> Bool
(DetectStackResourceDrift -> DetectStackResourceDrift -> Bool)
-> (DetectStackResourceDrift -> DetectStackResourceDrift -> Bool)
-> Eq DetectStackResourceDrift
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetectStackResourceDrift -> DetectStackResourceDrift -> Bool
$c/= :: DetectStackResourceDrift -> DetectStackResourceDrift -> Bool
== :: DetectStackResourceDrift -> DetectStackResourceDrift -> Bool
$c== :: DetectStackResourceDrift -> DetectStackResourceDrift -> Bool
Prelude.Eq, ReadPrec [DetectStackResourceDrift]
ReadPrec DetectStackResourceDrift
Int -> ReadS DetectStackResourceDrift
ReadS [DetectStackResourceDrift]
(Int -> ReadS DetectStackResourceDrift)
-> ReadS [DetectStackResourceDrift]
-> ReadPrec DetectStackResourceDrift
-> ReadPrec [DetectStackResourceDrift]
-> Read DetectStackResourceDrift
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetectStackResourceDrift]
$creadListPrec :: ReadPrec [DetectStackResourceDrift]
readPrec :: ReadPrec DetectStackResourceDrift
$creadPrec :: ReadPrec DetectStackResourceDrift
readList :: ReadS [DetectStackResourceDrift]
$creadList :: ReadS [DetectStackResourceDrift]
readsPrec :: Int -> ReadS DetectStackResourceDrift
$creadsPrec :: Int -> ReadS DetectStackResourceDrift
Prelude.Read, Int -> DetectStackResourceDrift -> ShowS
[DetectStackResourceDrift] -> ShowS
DetectStackResourceDrift -> String
(Int -> DetectStackResourceDrift -> ShowS)
-> (DetectStackResourceDrift -> String)
-> ([DetectStackResourceDrift] -> ShowS)
-> Show DetectStackResourceDrift
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetectStackResourceDrift] -> ShowS
$cshowList :: [DetectStackResourceDrift] -> ShowS
show :: DetectStackResourceDrift -> String
$cshow :: DetectStackResourceDrift -> String
showsPrec :: Int -> DetectStackResourceDrift -> ShowS
$cshowsPrec :: Int -> DetectStackResourceDrift -> ShowS
Prelude.Show, (forall x.
 DetectStackResourceDrift -> Rep DetectStackResourceDrift x)
-> (forall x.
    Rep DetectStackResourceDrift x -> DetectStackResourceDrift)
-> Generic DetectStackResourceDrift
forall x.
Rep DetectStackResourceDrift x -> DetectStackResourceDrift
forall x.
DetectStackResourceDrift -> Rep DetectStackResourceDrift x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DetectStackResourceDrift x -> DetectStackResourceDrift
$cfrom :: forall x.
DetectStackResourceDrift -> Rep DetectStackResourceDrift x
Prelude.Generic)

-- |
-- Create a value of 'DetectStackResourceDrift' 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:
--
-- 'stackName', 'detectStackResourceDrift_stackName' - The name of the stack to which the resource belongs.
--
-- 'logicalResourceId', 'detectStackResourceDrift_logicalResourceId' - The logical name of the resource for which to return drift information.
newDetectStackResourceDrift ::
  -- | 'stackName'
  Prelude.Text ->
  -- | 'logicalResourceId'
  Prelude.Text ->
  DetectStackResourceDrift
newDetectStackResourceDrift :: Text -> Text -> DetectStackResourceDrift
newDetectStackResourceDrift
  Text
pStackName_
  Text
pLogicalResourceId_ =
    DetectStackResourceDrift' :: Text -> Text -> DetectStackResourceDrift
DetectStackResourceDrift'
      { $sel:stackName:DetectStackResourceDrift' :: Text
stackName = Text
pStackName_,
        $sel:logicalResourceId:DetectStackResourceDrift' :: Text
logicalResourceId = Text
pLogicalResourceId_
      }

-- | The name of the stack to which the resource belongs.
detectStackResourceDrift_stackName :: Lens.Lens' DetectStackResourceDrift Prelude.Text
detectStackResourceDrift_stackName :: (Text -> f Text)
-> DetectStackResourceDrift -> f DetectStackResourceDrift
detectStackResourceDrift_stackName = (DetectStackResourceDrift -> Text)
-> (DetectStackResourceDrift -> Text -> DetectStackResourceDrift)
-> Lens DetectStackResourceDrift DetectStackResourceDrift Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectStackResourceDrift' {Text
stackName :: Text
$sel:stackName:DetectStackResourceDrift' :: DetectStackResourceDrift -> Text
stackName} -> Text
stackName) (\s :: DetectStackResourceDrift
s@DetectStackResourceDrift' {} Text
a -> DetectStackResourceDrift
s {$sel:stackName:DetectStackResourceDrift' :: Text
stackName = Text
a} :: DetectStackResourceDrift)

-- | The logical name of the resource for which to return drift information.
detectStackResourceDrift_logicalResourceId :: Lens.Lens' DetectStackResourceDrift Prelude.Text
detectStackResourceDrift_logicalResourceId :: (Text -> f Text)
-> DetectStackResourceDrift -> f DetectStackResourceDrift
detectStackResourceDrift_logicalResourceId = (DetectStackResourceDrift -> Text)
-> (DetectStackResourceDrift -> Text -> DetectStackResourceDrift)
-> Lens DetectStackResourceDrift DetectStackResourceDrift Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectStackResourceDrift' {Text
logicalResourceId :: Text
$sel:logicalResourceId:DetectStackResourceDrift' :: DetectStackResourceDrift -> Text
logicalResourceId} -> Text
logicalResourceId) (\s :: DetectStackResourceDrift
s@DetectStackResourceDrift' {} Text
a -> DetectStackResourceDrift
s {$sel:logicalResourceId:DetectStackResourceDrift' :: Text
logicalResourceId = Text
a} :: DetectStackResourceDrift)

instance Core.AWSRequest DetectStackResourceDrift where
  type
    AWSResponse DetectStackResourceDrift =
      DetectStackResourceDriftResponse
  request :: DetectStackResourceDrift -> Request DetectStackResourceDrift
request = Service
-> DetectStackResourceDrift -> Request DetectStackResourceDrift
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DetectStackResourceDrift
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DetectStackResourceDrift)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DetectStackResourceDrift))
-> Logger
-> Service
-> Proxy DetectStackResourceDrift
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DetectStackResourceDrift)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"DetectStackResourceDriftResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> StackResourceDrift -> DetectStackResourceDriftResponse
DetectStackResourceDriftResponse'
            (Int -> StackResourceDrift -> DetectStackResourceDriftResponse)
-> Either String Int
-> Either
     String (StackResourceDrift -> DetectStackResourceDriftResponse)
forall (f :: * -> *) a b. Functor 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))
            Either
  String (StackResourceDrift -> DetectStackResourceDriftResponse)
-> Either String StackResourceDrift
-> Either String DetectStackResourceDriftResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String StackResourceDrift
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"StackResourceDrift")
      )

instance Prelude.Hashable DetectStackResourceDrift

instance Prelude.NFData DetectStackResourceDrift

instance Core.ToHeaders DetectStackResourceDrift where
  toHeaders :: DetectStackResourceDrift -> ResponseHeaders
toHeaders = ResponseHeaders -> DetectStackResourceDrift -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToQuery DetectStackResourceDrift where
  toQuery :: DetectStackResourceDrift -> QueryString
toQuery DetectStackResourceDrift' {Text
logicalResourceId :: Text
stackName :: Text
$sel:logicalResourceId:DetectStackResourceDrift' :: DetectStackResourceDrift -> Text
$sel:stackName:DetectStackResourceDrift' :: DetectStackResourceDrift -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"DetectStackResourceDrift" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-15" :: Prelude.ByteString),
        ByteString
"StackName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
stackName,
        ByteString
"LogicalResourceId" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
logicalResourceId
      ]

-- | /See:/ 'newDetectStackResourceDriftResponse' smart constructor.
data DetectStackResourceDriftResponse = DetectStackResourceDriftResponse'
  { -- | The response's http status code.
    DetectStackResourceDriftResponse -> Int
httpStatus :: Prelude.Int,
    -- | Information about whether the resource\'s actual configuration has
    -- drifted from its expected template configuration, including actual and
    -- expected property values and any differences detected.
    DetectStackResourceDriftResponse -> StackResourceDrift
stackResourceDrift :: StackResourceDrift
  }
  deriving (DetectStackResourceDriftResponse
-> DetectStackResourceDriftResponse -> Bool
(DetectStackResourceDriftResponse
 -> DetectStackResourceDriftResponse -> Bool)
-> (DetectStackResourceDriftResponse
    -> DetectStackResourceDriftResponse -> Bool)
-> Eq DetectStackResourceDriftResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetectStackResourceDriftResponse
-> DetectStackResourceDriftResponse -> Bool
$c/= :: DetectStackResourceDriftResponse
-> DetectStackResourceDriftResponse -> Bool
== :: DetectStackResourceDriftResponse
-> DetectStackResourceDriftResponse -> Bool
$c== :: DetectStackResourceDriftResponse
-> DetectStackResourceDriftResponse -> Bool
Prelude.Eq, ReadPrec [DetectStackResourceDriftResponse]
ReadPrec DetectStackResourceDriftResponse
Int -> ReadS DetectStackResourceDriftResponse
ReadS [DetectStackResourceDriftResponse]
(Int -> ReadS DetectStackResourceDriftResponse)
-> ReadS [DetectStackResourceDriftResponse]
-> ReadPrec DetectStackResourceDriftResponse
-> ReadPrec [DetectStackResourceDriftResponse]
-> Read DetectStackResourceDriftResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetectStackResourceDriftResponse]
$creadListPrec :: ReadPrec [DetectStackResourceDriftResponse]
readPrec :: ReadPrec DetectStackResourceDriftResponse
$creadPrec :: ReadPrec DetectStackResourceDriftResponse
readList :: ReadS [DetectStackResourceDriftResponse]
$creadList :: ReadS [DetectStackResourceDriftResponse]
readsPrec :: Int -> ReadS DetectStackResourceDriftResponse
$creadsPrec :: Int -> ReadS DetectStackResourceDriftResponse
Prelude.Read, Int -> DetectStackResourceDriftResponse -> ShowS
[DetectStackResourceDriftResponse] -> ShowS
DetectStackResourceDriftResponse -> String
(Int -> DetectStackResourceDriftResponse -> ShowS)
-> (DetectStackResourceDriftResponse -> String)
-> ([DetectStackResourceDriftResponse] -> ShowS)
-> Show DetectStackResourceDriftResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetectStackResourceDriftResponse] -> ShowS
$cshowList :: [DetectStackResourceDriftResponse] -> ShowS
show :: DetectStackResourceDriftResponse -> String
$cshow :: DetectStackResourceDriftResponse -> String
showsPrec :: Int -> DetectStackResourceDriftResponse -> ShowS
$cshowsPrec :: Int -> DetectStackResourceDriftResponse -> ShowS
Prelude.Show, (forall x.
 DetectStackResourceDriftResponse
 -> Rep DetectStackResourceDriftResponse x)
-> (forall x.
    Rep DetectStackResourceDriftResponse x
    -> DetectStackResourceDriftResponse)
-> Generic DetectStackResourceDriftResponse
forall x.
Rep DetectStackResourceDriftResponse x
-> DetectStackResourceDriftResponse
forall x.
DetectStackResourceDriftResponse
-> Rep DetectStackResourceDriftResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DetectStackResourceDriftResponse x
-> DetectStackResourceDriftResponse
$cfrom :: forall x.
DetectStackResourceDriftResponse
-> Rep DetectStackResourceDriftResponse x
Prelude.Generic)

-- |
-- Create a value of 'DetectStackResourceDriftResponse' 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:
--
-- 'httpStatus', 'detectStackResourceDriftResponse_httpStatus' - The response's http status code.
--
-- 'stackResourceDrift', 'detectStackResourceDriftResponse_stackResourceDrift' - Information about whether the resource\'s actual configuration has
-- drifted from its expected template configuration, including actual and
-- expected property values and any differences detected.
newDetectStackResourceDriftResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'stackResourceDrift'
  StackResourceDrift ->
  DetectStackResourceDriftResponse
newDetectStackResourceDriftResponse :: Int -> StackResourceDrift -> DetectStackResourceDriftResponse
newDetectStackResourceDriftResponse
  Int
pHttpStatus_
  StackResourceDrift
pStackResourceDrift_ =
    DetectStackResourceDriftResponse' :: Int -> StackResourceDrift -> DetectStackResourceDriftResponse
DetectStackResourceDriftResponse'
      { $sel:httpStatus:DetectStackResourceDriftResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:stackResourceDrift:DetectStackResourceDriftResponse' :: StackResourceDrift
stackResourceDrift = StackResourceDrift
pStackResourceDrift_
      }

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

-- | Information about whether the resource\'s actual configuration has
-- drifted from its expected template configuration, including actual and
-- expected property values and any differences detected.
detectStackResourceDriftResponse_stackResourceDrift :: Lens.Lens' DetectStackResourceDriftResponse StackResourceDrift
detectStackResourceDriftResponse_stackResourceDrift :: (StackResourceDrift -> f StackResourceDrift)
-> DetectStackResourceDriftResponse
-> f DetectStackResourceDriftResponse
detectStackResourceDriftResponse_stackResourceDrift = (DetectStackResourceDriftResponse -> StackResourceDrift)
-> (DetectStackResourceDriftResponse
    -> StackResourceDrift -> DetectStackResourceDriftResponse)
-> Lens
     DetectStackResourceDriftResponse
     DetectStackResourceDriftResponse
     StackResourceDrift
     StackResourceDrift
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectStackResourceDriftResponse' {StackResourceDrift
stackResourceDrift :: StackResourceDrift
$sel:stackResourceDrift:DetectStackResourceDriftResponse' :: DetectStackResourceDriftResponse -> StackResourceDrift
stackResourceDrift} -> StackResourceDrift
stackResourceDrift) (\s :: DetectStackResourceDriftResponse
s@DetectStackResourceDriftResponse' {} StackResourceDrift
a -> DetectStackResourceDriftResponse
s {$sel:stackResourceDrift:DetectStackResourceDriftResponse' :: StackResourceDrift
stackResourceDrift = StackResourceDrift
a} :: DetectStackResourceDriftResponse)

instance
  Prelude.NFData
    DetectStackResourceDriftResponse