{-# 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.Route53.CreateCidrCollection
-- 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 CIDR collection in the current Amazon Web Services account.
module Amazonka.Route53.CreateCidrCollection
  ( -- * Creating a Request
    CreateCidrCollection (..),
    newCreateCidrCollection,

    -- * Request Lenses
    createCidrCollection_name,
    createCidrCollection_callerReference,

    -- * Destructuring the Response
    CreateCidrCollectionResponse (..),
    newCreateCidrCollectionResponse,

    -- * Response Lenses
    createCidrCollectionResponse_collection,
    createCidrCollectionResponse_location,
    createCidrCollectionResponse_httpStatus,
  )
where

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

-- | /See:/ 'newCreateCidrCollection' smart constructor.
data CreateCidrCollection = CreateCidrCollection'
  { -- | A unique identifier for the account that can be used to reference the
    -- collection from other API calls.
    CreateCidrCollection -> Text
name :: Prelude.Text,
    -- | A client-specific token that allows requests to be securely retried so
    -- that the intended outcome will only occur once, retries receive a
    -- similar response, and there are no additional edge cases to handle.
    CreateCidrCollection -> Text
callerReference :: Prelude.Text
  }
  deriving (CreateCidrCollection -> CreateCidrCollection -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateCidrCollection -> CreateCidrCollection -> Bool
$c/= :: CreateCidrCollection -> CreateCidrCollection -> Bool
== :: CreateCidrCollection -> CreateCidrCollection -> Bool
$c== :: CreateCidrCollection -> CreateCidrCollection -> Bool
Prelude.Eq, ReadPrec [CreateCidrCollection]
ReadPrec CreateCidrCollection
Int -> ReadS CreateCidrCollection
ReadS [CreateCidrCollection]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateCidrCollection]
$creadListPrec :: ReadPrec [CreateCidrCollection]
readPrec :: ReadPrec CreateCidrCollection
$creadPrec :: ReadPrec CreateCidrCollection
readList :: ReadS [CreateCidrCollection]
$creadList :: ReadS [CreateCidrCollection]
readsPrec :: Int -> ReadS CreateCidrCollection
$creadsPrec :: Int -> ReadS CreateCidrCollection
Prelude.Read, Int -> CreateCidrCollection -> ShowS
[CreateCidrCollection] -> ShowS
CreateCidrCollection -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateCidrCollection] -> ShowS
$cshowList :: [CreateCidrCollection] -> ShowS
show :: CreateCidrCollection -> String
$cshow :: CreateCidrCollection -> String
showsPrec :: Int -> CreateCidrCollection -> ShowS
$cshowsPrec :: Int -> CreateCidrCollection -> ShowS
Prelude.Show, forall x. Rep CreateCidrCollection x -> CreateCidrCollection
forall x. CreateCidrCollection -> Rep CreateCidrCollection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateCidrCollection x -> CreateCidrCollection
$cfrom :: forall x. CreateCidrCollection -> Rep CreateCidrCollection x
Prelude.Generic)

-- |
-- Create a value of 'CreateCidrCollection' 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:
--
-- 'name', 'createCidrCollection_name' - A unique identifier for the account that can be used to reference the
-- collection from other API calls.
--
-- 'callerReference', 'createCidrCollection_callerReference' - A client-specific token that allows requests to be securely retried so
-- that the intended outcome will only occur once, retries receive a
-- similar response, and there are no additional edge cases to handle.
newCreateCidrCollection ::
  -- | 'name'
  Prelude.Text ->
  -- | 'callerReference'
  Prelude.Text ->
  CreateCidrCollection
newCreateCidrCollection :: Text -> Text -> CreateCidrCollection
newCreateCidrCollection Text
pName_ Text
pCallerReference_ =
  CreateCidrCollection'
    { $sel:name:CreateCidrCollection' :: Text
name = Text
pName_,
      $sel:callerReference:CreateCidrCollection' :: Text
callerReference = Text
pCallerReference_
    }

-- | A unique identifier for the account that can be used to reference the
-- collection from other API calls.
createCidrCollection_name :: Lens.Lens' CreateCidrCollection Prelude.Text
createCidrCollection_name :: Lens' CreateCidrCollection Text
createCidrCollection_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCidrCollection' {Text
name :: Text
$sel:name:CreateCidrCollection' :: CreateCidrCollection -> Text
name} -> Text
name) (\s :: CreateCidrCollection
s@CreateCidrCollection' {} Text
a -> CreateCidrCollection
s {$sel:name:CreateCidrCollection' :: Text
name = Text
a} :: CreateCidrCollection)

-- | A client-specific token that allows requests to be securely retried so
-- that the intended outcome will only occur once, retries receive a
-- similar response, and there are no additional edge cases to handle.
createCidrCollection_callerReference :: Lens.Lens' CreateCidrCollection Prelude.Text
createCidrCollection_callerReference :: Lens' CreateCidrCollection Text
createCidrCollection_callerReference = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCidrCollection' {Text
callerReference :: Text
$sel:callerReference:CreateCidrCollection' :: CreateCidrCollection -> Text
callerReference} -> Text
callerReference) (\s :: CreateCidrCollection
s@CreateCidrCollection' {} Text
a -> CreateCidrCollection
s {$sel:callerReference:CreateCidrCollection' :: Text
callerReference = Text
a} :: CreateCidrCollection)

instance Core.AWSRequest CreateCidrCollection where
  type
    AWSResponse CreateCidrCollection =
      CreateCidrCollectionResponse
  request :: (Service -> Service)
-> CreateCidrCollection -> Request CreateCidrCollection
request Service -> Service
overrides =
    forall a. (ToRequest a, ToElement a) => Service -> a -> Request a
Request.postXML (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateCidrCollection
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateCidrCollection)))
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 CidrCollection
-> Maybe Text -> Int -> CreateCidrCollectionResponse
CreateCidrCollectionResponse'
            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
"Collection")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (ResponseHeaders
h forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Data..#? HeaderName
"Location")
            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 CreateCidrCollection where
  hashWithSalt :: Int -> CreateCidrCollection -> Int
hashWithSalt Int
_salt CreateCidrCollection' {Text
callerReference :: Text
name :: Text
$sel:callerReference:CreateCidrCollection' :: CreateCidrCollection -> Text
$sel:name:CreateCidrCollection' :: CreateCidrCollection -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
callerReference

instance Prelude.NFData CreateCidrCollection where
  rnf :: CreateCidrCollection -> ()
rnf CreateCidrCollection' {Text
callerReference :: Text
name :: Text
$sel:callerReference:CreateCidrCollection' :: CreateCidrCollection -> Text
$sel:name:CreateCidrCollection' :: CreateCidrCollection -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
callerReference

instance Data.ToElement CreateCidrCollection where
  toElement :: CreateCidrCollection -> Element
toElement =
    forall a. ToXML a => Name -> a -> Element
Data.mkElement
      Name
"{https://route53.amazonaws.com/doc/2013-04-01/}CreateCidrCollectionRequest"

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

instance Data.ToPath CreateCidrCollection where
  toPath :: CreateCidrCollection -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/2013-04-01/cidrcollection"

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

instance Data.ToXML CreateCidrCollection where
  toXML :: CreateCidrCollection -> XML
toXML CreateCidrCollection' {Text
callerReference :: Text
name :: Text
$sel:callerReference:CreateCidrCollection' :: CreateCidrCollection -> Text
$sel:name:CreateCidrCollection' :: CreateCidrCollection -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"Name" forall a. ToXML a => Name -> a -> XML
Data.@= Text
name,
        Name
"CallerReference" forall a. ToXML a => Name -> a -> XML
Data.@= Text
callerReference
      ]

-- | /See:/ 'newCreateCidrCollectionResponse' smart constructor.
data CreateCidrCollectionResponse = CreateCidrCollectionResponse'
  { -- | A complex type that contains information about the CIDR collection.
    CreateCidrCollectionResponse -> Maybe CidrCollection
collection :: Prelude.Maybe CidrCollection,
    -- | A unique URL that represents the location for the CIDR collection.
    CreateCidrCollectionResponse -> Maybe Text
location :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateCidrCollectionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateCidrCollectionResponse
-> CreateCidrCollectionResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateCidrCollectionResponse
-> CreateCidrCollectionResponse -> Bool
$c/= :: CreateCidrCollectionResponse
-> CreateCidrCollectionResponse -> Bool
== :: CreateCidrCollectionResponse
-> CreateCidrCollectionResponse -> Bool
$c== :: CreateCidrCollectionResponse
-> CreateCidrCollectionResponse -> Bool
Prelude.Eq, ReadPrec [CreateCidrCollectionResponse]
ReadPrec CreateCidrCollectionResponse
Int -> ReadS CreateCidrCollectionResponse
ReadS [CreateCidrCollectionResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateCidrCollectionResponse]
$creadListPrec :: ReadPrec [CreateCidrCollectionResponse]
readPrec :: ReadPrec CreateCidrCollectionResponse
$creadPrec :: ReadPrec CreateCidrCollectionResponse
readList :: ReadS [CreateCidrCollectionResponse]
$creadList :: ReadS [CreateCidrCollectionResponse]
readsPrec :: Int -> ReadS CreateCidrCollectionResponse
$creadsPrec :: Int -> ReadS CreateCidrCollectionResponse
Prelude.Read, Int -> CreateCidrCollectionResponse -> ShowS
[CreateCidrCollectionResponse] -> ShowS
CreateCidrCollectionResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateCidrCollectionResponse] -> ShowS
$cshowList :: [CreateCidrCollectionResponse] -> ShowS
show :: CreateCidrCollectionResponse -> String
$cshow :: CreateCidrCollectionResponse -> String
showsPrec :: Int -> CreateCidrCollectionResponse -> ShowS
$cshowsPrec :: Int -> CreateCidrCollectionResponse -> ShowS
Prelude.Show, forall x.
Rep CreateCidrCollectionResponse x -> CreateCidrCollectionResponse
forall x.
CreateCidrCollectionResponse -> Rep CreateCidrCollectionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateCidrCollectionResponse x -> CreateCidrCollectionResponse
$cfrom :: forall x.
CreateCidrCollectionResponse -> Rep CreateCidrCollectionResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateCidrCollectionResponse' 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:
--
-- 'collection', 'createCidrCollectionResponse_collection' - A complex type that contains information about the CIDR collection.
--
-- 'location', 'createCidrCollectionResponse_location' - A unique URL that represents the location for the CIDR collection.
--
-- 'httpStatus', 'createCidrCollectionResponse_httpStatus' - The response's http status code.
newCreateCidrCollectionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateCidrCollectionResponse
newCreateCidrCollectionResponse :: Int -> CreateCidrCollectionResponse
newCreateCidrCollectionResponse Int
pHttpStatus_ =
  CreateCidrCollectionResponse'
    { $sel:collection:CreateCidrCollectionResponse' :: Maybe CidrCollection
collection =
        forall a. Maybe a
Prelude.Nothing,
      $sel:location:CreateCidrCollectionResponse' :: Maybe Text
location = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateCidrCollectionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A complex type that contains information about the CIDR collection.
createCidrCollectionResponse_collection :: Lens.Lens' CreateCidrCollectionResponse (Prelude.Maybe CidrCollection)
createCidrCollectionResponse_collection :: Lens' CreateCidrCollectionResponse (Maybe CidrCollection)
createCidrCollectionResponse_collection = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCidrCollectionResponse' {Maybe CidrCollection
collection :: Maybe CidrCollection
$sel:collection:CreateCidrCollectionResponse' :: CreateCidrCollectionResponse -> Maybe CidrCollection
collection} -> Maybe CidrCollection
collection) (\s :: CreateCidrCollectionResponse
s@CreateCidrCollectionResponse' {} Maybe CidrCollection
a -> CreateCidrCollectionResponse
s {$sel:collection:CreateCidrCollectionResponse' :: Maybe CidrCollection
collection = Maybe CidrCollection
a} :: CreateCidrCollectionResponse)

-- | A unique URL that represents the location for the CIDR collection.
createCidrCollectionResponse_location :: Lens.Lens' CreateCidrCollectionResponse (Prelude.Maybe Prelude.Text)
createCidrCollectionResponse_location :: Lens' CreateCidrCollectionResponse (Maybe Text)
createCidrCollectionResponse_location = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCidrCollectionResponse' {Maybe Text
location :: Maybe Text
$sel:location:CreateCidrCollectionResponse' :: CreateCidrCollectionResponse -> Maybe Text
location} -> Maybe Text
location) (\s :: CreateCidrCollectionResponse
s@CreateCidrCollectionResponse' {} Maybe Text
a -> CreateCidrCollectionResponse
s {$sel:location:CreateCidrCollectionResponse' :: Maybe Text
location = Maybe Text
a} :: CreateCidrCollectionResponse)

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

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