{-# 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.CreateLoadBalancer
-- 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 a Lightsail load balancer. To learn more about deciding whether
-- to load balance your application, see
-- <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/configure-lightsail-instances-for-load-balancing Configure your Lightsail instances for load balancing>.
-- You can create up to 5 load balancers per AWS Region in your account.
--
-- When you create a load balancer, you can specify a unique name and port
-- settings. To change additional load balancer settings, use the
-- @UpdateLoadBalancerAttribute@ operation.
--
-- The @create load balancer@ 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 Amazon Lightsail Developer Guide>.
module Amazonka.Lightsail.CreateLoadBalancer
  ( -- * Creating a Request
    CreateLoadBalancer (..),
    newCreateLoadBalancer,

    -- * Request Lenses
    createLoadBalancer_healthCheckPath,
    createLoadBalancer_certificateName,
    createLoadBalancer_certificateDomainName,
    createLoadBalancer_certificateAlternativeNames,
    createLoadBalancer_ipAddressType,
    createLoadBalancer_tags,
    createLoadBalancer_loadBalancerName,
    createLoadBalancer_instancePort,

    -- * Destructuring the Response
    CreateLoadBalancerResponse (..),
    newCreateLoadBalancerResponse,

    -- * Response Lenses
    createLoadBalancerResponse_operations,
    createLoadBalancerResponse_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:/ 'newCreateLoadBalancer' smart constructor.
data CreateLoadBalancer = CreateLoadBalancer'
  { -- | The path you provided to perform the load balancer health check. If you
    -- didn\'t specify a health check path, Lightsail uses the root path of
    -- your website (e.g., @\"\/\"@).
    --
    -- You may want to specify a custom health check path other than the root
    -- of your application if your home page loads slowly or has a lot of media
    -- or scripting on it.
    CreateLoadBalancer -> Maybe Text
healthCheckPath :: Prelude.Maybe Prelude.Text,
    -- | The name of the SSL\/TLS certificate.
    --
    -- If you specify @certificateName@, then @certificateDomainName@ is
    -- required (and vice-versa).
    CreateLoadBalancer -> Maybe Text
certificateName :: Prelude.Maybe Prelude.Text,
    -- | The domain name with which your certificate is associated (e.g.,
    -- @example.com@).
    --
    -- If you specify @certificateDomainName@, then @certificateName@ is
    -- required (and vice-versa).
    CreateLoadBalancer -> Maybe Text
certificateDomainName :: Prelude.Maybe Prelude.Text,
    -- | The optional alternative domains and subdomains to use with your
    -- SSL\/TLS certificate (e.g., @www.example.com@, @example.com@,
    -- @m.example.com@, @blog.example.com@).
    CreateLoadBalancer -> Maybe [Text]
certificateAlternativeNames :: Prelude.Maybe [Prelude.Text],
    -- | The IP address type for the load balancer.
    --
    -- The possible values are @ipv4@ for IPv4 only, and @dualstack@ for IPv4
    -- and IPv6.
    --
    -- The default value is @dualstack@.
    CreateLoadBalancer -> Maybe IpAddressType
ipAddressType :: Prelude.Maybe IpAddressType,
    -- | 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.
    CreateLoadBalancer -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The name of your load balancer.
    CreateLoadBalancer -> Text
loadBalancerName :: Prelude.Text,
    -- | The instance port where you\'re creating your load balancer.
    CreateLoadBalancer -> Int
instancePort :: Prelude.Int
  }
  deriving (CreateLoadBalancer -> CreateLoadBalancer -> Bool
(CreateLoadBalancer -> CreateLoadBalancer -> Bool)
-> (CreateLoadBalancer -> CreateLoadBalancer -> Bool)
-> Eq CreateLoadBalancer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateLoadBalancer -> CreateLoadBalancer -> Bool
$c/= :: CreateLoadBalancer -> CreateLoadBalancer -> Bool
== :: CreateLoadBalancer -> CreateLoadBalancer -> Bool
$c== :: CreateLoadBalancer -> CreateLoadBalancer -> Bool
Prelude.Eq, ReadPrec [CreateLoadBalancer]
ReadPrec CreateLoadBalancer
Int -> ReadS CreateLoadBalancer
ReadS [CreateLoadBalancer]
(Int -> ReadS CreateLoadBalancer)
-> ReadS [CreateLoadBalancer]
-> ReadPrec CreateLoadBalancer
-> ReadPrec [CreateLoadBalancer]
-> Read CreateLoadBalancer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateLoadBalancer]
$creadListPrec :: ReadPrec [CreateLoadBalancer]
readPrec :: ReadPrec CreateLoadBalancer
$creadPrec :: ReadPrec CreateLoadBalancer
readList :: ReadS [CreateLoadBalancer]
$creadList :: ReadS [CreateLoadBalancer]
readsPrec :: Int -> ReadS CreateLoadBalancer
$creadsPrec :: Int -> ReadS CreateLoadBalancer
Prelude.Read, Int -> CreateLoadBalancer -> ShowS
[CreateLoadBalancer] -> ShowS
CreateLoadBalancer -> String
(Int -> CreateLoadBalancer -> ShowS)
-> (CreateLoadBalancer -> String)
-> ([CreateLoadBalancer] -> ShowS)
-> Show CreateLoadBalancer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateLoadBalancer] -> ShowS
$cshowList :: [CreateLoadBalancer] -> ShowS
show :: CreateLoadBalancer -> String
$cshow :: CreateLoadBalancer -> String
showsPrec :: Int -> CreateLoadBalancer -> ShowS
$cshowsPrec :: Int -> CreateLoadBalancer -> ShowS
Prelude.Show, (forall x. CreateLoadBalancer -> Rep CreateLoadBalancer x)
-> (forall x. Rep CreateLoadBalancer x -> CreateLoadBalancer)
-> Generic CreateLoadBalancer
forall x. Rep CreateLoadBalancer x -> CreateLoadBalancer
forall x. CreateLoadBalancer -> Rep CreateLoadBalancer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateLoadBalancer x -> CreateLoadBalancer
$cfrom :: forall x. CreateLoadBalancer -> Rep CreateLoadBalancer x
Prelude.Generic)

-- |
-- Create a value of 'CreateLoadBalancer' 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:
--
-- 'healthCheckPath', 'createLoadBalancer_healthCheckPath' - The path you provided to perform the load balancer health check. If you
-- didn\'t specify a health check path, Lightsail uses the root path of
-- your website (e.g., @\"\/\"@).
--
-- You may want to specify a custom health check path other than the root
-- of your application if your home page loads slowly or has a lot of media
-- or scripting on it.
--
-- 'certificateName', 'createLoadBalancer_certificateName' - The name of the SSL\/TLS certificate.
--
-- If you specify @certificateName@, then @certificateDomainName@ is
-- required (and vice-versa).
--
-- 'certificateDomainName', 'createLoadBalancer_certificateDomainName' - The domain name with which your certificate is associated (e.g.,
-- @example.com@).
--
-- If you specify @certificateDomainName@, then @certificateName@ is
-- required (and vice-versa).
--
-- 'certificateAlternativeNames', 'createLoadBalancer_certificateAlternativeNames' - The optional alternative domains and subdomains to use with your
-- SSL\/TLS certificate (e.g., @www.example.com@, @example.com@,
-- @m.example.com@, @blog.example.com@).
--
-- 'ipAddressType', 'createLoadBalancer_ipAddressType' - The IP address type for the load balancer.
--
-- The possible values are @ipv4@ for IPv4 only, and @dualstack@ for IPv4
-- and IPv6.
--
-- The default value is @dualstack@.
--
-- 'tags', 'createLoadBalancer_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.
--
-- 'loadBalancerName', 'createLoadBalancer_loadBalancerName' - The name of your load balancer.
--
-- 'instancePort', 'createLoadBalancer_instancePort' - The instance port where you\'re creating your load balancer.
newCreateLoadBalancer ::
  -- | 'loadBalancerName'
  Prelude.Text ->
  -- | 'instancePort'
  Prelude.Int ->
  CreateLoadBalancer
newCreateLoadBalancer :: Text -> Int -> CreateLoadBalancer
newCreateLoadBalancer
  Text
pLoadBalancerName_
  Int
pInstancePort_ =
    CreateLoadBalancer' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe IpAddressType
-> Maybe [Tag]
-> Text
-> Int
-> CreateLoadBalancer
CreateLoadBalancer'
      { $sel:healthCheckPath:CreateLoadBalancer' :: Maybe Text
healthCheckPath =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:certificateName:CreateLoadBalancer' :: Maybe Text
certificateName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:certificateDomainName:CreateLoadBalancer' :: Maybe Text
certificateDomainName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:certificateAlternativeNames:CreateLoadBalancer' :: Maybe [Text]
certificateAlternativeNames = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:ipAddressType:CreateLoadBalancer' :: Maybe IpAddressType
ipAddressType = Maybe IpAddressType
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateLoadBalancer' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
        $sel:loadBalancerName:CreateLoadBalancer' :: Text
loadBalancerName = Text
pLoadBalancerName_,
        $sel:instancePort:CreateLoadBalancer' :: Int
instancePort = Int
pInstancePort_
      }

-- | The path you provided to perform the load balancer health check. If you
-- didn\'t specify a health check path, Lightsail uses the root path of
-- your website (e.g., @\"\/\"@).
--
-- You may want to specify a custom health check path other than the root
-- of your application if your home page loads slowly or has a lot of media
-- or scripting on it.
createLoadBalancer_healthCheckPath :: Lens.Lens' CreateLoadBalancer (Prelude.Maybe Prelude.Text)
createLoadBalancer_healthCheckPath :: (Maybe Text -> f (Maybe Text))
-> CreateLoadBalancer -> f CreateLoadBalancer
createLoadBalancer_healthCheckPath = (CreateLoadBalancer -> Maybe Text)
-> (CreateLoadBalancer -> Maybe Text -> CreateLoadBalancer)
-> Lens
     CreateLoadBalancer CreateLoadBalancer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLoadBalancer' {Maybe Text
healthCheckPath :: Maybe Text
$sel:healthCheckPath:CreateLoadBalancer' :: CreateLoadBalancer -> Maybe Text
healthCheckPath} -> Maybe Text
healthCheckPath) (\s :: CreateLoadBalancer
s@CreateLoadBalancer' {} Maybe Text
a -> CreateLoadBalancer
s {$sel:healthCheckPath:CreateLoadBalancer' :: Maybe Text
healthCheckPath = Maybe Text
a} :: CreateLoadBalancer)

-- | The name of the SSL\/TLS certificate.
--
-- If you specify @certificateName@, then @certificateDomainName@ is
-- required (and vice-versa).
createLoadBalancer_certificateName :: Lens.Lens' CreateLoadBalancer (Prelude.Maybe Prelude.Text)
createLoadBalancer_certificateName :: (Maybe Text -> f (Maybe Text))
-> CreateLoadBalancer -> f CreateLoadBalancer
createLoadBalancer_certificateName = (CreateLoadBalancer -> Maybe Text)
-> (CreateLoadBalancer -> Maybe Text -> CreateLoadBalancer)
-> Lens
     CreateLoadBalancer CreateLoadBalancer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLoadBalancer' {Maybe Text
certificateName :: Maybe Text
$sel:certificateName:CreateLoadBalancer' :: CreateLoadBalancer -> Maybe Text
certificateName} -> Maybe Text
certificateName) (\s :: CreateLoadBalancer
s@CreateLoadBalancer' {} Maybe Text
a -> CreateLoadBalancer
s {$sel:certificateName:CreateLoadBalancer' :: Maybe Text
certificateName = Maybe Text
a} :: CreateLoadBalancer)

-- | The domain name with which your certificate is associated (e.g.,
-- @example.com@).
--
-- If you specify @certificateDomainName@, then @certificateName@ is
-- required (and vice-versa).
createLoadBalancer_certificateDomainName :: Lens.Lens' CreateLoadBalancer (Prelude.Maybe Prelude.Text)
createLoadBalancer_certificateDomainName :: (Maybe Text -> f (Maybe Text))
-> CreateLoadBalancer -> f CreateLoadBalancer
createLoadBalancer_certificateDomainName = (CreateLoadBalancer -> Maybe Text)
-> (CreateLoadBalancer -> Maybe Text -> CreateLoadBalancer)
-> Lens
     CreateLoadBalancer CreateLoadBalancer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLoadBalancer' {Maybe Text
certificateDomainName :: Maybe Text
$sel:certificateDomainName:CreateLoadBalancer' :: CreateLoadBalancer -> Maybe Text
certificateDomainName} -> Maybe Text
certificateDomainName) (\s :: CreateLoadBalancer
s@CreateLoadBalancer' {} Maybe Text
a -> CreateLoadBalancer
s {$sel:certificateDomainName:CreateLoadBalancer' :: Maybe Text
certificateDomainName = Maybe Text
a} :: CreateLoadBalancer)

-- | The optional alternative domains and subdomains to use with your
-- SSL\/TLS certificate (e.g., @www.example.com@, @example.com@,
-- @m.example.com@, @blog.example.com@).
createLoadBalancer_certificateAlternativeNames :: Lens.Lens' CreateLoadBalancer (Prelude.Maybe [Prelude.Text])
createLoadBalancer_certificateAlternativeNames :: (Maybe [Text] -> f (Maybe [Text]))
-> CreateLoadBalancer -> f CreateLoadBalancer
createLoadBalancer_certificateAlternativeNames = (CreateLoadBalancer -> Maybe [Text])
-> (CreateLoadBalancer -> Maybe [Text] -> CreateLoadBalancer)
-> Lens
     CreateLoadBalancer CreateLoadBalancer (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLoadBalancer' {Maybe [Text]
certificateAlternativeNames :: Maybe [Text]
$sel:certificateAlternativeNames:CreateLoadBalancer' :: CreateLoadBalancer -> Maybe [Text]
certificateAlternativeNames} -> Maybe [Text]
certificateAlternativeNames) (\s :: CreateLoadBalancer
s@CreateLoadBalancer' {} Maybe [Text]
a -> CreateLoadBalancer
s {$sel:certificateAlternativeNames:CreateLoadBalancer' :: Maybe [Text]
certificateAlternativeNames = Maybe [Text]
a} :: CreateLoadBalancer) ((Maybe [Text] -> f (Maybe [Text]))
 -> CreateLoadBalancer -> f CreateLoadBalancer)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CreateLoadBalancer
-> f CreateLoadBalancer
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

-- | 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.
createLoadBalancer_tags :: Lens.Lens' CreateLoadBalancer (Prelude.Maybe [Tag])
createLoadBalancer_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateLoadBalancer -> f CreateLoadBalancer
createLoadBalancer_tags = (CreateLoadBalancer -> Maybe [Tag])
-> (CreateLoadBalancer -> Maybe [Tag] -> CreateLoadBalancer)
-> Lens
     CreateLoadBalancer CreateLoadBalancer (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLoadBalancer' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateLoadBalancer' :: CreateLoadBalancer -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateLoadBalancer
s@CreateLoadBalancer' {} Maybe [Tag]
a -> CreateLoadBalancer
s {$sel:tags:CreateLoadBalancer' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateLoadBalancer) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> CreateLoadBalancer -> f CreateLoadBalancer)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateLoadBalancer
-> f CreateLoadBalancer
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 name of your load balancer.
createLoadBalancer_loadBalancerName :: Lens.Lens' CreateLoadBalancer Prelude.Text
createLoadBalancer_loadBalancerName :: (Text -> f Text) -> CreateLoadBalancer -> f CreateLoadBalancer
createLoadBalancer_loadBalancerName = (CreateLoadBalancer -> Text)
-> (CreateLoadBalancer -> Text -> CreateLoadBalancer)
-> Lens CreateLoadBalancer CreateLoadBalancer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLoadBalancer' {Text
loadBalancerName :: Text
$sel:loadBalancerName:CreateLoadBalancer' :: CreateLoadBalancer -> Text
loadBalancerName} -> Text
loadBalancerName) (\s :: CreateLoadBalancer
s@CreateLoadBalancer' {} Text
a -> CreateLoadBalancer
s {$sel:loadBalancerName:CreateLoadBalancer' :: Text
loadBalancerName = Text
a} :: CreateLoadBalancer)

-- | The instance port where you\'re creating your load balancer.
createLoadBalancer_instancePort :: Lens.Lens' CreateLoadBalancer Prelude.Int
createLoadBalancer_instancePort :: (Int -> f Int) -> CreateLoadBalancer -> f CreateLoadBalancer
createLoadBalancer_instancePort = (CreateLoadBalancer -> Int)
-> (CreateLoadBalancer -> Int -> CreateLoadBalancer)
-> Lens CreateLoadBalancer CreateLoadBalancer Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLoadBalancer' {Int
instancePort :: Int
$sel:instancePort:CreateLoadBalancer' :: CreateLoadBalancer -> Int
instancePort} -> Int
instancePort) (\s :: CreateLoadBalancer
s@CreateLoadBalancer' {} Int
a -> CreateLoadBalancer
s {$sel:instancePort:CreateLoadBalancer' :: Int
instancePort = Int
a} :: CreateLoadBalancer)

instance Core.AWSRequest CreateLoadBalancer where
  type
    AWSResponse CreateLoadBalancer =
      CreateLoadBalancerResponse
  request :: CreateLoadBalancer -> Request CreateLoadBalancer
request = Service -> CreateLoadBalancer -> Request CreateLoadBalancer
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateLoadBalancer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateLoadBalancer)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateLoadBalancer))
-> Logger
-> Service
-> Proxy CreateLoadBalancer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateLoadBalancer)))
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 -> CreateLoadBalancerResponse
CreateLoadBalancerResponse'
            (Maybe [Operation] -> Int -> CreateLoadBalancerResponse)
-> Either String (Maybe [Operation])
-> Either String (Int -> CreateLoadBalancerResponse)
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 -> CreateLoadBalancerResponse)
-> Either String Int -> Either String CreateLoadBalancerResponse
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 CreateLoadBalancer

instance Prelude.NFData CreateLoadBalancer

instance Core.ToHeaders CreateLoadBalancer where
  toHeaders :: CreateLoadBalancer -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateLoadBalancer -> 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.CreateLoadBalancer" ::
                          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 CreateLoadBalancer where
  toJSON :: CreateLoadBalancer -> Value
toJSON CreateLoadBalancer' {Int
Maybe [Text]
Maybe [Tag]
Maybe Text
Maybe IpAddressType
Text
instancePort :: Int
loadBalancerName :: Text
tags :: Maybe [Tag]
ipAddressType :: Maybe IpAddressType
certificateAlternativeNames :: Maybe [Text]
certificateDomainName :: Maybe Text
certificateName :: Maybe Text
healthCheckPath :: Maybe Text
$sel:instancePort:CreateLoadBalancer' :: CreateLoadBalancer -> Int
$sel:loadBalancerName:CreateLoadBalancer' :: CreateLoadBalancer -> Text
$sel:tags:CreateLoadBalancer' :: CreateLoadBalancer -> Maybe [Tag]
$sel:ipAddressType:CreateLoadBalancer' :: CreateLoadBalancer -> Maybe IpAddressType
$sel:certificateAlternativeNames:CreateLoadBalancer' :: CreateLoadBalancer -> Maybe [Text]
$sel:certificateDomainName:CreateLoadBalancer' :: CreateLoadBalancer -> Maybe Text
$sel:certificateName:CreateLoadBalancer' :: CreateLoadBalancer -> Maybe Text
$sel:healthCheckPath:CreateLoadBalancer' :: CreateLoadBalancer -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"healthCheckPath" 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
healthCheckPath,
            (Text
"certificateName" 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
certificateName,
            (Text
"certificateDomainName" 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
certificateDomainName,
            (Text
"certificateAlternativeNames" 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]
certificateAlternativeNames,
            (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
"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
"loadBalancerName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
loadBalancerName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"instancePort" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Int
instancePort)
          ]
      )

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

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

-- | /See:/ 'newCreateLoadBalancerResponse' smart constructor.
data CreateLoadBalancerResponse = CreateLoadBalancerResponse'
  { -- | 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.
    CreateLoadBalancerResponse -> Maybe [Operation]
operations :: Prelude.Maybe [Operation],
    -- | The response's http status code.
    CreateLoadBalancerResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateLoadBalancerResponse -> CreateLoadBalancerResponse -> Bool
(CreateLoadBalancerResponse -> CreateLoadBalancerResponse -> Bool)
-> (CreateLoadBalancerResponse
    -> CreateLoadBalancerResponse -> Bool)
-> Eq CreateLoadBalancerResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateLoadBalancerResponse -> CreateLoadBalancerResponse -> Bool
$c/= :: CreateLoadBalancerResponse -> CreateLoadBalancerResponse -> Bool
== :: CreateLoadBalancerResponse -> CreateLoadBalancerResponse -> Bool
$c== :: CreateLoadBalancerResponse -> CreateLoadBalancerResponse -> Bool
Prelude.Eq, ReadPrec [CreateLoadBalancerResponse]
ReadPrec CreateLoadBalancerResponse
Int -> ReadS CreateLoadBalancerResponse
ReadS [CreateLoadBalancerResponse]
(Int -> ReadS CreateLoadBalancerResponse)
-> ReadS [CreateLoadBalancerResponse]
-> ReadPrec CreateLoadBalancerResponse
-> ReadPrec [CreateLoadBalancerResponse]
-> Read CreateLoadBalancerResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateLoadBalancerResponse]
$creadListPrec :: ReadPrec [CreateLoadBalancerResponse]
readPrec :: ReadPrec CreateLoadBalancerResponse
$creadPrec :: ReadPrec CreateLoadBalancerResponse
readList :: ReadS [CreateLoadBalancerResponse]
$creadList :: ReadS [CreateLoadBalancerResponse]
readsPrec :: Int -> ReadS CreateLoadBalancerResponse
$creadsPrec :: Int -> ReadS CreateLoadBalancerResponse
Prelude.Read, Int -> CreateLoadBalancerResponse -> ShowS
[CreateLoadBalancerResponse] -> ShowS
CreateLoadBalancerResponse -> String
(Int -> CreateLoadBalancerResponse -> ShowS)
-> (CreateLoadBalancerResponse -> String)
-> ([CreateLoadBalancerResponse] -> ShowS)
-> Show CreateLoadBalancerResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateLoadBalancerResponse] -> ShowS
$cshowList :: [CreateLoadBalancerResponse] -> ShowS
show :: CreateLoadBalancerResponse -> String
$cshow :: CreateLoadBalancerResponse -> String
showsPrec :: Int -> CreateLoadBalancerResponse -> ShowS
$cshowsPrec :: Int -> CreateLoadBalancerResponse -> ShowS
Prelude.Show, (forall x.
 CreateLoadBalancerResponse -> Rep CreateLoadBalancerResponse x)
-> (forall x.
    Rep CreateLoadBalancerResponse x -> CreateLoadBalancerResponse)
-> Generic CreateLoadBalancerResponse
forall x.
Rep CreateLoadBalancerResponse x -> CreateLoadBalancerResponse
forall x.
CreateLoadBalancerResponse -> Rep CreateLoadBalancerResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateLoadBalancerResponse x -> CreateLoadBalancerResponse
$cfrom :: forall x.
CreateLoadBalancerResponse -> Rep CreateLoadBalancerResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateLoadBalancerResponse' 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', 'createLoadBalancerResponse_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', 'createLoadBalancerResponse_httpStatus' - The response's http status code.
newCreateLoadBalancerResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateLoadBalancerResponse
newCreateLoadBalancerResponse :: Int -> CreateLoadBalancerResponse
newCreateLoadBalancerResponse Int
pHttpStatus_ =
  CreateLoadBalancerResponse' :: Maybe [Operation] -> Int -> CreateLoadBalancerResponse
CreateLoadBalancerResponse'
    { $sel:operations:CreateLoadBalancerResponse' :: Maybe [Operation]
operations =
        Maybe [Operation]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateLoadBalancerResponse' :: 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.
createLoadBalancerResponse_operations :: Lens.Lens' CreateLoadBalancerResponse (Prelude.Maybe [Operation])
createLoadBalancerResponse_operations :: (Maybe [Operation] -> f (Maybe [Operation]))
-> CreateLoadBalancerResponse -> f CreateLoadBalancerResponse
createLoadBalancerResponse_operations = (CreateLoadBalancerResponse -> Maybe [Operation])
-> (CreateLoadBalancerResponse
    -> Maybe [Operation] -> CreateLoadBalancerResponse)
-> Lens
     CreateLoadBalancerResponse
     CreateLoadBalancerResponse
     (Maybe [Operation])
     (Maybe [Operation])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLoadBalancerResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:CreateLoadBalancerResponse' :: CreateLoadBalancerResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: CreateLoadBalancerResponse
s@CreateLoadBalancerResponse' {} Maybe [Operation]
a -> CreateLoadBalancerResponse
s {$sel:operations:CreateLoadBalancerResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: CreateLoadBalancerResponse) ((Maybe [Operation] -> f (Maybe [Operation]))
 -> CreateLoadBalancerResponse -> f CreateLoadBalancerResponse)
-> ((Maybe [Operation] -> f (Maybe [Operation]))
    -> Maybe [Operation] -> f (Maybe [Operation]))
-> (Maybe [Operation] -> f (Maybe [Operation]))
-> CreateLoadBalancerResponse
-> f CreateLoadBalancerResponse
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.
createLoadBalancerResponse_httpStatus :: Lens.Lens' CreateLoadBalancerResponse Prelude.Int
createLoadBalancerResponse_httpStatus :: (Int -> f Int)
-> CreateLoadBalancerResponse -> f CreateLoadBalancerResponse
createLoadBalancerResponse_httpStatus = (CreateLoadBalancerResponse -> Int)
-> (CreateLoadBalancerResponse
    -> Int -> CreateLoadBalancerResponse)
-> Lens
     CreateLoadBalancerResponse CreateLoadBalancerResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLoadBalancerResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateLoadBalancerResponse' :: CreateLoadBalancerResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateLoadBalancerResponse
s@CreateLoadBalancerResponse' {} Int
a -> CreateLoadBalancerResponse
s {$sel:httpStatus:CreateLoadBalancerResponse' :: Int
httpStatus = Int
a} :: CreateLoadBalancerResponse)

instance Prelude.NFData CreateLoadBalancerResponse