{-# 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.ConnectParticipant.Types.ConnectionCredentials
-- 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.ConnectParticipant.Types.ConnectionCredentials where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Connection credentials.
--
-- /See:/ 'newConnectionCredentials' smart constructor.
data ConnectionCredentials = ConnectionCredentials'
  { -- | The connection token.
    ConnectionCredentials -> Maybe Text
connectionToken :: Prelude.Maybe Prelude.Text,
    -- | The expiration of the token.
    --
    -- It\'s specified in ISO 8601 format: yyyy-MM-ddThh:mm:ss.SSSZ. For
    -- example, 2019-11-08T02:41:28.172Z.
    ConnectionCredentials -> Maybe Text
expiry :: Prelude.Maybe Prelude.Text
  }
  deriving (ConnectionCredentials -> ConnectionCredentials -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConnectionCredentials -> ConnectionCredentials -> Bool
$c/= :: ConnectionCredentials -> ConnectionCredentials -> Bool
== :: ConnectionCredentials -> ConnectionCredentials -> Bool
$c== :: ConnectionCredentials -> ConnectionCredentials -> Bool
Prelude.Eq, ReadPrec [ConnectionCredentials]
ReadPrec ConnectionCredentials
Int -> ReadS ConnectionCredentials
ReadS [ConnectionCredentials]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConnectionCredentials]
$creadListPrec :: ReadPrec [ConnectionCredentials]
readPrec :: ReadPrec ConnectionCredentials
$creadPrec :: ReadPrec ConnectionCredentials
readList :: ReadS [ConnectionCredentials]
$creadList :: ReadS [ConnectionCredentials]
readsPrec :: Int -> ReadS ConnectionCredentials
$creadsPrec :: Int -> ReadS ConnectionCredentials
Prelude.Read, Int -> ConnectionCredentials -> ShowS
[ConnectionCredentials] -> ShowS
ConnectionCredentials -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConnectionCredentials] -> ShowS
$cshowList :: [ConnectionCredentials] -> ShowS
show :: ConnectionCredentials -> String
$cshow :: ConnectionCredentials -> String
showsPrec :: Int -> ConnectionCredentials -> ShowS
$cshowsPrec :: Int -> ConnectionCredentials -> ShowS
Prelude.Show, forall x. Rep ConnectionCredentials x -> ConnectionCredentials
forall x. ConnectionCredentials -> Rep ConnectionCredentials x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConnectionCredentials x -> ConnectionCredentials
$cfrom :: forall x. ConnectionCredentials -> Rep ConnectionCredentials x
Prelude.Generic)

-- |
-- Create a value of 'ConnectionCredentials' 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:
--
-- 'connectionToken', 'connectionCredentials_connectionToken' - The connection token.
--
-- 'expiry', 'connectionCredentials_expiry' - The expiration of the token.
--
-- It\'s specified in ISO 8601 format: yyyy-MM-ddThh:mm:ss.SSSZ. For
-- example, 2019-11-08T02:41:28.172Z.
newConnectionCredentials ::
  ConnectionCredentials
newConnectionCredentials :: ConnectionCredentials
newConnectionCredentials =
  ConnectionCredentials'
    { $sel:connectionToken:ConnectionCredentials' :: Maybe Text
connectionToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:expiry:ConnectionCredentials' :: Maybe Text
expiry = forall a. Maybe a
Prelude.Nothing
    }

-- | The connection token.
connectionCredentials_connectionToken :: Lens.Lens' ConnectionCredentials (Prelude.Maybe Prelude.Text)
connectionCredentials_connectionToken :: Lens' ConnectionCredentials (Maybe Text)
connectionCredentials_connectionToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectionCredentials' {Maybe Text
connectionToken :: Maybe Text
$sel:connectionToken:ConnectionCredentials' :: ConnectionCredentials -> Maybe Text
connectionToken} -> Maybe Text
connectionToken) (\s :: ConnectionCredentials
s@ConnectionCredentials' {} Maybe Text
a -> ConnectionCredentials
s {$sel:connectionToken:ConnectionCredentials' :: Maybe Text
connectionToken = Maybe Text
a} :: ConnectionCredentials)

-- | The expiration of the token.
--
-- It\'s specified in ISO 8601 format: yyyy-MM-ddThh:mm:ss.SSSZ. For
-- example, 2019-11-08T02:41:28.172Z.
connectionCredentials_expiry :: Lens.Lens' ConnectionCredentials (Prelude.Maybe Prelude.Text)
connectionCredentials_expiry :: Lens' ConnectionCredentials (Maybe Text)
connectionCredentials_expiry = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectionCredentials' {Maybe Text
expiry :: Maybe Text
$sel:expiry:ConnectionCredentials' :: ConnectionCredentials -> Maybe Text
expiry} -> Maybe Text
expiry) (\s :: ConnectionCredentials
s@ConnectionCredentials' {} Maybe Text
a -> ConnectionCredentials
s {$sel:expiry:ConnectionCredentials' :: Maybe Text
expiry = Maybe Text
a} :: ConnectionCredentials)

instance Data.FromJSON ConnectionCredentials where
  parseJSON :: Value -> Parser ConnectionCredentials
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ConnectionCredentials"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> ConnectionCredentials
ConnectionCredentials'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ConnectionToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Expiry")
      )

instance Prelude.Hashable ConnectionCredentials where
  hashWithSalt :: Int -> ConnectionCredentials -> Int
hashWithSalt Int
_salt ConnectionCredentials' {Maybe Text
expiry :: Maybe Text
connectionToken :: Maybe Text
$sel:expiry:ConnectionCredentials' :: ConnectionCredentials -> Maybe Text
$sel:connectionToken:ConnectionCredentials' :: ConnectionCredentials -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
connectionToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
expiry

instance Prelude.NFData ConnectionCredentials where
  rnf :: ConnectionCredentials -> ()
rnf ConnectionCredentials' {Maybe Text
expiry :: Maybe Text
connectionToken :: Maybe Text
$sel:expiry:ConnectionCredentials' :: ConnectionCredentials -> Maybe Text
$sel:connectionToken:ConnectionCredentials' :: ConnectionCredentials -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
connectionToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
expiry