{-# 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.CodeStarNotifications.DeleteNotificationRule
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes a notification rule for a resource.
module Amazonka.CodeStarNotifications.DeleteNotificationRule
  ( -- * Creating a Request
    DeleteNotificationRule (..),
    newDeleteNotificationRule,

    -- * Request Lenses
    deleteNotificationRule_arn,

    -- * Destructuring the Response
    DeleteNotificationRuleResponse (..),
    newDeleteNotificationRuleResponse,

    -- * Response Lenses
    deleteNotificationRuleResponse_arn,
    deleteNotificationRuleResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'DeleteNotificationRule' 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:
--
-- 'arn', 'deleteNotificationRule_arn' - The Amazon Resource Name (ARN) of the notification rule you want to
-- delete.
newDeleteNotificationRule ::
  -- | 'arn'
  Prelude.Text ->
  DeleteNotificationRule
newDeleteNotificationRule :: Text -> DeleteNotificationRule
newDeleteNotificationRule Text
pArn_ =
  DeleteNotificationRule' {$sel:arn:DeleteNotificationRule' :: Text
arn = Text
pArn_}

-- | The Amazon Resource Name (ARN) of the notification rule you want to
-- delete.
deleteNotificationRule_arn :: Lens.Lens' DeleteNotificationRule Prelude.Text
deleteNotificationRule_arn :: Lens' DeleteNotificationRule Text
deleteNotificationRule_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteNotificationRule' {Text
arn :: Text
$sel:arn:DeleteNotificationRule' :: DeleteNotificationRule -> Text
arn} -> Text
arn) (\s :: DeleteNotificationRule
s@DeleteNotificationRule' {} Text
a -> DeleteNotificationRule
s {$sel:arn:DeleteNotificationRule' :: Text
arn = Text
a} :: DeleteNotificationRule)

instance Core.AWSRequest DeleteNotificationRule where
  type
    AWSResponse DeleteNotificationRule =
      DeleteNotificationRuleResponse
  request :: (Service -> Service)
-> DeleteNotificationRule -> Request DeleteNotificationRule
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 DeleteNotificationRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteNotificationRule)))
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 Text -> Int -> DeleteNotificationRuleResponse
DeleteNotificationRuleResponse'
            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
"Arn")
            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 DeleteNotificationRule where
  hashWithSalt :: Int -> DeleteNotificationRule -> Int
hashWithSalt Int
_salt DeleteNotificationRule' {Text
arn :: Text
$sel:arn:DeleteNotificationRule' :: DeleteNotificationRule -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn

instance Prelude.NFData DeleteNotificationRule where
  rnf :: DeleteNotificationRule -> ()
rnf DeleteNotificationRule' {Text
arn :: Text
$sel:arn:DeleteNotificationRule' :: DeleteNotificationRule -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
arn

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

instance Data.ToJSON DeleteNotificationRule where
  toJSON :: DeleteNotificationRule -> Value
toJSON DeleteNotificationRule' {Text
arn :: Text
$sel:arn:DeleteNotificationRule' :: DeleteNotificationRule -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"Arn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
arn)]
      )

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

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

-- | /See:/ 'newDeleteNotificationRuleResponse' smart constructor.
data DeleteNotificationRuleResponse = DeleteNotificationRuleResponse'
  { -- | The Amazon Resource Name (ARN) of the deleted notification rule.
    DeleteNotificationRuleResponse -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DeleteNotificationRuleResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteNotificationRuleResponse
-> DeleteNotificationRuleResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteNotificationRuleResponse
-> DeleteNotificationRuleResponse -> Bool
$c/= :: DeleteNotificationRuleResponse
-> DeleteNotificationRuleResponse -> Bool
== :: DeleteNotificationRuleResponse
-> DeleteNotificationRuleResponse -> Bool
$c== :: DeleteNotificationRuleResponse
-> DeleteNotificationRuleResponse -> Bool
Prelude.Eq, ReadPrec [DeleteNotificationRuleResponse]
ReadPrec DeleteNotificationRuleResponse
Int -> ReadS DeleteNotificationRuleResponse
ReadS [DeleteNotificationRuleResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteNotificationRuleResponse]
$creadListPrec :: ReadPrec [DeleteNotificationRuleResponse]
readPrec :: ReadPrec DeleteNotificationRuleResponse
$creadPrec :: ReadPrec DeleteNotificationRuleResponse
readList :: ReadS [DeleteNotificationRuleResponse]
$creadList :: ReadS [DeleteNotificationRuleResponse]
readsPrec :: Int -> ReadS DeleteNotificationRuleResponse
$creadsPrec :: Int -> ReadS DeleteNotificationRuleResponse
Prelude.Read, Int -> DeleteNotificationRuleResponse -> ShowS
[DeleteNotificationRuleResponse] -> ShowS
DeleteNotificationRuleResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteNotificationRuleResponse] -> ShowS
$cshowList :: [DeleteNotificationRuleResponse] -> ShowS
show :: DeleteNotificationRuleResponse -> String
$cshow :: DeleteNotificationRuleResponse -> String
showsPrec :: Int -> DeleteNotificationRuleResponse -> ShowS
$cshowsPrec :: Int -> DeleteNotificationRuleResponse -> ShowS
Prelude.Show, forall x.
Rep DeleteNotificationRuleResponse x
-> DeleteNotificationRuleResponse
forall x.
DeleteNotificationRuleResponse
-> Rep DeleteNotificationRuleResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteNotificationRuleResponse x
-> DeleteNotificationRuleResponse
$cfrom :: forall x.
DeleteNotificationRuleResponse
-> Rep DeleteNotificationRuleResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteNotificationRuleResponse' 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:
--
-- 'arn', 'deleteNotificationRuleResponse_arn' - The Amazon Resource Name (ARN) of the deleted notification rule.
--
-- 'httpStatus', 'deleteNotificationRuleResponse_httpStatus' - The response's http status code.
newDeleteNotificationRuleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteNotificationRuleResponse
newDeleteNotificationRuleResponse :: Int -> DeleteNotificationRuleResponse
newDeleteNotificationRuleResponse Int
pHttpStatus_ =
  DeleteNotificationRuleResponse'
    { $sel:arn:DeleteNotificationRuleResponse' :: Maybe Text
arn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteNotificationRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the deleted notification rule.
deleteNotificationRuleResponse_arn :: Lens.Lens' DeleteNotificationRuleResponse (Prelude.Maybe Prelude.Text)
deleteNotificationRuleResponse_arn :: Lens' DeleteNotificationRuleResponse (Maybe Text)
deleteNotificationRuleResponse_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteNotificationRuleResponse' {Maybe Text
arn :: Maybe Text
$sel:arn:DeleteNotificationRuleResponse' :: DeleteNotificationRuleResponse -> Maybe Text
arn} -> Maybe Text
arn) (\s :: DeleteNotificationRuleResponse
s@DeleteNotificationRuleResponse' {} Maybe Text
a -> DeleteNotificationRuleResponse
s {$sel:arn:DeleteNotificationRuleResponse' :: Maybe Text
arn = Maybe Text
a} :: DeleteNotificationRuleResponse)

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

instance
  Prelude.NFData
    DeleteNotificationRuleResponse
  where
  rnf :: DeleteNotificationRuleResponse -> ()
rnf DeleteNotificationRuleResponse' {Int
Maybe Text
httpStatus :: Int
arn :: Maybe Text
$sel:httpStatus:DeleteNotificationRuleResponse' :: DeleteNotificationRuleResponse -> Int
$sel:arn:DeleteNotificationRuleResponse' :: DeleteNotificationRuleResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus