{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 response.
--
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
      { $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 :: Lens' DisassociateHealthCheck Text
disassociateHealthCheck_protectionId = 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 :: Lens' DisassociateHealthCheck Text
disassociateHealthCheck_healthCheckArn = 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 :: (Service -> Service)
-> DisassociateHealthCheck -> Request DisassociateHealthCheck
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 DisassociateHealthCheck
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateHealthCheck)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DisassociateHealthCheckResponse
DisassociateHealthCheckResponse'
            forall (f :: * -> *) a b. Functor 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 DisassociateHealthCheck where
  hashWithSalt :: Int -> DisassociateHealthCheck -> Int
hashWithSalt Int
_salt DisassociateHealthCheck' {Text
healthCheckArn :: Text
protectionId :: Text
$sel:healthCheckArn:DisassociateHealthCheck' :: DisassociateHealthCheck -> Text
$sel:protectionId:DisassociateHealthCheck' :: DisassociateHealthCheck -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
protectionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
healthCheckArn

instance Prelude.NFData DisassociateHealthCheck where
  rnf :: DisassociateHealthCheck -> ()
rnf DisassociateHealthCheck' {Text
healthCheckArn :: Text
protectionId :: Text
$sel:healthCheckArn:DisassociateHealthCheck' :: DisassociateHealthCheck -> Text
$sel:protectionId:DisassociateHealthCheck' :: DisassociateHealthCheck -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
protectionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
healthCheckArn

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

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

instance Data.ToQuery DisassociateHealthCheck where
  toQuery :: DisassociateHealthCheck -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:httpStatus:DisassociateHealthCheckResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
disassociateHealthCheckResponse_httpStatus :: Lens.Lens' DisassociateHealthCheckResponse Prelude.Int
disassociateHealthCheckResponse_httpStatus :: Lens' DisassociateHealthCheckResponse Int
disassociateHealthCheckResponse_httpStatus = 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
  where
  rnf :: DisassociateHealthCheckResponse -> ()
rnf DisassociateHealthCheckResponse' {Int
httpStatus :: Int
$sel:httpStatus:DisassociateHealthCheckResponse' :: DisassociateHealthCheckResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus