{-# 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.CodePipeline.Types.AWSSessionCredentials
-- 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.CodePipeline.Types.AWSSessionCredentials where

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

-- | Represents an AWS session credentials object. These credentials are
-- temporary credentials that are issued by AWS Secure Token Service (STS).
-- They can be used to access input and output artifacts in the S3 bucket
-- used to store artifact for the pipeline in AWS CodePipeline.
--
-- /See:/ 'newAWSSessionCredentials' smart constructor.
data AWSSessionCredentials = AWSSessionCredentials'
  { -- | The access key for the session.
    AWSSessionCredentials -> Sensitive Text
accessKeyId :: Core.Sensitive Prelude.Text,
    -- | The secret access key for the session.
    AWSSessionCredentials -> Sensitive Text
secretAccessKey :: Core.Sensitive Prelude.Text,
    -- | The token for the session.
    AWSSessionCredentials -> Sensitive Text
sessionToken :: Core.Sensitive Prelude.Text
  }
  deriving (AWSSessionCredentials -> AWSSessionCredentials -> Bool
(AWSSessionCredentials -> AWSSessionCredentials -> Bool)
-> (AWSSessionCredentials -> AWSSessionCredentials -> Bool)
-> Eq AWSSessionCredentials
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AWSSessionCredentials -> AWSSessionCredentials -> Bool
$c/= :: AWSSessionCredentials -> AWSSessionCredentials -> Bool
== :: AWSSessionCredentials -> AWSSessionCredentials -> Bool
$c== :: AWSSessionCredentials -> AWSSessionCredentials -> Bool
Prelude.Eq, Int -> AWSSessionCredentials -> ShowS
[AWSSessionCredentials] -> ShowS
AWSSessionCredentials -> String
(Int -> AWSSessionCredentials -> ShowS)
-> (AWSSessionCredentials -> String)
-> ([AWSSessionCredentials] -> ShowS)
-> Show AWSSessionCredentials
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AWSSessionCredentials] -> ShowS
$cshowList :: [AWSSessionCredentials] -> ShowS
show :: AWSSessionCredentials -> String
$cshow :: AWSSessionCredentials -> String
showsPrec :: Int -> AWSSessionCredentials -> ShowS
$cshowsPrec :: Int -> AWSSessionCredentials -> ShowS
Prelude.Show, (forall x. AWSSessionCredentials -> Rep AWSSessionCredentials x)
-> (forall x. Rep AWSSessionCredentials x -> AWSSessionCredentials)
-> Generic AWSSessionCredentials
forall x. Rep AWSSessionCredentials x -> AWSSessionCredentials
forall x. AWSSessionCredentials -> Rep AWSSessionCredentials x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AWSSessionCredentials x -> AWSSessionCredentials
$cfrom :: forall x. AWSSessionCredentials -> Rep AWSSessionCredentials x
Prelude.Generic)

-- |
-- Create a value of 'AWSSessionCredentials' 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:
--
-- 'accessKeyId', 'aWSSessionCredentials_accessKeyId' - The access key for the session.
--
-- 'secretAccessKey', 'aWSSessionCredentials_secretAccessKey' - The secret access key for the session.
--
-- 'sessionToken', 'aWSSessionCredentials_sessionToken' - The token for the session.
newAWSSessionCredentials ::
  -- | 'accessKeyId'
  Prelude.Text ->
  -- | 'secretAccessKey'
  Prelude.Text ->
  -- | 'sessionToken'
  Prelude.Text ->
  AWSSessionCredentials
newAWSSessionCredentials :: Text -> Text -> Text -> AWSSessionCredentials
newAWSSessionCredentials
  Text
pAccessKeyId_
  Text
pSecretAccessKey_
  Text
pSessionToken_ =
    AWSSessionCredentials' :: Sensitive Text
-> Sensitive Text -> Sensitive Text -> AWSSessionCredentials
AWSSessionCredentials'
      { $sel:accessKeyId:AWSSessionCredentials' :: Sensitive Text
accessKeyId =
          Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pAccessKeyId_,
        $sel:secretAccessKey:AWSSessionCredentials' :: Sensitive Text
secretAccessKey =
          Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pSecretAccessKey_,
        $sel:sessionToken:AWSSessionCredentials' :: Sensitive Text
sessionToken = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pSessionToken_
      }

-- | The access key for the session.
aWSSessionCredentials_accessKeyId :: Lens.Lens' AWSSessionCredentials Prelude.Text
aWSSessionCredentials_accessKeyId :: (Text -> f Text)
-> AWSSessionCredentials -> f AWSSessionCredentials
aWSSessionCredentials_accessKeyId = (AWSSessionCredentials -> Sensitive Text)
-> (AWSSessionCredentials
    -> Sensitive Text -> AWSSessionCredentials)
-> Lens
     AWSSessionCredentials
     AWSSessionCredentials
     (Sensitive Text)
     (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AWSSessionCredentials' {Sensitive Text
accessKeyId :: Sensitive Text
$sel:accessKeyId:AWSSessionCredentials' :: AWSSessionCredentials -> Sensitive Text
accessKeyId} -> Sensitive Text
accessKeyId) (\s :: AWSSessionCredentials
s@AWSSessionCredentials' {} Sensitive Text
a -> AWSSessionCredentials
s {$sel:accessKeyId:AWSSessionCredentials' :: Sensitive Text
accessKeyId = Sensitive Text
a} :: AWSSessionCredentials) ((Sensitive Text -> f (Sensitive Text))
 -> AWSSessionCredentials -> f AWSSessionCredentials)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> AWSSessionCredentials
-> f AWSSessionCredentials
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The secret access key for the session.
aWSSessionCredentials_secretAccessKey :: Lens.Lens' AWSSessionCredentials Prelude.Text
aWSSessionCredentials_secretAccessKey :: (Text -> f Text)
-> AWSSessionCredentials -> f AWSSessionCredentials
aWSSessionCredentials_secretAccessKey = (AWSSessionCredentials -> Sensitive Text)
-> (AWSSessionCredentials
    -> Sensitive Text -> AWSSessionCredentials)
-> Lens
     AWSSessionCredentials
     AWSSessionCredentials
     (Sensitive Text)
     (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AWSSessionCredentials' {Sensitive Text
secretAccessKey :: Sensitive Text
$sel:secretAccessKey:AWSSessionCredentials' :: AWSSessionCredentials -> Sensitive Text
secretAccessKey} -> Sensitive Text
secretAccessKey) (\s :: AWSSessionCredentials
s@AWSSessionCredentials' {} Sensitive Text
a -> AWSSessionCredentials
s {$sel:secretAccessKey:AWSSessionCredentials' :: Sensitive Text
secretAccessKey = Sensitive Text
a} :: AWSSessionCredentials) ((Sensitive Text -> f (Sensitive Text))
 -> AWSSessionCredentials -> f AWSSessionCredentials)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> AWSSessionCredentials
-> f AWSSessionCredentials
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The token for the session.
aWSSessionCredentials_sessionToken :: Lens.Lens' AWSSessionCredentials Prelude.Text
aWSSessionCredentials_sessionToken :: (Text -> f Text)
-> AWSSessionCredentials -> f AWSSessionCredentials
aWSSessionCredentials_sessionToken = (AWSSessionCredentials -> Sensitive Text)
-> (AWSSessionCredentials
    -> Sensitive Text -> AWSSessionCredentials)
-> Lens
     AWSSessionCredentials
     AWSSessionCredentials
     (Sensitive Text)
     (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AWSSessionCredentials' {Sensitive Text
sessionToken :: Sensitive Text
$sel:sessionToken:AWSSessionCredentials' :: AWSSessionCredentials -> Sensitive Text
sessionToken} -> Sensitive Text
sessionToken) (\s :: AWSSessionCredentials
s@AWSSessionCredentials' {} Sensitive Text
a -> AWSSessionCredentials
s {$sel:sessionToken:AWSSessionCredentials' :: Sensitive Text
sessionToken = Sensitive Text
a} :: AWSSessionCredentials) ((Sensitive Text -> f (Sensitive Text))
 -> AWSSessionCredentials -> f AWSSessionCredentials)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> AWSSessionCredentials
-> f AWSSessionCredentials
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

instance Core.FromJSON AWSSessionCredentials where
  parseJSON :: Value -> Parser AWSSessionCredentials
parseJSON =
    String
-> (Object -> Parser AWSSessionCredentials)
-> Value
-> Parser AWSSessionCredentials
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AWSSessionCredentials"
      ( \Object
x ->
          Sensitive Text
-> Sensitive Text -> Sensitive Text -> AWSSessionCredentials
AWSSessionCredentials'
            (Sensitive Text
 -> Sensitive Text -> Sensitive Text -> AWSSessionCredentials)
-> Parser (Sensitive Text)
-> Parser
     (Sensitive Text -> Sensitive Text -> AWSSessionCredentials)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Sensitive Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"accessKeyId")
            Parser (Sensitive Text -> Sensitive Text -> AWSSessionCredentials)
-> Parser (Sensitive Text)
-> Parser (Sensitive Text -> AWSSessionCredentials)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Sensitive Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"secretAccessKey")
            Parser (Sensitive Text -> AWSSessionCredentials)
-> Parser (Sensitive Text) -> Parser AWSSessionCredentials
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Sensitive Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"sessionToken")
      )

instance Prelude.Hashable AWSSessionCredentials

instance Prelude.NFData AWSSessionCredentials