{-# 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.ShareTarget
-- 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.ShareTarget 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.
--
-- /See:/ 'newShareTarget' smart constructor.
data ShareTarget = ShareTarget'
  { -- | Identifier of the directory consumer account.
    ShareTarget -> Text
id :: Prelude.Text,
    -- | Type of identifier to be used in the @Id@ field.
    ShareTarget -> TargetType
type' :: TargetType
  }
  deriving (ShareTarget -> ShareTarget -> Bool
(ShareTarget -> ShareTarget -> Bool)
-> (ShareTarget -> ShareTarget -> Bool) -> Eq ShareTarget
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ShareTarget -> ShareTarget -> Bool
$c/= :: ShareTarget -> ShareTarget -> Bool
== :: ShareTarget -> ShareTarget -> Bool
$c== :: ShareTarget -> ShareTarget -> Bool
Prelude.Eq, ReadPrec [ShareTarget]
ReadPrec ShareTarget
Int -> ReadS ShareTarget
ReadS [ShareTarget]
(Int -> ReadS ShareTarget)
-> ReadS [ShareTarget]
-> ReadPrec ShareTarget
-> ReadPrec [ShareTarget]
-> Read ShareTarget
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ShareTarget]
$creadListPrec :: ReadPrec [ShareTarget]
readPrec :: ReadPrec ShareTarget
$creadPrec :: ReadPrec ShareTarget
readList :: ReadS [ShareTarget]
$creadList :: ReadS [ShareTarget]
readsPrec :: Int -> ReadS ShareTarget
$creadsPrec :: Int -> ReadS ShareTarget
Prelude.Read, Int -> ShareTarget -> ShowS
[ShareTarget] -> ShowS
ShareTarget -> String
(Int -> ShareTarget -> ShowS)
-> (ShareTarget -> String)
-> ([ShareTarget] -> ShowS)
-> Show ShareTarget
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ShareTarget] -> ShowS
$cshowList :: [ShareTarget] -> ShowS
show :: ShareTarget -> String
$cshow :: ShareTarget -> String
showsPrec :: Int -> ShareTarget -> ShowS
$cshowsPrec :: Int -> ShareTarget -> ShowS
Prelude.Show, (forall x. ShareTarget -> Rep ShareTarget x)
-> (forall x. Rep ShareTarget x -> ShareTarget)
-> Generic ShareTarget
forall x. Rep ShareTarget x -> ShareTarget
forall x. ShareTarget -> Rep ShareTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ShareTarget x -> ShareTarget
$cfrom :: forall x. ShareTarget -> Rep ShareTarget x
Prelude.Generic)

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

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

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

instance Prelude.Hashable ShareTarget

instance Prelude.NFData ShareTarget

instance Core.ToJSON ShareTarget where
  toJSON :: ShareTarget -> Value
toJSON ShareTarget' {Text
TargetType
type' :: TargetType
id :: Text
$sel:type':ShareTarget' :: ShareTarget -> TargetType
$sel:id:ShareTarget' :: ShareTarget -> 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')
          ]
      )