{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.CreateInstances
-- 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)
--
-- Creates one or more Amazon Lightsail instances.
--
-- The @create instances@ operation supports tag-based access control via
-- request tags. For more information, see the
-- <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-controlling-access-using-tags Lightsail Developer Guide>.
module Amazonka.Lightsail.CreateInstances
  ( -- * Creating a Request
    CreateInstances (..),
    newCreateInstances,

    -- * Request Lenses
    createInstances_customImageName,
    createInstances_addOns,
    createInstances_userData,
    createInstances_ipAddressType,
    createInstances_keyPairName,
    createInstances_tags,
    createInstances_instanceNames,
    createInstances_availabilityZone,
    createInstances_blueprintId,
    createInstances_bundleId,

    -- * Destructuring the Response
    CreateInstancesResponse (..),
    newCreateInstancesResponse,

    -- * Response Lenses
    createInstancesResponse_operations,
    createInstancesResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Lightsail.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newCreateInstances' smart constructor.
data CreateInstances = CreateInstances'
  { -- | (Deprecated) The name for your custom image.
    --
    -- In releases prior to June 12, 2017, this parameter was ignored by the
    -- API. It is now deprecated.
    CreateInstances -> Maybe Text
customImageName :: Prelude.Maybe Prelude.Text,
    -- | An array of objects representing the add-ons to enable for the new
    -- instance.
    CreateInstances -> Maybe [AddOnRequest]
addOns :: Prelude.Maybe [AddOnRequest],
    -- | 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@. For a complete list, see
    -- the
    -- <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/compare-options-choose-lightsail-instance-image Amazon Lightsail Developer Guide>.
    CreateInstances -> Maybe Text
userData :: Prelude.Maybe Prelude.Text,
    -- | The IP address type for the instance.
    --
    -- The possible values are @ipv4@ for IPv4 only, and @dualstack@ for IPv4
    -- and IPv6.
    --
    -- The default value is @dualstack@.
    CreateInstances -> Maybe IpAddressType
ipAddressType :: Prelude.Maybe IpAddressType,
    -- | The name of your key pair.
    CreateInstances -> Maybe Text
keyPairName :: Prelude.Maybe Prelude.Text,
    -- | The tag keys and optional values to add to the resource during create.
    --
    -- Use the @TagResource@ action to tag a resource after it\'s created.
    CreateInstances -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The names to use for your new Lightsail instances. Separate multiple
    -- values using quotation marks and commas, for example:
    -- @[\"MyFirstInstance\",\"MySecondInstance\"]@
    CreateInstances -> [Text]
instanceNames :: [Prelude.Text],
    -- | The Availability Zone in which to create your instance. Use the
    -- following format: @us-east-2a@ (case sensitive). You can get a list of
    -- Availability Zones by using the
    -- <http://docs.aws.amazon.com/lightsail/2016-11-28/api-reference/API_GetRegions.html get regions>
    -- operation. Be sure to add the @include Availability Zones@ parameter to
    -- your request.
    CreateInstances -> Text
availabilityZone :: Prelude.Text,
    -- | The ID for a virtual private server image (e.g., @app_wordpress_4_4@ or
    -- @app_lamp_7_0@). Use the @get blueprints@ operation to return a list of
    -- available images (or /blueprints/).
    --
    -- Use active blueprints when creating new instances. Inactive blueprints
    -- are listed to support customers with existing instances and are not
    -- necessarily available to create new instances. Blueprints are marked
    -- inactive when they become outdated due to operating system updates or
    -- new application releases.
    CreateInstances -> Text
blueprintId :: Prelude.Text,
    -- | The bundle of specification information for your virtual private server
    -- (or /instance/), including the pricing plan (e.g., @micro_1_0@).
    CreateInstances -> Text
bundleId :: Prelude.Text
  }
  deriving (CreateInstances -> CreateInstances -> Bool
(CreateInstances -> CreateInstances -> Bool)
-> (CreateInstances -> CreateInstances -> Bool)
-> Eq CreateInstances
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateInstances -> CreateInstances -> Bool
$c/= :: CreateInstances -> CreateInstances -> Bool
== :: CreateInstances -> CreateInstances -> Bool
$c== :: CreateInstances -> CreateInstances -> Bool
Prelude.Eq, ReadPrec [CreateInstances]
ReadPrec CreateInstances
Int -> ReadS CreateInstances
ReadS [CreateInstances]
(Int -> ReadS CreateInstances)
-> ReadS [CreateInstances]
-> ReadPrec CreateInstances
-> ReadPrec [CreateInstances]
-> Read CreateInstances
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateInstances]
$creadListPrec :: ReadPrec [CreateInstances]
readPrec :: ReadPrec CreateInstances
$creadPrec :: ReadPrec CreateInstances
readList :: ReadS [CreateInstances]
$creadList :: ReadS [CreateInstances]
readsPrec :: Int -> ReadS CreateInstances
$creadsPrec :: Int -> ReadS CreateInstances
Prelude.Read, Int -> CreateInstances -> ShowS
[CreateInstances] -> ShowS
CreateInstances -> String
(Int -> CreateInstances -> ShowS)
-> (CreateInstances -> String)
-> ([CreateInstances] -> ShowS)
-> Show CreateInstances
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateInstances] -> ShowS
$cshowList :: [CreateInstances] -> ShowS
show :: CreateInstances -> String
$cshow :: CreateInstances -> String
showsPrec :: Int -> CreateInstances -> ShowS
$cshowsPrec :: Int -> CreateInstances -> ShowS
Prelude.Show, (forall x. CreateInstances -> Rep CreateInstances x)
-> (forall x. Rep CreateInstances x -> CreateInstances)
-> Generic CreateInstances
forall x. Rep CreateInstances x -> CreateInstances
forall x. CreateInstances -> Rep CreateInstances x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateInstances x -> CreateInstances
$cfrom :: forall x. CreateInstances -> Rep CreateInstances x
Prelude.Generic)

-- |
-- Create a value of 'CreateInstances' 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:
--
-- 'customImageName', 'createInstances_customImageName' - (Deprecated) The name for your custom image.
--
-- In releases prior to June 12, 2017, this parameter was ignored by the
-- API. It is now deprecated.
--
-- 'addOns', 'createInstances_addOns' - An array of objects representing the add-ons to enable for the new
-- instance.
--
-- 'userData', 'createInstances_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@. For a complete list, see
-- the
-- <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/compare-options-choose-lightsail-instance-image Amazon Lightsail Developer Guide>.
--
-- 'ipAddressType', 'createInstances_ipAddressType' - The IP address type for the instance.
--
-- The possible values are @ipv4@ for IPv4 only, and @dualstack@ for IPv4
-- and IPv6.
--
-- The default value is @dualstack@.
--
-- 'keyPairName', 'createInstances_keyPairName' - The name of your key pair.
--
-- 'tags', 'createInstances_tags' - The tag keys and optional values to add to the resource during create.
--
-- Use the @TagResource@ action to tag a resource after it\'s created.
--
-- 'instanceNames', 'createInstances_instanceNames' - The names to use for your new Lightsail instances. Separate multiple
-- values using quotation marks and commas, for example:
-- @[\"MyFirstInstance\",\"MySecondInstance\"]@
--
-- 'availabilityZone', 'createInstances_availabilityZone' - The Availability Zone in which to create your instance. Use the
-- following format: @us-east-2a@ (case sensitive). You can get a list of
-- Availability Zones by using the
-- <http://docs.aws.amazon.com/lightsail/2016-11-28/api-reference/API_GetRegions.html get regions>
-- operation. Be sure to add the @include Availability Zones@ parameter to
-- your request.
--
-- 'blueprintId', 'createInstances_blueprintId' - The ID for a virtual private server image (e.g., @app_wordpress_4_4@ or
-- @app_lamp_7_0@). Use the @get blueprints@ operation to return a list of
-- available images (or /blueprints/).
--
-- Use active blueprints when creating new instances. Inactive blueprints
-- are listed to support customers with existing instances and are not
-- necessarily available to create new instances. Blueprints are marked
-- inactive when they become outdated due to operating system updates or
-- new application releases.
--
-- 'bundleId', 'createInstances_bundleId' - The bundle of specification information for your virtual private server
-- (or /instance/), including the pricing plan (e.g., @micro_1_0@).
newCreateInstances ::
  -- | 'availabilityZone'
  Prelude.Text ->
  -- | 'blueprintId'
  Prelude.Text ->
  -- | 'bundleId'
  Prelude.Text ->
  CreateInstances
newCreateInstances :: Text -> Text -> Text -> CreateInstances
newCreateInstances
  Text
pAvailabilityZone_
  Text
pBlueprintId_
  Text
pBundleId_ =
    CreateInstances' :: Maybe Text
-> Maybe [AddOnRequest]
-> Maybe Text
-> Maybe IpAddressType
-> Maybe Text
-> Maybe [Tag]
-> [Text]
-> Text
-> Text
-> Text
-> CreateInstances
CreateInstances'
      { $sel:customImageName:CreateInstances' :: Maybe Text
customImageName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:addOns:CreateInstances' :: Maybe [AddOnRequest]
addOns = Maybe [AddOnRequest]
forall a. Maybe a
Prelude.Nothing,
        $sel:userData:CreateInstances' :: Maybe Text
userData = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:ipAddressType:CreateInstances' :: Maybe IpAddressType
ipAddressType = Maybe IpAddressType
forall a. Maybe a
Prelude.Nothing,
        $sel:keyPairName:CreateInstances' :: Maybe Text
keyPairName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateInstances' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
        $sel:instanceNames:CreateInstances' :: [Text]
instanceNames = [Text]
forall a. Monoid a => a
Prelude.mempty,
        $sel:availabilityZone:CreateInstances' :: Text
availabilityZone = Text
pAvailabilityZone_,
        $sel:blueprintId:CreateInstances' :: Text
blueprintId = Text
pBlueprintId_,
        $sel:bundleId:CreateInstances' :: Text
bundleId = Text
pBundleId_
      }

-- | (Deprecated) The name for your custom image.
--
-- In releases prior to June 12, 2017, this parameter was ignored by the
-- API. It is now deprecated.
createInstances_customImageName :: Lens.Lens' CreateInstances (Prelude.Maybe Prelude.Text)
createInstances_customImageName :: (Maybe Text -> f (Maybe Text))
-> CreateInstances -> f CreateInstances
createInstances_customImageName = (CreateInstances -> Maybe Text)
-> (CreateInstances -> Maybe Text -> CreateInstances)
-> Lens CreateInstances CreateInstances (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInstances' {Maybe Text
customImageName :: Maybe Text
$sel:customImageName:CreateInstances' :: CreateInstances -> Maybe Text
customImageName} -> Maybe Text
customImageName) (\s :: CreateInstances
s@CreateInstances' {} Maybe Text
a -> CreateInstances
s {$sel:customImageName:CreateInstances' :: Maybe Text
customImageName = Maybe Text
a} :: CreateInstances)

-- | An array of objects representing the add-ons to enable for the new
-- instance.
createInstances_addOns :: Lens.Lens' CreateInstances (Prelude.Maybe [AddOnRequest])
createInstances_addOns :: (Maybe [AddOnRequest] -> f (Maybe [AddOnRequest]))
-> CreateInstances -> f CreateInstances
createInstances_addOns = (CreateInstances -> Maybe [AddOnRequest])
-> (CreateInstances -> Maybe [AddOnRequest] -> CreateInstances)
-> Lens
     CreateInstances
     CreateInstances
     (Maybe [AddOnRequest])
     (Maybe [AddOnRequest])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInstances' {Maybe [AddOnRequest]
addOns :: Maybe [AddOnRequest]
$sel:addOns:CreateInstances' :: CreateInstances -> Maybe [AddOnRequest]
addOns} -> Maybe [AddOnRequest]
addOns) (\s :: CreateInstances
s@CreateInstances' {} Maybe [AddOnRequest]
a -> CreateInstances
s {$sel:addOns:CreateInstances' :: Maybe [AddOnRequest]
addOns = Maybe [AddOnRequest]
a} :: CreateInstances) ((Maybe [AddOnRequest] -> f (Maybe [AddOnRequest]))
 -> CreateInstances -> f CreateInstances)
-> ((Maybe [AddOnRequest] -> f (Maybe [AddOnRequest]))
    -> Maybe [AddOnRequest] -> f (Maybe [AddOnRequest]))
-> (Maybe [AddOnRequest] -> f (Maybe [AddOnRequest]))
-> CreateInstances
-> f CreateInstances
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [AddOnRequest] [AddOnRequest] [AddOnRequest] [AddOnRequest]
-> Iso
     (Maybe [AddOnRequest])
     (Maybe [AddOnRequest])
     (Maybe [AddOnRequest])
     (Maybe [AddOnRequest])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [AddOnRequest] [AddOnRequest] [AddOnRequest] [AddOnRequest]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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@. For a complete list, see
-- the
-- <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/compare-options-choose-lightsail-instance-image Amazon Lightsail Developer Guide>.
createInstances_userData :: Lens.Lens' CreateInstances (Prelude.Maybe Prelude.Text)
createInstances_userData :: (Maybe Text -> f (Maybe Text))
-> CreateInstances -> f CreateInstances
createInstances_userData = (CreateInstances -> Maybe Text)
-> (CreateInstances -> Maybe Text -> CreateInstances)
-> Lens CreateInstances CreateInstances (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInstances' {Maybe Text
userData :: Maybe Text
$sel:userData:CreateInstances' :: CreateInstances -> Maybe Text
userData} -> Maybe Text
userData) (\s :: CreateInstances
s@CreateInstances' {} Maybe Text
a -> CreateInstances
s {$sel:userData:CreateInstances' :: Maybe Text
userData = Maybe Text
a} :: CreateInstances)

-- | The IP address type for the instance.
--
-- The possible values are @ipv4@ for IPv4 only, and @dualstack@ for IPv4
-- and IPv6.
--
-- The default value is @dualstack@.
createInstances_ipAddressType :: Lens.Lens' CreateInstances (Prelude.Maybe IpAddressType)
createInstances_ipAddressType :: (Maybe IpAddressType -> f (Maybe IpAddressType))
-> CreateInstances -> f CreateInstances
createInstances_ipAddressType = (CreateInstances -> Maybe IpAddressType)
-> (CreateInstances -> Maybe IpAddressType -> CreateInstances)
-> Lens
     CreateInstances
     CreateInstances
     (Maybe IpAddressType)
     (Maybe IpAddressType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInstances' {Maybe IpAddressType
ipAddressType :: Maybe IpAddressType
$sel:ipAddressType:CreateInstances' :: CreateInstances -> Maybe IpAddressType
ipAddressType} -> Maybe IpAddressType
ipAddressType) (\s :: CreateInstances
s@CreateInstances' {} Maybe IpAddressType
a -> CreateInstances
s {$sel:ipAddressType:CreateInstances' :: Maybe IpAddressType
ipAddressType = Maybe IpAddressType
a} :: CreateInstances)

-- | The name of your key pair.
createInstances_keyPairName :: Lens.Lens' CreateInstances (Prelude.Maybe Prelude.Text)
createInstances_keyPairName :: (Maybe Text -> f (Maybe Text))
-> CreateInstances -> f CreateInstances
createInstances_keyPairName = (CreateInstances -> Maybe Text)
-> (CreateInstances -> Maybe Text -> CreateInstances)
-> Lens CreateInstances CreateInstances (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInstances' {Maybe Text
keyPairName :: Maybe Text
$sel:keyPairName:CreateInstances' :: CreateInstances -> Maybe Text
keyPairName} -> Maybe Text
keyPairName) (\s :: CreateInstances
s@CreateInstances' {} Maybe Text
a -> CreateInstances
s {$sel:keyPairName:CreateInstances' :: Maybe Text
keyPairName = Maybe Text
a} :: CreateInstances)

-- | The tag keys and optional values to add to the resource during create.
--
-- Use the @TagResource@ action to tag a resource after it\'s created.
createInstances_tags :: Lens.Lens' CreateInstances (Prelude.Maybe [Tag])
createInstances_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateInstances -> f CreateInstances
createInstances_tags = (CreateInstances -> Maybe [Tag])
-> (CreateInstances -> Maybe [Tag] -> CreateInstances)
-> Lens CreateInstances CreateInstances (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInstances' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateInstances' :: CreateInstances -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateInstances
s@CreateInstances' {} Maybe [Tag]
a -> CreateInstances
s {$sel:tags:CreateInstances' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateInstances) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> CreateInstances -> f CreateInstances)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateInstances
-> f CreateInstances
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The names to use for your new Lightsail instances. Separate multiple
-- values using quotation marks and commas, for example:
-- @[\"MyFirstInstance\",\"MySecondInstance\"]@
createInstances_instanceNames :: Lens.Lens' CreateInstances [Prelude.Text]
createInstances_instanceNames :: ([Text] -> f [Text]) -> CreateInstances -> f CreateInstances
createInstances_instanceNames = (CreateInstances -> [Text])
-> (CreateInstances -> [Text] -> CreateInstances)
-> Lens CreateInstances CreateInstances [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInstances' {[Text]
instanceNames :: [Text]
$sel:instanceNames:CreateInstances' :: CreateInstances -> [Text]
instanceNames} -> [Text]
instanceNames) (\s :: CreateInstances
s@CreateInstances' {} [Text]
a -> CreateInstances
s {$sel:instanceNames:CreateInstances' :: [Text]
instanceNames = [Text]
a} :: CreateInstances) (([Text] -> f [Text]) -> CreateInstances -> f CreateInstances)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> CreateInstances
-> f CreateInstances
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Availability Zone in which to create your instance. Use the
-- following format: @us-east-2a@ (case sensitive). You can get a list of
-- Availability Zones by using the
-- <http://docs.aws.amazon.com/lightsail/2016-11-28/api-reference/API_GetRegions.html get regions>
-- operation. Be sure to add the @include Availability Zones@ parameter to
-- your request.
createInstances_availabilityZone :: Lens.Lens' CreateInstances Prelude.Text
createInstances_availabilityZone :: (Text -> f Text) -> CreateInstances -> f CreateInstances
createInstances_availabilityZone = (CreateInstances -> Text)
-> (CreateInstances -> Text -> CreateInstances)
-> Lens CreateInstances CreateInstances Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInstances' {Text
availabilityZone :: Text
$sel:availabilityZone:CreateInstances' :: CreateInstances -> Text
availabilityZone} -> Text
availabilityZone) (\s :: CreateInstances
s@CreateInstances' {} Text
a -> CreateInstances
s {$sel:availabilityZone:CreateInstances' :: Text
availabilityZone = Text
a} :: CreateInstances)

-- | The ID for a virtual private server image (e.g., @app_wordpress_4_4@ or
-- @app_lamp_7_0@). Use the @get blueprints@ operation to return a list of
-- available images (or /blueprints/).
--
-- Use active blueprints when creating new instances. Inactive blueprints
-- are listed to support customers with existing instances and are not
-- necessarily available to create new instances. Blueprints are marked
-- inactive when they become outdated due to operating system updates or
-- new application releases.
createInstances_blueprintId :: Lens.Lens' CreateInstances Prelude.Text
createInstances_blueprintId :: (Text -> f Text) -> CreateInstances -> f CreateInstances
createInstances_blueprintId = (CreateInstances -> Text)
-> (CreateInstances -> Text -> CreateInstances)
-> Lens CreateInstances CreateInstances Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInstances' {Text
blueprintId :: Text
$sel:blueprintId:CreateInstances' :: CreateInstances -> Text
blueprintId} -> Text
blueprintId) (\s :: CreateInstances
s@CreateInstances' {} Text
a -> CreateInstances
s {$sel:blueprintId:CreateInstances' :: Text
blueprintId = Text
a} :: CreateInstances)

-- | The bundle of specification information for your virtual private server
-- (or /instance/), including the pricing plan (e.g., @micro_1_0@).
createInstances_bundleId :: Lens.Lens' CreateInstances Prelude.Text
createInstances_bundleId :: (Text -> f Text) -> CreateInstances -> f CreateInstances
createInstances_bundleId = (CreateInstances -> Text)
-> (CreateInstances -> Text -> CreateInstances)
-> Lens CreateInstances CreateInstances Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInstances' {Text
bundleId :: Text
$sel:bundleId:CreateInstances' :: CreateInstances -> Text
bundleId} -> Text
bundleId) (\s :: CreateInstances
s@CreateInstances' {} Text
a -> CreateInstances
s {$sel:bundleId:CreateInstances' :: Text
bundleId = Text
a} :: CreateInstances)

instance Core.AWSRequest CreateInstances where
  type
    AWSResponse CreateInstances =
      CreateInstancesResponse
  request :: CreateInstances -> Request CreateInstances
request = Service -> CreateInstances -> Request CreateInstances
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateInstances
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateInstances)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateInstances))
-> Logger
-> Service
-> Proxy CreateInstances
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateInstances)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Operation] -> Int -> CreateInstancesResponse
CreateInstancesResponse'
            (Maybe [Operation] -> Int -> CreateInstancesResponse)
-> Either String (Maybe [Operation])
-> Either String (Int -> CreateInstancesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Operation]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"operations" Either String (Maybe (Maybe [Operation]))
-> Maybe [Operation] -> Either String (Maybe [Operation])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Operation]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> CreateInstancesResponse)
-> Either String Int -> Either String CreateInstancesResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreateInstances

instance Prelude.NFData CreateInstances

instance Core.ToHeaders CreateInstances where
  toHeaders :: CreateInstances -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateInstances -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"Lightsail_20161128.CreateInstances" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON CreateInstances where
  toJSON :: CreateInstances -> Value
toJSON CreateInstances' {[Text]
Maybe [AddOnRequest]
Maybe [Tag]
Maybe Text
Maybe IpAddressType
Text
bundleId :: Text
blueprintId :: Text
availabilityZone :: Text
instanceNames :: [Text]
tags :: Maybe [Tag]
keyPairName :: Maybe Text
ipAddressType :: Maybe IpAddressType
userData :: Maybe Text
addOns :: Maybe [AddOnRequest]
customImageName :: Maybe Text
$sel:bundleId:CreateInstances' :: CreateInstances -> Text
$sel:blueprintId:CreateInstances' :: CreateInstances -> Text
$sel:availabilityZone:CreateInstances' :: CreateInstances -> Text
$sel:instanceNames:CreateInstances' :: CreateInstances -> [Text]
$sel:tags:CreateInstances' :: CreateInstances -> Maybe [Tag]
$sel:keyPairName:CreateInstances' :: CreateInstances -> Maybe Text
$sel:ipAddressType:CreateInstances' :: CreateInstances -> Maybe IpAddressType
$sel:userData:CreateInstances' :: CreateInstances -> Maybe Text
$sel:addOns:CreateInstances' :: CreateInstances -> Maybe [AddOnRequest]
$sel:customImageName:CreateInstances' :: CreateInstances -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"customImageName" 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
customImageName,
            (Text
"addOns" Text -> [AddOnRequest] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([AddOnRequest] -> Pair) -> Maybe [AddOnRequest] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [AddOnRequest]
addOns,
            (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,
            (Text
"ipAddressType" Text -> IpAddressType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (IpAddressType -> Pair) -> Maybe IpAddressType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe IpAddressType
ipAddressType,
            (Text
"keyPairName" 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
keyPairName,
            (Text
"tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"instanceNames" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
instanceNames),
            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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"blueprintId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
blueprintId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"bundleId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
bundleId)
          ]
      )

instance Core.ToPath CreateInstances where
  toPath :: CreateInstances -> ByteString
toPath = ByteString -> CreateInstances -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery CreateInstances where
  toQuery :: CreateInstances -> QueryString
toQuery = QueryString -> CreateInstances -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newCreateInstancesResponse' smart constructor.
data CreateInstancesResponse = CreateInstancesResponse'
  { -- | An array of objects that describe the result of the action, such as the
    -- status of the request, the timestamp of the request, and the resources
    -- affected by the request.
    CreateInstancesResponse -> Maybe [Operation]
operations :: Prelude.Maybe [Operation],
    -- | The response's http status code.
    CreateInstancesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateInstancesResponse -> CreateInstancesResponse -> Bool
(CreateInstancesResponse -> CreateInstancesResponse -> Bool)
-> (CreateInstancesResponse -> CreateInstancesResponse -> Bool)
-> Eq CreateInstancesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateInstancesResponse -> CreateInstancesResponse -> Bool
$c/= :: CreateInstancesResponse -> CreateInstancesResponse -> Bool
== :: CreateInstancesResponse -> CreateInstancesResponse -> Bool
$c== :: CreateInstancesResponse -> CreateInstancesResponse -> Bool
Prelude.Eq, ReadPrec [CreateInstancesResponse]
ReadPrec CreateInstancesResponse
Int -> ReadS CreateInstancesResponse
ReadS [CreateInstancesResponse]
(Int -> ReadS CreateInstancesResponse)
-> ReadS [CreateInstancesResponse]
-> ReadPrec CreateInstancesResponse
-> ReadPrec [CreateInstancesResponse]
-> Read CreateInstancesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateInstancesResponse]
$creadListPrec :: ReadPrec [CreateInstancesResponse]
readPrec :: ReadPrec CreateInstancesResponse
$creadPrec :: ReadPrec CreateInstancesResponse
readList :: ReadS [CreateInstancesResponse]
$creadList :: ReadS [CreateInstancesResponse]
readsPrec :: Int -> ReadS CreateInstancesResponse
$creadsPrec :: Int -> ReadS CreateInstancesResponse
Prelude.Read, Int -> CreateInstancesResponse -> ShowS
[CreateInstancesResponse] -> ShowS
CreateInstancesResponse -> String
(Int -> CreateInstancesResponse -> ShowS)
-> (CreateInstancesResponse -> String)
-> ([CreateInstancesResponse] -> ShowS)
-> Show CreateInstancesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateInstancesResponse] -> ShowS
$cshowList :: [CreateInstancesResponse] -> ShowS
show :: CreateInstancesResponse -> String
$cshow :: CreateInstancesResponse -> String
showsPrec :: Int -> CreateInstancesResponse -> ShowS
$cshowsPrec :: Int -> CreateInstancesResponse -> ShowS
Prelude.Show, (forall x.
 CreateInstancesResponse -> Rep CreateInstancesResponse x)
-> (forall x.
    Rep CreateInstancesResponse x -> CreateInstancesResponse)
-> Generic CreateInstancesResponse
forall x. Rep CreateInstancesResponse x -> CreateInstancesResponse
forall x. CreateInstancesResponse -> Rep CreateInstancesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateInstancesResponse x -> CreateInstancesResponse
$cfrom :: forall x. CreateInstancesResponse -> Rep CreateInstancesResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateInstancesResponse' 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:
--
-- 'operations', 'createInstancesResponse_operations' - An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
--
-- 'httpStatus', 'createInstancesResponse_httpStatus' - The response's http status code.
newCreateInstancesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateInstancesResponse
newCreateInstancesResponse :: Int -> CreateInstancesResponse
newCreateInstancesResponse Int
pHttpStatus_ =
  CreateInstancesResponse' :: Maybe [Operation] -> Int -> CreateInstancesResponse
CreateInstancesResponse'
    { $sel:operations:CreateInstancesResponse' :: Maybe [Operation]
operations =
        Maybe [Operation]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateInstancesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
createInstancesResponse_operations :: Lens.Lens' CreateInstancesResponse (Prelude.Maybe [Operation])
createInstancesResponse_operations :: (Maybe [Operation] -> f (Maybe [Operation]))
-> CreateInstancesResponse -> f CreateInstancesResponse
createInstancesResponse_operations = (CreateInstancesResponse -> Maybe [Operation])
-> (CreateInstancesResponse
    -> Maybe [Operation] -> CreateInstancesResponse)
-> Lens
     CreateInstancesResponse
     CreateInstancesResponse
     (Maybe [Operation])
     (Maybe [Operation])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInstancesResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:CreateInstancesResponse' :: CreateInstancesResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: CreateInstancesResponse
s@CreateInstancesResponse' {} Maybe [Operation]
a -> CreateInstancesResponse
s {$sel:operations:CreateInstancesResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: CreateInstancesResponse) ((Maybe [Operation] -> f (Maybe [Operation]))
 -> CreateInstancesResponse -> f CreateInstancesResponse)
-> ((Maybe [Operation] -> f (Maybe [Operation]))
    -> Maybe [Operation] -> f (Maybe [Operation]))
-> (Maybe [Operation] -> f (Maybe [Operation]))
-> CreateInstancesResponse
-> f CreateInstancesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Operation] [Operation] [Operation] [Operation]
-> Iso
     (Maybe [Operation])
     (Maybe [Operation])
     (Maybe [Operation])
     (Maybe [Operation])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Operation] [Operation] [Operation] [Operation]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
createInstancesResponse_httpStatus :: Lens.Lens' CreateInstancesResponse Prelude.Int
createInstancesResponse_httpStatus :: (Int -> f Int)
-> CreateInstancesResponse -> f CreateInstancesResponse
createInstancesResponse_httpStatus = (CreateInstancesResponse -> Int)
-> (CreateInstancesResponse -> Int -> CreateInstancesResponse)
-> Lens CreateInstancesResponse CreateInstancesResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInstancesResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateInstancesResponse' :: CreateInstancesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateInstancesResponse
s@CreateInstancesResponse' {} Int
a -> CreateInstancesResponse
s {$sel:httpStatus:CreateInstancesResponse' :: Int
httpStatus = Int
a} :: CreateInstancesResponse)

instance Prelude.NFData CreateInstancesResponse