{-# 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.DeleteBotAlias
-- 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 an alias for the specified bot.
--
-- You can\'t delete an alias that is used in the association between a bot
-- and a messaging channel. If an alias is used in a channel association,
-- the @DeleteBot@ operation returns a @ResourceInUseException@ exception
-- that includes a reference to the channel association that refers to the
-- bot. You can remove the reference to the alias by deleting the channel
-- association. If you get the same exception again, delete the referring
-- association until the @DeleteBotAlias@ operation is successful.
module Amazonka.LexModels.DeleteBotAlias
  ( -- * Creating a Request
    DeleteBotAlias (..),
    newDeleteBotAlias,

    -- * Request Lenses
    deleteBotAlias_name,
    deleteBotAlias_botName,

    -- * Destructuring the Response
    DeleteBotAliasResponse (..),
    newDeleteBotAliasResponse,
  )
where

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

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

-- |
-- Create a value of 'DeleteBotAlias' 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', 'deleteBotAlias_name' - The name of the alias to delete. The name is case sensitive.
--
-- 'botName', 'deleteBotAlias_botName' - The name of the bot that the alias points to.
newDeleteBotAlias ::
  -- | 'name'
  Prelude.Text ->
  -- | 'botName'
  Prelude.Text ->
  DeleteBotAlias
newDeleteBotAlias :: Text -> Text -> DeleteBotAlias
newDeleteBotAlias Text
pName_ Text
pBotName_ =
  DeleteBotAlias' {$sel:name:DeleteBotAlias' :: Text
name = Text
pName_, $sel:botName:DeleteBotAlias' :: Text
botName = Text
pBotName_}

-- | The name of the alias to delete. The name is case sensitive.
deleteBotAlias_name :: Lens.Lens' DeleteBotAlias Prelude.Text
deleteBotAlias_name :: Lens' DeleteBotAlias Text
deleteBotAlias_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBotAlias' {Text
name :: Text
$sel:name:DeleteBotAlias' :: DeleteBotAlias -> Text
name} -> Text
name) (\s :: DeleteBotAlias
s@DeleteBotAlias' {} Text
a -> DeleteBotAlias
s {$sel:name:DeleteBotAlias' :: Text
name = Text
a} :: DeleteBotAlias)

-- | The name of the bot that the alias points to.
deleteBotAlias_botName :: Lens.Lens' DeleteBotAlias Prelude.Text
deleteBotAlias_botName :: Lens' DeleteBotAlias Text
deleteBotAlias_botName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBotAlias' {Text
botName :: Text
$sel:botName:DeleteBotAlias' :: DeleteBotAlias -> Text
botName} -> Text
botName) (\s :: DeleteBotAlias
s@DeleteBotAlias' {} Text
a -> DeleteBotAlias
s {$sel:botName:DeleteBotAlias' :: Text
botName = Text
a} :: DeleteBotAlias)

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

instance Prelude.Hashable DeleteBotAlias where
  hashWithSalt :: Int -> DeleteBotAlias -> Int
hashWithSalt Int
_salt DeleteBotAlias' {Text
botName :: Text
name :: Text
$sel:botName:DeleteBotAlias' :: DeleteBotAlias -> Text
$sel:name:DeleteBotAlias' :: DeleteBotAlias -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
botName

instance Prelude.NFData DeleteBotAlias where
  rnf :: DeleteBotAlias -> ()
rnf DeleteBotAlias' {Text
botName :: Text
name :: Text
$sel:botName:DeleteBotAlias' :: DeleteBotAlias -> Text
$sel:name:DeleteBotAlias' :: DeleteBotAlias -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
name seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
botName

instance Data.ToHeaders DeleteBotAlias where
  toHeaders :: DeleteBotAlias -> [Header]
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 -> [Header]
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath DeleteBotAlias where
  toPath :: DeleteBotAlias -> ByteString
toPath DeleteBotAlias' {Text
botName :: Text
name :: Text
$sel:botName:DeleteBotAlias' :: DeleteBotAlias -> Text
$sel:name:DeleteBotAlias' :: DeleteBotAlias -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/bots/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
botName,
        ByteString
"/aliases/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
name
      ]

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

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

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

instance Prelude.NFData DeleteBotAliasResponse where
  rnf :: DeleteBotAliasResponse -> ()
rnf DeleteBotAliasResponse
_ = ()