{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.UnshareTarget
-- 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)
module Amazonka.DirectoryService.Types.UnshareTarget where

import qualified Amazonka.Core as Core
import Amazonka.DirectoryService.Types.TargetType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Identifier that contains details about the directory consumer account
-- with whom the directory is being unshared.
--
-- /See:/ 'newUnshareTarget' smart constructor.
data UnshareTarget = UnshareTarget'
  { -- | Identifier of the directory consumer account.
    UnshareTarget -> Text
id :: Prelude.Text,
    -- | Type of identifier to be used in the /Id/ field.
    UnshareTarget -> TargetType
type' :: TargetType
  }
  deriving (UnshareTarget -> UnshareTarget -> Bool
(UnshareTarget -> UnshareTarget -> Bool)
-> (UnshareTarget -> UnshareTarget -> Bool) -> Eq UnshareTarget
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UnshareTarget -> UnshareTarget -> Bool
$c/= :: UnshareTarget -> UnshareTarget -> Bool
== :: UnshareTarget -> UnshareTarget -> Bool
$c== :: UnshareTarget -> UnshareTarget -> Bool
Prelude.Eq, ReadPrec [UnshareTarget]
ReadPrec UnshareTarget
Int -> ReadS UnshareTarget
ReadS [UnshareTarget]
(Int -> ReadS UnshareTarget)
-> ReadS [UnshareTarget]
-> ReadPrec UnshareTarget
-> ReadPrec [UnshareTarget]
-> Read UnshareTarget
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UnshareTarget]
$creadListPrec :: ReadPrec [UnshareTarget]
readPrec :: ReadPrec UnshareTarget
$creadPrec :: ReadPrec UnshareTarget
readList :: ReadS [UnshareTarget]
$creadList :: ReadS [UnshareTarget]
readsPrec :: Int -> ReadS UnshareTarget
$creadsPrec :: Int -> ReadS UnshareTarget
Prelude.Read, Int -> UnshareTarget -> ShowS
[UnshareTarget] -> ShowS
UnshareTarget -> String
(Int -> UnshareTarget -> ShowS)
-> (UnshareTarget -> String)
-> ([UnshareTarget] -> ShowS)
-> Show UnshareTarget
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UnshareTarget] -> ShowS
$cshowList :: [UnshareTarget] -> ShowS
show :: UnshareTarget -> String
$cshow :: UnshareTarget -> String
showsPrec :: Int -> UnshareTarget -> ShowS
$cshowsPrec :: Int -> UnshareTarget -> ShowS
Prelude.Show, (forall x. UnshareTarget -> Rep UnshareTarget x)
-> (forall x. Rep UnshareTarget x -> UnshareTarget)
-> Generic UnshareTarget
forall x. Rep UnshareTarget x -> UnshareTarget
forall x. UnshareTarget -> Rep UnshareTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UnshareTarget x -> UnshareTarget
$cfrom :: forall x. UnshareTarget -> Rep UnshareTarget x
Prelude.Generic)

-- |
-- Create a value of 'UnshareTarget' 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:
--
-- 'id', 'unshareTarget_id' - Identifier of the directory consumer account.
--
-- 'type'', 'unshareTarget_type' - Type of identifier to be used in the /Id/ field.
newUnshareTarget ::
  -- | 'id'
  Prelude.Text ->
  -- | 'type''
  TargetType ->
  UnshareTarget
newUnshareTarget :: Text -> TargetType -> UnshareTarget
newUnshareTarget Text
pId_ TargetType
pType_ =
  UnshareTarget' :: Text -> TargetType -> UnshareTarget
UnshareTarget' {$sel:id:UnshareTarget' :: Text
id = Text
pId_, $sel:type':UnshareTarget' :: TargetType
type' = TargetType
pType_}

-- | Identifier of the directory consumer account.
unshareTarget_id :: Lens.Lens' UnshareTarget Prelude.Text
unshareTarget_id :: (Text -> f Text) -> UnshareTarget -> f UnshareTarget
unshareTarget_id = (UnshareTarget -> Text)
-> (UnshareTarget -> Text -> UnshareTarget)
-> Lens UnshareTarget UnshareTarget Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnshareTarget' {Text
id :: Text
$sel:id:UnshareTarget' :: UnshareTarget -> Text
id} -> Text
id) (\s :: UnshareTarget
s@UnshareTarget' {} Text
a -> UnshareTarget
s {$sel:id:UnshareTarget' :: Text
id = Text
a} :: UnshareTarget)

-- | Type of identifier to be used in the /Id/ field.
unshareTarget_type :: Lens.Lens' UnshareTarget TargetType
unshareTarget_type :: (TargetType -> f TargetType) -> UnshareTarget -> f UnshareTarget
unshareTarget_type = (UnshareTarget -> TargetType)
-> (UnshareTarget -> TargetType -> UnshareTarget)
-> Lens UnshareTarget UnshareTarget TargetType TargetType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnshareTarget' {TargetType
type' :: TargetType
$sel:type':UnshareTarget' :: UnshareTarget -> TargetType
type'} -> TargetType
type') (\s :: UnshareTarget
s@UnshareTarget' {} TargetType
a -> UnshareTarget
s {$sel:type':UnshareTarget' :: TargetType
type' = TargetType
a} :: UnshareTarget)

instance Prelude.Hashable UnshareTarget

instance Prelude.NFData UnshareTarget

instance Core.ToJSON UnshareTarget where
  toJSON :: UnshareTarget -> Value
toJSON UnshareTarget' {Text
TargetType
type' :: TargetType
id :: Text
$sel:type':UnshareTarget' :: UnshareTarget -> TargetType
$sel:id:UnshareTarget' :: UnshareTarget -> 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
"Id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> TargetType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TargetType
type')
          ]
      )