{-# 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.GlobalAccelerator.CreateAccelerator
-- 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)
--
-- Create an accelerator. An accelerator includes one or more listeners
-- that process inbound connections and direct traffic to one or more
-- endpoint groups, each of which includes endpoints, such as Network Load
-- Balancers.
--
-- Global Accelerator is a global service that supports endpoints in
-- multiple AWS Regions but you must specify the US West (Oregon) Region to
-- create or update accelerators.
module Amazonka.GlobalAccelerator.CreateAccelerator
  ( -- * Creating a Request
    CreateAccelerator (..),
    newCreateAccelerator,

    -- * Request Lenses
    createAccelerator_enabled,
    createAccelerator_ipAddressType,
    createAccelerator_tags,
    createAccelerator_ipAddresses,
    createAccelerator_name,
    createAccelerator_idempotencyToken,

    -- * Destructuring the Response
    CreateAcceleratorResponse (..),
    newCreateAcceleratorResponse,

    -- * Response Lenses
    createAcceleratorResponse_accelerator,
    createAcceleratorResponse_httpStatus,
  )
where

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

-- | /See:/ 'newCreateAccelerator' smart constructor.
data CreateAccelerator = CreateAccelerator'
  { -- | Indicates whether an accelerator is enabled. The value is true or false.
    -- The default value is true.
    --
    -- If the value is set to true, an accelerator cannot be deleted. If set to
    -- false, the accelerator can be deleted.
    CreateAccelerator -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | The value for the address type must be IPv4.
    CreateAccelerator -> Maybe IpAddressType
ipAddressType :: Prelude.Maybe IpAddressType,
    -- | Create tags for an accelerator.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/global-accelerator/latest/dg/tagging-in-global-accelerator.html Tagging in AWS Global Accelerator>
    -- in the /AWS Global Accelerator Developer Guide/.
    CreateAccelerator -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | Optionally, if you\'ve added your own IP address pool to Global
    -- Accelerator (BYOIP), you can choose IP addresses from your own pool to
    -- use for the accelerator\'s static IP addresses when you create an
    -- accelerator. You can specify one or two addresses, separated by a space.
    -- Do not include the \/32 suffix.
    --
    -- Only one IP address from each of your IP address ranges can be used for
    -- each accelerator. If you specify only one IP address from your IP
    -- address range, Global Accelerator assigns a second static IP address for
    -- the accelerator from the AWS IP address pool.
    --
    -- Note that you can\'t update IP addresses for an existing accelerator. To
    -- change them, you must create a new accelerator with the new addresses.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/global-accelerator/latest/dg/using-byoip.html Bring Your Own IP Addresses (BYOIP)>
    -- in the /AWS Global Accelerator Developer Guide/.
    CreateAccelerator -> Maybe [Text]
ipAddresses :: Prelude.Maybe [Prelude.Text],
    -- | The name of an accelerator. The name can have a maximum of 32
    -- characters, must contain only alphanumeric characters or hyphens (-),
    -- and must not begin or end with a hyphen.
    CreateAccelerator -> Text
name :: Prelude.Text,
    -- | A unique, case-sensitive identifier that you provide to ensure the
    -- idempotency—that is, the uniqueness—of an accelerator.
    CreateAccelerator -> Text
idempotencyToken :: Prelude.Text
  }
  deriving (CreateAccelerator -> CreateAccelerator -> Bool
(CreateAccelerator -> CreateAccelerator -> Bool)
-> (CreateAccelerator -> CreateAccelerator -> Bool)
-> Eq CreateAccelerator
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateAccelerator -> CreateAccelerator -> Bool
$c/= :: CreateAccelerator -> CreateAccelerator -> Bool
== :: CreateAccelerator -> CreateAccelerator -> Bool
$c== :: CreateAccelerator -> CreateAccelerator -> Bool
Prelude.Eq, ReadPrec [CreateAccelerator]
ReadPrec CreateAccelerator
Int -> ReadS CreateAccelerator
ReadS [CreateAccelerator]
(Int -> ReadS CreateAccelerator)
-> ReadS [CreateAccelerator]
-> ReadPrec CreateAccelerator
-> ReadPrec [CreateAccelerator]
-> Read CreateAccelerator
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateAccelerator]
$creadListPrec :: ReadPrec [CreateAccelerator]
readPrec :: ReadPrec CreateAccelerator
$creadPrec :: ReadPrec CreateAccelerator
readList :: ReadS [CreateAccelerator]
$creadList :: ReadS [CreateAccelerator]
readsPrec :: Int -> ReadS CreateAccelerator
$creadsPrec :: Int -> ReadS CreateAccelerator
Prelude.Read, Int -> CreateAccelerator -> ShowS
[CreateAccelerator] -> ShowS
CreateAccelerator -> String
(Int -> CreateAccelerator -> ShowS)
-> (CreateAccelerator -> String)
-> ([CreateAccelerator] -> ShowS)
-> Show CreateAccelerator
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateAccelerator] -> ShowS
$cshowList :: [CreateAccelerator] -> ShowS
show :: CreateAccelerator -> String
$cshow :: CreateAccelerator -> String
showsPrec :: Int -> CreateAccelerator -> ShowS
$cshowsPrec :: Int -> CreateAccelerator -> ShowS
Prelude.Show, (forall x. CreateAccelerator -> Rep CreateAccelerator x)
-> (forall x. Rep CreateAccelerator x -> CreateAccelerator)
-> Generic CreateAccelerator
forall x. Rep CreateAccelerator x -> CreateAccelerator
forall x. CreateAccelerator -> Rep CreateAccelerator x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateAccelerator x -> CreateAccelerator
$cfrom :: forall x. CreateAccelerator -> Rep CreateAccelerator x
Prelude.Generic)

-- |
-- Create a value of 'CreateAccelerator' 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:
--
-- 'enabled', 'createAccelerator_enabled' - Indicates whether an accelerator is enabled. The value is true or false.
-- The default value is true.
--
-- If the value is set to true, an accelerator cannot be deleted. If set to
-- false, the accelerator can be deleted.
--
-- 'ipAddressType', 'createAccelerator_ipAddressType' - The value for the address type must be IPv4.
--
-- 'tags', 'createAccelerator_tags' - Create tags for an accelerator.
--
-- For more information, see
-- <https://docs.aws.amazon.com/global-accelerator/latest/dg/tagging-in-global-accelerator.html Tagging in AWS Global Accelerator>
-- in the /AWS Global Accelerator Developer Guide/.
--
-- 'ipAddresses', 'createAccelerator_ipAddresses' - Optionally, if you\'ve added your own IP address pool to Global
-- Accelerator (BYOIP), you can choose IP addresses from your own pool to
-- use for the accelerator\'s static IP addresses when you create an
-- accelerator. You can specify one or two addresses, separated by a space.
-- Do not include the \/32 suffix.
--
-- Only one IP address from each of your IP address ranges can be used for
-- each accelerator. If you specify only one IP address from your IP
-- address range, Global Accelerator assigns a second static IP address for
-- the accelerator from the AWS IP address pool.
--
-- Note that you can\'t update IP addresses for an existing accelerator. To
-- change them, you must create a new accelerator with the new addresses.
--
-- For more information, see
-- <https://docs.aws.amazon.com/global-accelerator/latest/dg/using-byoip.html Bring Your Own IP Addresses (BYOIP)>
-- in the /AWS Global Accelerator Developer Guide/.
--
-- 'name', 'createAccelerator_name' - The name of an accelerator. The name can have a maximum of 32
-- characters, must contain only alphanumeric characters or hyphens (-),
-- and must not begin or end with a hyphen.
--
-- 'idempotencyToken', 'createAccelerator_idempotencyToken' - A unique, case-sensitive identifier that you provide to ensure the
-- idempotency—that is, the uniqueness—of an accelerator.
newCreateAccelerator ::
  -- | 'name'
  Prelude.Text ->
  -- | 'idempotencyToken'
  Prelude.Text ->
  CreateAccelerator
newCreateAccelerator :: Text -> Text -> CreateAccelerator
newCreateAccelerator Text
pName_ Text
pIdempotencyToken_ =
  CreateAccelerator' :: Maybe Bool
-> Maybe IpAddressType
-> Maybe [Tag]
-> Maybe [Text]
-> Text
-> Text
-> CreateAccelerator
CreateAccelerator'
    { $sel:enabled:CreateAccelerator' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:ipAddressType:CreateAccelerator' :: Maybe IpAddressType
ipAddressType = Maybe IpAddressType
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateAccelerator' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:ipAddresses:CreateAccelerator' :: Maybe [Text]
ipAddresses = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CreateAccelerator' :: Text
name = Text
pName_,
      $sel:idempotencyToken:CreateAccelerator' :: Text
idempotencyToken = Text
pIdempotencyToken_
    }

-- | Indicates whether an accelerator is enabled. The value is true or false.
-- The default value is true.
--
-- If the value is set to true, an accelerator cannot be deleted. If set to
-- false, the accelerator can be deleted.
createAccelerator_enabled :: Lens.Lens' CreateAccelerator (Prelude.Maybe Prelude.Bool)
createAccelerator_enabled :: (Maybe Bool -> f (Maybe Bool))
-> CreateAccelerator -> f CreateAccelerator
createAccelerator_enabled = (CreateAccelerator -> Maybe Bool)
-> (CreateAccelerator -> Maybe Bool -> CreateAccelerator)
-> Lens
     CreateAccelerator CreateAccelerator (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAccelerator' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:CreateAccelerator' :: CreateAccelerator -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: CreateAccelerator
s@CreateAccelerator' {} Maybe Bool
a -> CreateAccelerator
s {$sel:enabled:CreateAccelerator' :: Maybe Bool
enabled = Maybe Bool
a} :: CreateAccelerator)

-- | The value for the address type must be IPv4.
createAccelerator_ipAddressType :: Lens.Lens' CreateAccelerator (Prelude.Maybe IpAddressType)
createAccelerator_ipAddressType :: (Maybe IpAddressType -> f (Maybe IpAddressType))
-> CreateAccelerator -> f CreateAccelerator
createAccelerator_ipAddressType = (CreateAccelerator -> Maybe IpAddressType)
-> (CreateAccelerator -> Maybe IpAddressType -> CreateAccelerator)
-> Lens
     CreateAccelerator
     CreateAccelerator
     (Maybe IpAddressType)
     (Maybe IpAddressType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAccelerator' {Maybe IpAddressType
ipAddressType :: Maybe IpAddressType
$sel:ipAddressType:CreateAccelerator' :: CreateAccelerator -> Maybe IpAddressType
ipAddressType} -> Maybe IpAddressType
ipAddressType) (\s :: CreateAccelerator
s@CreateAccelerator' {} Maybe IpAddressType
a -> CreateAccelerator
s {$sel:ipAddressType:CreateAccelerator' :: Maybe IpAddressType
ipAddressType = Maybe IpAddressType
a} :: CreateAccelerator)

-- | Create tags for an accelerator.
--
-- For more information, see
-- <https://docs.aws.amazon.com/global-accelerator/latest/dg/tagging-in-global-accelerator.html Tagging in AWS Global Accelerator>
-- in the /AWS Global Accelerator Developer Guide/.
createAccelerator_tags :: Lens.Lens' CreateAccelerator (Prelude.Maybe [Tag])
createAccelerator_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateAccelerator -> f CreateAccelerator
createAccelerator_tags = (CreateAccelerator -> Maybe [Tag])
-> (CreateAccelerator -> Maybe [Tag] -> CreateAccelerator)
-> Lens
     CreateAccelerator CreateAccelerator (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAccelerator' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateAccelerator' :: CreateAccelerator -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateAccelerator
s@CreateAccelerator' {} Maybe [Tag]
a -> CreateAccelerator
s {$sel:tags:CreateAccelerator' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateAccelerator) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> CreateAccelerator -> f CreateAccelerator)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateAccelerator
-> f CreateAccelerator
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

-- | Optionally, if you\'ve added your own IP address pool to Global
-- Accelerator (BYOIP), you can choose IP addresses from your own pool to
-- use for the accelerator\'s static IP addresses when you create an
-- accelerator. You can specify one or two addresses, separated by a space.
-- Do not include the \/32 suffix.
--
-- Only one IP address from each of your IP address ranges can be used for
-- each accelerator. If you specify only one IP address from your IP
-- address range, Global Accelerator assigns a second static IP address for
-- the accelerator from the AWS IP address pool.
--
-- Note that you can\'t update IP addresses for an existing accelerator. To
-- change them, you must create a new accelerator with the new addresses.
--
-- For more information, see
-- <https://docs.aws.amazon.com/global-accelerator/latest/dg/using-byoip.html Bring Your Own IP Addresses (BYOIP)>
-- in the /AWS Global Accelerator Developer Guide/.
createAccelerator_ipAddresses :: Lens.Lens' CreateAccelerator (Prelude.Maybe [Prelude.Text])
createAccelerator_ipAddresses :: (Maybe [Text] -> f (Maybe [Text]))
-> CreateAccelerator -> f CreateAccelerator
createAccelerator_ipAddresses = (CreateAccelerator -> Maybe [Text])
-> (CreateAccelerator -> Maybe [Text] -> CreateAccelerator)
-> Lens
     CreateAccelerator CreateAccelerator (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAccelerator' {Maybe [Text]
ipAddresses :: Maybe [Text]
$sel:ipAddresses:CreateAccelerator' :: CreateAccelerator -> Maybe [Text]
ipAddresses} -> Maybe [Text]
ipAddresses) (\s :: CreateAccelerator
s@CreateAccelerator' {} Maybe [Text]
a -> CreateAccelerator
s {$sel:ipAddresses:CreateAccelerator' :: Maybe [Text]
ipAddresses = Maybe [Text]
a} :: CreateAccelerator) ((Maybe [Text] -> f (Maybe [Text]))
 -> CreateAccelerator -> f CreateAccelerator)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CreateAccelerator
-> f CreateAccelerator
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 name of an accelerator. The name can have a maximum of 32
-- characters, must contain only alphanumeric characters or hyphens (-),
-- and must not begin or end with a hyphen.
createAccelerator_name :: Lens.Lens' CreateAccelerator Prelude.Text
createAccelerator_name :: (Text -> f Text) -> CreateAccelerator -> f CreateAccelerator
createAccelerator_name = (CreateAccelerator -> Text)
-> (CreateAccelerator -> Text -> CreateAccelerator)
-> Lens CreateAccelerator CreateAccelerator Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAccelerator' {Text
name :: Text
$sel:name:CreateAccelerator' :: CreateAccelerator -> Text
name} -> Text
name) (\s :: CreateAccelerator
s@CreateAccelerator' {} Text
a -> CreateAccelerator
s {$sel:name:CreateAccelerator' :: Text
name = Text
a} :: CreateAccelerator)

-- | A unique, case-sensitive identifier that you provide to ensure the
-- idempotency—that is, the uniqueness—of an accelerator.
createAccelerator_idempotencyToken :: Lens.Lens' CreateAccelerator Prelude.Text
createAccelerator_idempotencyToken :: (Text -> f Text) -> CreateAccelerator -> f CreateAccelerator
createAccelerator_idempotencyToken = (CreateAccelerator -> Text)
-> (CreateAccelerator -> Text -> CreateAccelerator)
-> Lens CreateAccelerator CreateAccelerator Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAccelerator' {Text
idempotencyToken :: Text
$sel:idempotencyToken:CreateAccelerator' :: CreateAccelerator -> Text
idempotencyToken} -> Text
idempotencyToken) (\s :: CreateAccelerator
s@CreateAccelerator' {} Text
a -> CreateAccelerator
s {$sel:idempotencyToken:CreateAccelerator' :: Text
idempotencyToken = Text
a} :: CreateAccelerator)

instance Core.AWSRequest CreateAccelerator where
  type
    AWSResponse CreateAccelerator =
      CreateAcceleratorResponse
  request :: CreateAccelerator -> Request CreateAccelerator
request = Service -> CreateAccelerator -> Request CreateAccelerator
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateAccelerator
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateAccelerator)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateAccelerator))
-> Logger
-> Service
-> Proxy CreateAccelerator
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateAccelerator)))
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 Accelerator -> Int -> CreateAcceleratorResponse
CreateAcceleratorResponse'
            (Maybe Accelerator -> Int -> CreateAcceleratorResponse)
-> Either String (Maybe Accelerator)
-> Either String (Int -> CreateAcceleratorResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Accelerator)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Accelerator")
            Either String (Int -> CreateAcceleratorResponse)
-> Either String Int -> Either String CreateAcceleratorResponse
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 CreateAccelerator

instance Prelude.NFData CreateAccelerator

instance Core.ToHeaders CreateAccelerator where
  toHeaders :: CreateAccelerator -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateAccelerator -> 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
"GlobalAccelerator_V20180706.CreateAccelerator" ::
                          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 CreateAccelerator where
  toJSON :: CreateAccelerator -> Value
toJSON CreateAccelerator' {Maybe Bool
Maybe [Text]
Maybe [Tag]
Maybe IpAddressType
Text
idempotencyToken :: Text
name :: Text
ipAddresses :: Maybe [Text]
tags :: Maybe [Tag]
ipAddressType :: Maybe IpAddressType
enabled :: Maybe Bool
$sel:idempotencyToken:CreateAccelerator' :: CreateAccelerator -> Text
$sel:name:CreateAccelerator' :: CreateAccelerator -> Text
$sel:ipAddresses:CreateAccelerator' :: CreateAccelerator -> Maybe [Text]
$sel:tags:CreateAccelerator' :: CreateAccelerator -> Maybe [Tag]
$sel:ipAddressType:CreateAccelerator' :: CreateAccelerator -> Maybe IpAddressType
$sel:enabled:CreateAccelerator' :: CreateAccelerator -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Enabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enabled,
            (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,
            (Text
"IpAddresses" 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]
ipAddresses,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"IdempotencyToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
idempotencyToken)
          ]
      )

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

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

-- | /See:/ 'newCreateAcceleratorResponse' smart constructor.
data CreateAcceleratorResponse = CreateAcceleratorResponse'
  { -- | The accelerator that is created by specifying a listener and the
    -- supported IP address types.
    CreateAcceleratorResponse -> Maybe Accelerator
accelerator :: Prelude.Maybe Accelerator,
    -- | The response's http status code.
    CreateAcceleratorResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateAcceleratorResponse -> CreateAcceleratorResponse -> Bool
(CreateAcceleratorResponse -> CreateAcceleratorResponse -> Bool)
-> (CreateAcceleratorResponse -> CreateAcceleratorResponse -> Bool)
-> Eq CreateAcceleratorResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateAcceleratorResponse -> CreateAcceleratorResponse -> Bool
$c/= :: CreateAcceleratorResponse -> CreateAcceleratorResponse -> Bool
== :: CreateAcceleratorResponse -> CreateAcceleratorResponse -> Bool
$c== :: CreateAcceleratorResponse -> CreateAcceleratorResponse -> Bool
Prelude.Eq, ReadPrec [CreateAcceleratorResponse]
ReadPrec CreateAcceleratorResponse
Int -> ReadS CreateAcceleratorResponse
ReadS [CreateAcceleratorResponse]
(Int -> ReadS CreateAcceleratorResponse)
-> ReadS [CreateAcceleratorResponse]
-> ReadPrec CreateAcceleratorResponse
-> ReadPrec [CreateAcceleratorResponse]
-> Read CreateAcceleratorResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateAcceleratorResponse]
$creadListPrec :: ReadPrec [CreateAcceleratorResponse]
readPrec :: ReadPrec CreateAcceleratorResponse
$creadPrec :: ReadPrec CreateAcceleratorResponse
readList :: ReadS [CreateAcceleratorResponse]
$creadList :: ReadS [CreateAcceleratorResponse]
readsPrec :: Int -> ReadS CreateAcceleratorResponse
$creadsPrec :: Int -> ReadS CreateAcceleratorResponse
Prelude.Read, Int -> CreateAcceleratorResponse -> ShowS
[CreateAcceleratorResponse] -> ShowS
CreateAcceleratorResponse -> String
(Int -> CreateAcceleratorResponse -> ShowS)
-> (CreateAcceleratorResponse -> String)
-> ([CreateAcceleratorResponse] -> ShowS)
-> Show CreateAcceleratorResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateAcceleratorResponse] -> ShowS
$cshowList :: [CreateAcceleratorResponse] -> ShowS
show :: CreateAcceleratorResponse -> String
$cshow :: CreateAcceleratorResponse -> String
showsPrec :: Int -> CreateAcceleratorResponse -> ShowS
$cshowsPrec :: Int -> CreateAcceleratorResponse -> ShowS
Prelude.Show, (forall x.
 CreateAcceleratorResponse -> Rep CreateAcceleratorResponse x)
-> (forall x.
    Rep CreateAcceleratorResponse x -> CreateAcceleratorResponse)
-> Generic CreateAcceleratorResponse
forall x.
Rep CreateAcceleratorResponse x -> CreateAcceleratorResponse
forall x.
CreateAcceleratorResponse -> Rep CreateAcceleratorResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateAcceleratorResponse x -> CreateAcceleratorResponse
$cfrom :: forall x.
CreateAcceleratorResponse -> Rep CreateAcceleratorResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateAcceleratorResponse' 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:
--
-- 'accelerator', 'createAcceleratorResponse_accelerator' - The accelerator that is created by specifying a listener and the
-- supported IP address types.
--
-- 'httpStatus', 'createAcceleratorResponse_httpStatus' - The response's http status code.
newCreateAcceleratorResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateAcceleratorResponse
newCreateAcceleratorResponse :: Int -> CreateAcceleratorResponse
newCreateAcceleratorResponse Int
pHttpStatus_ =
  CreateAcceleratorResponse' :: Maybe Accelerator -> Int -> CreateAcceleratorResponse
CreateAcceleratorResponse'
    { $sel:accelerator:CreateAcceleratorResponse' :: Maybe Accelerator
accelerator =
        Maybe Accelerator
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateAcceleratorResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The accelerator that is created by specifying a listener and the
-- supported IP address types.
createAcceleratorResponse_accelerator :: Lens.Lens' CreateAcceleratorResponse (Prelude.Maybe Accelerator)
createAcceleratorResponse_accelerator :: (Maybe Accelerator -> f (Maybe Accelerator))
-> CreateAcceleratorResponse -> f CreateAcceleratorResponse
createAcceleratorResponse_accelerator = (CreateAcceleratorResponse -> Maybe Accelerator)
-> (CreateAcceleratorResponse
    -> Maybe Accelerator -> CreateAcceleratorResponse)
-> Lens
     CreateAcceleratorResponse
     CreateAcceleratorResponse
     (Maybe Accelerator)
     (Maybe Accelerator)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAcceleratorResponse' {Maybe Accelerator
accelerator :: Maybe Accelerator
$sel:accelerator:CreateAcceleratorResponse' :: CreateAcceleratorResponse -> Maybe Accelerator
accelerator} -> Maybe Accelerator
accelerator) (\s :: CreateAcceleratorResponse
s@CreateAcceleratorResponse' {} Maybe Accelerator
a -> CreateAcceleratorResponse
s {$sel:accelerator:CreateAcceleratorResponse' :: Maybe Accelerator
accelerator = Maybe Accelerator
a} :: CreateAcceleratorResponse)

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

instance Prelude.NFData CreateAcceleratorResponse