{-# 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.DirectoryService.AcceptSharedDirectory
-- 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)
--
-- Accepts a directory sharing request that was sent from the directory
-- owner account.
module Amazonka.DirectoryService.AcceptSharedDirectory
  ( -- * Creating a Request
    AcceptSharedDirectory (..),
    newAcceptSharedDirectory,

    -- * Request Lenses
    acceptSharedDirectory_sharedDirectoryId,

    -- * Destructuring the Response
    AcceptSharedDirectoryResponse (..),
    newAcceptSharedDirectoryResponse,

    -- * Response Lenses
    acceptSharedDirectoryResponse_sharedDirectory,
    acceptSharedDirectoryResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DirectoryService.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:/ 'newAcceptSharedDirectory' smart constructor.
data AcceptSharedDirectory = AcceptSharedDirectory'
  { -- | Identifier of the shared directory in the directory consumer account.
    -- This identifier is different for each directory owner account.
    AcceptSharedDirectory -> Text
sharedDirectoryId :: Prelude.Text
  }
  deriving (AcceptSharedDirectory -> AcceptSharedDirectory -> Bool
(AcceptSharedDirectory -> AcceptSharedDirectory -> Bool)
-> (AcceptSharedDirectory -> AcceptSharedDirectory -> Bool)
-> Eq AcceptSharedDirectory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AcceptSharedDirectory -> AcceptSharedDirectory -> Bool
$c/= :: AcceptSharedDirectory -> AcceptSharedDirectory -> Bool
== :: AcceptSharedDirectory -> AcceptSharedDirectory -> Bool
$c== :: AcceptSharedDirectory -> AcceptSharedDirectory -> Bool
Prelude.Eq, ReadPrec [AcceptSharedDirectory]
ReadPrec AcceptSharedDirectory
Int -> ReadS AcceptSharedDirectory
ReadS [AcceptSharedDirectory]
(Int -> ReadS AcceptSharedDirectory)
-> ReadS [AcceptSharedDirectory]
-> ReadPrec AcceptSharedDirectory
-> ReadPrec [AcceptSharedDirectory]
-> Read AcceptSharedDirectory
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AcceptSharedDirectory]
$creadListPrec :: ReadPrec [AcceptSharedDirectory]
readPrec :: ReadPrec AcceptSharedDirectory
$creadPrec :: ReadPrec AcceptSharedDirectory
readList :: ReadS [AcceptSharedDirectory]
$creadList :: ReadS [AcceptSharedDirectory]
readsPrec :: Int -> ReadS AcceptSharedDirectory
$creadsPrec :: Int -> ReadS AcceptSharedDirectory
Prelude.Read, Int -> AcceptSharedDirectory -> ShowS
[AcceptSharedDirectory] -> ShowS
AcceptSharedDirectory -> String
(Int -> AcceptSharedDirectory -> ShowS)
-> (AcceptSharedDirectory -> String)
-> ([AcceptSharedDirectory] -> ShowS)
-> Show AcceptSharedDirectory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AcceptSharedDirectory] -> ShowS
$cshowList :: [AcceptSharedDirectory] -> ShowS
show :: AcceptSharedDirectory -> String
$cshow :: AcceptSharedDirectory -> String
showsPrec :: Int -> AcceptSharedDirectory -> ShowS
$cshowsPrec :: Int -> AcceptSharedDirectory -> ShowS
Prelude.Show, (forall x. AcceptSharedDirectory -> Rep AcceptSharedDirectory x)
-> (forall x. Rep AcceptSharedDirectory x -> AcceptSharedDirectory)
-> Generic AcceptSharedDirectory
forall x. Rep AcceptSharedDirectory x -> AcceptSharedDirectory
forall x. AcceptSharedDirectory -> Rep AcceptSharedDirectory x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AcceptSharedDirectory x -> AcceptSharedDirectory
$cfrom :: forall x. AcceptSharedDirectory -> Rep AcceptSharedDirectory x
Prelude.Generic)

-- |
-- Create a value of 'AcceptSharedDirectory' 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:
--
-- 'sharedDirectoryId', 'acceptSharedDirectory_sharedDirectoryId' - Identifier of the shared directory in the directory consumer account.
-- This identifier is different for each directory owner account.
newAcceptSharedDirectory ::
  -- | 'sharedDirectoryId'
  Prelude.Text ->
  AcceptSharedDirectory
newAcceptSharedDirectory :: Text -> AcceptSharedDirectory
newAcceptSharedDirectory Text
pSharedDirectoryId_ =
  AcceptSharedDirectory' :: Text -> AcceptSharedDirectory
AcceptSharedDirectory'
    { $sel:sharedDirectoryId:AcceptSharedDirectory' :: Text
sharedDirectoryId =
        Text
pSharedDirectoryId_
    }

-- | Identifier of the shared directory in the directory consumer account.
-- This identifier is different for each directory owner account.
acceptSharedDirectory_sharedDirectoryId :: Lens.Lens' AcceptSharedDirectory Prelude.Text
acceptSharedDirectory_sharedDirectoryId :: (Text -> f Text)
-> AcceptSharedDirectory -> f AcceptSharedDirectory
acceptSharedDirectory_sharedDirectoryId = (AcceptSharedDirectory -> Text)
-> (AcceptSharedDirectory -> Text -> AcceptSharedDirectory)
-> Lens AcceptSharedDirectory AcceptSharedDirectory Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AcceptSharedDirectory' {Text
sharedDirectoryId :: Text
$sel:sharedDirectoryId:AcceptSharedDirectory' :: AcceptSharedDirectory -> Text
sharedDirectoryId} -> Text
sharedDirectoryId) (\s :: AcceptSharedDirectory
s@AcceptSharedDirectory' {} Text
a -> AcceptSharedDirectory
s {$sel:sharedDirectoryId:AcceptSharedDirectory' :: Text
sharedDirectoryId = Text
a} :: AcceptSharedDirectory)

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

instance Prelude.NFData AcceptSharedDirectory

instance Core.ToHeaders AcceptSharedDirectory where
  toHeaders :: AcceptSharedDirectory -> ResponseHeaders
toHeaders =
    ResponseHeaders -> AcceptSharedDirectory -> 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
"DirectoryService_20150416.AcceptSharedDirectory" ::
                          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 AcceptSharedDirectory where
  toJSON :: AcceptSharedDirectory -> Value
toJSON AcceptSharedDirectory' {Text
sharedDirectoryId :: Text
$sel:sharedDirectoryId:AcceptSharedDirectory' :: AcceptSharedDirectory -> 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
"SharedDirectoryId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
sharedDirectoryId)
          ]
      )

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

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

-- | /See:/ 'newAcceptSharedDirectoryResponse' smart constructor.
data AcceptSharedDirectoryResponse = AcceptSharedDirectoryResponse'
  { -- | The shared directory in the directory consumer account.
    AcceptSharedDirectoryResponse -> Maybe SharedDirectory
sharedDirectory :: Prelude.Maybe SharedDirectory,
    -- | The response's http status code.
    AcceptSharedDirectoryResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (AcceptSharedDirectoryResponse
-> AcceptSharedDirectoryResponse -> Bool
(AcceptSharedDirectoryResponse
 -> AcceptSharedDirectoryResponse -> Bool)
-> (AcceptSharedDirectoryResponse
    -> AcceptSharedDirectoryResponse -> Bool)
-> Eq AcceptSharedDirectoryResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AcceptSharedDirectoryResponse
-> AcceptSharedDirectoryResponse -> Bool
$c/= :: AcceptSharedDirectoryResponse
-> AcceptSharedDirectoryResponse -> Bool
== :: AcceptSharedDirectoryResponse
-> AcceptSharedDirectoryResponse -> Bool
$c== :: AcceptSharedDirectoryResponse
-> AcceptSharedDirectoryResponse -> Bool
Prelude.Eq, Int -> AcceptSharedDirectoryResponse -> ShowS
[AcceptSharedDirectoryResponse] -> ShowS
AcceptSharedDirectoryResponse -> String
(Int -> AcceptSharedDirectoryResponse -> ShowS)
-> (AcceptSharedDirectoryResponse -> String)
-> ([AcceptSharedDirectoryResponse] -> ShowS)
-> Show AcceptSharedDirectoryResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AcceptSharedDirectoryResponse] -> ShowS
$cshowList :: [AcceptSharedDirectoryResponse] -> ShowS
show :: AcceptSharedDirectoryResponse -> String
$cshow :: AcceptSharedDirectoryResponse -> String
showsPrec :: Int -> AcceptSharedDirectoryResponse -> ShowS
$cshowsPrec :: Int -> AcceptSharedDirectoryResponse -> ShowS
Prelude.Show, (forall x.
 AcceptSharedDirectoryResponse
 -> Rep AcceptSharedDirectoryResponse x)
-> (forall x.
    Rep AcceptSharedDirectoryResponse x
    -> AcceptSharedDirectoryResponse)
-> Generic AcceptSharedDirectoryResponse
forall x.
Rep AcceptSharedDirectoryResponse x
-> AcceptSharedDirectoryResponse
forall x.
AcceptSharedDirectoryResponse
-> Rep AcceptSharedDirectoryResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AcceptSharedDirectoryResponse x
-> AcceptSharedDirectoryResponse
$cfrom :: forall x.
AcceptSharedDirectoryResponse
-> Rep AcceptSharedDirectoryResponse x
Prelude.Generic)

-- |
-- Create a value of 'AcceptSharedDirectoryResponse' 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:
--
-- 'sharedDirectory', 'acceptSharedDirectoryResponse_sharedDirectory' - The shared directory in the directory consumer account.
--
-- 'httpStatus', 'acceptSharedDirectoryResponse_httpStatus' - The response's http status code.
newAcceptSharedDirectoryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AcceptSharedDirectoryResponse
newAcceptSharedDirectoryResponse :: Int -> AcceptSharedDirectoryResponse
newAcceptSharedDirectoryResponse Int
pHttpStatus_ =
  AcceptSharedDirectoryResponse' :: Maybe SharedDirectory -> Int -> AcceptSharedDirectoryResponse
AcceptSharedDirectoryResponse'
    { $sel:sharedDirectory:AcceptSharedDirectoryResponse' :: Maybe SharedDirectory
sharedDirectory =
        Maybe SharedDirectory
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:AcceptSharedDirectoryResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The shared directory in the directory consumer account.
acceptSharedDirectoryResponse_sharedDirectory :: Lens.Lens' AcceptSharedDirectoryResponse (Prelude.Maybe SharedDirectory)
acceptSharedDirectoryResponse_sharedDirectory :: (Maybe SharedDirectory -> f (Maybe SharedDirectory))
-> AcceptSharedDirectoryResponse -> f AcceptSharedDirectoryResponse
acceptSharedDirectoryResponse_sharedDirectory = (AcceptSharedDirectoryResponse -> Maybe SharedDirectory)
-> (AcceptSharedDirectoryResponse
    -> Maybe SharedDirectory -> AcceptSharedDirectoryResponse)
-> Lens
     AcceptSharedDirectoryResponse
     AcceptSharedDirectoryResponse
     (Maybe SharedDirectory)
     (Maybe SharedDirectory)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AcceptSharedDirectoryResponse' {Maybe SharedDirectory
sharedDirectory :: Maybe SharedDirectory
$sel:sharedDirectory:AcceptSharedDirectoryResponse' :: AcceptSharedDirectoryResponse -> Maybe SharedDirectory
sharedDirectory} -> Maybe SharedDirectory
sharedDirectory) (\s :: AcceptSharedDirectoryResponse
s@AcceptSharedDirectoryResponse' {} Maybe SharedDirectory
a -> AcceptSharedDirectoryResponse
s {$sel:sharedDirectory:AcceptSharedDirectoryResponse' :: Maybe SharedDirectory
sharedDirectory = Maybe SharedDirectory
a} :: AcceptSharedDirectoryResponse)

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

instance Prelude.NFData AcceptSharedDirectoryResponse