{-# 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.WorkSpaces.DeregisterWorkspaceDirectory
-- 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)
--
-- Deregisters the specified directory. This operation is asynchronous and
-- returns before the WorkSpace directory is deregistered. If any
-- WorkSpaces are registered to this directory, you must remove them before
-- you can deregister the directory.
--
-- Simple AD and AD Connector are made available to you free of charge to
-- use with WorkSpaces. If there are no WorkSpaces being used with your
-- Simple AD or AD Connector directory for 30 consecutive days, this
-- directory will be automatically deregistered for use with Amazon
-- WorkSpaces, and you will be charged for this directory as per the
-- <http://aws.amazon.com/directoryservice/pricing/ Directory Service pricing terms>.
--
-- To delete empty directories, see
-- <https://docs.aws.amazon.com/workspaces/latest/adminguide/delete-workspaces-directory.html Delete the Directory for Your WorkSpaces>.
-- If you delete your Simple AD or AD Connector directory, you can always
-- create a new one when you want to start using WorkSpaces again.
module Amazonka.WorkSpaces.DeregisterWorkspaceDirectory
  ( -- * Creating a Request
    DeregisterWorkspaceDirectory (..),
    newDeregisterWorkspaceDirectory,

    -- * Request Lenses
    deregisterWorkspaceDirectory_directoryId,

    -- * Destructuring the Response
    DeregisterWorkspaceDirectoryResponse (..),
    newDeregisterWorkspaceDirectoryResponse,

    -- * Response Lenses
    deregisterWorkspaceDirectoryResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.WorkSpaces.Types

-- | /See:/ 'newDeregisterWorkspaceDirectory' smart constructor.
data DeregisterWorkspaceDirectory = DeregisterWorkspaceDirectory'
  { -- | The identifier of the directory. If any WorkSpaces are registered to
    -- this directory, you must remove them before you deregister the
    -- directory, or you will receive an OperationNotSupportedException error.
    DeregisterWorkspaceDirectory -> Text
directoryId :: Prelude.Text
  }
  deriving (DeregisterWorkspaceDirectory
-> DeregisterWorkspaceDirectory -> Bool
(DeregisterWorkspaceDirectory
 -> DeregisterWorkspaceDirectory -> Bool)
-> (DeregisterWorkspaceDirectory
    -> DeregisterWorkspaceDirectory -> Bool)
-> Eq DeregisterWorkspaceDirectory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeregisterWorkspaceDirectory
-> DeregisterWorkspaceDirectory -> Bool
$c/= :: DeregisterWorkspaceDirectory
-> DeregisterWorkspaceDirectory -> Bool
== :: DeregisterWorkspaceDirectory
-> DeregisterWorkspaceDirectory -> Bool
$c== :: DeregisterWorkspaceDirectory
-> DeregisterWorkspaceDirectory -> Bool
Prelude.Eq, ReadPrec [DeregisterWorkspaceDirectory]
ReadPrec DeregisterWorkspaceDirectory
Int -> ReadS DeregisterWorkspaceDirectory
ReadS [DeregisterWorkspaceDirectory]
(Int -> ReadS DeregisterWorkspaceDirectory)
-> ReadS [DeregisterWorkspaceDirectory]
-> ReadPrec DeregisterWorkspaceDirectory
-> ReadPrec [DeregisterWorkspaceDirectory]
-> Read DeregisterWorkspaceDirectory
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeregisterWorkspaceDirectory]
$creadListPrec :: ReadPrec [DeregisterWorkspaceDirectory]
readPrec :: ReadPrec DeregisterWorkspaceDirectory
$creadPrec :: ReadPrec DeregisterWorkspaceDirectory
readList :: ReadS [DeregisterWorkspaceDirectory]
$creadList :: ReadS [DeregisterWorkspaceDirectory]
readsPrec :: Int -> ReadS DeregisterWorkspaceDirectory
$creadsPrec :: Int -> ReadS DeregisterWorkspaceDirectory
Prelude.Read, Int -> DeregisterWorkspaceDirectory -> ShowS
[DeregisterWorkspaceDirectory] -> ShowS
DeregisterWorkspaceDirectory -> String
(Int -> DeregisterWorkspaceDirectory -> ShowS)
-> (DeregisterWorkspaceDirectory -> String)
-> ([DeregisterWorkspaceDirectory] -> ShowS)
-> Show DeregisterWorkspaceDirectory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeregisterWorkspaceDirectory] -> ShowS
$cshowList :: [DeregisterWorkspaceDirectory] -> ShowS
show :: DeregisterWorkspaceDirectory -> String
$cshow :: DeregisterWorkspaceDirectory -> String
showsPrec :: Int -> DeregisterWorkspaceDirectory -> ShowS
$cshowsPrec :: Int -> DeregisterWorkspaceDirectory -> ShowS
Prelude.Show, (forall x.
 DeregisterWorkspaceDirectory -> Rep DeregisterWorkspaceDirectory x)
-> (forall x.
    Rep DeregisterWorkspaceDirectory x -> DeregisterWorkspaceDirectory)
-> Generic DeregisterWorkspaceDirectory
forall x.
Rep DeregisterWorkspaceDirectory x -> DeregisterWorkspaceDirectory
forall x.
DeregisterWorkspaceDirectory -> Rep DeregisterWorkspaceDirectory x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeregisterWorkspaceDirectory x -> DeregisterWorkspaceDirectory
$cfrom :: forall x.
DeregisterWorkspaceDirectory -> Rep DeregisterWorkspaceDirectory x
Prelude.Generic)

-- |
-- Create a value of 'DeregisterWorkspaceDirectory' 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:
--
-- 'directoryId', 'deregisterWorkspaceDirectory_directoryId' - The identifier of the directory. If any WorkSpaces are registered to
-- this directory, you must remove them before you deregister the
-- directory, or you will receive an OperationNotSupportedException error.
newDeregisterWorkspaceDirectory ::
  -- | 'directoryId'
  Prelude.Text ->
  DeregisterWorkspaceDirectory
newDeregisterWorkspaceDirectory :: Text -> DeregisterWorkspaceDirectory
newDeregisterWorkspaceDirectory Text
pDirectoryId_ =
  DeregisterWorkspaceDirectory' :: Text -> DeregisterWorkspaceDirectory
DeregisterWorkspaceDirectory'
    { $sel:directoryId:DeregisterWorkspaceDirectory' :: Text
directoryId =
        Text
pDirectoryId_
    }

-- | The identifier of the directory. If any WorkSpaces are registered to
-- this directory, you must remove them before you deregister the
-- directory, or you will receive an OperationNotSupportedException error.
deregisterWorkspaceDirectory_directoryId :: Lens.Lens' DeregisterWorkspaceDirectory Prelude.Text
deregisterWorkspaceDirectory_directoryId :: (Text -> f Text)
-> DeregisterWorkspaceDirectory -> f DeregisterWorkspaceDirectory
deregisterWorkspaceDirectory_directoryId = (DeregisterWorkspaceDirectory -> Text)
-> (DeregisterWorkspaceDirectory
    -> Text -> DeregisterWorkspaceDirectory)
-> Lens
     DeregisterWorkspaceDirectory DeregisterWorkspaceDirectory Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterWorkspaceDirectory' {Text
directoryId :: Text
$sel:directoryId:DeregisterWorkspaceDirectory' :: DeregisterWorkspaceDirectory -> Text
directoryId} -> Text
directoryId) (\s :: DeregisterWorkspaceDirectory
s@DeregisterWorkspaceDirectory' {} Text
a -> DeregisterWorkspaceDirectory
s {$sel:directoryId:DeregisterWorkspaceDirectory' :: Text
directoryId = Text
a} :: DeregisterWorkspaceDirectory)

instance Core.AWSRequest DeregisterWorkspaceDirectory where
  type
    AWSResponse DeregisterWorkspaceDirectory =
      DeregisterWorkspaceDirectoryResponse
  request :: DeregisterWorkspaceDirectory
-> Request DeregisterWorkspaceDirectory
request = Service
-> DeregisterWorkspaceDirectory
-> Request DeregisterWorkspaceDirectory
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeregisterWorkspaceDirectory
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeregisterWorkspaceDirectory)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeregisterWorkspaceDirectory))
-> Logger
-> Service
-> Proxy DeregisterWorkspaceDirectory
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeregisterWorkspaceDirectory)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeregisterWorkspaceDirectoryResponse
DeregisterWorkspaceDirectoryResponse'
            (Int -> DeregisterWorkspaceDirectoryResponse)
-> Either String Int
-> Either String DeregisterWorkspaceDirectoryResponse
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))
      )

instance
  Prelude.Hashable
    DeregisterWorkspaceDirectory

instance Prelude.NFData DeregisterWorkspaceDirectory

instance Core.ToHeaders DeregisterWorkspaceDirectory where
  toHeaders :: DeregisterWorkspaceDirectory -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeregisterWorkspaceDirectory -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"WorkspacesService.DeregisterWorkspaceDirectory" ::
                          Prelude.ByteString
                      ),
            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.ToJSON DeregisterWorkspaceDirectory where
  toJSON :: DeregisterWorkspaceDirectory -> Value
toJSON DeregisterWorkspaceDirectory' {Text
directoryId :: Text
$sel:directoryId:DeregisterWorkspaceDirectory' :: DeregisterWorkspaceDirectory -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DirectoryId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
directoryId)]
      )

instance Core.ToPath DeregisterWorkspaceDirectory where
  toPath :: DeregisterWorkspaceDirectory -> ByteString
toPath = ByteString -> DeregisterWorkspaceDirectory -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'DeregisterWorkspaceDirectoryResponse' 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', 'deregisterWorkspaceDirectoryResponse_httpStatus' - The response's http status code.
newDeregisterWorkspaceDirectoryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeregisterWorkspaceDirectoryResponse
newDeregisterWorkspaceDirectoryResponse :: Int -> DeregisterWorkspaceDirectoryResponse
newDeregisterWorkspaceDirectoryResponse Int
pHttpStatus_ =
  DeregisterWorkspaceDirectoryResponse' :: Int -> DeregisterWorkspaceDirectoryResponse
DeregisterWorkspaceDirectoryResponse'
    { $sel:httpStatus:DeregisterWorkspaceDirectoryResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance
  Prelude.NFData
    DeregisterWorkspaceDirectoryResponse