{-# 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-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 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.Lens as Lens
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
(DeleteNotificationRule -> DeleteNotificationRule -> Bool)
-> (DeleteNotificationRule -> DeleteNotificationRule -> Bool)
-> Eq DeleteNotificationRule
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]
(Int -> ReadS DeleteNotificationRule)
-> ReadS [DeleteNotificationRule]
-> ReadPrec DeleteNotificationRule
-> ReadPrec [DeleteNotificationRule]
-> Read 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
(Int -> DeleteNotificationRule -> ShowS)
-> (DeleteNotificationRule -> String)
-> ([DeleteNotificationRule] -> ShowS)
-> Show DeleteNotificationRule
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. DeleteNotificationRule -> Rep DeleteNotificationRule x)
-> (forall x.
    Rep DeleteNotificationRule x -> DeleteNotificationRule)
-> Generic DeleteNotificationRule
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' :: Text -> DeleteNotificationRule
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 :: (Text -> f Text)
-> DeleteNotificationRule -> f DeleteNotificationRule
deleteNotificationRule_arn = (DeleteNotificationRule -> Text)
-> (DeleteNotificationRule -> Text -> DeleteNotificationRule)
-> Lens DeleteNotificationRule DeleteNotificationRule Text Text
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 :: DeleteNotificationRule -> Request DeleteNotificationRule
request = Service -> DeleteNotificationRule -> Request DeleteNotificationRule
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteNotificationRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteNotificationRule)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteNotificationRule))
-> Logger
-> Service
-> Proxy DeleteNotificationRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteNotificationRule)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> DeleteNotificationRuleResponse
DeleteNotificationRuleResponse'
            (Maybe Text -> Int -> DeleteNotificationRuleResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DeleteNotificationRuleResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Arn")
            Either String (Int -> DeleteNotificationRuleResponse)
-> Either String Int
-> Either String DeleteNotificationRuleResponse
forall (f :: * -> *) a b. Applicative f => 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 DeleteNotificationRule

instance Prelude.NFData DeleteNotificationRule

instance Core.ToHeaders DeleteNotificationRule where
  toHeaders :: DeleteNotificationRule -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteNotificationRule -> 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 DeleteNotificationRule where
  toJSON :: DeleteNotificationRule -> Value
toJSON DeleteNotificationRule' {Text
arn :: Text
$sel:arn:DeleteNotificationRule' :: DeleteNotificationRule -> 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
"Arn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
arn)]
      )

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

instance Core.ToQuery DeleteNotificationRule where
  toQuery :: DeleteNotificationRule -> QueryString
toQuery = QueryString -> DeleteNotificationRule -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeleteNotificationRuleResponse
 -> DeleteNotificationRuleResponse -> Bool)
-> (DeleteNotificationRuleResponse
    -> DeleteNotificationRuleResponse -> Bool)
-> Eq DeleteNotificationRuleResponse
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]
(Int -> ReadS DeleteNotificationRuleResponse)
-> ReadS [DeleteNotificationRuleResponse]
-> ReadPrec DeleteNotificationRuleResponse
-> ReadPrec [DeleteNotificationRuleResponse]
-> Read 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
(Int -> DeleteNotificationRuleResponse -> ShowS)
-> (DeleteNotificationRuleResponse -> String)
-> ([DeleteNotificationRuleResponse] -> ShowS)
-> Show DeleteNotificationRuleResponse
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.
 DeleteNotificationRuleResponse
 -> Rep DeleteNotificationRuleResponse x)
-> (forall x.
    Rep DeleteNotificationRuleResponse x
    -> DeleteNotificationRuleResponse)
-> Generic DeleteNotificationRuleResponse
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' :: Maybe Text -> Int -> DeleteNotificationRuleResponse
DeleteNotificationRuleResponse'
    { $sel:arn:DeleteNotificationRuleResponse' :: Maybe Text
arn =
        Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> DeleteNotificationRuleResponse
-> f DeleteNotificationRuleResponse
deleteNotificationRuleResponse_arn = (DeleteNotificationRuleResponse -> Maybe Text)
-> (DeleteNotificationRuleResponse
    -> Maybe Text -> DeleteNotificationRuleResponse)
-> Lens
     DeleteNotificationRuleResponse
     DeleteNotificationRuleResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Int -> f Int)
-> DeleteNotificationRuleResponse
-> f DeleteNotificationRuleResponse
deleteNotificationRuleResponse_httpStatus = (DeleteNotificationRuleResponse -> Int)
-> (DeleteNotificationRuleResponse
    -> Int -> DeleteNotificationRuleResponse)
-> Lens
     DeleteNotificationRuleResponse
     DeleteNotificationRuleResponse
     Int
     Int
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