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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Lightsail.Types.PortInfoSourceType
import qualified Amazonka.Prelude as Prelude

-- | Describes the Amazon Elastic Compute Cloud instance and related
-- resources to be created using the @create cloud formation stack@
-- operation.
--
-- /See:/ 'newInstanceEntry' smart constructor.
data InstanceEntry = InstanceEntry'
  { -- | A launch script you can create that configures a server with additional
    -- user data. For example, you might want to run @apt-get -y update@.
    --
    -- Depending on the machine image you choose, the command to get software
    -- on your instance varies. Amazon Linux and CentOS use @yum@, Debian and
    -- Ubuntu use @apt-get@, and FreeBSD uses @pkg@.
    InstanceEntry -> Maybe Text
userData :: Prelude.Maybe Prelude.Text,
    -- | The name of the export snapshot record, which contains the exported
    -- Lightsail instance snapshot that will be used as the source of the new
    -- Amazon EC2 instance.
    --
    -- Use the @get export snapshot records@ operation to get a list of export
    -- snapshot records that you can use to create a CloudFormation stack.
    InstanceEntry -> Text
sourceName :: Prelude.Text,
    -- | The instance type (e.g., @t2.micro@) to use for the new Amazon EC2
    -- instance.
    InstanceEntry -> Text
instanceType :: Prelude.Text,
    -- | The port configuration to use for the new Amazon EC2 instance.
    --
    -- The following configuration options are available:
    --
    -- -   @DEFAULT@ - Use the default firewall settings from the Lightsail
    --     instance blueprint. If this is specified, then IPv4 and IPv6 will be
    --     configured for the new instance that is created in Amazon EC2.
    --
    -- -   @INSTANCE@ - Use the configured firewall settings from the source
    --     Lightsail instance. If this is specified, the new instance that is
    --     created in Amazon EC2 will be configured to match the configuration
    --     of the source Lightsail instance. For example, if the source
    --     instance is configured for dual-stack (IPv4 and IPv6), then IPv4 and
    --     IPv6 will be configured for the new instance that is created in
    --     Amazon EC2. If the source instance is configured for IPv4 only, then
    --     only IPv4 will be configured for the new instance that is created in
    --     Amazon EC2.
    --
    -- -   @NONE@ - Use the default Amazon EC2 security group. If this is
    --     specified, then only IPv4 will be configured for the new instance
    --     that is created in Amazon EC2.
    --
    -- -   @CLOSED@ - All ports closed. If this is specified, then only IPv4
    --     will be configured for the new instance that is created in Amazon
    --     EC2.
    --
    -- If you configured @lightsail-connect@ as a @cidrListAliases@ on your
    -- instance, or if you chose to allow the Lightsail browser-based SSH or
    -- RDP clients to connect to your instance, that configuration is not
    -- carried over to your new Amazon EC2 instance.
    InstanceEntry -> PortInfoSourceType
portInfoSource :: PortInfoSourceType,
    -- | The Availability Zone for the new Amazon EC2 instance.
    InstanceEntry -> Text
availabilityZone :: Prelude.Text
  }
  deriving (InstanceEntry -> InstanceEntry -> Bool
(InstanceEntry -> InstanceEntry -> Bool)
-> (InstanceEntry -> InstanceEntry -> Bool) -> Eq InstanceEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceEntry -> InstanceEntry -> Bool
$c/= :: InstanceEntry -> InstanceEntry -> Bool
== :: InstanceEntry -> InstanceEntry -> Bool
$c== :: InstanceEntry -> InstanceEntry -> Bool
Prelude.Eq, ReadPrec [InstanceEntry]
ReadPrec InstanceEntry
Int -> ReadS InstanceEntry
ReadS [InstanceEntry]
(Int -> ReadS InstanceEntry)
-> ReadS [InstanceEntry]
-> ReadPrec InstanceEntry
-> ReadPrec [InstanceEntry]
-> Read InstanceEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceEntry]
$creadListPrec :: ReadPrec [InstanceEntry]
readPrec :: ReadPrec InstanceEntry
$creadPrec :: ReadPrec InstanceEntry
readList :: ReadS [InstanceEntry]
$creadList :: ReadS [InstanceEntry]
readsPrec :: Int -> ReadS InstanceEntry
$creadsPrec :: Int -> ReadS InstanceEntry
Prelude.Read, Int -> InstanceEntry -> ShowS
[InstanceEntry] -> ShowS
InstanceEntry -> String
(Int -> InstanceEntry -> ShowS)
-> (InstanceEntry -> String)
-> ([InstanceEntry] -> ShowS)
-> Show InstanceEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceEntry] -> ShowS
$cshowList :: [InstanceEntry] -> ShowS
show :: InstanceEntry -> String
$cshow :: InstanceEntry -> String
showsPrec :: Int -> InstanceEntry -> ShowS
$cshowsPrec :: Int -> InstanceEntry -> ShowS
Prelude.Show, (forall x. InstanceEntry -> Rep InstanceEntry x)
-> (forall x. Rep InstanceEntry x -> InstanceEntry)
-> Generic InstanceEntry
forall x. Rep InstanceEntry x -> InstanceEntry
forall x. InstanceEntry -> Rep InstanceEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstanceEntry x -> InstanceEntry
$cfrom :: forall x. InstanceEntry -> Rep InstanceEntry x
Prelude.Generic)

-- |
-- Create a value of 'InstanceEntry' 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:
--
-- 'userData', 'instanceEntry_userData' - A launch script you can create that configures a server with additional
-- user data. For example, you might want to run @apt-get -y update@.
--
-- Depending on the machine image you choose, the command to get software
-- on your instance varies. Amazon Linux and CentOS use @yum@, Debian and
-- Ubuntu use @apt-get@, and FreeBSD uses @pkg@.
--
-- 'sourceName', 'instanceEntry_sourceName' - The name of the export snapshot record, which contains the exported
-- Lightsail instance snapshot that will be used as the source of the new
-- Amazon EC2 instance.
--
-- Use the @get export snapshot records@ operation to get a list of export
-- snapshot records that you can use to create a CloudFormation stack.
--
-- 'instanceType', 'instanceEntry_instanceType' - The instance type (e.g., @t2.micro@) to use for the new Amazon EC2
-- instance.
--
-- 'portInfoSource', 'instanceEntry_portInfoSource' - The port configuration to use for the new Amazon EC2 instance.
--
-- The following configuration options are available:
--
-- -   @DEFAULT@ - Use the default firewall settings from the Lightsail
--     instance blueprint. If this is specified, then IPv4 and IPv6 will be
--     configured for the new instance that is created in Amazon EC2.
--
-- -   @INSTANCE@ - Use the configured firewall settings from the source
--     Lightsail instance. If this is specified, the new instance that is
--     created in Amazon EC2 will be configured to match the configuration
--     of the source Lightsail instance. For example, if the source
--     instance is configured for dual-stack (IPv4 and IPv6), then IPv4 and
--     IPv6 will be configured for the new instance that is created in
--     Amazon EC2. If the source instance is configured for IPv4 only, then
--     only IPv4 will be configured for the new instance that is created in
--     Amazon EC2.
--
-- -   @NONE@ - Use the default Amazon EC2 security group. If this is
--     specified, then only IPv4 will be configured for the new instance
--     that is created in Amazon EC2.
--
-- -   @CLOSED@ - All ports closed. If this is specified, then only IPv4
--     will be configured for the new instance that is created in Amazon
--     EC2.
--
-- If you configured @lightsail-connect@ as a @cidrListAliases@ on your
-- instance, or if you chose to allow the Lightsail browser-based SSH or
-- RDP clients to connect to your instance, that configuration is not
-- carried over to your new Amazon EC2 instance.
--
-- 'availabilityZone', 'instanceEntry_availabilityZone' - The Availability Zone for the new Amazon EC2 instance.
newInstanceEntry ::
  -- | 'sourceName'
  Prelude.Text ->
  -- | 'instanceType'
  Prelude.Text ->
  -- | 'portInfoSource'
  PortInfoSourceType ->
  -- | 'availabilityZone'
  Prelude.Text ->
  InstanceEntry
newInstanceEntry :: Text -> Text -> PortInfoSourceType -> Text -> InstanceEntry
newInstanceEntry
  Text
pSourceName_
  Text
pInstanceType_
  PortInfoSourceType
pPortInfoSource_
  Text
pAvailabilityZone_ =
    InstanceEntry' :: Maybe Text
-> Text -> Text -> PortInfoSourceType -> Text -> InstanceEntry
InstanceEntry'
      { $sel:userData:InstanceEntry' :: Maybe Text
userData = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:sourceName:InstanceEntry' :: Text
sourceName = Text
pSourceName_,
        $sel:instanceType:InstanceEntry' :: Text
instanceType = Text
pInstanceType_,
        $sel:portInfoSource:InstanceEntry' :: PortInfoSourceType
portInfoSource = PortInfoSourceType
pPortInfoSource_,
        $sel:availabilityZone:InstanceEntry' :: Text
availabilityZone = Text
pAvailabilityZone_
      }

-- | A launch script you can create that configures a server with additional
-- user data. For example, you might want to run @apt-get -y update@.
--
-- Depending on the machine image you choose, the command to get software
-- on your instance varies. Amazon Linux and CentOS use @yum@, Debian and
-- Ubuntu use @apt-get@, and FreeBSD uses @pkg@.
instanceEntry_userData :: Lens.Lens' InstanceEntry (Prelude.Maybe Prelude.Text)
instanceEntry_userData :: (Maybe Text -> f (Maybe Text)) -> InstanceEntry -> f InstanceEntry
instanceEntry_userData = (InstanceEntry -> Maybe Text)
-> (InstanceEntry -> Maybe Text -> InstanceEntry)
-> Lens InstanceEntry InstanceEntry (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceEntry' {Maybe Text
userData :: Maybe Text
$sel:userData:InstanceEntry' :: InstanceEntry -> Maybe Text
userData} -> Maybe Text
userData) (\s :: InstanceEntry
s@InstanceEntry' {} Maybe Text
a -> InstanceEntry
s {$sel:userData:InstanceEntry' :: Maybe Text
userData = Maybe Text
a} :: InstanceEntry)

-- | The name of the export snapshot record, which contains the exported
-- Lightsail instance snapshot that will be used as the source of the new
-- Amazon EC2 instance.
--
-- Use the @get export snapshot records@ operation to get a list of export
-- snapshot records that you can use to create a CloudFormation stack.
instanceEntry_sourceName :: Lens.Lens' InstanceEntry Prelude.Text
instanceEntry_sourceName :: (Text -> f Text) -> InstanceEntry -> f InstanceEntry
instanceEntry_sourceName = (InstanceEntry -> Text)
-> (InstanceEntry -> Text -> InstanceEntry)
-> Lens InstanceEntry InstanceEntry Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceEntry' {Text
sourceName :: Text
$sel:sourceName:InstanceEntry' :: InstanceEntry -> Text
sourceName} -> Text
sourceName) (\s :: InstanceEntry
s@InstanceEntry' {} Text
a -> InstanceEntry
s {$sel:sourceName:InstanceEntry' :: Text
sourceName = Text
a} :: InstanceEntry)

-- | The instance type (e.g., @t2.micro@) to use for the new Amazon EC2
-- instance.
instanceEntry_instanceType :: Lens.Lens' InstanceEntry Prelude.Text
instanceEntry_instanceType :: (Text -> f Text) -> InstanceEntry -> f InstanceEntry
instanceEntry_instanceType = (InstanceEntry -> Text)
-> (InstanceEntry -> Text -> InstanceEntry)
-> Lens InstanceEntry InstanceEntry Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceEntry' {Text
instanceType :: Text
$sel:instanceType:InstanceEntry' :: InstanceEntry -> Text
instanceType} -> Text
instanceType) (\s :: InstanceEntry
s@InstanceEntry' {} Text
a -> InstanceEntry
s {$sel:instanceType:InstanceEntry' :: Text
instanceType = Text
a} :: InstanceEntry)

-- | The port configuration to use for the new Amazon EC2 instance.
--
-- The following configuration options are available:
--
-- -   @DEFAULT@ - Use the default firewall settings from the Lightsail
--     instance blueprint. If this is specified, then IPv4 and IPv6 will be
--     configured for the new instance that is created in Amazon EC2.
--
-- -   @INSTANCE@ - Use the configured firewall settings from the source
--     Lightsail instance. If this is specified, the new instance that is
--     created in Amazon EC2 will be configured to match the configuration
--     of the source Lightsail instance. For example, if the source
--     instance is configured for dual-stack (IPv4 and IPv6), then IPv4 and
--     IPv6 will be configured for the new instance that is created in
--     Amazon EC2. If the source instance is configured for IPv4 only, then
--     only IPv4 will be configured for the new instance that is created in
--     Amazon EC2.
--
-- -   @NONE@ - Use the default Amazon EC2 security group. If this is
--     specified, then only IPv4 will be configured for the new instance
--     that is created in Amazon EC2.
--
-- -   @CLOSED@ - All ports closed. If this is specified, then only IPv4
--     will be configured for the new instance that is created in Amazon
--     EC2.
--
-- If you configured @lightsail-connect@ as a @cidrListAliases@ on your
-- instance, or if you chose to allow the Lightsail browser-based SSH or
-- RDP clients to connect to your instance, that configuration is not
-- carried over to your new Amazon EC2 instance.
instanceEntry_portInfoSource :: Lens.Lens' InstanceEntry PortInfoSourceType
instanceEntry_portInfoSource :: (PortInfoSourceType -> f PortInfoSourceType)
-> InstanceEntry -> f InstanceEntry
instanceEntry_portInfoSource = (InstanceEntry -> PortInfoSourceType)
-> (InstanceEntry -> PortInfoSourceType -> InstanceEntry)
-> Lens
     InstanceEntry InstanceEntry PortInfoSourceType PortInfoSourceType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceEntry' {PortInfoSourceType
portInfoSource :: PortInfoSourceType
$sel:portInfoSource:InstanceEntry' :: InstanceEntry -> PortInfoSourceType
portInfoSource} -> PortInfoSourceType
portInfoSource) (\s :: InstanceEntry
s@InstanceEntry' {} PortInfoSourceType
a -> InstanceEntry
s {$sel:portInfoSource:InstanceEntry' :: PortInfoSourceType
portInfoSource = PortInfoSourceType
a} :: InstanceEntry)

-- | The Availability Zone for the new Amazon EC2 instance.
instanceEntry_availabilityZone :: Lens.Lens' InstanceEntry Prelude.Text
instanceEntry_availabilityZone :: (Text -> f Text) -> InstanceEntry -> f InstanceEntry
instanceEntry_availabilityZone = (InstanceEntry -> Text)
-> (InstanceEntry -> Text -> InstanceEntry)
-> Lens InstanceEntry InstanceEntry Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceEntry' {Text
availabilityZone :: Text
$sel:availabilityZone:InstanceEntry' :: InstanceEntry -> Text
availabilityZone} -> Text
availabilityZone) (\s :: InstanceEntry
s@InstanceEntry' {} Text
a -> InstanceEntry
s {$sel:availabilityZone:InstanceEntry' :: Text
availabilityZone = Text
a} :: InstanceEntry)

instance Prelude.Hashable InstanceEntry

instance Prelude.NFData InstanceEntry

instance Core.ToJSON InstanceEntry where
  toJSON :: InstanceEntry -> Value
toJSON InstanceEntry' {Maybe Text
Text
PortInfoSourceType
availabilityZone :: Text
portInfoSource :: PortInfoSourceType
instanceType :: Text
sourceName :: Text
userData :: Maybe Text
$sel:availabilityZone:InstanceEntry' :: InstanceEntry -> Text
$sel:portInfoSource:InstanceEntry' :: InstanceEntry -> PortInfoSourceType
$sel:instanceType:InstanceEntry' :: InstanceEntry -> Text
$sel:sourceName:InstanceEntry' :: InstanceEntry -> Text
$sel:userData:InstanceEntry' :: InstanceEntry -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"userData" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
userData,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"sourceName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
sourceName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"instanceType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
instanceType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"portInfoSource" Text -> PortInfoSourceType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= PortInfoSourceType
portInfoSource),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"availabilityZone" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
availabilityZone)
          ]
      )