{-# 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.FinSpaceData.Types.Credentials
-- 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.FinSpaceData.Types.Credentials where

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

-- | Set short term API credentials.
--
-- /See:/ 'newCredentials' smart constructor.
data Credentials = Credentials'
  { -- | The access key.
    Credentials -> Maybe Text
secretAccessKey :: Prelude.Maybe Prelude.Text,
    -- | The session token.
    Credentials -> Maybe Text
sessionToken :: Prelude.Maybe Prelude.Text,
    -- | The access key identifier.
    Credentials -> Maybe Text
accessKeyId :: Prelude.Maybe Prelude.Text
  }
  deriving (Credentials -> Credentials -> Bool
(Credentials -> Credentials -> Bool)
-> (Credentials -> Credentials -> Bool) -> Eq Credentials
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Credentials -> Credentials -> Bool
$c/= :: Credentials -> Credentials -> Bool
== :: Credentials -> Credentials -> Bool
$c== :: Credentials -> Credentials -> Bool
Prelude.Eq, ReadPrec [Credentials]
ReadPrec Credentials
Int -> ReadS Credentials
ReadS [Credentials]
(Int -> ReadS Credentials)
-> ReadS [Credentials]
-> ReadPrec Credentials
-> ReadPrec [Credentials]
-> Read Credentials
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Credentials]
$creadListPrec :: ReadPrec [Credentials]
readPrec :: ReadPrec Credentials
$creadPrec :: ReadPrec Credentials
readList :: ReadS [Credentials]
$creadList :: ReadS [Credentials]
readsPrec :: Int -> ReadS Credentials
$creadsPrec :: Int -> ReadS Credentials
Prelude.Read, Int -> Credentials -> ShowS
[Credentials] -> ShowS
Credentials -> String
(Int -> Credentials -> ShowS)
-> (Credentials -> String)
-> ([Credentials] -> ShowS)
-> Show Credentials
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Credentials] -> ShowS
$cshowList :: [Credentials] -> ShowS
show :: Credentials -> String
$cshow :: Credentials -> String
showsPrec :: Int -> Credentials -> ShowS
$cshowsPrec :: Int -> Credentials -> ShowS
Prelude.Show, (forall x. Credentials -> Rep Credentials x)
-> (forall x. Rep Credentials x -> Credentials)
-> Generic Credentials
forall x. Rep Credentials x -> Credentials
forall x. Credentials -> Rep Credentials x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Credentials x -> Credentials
$cfrom :: forall x. Credentials -> Rep Credentials x
Prelude.Generic)

-- |
-- Create a value of 'Credentials' 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:
--
-- 'secretAccessKey', 'credentials_secretAccessKey' - The access key.
--
-- 'sessionToken', 'credentials_sessionToken' - The session token.
--
-- 'accessKeyId', 'credentials_accessKeyId' - The access key identifier.
newCredentials ::
  Credentials
newCredentials :: Credentials
newCredentials =
  Credentials' :: Maybe Text -> Maybe Text -> Maybe Text -> Credentials
Credentials'
    { $sel:secretAccessKey:Credentials' :: Maybe Text
secretAccessKey = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sessionToken:Credentials' :: Maybe Text
sessionToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:accessKeyId:Credentials' :: Maybe Text
accessKeyId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The access key.
credentials_secretAccessKey :: Lens.Lens' Credentials (Prelude.Maybe Prelude.Text)
credentials_secretAccessKey :: (Maybe Text -> f (Maybe Text)) -> Credentials -> f Credentials
credentials_secretAccessKey = (Credentials -> Maybe Text)
-> (Credentials -> Maybe Text -> Credentials)
-> Lens Credentials Credentials (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Credentials' {Maybe Text
secretAccessKey :: Maybe Text
$sel:secretAccessKey:Credentials' :: Credentials -> Maybe Text
secretAccessKey} -> Maybe Text
secretAccessKey) (\s :: Credentials
s@Credentials' {} Maybe Text
a -> Credentials
s {$sel:secretAccessKey:Credentials' :: Maybe Text
secretAccessKey = Maybe Text
a} :: Credentials)

-- | The session token.
credentials_sessionToken :: Lens.Lens' Credentials (Prelude.Maybe Prelude.Text)
credentials_sessionToken :: (Maybe Text -> f (Maybe Text)) -> Credentials -> f Credentials
credentials_sessionToken = (Credentials -> Maybe Text)
-> (Credentials -> Maybe Text -> Credentials)
-> Lens Credentials Credentials (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Credentials' {Maybe Text
sessionToken :: Maybe Text
$sel:sessionToken:Credentials' :: Credentials -> Maybe Text
sessionToken} -> Maybe Text
sessionToken) (\s :: Credentials
s@Credentials' {} Maybe Text
a -> Credentials
s {$sel:sessionToken:Credentials' :: Maybe Text
sessionToken = Maybe Text
a} :: Credentials)

-- | The access key identifier.
credentials_accessKeyId :: Lens.Lens' Credentials (Prelude.Maybe Prelude.Text)
credentials_accessKeyId :: (Maybe Text -> f (Maybe Text)) -> Credentials -> f Credentials
credentials_accessKeyId = (Credentials -> Maybe Text)
-> (Credentials -> Maybe Text -> Credentials)
-> Lens Credentials Credentials (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Credentials' {Maybe Text
accessKeyId :: Maybe Text
$sel:accessKeyId:Credentials' :: Credentials -> Maybe Text
accessKeyId} -> Maybe Text
accessKeyId) (\s :: Credentials
s@Credentials' {} Maybe Text
a -> Credentials
s {$sel:accessKeyId:Credentials' :: Maybe Text
accessKeyId = Maybe Text
a} :: Credentials)

instance Core.FromJSON Credentials where
  parseJSON :: Value -> Parser Credentials
parseJSON =
    String
-> (Object -> Parser Credentials) -> Value -> Parser Credentials
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Credentials"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> Credentials
Credentials'
            (Maybe Text -> Maybe Text -> Maybe Text -> Credentials)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Credentials)
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
"secretAccessKey")
            Parser (Maybe Text -> Maybe Text -> Credentials)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Credentials)
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
"sessionToken")
            Parser (Maybe Text -> Credentials)
-> Parser (Maybe Text) -> Parser Credentials
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
"accessKeyId")
      )

instance Prelude.Hashable Credentials

instance Prelude.NFData Credentials