{-# 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.Grafana.DeleteWorkspace
-- 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 Amazon Managed Grafana workspace.
module Amazonka.Grafana.DeleteWorkspace
  ( -- * Creating a Request
    DeleteWorkspace (..),
    newDeleteWorkspace,

    -- * Request Lenses
    deleteWorkspace_workspaceId,

    -- * Destructuring the Response
    DeleteWorkspaceResponse (..),
    newDeleteWorkspaceResponse,

    -- * Response Lenses
    deleteWorkspaceResponse_httpStatus,
    deleteWorkspaceResponse_workspace,
  )
where

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

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

-- |
-- Create a value of 'DeleteWorkspace' 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:
--
-- 'workspaceId', 'deleteWorkspace_workspaceId' - The ID of the workspace to delete.
newDeleteWorkspace ::
  -- | 'workspaceId'
  Prelude.Text ->
  DeleteWorkspace
newDeleteWorkspace :: Text -> DeleteWorkspace
newDeleteWorkspace Text
pWorkspaceId_ =
  DeleteWorkspace' {$sel:workspaceId:DeleteWorkspace' :: Text
workspaceId = Text
pWorkspaceId_}

-- | The ID of the workspace to delete.
deleteWorkspace_workspaceId :: Lens.Lens' DeleteWorkspace Prelude.Text
deleteWorkspace_workspaceId :: Lens' DeleteWorkspace Text
deleteWorkspace_workspaceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteWorkspace' {Text
workspaceId :: Text
$sel:workspaceId:DeleteWorkspace' :: DeleteWorkspace -> Text
workspaceId} -> Text
workspaceId) (\s :: DeleteWorkspace
s@DeleteWorkspace' {} Text
a -> DeleteWorkspace
s {$sel:workspaceId:DeleteWorkspace' :: Text
workspaceId = Text
a} :: DeleteWorkspace)

instance Core.AWSRequest DeleteWorkspace where
  type
    AWSResponse DeleteWorkspace =
      DeleteWorkspaceResponse
  request :: (Service -> Service) -> DeleteWorkspace -> Request DeleteWorkspace
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 DeleteWorkspace
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteWorkspace)))
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 ->
          Int -> WorkspaceDescription -> DeleteWorkspaceResponse
DeleteWorkspaceResponse'
            forall (f :: * -> *) a b. Functor 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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"workspace")
      )

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

instance Prelude.NFData DeleteWorkspace where
  rnf :: DeleteWorkspace -> ()
rnf DeleteWorkspace' {Text
workspaceId :: Text
$sel:workspaceId:DeleteWorkspace' :: DeleteWorkspace -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
workspaceId

instance Data.ToHeaders DeleteWorkspace where
  toHeaders :: DeleteWorkspace -> 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 DeleteWorkspace where
  toPath :: DeleteWorkspace -> ByteString
toPath DeleteWorkspace' {Text
workspaceId :: Text
$sel:workspaceId:DeleteWorkspace' :: DeleteWorkspace -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/workspaces/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
workspaceId]

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

-- | /See:/ 'newDeleteWorkspaceResponse' smart constructor.
data DeleteWorkspaceResponse = DeleteWorkspaceResponse'
  { -- | The response's http status code.
    DeleteWorkspaceResponse -> Int
httpStatus :: Prelude.Int,
    -- | A structure containing information about the workspace that was deleted.
    DeleteWorkspaceResponse -> WorkspaceDescription
workspace :: WorkspaceDescription
  }
  deriving (DeleteWorkspaceResponse -> DeleteWorkspaceResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteWorkspaceResponse -> DeleteWorkspaceResponse -> Bool
$c/= :: DeleteWorkspaceResponse -> DeleteWorkspaceResponse -> Bool
== :: DeleteWorkspaceResponse -> DeleteWorkspaceResponse -> Bool
$c== :: DeleteWorkspaceResponse -> DeleteWorkspaceResponse -> Bool
Prelude.Eq, Int -> DeleteWorkspaceResponse -> ShowS
[DeleteWorkspaceResponse] -> ShowS
DeleteWorkspaceResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteWorkspaceResponse] -> ShowS
$cshowList :: [DeleteWorkspaceResponse] -> ShowS
show :: DeleteWorkspaceResponse -> String
$cshow :: DeleteWorkspaceResponse -> String
showsPrec :: Int -> DeleteWorkspaceResponse -> ShowS
$cshowsPrec :: Int -> DeleteWorkspaceResponse -> ShowS
Prelude.Show, forall x. Rep DeleteWorkspaceResponse x -> DeleteWorkspaceResponse
forall x. DeleteWorkspaceResponse -> Rep DeleteWorkspaceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteWorkspaceResponse x -> DeleteWorkspaceResponse
$cfrom :: forall x. DeleteWorkspaceResponse -> Rep DeleteWorkspaceResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteWorkspaceResponse' 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', 'deleteWorkspaceResponse_httpStatus' - The response's http status code.
--
-- 'workspace', 'deleteWorkspaceResponse_workspace' - A structure containing information about the workspace that was deleted.
newDeleteWorkspaceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'workspace'
  WorkspaceDescription ->
  DeleteWorkspaceResponse
newDeleteWorkspaceResponse :: Int -> WorkspaceDescription -> DeleteWorkspaceResponse
newDeleteWorkspaceResponse Int
pHttpStatus_ WorkspaceDescription
pWorkspace_ =
  DeleteWorkspaceResponse'
    { $sel:httpStatus:DeleteWorkspaceResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:workspace:DeleteWorkspaceResponse' :: WorkspaceDescription
workspace = WorkspaceDescription
pWorkspace_
    }

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

-- | A structure containing information about the workspace that was deleted.
deleteWorkspaceResponse_workspace :: Lens.Lens' DeleteWorkspaceResponse WorkspaceDescription
deleteWorkspaceResponse_workspace :: Lens' DeleteWorkspaceResponse WorkspaceDescription
deleteWorkspaceResponse_workspace = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteWorkspaceResponse' {WorkspaceDescription
workspace :: WorkspaceDescription
$sel:workspace:DeleteWorkspaceResponse' :: DeleteWorkspaceResponse -> WorkspaceDescription
workspace} -> WorkspaceDescription
workspace) (\s :: DeleteWorkspaceResponse
s@DeleteWorkspaceResponse' {} WorkspaceDescription
a -> DeleteWorkspaceResponse
s {$sel:workspace:DeleteWorkspaceResponse' :: WorkspaceDescription
workspace = WorkspaceDescription
a} :: DeleteWorkspaceResponse)

instance Prelude.NFData DeleteWorkspaceResponse where
  rnf :: DeleteWorkspaceResponse -> ()
rnf DeleteWorkspaceResponse' {Int
WorkspaceDescription
workspace :: WorkspaceDescription
httpStatus :: Int
$sel:workspace:DeleteWorkspaceResponse' :: DeleteWorkspaceResponse -> WorkspaceDescription
$sel:httpStatus:DeleteWorkspaceResponse' :: DeleteWorkspaceResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf WorkspaceDescription
workspace