{-# 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.EC2.CreatePublicIpv4Pool
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a public IPv4 address pool. A public IPv4 pool is an EC2 IP
-- address pool required for the public IPv4 CIDRs that you own and bring
-- to Amazon Web Services to manage with IPAM. IPv6 addresses you bring to
-- Amazon Web Services, however, use IPAM pools only. To monitor the status
-- of pool creation, use
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribePublicIpv4Pools.html DescribePublicIpv4Pools>.
module Amazonka.EC2.CreatePublicIpv4Pool
  ( -- * Creating a Request
    CreatePublicIpv4Pool (..),
    newCreatePublicIpv4Pool,

    -- * Request Lenses
    createPublicIpv4Pool_dryRun,
    createPublicIpv4Pool_tagSpecifications,

    -- * Destructuring the Response
    CreatePublicIpv4PoolResponse (..),
    newCreatePublicIpv4PoolResponse,

    -- * Response Lenses
    createPublicIpv4PoolResponse_poolId,
    createPublicIpv4PoolResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newCreatePublicIpv4Pool' smart constructor.
data CreatePublicIpv4Pool = CreatePublicIpv4Pool'
  { -- | A check for whether you have the required permissions for the action
    -- without actually making the request and provides an error response. If
    -- you have the required permissions, the error response is
    -- @DryRunOperation@. Otherwise, it is @UnauthorizedOperation@.
    CreatePublicIpv4Pool -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | The key\/value combination of a tag assigned to the resource. Use the
    -- tag key in the filter name and the tag value as the filter value. For
    -- example, to find all resources that have a tag with the key @Owner@ and
    -- the value @TeamA@, specify @tag:Owner@ for the filter name and @TeamA@
    -- for the filter value.
    CreatePublicIpv4Pool -> Maybe [TagSpecification]
tagSpecifications :: Prelude.Maybe [TagSpecification]
  }
  deriving (CreatePublicIpv4Pool -> CreatePublicIpv4Pool -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreatePublicIpv4Pool -> CreatePublicIpv4Pool -> Bool
$c/= :: CreatePublicIpv4Pool -> CreatePublicIpv4Pool -> Bool
== :: CreatePublicIpv4Pool -> CreatePublicIpv4Pool -> Bool
$c== :: CreatePublicIpv4Pool -> CreatePublicIpv4Pool -> Bool
Prelude.Eq, ReadPrec [CreatePublicIpv4Pool]
ReadPrec CreatePublicIpv4Pool
Int -> ReadS CreatePublicIpv4Pool
ReadS [CreatePublicIpv4Pool]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreatePublicIpv4Pool]
$creadListPrec :: ReadPrec [CreatePublicIpv4Pool]
readPrec :: ReadPrec CreatePublicIpv4Pool
$creadPrec :: ReadPrec CreatePublicIpv4Pool
readList :: ReadS [CreatePublicIpv4Pool]
$creadList :: ReadS [CreatePublicIpv4Pool]
readsPrec :: Int -> ReadS CreatePublicIpv4Pool
$creadsPrec :: Int -> ReadS CreatePublicIpv4Pool
Prelude.Read, Int -> CreatePublicIpv4Pool -> ShowS
[CreatePublicIpv4Pool] -> ShowS
CreatePublicIpv4Pool -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreatePublicIpv4Pool] -> ShowS
$cshowList :: [CreatePublicIpv4Pool] -> ShowS
show :: CreatePublicIpv4Pool -> String
$cshow :: CreatePublicIpv4Pool -> String
showsPrec :: Int -> CreatePublicIpv4Pool -> ShowS
$cshowsPrec :: Int -> CreatePublicIpv4Pool -> ShowS
Prelude.Show, forall x. Rep CreatePublicIpv4Pool x -> CreatePublicIpv4Pool
forall x. CreatePublicIpv4Pool -> Rep CreatePublicIpv4Pool x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreatePublicIpv4Pool x -> CreatePublicIpv4Pool
$cfrom :: forall x. CreatePublicIpv4Pool -> Rep CreatePublicIpv4Pool x
Prelude.Generic)

-- |
-- Create a value of 'CreatePublicIpv4Pool' 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:
--
-- 'dryRun', 'createPublicIpv4Pool_dryRun' - A check for whether you have the required permissions for the action
-- without actually making the request and provides an error response. If
-- you have the required permissions, the error response is
-- @DryRunOperation@. Otherwise, it is @UnauthorizedOperation@.
--
-- 'tagSpecifications', 'createPublicIpv4Pool_tagSpecifications' - The key\/value combination of a tag assigned to the resource. Use the
-- tag key in the filter name and the tag value as the filter value. For
-- example, to find all resources that have a tag with the key @Owner@ and
-- the value @TeamA@, specify @tag:Owner@ for the filter name and @TeamA@
-- for the filter value.
newCreatePublicIpv4Pool ::
  CreatePublicIpv4Pool
newCreatePublicIpv4Pool :: CreatePublicIpv4Pool
newCreatePublicIpv4Pool =
  CreatePublicIpv4Pool'
    { $sel:dryRun:CreatePublicIpv4Pool' :: Maybe Bool
dryRun = forall a. Maybe a
Prelude.Nothing,
      $sel:tagSpecifications:CreatePublicIpv4Pool' :: Maybe [TagSpecification]
tagSpecifications = forall a. Maybe a
Prelude.Nothing
    }

-- | A check for whether you have the required permissions for the action
-- without actually making the request and provides an error response. If
-- you have the required permissions, the error response is
-- @DryRunOperation@. Otherwise, it is @UnauthorizedOperation@.
createPublicIpv4Pool_dryRun :: Lens.Lens' CreatePublicIpv4Pool (Prelude.Maybe Prelude.Bool)
createPublicIpv4Pool_dryRun :: Lens' CreatePublicIpv4Pool (Maybe Bool)
createPublicIpv4Pool_dryRun = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePublicIpv4Pool' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:CreatePublicIpv4Pool' :: CreatePublicIpv4Pool -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: CreatePublicIpv4Pool
s@CreatePublicIpv4Pool' {} Maybe Bool
a -> CreatePublicIpv4Pool
s {$sel:dryRun:CreatePublicIpv4Pool' :: Maybe Bool
dryRun = Maybe Bool
a} :: CreatePublicIpv4Pool)

-- | The key\/value combination of a tag assigned to the resource. Use the
-- tag key in the filter name and the tag value as the filter value. For
-- example, to find all resources that have a tag with the key @Owner@ and
-- the value @TeamA@, specify @tag:Owner@ for the filter name and @TeamA@
-- for the filter value.
createPublicIpv4Pool_tagSpecifications :: Lens.Lens' CreatePublicIpv4Pool (Prelude.Maybe [TagSpecification])
createPublicIpv4Pool_tagSpecifications :: Lens' CreatePublicIpv4Pool (Maybe [TagSpecification])
createPublicIpv4Pool_tagSpecifications = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePublicIpv4Pool' {Maybe [TagSpecification]
tagSpecifications :: Maybe [TagSpecification]
$sel:tagSpecifications:CreatePublicIpv4Pool' :: CreatePublicIpv4Pool -> Maybe [TagSpecification]
tagSpecifications} -> Maybe [TagSpecification]
tagSpecifications) (\s :: CreatePublicIpv4Pool
s@CreatePublicIpv4Pool' {} Maybe [TagSpecification]
a -> CreatePublicIpv4Pool
s {$sel:tagSpecifications:CreatePublicIpv4Pool' :: Maybe [TagSpecification]
tagSpecifications = Maybe [TagSpecification]
a} :: CreatePublicIpv4Pool) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest CreatePublicIpv4Pool where
  type
    AWSResponse CreatePublicIpv4Pool =
      CreatePublicIpv4PoolResponse
  request :: (Service -> Service)
-> CreatePublicIpv4Pool -> Request CreatePublicIpv4Pool
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreatePublicIpv4Pool
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreatePublicIpv4Pool)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text -> Int -> CreatePublicIpv4PoolResponse
CreatePublicIpv4PoolResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"poolId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreatePublicIpv4Pool where
  hashWithSalt :: Int -> CreatePublicIpv4Pool -> Int
hashWithSalt Int
_salt CreatePublicIpv4Pool' {Maybe Bool
Maybe [TagSpecification]
tagSpecifications :: Maybe [TagSpecification]
dryRun :: Maybe Bool
$sel:tagSpecifications:CreatePublicIpv4Pool' :: CreatePublicIpv4Pool -> Maybe [TagSpecification]
$sel:dryRun:CreatePublicIpv4Pool' :: CreatePublicIpv4Pool -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
dryRun
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [TagSpecification]
tagSpecifications

instance Prelude.NFData CreatePublicIpv4Pool where
  rnf :: CreatePublicIpv4Pool -> ()
rnf CreatePublicIpv4Pool' {Maybe Bool
Maybe [TagSpecification]
tagSpecifications :: Maybe [TagSpecification]
dryRun :: Maybe Bool
$sel:tagSpecifications:CreatePublicIpv4Pool' :: CreatePublicIpv4Pool -> Maybe [TagSpecification]
$sel:dryRun:CreatePublicIpv4Pool' :: CreatePublicIpv4Pool -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
dryRun
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [TagSpecification]
tagSpecifications

instance Data.ToHeaders CreatePublicIpv4Pool where
  toHeaders :: CreatePublicIpv4Pool -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery CreatePublicIpv4Pool where
  toQuery :: CreatePublicIpv4Pool -> QueryString
toQuery CreatePublicIpv4Pool' {Maybe Bool
Maybe [TagSpecification]
tagSpecifications :: Maybe [TagSpecification]
dryRun :: Maybe Bool
$sel:tagSpecifications:CreatePublicIpv4Pool' :: CreatePublicIpv4Pool -> Maybe [TagSpecification]
$sel:dryRun:CreatePublicIpv4Pool' :: CreatePublicIpv4Pool -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"CreatePublicIpv4Pool" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2016-11-15" :: Prelude.ByteString),
        ByteString
"DryRun" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
dryRun,
        forall a. ToQuery a => a -> QueryString
Data.toQuery
          ( forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"TagSpecification"
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [TagSpecification]
tagSpecifications
          )
      ]

-- | /See:/ 'newCreatePublicIpv4PoolResponse' smart constructor.
data CreatePublicIpv4PoolResponse = CreatePublicIpv4PoolResponse'
  { -- | The ID of the public IPv4 pool.
    CreatePublicIpv4PoolResponse -> Maybe Text
poolId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreatePublicIpv4PoolResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreatePublicIpv4PoolResponse
-> CreatePublicIpv4PoolResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreatePublicIpv4PoolResponse
-> CreatePublicIpv4PoolResponse -> Bool
$c/= :: CreatePublicIpv4PoolResponse
-> CreatePublicIpv4PoolResponse -> Bool
== :: CreatePublicIpv4PoolResponse
-> CreatePublicIpv4PoolResponse -> Bool
$c== :: CreatePublicIpv4PoolResponse
-> CreatePublicIpv4PoolResponse -> Bool
Prelude.Eq, ReadPrec [CreatePublicIpv4PoolResponse]
ReadPrec CreatePublicIpv4PoolResponse
Int -> ReadS CreatePublicIpv4PoolResponse
ReadS [CreatePublicIpv4PoolResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreatePublicIpv4PoolResponse]
$creadListPrec :: ReadPrec [CreatePublicIpv4PoolResponse]
readPrec :: ReadPrec CreatePublicIpv4PoolResponse
$creadPrec :: ReadPrec CreatePublicIpv4PoolResponse
readList :: ReadS [CreatePublicIpv4PoolResponse]
$creadList :: ReadS [CreatePublicIpv4PoolResponse]
readsPrec :: Int -> ReadS CreatePublicIpv4PoolResponse
$creadsPrec :: Int -> ReadS CreatePublicIpv4PoolResponse
Prelude.Read, Int -> CreatePublicIpv4PoolResponse -> ShowS
[CreatePublicIpv4PoolResponse] -> ShowS
CreatePublicIpv4PoolResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreatePublicIpv4PoolResponse] -> ShowS
$cshowList :: [CreatePublicIpv4PoolResponse] -> ShowS
show :: CreatePublicIpv4PoolResponse -> String
$cshow :: CreatePublicIpv4PoolResponse -> String
showsPrec :: Int -> CreatePublicIpv4PoolResponse -> ShowS
$cshowsPrec :: Int -> CreatePublicIpv4PoolResponse -> ShowS
Prelude.Show, forall x.
Rep CreatePublicIpv4PoolResponse x -> CreatePublicIpv4PoolResponse
forall x.
CreatePublicIpv4PoolResponse -> Rep CreatePublicIpv4PoolResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreatePublicIpv4PoolResponse x -> CreatePublicIpv4PoolResponse
$cfrom :: forall x.
CreatePublicIpv4PoolResponse -> Rep CreatePublicIpv4PoolResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreatePublicIpv4PoolResponse' 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:
--
-- 'poolId', 'createPublicIpv4PoolResponse_poolId' - The ID of the public IPv4 pool.
--
-- 'httpStatus', 'createPublicIpv4PoolResponse_httpStatus' - The response's http status code.
newCreatePublicIpv4PoolResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreatePublicIpv4PoolResponse
newCreatePublicIpv4PoolResponse :: Int -> CreatePublicIpv4PoolResponse
newCreatePublicIpv4PoolResponse Int
pHttpStatus_ =
  CreatePublicIpv4PoolResponse'
    { $sel:poolId:CreatePublicIpv4PoolResponse' :: Maybe Text
poolId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreatePublicIpv4PoolResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ID of the public IPv4 pool.
createPublicIpv4PoolResponse_poolId :: Lens.Lens' CreatePublicIpv4PoolResponse (Prelude.Maybe Prelude.Text)
createPublicIpv4PoolResponse_poolId :: Lens' CreatePublicIpv4PoolResponse (Maybe Text)
createPublicIpv4PoolResponse_poolId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePublicIpv4PoolResponse' {Maybe Text
poolId :: Maybe Text
$sel:poolId:CreatePublicIpv4PoolResponse' :: CreatePublicIpv4PoolResponse -> Maybe Text
poolId} -> Maybe Text
poolId) (\s :: CreatePublicIpv4PoolResponse
s@CreatePublicIpv4PoolResponse' {} Maybe Text
a -> CreatePublicIpv4PoolResponse
s {$sel:poolId:CreatePublicIpv4PoolResponse' :: Maybe Text
poolId = Maybe Text
a} :: CreatePublicIpv4PoolResponse)

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

instance Prelude.NFData CreatePublicIpv4PoolResponse where
  rnf :: CreatePublicIpv4PoolResponse -> ()
rnf CreatePublicIpv4PoolResponse' {Int
Maybe Text
httpStatus :: Int
poolId :: Maybe Text
$sel:httpStatus:CreatePublicIpv4PoolResponse' :: CreatePublicIpv4PoolResponse -> Int
$sel:poolId:CreatePublicIpv4PoolResponse' :: CreatePublicIpv4PoolResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
poolId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus