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

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

-- | Connection credentials.
--
-- /See:/ 'newConnectionCredentials' smart constructor.
data ConnectionCredentials = 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 -> Maybe Text
expiry :: Prelude.Maybe Prelude.Text,
    -- | The connection token.
    ConnectionCredentials -> Maybe Text
connectionToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ConnectionCredentials -> ConnectionCredentials -> Bool
(ConnectionCredentials -> ConnectionCredentials -> Bool)
-> (ConnectionCredentials -> ConnectionCredentials -> Bool)
-> Eq ConnectionCredentials
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]
(Int -> ReadS ConnectionCredentials)
-> ReadS [ConnectionCredentials]
-> ReadPrec ConnectionCredentials
-> ReadPrec [ConnectionCredentials]
-> Read 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
(Int -> ConnectionCredentials -> ShowS)
-> (ConnectionCredentials -> String)
-> ([ConnectionCredentials] -> ShowS)
-> Show ConnectionCredentials
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. ConnectionCredentials -> Rep ConnectionCredentials x)
-> (forall x. Rep ConnectionCredentials x -> ConnectionCredentials)
-> Generic ConnectionCredentials
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:
--
-- '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.
--
-- 'connectionToken', 'connectionCredentials_connectionToken' - The connection token.
newConnectionCredentials ::
  ConnectionCredentials
newConnectionCredentials :: ConnectionCredentials
newConnectionCredentials =
  ConnectionCredentials' :: Maybe Text -> Maybe Text -> ConnectionCredentials
ConnectionCredentials'
    { $sel:expiry:ConnectionCredentials' :: Maybe Text
expiry = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:connectionToken:ConnectionCredentials' :: Maybe Text
connectionToken = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> ConnectionCredentials -> f ConnectionCredentials
connectionCredentials_expiry = (ConnectionCredentials -> Maybe Text)
-> (ConnectionCredentials -> Maybe Text -> ConnectionCredentials)
-> Lens
     ConnectionCredentials
     ConnectionCredentials
     (Maybe Text)
     (Maybe Text)
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)

-- | The connection token.
connectionCredentials_connectionToken :: Lens.Lens' ConnectionCredentials (Prelude.Maybe Prelude.Text)
connectionCredentials_connectionToken :: (Maybe Text -> f (Maybe Text))
-> ConnectionCredentials -> f ConnectionCredentials
connectionCredentials_connectionToken = (ConnectionCredentials -> Maybe Text)
-> (ConnectionCredentials -> Maybe Text -> ConnectionCredentials)
-> Lens
     ConnectionCredentials
     ConnectionCredentials
     (Maybe Text)
     (Maybe Text)
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)

instance Core.FromJSON ConnectionCredentials where
  parseJSON :: Value -> Parser ConnectionCredentials
parseJSON =
    String
-> (Object -> Parser ConnectionCredentials)
-> Value
-> Parser ConnectionCredentials
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ConnectionCredentials"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> ConnectionCredentials
ConnectionCredentials'
            (Maybe Text -> Maybe Text -> ConnectionCredentials)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> ConnectionCredentials)
forall (f :: * -> *) a b. Functor 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
"Expiry")
            Parser (Maybe Text -> ConnectionCredentials)
-> Parser (Maybe Text) -> Parser ConnectionCredentials
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
"ConnectionToken")
      )

instance Prelude.Hashable ConnectionCredentials

instance Prelude.NFData ConnectionCredentials