{-# 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.HandshakeResource
-- 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.HandshakeResource where

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

-- | Contains additional data that is needed to process a handshake.
--
-- /See:/ 'newHandshakeResource' smart constructor.
data HandshakeResource = HandshakeResource'
  { -- | The information that is passed to the other party in the handshake. The
    -- format of the value string must match the requirements of the specified
    -- type.
    HandshakeResource -> Maybe (Sensitive Text)
value :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | When needed, contains an additional array of @HandshakeResource@
    -- objects.
    HandshakeResource -> Maybe [HandshakeResource]
resources :: Prelude.Maybe [HandshakeResource],
    -- | The type of information being passed, specifying how the value is to be
    -- interpreted by the other party:
    --
    -- -   @ACCOUNT@ - Specifies an AWS account ID number.
    --
    -- -   @ORGANIZATION@ - Specifies an organization ID number.
    --
    -- -   @EMAIL@ - Specifies the email address that is associated with the
    --     account that receives the handshake.
    --
    -- -   @OWNER_EMAIL@ - Specifies the email address associated with the
    --     management account. Included as information about an organization.
    --
    -- -   @OWNER_NAME@ - Specifies the name associated with the management
    --     account. Included as information about an organization.
    --
    -- -   @NOTES@ - Additional text provided by the handshake initiator and
    --     intended for the recipient to read.
    HandshakeResource -> Maybe HandshakeResourceType
type' :: Prelude.Maybe HandshakeResourceType
  }
  deriving (HandshakeResource -> HandshakeResource -> Bool
(HandshakeResource -> HandshakeResource -> Bool)
-> (HandshakeResource -> HandshakeResource -> Bool)
-> Eq HandshakeResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HandshakeResource -> HandshakeResource -> Bool
$c/= :: HandshakeResource -> HandshakeResource -> Bool
== :: HandshakeResource -> HandshakeResource -> Bool
$c== :: HandshakeResource -> HandshakeResource -> Bool
Prelude.Eq, Int -> HandshakeResource -> ShowS
[HandshakeResource] -> ShowS
HandshakeResource -> String
(Int -> HandshakeResource -> ShowS)
-> (HandshakeResource -> String)
-> ([HandshakeResource] -> ShowS)
-> Show HandshakeResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HandshakeResource] -> ShowS
$cshowList :: [HandshakeResource] -> ShowS
show :: HandshakeResource -> String
$cshow :: HandshakeResource -> String
showsPrec :: Int -> HandshakeResource -> ShowS
$cshowsPrec :: Int -> HandshakeResource -> ShowS
Prelude.Show, (forall x. HandshakeResource -> Rep HandshakeResource x)
-> (forall x. Rep HandshakeResource x -> HandshakeResource)
-> Generic HandshakeResource
forall x. Rep HandshakeResource x -> HandshakeResource
forall x. HandshakeResource -> Rep HandshakeResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HandshakeResource x -> HandshakeResource
$cfrom :: forall x. HandshakeResource -> Rep HandshakeResource x
Prelude.Generic)

-- |
-- Create a value of 'HandshakeResource' 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:
--
-- 'value', 'handshakeResource_value' - The information that is passed to the other party in the handshake. The
-- format of the value string must match the requirements of the specified
-- type.
--
-- 'resources', 'handshakeResource_resources' - When needed, contains an additional array of @HandshakeResource@
-- objects.
--
-- 'type'', 'handshakeResource_type' - The type of information being passed, specifying how the value is to be
-- interpreted by the other party:
--
-- -   @ACCOUNT@ - Specifies an AWS account ID number.
--
-- -   @ORGANIZATION@ - Specifies an organization ID number.
--
-- -   @EMAIL@ - Specifies the email address that is associated with the
--     account that receives the handshake.
--
-- -   @OWNER_EMAIL@ - Specifies the email address associated with the
--     management account. Included as information about an organization.
--
-- -   @OWNER_NAME@ - Specifies the name associated with the management
--     account. Included as information about an organization.
--
-- -   @NOTES@ - Additional text provided by the handshake initiator and
--     intended for the recipient to read.
newHandshakeResource ::
  HandshakeResource
newHandshakeResource :: HandshakeResource
newHandshakeResource =
  HandshakeResource' :: Maybe (Sensitive Text)
-> Maybe [HandshakeResource]
-> Maybe HandshakeResourceType
-> HandshakeResource
HandshakeResource'
    { $sel:value:HandshakeResource' :: Maybe (Sensitive Text)
value = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:resources:HandshakeResource' :: Maybe [HandshakeResource]
resources = Maybe [HandshakeResource]
forall a. Maybe a
Prelude.Nothing,
      $sel:type':HandshakeResource' :: Maybe HandshakeResourceType
type' = Maybe HandshakeResourceType
forall a. Maybe a
Prelude.Nothing
    }

-- | The information that is passed to the other party in the handshake. The
-- format of the value string must match the requirements of the specified
-- type.
handshakeResource_value :: Lens.Lens' HandshakeResource (Prelude.Maybe Prelude.Text)
handshakeResource_value :: (Maybe Text -> f (Maybe Text))
-> HandshakeResource -> f HandshakeResource
handshakeResource_value = (HandshakeResource -> Maybe (Sensitive Text))
-> (HandshakeResource
    -> Maybe (Sensitive Text) -> HandshakeResource)
-> Lens
     HandshakeResource
     HandshakeResource
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HandshakeResource' {Maybe (Sensitive Text)
value :: Maybe (Sensitive Text)
$sel:value:HandshakeResource' :: HandshakeResource -> Maybe (Sensitive Text)
value} -> Maybe (Sensitive Text)
value) (\s :: HandshakeResource
s@HandshakeResource' {} Maybe (Sensitive Text)
a -> HandshakeResource
s {$sel:value:HandshakeResource' :: Maybe (Sensitive Text)
value = Maybe (Sensitive Text)
a} :: HandshakeResource) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> HandshakeResource -> f HandshakeResource)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> HandshakeResource
-> f HandshakeResource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | When needed, contains an additional array of @HandshakeResource@
-- objects.
handshakeResource_resources :: Lens.Lens' HandshakeResource (Prelude.Maybe [HandshakeResource])
handshakeResource_resources :: (Maybe [HandshakeResource] -> f (Maybe [HandshakeResource]))
-> HandshakeResource -> f HandshakeResource
handshakeResource_resources = (HandshakeResource -> Maybe [HandshakeResource])
-> (HandshakeResource
    -> Maybe [HandshakeResource] -> HandshakeResource)
-> Lens
     HandshakeResource
     HandshakeResource
     (Maybe [HandshakeResource])
     (Maybe [HandshakeResource])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HandshakeResource' {Maybe [HandshakeResource]
resources :: Maybe [HandshakeResource]
$sel:resources:HandshakeResource' :: HandshakeResource -> Maybe [HandshakeResource]
resources} -> Maybe [HandshakeResource]
resources) (\s :: HandshakeResource
s@HandshakeResource' {} Maybe [HandshakeResource]
a -> HandshakeResource
s {$sel:resources:HandshakeResource' :: Maybe [HandshakeResource]
resources = Maybe [HandshakeResource]
a} :: HandshakeResource) ((Maybe [HandshakeResource] -> f (Maybe [HandshakeResource]))
 -> HandshakeResource -> f HandshakeResource)
-> ((Maybe [HandshakeResource] -> f (Maybe [HandshakeResource]))
    -> Maybe [HandshakeResource] -> f (Maybe [HandshakeResource]))
-> (Maybe [HandshakeResource] -> f (Maybe [HandshakeResource]))
-> HandshakeResource
-> f HandshakeResource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [HandshakeResource]
  [HandshakeResource]
  [HandshakeResource]
  [HandshakeResource]
-> Iso
     (Maybe [HandshakeResource])
     (Maybe [HandshakeResource])
     (Maybe [HandshakeResource])
     (Maybe [HandshakeResource])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [HandshakeResource]
  [HandshakeResource]
  [HandshakeResource]
  [HandshakeResource]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The type of information being passed, specifying how the value is to be
-- interpreted by the other party:
--
-- -   @ACCOUNT@ - Specifies an AWS account ID number.
--
-- -   @ORGANIZATION@ - Specifies an organization ID number.
--
-- -   @EMAIL@ - Specifies the email address that is associated with the
--     account that receives the handshake.
--
-- -   @OWNER_EMAIL@ - Specifies the email address associated with the
--     management account. Included as information about an organization.
--
-- -   @OWNER_NAME@ - Specifies the name associated with the management
--     account. Included as information about an organization.
--
-- -   @NOTES@ - Additional text provided by the handshake initiator and
--     intended for the recipient to read.
handshakeResource_type :: Lens.Lens' HandshakeResource (Prelude.Maybe HandshakeResourceType)
handshakeResource_type :: (Maybe HandshakeResourceType -> f (Maybe HandshakeResourceType))
-> HandshakeResource -> f HandshakeResource
handshakeResource_type = (HandshakeResource -> Maybe HandshakeResourceType)
-> (HandshakeResource
    -> Maybe HandshakeResourceType -> HandshakeResource)
-> Lens
     HandshakeResource
     HandshakeResource
     (Maybe HandshakeResourceType)
     (Maybe HandshakeResourceType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HandshakeResource' {Maybe HandshakeResourceType
type' :: Maybe HandshakeResourceType
$sel:type':HandshakeResource' :: HandshakeResource -> Maybe HandshakeResourceType
type'} -> Maybe HandshakeResourceType
type') (\s :: HandshakeResource
s@HandshakeResource' {} Maybe HandshakeResourceType
a -> HandshakeResource
s {$sel:type':HandshakeResource' :: Maybe HandshakeResourceType
type' = Maybe HandshakeResourceType
a} :: HandshakeResource)

instance Core.FromJSON HandshakeResource where
  parseJSON :: Value -> Parser HandshakeResource
parseJSON =
    String
-> (Object -> Parser HandshakeResource)
-> Value
-> Parser HandshakeResource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HandshakeResource"
      ( \Object
x ->
          Maybe (Sensitive Text)
-> Maybe [HandshakeResource]
-> Maybe HandshakeResourceType
-> HandshakeResource
HandshakeResource'
            (Maybe (Sensitive Text)
 -> Maybe [HandshakeResource]
 -> Maybe HandshakeResourceType
 -> HandshakeResource)
-> Parser (Maybe (Sensitive Text))
-> Parser
     (Maybe [HandshakeResource]
      -> Maybe HandshakeResourceType -> HandshakeResource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Value")
            Parser
  (Maybe [HandshakeResource]
   -> Maybe HandshakeResourceType -> HandshakeResource)
-> Parser (Maybe [HandshakeResource])
-> Parser (Maybe HandshakeResourceType -> HandshakeResource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [HandshakeResource]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Resources" Parser (Maybe (Maybe [HandshakeResource]))
-> Maybe [HandshakeResource] -> Parser (Maybe [HandshakeResource])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [HandshakeResource]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe HandshakeResourceType -> HandshakeResource)
-> Parser (Maybe HandshakeResourceType) -> Parser HandshakeResource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe HandshakeResourceType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
      )

instance Prelude.Hashable HandshakeResource

instance Prelude.NFData HandshakeResource