{-# 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.LookoutMetrics.DeleteAlert
-- 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)
--
-- Deletes an alert.
module Amazonka.LookoutMetrics.DeleteAlert
  ( -- * Creating a Request
    DeleteAlert (..),
    newDeleteAlert,

    -- * Request Lenses
    deleteAlert_alertArn,

    -- * Destructuring the Response
    DeleteAlertResponse (..),
    newDeleteAlertResponse,

    -- * Response Lenses
    deleteAlertResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.LookoutMetrics.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteAlert' smart constructor.
data DeleteAlert = DeleteAlert'
  { -- | The ARN of the alert to delete.
    DeleteAlert -> Text
alertArn :: Prelude.Text
  }
  deriving (DeleteAlert -> DeleteAlert -> Bool
(DeleteAlert -> DeleteAlert -> Bool)
-> (DeleteAlert -> DeleteAlert -> Bool) -> Eq DeleteAlert
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteAlert -> DeleteAlert -> Bool
$c/= :: DeleteAlert -> DeleteAlert -> Bool
== :: DeleteAlert -> DeleteAlert -> Bool
$c== :: DeleteAlert -> DeleteAlert -> Bool
Prelude.Eq, ReadPrec [DeleteAlert]
ReadPrec DeleteAlert
Int -> ReadS DeleteAlert
ReadS [DeleteAlert]
(Int -> ReadS DeleteAlert)
-> ReadS [DeleteAlert]
-> ReadPrec DeleteAlert
-> ReadPrec [DeleteAlert]
-> Read DeleteAlert
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteAlert]
$creadListPrec :: ReadPrec [DeleteAlert]
readPrec :: ReadPrec DeleteAlert
$creadPrec :: ReadPrec DeleteAlert
readList :: ReadS [DeleteAlert]
$creadList :: ReadS [DeleteAlert]
readsPrec :: Int -> ReadS DeleteAlert
$creadsPrec :: Int -> ReadS DeleteAlert
Prelude.Read, Int -> DeleteAlert -> ShowS
[DeleteAlert] -> ShowS
DeleteAlert -> String
(Int -> DeleteAlert -> ShowS)
-> (DeleteAlert -> String)
-> ([DeleteAlert] -> ShowS)
-> Show DeleteAlert
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteAlert] -> ShowS
$cshowList :: [DeleteAlert] -> ShowS
show :: DeleteAlert -> String
$cshow :: DeleteAlert -> String
showsPrec :: Int -> DeleteAlert -> ShowS
$cshowsPrec :: Int -> DeleteAlert -> ShowS
Prelude.Show, (forall x. DeleteAlert -> Rep DeleteAlert x)
-> (forall x. Rep DeleteAlert x -> DeleteAlert)
-> Generic DeleteAlert
forall x. Rep DeleteAlert x -> DeleteAlert
forall x. DeleteAlert -> Rep DeleteAlert x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteAlert x -> DeleteAlert
$cfrom :: forall x. DeleteAlert -> Rep DeleteAlert x
Prelude.Generic)

-- |
-- Create a value of 'DeleteAlert' 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:
--
-- 'alertArn', 'deleteAlert_alertArn' - The ARN of the alert to delete.
newDeleteAlert ::
  -- | 'alertArn'
  Prelude.Text ->
  DeleteAlert
newDeleteAlert :: Text -> DeleteAlert
newDeleteAlert Text
pAlertArn_ =
  DeleteAlert' :: Text -> DeleteAlert
DeleteAlert' {$sel:alertArn:DeleteAlert' :: Text
alertArn = Text
pAlertArn_}

-- | The ARN of the alert to delete.
deleteAlert_alertArn :: Lens.Lens' DeleteAlert Prelude.Text
deleteAlert_alertArn :: (Text -> f Text) -> DeleteAlert -> f DeleteAlert
deleteAlert_alertArn = (DeleteAlert -> Text)
-> (DeleteAlert -> Text -> DeleteAlert)
-> Lens DeleteAlert DeleteAlert Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAlert' {Text
alertArn :: Text
$sel:alertArn:DeleteAlert' :: DeleteAlert -> Text
alertArn} -> Text
alertArn) (\s :: DeleteAlert
s@DeleteAlert' {} Text
a -> DeleteAlert
s {$sel:alertArn:DeleteAlert' :: Text
alertArn = Text
a} :: DeleteAlert)

instance Core.AWSRequest DeleteAlert where
  type AWSResponse DeleteAlert = DeleteAlertResponse
  request :: DeleteAlert -> Request DeleteAlert
request = Service -> DeleteAlert -> Request DeleteAlert
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteAlert
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteAlert)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteAlert))
-> Logger
-> Service
-> Proxy DeleteAlert
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteAlert)))
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 -> DeleteAlertResponse
DeleteAlertResponse'
            (Int -> DeleteAlertResponse)
-> Either String Int -> Either String DeleteAlertResponse
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 DeleteAlert

instance Prelude.NFData DeleteAlert

instance Core.ToHeaders DeleteAlert where
  toHeaders :: DeleteAlert -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteAlert -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 DeleteAlert where
  toJSON :: DeleteAlert -> Value
toJSON DeleteAlert' {Text
alertArn :: Text
$sel:alertArn:DeleteAlert' :: DeleteAlert -> 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
"AlertArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
alertArn)]
      )

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

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

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

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

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

instance Prelude.NFData DeleteAlertResponse