{-# 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.InstanceCredentials
-- 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.InstanceCredentials where

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

-- | Set of credentials required to remotely access a fleet instance. Access
-- credentials are requested by calling GetInstanceAccess and returned in
-- an InstanceAccess object.
--
-- /See:/ 'newInstanceCredentials' smart constructor.
data InstanceCredentials = InstanceCredentials'
  { -- | User login string.
    InstanceCredentials -> Maybe Text
userName :: Prelude.Maybe Prelude.Text,
    -- | Secret string. For Windows instances, the secret is a password for use
    -- with Windows Remote Desktop. For Linux instances, it is a private key
    -- (which must be saved as a @.pem@ file) for use with SSH.
    InstanceCredentials -> Maybe Text
secret :: Prelude.Maybe Prelude.Text
  }
  deriving (InstanceCredentials -> InstanceCredentials -> Bool
(InstanceCredentials -> InstanceCredentials -> Bool)
-> (InstanceCredentials -> InstanceCredentials -> Bool)
-> Eq InstanceCredentials
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceCredentials -> InstanceCredentials -> Bool
$c/= :: InstanceCredentials -> InstanceCredentials -> Bool
== :: InstanceCredentials -> InstanceCredentials -> Bool
$c== :: InstanceCredentials -> InstanceCredentials -> Bool
Prelude.Eq, Int -> InstanceCredentials -> ShowS
[InstanceCredentials] -> ShowS
InstanceCredentials -> String
(Int -> InstanceCredentials -> ShowS)
-> (InstanceCredentials -> String)
-> ([InstanceCredentials] -> ShowS)
-> Show InstanceCredentials
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceCredentials] -> ShowS
$cshowList :: [InstanceCredentials] -> ShowS
show :: InstanceCredentials -> String
$cshow :: InstanceCredentials -> String
showsPrec :: Int -> InstanceCredentials -> ShowS
$cshowsPrec :: Int -> InstanceCredentials -> ShowS
Prelude.Show, (forall x. InstanceCredentials -> Rep InstanceCredentials x)
-> (forall x. Rep InstanceCredentials x -> InstanceCredentials)
-> Generic InstanceCredentials
forall x. Rep InstanceCredentials x -> InstanceCredentials
forall x. InstanceCredentials -> Rep InstanceCredentials x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstanceCredentials x -> InstanceCredentials
$cfrom :: forall x. InstanceCredentials -> Rep InstanceCredentials x
Prelude.Generic)

-- |
-- Create a value of 'InstanceCredentials' 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:
--
-- 'userName', 'instanceCredentials_userName' - User login string.
--
-- 'secret', 'instanceCredentials_secret' - Secret string. For Windows instances, the secret is a password for use
-- with Windows Remote Desktop. For Linux instances, it is a private key
-- (which must be saved as a @.pem@ file) for use with SSH.
newInstanceCredentials ::
  InstanceCredentials
newInstanceCredentials :: InstanceCredentials
newInstanceCredentials =
  InstanceCredentials' :: Maybe Text -> Maybe Text -> InstanceCredentials
InstanceCredentials'
    { $sel:userName:InstanceCredentials' :: Maybe Text
userName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:secret:InstanceCredentials' :: Maybe Text
secret = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | User login string.
instanceCredentials_userName :: Lens.Lens' InstanceCredentials (Prelude.Maybe Prelude.Text)
instanceCredentials_userName :: (Maybe Text -> f (Maybe Text))
-> InstanceCredentials -> f InstanceCredentials
instanceCredentials_userName = (InstanceCredentials -> Maybe Text)
-> (InstanceCredentials -> Maybe Text -> InstanceCredentials)
-> Lens
     InstanceCredentials InstanceCredentials (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceCredentials' {Maybe Text
userName :: Maybe Text
$sel:userName:InstanceCredentials' :: InstanceCredentials -> Maybe Text
userName} -> Maybe Text
userName) (\s :: InstanceCredentials
s@InstanceCredentials' {} Maybe Text
a -> InstanceCredentials
s {$sel:userName:InstanceCredentials' :: Maybe Text
userName = Maybe Text
a} :: InstanceCredentials)

-- | Secret string. For Windows instances, the secret is a password for use
-- with Windows Remote Desktop. For Linux instances, it is a private key
-- (which must be saved as a @.pem@ file) for use with SSH.
instanceCredentials_secret :: Lens.Lens' InstanceCredentials (Prelude.Maybe Prelude.Text)
instanceCredentials_secret :: (Maybe Text -> f (Maybe Text))
-> InstanceCredentials -> f InstanceCredentials
instanceCredentials_secret = (InstanceCredentials -> Maybe Text)
-> (InstanceCredentials -> Maybe Text -> InstanceCredentials)
-> Lens
     InstanceCredentials InstanceCredentials (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceCredentials' {Maybe Text
secret :: Maybe Text
$sel:secret:InstanceCredentials' :: InstanceCredentials -> Maybe Text
secret} -> Maybe Text
secret) (\s :: InstanceCredentials
s@InstanceCredentials' {} Maybe Text
a -> InstanceCredentials
s {$sel:secret:InstanceCredentials' :: Maybe Text
secret = Maybe Text
a} :: InstanceCredentials)

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

instance Prelude.Hashable InstanceCredentials

instance Prelude.NFData InstanceCredentials