{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Organizations.Types.HandshakeParty where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 :: Data.Sensitive Prelude.Text,
    -- | The type of party.
    HandshakeParty -> HandshakePartyType
type' :: HandshakePartyType
  }
  deriving (HandshakeParty -> HandshakeParty -> Bool
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
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. 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'
    { $sel:id:HandshakeParty' :: Sensitive Text
id = forall a. Iso' (Sensitive a) a
Data._Sensitive 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 :: Lens' HandshakeParty Text
handshakeParty_id = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | The type of party.
handshakeParty_type :: Lens.Lens' HandshakeParty HandshakePartyType
handshakeParty_type :: Lens' HandshakeParty HandshakePartyType
handshakeParty_type = 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 Data.FromJSON HandshakeParty where
  parseJSON :: Value -> Parser HandshakeParty
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"HandshakeParty"
      ( \Object
x ->
          Sensitive Text -> HandshakePartyType -> HandshakeParty
HandshakeParty'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Id")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Type")
      )

instance Prelude.Hashable HandshakeParty where
  hashWithSalt :: Int -> HandshakeParty -> Int
hashWithSalt Int
_salt HandshakeParty' {Sensitive Text
HandshakePartyType
type' :: HandshakePartyType
id :: Sensitive Text
$sel:type':HandshakeParty' :: HandshakeParty -> HandshakePartyType
$sel:id:HandshakeParty' :: HandshakeParty -> Sensitive Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` HandshakePartyType
type'

instance Prelude.NFData HandshakeParty where
  rnf :: HandshakeParty -> ()
rnf HandshakeParty' {Sensitive Text
HandshakePartyType
type' :: HandshakePartyType
id :: Sensitive Text
$sel:type':HandshakeParty' :: HandshakeParty -> HandshakePartyType
$sel:id:HandshakeParty' :: HandshakeParty -> Sensitive Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
id seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf HandshakePartyType
type'

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive Text
id),
            forall a. a -> Maybe a
Prelude.Just (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= HandshakePartyType
type')
          ]
      )