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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Organizations.Types.ActionType
import Amazonka.Organizations.Types.HandshakeParty
import Amazonka.Organizations.Types.HandshakeResource
import Amazonka.Organizations.Types.HandshakeState
import qualified Amazonka.Prelude as Prelude

-- | Contains information that must be exchanged to securely establish a
-- relationship between two accounts (an /originator/ and a /recipient/).
-- For example, when a management account (the originator) invites another
-- account (the recipient) to join its organization, the two accounts
-- exchange information as a series of handshake requests and responses.
--
-- __Note:__ Handshakes that are @CANCELED@, @ACCEPTED@, or @DECLINED@ show
-- up in lists for only 30 days after entering that state After that they
-- are deleted.
--
-- /See:/ 'newHandshake' smart constructor.
data Handshake = Handshake'
  { -- | The current state of the handshake. Use the state to trace the flow of
    -- the handshake through the process from its creation to its acceptance.
    -- The meaning of each of the valid values is as follows:
    --
    -- -   __REQUESTED__: This handshake was sent to multiple recipients
    --     (applicable to only some handshake types) and not all recipients
    --     have responded yet. The request stays in this state until all
    --     recipients respond.
    --
    -- -   __OPEN__: This handshake was sent to multiple recipients (applicable
    --     to only some policy types) and all recipients have responded,
    --     allowing the originator to complete the handshake action.
    --
    -- -   __CANCELED__: This handshake is no longer active because it was
    --     canceled by the originating account.
    --
    -- -   __ACCEPTED__: This handshake is complete because it has been
    --     accepted by the recipient.
    --
    -- -   __DECLINED__: This handshake is no longer active because it was
    --     declined by the recipient account.
    --
    -- -   __EXPIRED__: This handshake is no longer active because the
    --     originator did not receive a response of any kind from the recipient
    --     before the expiration time (15 days).
    Handshake -> Maybe HandshakeState
state :: Prelude.Maybe HandshakeState,
    -- | The Amazon Resource Name (ARN) of a handshake.
    --
    -- For more information about ARNs in Organizations, see
    -- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsorganizations.html#awsorganizations-resources-for-iam-policies ARN Formats Supported by Organizations>
    -- in the /AWS Service Authorization Reference/.
    Handshake -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The type of handshake, indicating what action occurs when the recipient
    -- accepts the handshake. The following handshake types are supported:
    --
    -- -   __INVITE__: This type of handshake represents a request to join an
    --     organization. It is always sent from the management account to only
    --     non-member accounts.
    --
    -- -   __ENABLE_ALL_FEATURES__: This type of handshake represents a request
    --     to enable all features in an organization. It is always sent from
    --     the management account to only /invited/ member accounts. Created
    --     accounts do not receive this because those accounts were created by
    --     the organization\'s management account and approval is inferred.
    --
    -- -   __APPROVE_ALL_FEATURES__: This type of handshake is sent from the
    --     Organizations service when all member accounts have approved the
    --     @ENABLE_ALL_FEATURES@ invitation. It is sent only to the management
    --     account and signals the master that it can finalize the process to
    --     enable all features.
    Handshake -> Maybe ActionType
action :: Prelude.Maybe ActionType,
    -- | Additional information that is needed to process the handshake.
    Handshake -> Maybe [HandshakeResource]
resources :: Prelude.Maybe [HandshakeResource],
    -- | The unique identifier (ID) of a handshake. The originating account
    -- creates the ID when it initiates the handshake.
    --
    -- The <http://wikipedia.org/wiki/regex regex pattern> for handshake ID
    -- string requires \"h-\" followed by from 8 to 32 lowercase letters or
    -- digits.
    Handshake -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The date and time that the handshake expires. If the recipient of the
    -- handshake request fails to respond before the specified date and time,
    -- the handshake becomes inactive and is no longer valid.
    Handshake -> Maybe POSIX
expirationTimestamp :: Prelude.Maybe Core.POSIX,
    -- | Information about the two accounts that are participating in the
    -- handshake.
    Handshake -> Maybe [HandshakeParty]
parties :: Prelude.Maybe [HandshakeParty],
    -- | The date and time that the handshake request was made.
    Handshake -> Maybe POSIX
requestedTimestamp :: Prelude.Maybe Core.POSIX
  }
  deriving (Handshake -> Handshake -> Bool
(Handshake -> Handshake -> Bool)
-> (Handshake -> Handshake -> Bool) -> Eq Handshake
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Handshake -> Handshake -> Bool
$c/= :: Handshake -> Handshake -> Bool
== :: Handshake -> Handshake -> Bool
$c== :: Handshake -> Handshake -> Bool
Prelude.Eq, Int -> Handshake -> ShowS
[Handshake] -> ShowS
Handshake -> String
(Int -> Handshake -> ShowS)
-> (Handshake -> String)
-> ([Handshake] -> ShowS)
-> Show Handshake
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Handshake] -> ShowS
$cshowList :: [Handshake] -> ShowS
show :: Handshake -> String
$cshow :: Handshake -> String
showsPrec :: Int -> Handshake -> ShowS
$cshowsPrec :: Int -> Handshake -> ShowS
Prelude.Show, (forall x. Handshake -> Rep Handshake x)
-> (forall x. Rep Handshake x -> Handshake) -> Generic Handshake
forall x. Rep Handshake x -> Handshake
forall x. Handshake -> Rep Handshake x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Handshake x -> Handshake
$cfrom :: forall x. Handshake -> Rep Handshake x
Prelude.Generic)

-- |
-- Create a value of 'Handshake' 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:
--
-- 'state', 'handshake_state' - The current state of the handshake. Use the state to trace the flow of
-- the handshake through the process from its creation to its acceptance.
-- The meaning of each of the valid values is as follows:
--
-- -   __REQUESTED__: This handshake was sent to multiple recipients
--     (applicable to only some handshake types) and not all recipients
--     have responded yet. The request stays in this state until all
--     recipients respond.
--
-- -   __OPEN__: This handshake was sent to multiple recipients (applicable
--     to only some policy types) and all recipients have responded,
--     allowing the originator to complete the handshake action.
--
-- -   __CANCELED__: This handshake is no longer active because it was
--     canceled by the originating account.
--
-- -   __ACCEPTED__: This handshake is complete because it has been
--     accepted by the recipient.
--
-- -   __DECLINED__: This handshake is no longer active because it was
--     declined by the recipient account.
--
-- -   __EXPIRED__: This handshake is no longer active because the
--     originator did not receive a response of any kind from the recipient
--     before the expiration time (15 days).
--
-- 'arn', 'handshake_arn' - The Amazon Resource Name (ARN) of a handshake.
--
-- For more information about ARNs in Organizations, see
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsorganizations.html#awsorganizations-resources-for-iam-policies ARN Formats Supported by Organizations>
-- in the /AWS Service Authorization Reference/.
--
-- 'action', 'handshake_action' - The type of handshake, indicating what action occurs when the recipient
-- accepts the handshake. The following handshake types are supported:
--
-- -   __INVITE__: This type of handshake represents a request to join an
--     organization. It is always sent from the management account to only
--     non-member accounts.
--
-- -   __ENABLE_ALL_FEATURES__: This type of handshake represents a request
--     to enable all features in an organization. It is always sent from
--     the management account to only /invited/ member accounts. Created
--     accounts do not receive this because those accounts were created by
--     the organization\'s management account and approval is inferred.
--
-- -   __APPROVE_ALL_FEATURES__: This type of handshake is sent from the
--     Organizations service when all member accounts have approved the
--     @ENABLE_ALL_FEATURES@ invitation. It is sent only to the management
--     account and signals the master that it can finalize the process to
--     enable all features.
--
-- 'resources', 'handshake_resources' - Additional information that is needed to process the handshake.
--
-- 'id', 'handshake_id' - The unique identifier (ID) of a handshake. The originating account
-- creates the ID when it initiates the handshake.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for handshake ID
-- string requires \"h-\" followed by from 8 to 32 lowercase letters or
-- digits.
--
-- 'expirationTimestamp', 'handshake_expirationTimestamp' - The date and time that the handshake expires. If the recipient of the
-- handshake request fails to respond before the specified date and time,
-- the handshake becomes inactive and is no longer valid.
--
-- 'parties', 'handshake_parties' - Information about the two accounts that are participating in the
-- handshake.
--
-- 'requestedTimestamp', 'handshake_requestedTimestamp' - The date and time that the handshake request was made.
newHandshake ::
  Handshake
newHandshake :: Handshake
newHandshake =
  Handshake' :: Maybe HandshakeState
-> Maybe Text
-> Maybe ActionType
-> Maybe [HandshakeResource]
-> Maybe Text
-> Maybe POSIX
-> Maybe [HandshakeParty]
-> Maybe POSIX
-> Handshake
Handshake'
    { $sel:state:Handshake' :: Maybe HandshakeState
state = Maybe HandshakeState
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:Handshake' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:action:Handshake' :: Maybe ActionType
action = Maybe ActionType
forall a. Maybe a
Prelude.Nothing,
      $sel:resources:Handshake' :: Maybe [HandshakeResource]
resources = Maybe [HandshakeResource]
forall a. Maybe a
Prelude.Nothing,
      $sel:id:Handshake' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:expirationTimestamp:Handshake' :: Maybe POSIX
expirationTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:parties:Handshake' :: Maybe [HandshakeParty]
parties = Maybe [HandshakeParty]
forall a. Maybe a
Prelude.Nothing,
      $sel:requestedTimestamp:Handshake' :: Maybe POSIX
requestedTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The current state of the handshake. Use the state to trace the flow of
-- the handshake through the process from its creation to its acceptance.
-- The meaning of each of the valid values is as follows:
--
-- -   __REQUESTED__: This handshake was sent to multiple recipients
--     (applicable to only some handshake types) and not all recipients
--     have responded yet. The request stays in this state until all
--     recipients respond.
--
-- -   __OPEN__: This handshake was sent to multiple recipients (applicable
--     to only some policy types) and all recipients have responded,
--     allowing the originator to complete the handshake action.
--
-- -   __CANCELED__: This handshake is no longer active because it was
--     canceled by the originating account.
--
-- -   __ACCEPTED__: This handshake is complete because it has been
--     accepted by the recipient.
--
-- -   __DECLINED__: This handshake is no longer active because it was
--     declined by the recipient account.
--
-- -   __EXPIRED__: This handshake is no longer active because the
--     originator did not receive a response of any kind from the recipient
--     before the expiration time (15 days).
handshake_state :: Lens.Lens' Handshake (Prelude.Maybe HandshakeState)
handshake_state :: (Maybe HandshakeState -> f (Maybe HandshakeState))
-> Handshake -> f Handshake
handshake_state = (Handshake -> Maybe HandshakeState)
-> (Handshake -> Maybe HandshakeState -> Handshake)
-> Lens
     Handshake Handshake (Maybe HandshakeState) (Maybe HandshakeState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Handshake' {Maybe HandshakeState
state :: Maybe HandshakeState
$sel:state:Handshake' :: Handshake -> Maybe HandshakeState
state} -> Maybe HandshakeState
state) (\s :: Handshake
s@Handshake' {} Maybe HandshakeState
a -> Handshake
s {$sel:state:Handshake' :: Maybe HandshakeState
state = Maybe HandshakeState
a} :: Handshake)

-- | The Amazon Resource Name (ARN) of a handshake.
--
-- For more information about ARNs in Organizations, see
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsorganizations.html#awsorganizations-resources-for-iam-policies ARN Formats Supported by Organizations>
-- in the /AWS Service Authorization Reference/.
handshake_arn :: Lens.Lens' Handshake (Prelude.Maybe Prelude.Text)
handshake_arn :: (Maybe Text -> f (Maybe Text)) -> Handshake -> f Handshake
handshake_arn = (Handshake -> Maybe Text)
-> (Handshake -> Maybe Text -> Handshake)
-> Lens Handshake Handshake (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Handshake' {Maybe Text
arn :: Maybe Text
$sel:arn:Handshake' :: Handshake -> Maybe Text
arn} -> Maybe Text
arn) (\s :: Handshake
s@Handshake' {} Maybe Text
a -> Handshake
s {$sel:arn:Handshake' :: Maybe Text
arn = Maybe Text
a} :: Handshake)

-- | The type of handshake, indicating what action occurs when the recipient
-- accepts the handshake. The following handshake types are supported:
--
-- -   __INVITE__: This type of handshake represents a request to join an
--     organization. It is always sent from the management account to only
--     non-member accounts.
--
-- -   __ENABLE_ALL_FEATURES__: This type of handshake represents a request
--     to enable all features in an organization. It is always sent from
--     the management account to only /invited/ member accounts. Created
--     accounts do not receive this because those accounts were created by
--     the organization\'s management account and approval is inferred.
--
-- -   __APPROVE_ALL_FEATURES__: This type of handshake is sent from the
--     Organizations service when all member accounts have approved the
--     @ENABLE_ALL_FEATURES@ invitation. It is sent only to the management
--     account and signals the master that it can finalize the process to
--     enable all features.
handshake_action :: Lens.Lens' Handshake (Prelude.Maybe ActionType)
handshake_action :: (Maybe ActionType -> f (Maybe ActionType))
-> Handshake -> f Handshake
handshake_action = (Handshake -> Maybe ActionType)
-> (Handshake -> Maybe ActionType -> Handshake)
-> Lens Handshake Handshake (Maybe ActionType) (Maybe ActionType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Handshake' {Maybe ActionType
action :: Maybe ActionType
$sel:action:Handshake' :: Handshake -> Maybe ActionType
action} -> Maybe ActionType
action) (\s :: Handshake
s@Handshake' {} Maybe ActionType
a -> Handshake
s {$sel:action:Handshake' :: Maybe ActionType
action = Maybe ActionType
a} :: Handshake)

-- | Additional information that is needed to process the handshake.
handshake_resources :: Lens.Lens' Handshake (Prelude.Maybe [HandshakeResource])
handshake_resources :: (Maybe [HandshakeResource] -> f (Maybe [HandshakeResource]))
-> Handshake -> f Handshake
handshake_resources = (Handshake -> Maybe [HandshakeResource])
-> (Handshake -> Maybe [HandshakeResource] -> Handshake)
-> Lens
     Handshake
     Handshake
     (Maybe [HandshakeResource])
     (Maybe [HandshakeResource])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Handshake' {Maybe [HandshakeResource]
resources :: Maybe [HandshakeResource]
$sel:resources:Handshake' :: Handshake -> Maybe [HandshakeResource]
resources} -> Maybe [HandshakeResource]
resources) (\s :: Handshake
s@Handshake' {} Maybe [HandshakeResource]
a -> Handshake
s {$sel:resources:Handshake' :: Maybe [HandshakeResource]
resources = Maybe [HandshakeResource]
a} :: Handshake) ((Maybe [HandshakeResource] -> f (Maybe [HandshakeResource]))
 -> Handshake -> f Handshake)
-> ((Maybe [HandshakeResource] -> f (Maybe [HandshakeResource]))
    -> Maybe [HandshakeResource] -> f (Maybe [HandshakeResource]))
-> (Maybe [HandshakeResource] -> f (Maybe [HandshakeResource]))
-> Handshake
-> f Handshake
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 unique identifier (ID) of a handshake. The originating account
-- creates the ID when it initiates the handshake.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for handshake ID
-- string requires \"h-\" followed by from 8 to 32 lowercase letters or
-- digits.
handshake_id :: Lens.Lens' Handshake (Prelude.Maybe Prelude.Text)
handshake_id :: (Maybe Text -> f (Maybe Text)) -> Handshake -> f Handshake
handshake_id = (Handshake -> Maybe Text)
-> (Handshake -> Maybe Text -> Handshake)
-> Lens Handshake Handshake (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Handshake' {Maybe Text
id :: Maybe Text
$sel:id:Handshake' :: Handshake -> Maybe Text
id} -> Maybe Text
id) (\s :: Handshake
s@Handshake' {} Maybe Text
a -> Handshake
s {$sel:id:Handshake' :: Maybe Text
id = Maybe Text
a} :: Handshake)

-- | The date and time that the handshake expires. If the recipient of the
-- handshake request fails to respond before the specified date and time,
-- the handshake becomes inactive and is no longer valid.
handshake_expirationTimestamp :: Lens.Lens' Handshake (Prelude.Maybe Prelude.UTCTime)
handshake_expirationTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Handshake -> f Handshake
handshake_expirationTimestamp = (Handshake -> Maybe POSIX)
-> (Handshake -> Maybe POSIX -> Handshake)
-> Lens Handshake Handshake (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Handshake' {Maybe POSIX
expirationTimestamp :: Maybe POSIX
$sel:expirationTimestamp:Handshake' :: Handshake -> Maybe POSIX
expirationTimestamp} -> Maybe POSIX
expirationTimestamp) (\s :: Handshake
s@Handshake' {} Maybe POSIX
a -> Handshake
s {$sel:expirationTimestamp:Handshake' :: Maybe POSIX
expirationTimestamp = Maybe POSIX
a} :: Handshake) ((Maybe POSIX -> f (Maybe POSIX)) -> Handshake -> f Handshake)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Handshake
-> f Handshake
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | Information about the two accounts that are participating in the
-- handshake.
handshake_parties :: Lens.Lens' Handshake (Prelude.Maybe [HandshakeParty])
handshake_parties :: (Maybe [HandshakeParty] -> f (Maybe [HandshakeParty]))
-> Handshake -> f Handshake
handshake_parties = (Handshake -> Maybe [HandshakeParty])
-> (Handshake -> Maybe [HandshakeParty] -> Handshake)
-> Lens
     Handshake
     Handshake
     (Maybe [HandshakeParty])
     (Maybe [HandshakeParty])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Handshake' {Maybe [HandshakeParty]
parties :: Maybe [HandshakeParty]
$sel:parties:Handshake' :: Handshake -> Maybe [HandshakeParty]
parties} -> Maybe [HandshakeParty]
parties) (\s :: Handshake
s@Handshake' {} Maybe [HandshakeParty]
a -> Handshake
s {$sel:parties:Handshake' :: Maybe [HandshakeParty]
parties = Maybe [HandshakeParty]
a} :: Handshake) ((Maybe [HandshakeParty] -> f (Maybe [HandshakeParty]))
 -> Handshake -> f Handshake)
-> ((Maybe [HandshakeParty] -> f (Maybe [HandshakeParty]))
    -> Maybe [HandshakeParty] -> f (Maybe [HandshakeParty]))
-> (Maybe [HandshakeParty] -> f (Maybe [HandshakeParty]))
-> Handshake
-> f Handshake
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [HandshakeParty] [HandshakeParty] [HandshakeParty] [HandshakeParty]
-> Iso
     (Maybe [HandshakeParty])
     (Maybe [HandshakeParty])
     (Maybe [HandshakeParty])
     (Maybe [HandshakeParty])
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
  [HandshakeParty] [HandshakeParty] [HandshakeParty] [HandshakeParty]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The date and time that the handshake request was made.
handshake_requestedTimestamp :: Lens.Lens' Handshake (Prelude.Maybe Prelude.UTCTime)
handshake_requestedTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Handshake -> f Handshake
handshake_requestedTimestamp = (Handshake -> Maybe POSIX)
-> (Handshake -> Maybe POSIX -> Handshake)
-> Lens Handshake Handshake (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Handshake' {Maybe POSIX
requestedTimestamp :: Maybe POSIX
$sel:requestedTimestamp:Handshake' :: Handshake -> Maybe POSIX
requestedTimestamp} -> Maybe POSIX
requestedTimestamp) (\s :: Handshake
s@Handshake' {} Maybe POSIX
a -> Handshake
s {$sel:requestedTimestamp:Handshake' :: Maybe POSIX
requestedTimestamp = Maybe POSIX
a} :: Handshake) ((Maybe POSIX -> f (Maybe POSIX)) -> Handshake -> f Handshake)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Handshake
-> f Handshake
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON Handshake where
  parseJSON :: Value -> Parser Handshake
parseJSON =
    String -> (Object -> Parser Handshake) -> Value -> Parser Handshake
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Handshake"
      ( \Object
x ->
          Maybe HandshakeState
-> Maybe Text
-> Maybe ActionType
-> Maybe [HandshakeResource]
-> Maybe Text
-> Maybe POSIX
-> Maybe [HandshakeParty]
-> Maybe POSIX
-> Handshake
Handshake'
            (Maybe HandshakeState
 -> Maybe Text
 -> Maybe ActionType
 -> Maybe [HandshakeResource]
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe [HandshakeParty]
 -> Maybe POSIX
 -> Handshake)
-> Parser (Maybe HandshakeState)
-> Parser
     (Maybe Text
      -> Maybe ActionType
      -> Maybe [HandshakeResource]
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe [HandshakeParty]
      -> Maybe POSIX
      -> Handshake)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe HandshakeState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"State")
            Parser
  (Maybe Text
   -> Maybe ActionType
   -> Maybe [HandshakeResource]
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe [HandshakeParty]
   -> Maybe POSIX
   -> Handshake)
-> Parser (Maybe Text)
-> Parser
     (Maybe ActionType
      -> Maybe [HandshakeResource]
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe [HandshakeParty]
      -> Maybe POSIX
      -> Handshake)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Arn")
            Parser
  (Maybe ActionType
   -> Maybe [HandshakeResource]
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe [HandshakeParty]
   -> Maybe POSIX
   -> Handshake)
-> Parser (Maybe ActionType)
-> Parser
     (Maybe [HandshakeResource]
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe [HandshakeParty]
      -> Maybe POSIX
      -> Handshake)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ActionType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Action")
            Parser
  (Maybe [HandshakeResource]
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe [HandshakeParty]
   -> Maybe POSIX
   -> Handshake)
-> Parser (Maybe [HandshakeResource])
-> Parser
     (Maybe Text
      -> Maybe POSIX
      -> Maybe [HandshakeParty]
      -> Maybe POSIX
      -> Handshake)
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 Text
   -> Maybe POSIX
   -> Maybe [HandshakeParty]
   -> Maybe POSIX
   -> Handshake)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX -> Maybe [HandshakeParty] -> Maybe POSIX -> Handshake)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Id")
            Parser
  (Maybe POSIX -> Maybe [HandshakeParty] -> Maybe POSIX -> Handshake)
-> Parser (Maybe POSIX)
-> Parser (Maybe [HandshakeParty] -> Maybe POSIX -> Handshake)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ExpirationTimestamp")
            Parser (Maybe [HandshakeParty] -> Maybe POSIX -> Handshake)
-> Parser (Maybe [HandshakeParty])
-> Parser (Maybe POSIX -> Handshake)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [HandshakeParty]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Parties" Parser (Maybe (Maybe [HandshakeParty]))
-> Maybe [HandshakeParty] -> Parser (Maybe [HandshakeParty])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [HandshakeParty]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe POSIX -> Handshake)
-> Parser (Maybe POSIX) -> Parser Handshake
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RequestedTimestamp")
      )

instance Prelude.Hashable Handshake

instance Prelude.NFData Handshake