{-# 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.Shield.DisassociateHealthCheck
-- 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)
--
-- Removes health-based detection from the Shield Advanced protection for a
-- resource. Shield Advanced health-based detection uses the health of your
-- Amazon Web Services resource to improve responsiveness and accuracy in
-- attack detection and mitigation.
--
-- You define the health check in Route 53 and then associate or
-- disassociate it with your Shield Advanced protection. For more
-- information, see
-- <https://docs.aws.amazon.com/waf/latest/developerguide/ddos-overview.html#ddos-advanced-health-check-option Shield Advanced Health-Based Detection>
-- in the /WAF Developer Guide/.
module Amazonka.Shield.DisassociateHealthCheck
  ( -- * Creating a Request
    DisassociateHealthCheck (..),
    newDisassociateHealthCheck,

    -- * Request Lenses
    disassociateHealthCheck_protectionId,
    disassociateHealthCheck_healthCheckArn,

    -- * Destructuring the Response
    DisassociateHealthCheckResponse (..),
    newDisassociateHealthCheckResponse,

    -- * Response Lenses
    disassociateHealthCheckResponse_httpStatus,
  )
where

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
import Amazonka.Shield.Types

-- | /See:/ 'newDisassociateHealthCheck' smart constructor.
data DisassociateHealthCheck = DisassociateHealthCheck'
  { -- | The unique identifier (ID) for the Protection object to remove the
    -- health check association from.
    DisassociateHealthCheck -> Text
protectionId :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the health check that is associated
    -- with the protection.
    DisassociateHealthCheck -> Text
healthCheckArn :: Prelude.Text
  }
  deriving (DisassociateHealthCheck -> DisassociateHealthCheck -> Bool
(DisassociateHealthCheck -> DisassociateHealthCheck -> Bool)
-> (DisassociateHealthCheck -> DisassociateHealthCheck -> Bool)
-> Eq DisassociateHealthCheck
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateHealthCheck -> DisassociateHealthCheck -> Bool
$c/= :: DisassociateHealthCheck -> DisassociateHealthCheck -> Bool
== :: DisassociateHealthCheck -> DisassociateHealthCheck -> Bool
$c== :: DisassociateHealthCheck -> DisassociateHealthCheck -> Bool
Prelude.Eq, ReadPrec [DisassociateHealthCheck]
ReadPrec DisassociateHealthCheck
Int -> ReadS DisassociateHealthCheck
ReadS [DisassociateHealthCheck]
(Int -> ReadS DisassociateHealthCheck)
-> ReadS [DisassociateHealthCheck]
-> ReadPrec DisassociateHealthCheck
-> ReadPrec [DisassociateHealthCheck]
-> Read DisassociateHealthCheck
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateHealthCheck]
$creadListPrec :: ReadPrec [DisassociateHealthCheck]
readPrec :: ReadPrec DisassociateHealthCheck
$creadPrec :: ReadPrec DisassociateHealthCheck
readList :: ReadS [DisassociateHealthCheck]
$creadList :: ReadS [DisassociateHealthCheck]
readsPrec :: Int -> ReadS DisassociateHealthCheck
$creadsPrec :: Int -> ReadS DisassociateHealthCheck
Prelude.Read, Int -> DisassociateHealthCheck -> ShowS
[DisassociateHealthCheck] -> ShowS
DisassociateHealthCheck -> String
(Int -> DisassociateHealthCheck -> ShowS)
-> (DisassociateHealthCheck -> String)
-> ([DisassociateHealthCheck] -> ShowS)
-> Show DisassociateHealthCheck
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateHealthCheck] -> ShowS
$cshowList :: [DisassociateHealthCheck] -> ShowS
show :: DisassociateHealthCheck -> String
$cshow :: DisassociateHealthCheck -> String
showsPrec :: Int -> DisassociateHealthCheck -> ShowS
$cshowsPrec :: Int -> DisassociateHealthCheck -> ShowS
Prelude.Show, (forall x.
 DisassociateHealthCheck -> Rep DisassociateHealthCheck x)
-> (forall x.
    Rep DisassociateHealthCheck x -> DisassociateHealthCheck)
-> Generic DisassociateHealthCheck
forall x. Rep DisassociateHealthCheck x -> DisassociateHealthCheck
forall x. DisassociateHealthCheck -> Rep DisassociateHealthCheck x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisassociateHealthCheck x -> DisassociateHealthCheck
$cfrom :: forall x. DisassociateHealthCheck -> Rep DisassociateHealthCheck x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateHealthCheck' 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:
--
-- 'protectionId', 'disassociateHealthCheck_protectionId' - The unique identifier (ID) for the Protection object to remove the
-- health check association from.
--
-- 'healthCheckArn', 'disassociateHealthCheck_healthCheckArn' - The Amazon Resource Name (ARN) of the health check that is associated
-- with the protection.
newDisassociateHealthCheck ::
  -- | 'protectionId'
  Prelude.Text ->
  -- | 'healthCheckArn'
  Prelude.Text ->
  DisassociateHealthCheck
newDisassociateHealthCheck :: Text -> Text -> DisassociateHealthCheck
newDisassociateHealthCheck
  Text
pProtectionId_
  Text
pHealthCheckArn_ =
    DisassociateHealthCheck' :: Text -> Text -> DisassociateHealthCheck
DisassociateHealthCheck'
      { $sel:protectionId:DisassociateHealthCheck' :: Text
protectionId =
          Text
pProtectionId_,
        $sel:healthCheckArn:DisassociateHealthCheck' :: Text
healthCheckArn = Text
pHealthCheckArn_
      }

-- | The unique identifier (ID) for the Protection object to remove the
-- health check association from.
disassociateHealthCheck_protectionId :: Lens.Lens' DisassociateHealthCheck Prelude.Text
disassociateHealthCheck_protectionId :: (Text -> f Text)
-> DisassociateHealthCheck -> f DisassociateHealthCheck
disassociateHealthCheck_protectionId = (DisassociateHealthCheck -> Text)
-> (DisassociateHealthCheck -> Text -> DisassociateHealthCheck)
-> Lens DisassociateHealthCheck DisassociateHealthCheck Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateHealthCheck' {Text
protectionId :: Text
$sel:protectionId:DisassociateHealthCheck' :: DisassociateHealthCheck -> Text
protectionId} -> Text
protectionId) (\s :: DisassociateHealthCheck
s@DisassociateHealthCheck' {} Text
a -> DisassociateHealthCheck
s {$sel:protectionId:DisassociateHealthCheck' :: Text
protectionId = Text
a} :: DisassociateHealthCheck)

-- | The Amazon Resource Name (ARN) of the health check that is associated
-- with the protection.
disassociateHealthCheck_healthCheckArn :: Lens.Lens' DisassociateHealthCheck Prelude.Text
disassociateHealthCheck_healthCheckArn :: (Text -> f Text)
-> DisassociateHealthCheck -> f DisassociateHealthCheck
disassociateHealthCheck_healthCheckArn = (DisassociateHealthCheck -> Text)
-> (DisassociateHealthCheck -> Text -> DisassociateHealthCheck)
-> Lens DisassociateHealthCheck DisassociateHealthCheck Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateHealthCheck' {Text
healthCheckArn :: Text
$sel:healthCheckArn:DisassociateHealthCheck' :: DisassociateHealthCheck -> Text
healthCheckArn} -> Text
healthCheckArn) (\s :: DisassociateHealthCheck
s@DisassociateHealthCheck' {} Text
a -> DisassociateHealthCheck
s {$sel:healthCheckArn:DisassociateHealthCheck' :: Text
healthCheckArn = Text
a} :: DisassociateHealthCheck)

instance Core.AWSRequest DisassociateHealthCheck where
  type
    AWSResponse DisassociateHealthCheck =
      DisassociateHealthCheckResponse
  request :: DisassociateHealthCheck -> Request DisassociateHealthCheck
request = Service
-> DisassociateHealthCheck -> Request DisassociateHealthCheck
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DisassociateHealthCheck
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateHealthCheck)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DisassociateHealthCheck))
-> Logger
-> Service
-> Proxy DisassociateHealthCheck
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateHealthCheck)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DisassociateHealthCheckResponse
DisassociateHealthCheckResponse'
            (Int -> DisassociateHealthCheckResponse)
-> Either String Int
-> Either String DisassociateHealthCheckResponse
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))
      )

instance Prelude.Hashable DisassociateHealthCheck

instance Prelude.NFData DisassociateHealthCheck

instance Core.ToHeaders DisassociateHealthCheck where
  toHeaders :: DisassociateHealthCheck -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DisassociateHealthCheck -> 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
"AWSShield_20160616.DisassociateHealthCheck" ::
                          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 DisassociateHealthCheck where
  toJSON :: DisassociateHealthCheck -> Value
toJSON DisassociateHealthCheck' {Text
healthCheckArn :: Text
protectionId :: Text
$sel:healthCheckArn:DisassociateHealthCheck' :: DisassociateHealthCheck -> Text
$sel:protectionId:DisassociateHealthCheck' :: DisassociateHealthCheck -> 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
"ProtectionId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
protectionId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"HealthCheckArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
healthCheckArn)
          ]
      )

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

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

-- | /See:/ 'newDisassociateHealthCheckResponse' smart constructor.
data DisassociateHealthCheckResponse = DisassociateHealthCheckResponse'
  { -- | The response's http status code.
    DisassociateHealthCheckResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DisassociateHealthCheckResponse
-> DisassociateHealthCheckResponse -> Bool
(DisassociateHealthCheckResponse
 -> DisassociateHealthCheckResponse -> Bool)
-> (DisassociateHealthCheckResponse
    -> DisassociateHealthCheckResponse -> Bool)
-> Eq DisassociateHealthCheckResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateHealthCheckResponse
-> DisassociateHealthCheckResponse -> Bool
$c/= :: DisassociateHealthCheckResponse
-> DisassociateHealthCheckResponse -> Bool
== :: DisassociateHealthCheckResponse
-> DisassociateHealthCheckResponse -> Bool
$c== :: DisassociateHealthCheckResponse
-> DisassociateHealthCheckResponse -> Bool
Prelude.Eq, ReadPrec [DisassociateHealthCheckResponse]
ReadPrec DisassociateHealthCheckResponse
Int -> ReadS DisassociateHealthCheckResponse
ReadS [DisassociateHealthCheckResponse]
(Int -> ReadS DisassociateHealthCheckResponse)
-> ReadS [DisassociateHealthCheckResponse]
-> ReadPrec DisassociateHealthCheckResponse
-> ReadPrec [DisassociateHealthCheckResponse]
-> Read DisassociateHealthCheckResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateHealthCheckResponse]
$creadListPrec :: ReadPrec [DisassociateHealthCheckResponse]
readPrec :: ReadPrec DisassociateHealthCheckResponse
$creadPrec :: ReadPrec DisassociateHealthCheckResponse
readList :: ReadS [DisassociateHealthCheckResponse]
$creadList :: ReadS [DisassociateHealthCheckResponse]
readsPrec :: Int -> ReadS DisassociateHealthCheckResponse
$creadsPrec :: Int -> ReadS DisassociateHealthCheckResponse
Prelude.Read, Int -> DisassociateHealthCheckResponse -> ShowS
[DisassociateHealthCheckResponse] -> ShowS
DisassociateHealthCheckResponse -> String
(Int -> DisassociateHealthCheckResponse -> ShowS)
-> (DisassociateHealthCheckResponse -> String)
-> ([DisassociateHealthCheckResponse] -> ShowS)
-> Show DisassociateHealthCheckResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateHealthCheckResponse] -> ShowS
$cshowList :: [DisassociateHealthCheckResponse] -> ShowS
show :: DisassociateHealthCheckResponse -> String
$cshow :: DisassociateHealthCheckResponse -> String
showsPrec :: Int -> DisassociateHealthCheckResponse -> ShowS
$cshowsPrec :: Int -> DisassociateHealthCheckResponse -> ShowS
Prelude.Show, (forall x.
 DisassociateHealthCheckResponse
 -> Rep DisassociateHealthCheckResponse x)
-> (forall x.
    Rep DisassociateHealthCheckResponse x
    -> DisassociateHealthCheckResponse)
-> Generic DisassociateHealthCheckResponse
forall x.
Rep DisassociateHealthCheckResponse x
-> DisassociateHealthCheckResponse
forall x.
DisassociateHealthCheckResponse
-> Rep DisassociateHealthCheckResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisassociateHealthCheckResponse x
-> DisassociateHealthCheckResponse
$cfrom :: forall x.
DisassociateHealthCheckResponse
-> Rep DisassociateHealthCheckResponse x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateHealthCheckResponse' 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', 'disassociateHealthCheckResponse_httpStatus' - The response's http status code.
newDisassociateHealthCheckResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DisassociateHealthCheckResponse
newDisassociateHealthCheckResponse :: Int -> DisassociateHealthCheckResponse
newDisassociateHealthCheckResponse Int
pHttpStatus_ =
  DisassociateHealthCheckResponse' :: Int -> DisassociateHealthCheckResponse
DisassociateHealthCheckResponse'
    { $sel:httpStatus:DisassociateHealthCheckResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance
  Prelude.NFData
    DisassociateHealthCheckResponse