{-# 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.Comprehend.DeleteEntityRecognizer
-- 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 entity recognizer.
--
-- Only those recognizers that are in terminated states (IN_ERROR, TRAINED)
-- will be deleted. If an active inference job is using the model, a
-- @ResourceInUseException@ will be returned.
--
-- This is an asynchronous action that puts the recognizer into a DELETING
-- state, and it is then removed by a background job. Once removed, the
-- recognizer disappears from your account and is no longer available for
-- use.
module Amazonka.Comprehend.DeleteEntityRecognizer
  ( -- * Creating a Request
    DeleteEntityRecognizer (..),
    newDeleteEntityRecognizer,

    -- * Request Lenses
    deleteEntityRecognizer_entityRecognizerArn,

    -- * Destructuring the Response
    DeleteEntityRecognizerResponse (..),
    newDeleteEntityRecognizerResponse,

    -- * Response Lenses
    deleteEntityRecognizerResponse_httpStatus,
  )
where

import Amazonka.Comprehend.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:/ 'newDeleteEntityRecognizer' smart constructor.
data DeleteEntityRecognizer = DeleteEntityRecognizer'
  { -- | The Amazon Resource Name (ARN) that identifies the entity recognizer.
    DeleteEntityRecognizer -> Text
entityRecognizerArn :: Prelude.Text
  }
  deriving (DeleteEntityRecognizer -> DeleteEntityRecognizer -> Bool
(DeleteEntityRecognizer -> DeleteEntityRecognizer -> Bool)
-> (DeleteEntityRecognizer -> DeleteEntityRecognizer -> Bool)
-> Eq DeleteEntityRecognizer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteEntityRecognizer -> DeleteEntityRecognizer -> Bool
$c/= :: DeleteEntityRecognizer -> DeleteEntityRecognizer -> Bool
== :: DeleteEntityRecognizer -> DeleteEntityRecognizer -> Bool
$c== :: DeleteEntityRecognizer -> DeleteEntityRecognizer -> Bool
Prelude.Eq, ReadPrec [DeleteEntityRecognizer]
ReadPrec DeleteEntityRecognizer
Int -> ReadS DeleteEntityRecognizer
ReadS [DeleteEntityRecognizer]
(Int -> ReadS DeleteEntityRecognizer)
-> ReadS [DeleteEntityRecognizer]
-> ReadPrec DeleteEntityRecognizer
-> ReadPrec [DeleteEntityRecognizer]
-> Read DeleteEntityRecognizer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteEntityRecognizer]
$creadListPrec :: ReadPrec [DeleteEntityRecognizer]
readPrec :: ReadPrec DeleteEntityRecognizer
$creadPrec :: ReadPrec DeleteEntityRecognizer
readList :: ReadS [DeleteEntityRecognizer]
$creadList :: ReadS [DeleteEntityRecognizer]
readsPrec :: Int -> ReadS DeleteEntityRecognizer
$creadsPrec :: Int -> ReadS DeleteEntityRecognizer
Prelude.Read, Int -> DeleteEntityRecognizer -> ShowS
[DeleteEntityRecognizer] -> ShowS
DeleteEntityRecognizer -> String
(Int -> DeleteEntityRecognizer -> ShowS)
-> (DeleteEntityRecognizer -> String)
-> ([DeleteEntityRecognizer] -> ShowS)
-> Show DeleteEntityRecognizer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteEntityRecognizer] -> ShowS
$cshowList :: [DeleteEntityRecognizer] -> ShowS
show :: DeleteEntityRecognizer -> String
$cshow :: DeleteEntityRecognizer -> String
showsPrec :: Int -> DeleteEntityRecognizer -> ShowS
$cshowsPrec :: Int -> DeleteEntityRecognizer -> ShowS
Prelude.Show, (forall x. DeleteEntityRecognizer -> Rep DeleteEntityRecognizer x)
-> (forall x.
    Rep DeleteEntityRecognizer x -> DeleteEntityRecognizer)
-> Generic DeleteEntityRecognizer
forall x. Rep DeleteEntityRecognizer x -> DeleteEntityRecognizer
forall x. DeleteEntityRecognizer -> Rep DeleteEntityRecognizer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteEntityRecognizer x -> DeleteEntityRecognizer
$cfrom :: forall x. DeleteEntityRecognizer -> Rep DeleteEntityRecognizer x
Prelude.Generic)

-- |
-- Create a value of 'DeleteEntityRecognizer' 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:
--
-- 'entityRecognizerArn', 'deleteEntityRecognizer_entityRecognizerArn' - The Amazon Resource Name (ARN) that identifies the entity recognizer.
newDeleteEntityRecognizer ::
  -- | 'entityRecognizerArn'
  Prelude.Text ->
  DeleteEntityRecognizer
newDeleteEntityRecognizer :: Text -> DeleteEntityRecognizer
newDeleteEntityRecognizer Text
pEntityRecognizerArn_ =
  DeleteEntityRecognizer' :: Text -> DeleteEntityRecognizer
DeleteEntityRecognizer'
    { $sel:entityRecognizerArn:DeleteEntityRecognizer' :: Text
entityRecognizerArn =
        Text
pEntityRecognizerArn_
    }

-- | The Amazon Resource Name (ARN) that identifies the entity recognizer.
deleteEntityRecognizer_entityRecognizerArn :: Lens.Lens' DeleteEntityRecognizer Prelude.Text
deleteEntityRecognizer_entityRecognizerArn :: (Text -> f Text)
-> DeleteEntityRecognizer -> f DeleteEntityRecognizer
deleteEntityRecognizer_entityRecognizerArn = (DeleteEntityRecognizer -> Text)
-> (DeleteEntityRecognizer -> Text -> DeleteEntityRecognizer)
-> Lens DeleteEntityRecognizer DeleteEntityRecognizer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteEntityRecognizer' {Text
entityRecognizerArn :: Text
$sel:entityRecognizerArn:DeleteEntityRecognizer' :: DeleteEntityRecognizer -> Text
entityRecognizerArn} -> Text
entityRecognizerArn) (\s :: DeleteEntityRecognizer
s@DeleteEntityRecognizer' {} Text
a -> DeleteEntityRecognizer
s {$sel:entityRecognizerArn:DeleteEntityRecognizer' :: Text
entityRecognizerArn = Text
a} :: DeleteEntityRecognizer)

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

instance Prelude.NFData DeleteEntityRecognizer

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

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

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

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

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

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

instance
  Prelude.NFData
    DeleteEntityRecognizerResponse