{-# 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.CloudDirectory.DeleteDirectory
-- 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 a directory. Only disabled directories can be deleted. A deleted
-- directory cannot be undone. Exercise extreme caution when deleting
-- directories.
module Amazonka.CloudDirectory.DeleteDirectory
  ( -- * Creating a Request
    DeleteDirectory (..),
    newDeleteDirectory,

    -- * Request Lenses
    deleteDirectory_directoryArn,

    -- * Destructuring the Response
    DeleteDirectoryResponse (..),
    newDeleteDirectoryResponse,

    -- * Response Lenses
    deleteDirectoryResponse_httpStatus,
    deleteDirectoryResponse_directoryArn,
  )
where

import Amazonka.CloudDirectory.Types
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

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

-- |
-- Create a value of 'DeleteDirectory' 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:
--
-- 'directoryArn', 'deleteDirectory_directoryArn' - The ARN of the directory to delete.
newDeleteDirectory ::
  -- | 'directoryArn'
  Prelude.Text ->
  DeleteDirectory
newDeleteDirectory :: Text -> DeleteDirectory
newDeleteDirectory Text
pDirectoryArn_ =
  DeleteDirectory' :: Text -> DeleteDirectory
DeleteDirectory' {$sel:directoryArn:DeleteDirectory' :: Text
directoryArn = Text
pDirectoryArn_}

-- | The ARN of the directory to delete.
deleteDirectory_directoryArn :: Lens.Lens' DeleteDirectory Prelude.Text
deleteDirectory_directoryArn :: (Text -> f Text) -> DeleteDirectory -> f DeleteDirectory
deleteDirectory_directoryArn = (DeleteDirectory -> Text)
-> (DeleteDirectory -> Text -> DeleteDirectory)
-> Lens DeleteDirectory DeleteDirectory Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDirectory' {Text
directoryArn :: Text
$sel:directoryArn:DeleteDirectory' :: DeleteDirectory -> Text
directoryArn} -> Text
directoryArn) (\s :: DeleteDirectory
s@DeleteDirectory' {} Text
a -> DeleteDirectory
s {$sel:directoryArn:DeleteDirectory' :: Text
directoryArn = Text
a} :: DeleteDirectory)

instance Core.AWSRequest DeleteDirectory where
  type
    AWSResponse DeleteDirectory =
      DeleteDirectoryResponse
  request :: DeleteDirectory -> Request DeleteDirectory
request = Service -> DeleteDirectory -> Request DeleteDirectory
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteDirectory
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteDirectory)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteDirectory))
-> Logger
-> Service
-> Proxy DeleteDirectory
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteDirectory)))
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 -> Text -> DeleteDirectoryResponse
DeleteDirectoryResponse'
            (Int -> Text -> DeleteDirectoryResponse)
-> Either String Int
-> Either String (Text -> DeleteDirectoryResponse)
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 (Text -> DeleteDirectoryResponse)
-> Either String Text -> Either String DeleteDirectoryResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"DirectoryArn")
      )

instance Prelude.Hashable DeleteDirectory

instance Prelude.NFData DeleteDirectory

instance Core.ToHeaders DeleteDirectory where
  toHeaders :: DeleteDirectory -> ResponseHeaders
toHeaders DeleteDirectory' {Text
directoryArn :: Text
$sel:directoryArn:DeleteDirectory' :: DeleteDirectory -> Text
..} =
    [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [HeaderName
"x-amz-data-partition" HeaderName -> Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Text
directoryArn]

instance Core.ToJSON DeleteDirectory where
  toJSON :: DeleteDirectory -> Value
toJSON = Value -> DeleteDirectory -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

instance Core.ToPath DeleteDirectory where
  toPath :: DeleteDirectory -> ByteString
toPath =
    ByteString -> DeleteDirectory -> ByteString
forall a b. a -> b -> a
Prelude.const
      ByteString
"/amazonclouddirectory/2017-01-11/directory"

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

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

-- |
-- Create a value of 'DeleteDirectoryResponse' 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', 'deleteDirectoryResponse_httpStatus' - The response's http status code.
--
-- 'directoryArn', 'deleteDirectoryResponse_directoryArn' - The ARN of the deleted directory.
newDeleteDirectoryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'directoryArn'
  Prelude.Text ->
  DeleteDirectoryResponse
newDeleteDirectoryResponse :: Int -> Text -> DeleteDirectoryResponse
newDeleteDirectoryResponse
  Int
pHttpStatus_
  Text
pDirectoryArn_ =
    DeleteDirectoryResponse' :: Int -> Text -> DeleteDirectoryResponse
DeleteDirectoryResponse'
      { $sel:httpStatus:DeleteDirectoryResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:directoryArn:DeleteDirectoryResponse' :: Text
directoryArn = Text
pDirectoryArn_
      }

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

-- | The ARN of the deleted directory.
deleteDirectoryResponse_directoryArn :: Lens.Lens' DeleteDirectoryResponse Prelude.Text
deleteDirectoryResponse_directoryArn :: (Text -> f Text)
-> DeleteDirectoryResponse -> f DeleteDirectoryResponse
deleteDirectoryResponse_directoryArn = (DeleteDirectoryResponse -> Text)
-> (DeleteDirectoryResponse -> Text -> DeleteDirectoryResponse)
-> Lens DeleteDirectoryResponse DeleteDirectoryResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDirectoryResponse' {Text
directoryArn :: Text
$sel:directoryArn:DeleteDirectoryResponse' :: DeleteDirectoryResponse -> Text
directoryArn} -> Text
directoryArn) (\s :: DeleteDirectoryResponse
s@DeleteDirectoryResponse' {} Text
a -> DeleteDirectoryResponse
s {$sel:directoryArn:DeleteDirectoryResponse' :: Text
directoryArn = Text
a} :: DeleteDirectoryResponse)

instance Prelude.NFData DeleteDirectoryResponse