{-# 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-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 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 Amazonka.Grafana.Types
import qualified Amazonka.Lens as Lens
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
(DeleteWorkspace -> DeleteWorkspace -> Bool)
-> (DeleteWorkspace -> DeleteWorkspace -> Bool)
-> Eq DeleteWorkspace
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]
(Int -> ReadS DeleteWorkspace)
-> ReadS [DeleteWorkspace]
-> ReadPrec DeleteWorkspace
-> ReadPrec [DeleteWorkspace]
-> Read 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
(Int -> DeleteWorkspace -> ShowS)
-> (DeleteWorkspace -> String)
-> ([DeleteWorkspace] -> ShowS)
-> Show DeleteWorkspace
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. DeleteWorkspace -> Rep DeleteWorkspace x)
-> (forall x. Rep DeleteWorkspace x -> DeleteWorkspace)
-> Generic DeleteWorkspace
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' :: Text -> DeleteWorkspace
DeleteWorkspace' {$sel:workspaceId:DeleteWorkspace' :: Text
workspaceId = Text
pWorkspaceId_}

-- | The ID of the workspace to delete.
deleteWorkspace_workspaceId :: Lens.Lens' DeleteWorkspace Prelude.Text
deleteWorkspace_workspaceId :: (Text -> f Text) -> DeleteWorkspace -> f DeleteWorkspace
deleteWorkspace_workspaceId = (DeleteWorkspace -> Text)
-> (DeleteWorkspace -> Text -> DeleteWorkspace)
-> Lens DeleteWorkspace DeleteWorkspace Text Text
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 :: DeleteWorkspace -> Request DeleteWorkspace
request = Service -> DeleteWorkspace -> Request DeleteWorkspace
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteWorkspace
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteWorkspace)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteWorkspace))
-> Logger
-> Service
-> Proxy DeleteWorkspace
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteWorkspace)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> WorkspaceDescription -> DeleteWorkspaceResponse
DeleteWorkspaceResponse'
            (Int -> WorkspaceDescription -> DeleteWorkspaceResponse)
-> Either String Int
-> Either String (WorkspaceDescription -> DeleteWorkspaceResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either String (WorkspaceDescription -> DeleteWorkspaceResponse)
-> Either String WorkspaceDescription
-> Either String DeleteWorkspaceResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String WorkspaceDescription
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"workspace")
      )

instance Prelude.Hashable DeleteWorkspace

instance Prelude.NFData DeleteWorkspace

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

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

instance Core.ToQuery DeleteWorkspace where
  toQuery :: DeleteWorkspace -> QueryString
toQuery = QueryString -> DeleteWorkspace -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeleteWorkspaceResponse -> DeleteWorkspaceResponse -> Bool)
-> (DeleteWorkspaceResponse -> DeleteWorkspaceResponse -> Bool)
-> Eq DeleteWorkspaceResponse
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
(Int -> DeleteWorkspaceResponse -> ShowS)
-> (DeleteWorkspaceResponse -> String)
-> ([DeleteWorkspaceResponse] -> ShowS)
-> Show DeleteWorkspaceResponse
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.
 DeleteWorkspaceResponse -> Rep DeleteWorkspaceResponse x)
-> (forall x.
    Rep DeleteWorkspaceResponse x -> DeleteWorkspaceResponse)
-> Generic DeleteWorkspaceResponse
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' :: Int -> WorkspaceDescription -> DeleteWorkspaceResponse
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 :: (Int -> f Int)
-> DeleteWorkspaceResponse -> f DeleteWorkspaceResponse
deleteWorkspaceResponse_httpStatus = (DeleteWorkspaceResponse -> Int)
-> (DeleteWorkspaceResponse -> Int -> DeleteWorkspaceResponse)
-> Lens DeleteWorkspaceResponse DeleteWorkspaceResponse Int Int
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 :: (WorkspaceDescription -> f WorkspaceDescription)
-> DeleteWorkspaceResponse -> f DeleteWorkspaceResponse
deleteWorkspaceResponse_workspace = (DeleteWorkspaceResponse -> WorkspaceDescription)
-> (DeleteWorkspaceResponse
    -> WorkspaceDescription -> DeleteWorkspaceResponse)
-> Lens
     DeleteWorkspaceResponse
     DeleteWorkspaceResponse
     WorkspaceDescription
     WorkspaceDescription
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