{-# 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.EC2.Types.UserData
-- 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.EC2.Types.UserData where

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

-- | Describes the user data for an instance.
--
-- /See:/ 'newUserData' smart constructor.
data UserData = UserData'
  { -- | The user data. If you are using an Amazon Web Services SDK or command
    -- line tool, Base64-encoding is performed for you, and you can load the
    -- text from a file. Otherwise, you must provide Base64-encoded text.
    UserData -> Maybe Text
data' :: Prelude.Maybe Prelude.Text
  }
  deriving (UserData -> UserData -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserData -> UserData -> Bool
$c/= :: UserData -> UserData -> Bool
== :: UserData -> UserData -> Bool
$c== :: UserData -> UserData -> Bool
Prelude.Eq, Int -> UserData -> ShowS
[UserData] -> ShowS
UserData -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UserData] -> ShowS
$cshowList :: [UserData] -> ShowS
show :: UserData -> String
$cshow :: UserData -> String
showsPrec :: Int -> UserData -> ShowS
$cshowsPrec :: Int -> UserData -> ShowS
Prelude.Show, forall x. Rep UserData x -> UserData
forall x. UserData -> Rep UserData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UserData x -> UserData
$cfrom :: forall x. UserData -> Rep UserData x
Prelude.Generic)

-- |
-- Create a value of 'UserData' 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:
--
-- 'data'', 'userData_data' - The user data. If you are using an Amazon Web Services SDK or command
-- line tool, Base64-encoding is performed for you, and you can load the
-- text from a file. Otherwise, you must provide Base64-encoded text.
newUserData ::
  UserData
newUserData :: UserData
newUserData = UserData' {$sel:data':UserData' :: Maybe Text
data' = forall a. Maybe a
Prelude.Nothing}

-- | The user data. If you are using an Amazon Web Services SDK or command
-- line tool, Base64-encoding is performed for you, and you can load the
-- text from a file. Otherwise, you must provide Base64-encoded text.
userData_data :: Lens.Lens' UserData (Prelude.Maybe Prelude.Text)
userData_data :: Lens' UserData (Maybe Text)
userData_data = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserData' {Maybe Text
data' :: Maybe Text
$sel:data':UserData' :: UserData -> Maybe Text
data'} -> Maybe Text
data') (\s :: UserData
s@UserData' {} Maybe Text
a -> UserData
s {$sel:data':UserData' :: Maybe Text
data' = Maybe Text
a} :: UserData)

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

instance Prelude.NFData UserData where
  rnf :: UserData -> ()
rnf UserData' {Maybe Text
data' :: Maybe Text
$sel:data':UserData' :: UserData -> Maybe Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
data'

instance Data.ToQuery UserData where
  toQuery :: UserData -> QueryString
toQuery UserData' {Maybe Text
data' :: Maybe Text
$sel:data':UserData' :: UserData -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"Data" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
data']