{-# 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.GameLift.Types.AwsCredentials
-- 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.GameLift.Types.AwsCredentials where

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

-- | Temporary access credentials used for uploading game build files to
-- Amazon GameLift. They are valid for a limited time. If they expire
-- before you upload your game build, get a new set by calling
-- RequestUploadCredentials.
--
-- /See:/ 'newAwsCredentials' smart constructor.
data AwsCredentials = AwsCredentials'
  { -- | Temporary secret key allowing access to the Amazon GameLift S3 account.
    AwsCredentials -> Maybe Text
secretAccessKey :: Prelude.Maybe Prelude.Text,
    -- | Token used to associate a specific build ID with the files uploaded
    -- using these credentials.
    AwsCredentials -> Maybe Text
sessionToken :: Prelude.Maybe Prelude.Text,
    -- | Temporary key allowing access to the Amazon GameLift S3 account.
    AwsCredentials -> Maybe Text
accessKeyId :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsCredentials -> AwsCredentials -> Bool
(AwsCredentials -> AwsCredentials -> Bool)
-> (AwsCredentials -> AwsCredentials -> Bool) -> Eq AwsCredentials
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsCredentials -> AwsCredentials -> Bool
$c/= :: AwsCredentials -> AwsCredentials -> Bool
== :: AwsCredentials -> AwsCredentials -> Bool
$c== :: AwsCredentials -> AwsCredentials -> Bool
Prelude.Eq, Int -> AwsCredentials -> ShowS
[AwsCredentials] -> ShowS
AwsCredentials -> String
(Int -> AwsCredentials -> ShowS)
-> (AwsCredentials -> String)
-> ([AwsCredentials] -> ShowS)
-> Show AwsCredentials
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsCredentials] -> ShowS
$cshowList :: [AwsCredentials] -> ShowS
show :: AwsCredentials -> String
$cshow :: AwsCredentials -> String
showsPrec :: Int -> AwsCredentials -> ShowS
$cshowsPrec :: Int -> AwsCredentials -> ShowS
Prelude.Show, (forall x. AwsCredentials -> Rep AwsCredentials x)
-> (forall x. Rep AwsCredentials x -> AwsCredentials)
-> Generic AwsCredentials
forall x. Rep AwsCredentials x -> AwsCredentials
forall x. AwsCredentials -> Rep AwsCredentials x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AwsCredentials x -> AwsCredentials
$cfrom :: forall x. AwsCredentials -> Rep AwsCredentials x
Prelude.Generic)

-- |
-- Create a value of 'AwsCredentials' 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', 'awsCredentials_secretAccessKey' - Temporary secret key allowing access to the Amazon GameLift S3 account.
--
-- 'sessionToken', 'awsCredentials_sessionToken' - Token used to associate a specific build ID with the files uploaded
-- using these credentials.
--
-- 'accessKeyId', 'awsCredentials_accessKeyId' - Temporary key allowing access to the Amazon GameLift S3 account.
newAwsCredentials ::
  AwsCredentials
newAwsCredentials :: AwsCredentials
newAwsCredentials =
  AwsCredentials' :: Maybe Text -> Maybe Text -> Maybe Text -> AwsCredentials
AwsCredentials'
    { $sel:secretAccessKey:AwsCredentials' :: Maybe Text
secretAccessKey = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sessionToken:AwsCredentials' :: Maybe Text
sessionToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:accessKeyId:AwsCredentials' :: Maybe Text
accessKeyId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Temporary secret key allowing access to the Amazon GameLift S3 account.
awsCredentials_secretAccessKey :: Lens.Lens' AwsCredentials (Prelude.Maybe Prelude.Text)
awsCredentials_secretAccessKey :: (Maybe Text -> f (Maybe Text))
-> AwsCredentials -> f AwsCredentials
awsCredentials_secretAccessKey = (AwsCredentials -> Maybe Text)
-> (AwsCredentials -> Maybe Text -> AwsCredentials)
-> Lens AwsCredentials AwsCredentials (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCredentials' {Maybe Text
secretAccessKey :: Maybe Text
$sel:secretAccessKey:AwsCredentials' :: AwsCredentials -> Maybe Text
secretAccessKey} -> Maybe Text
secretAccessKey) (\s :: AwsCredentials
s@AwsCredentials' {} Maybe Text
a -> AwsCredentials
s {$sel:secretAccessKey:AwsCredentials' :: Maybe Text
secretAccessKey = Maybe Text
a} :: AwsCredentials)

-- | Token used to associate a specific build ID with the files uploaded
-- using these credentials.
awsCredentials_sessionToken :: Lens.Lens' AwsCredentials (Prelude.Maybe Prelude.Text)
awsCredentials_sessionToken :: (Maybe Text -> f (Maybe Text))
-> AwsCredentials -> f AwsCredentials
awsCredentials_sessionToken = (AwsCredentials -> Maybe Text)
-> (AwsCredentials -> Maybe Text -> AwsCredentials)
-> Lens AwsCredentials AwsCredentials (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCredentials' {Maybe Text
sessionToken :: Maybe Text
$sel:sessionToken:AwsCredentials' :: AwsCredentials -> Maybe Text
sessionToken} -> Maybe Text
sessionToken) (\s :: AwsCredentials
s@AwsCredentials' {} Maybe Text
a -> AwsCredentials
s {$sel:sessionToken:AwsCredentials' :: Maybe Text
sessionToken = Maybe Text
a} :: AwsCredentials)

-- | Temporary key allowing access to the Amazon GameLift S3 account.
awsCredentials_accessKeyId :: Lens.Lens' AwsCredentials (Prelude.Maybe Prelude.Text)
awsCredentials_accessKeyId :: (Maybe Text -> f (Maybe Text))
-> AwsCredentials -> f AwsCredentials
awsCredentials_accessKeyId = (AwsCredentials -> Maybe Text)
-> (AwsCredentials -> Maybe Text -> AwsCredentials)
-> Lens AwsCredentials AwsCredentials (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCredentials' {Maybe Text
accessKeyId :: Maybe Text
$sel:accessKeyId:AwsCredentials' :: AwsCredentials -> Maybe Text
accessKeyId} -> Maybe Text
accessKeyId) (\s :: AwsCredentials
s@AwsCredentials' {} Maybe Text
a -> AwsCredentials
s {$sel:accessKeyId:AwsCredentials' :: Maybe Text
accessKeyId = Maybe Text
a} :: AwsCredentials)

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

instance Prelude.NFData AwsCredentials