{-# 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.SSO.Types.RoleCredentials
-- 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.SSO.Types.RoleCredentials where

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

-- | Provides information about the role credentials that are assigned to the
-- user.
--
-- /See:/ 'newRoleCredentials' smart constructor.
data RoleCredentials = RoleCredentials'
  { -- | The key that is used to sign the request. For more information, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html Using Temporary Security Credentials to Request Access to AWS Resources>
    -- in the /AWS IAM User Guide/.
    RoleCredentials -> Maybe (Sensitive Text)
secretAccessKey :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The token used for temporary credentials. For more information, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html Using Temporary Security Credentials to Request Access to AWS Resources>
    -- in the /AWS IAM User Guide/.
    RoleCredentials -> Maybe (Sensitive Text)
sessionToken :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The date on which temporary security credentials expire.
    RoleCredentials -> Maybe Integer
expiration :: Prelude.Maybe Prelude.Integer,
    -- | The identifier used for the temporary security credentials. For more
    -- information, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html Using Temporary Security Credentials to Request Access to AWS Resources>
    -- in the /AWS IAM User Guide/.
    RoleCredentials -> Maybe Text
accessKeyId :: Prelude.Maybe Prelude.Text
  }
  deriving (RoleCredentials -> RoleCredentials -> Bool
(RoleCredentials -> RoleCredentials -> Bool)
-> (RoleCredentials -> RoleCredentials -> Bool)
-> Eq RoleCredentials
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RoleCredentials -> RoleCredentials -> Bool
$c/= :: RoleCredentials -> RoleCredentials -> Bool
== :: RoleCredentials -> RoleCredentials -> Bool
$c== :: RoleCredentials -> RoleCredentials -> Bool
Prelude.Eq, Int -> RoleCredentials -> ShowS
[RoleCredentials] -> ShowS
RoleCredentials -> String
(Int -> RoleCredentials -> ShowS)
-> (RoleCredentials -> String)
-> ([RoleCredentials] -> ShowS)
-> Show RoleCredentials
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RoleCredentials] -> ShowS
$cshowList :: [RoleCredentials] -> ShowS
show :: RoleCredentials -> String
$cshow :: RoleCredentials -> String
showsPrec :: Int -> RoleCredentials -> ShowS
$cshowsPrec :: Int -> RoleCredentials -> ShowS
Prelude.Show, (forall x. RoleCredentials -> Rep RoleCredentials x)
-> (forall x. Rep RoleCredentials x -> RoleCredentials)
-> Generic RoleCredentials
forall x. Rep RoleCredentials x -> RoleCredentials
forall x. RoleCredentials -> Rep RoleCredentials x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RoleCredentials x -> RoleCredentials
$cfrom :: forall x. RoleCredentials -> Rep RoleCredentials x
Prelude.Generic)

-- |
-- Create a value of 'RoleCredentials' 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', 'roleCredentials_secretAccessKey' - The key that is used to sign the request. For more information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html Using Temporary Security Credentials to Request Access to AWS Resources>
-- in the /AWS IAM User Guide/.
--
-- 'sessionToken', 'roleCredentials_sessionToken' - The token used for temporary credentials. For more information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html Using Temporary Security Credentials to Request Access to AWS Resources>
-- in the /AWS IAM User Guide/.
--
-- 'expiration', 'roleCredentials_expiration' - The date on which temporary security credentials expire.
--
-- 'accessKeyId', 'roleCredentials_accessKeyId' - The identifier used for the temporary security credentials. For more
-- information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html Using Temporary Security Credentials to Request Access to AWS Resources>
-- in the /AWS IAM User Guide/.
newRoleCredentials ::
  RoleCredentials
newRoleCredentials :: RoleCredentials
newRoleCredentials =
  RoleCredentials' :: Maybe (Sensitive Text)
-> Maybe (Sensitive Text)
-> Maybe Integer
-> Maybe Text
-> RoleCredentials
RoleCredentials'
    { $sel:secretAccessKey:RoleCredentials' :: Maybe (Sensitive Text)
secretAccessKey = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:sessionToken:RoleCredentials' :: Maybe (Sensitive Text)
sessionToken = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:expiration:RoleCredentials' :: Maybe Integer
expiration = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:accessKeyId:RoleCredentials' :: Maybe Text
accessKeyId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The key that is used to sign the request. For more information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html Using Temporary Security Credentials to Request Access to AWS Resources>
-- in the /AWS IAM User Guide/.
roleCredentials_secretAccessKey :: Lens.Lens' RoleCredentials (Prelude.Maybe Prelude.Text)
roleCredentials_secretAccessKey :: (Maybe Text -> f (Maybe Text))
-> RoleCredentials -> f RoleCredentials
roleCredentials_secretAccessKey = (RoleCredentials -> Maybe (Sensitive Text))
-> (RoleCredentials -> Maybe (Sensitive Text) -> RoleCredentials)
-> Lens
     RoleCredentials
     RoleCredentials
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RoleCredentials' {Maybe (Sensitive Text)
secretAccessKey :: Maybe (Sensitive Text)
$sel:secretAccessKey:RoleCredentials' :: RoleCredentials -> Maybe (Sensitive Text)
secretAccessKey} -> Maybe (Sensitive Text)
secretAccessKey) (\s :: RoleCredentials
s@RoleCredentials' {} Maybe (Sensitive Text)
a -> RoleCredentials
s {$sel:secretAccessKey:RoleCredentials' :: Maybe (Sensitive Text)
secretAccessKey = Maybe (Sensitive Text)
a} :: RoleCredentials) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> RoleCredentials -> f RoleCredentials)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> RoleCredentials
-> f RoleCredentials
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

-- | The token used for temporary credentials. For more information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html Using Temporary Security Credentials to Request Access to AWS Resources>
-- in the /AWS IAM User Guide/.
roleCredentials_sessionToken :: Lens.Lens' RoleCredentials (Prelude.Maybe Prelude.Text)
roleCredentials_sessionToken :: (Maybe Text -> f (Maybe Text))
-> RoleCredentials -> f RoleCredentials
roleCredentials_sessionToken = (RoleCredentials -> Maybe (Sensitive Text))
-> (RoleCredentials -> Maybe (Sensitive Text) -> RoleCredentials)
-> Lens
     RoleCredentials
     RoleCredentials
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RoleCredentials' {Maybe (Sensitive Text)
sessionToken :: Maybe (Sensitive Text)
$sel:sessionToken:RoleCredentials' :: RoleCredentials -> Maybe (Sensitive Text)
sessionToken} -> Maybe (Sensitive Text)
sessionToken) (\s :: RoleCredentials
s@RoleCredentials' {} Maybe (Sensitive Text)
a -> RoleCredentials
s {$sel:sessionToken:RoleCredentials' :: Maybe (Sensitive Text)
sessionToken = Maybe (Sensitive Text)
a} :: RoleCredentials) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> RoleCredentials -> f RoleCredentials)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> RoleCredentials
-> f RoleCredentials
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

-- | The date on which temporary security credentials expire.
roleCredentials_expiration :: Lens.Lens' RoleCredentials (Prelude.Maybe Prelude.Integer)
roleCredentials_expiration :: (Maybe Integer -> f (Maybe Integer))
-> RoleCredentials -> f RoleCredentials
roleCredentials_expiration = (RoleCredentials -> Maybe Integer)
-> (RoleCredentials -> Maybe Integer -> RoleCredentials)
-> Lens
     RoleCredentials RoleCredentials (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RoleCredentials' {Maybe Integer
expiration :: Maybe Integer
$sel:expiration:RoleCredentials' :: RoleCredentials -> Maybe Integer
expiration} -> Maybe Integer
expiration) (\s :: RoleCredentials
s@RoleCredentials' {} Maybe Integer
a -> RoleCredentials
s {$sel:expiration:RoleCredentials' :: Maybe Integer
expiration = Maybe Integer
a} :: RoleCredentials)

-- | The identifier used for the temporary security credentials. For more
-- information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html Using Temporary Security Credentials to Request Access to AWS Resources>
-- in the /AWS IAM User Guide/.
roleCredentials_accessKeyId :: Lens.Lens' RoleCredentials (Prelude.Maybe Prelude.Text)
roleCredentials_accessKeyId :: (Maybe Text -> f (Maybe Text))
-> RoleCredentials -> f RoleCredentials
roleCredentials_accessKeyId = (RoleCredentials -> Maybe Text)
-> (RoleCredentials -> Maybe Text -> RoleCredentials)
-> Lens RoleCredentials RoleCredentials (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RoleCredentials' {Maybe Text
accessKeyId :: Maybe Text
$sel:accessKeyId:RoleCredentials' :: RoleCredentials -> Maybe Text
accessKeyId} -> Maybe Text
accessKeyId) (\s :: RoleCredentials
s@RoleCredentials' {} Maybe Text
a -> RoleCredentials
s {$sel:accessKeyId:RoleCredentials' :: Maybe Text
accessKeyId = Maybe Text
a} :: RoleCredentials)

instance Core.FromJSON RoleCredentials where
  parseJSON :: Value -> Parser RoleCredentials
parseJSON =
    String
-> (Object -> Parser RoleCredentials)
-> Value
-> Parser RoleCredentials
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RoleCredentials"
      ( \Object
x ->
          Maybe (Sensitive Text)
-> Maybe (Sensitive Text)
-> Maybe Integer
-> Maybe Text
-> RoleCredentials
RoleCredentials'
            (Maybe (Sensitive Text)
 -> Maybe (Sensitive Text)
 -> Maybe Integer
 -> Maybe Text
 -> RoleCredentials)
-> Parser (Maybe (Sensitive Text))
-> Parser
     (Maybe (Sensitive Text)
      -> Maybe Integer -> Maybe Text -> RoleCredentials)
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
"secretAccessKey")
            Parser
  (Maybe (Sensitive Text)
   -> Maybe Integer -> Maybe Text -> RoleCredentials)
-> Parser (Maybe (Sensitive Text))
-> Parser (Maybe Integer -> Maybe Text -> RoleCredentials)
forall (f :: * -> *) a b. Applicative f => 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
"sessionToken")
            Parser (Maybe Integer -> Maybe Text -> RoleCredentials)
-> Parser (Maybe Integer) -> Parser (Maybe Text -> RoleCredentials)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"expiration")
            Parser (Maybe Text -> RoleCredentials)
-> Parser (Maybe Text) -> Parser RoleCredentials
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 RoleCredentials

instance Prelude.NFData RoleCredentials