{-# 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.CreateCoipCidr
-- 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 range of customer-owned IP addresses.
module Amazonka.EC2.CreateCoipCidr
  ( -- * Creating a Request
    CreateCoipCidr (..),
    newCreateCoipCidr,

    -- * Request Lenses
    createCoipCidr_dryRun,
    createCoipCidr_cidr,
    createCoipCidr_coipPoolId,

    -- * Destructuring the Response
    CreateCoipCidrResponse (..),
    newCreateCoipCidrResponse,

    -- * Response Lenses
    createCoipCidrResponse_coipCidr,
    createCoipCidrResponse_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:/ 'newCreateCoipCidr' smart constructor.
data CreateCoipCidr = CreateCoipCidr'
  { -- | Checks 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@.
    CreateCoipCidr -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | A customer-owned IP address range to create.
    CreateCoipCidr -> Text
cidr :: Prelude.Text,
    -- | The ID of the address pool.
    CreateCoipCidr -> Text
coipPoolId :: Prelude.Text
  }
  deriving (CreateCoipCidr -> CreateCoipCidr -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateCoipCidr -> CreateCoipCidr -> Bool
$c/= :: CreateCoipCidr -> CreateCoipCidr -> Bool
== :: CreateCoipCidr -> CreateCoipCidr -> Bool
$c== :: CreateCoipCidr -> CreateCoipCidr -> Bool
Prelude.Eq, ReadPrec [CreateCoipCidr]
ReadPrec CreateCoipCidr
Int -> ReadS CreateCoipCidr
ReadS [CreateCoipCidr]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateCoipCidr]
$creadListPrec :: ReadPrec [CreateCoipCidr]
readPrec :: ReadPrec CreateCoipCidr
$creadPrec :: ReadPrec CreateCoipCidr
readList :: ReadS [CreateCoipCidr]
$creadList :: ReadS [CreateCoipCidr]
readsPrec :: Int -> ReadS CreateCoipCidr
$creadsPrec :: Int -> ReadS CreateCoipCidr
Prelude.Read, Int -> CreateCoipCidr -> ShowS
[CreateCoipCidr] -> ShowS
CreateCoipCidr -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateCoipCidr] -> ShowS
$cshowList :: [CreateCoipCidr] -> ShowS
show :: CreateCoipCidr -> String
$cshow :: CreateCoipCidr -> String
showsPrec :: Int -> CreateCoipCidr -> ShowS
$cshowsPrec :: Int -> CreateCoipCidr -> ShowS
Prelude.Show, forall x. Rep CreateCoipCidr x -> CreateCoipCidr
forall x. CreateCoipCidr -> Rep CreateCoipCidr x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateCoipCidr x -> CreateCoipCidr
$cfrom :: forall x. CreateCoipCidr -> Rep CreateCoipCidr x
Prelude.Generic)

-- |
-- Create a value of 'CreateCoipCidr' 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', 'createCoipCidr_dryRun' - Checks 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@.
--
-- 'cidr', 'createCoipCidr_cidr' - A customer-owned IP address range to create.
--
-- 'coipPoolId', 'createCoipCidr_coipPoolId' - The ID of the address pool.
newCreateCoipCidr ::
  -- | 'cidr'
  Prelude.Text ->
  -- | 'coipPoolId'
  Prelude.Text ->
  CreateCoipCidr
newCreateCoipCidr :: Text -> Text -> CreateCoipCidr
newCreateCoipCidr Text
pCidr_ Text
pCoipPoolId_ =
  CreateCoipCidr'
    { $sel:dryRun:CreateCoipCidr' :: Maybe Bool
dryRun = forall a. Maybe a
Prelude.Nothing,
      $sel:cidr:CreateCoipCidr' :: Text
cidr = Text
pCidr_,
      $sel:coipPoolId:CreateCoipCidr' :: Text
coipPoolId = Text
pCoipPoolId_
    }

-- | Checks 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@.
createCoipCidr_dryRun :: Lens.Lens' CreateCoipCidr (Prelude.Maybe Prelude.Bool)
createCoipCidr_dryRun :: Lens' CreateCoipCidr (Maybe Bool)
createCoipCidr_dryRun = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCoipCidr' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:CreateCoipCidr' :: CreateCoipCidr -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: CreateCoipCidr
s@CreateCoipCidr' {} Maybe Bool
a -> CreateCoipCidr
s {$sel:dryRun:CreateCoipCidr' :: Maybe Bool
dryRun = Maybe Bool
a} :: CreateCoipCidr)

-- | A customer-owned IP address range to create.
createCoipCidr_cidr :: Lens.Lens' CreateCoipCidr Prelude.Text
createCoipCidr_cidr :: Lens' CreateCoipCidr Text
createCoipCidr_cidr = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCoipCidr' {Text
cidr :: Text
$sel:cidr:CreateCoipCidr' :: CreateCoipCidr -> Text
cidr} -> Text
cidr) (\s :: CreateCoipCidr
s@CreateCoipCidr' {} Text
a -> CreateCoipCidr
s {$sel:cidr:CreateCoipCidr' :: Text
cidr = Text
a} :: CreateCoipCidr)

-- | The ID of the address pool.
createCoipCidr_coipPoolId :: Lens.Lens' CreateCoipCidr Prelude.Text
createCoipCidr_coipPoolId :: Lens' CreateCoipCidr Text
createCoipCidr_coipPoolId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCoipCidr' {Text
coipPoolId :: Text
$sel:coipPoolId:CreateCoipCidr' :: CreateCoipCidr -> Text
coipPoolId} -> Text
coipPoolId) (\s :: CreateCoipCidr
s@CreateCoipCidr' {} Text
a -> CreateCoipCidr
s {$sel:coipPoolId:CreateCoipCidr' :: Text
coipPoolId = Text
a} :: CreateCoipCidr)

instance Core.AWSRequest CreateCoipCidr where
  type
    AWSResponse CreateCoipCidr =
      CreateCoipCidrResponse
  request :: (Service -> Service) -> CreateCoipCidr -> Request CreateCoipCidr
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 CreateCoipCidr
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateCoipCidr)))
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 CoipCidr -> Int -> CreateCoipCidrResponse
CreateCoipCidrResponse'
            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
"coipCidr")
            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 CreateCoipCidr where
  hashWithSalt :: Int -> CreateCoipCidr -> Int
hashWithSalt Int
_salt CreateCoipCidr' {Maybe Bool
Text
coipPoolId :: Text
cidr :: Text
dryRun :: Maybe Bool
$sel:coipPoolId:CreateCoipCidr' :: CreateCoipCidr -> Text
$sel:cidr:CreateCoipCidr' :: CreateCoipCidr -> Text
$sel:dryRun:CreateCoipCidr' :: CreateCoipCidr -> 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` Text
cidr
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
coipPoolId

instance Prelude.NFData CreateCoipCidr where
  rnf :: CreateCoipCidr -> ()
rnf CreateCoipCidr' {Maybe Bool
Text
coipPoolId :: Text
cidr :: Text
dryRun :: Maybe Bool
$sel:coipPoolId:CreateCoipCidr' :: CreateCoipCidr -> Text
$sel:cidr:CreateCoipCidr' :: CreateCoipCidr -> Text
$sel:dryRun:CreateCoipCidr' :: CreateCoipCidr -> 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 Text
cidr
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
coipPoolId

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

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

instance Data.ToQuery CreateCoipCidr where
  toQuery :: CreateCoipCidr -> QueryString
toQuery CreateCoipCidr' {Maybe Bool
Text
coipPoolId :: Text
cidr :: Text
dryRun :: Maybe Bool
$sel:coipPoolId:CreateCoipCidr' :: CreateCoipCidr -> Text
$sel:cidr:CreateCoipCidr' :: CreateCoipCidr -> Text
$sel:dryRun:CreateCoipCidr' :: CreateCoipCidr -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"CreateCoipCidr" :: 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,
        ByteString
"Cidr" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
cidr,
        ByteString
"CoipPoolId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
coipPoolId
      ]

-- | /See:/ 'newCreateCoipCidrResponse' smart constructor.
data CreateCoipCidrResponse = CreateCoipCidrResponse'
  { -- | Information about a range of customer-owned IP addresses.
    CreateCoipCidrResponse -> Maybe CoipCidr
coipCidr :: Prelude.Maybe CoipCidr,
    -- | The response's http status code.
    CreateCoipCidrResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateCoipCidrResponse -> CreateCoipCidrResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateCoipCidrResponse -> CreateCoipCidrResponse -> Bool
$c/= :: CreateCoipCidrResponse -> CreateCoipCidrResponse -> Bool
== :: CreateCoipCidrResponse -> CreateCoipCidrResponse -> Bool
$c== :: CreateCoipCidrResponse -> CreateCoipCidrResponse -> Bool
Prelude.Eq, ReadPrec [CreateCoipCidrResponse]
ReadPrec CreateCoipCidrResponse
Int -> ReadS CreateCoipCidrResponse
ReadS [CreateCoipCidrResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateCoipCidrResponse]
$creadListPrec :: ReadPrec [CreateCoipCidrResponse]
readPrec :: ReadPrec CreateCoipCidrResponse
$creadPrec :: ReadPrec CreateCoipCidrResponse
readList :: ReadS [CreateCoipCidrResponse]
$creadList :: ReadS [CreateCoipCidrResponse]
readsPrec :: Int -> ReadS CreateCoipCidrResponse
$creadsPrec :: Int -> ReadS CreateCoipCidrResponse
Prelude.Read, Int -> CreateCoipCidrResponse -> ShowS
[CreateCoipCidrResponse] -> ShowS
CreateCoipCidrResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateCoipCidrResponse] -> ShowS
$cshowList :: [CreateCoipCidrResponse] -> ShowS
show :: CreateCoipCidrResponse -> String
$cshow :: CreateCoipCidrResponse -> String
showsPrec :: Int -> CreateCoipCidrResponse -> ShowS
$cshowsPrec :: Int -> CreateCoipCidrResponse -> ShowS
Prelude.Show, forall x. Rep CreateCoipCidrResponse x -> CreateCoipCidrResponse
forall x. CreateCoipCidrResponse -> Rep CreateCoipCidrResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateCoipCidrResponse x -> CreateCoipCidrResponse
$cfrom :: forall x. CreateCoipCidrResponse -> Rep CreateCoipCidrResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateCoipCidrResponse' 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:
--
-- 'coipCidr', 'createCoipCidrResponse_coipCidr' - Information about a range of customer-owned IP addresses.
--
-- 'httpStatus', 'createCoipCidrResponse_httpStatus' - The response's http status code.
newCreateCoipCidrResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateCoipCidrResponse
newCreateCoipCidrResponse :: Int -> CreateCoipCidrResponse
newCreateCoipCidrResponse Int
pHttpStatus_ =
  CreateCoipCidrResponse'
    { $sel:coipCidr:CreateCoipCidrResponse' :: Maybe CoipCidr
coipCidr = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateCoipCidrResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about a range of customer-owned IP addresses.
createCoipCidrResponse_coipCidr :: Lens.Lens' CreateCoipCidrResponse (Prelude.Maybe CoipCidr)
createCoipCidrResponse_coipCidr :: Lens' CreateCoipCidrResponse (Maybe CoipCidr)
createCoipCidrResponse_coipCidr = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCoipCidrResponse' {Maybe CoipCidr
coipCidr :: Maybe CoipCidr
$sel:coipCidr:CreateCoipCidrResponse' :: CreateCoipCidrResponse -> Maybe CoipCidr
coipCidr} -> Maybe CoipCidr
coipCidr) (\s :: CreateCoipCidrResponse
s@CreateCoipCidrResponse' {} Maybe CoipCidr
a -> CreateCoipCidrResponse
s {$sel:coipCidr:CreateCoipCidrResponse' :: Maybe CoipCidr
coipCidr = Maybe CoipCidr
a} :: CreateCoipCidrResponse)

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

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