{-# 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.FraudDetector.DeleteLabel
-- 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 label.
--
-- You cannot delete labels that are included in an event type in Amazon
-- Fraud Detector.
--
-- You cannot delete a label assigned to an event ID. You must first delete
-- the relevant event ID.
--
-- When you delete a label, Amazon Fraud Detector permanently deletes that
-- label and the data is no longer stored in Amazon Fraud Detector.
module Amazonka.FraudDetector.DeleteLabel
  ( -- * Creating a Request
    DeleteLabel (..),
    newDeleteLabel,

    -- * Request Lenses
    deleteLabel_name,

    -- * Destructuring the Response
    DeleteLabelResponse (..),
    newDeleteLabelResponse,

    -- * Response Lenses
    deleteLabelResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.FraudDetector.Types
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:/ 'newDeleteLabel' smart constructor.
data DeleteLabel = DeleteLabel'
  { -- | The name of the label to delete.
    DeleteLabel -> Text
name :: Prelude.Text
  }
  deriving (DeleteLabel -> DeleteLabel -> Bool
(DeleteLabel -> DeleteLabel -> Bool)
-> (DeleteLabel -> DeleteLabel -> Bool) -> Eq DeleteLabel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteLabel -> DeleteLabel -> Bool
$c/= :: DeleteLabel -> DeleteLabel -> Bool
== :: DeleteLabel -> DeleteLabel -> Bool
$c== :: DeleteLabel -> DeleteLabel -> Bool
Prelude.Eq, ReadPrec [DeleteLabel]
ReadPrec DeleteLabel
Int -> ReadS DeleteLabel
ReadS [DeleteLabel]
(Int -> ReadS DeleteLabel)
-> ReadS [DeleteLabel]
-> ReadPrec DeleteLabel
-> ReadPrec [DeleteLabel]
-> Read DeleteLabel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteLabel]
$creadListPrec :: ReadPrec [DeleteLabel]
readPrec :: ReadPrec DeleteLabel
$creadPrec :: ReadPrec DeleteLabel
readList :: ReadS [DeleteLabel]
$creadList :: ReadS [DeleteLabel]
readsPrec :: Int -> ReadS DeleteLabel
$creadsPrec :: Int -> ReadS DeleteLabel
Prelude.Read, Int -> DeleteLabel -> ShowS
[DeleteLabel] -> ShowS
DeleteLabel -> String
(Int -> DeleteLabel -> ShowS)
-> (DeleteLabel -> String)
-> ([DeleteLabel] -> ShowS)
-> Show DeleteLabel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteLabel] -> ShowS
$cshowList :: [DeleteLabel] -> ShowS
show :: DeleteLabel -> String
$cshow :: DeleteLabel -> String
showsPrec :: Int -> DeleteLabel -> ShowS
$cshowsPrec :: Int -> DeleteLabel -> ShowS
Prelude.Show, (forall x. DeleteLabel -> Rep DeleteLabel x)
-> (forall x. Rep DeleteLabel x -> DeleteLabel)
-> Generic DeleteLabel
forall x. Rep DeleteLabel x -> DeleteLabel
forall x. DeleteLabel -> Rep DeleteLabel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteLabel x -> DeleteLabel
$cfrom :: forall x. DeleteLabel -> Rep DeleteLabel x
Prelude.Generic)

-- |
-- Create a value of 'DeleteLabel' 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:
--
-- 'name', 'deleteLabel_name' - The name of the label to delete.
newDeleteLabel ::
  -- | 'name'
  Prelude.Text ->
  DeleteLabel
newDeleteLabel :: Text -> DeleteLabel
newDeleteLabel Text
pName_ = DeleteLabel' :: Text -> DeleteLabel
DeleteLabel' {$sel:name:DeleteLabel' :: Text
name = Text
pName_}

-- | The name of the label to delete.
deleteLabel_name :: Lens.Lens' DeleteLabel Prelude.Text
deleteLabel_name :: (Text -> f Text) -> DeleteLabel -> f DeleteLabel
deleteLabel_name = (DeleteLabel -> Text)
-> (DeleteLabel -> Text -> DeleteLabel)
-> Lens DeleteLabel DeleteLabel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteLabel' {Text
name :: Text
$sel:name:DeleteLabel' :: DeleteLabel -> Text
name} -> Text
name) (\s :: DeleteLabel
s@DeleteLabel' {} Text
a -> DeleteLabel
s {$sel:name:DeleteLabel' :: Text
name = Text
a} :: DeleteLabel)

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

instance Prelude.NFData DeleteLabel

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

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

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

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

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

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

instance Prelude.NFData DeleteLabelResponse