{-# 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-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 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.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:/ '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
(DeleteBotAlias -> DeleteBotAlias -> Bool)
-> (DeleteBotAlias -> DeleteBotAlias -> Bool) -> Eq DeleteBotAlias
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]
(Int -> ReadS DeleteBotAlias)
-> ReadS [DeleteBotAlias]
-> ReadPrec DeleteBotAlias
-> ReadPrec [DeleteBotAlias]
-> Read 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
(Int -> DeleteBotAlias -> ShowS)
-> (DeleteBotAlias -> String)
-> ([DeleteBotAlias] -> ShowS)
-> Show DeleteBotAlias
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. DeleteBotAlias -> Rep DeleteBotAlias x)
-> (forall x. Rep DeleteBotAlias x -> DeleteBotAlias)
-> Generic DeleteBotAlias
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' :: Text -> Text -> DeleteBotAlias
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 :: (Text -> f Text) -> DeleteBotAlias -> f DeleteBotAlias
deleteBotAlias_name = (DeleteBotAlias -> Text)
-> (DeleteBotAlias -> Text -> DeleteBotAlias)
-> Lens DeleteBotAlias DeleteBotAlias Text Text
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 :: (Text -> f Text) -> DeleteBotAlias -> f DeleteBotAlias
deleteBotAlias_botName = (DeleteBotAlias -> Text)
-> (DeleteBotAlias -> Text -> DeleteBotAlias)
-> Lens DeleteBotAlias DeleteBotAlias Text Text
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 :: DeleteBotAlias -> Request DeleteBotAlias
request = Service -> DeleteBotAlias -> Request DeleteBotAlias
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteBotAlias
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteBotAlias)))
response =
    AWSResponse DeleteBotAlias
-> Logger
-> Service
-> Proxy DeleteBotAlias
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteBotAlias)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse DeleteBotAlias
DeleteBotAliasResponse
DeleteBotAliasResponse'

instance Prelude.Hashable DeleteBotAlias

instance Prelude.NFData DeleteBotAlias

instance Core.ToHeaders DeleteBotAlias where
  toHeaders :: DeleteBotAlias -> [Header]
toHeaders =
    [Header] -> DeleteBotAlias -> [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 DeleteBotAlias where
  toPath :: DeleteBotAlias -> ByteString
toPath DeleteBotAlias' {Text
botName :: Text
name :: Text
$sel:botName:DeleteBotAlias' :: DeleteBotAlias -> Text
$sel:name:DeleteBotAlias' :: DeleteBotAlias -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/bots/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
botName,
        ByteString
"/aliases/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
name
      ]

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

-- | /See:/ 'newDeleteBotAliasResponse' smart constructor.
data DeleteBotAliasResponse = DeleteBotAliasResponse'
  {
  }
  deriving (DeleteBotAliasResponse -> DeleteBotAliasResponse -> Bool
(DeleteBotAliasResponse -> DeleteBotAliasResponse -> Bool)
-> (DeleteBotAliasResponse -> DeleteBotAliasResponse -> Bool)
-> Eq DeleteBotAliasResponse
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]
(Int -> ReadS DeleteBotAliasResponse)
-> ReadS [DeleteBotAliasResponse]
-> ReadPrec DeleteBotAliasResponse
-> ReadPrec [DeleteBotAliasResponse]
-> Read 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
(Int -> DeleteBotAliasResponse -> ShowS)
-> (DeleteBotAliasResponse -> String)
-> ([DeleteBotAliasResponse] -> ShowS)
-> Show DeleteBotAliasResponse
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. DeleteBotAliasResponse -> Rep DeleteBotAliasResponse x)
-> (forall x.
    Rep DeleteBotAliasResponse x -> DeleteBotAliasResponse)
-> Generic DeleteBotAliasResponse
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