{-# 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-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.Lightsail.Types.PasswordData where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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,
    -- | 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
  }
  deriving (PasswordData -> PasswordData -> Bool
(PasswordData -> PasswordData -> Bool)
-> (PasswordData -> PasswordData -> Bool) -> Eq PasswordData
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]
(Int -> ReadS PasswordData)
-> ReadS [PasswordData]
-> ReadPrec PasswordData
-> ReadPrec [PasswordData]
-> Read 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
(Int -> PasswordData -> ShowS)
-> (PasswordData -> String)
-> ([PasswordData] -> ShowS)
-> Show PasswordData
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. PasswordData -> Rep PasswordData x)
-> (forall x. Rep PasswordData x -> PasswordData)
-> Generic PasswordData
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:
--
-- '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.
--
-- '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.
newPasswordData ::
  PasswordData
newPasswordData :: PasswordData
newPasswordData =
  PasswordData' :: Maybe Text -> Maybe Text -> PasswordData
PasswordData'
    { $sel:keyPairName:PasswordData' :: Maybe Text
keyPairName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:ciphertext:PasswordData' :: Maybe Text
ciphertext = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> PasswordData -> f PasswordData
passwordData_keyPairName = (PasswordData -> Maybe Text)
-> (PasswordData -> Maybe Text -> PasswordData)
-> Lens PasswordData PasswordData (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> PasswordData -> f PasswordData
passwordData_ciphertext = (PasswordData -> Maybe Text)
-> (PasswordData -> Maybe Text -> PasswordData)
-> Lens PasswordData PasswordData (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable PasswordData

instance Prelude.NFData PasswordData