{-# 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.LexModels.DeleteIntent
-- 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 all versions of the intent, including the @$LATEST@ version. To
-- delete a specific version of the intent, use the DeleteIntentVersion
-- operation.
--
-- You can delete a version of an intent only if it is not referenced. To
-- delete an intent that is referred to in one or more bots (see
-- how-it-works), you must remove those references first.
--
-- If you get the @ResourceInUseException@ exception, it provides an
-- example reference that shows where the intent is referenced. To remove
-- the reference to the intent, either update the bot or delete it. If you
-- get the same exception when you attempt to delete the intent again,
-- repeat until the intent has no references and the call to @DeleteIntent@
-- is successful.
--
-- This operation requires permission for the @lex:DeleteIntent@ action.
module Amazonka.LexModels.DeleteIntent
  ( -- * Creating a Request
    DeleteIntent (..),
    newDeleteIntent,

    -- * Request Lenses
    deleteIntent_name,

    -- * Destructuring the Response
    DeleteIntentResponse (..),
    newDeleteIntentResponse,
  )
where

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

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

-- |
-- Create a value of 'DeleteIntent' 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', 'deleteIntent_name' - The name of the intent. The name is case sensitive.
newDeleteIntent ::
  -- | 'name'
  Prelude.Text ->
  DeleteIntent
newDeleteIntent :: Text -> DeleteIntent
newDeleteIntent Text
pName_ = DeleteIntent' :: Text -> DeleteIntent
DeleteIntent' {$sel:name:DeleteIntent' :: Text
name = Text
pName_}

-- | The name of the intent. The name is case sensitive.
deleteIntent_name :: Lens.Lens' DeleteIntent Prelude.Text
deleteIntent_name :: (Text -> f Text) -> DeleteIntent -> f DeleteIntent
deleteIntent_name = (DeleteIntent -> Text)
-> (DeleteIntent -> Text -> DeleteIntent)
-> Lens DeleteIntent DeleteIntent Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteIntent' {Text
name :: Text
$sel:name:DeleteIntent' :: DeleteIntent -> Text
name} -> Text
name) (\s :: DeleteIntent
s@DeleteIntent' {} Text
a -> DeleteIntent
s {$sel:name:DeleteIntent' :: Text
name = Text
a} :: DeleteIntent)

instance Core.AWSRequest DeleteIntent where
  type AWSResponse DeleteIntent = DeleteIntentResponse
  request :: DeleteIntent -> Request DeleteIntent
request = Service -> DeleteIntent -> Request DeleteIntent
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteIntent
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteIntent)))
response = AWSResponse DeleteIntent
-> Logger
-> Service
-> Proxy DeleteIntent
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteIntent)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse DeleteIntent
DeleteIntentResponse
DeleteIntentResponse'

instance Prelude.Hashable DeleteIntent

instance Prelude.NFData DeleteIntent

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

instance Core.ToPath DeleteIntent where
  toPath :: DeleteIntent -> ByteString
toPath DeleteIntent' {Text
name :: Text
$sel:name:DeleteIntent' :: DeleteIntent -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/intents/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
name]

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

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

-- |
-- Create a value of 'DeleteIntentResponse' 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.
newDeleteIntentResponse ::
  DeleteIntentResponse
newDeleteIntentResponse :: DeleteIntentResponse
newDeleteIntentResponse = DeleteIntentResponse
DeleteIntentResponse'

instance Prelude.NFData DeleteIntentResponse