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

    -- * Request Lenses
    rejectSharedDirectory_sharedDirectoryId,

    -- * Destructuring the Response
    RejectSharedDirectoryResponse (..),
    newRejectSharedDirectoryResponse,

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

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

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

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

instance Prelude.NFData RejectSharedDirectory

instance Core.ToHeaders RejectSharedDirectory where
  toHeaders :: RejectSharedDirectory -> ResponseHeaders
toHeaders =
    ResponseHeaders -> RejectSharedDirectory -> 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.RejectSharedDirectory" ::
                          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 RejectSharedDirectory where
  toJSON :: RejectSharedDirectory -> Value
toJSON RejectSharedDirectory' {Text
sharedDirectoryId :: Text
$sel:sharedDirectoryId:RejectSharedDirectory' :: RejectSharedDirectory -> 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 RejectSharedDirectory where
  toPath :: RejectSharedDirectory -> ByteString
toPath = ByteString -> RejectSharedDirectory -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'RejectSharedDirectoryResponse' 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', 'rejectSharedDirectoryResponse_sharedDirectoryId' - Identifier of the shared directory in the directory consumer account.
--
-- 'httpStatus', 'rejectSharedDirectoryResponse_httpStatus' - The response's http status code.
newRejectSharedDirectoryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  RejectSharedDirectoryResponse
newRejectSharedDirectoryResponse :: Int -> RejectSharedDirectoryResponse
newRejectSharedDirectoryResponse Int
pHttpStatus_ =
  RejectSharedDirectoryResponse' :: Maybe Text -> Int -> RejectSharedDirectoryResponse
RejectSharedDirectoryResponse'
    { $sel:sharedDirectoryId:RejectSharedDirectoryResponse' :: Maybe Text
sharedDirectoryId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:RejectSharedDirectoryResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Identifier of the shared directory in the directory consumer account.
rejectSharedDirectoryResponse_sharedDirectoryId :: Lens.Lens' RejectSharedDirectoryResponse (Prelude.Maybe Prelude.Text)
rejectSharedDirectoryResponse_sharedDirectoryId :: (Maybe Text -> f (Maybe Text))
-> RejectSharedDirectoryResponse -> f RejectSharedDirectoryResponse
rejectSharedDirectoryResponse_sharedDirectoryId = (RejectSharedDirectoryResponse -> Maybe Text)
-> (RejectSharedDirectoryResponse
    -> Maybe Text -> RejectSharedDirectoryResponse)
-> Lens
     RejectSharedDirectoryResponse
     RejectSharedDirectoryResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RejectSharedDirectoryResponse' {Maybe Text
sharedDirectoryId :: Maybe Text
$sel:sharedDirectoryId:RejectSharedDirectoryResponse' :: RejectSharedDirectoryResponse -> Maybe Text
sharedDirectoryId} -> Maybe Text
sharedDirectoryId) (\s :: RejectSharedDirectoryResponse
s@RejectSharedDirectoryResponse' {} Maybe Text
a -> RejectSharedDirectoryResponse
s {$sel:sharedDirectoryId:RejectSharedDirectoryResponse' :: Maybe Text
sharedDirectoryId = Maybe Text
a} :: RejectSharedDirectoryResponse)

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

instance Prelude.NFData RejectSharedDirectoryResponse