{-# 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.LexV2Models.DeleteBot
-- 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 all versions of a bot, including the @Draft@ version. To delete
-- a specific version, use the @DeleteBotVersion@ operation.
--
-- When you delete a bot, all of the resources contained in the bot are
-- also deleted. Deleting a bot removes all locales, intents, slot, and
-- slot types defined for the bot.
--
-- If a bot has an alias, the @DeleteBot@ operation returns a
-- @ResourceInUseException@ exception. If you want to delete the bot and
-- the alias, set the @skipResourceInUseCheck@ parameter to @true@.
module Amazonka.LexV2Models.DeleteBot
  ( -- * Creating a Request
    DeleteBot (..),
    newDeleteBot,

    -- * Request Lenses
    deleteBot_skipResourceInUseCheck,
    deleteBot_botId,

    -- * Destructuring the Response
    DeleteBotResponse (..),
    newDeleteBotResponse,

    -- * Response Lenses
    deleteBotResponse_botId,
    deleteBotResponse_botStatus,
    deleteBotResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteBot' smart constructor.
data DeleteBot = DeleteBot'
  { -- | When @true@, Amazon Lex doesn\'t check to see if another resource, such
    -- as an alias, is using the bot before it is deleted.
    DeleteBot -> Maybe Bool
skipResourceInUseCheck :: Prelude.Maybe Prelude.Bool,
    -- | The identifier of the bot to delete.
    DeleteBot -> Text
botId :: Prelude.Text
  }
  deriving (DeleteBot -> DeleteBot -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteBot -> DeleteBot -> Bool
$c/= :: DeleteBot -> DeleteBot -> Bool
== :: DeleteBot -> DeleteBot -> Bool
$c== :: DeleteBot -> DeleteBot -> Bool
Prelude.Eq, ReadPrec [DeleteBot]
ReadPrec DeleteBot
Int -> ReadS DeleteBot
ReadS [DeleteBot]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteBot]
$creadListPrec :: ReadPrec [DeleteBot]
readPrec :: ReadPrec DeleteBot
$creadPrec :: ReadPrec DeleteBot
readList :: ReadS [DeleteBot]
$creadList :: ReadS [DeleteBot]
readsPrec :: Int -> ReadS DeleteBot
$creadsPrec :: Int -> ReadS DeleteBot
Prelude.Read, Int -> DeleteBot -> ShowS
[DeleteBot] -> ShowS
DeleteBot -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteBot] -> ShowS
$cshowList :: [DeleteBot] -> ShowS
show :: DeleteBot -> String
$cshow :: DeleteBot -> String
showsPrec :: Int -> DeleteBot -> ShowS
$cshowsPrec :: Int -> DeleteBot -> ShowS
Prelude.Show, forall x. Rep DeleteBot x -> DeleteBot
forall x. DeleteBot -> Rep DeleteBot x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteBot x -> DeleteBot
$cfrom :: forall x. DeleteBot -> Rep DeleteBot x
Prelude.Generic)

-- |
-- Create a value of 'DeleteBot' 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:
--
-- 'skipResourceInUseCheck', 'deleteBot_skipResourceInUseCheck' - When @true@, Amazon Lex doesn\'t check to see if another resource, such
-- as an alias, is using the bot before it is deleted.
--
-- 'botId', 'deleteBot_botId' - The identifier of the bot to delete.
newDeleteBot ::
  -- | 'botId'
  Prelude.Text ->
  DeleteBot
newDeleteBot :: Text -> DeleteBot
newDeleteBot Text
pBotId_ =
  DeleteBot'
    { $sel:skipResourceInUseCheck:DeleteBot' :: Maybe Bool
skipResourceInUseCheck =
        forall a. Maybe a
Prelude.Nothing,
      $sel:botId:DeleteBot' :: Text
botId = Text
pBotId_
    }

-- | When @true@, Amazon Lex doesn\'t check to see if another resource, such
-- as an alias, is using the bot before it is deleted.
deleteBot_skipResourceInUseCheck :: Lens.Lens' DeleteBot (Prelude.Maybe Prelude.Bool)
deleteBot_skipResourceInUseCheck :: Lens' DeleteBot (Maybe Bool)
deleteBot_skipResourceInUseCheck = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBot' {Maybe Bool
skipResourceInUseCheck :: Maybe Bool
$sel:skipResourceInUseCheck:DeleteBot' :: DeleteBot -> Maybe Bool
skipResourceInUseCheck} -> Maybe Bool
skipResourceInUseCheck) (\s :: DeleteBot
s@DeleteBot' {} Maybe Bool
a -> DeleteBot
s {$sel:skipResourceInUseCheck:DeleteBot' :: Maybe Bool
skipResourceInUseCheck = Maybe Bool
a} :: DeleteBot)

-- | The identifier of the bot to delete.
deleteBot_botId :: Lens.Lens' DeleteBot Prelude.Text
deleteBot_botId :: Lens' DeleteBot Text
deleteBot_botId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBot' {Text
botId :: Text
$sel:botId:DeleteBot' :: DeleteBot -> Text
botId} -> Text
botId) (\s :: DeleteBot
s@DeleteBot' {} Text
a -> DeleteBot
s {$sel:botId:DeleteBot' :: Text
botId = Text
a} :: DeleteBot)

instance Core.AWSRequest DeleteBot where
  type AWSResponse DeleteBot = DeleteBotResponse
  request :: (Service -> Service) -> DeleteBot -> Request DeleteBot
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 DeleteBot
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteBot)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Maybe BotStatus -> Int -> DeleteBotResponse
DeleteBotResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"botId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"botStatus")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteBot where
  hashWithSalt :: Int -> DeleteBot -> Int
hashWithSalt Int
_salt DeleteBot' {Maybe Bool
Text
botId :: Text
skipResourceInUseCheck :: Maybe Bool
$sel:botId:DeleteBot' :: DeleteBot -> Text
$sel:skipResourceInUseCheck:DeleteBot' :: DeleteBot -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
skipResourceInUseCheck
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
botId

instance Prelude.NFData DeleteBot where
  rnf :: DeleteBot -> ()
rnf DeleteBot' {Maybe Bool
Text
botId :: Text
skipResourceInUseCheck :: Maybe Bool
$sel:botId:DeleteBot' :: DeleteBot -> Text
$sel:skipResourceInUseCheck:DeleteBot' :: DeleteBot -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
skipResourceInUseCheck
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
botId

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

instance Data.ToPath DeleteBot where
  toPath :: DeleteBot -> ByteString
toPath DeleteBot' {Maybe Bool
Text
botId :: Text
skipResourceInUseCheck :: Maybe Bool
$sel:botId:DeleteBot' :: DeleteBot -> Text
$sel:skipResourceInUseCheck:DeleteBot' :: DeleteBot -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/bots/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
botId, ByteString
"/"]

instance Data.ToQuery DeleteBot where
  toQuery :: DeleteBot -> QueryString
toQuery DeleteBot' {Maybe Bool
Text
botId :: Text
skipResourceInUseCheck :: Maybe Bool
$sel:botId:DeleteBot' :: DeleteBot -> Text
$sel:skipResourceInUseCheck:DeleteBot' :: DeleteBot -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"skipResourceInUseCheck"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
skipResourceInUseCheck
      ]

-- | /See:/ 'newDeleteBotResponse' smart constructor.
data DeleteBotResponse = DeleteBotResponse'
  { -- | The unique identifier of the bot that Amazon Lex is deleting.
    DeleteBotResponse -> Maybe Text
botId :: Prelude.Maybe Prelude.Text,
    -- | The current status of the bot. The status is @Deleting@ while the bot
    -- and its associated resources are being deleted.
    DeleteBotResponse -> Maybe BotStatus
botStatus :: Prelude.Maybe BotStatus,
    -- | The response's http status code.
    DeleteBotResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteBotResponse -> DeleteBotResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteBotResponse -> DeleteBotResponse -> Bool
$c/= :: DeleteBotResponse -> DeleteBotResponse -> Bool
== :: DeleteBotResponse -> DeleteBotResponse -> Bool
$c== :: DeleteBotResponse -> DeleteBotResponse -> Bool
Prelude.Eq, ReadPrec [DeleteBotResponse]
ReadPrec DeleteBotResponse
Int -> ReadS DeleteBotResponse
ReadS [DeleteBotResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteBotResponse]
$creadListPrec :: ReadPrec [DeleteBotResponse]
readPrec :: ReadPrec DeleteBotResponse
$creadPrec :: ReadPrec DeleteBotResponse
readList :: ReadS [DeleteBotResponse]
$creadList :: ReadS [DeleteBotResponse]
readsPrec :: Int -> ReadS DeleteBotResponse
$creadsPrec :: Int -> ReadS DeleteBotResponse
Prelude.Read, Int -> DeleteBotResponse -> ShowS
[DeleteBotResponse] -> ShowS
DeleteBotResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteBotResponse] -> ShowS
$cshowList :: [DeleteBotResponse] -> ShowS
show :: DeleteBotResponse -> String
$cshow :: DeleteBotResponse -> String
showsPrec :: Int -> DeleteBotResponse -> ShowS
$cshowsPrec :: Int -> DeleteBotResponse -> ShowS
Prelude.Show, forall x. Rep DeleteBotResponse x -> DeleteBotResponse
forall x. DeleteBotResponse -> Rep DeleteBotResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteBotResponse x -> DeleteBotResponse
$cfrom :: forall x. DeleteBotResponse -> Rep DeleteBotResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteBotResponse' 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:
--
-- 'botId', 'deleteBotResponse_botId' - The unique identifier of the bot that Amazon Lex is deleting.
--
-- 'botStatus', 'deleteBotResponse_botStatus' - The current status of the bot. The status is @Deleting@ while the bot
-- and its associated resources are being deleted.
--
-- 'httpStatus', 'deleteBotResponse_httpStatus' - The response's http status code.
newDeleteBotResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteBotResponse
newDeleteBotResponse :: Int -> DeleteBotResponse
newDeleteBotResponse Int
pHttpStatus_ =
  DeleteBotResponse'
    { $sel:botId:DeleteBotResponse' :: Maybe Text
botId = forall a. Maybe a
Prelude.Nothing,
      $sel:botStatus:DeleteBotResponse' :: Maybe BotStatus
botStatus = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteBotResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The unique identifier of the bot that Amazon Lex is deleting.
deleteBotResponse_botId :: Lens.Lens' DeleteBotResponse (Prelude.Maybe Prelude.Text)
deleteBotResponse_botId :: Lens' DeleteBotResponse (Maybe Text)
deleteBotResponse_botId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBotResponse' {Maybe Text
botId :: Maybe Text
$sel:botId:DeleteBotResponse' :: DeleteBotResponse -> Maybe Text
botId} -> Maybe Text
botId) (\s :: DeleteBotResponse
s@DeleteBotResponse' {} Maybe Text
a -> DeleteBotResponse
s {$sel:botId:DeleteBotResponse' :: Maybe Text
botId = Maybe Text
a} :: DeleteBotResponse)

-- | The current status of the bot. The status is @Deleting@ while the bot
-- and its associated resources are being deleted.
deleteBotResponse_botStatus :: Lens.Lens' DeleteBotResponse (Prelude.Maybe BotStatus)
deleteBotResponse_botStatus :: Lens' DeleteBotResponse (Maybe BotStatus)
deleteBotResponse_botStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBotResponse' {Maybe BotStatus
botStatus :: Maybe BotStatus
$sel:botStatus:DeleteBotResponse' :: DeleteBotResponse -> Maybe BotStatus
botStatus} -> Maybe BotStatus
botStatus) (\s :: DeleteBotResponse
s@DeleteBotResponse' {} Maybe BotStatus
a -> DeleteBotResponse
s {$sel:botStatus:DeleteBotResponse' :: Maybe BotStatus
botStatus = Maybe BotStatus
a} :: DeleteBotResponse)

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

instance Prelude.NFData DeleteBotResponse where
  rnf :: DeleteBotResponse -> ()
rnf DeleteBotResponse' {Int
Maybe Text
Maybe BotStatus
httpStatus :: Int
botStatus :: Maybe BotStatus
botId :: Maybe Text
$sel:httpStatus:DeleteBotResponse' :: DeleteBotResponse -> Int
$sel:botStatus:DeleteBotResponse' :: DeleteBotResponse -> Maybe BotStatus
$sel:botId:DeleteBotResponse' :: DeleteBotResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
botId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe BotStatus
botStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus