{-# 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.Organizations.Types.HandshakeParty
-- 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.Organizations.Types.HandshakeParty where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Organizations.Types.HandshakePartyType
import qualified Amazonka.Prelude as Prelude

-- | Identifies a participant in a handshake.
--
-- /See:/ 'newHandshakeParty' smart constructor.
data HandshakeParty = HandshakeParty'
  { -- | The unique identifier (ID) for the party.
    --
    -- The <http://wikipedia.org/wiki/regex regex pattern> for handshake ID
    -- string requires \"h-\" followed by from 8 to 32 lowercase letters or
    -- digits.
    HandshakeParty -> Sensitive Text
id :: Core.Sensitive Prelude.Text,
    -- | The type of party.
    HandshakeParty -> HandshakePartyType
type' :: HandshakePartyType
  }
  deriving (HandshakeParty -> HandshakeParty -> Bool
(HandshakeParty -> HandshakeParty -> Bool)
-> (HandshakeParty -> HandshakeParty -> Bool) -> Eq HandshakeParty
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HandshakeParty -> HandshakeParty -> Bool
$c/= :: HandshakeParty -> HandshakeParty -> Bool
== :: HandshakeParty -> HandshakeParty -> Bool
$c== :: HandshakeParty -> HandshakeParty -> Bool
Prelude.Eq, Int -> HandshakeParty -> ShowS
[HandshakeParty] -> ShowS
HandshakeParty -> String
(Int -> HandshakeParty -> ShowS)
-> (HandshakeParty -> String)
-> ([HandshakeParty] -> ShowS)
-> Show HandshakeParty
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HandshakeParty] -> ShowS
$cshowList :: [HandshakeParty] -> ShowS
show :: HandshakeParty -> String
$cshow :: HandshakeParty -> String
showsPrec :: Int -> HandshakeParty -> ShowS
$cshowsPrec :: Int -> HandshakeParty -> ShowS
Prelude.Show, (forall x. HandshakeParty -> Rep HandshakeParty x)
-> (forall x. Rep HandshakeParty x -> HandshakeParty)
-> Generic HandshakeParty
forall x. Rep HandshakeParty x -> HandshakeParty
forall x. HandshakeParty -> Rep HandshakeParty x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HandshakeParty x -> HandshakeParty
$cfrom :: forall x. HandshakeParty -> Rep HandshakeParty x
Prelude.Generic)

-- |
-- Create a value of 'HandshakeParty' 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', 'handshakeParty_id' - The unique identifier (ID) for the party.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for handshake ID
-- string requires \"h-\" followed by from 8 to 32 lowercase letters or
-- digits.
--
-- 'type'', 'handshakeParty_type' - The type of party.
newHandshakeParty ::
  -- | 'id'
  Prelude.Text ->
  -- | 'type''
  HandshakePartyType ->
  HandshakeParty
newHandshakeParty :: Text -> HandshakePartyType -> HandshakeParty
newHandshakeParty Text
pId_ HandshakePartyType
pType_ =
  HandshakeParty' :: Sensitive Text -> HandshakePartyType -> HandshakeParty
HandshakeParty'
    { $sel:id:HandshakeParty' :: Sensitive Text
id = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pId_,
      $sel:type':HandshakeParty' :: HandshakePartyType
type' = HandshakePartyType
pType_
    }

-- | The unique identifier (ID) for the party.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for handshake ID
-- string requires \"h-\" followed by from 8 to 32 lowercase letters or
-- digits.
handshakeParty_id :: Lens.Lens' HandshakeParty Prelude.Text
handshakeParty_id :: (Text -> f Text) -> HandshakeParty -> f HandshakeParty
handshakeParty_id = (HandshakeParty -> Sensitive Text)
-> (HandshakeParty -> Sensitive Text -> HandshakeParty)
-> Lens
     HandshakeParty HandshakeParty (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HandshakeParty' {Sensitive Text
id :: Sensitive Text
$sel:id:HandshakeParty' :: HandshakeParty -> Sensitive Text
id} -> Sensitive Text
id) (\s :: HandshakeParty
s@HandshakeParty' {} Sensitive Text
a -> HandshakeParty
s {$sel:id:HandshakeParty' :: Sensitive Text
id = Sensitive Text
a} :: HandshakeParty) ((Sensitive Text -> f (Sensitive Text))
 -> HandshakeParty -> f HandshakeParty)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> HandshakeParty
-> f HandshakeParty
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The type of party.
handshakeParty_type :: Lens.Lens' HandshakeParty HandshakePartyType
handshakeParty_type :: (HandshakePartyType -> f HandshakePartyType)
-> HandshakeParty -> f HandshakeParty
handshakeParty_type = (HandshakeParty -> HandshakePartyType)
-> (HandshakeParty -> HandshakePartyType -> HandshakeParty)
-> Lens
     HandshakeParty HandshakeParty HandshakePartyType HandshakePartyType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HandshakeParty' {HandshakePartyType
type' :: HandshakePartyType
$sel:type':HandshakeParty' :: HandshakeParty -> HandshakePartyType
type'} -> HandshakePartyType
type') (\s :: HandshakeParty
s@HandshakeParty' {} HandshakePartyType
a -> HandshakeParty
s {$sel:type':HandshakeParty' :: HandshakePartyType
type' = HandshakePartyType
a} :: HandshakeParty)

instance Core.FromJSON HandshakeParty where
  parseJSON :: Value -> Parser HandshakeParty
parseJSON =
    String
-> (Object -> Parser HandshakeParty)
-> Value
-> Parser HandshakeParty
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HandshakeParty"
      ( \Object
x ->
          Sensitive Text -> HandshakePartyType -> HandshakeParty
HandshakeParty'
            (Sensitive Text -> HandshakePartyType -> HandshakeParty)
-> Parser (Sensitive Text)
-> Parser (HandshakePartyType -> HandshakeParty)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Sensitive Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Id") Parser (HandshakePartyType -> HandshakeParty)
-> Parser HandshakePartyType -> Parser HandshakeParty
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser HandshakePartyType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Type")
      )

instance Prelude.Hashable HandshakeParty

instance Prelude.NFData HandshakeParty

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