{-# 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.Lightsail.Types.PasswordData
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Lightsail.Types.PasswordData where

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

-- | The password data for the Windows Server-based instance, including the
-- ciphertext and the key pair name.
--
-- /See:/ 'newPasswordData' smart constructor.
data PasswordData = PasswordData'
  { -- | The encrypted password. Ciphertext will be an empty string if access to
    -- your new instance is not ready yet. When you create an instance, it can
    -- take up to 15 minutes for the instance to be ready.
    --
    -- If you use the default key pair (@LightsailDefaultKeyPair@), the
    -- decrypted password will be available in the password field.
    --
    -- If you are using a custom key pair, you need to use your own means of
    -- decryption.
    --
    -- If you change the Administrator password on the instance, Lightsail will
    -- continue to return the original ciphertext value. When accessing the
    -- instance using RDP, you need to manually enter the Administrator
    -- password after changing it from the default.
    PasswordData -> Maybe Text
ciphertext :: Prelude.Maybe Prelude.Text,
    -- | The name of the key pair that you used when creating your instance. If
    -- no key pair name was specified when creating the instance, Lightsail
    -- uses the default key pair (@LightsailDefaultKeyPair@).
    --
    -- If you are using a custom key pair, you need to use your own means of
    -- decrypting your password using the @ciphertext@. Lightsail creates the
    -- ciphertext by encrypting your password with the public key part of this
    -- key pair.
    PasswordData -> Maybe Text
keyPairName :: Prelude.Maybe Prelude.Text
  }
  deriving (PasswordData -> PasswordData -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PasswordData -> PasswordData -> Bool
$c/= :: PasswordData -> PasswordData -> Bool
== :: PasswordData -> PasswordData -> Bool
$c== :: PasswordData -> PasswordData -> Bool
Prelude.Eq, ReadPrec [PasswordData]
ReadPrec PasswordData
Int -> ReadS PasswordData
ReadS [PasswordData]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PasswordData]
$creadListPrec :: ReadPrec [PasswordData]
readPrec :: ReadPrec PasswordData
$creadPrec :: ReadPrec PasswordData
readList :: ReadS [PasswordData]
$creadList :: ReadS [PasswordData]
readsPrec :: Int -> ReadS PasswordData
$creadsPrec :: Int -> ReadS PasswordData
Prelude.Read, Int -> PasswordData -> ShowS
[PasswordData] -> ShowS
PasswordData -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PasswordData] -> ShowS
$cshowList :: [PasswordData] -> ShowS
show :: PasswordData -> String
$cshow :: PasswordData -> String
showsPrec :: Int -> PasswordData -> ShowS
$cshowsPrec :: Int -> PasswordData -> ShowS
Prelude.Show, forall x. Rep PasswordData x -> PasswordData
forall x. PasswordData -> Rep PasswordData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PasswordData x -> PasswordData
$cfrom :: forall x. PasswordData -> Rep PasswordData x
Prelude.Generic)

-- |
-- Create a value of 'PasswordData' 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:
--
-- 'ciphertext', 'passwordData_ciphertext' - The encrypted password. Ciphertext will be an empty string if access to
-- your new instance is not ready yet. When you create an instance, it can
-- take up to 15 minutes for the instance to be ready.
--
-- If you use the default key pair (@LightsailDefaultKeyPair@), the
-- decrypted password will be available in the password field.
--
-- If you are using a custom key pair, you need to use your own means of
-- decryption.
--
-- If you change the Administrator password on the instance, Lightsail will
-- continue to return the original ciphertext value. When accessing the
-- instance using RDP, you need to manually enter the Administrator
-- password after changing it from the default.
--
-- 'keyPairName', 'passwordData_keyPairName' - The name of the key pair that you used when creating your instance. If
-- no key pair name was specified when creating the instance, Lightsail
-- uses the default key pair (@LightsailDefaultKeyPair@).
--
-- If you are using a custom key pair, you need to use your own means of
-- decrypting your password using the @ciphertext@. Lightsail creates the
-- ciphertext by encrypting your password with the public key part of this
-- key pair.
newPasswordData ::
  PasswordData
newPasswordData :: PasswordData
newPasswordData =
  PasswordData'
    { $sel:ciphertext:PasswordData' :: Maybe Text
ciphertext = forall a. Maybe a
Prelude.Nothing,
      $sel:keyPairName:PasswordData' :: Maybe Text
keyPairName = forall a. Maybe a
Prelude.Nothing
    }

-- | The encrypted password. Ciphertext will be an empty string if access to
-- your new instance is not ready yet. When you create an instance, it can
-- take up to 15 minutes for the instance to be ready.
--
-- If you use the default key pair (@LightsailDefaultKeyPair@), the
-- decrypted password will be available in the password field.
--
-- If you are using a custom key pair, you need to use your own means of
-- decryption.
--
-- If you change the Administrator password on the instance, Lightsail will
-- continue to return the original ciphertext value. When accessing the
-- instance using RDP, you need to manually enter the Administrator
-- password after changing it from the default.
passwordData_ciphertext :: Lens.Lens' PasswordData (Prelude.Maybe Prelude.Text)
passwordData_ciphertext :: Lens' PasswordData (Maybe Text)
passwordData_ciphertext = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PasswordData' {Maybe Text
ciphertext :: Maybe Text
$sel:ciphertext:PasswordData' :: PasswordData -> Maybe Text
ciphertext} -> Maybe Text
ciphertext) (\s :: PasswordData
s@PasswordData' {} Maybe Text
a -> PasswordData
s {$sel:ciphertext:PasswordData' :: Maybe Text
ciphertext = Maybe Text
a} :: PasswordData)

-- | The name of the key pair that you used when creating your instance. If
-- no key pair name was specified when creating the instance, Lightsail
-- uses the default key pair (@LightsailDefaultKeyPair@).
--
-- If you are using a custom key pair, you need to use your own means of
-- decrypting your password using the @ciphertext@. Lightsail creates the
-- ciphertext by encrypting your password with the public key part of this
-- key pair.
passwordData_keyPairName :: Lens.Lens' PasswordData (Prelude.Maybe Prelude.Text)
passwordData_keyPairName :: Lens' PasswordData (Maybe Text)
passwordData_keyPairName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PasswordData' {Maybe Text
keyPairName :: Maybe Text
$sel:keyPairName:PasswordData' :: PasswordData -> Maybe Text
keyPairName} -> Maybe Text
keyPairName) (\s :: PasswordData
s@PasswordData' {} Maybe Text
a -> PasswordData
s {$sel:keyPairName:PasswordData' :: Maybe Text
keyPairName = Maybe Text
a} :: PasswordData)

instance Data.FromJSON PasswordData where
  parseJSON :: Value -> Parser PasswordData
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PasswordData"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> PasswordData
PasswordData'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ciphertext")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"keyPairName")
      )

instance Prelude.Hashable PasswordData where
  hashWithSalt :: Int -> PasswordData -> Int
hashWithSalt Int
_salt PasswordData' {Maybe Text
keyPairName :: Maybe Text
ciphertext :: Maybe Text
$sel:keyPairName:PasswordData' :: PasswordData -> Maybe Text
$sel:ciphertext:PasswordData' :: PasswordData -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
ciphertext
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
keyPairName

instance Prelude.NFData PasswordData where
  rnf :: PasswordData -> ()
rnf PasswordData' {Maybe Text
keyPairName :: Maybe Text
ciphertext :: Maybe Text
$sel:keyPairName:PasswordData' :: PasswordData -> Maybe Text
$sel:ciphertext:PasswordData' :: PasswordData -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
ciphertext
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
keyPairName