{-# 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.CreateInternetGateway
-- 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 an internet gateway for use with a VPC. After creating the
-- internet gateway, you attach it to a VPC using AttachInternetGateway.
--
-- For more information about your VPC and internet gateway, see the
-- <https://docs.aws.amazon.com/vpc/latest/userguide/ Amazon Virtual Private Cloud User Guide>.
module Amazonka.EC2.CreateInternetGateway
  ( -- * Creating a Request
    CreateInternetGateway (..),
    newCreateInternetGateway,

    -- * Request Lenses
    createInternetGateway_dryRun,
    createInternetGateway_tagSpecifications,

    -- * Destructuring the Response
    CreateInternetGatewayResponse (..),
    newCreateInternetGatewayResponse,

    -- * Response Lenses
    createInternetGatewayResponse_internetGateway,
    createInternetGatewayResponse_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:/ 'newCreateInternetGateway' smart constructor.
data CreateInternetGateway = CreateInternetGateway'
  { -- | 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@.
    CreateInternetGateway -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | The tags to assign to the internet gateway.
    CreateInternetGateway -> Maybe [TagSpecification]
tagSpecifications :: Prelude.Maybe [TagSpecification]
  }
  deriving (CreateInternetGateway -> CreateInternetGateway -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateInternetGateway -> CreateInternetGateway -> Bool
$c/= :: CreateInternetGateway -> CreateInternetGateway -> Bool
== :: CreateInternetGateway -> CreateInternetGateway -> Bool
$c== :: CreateInternetGateway -> CreateInternetGateway -> Bool
Prelude.Eq, ReadPrec [CreateInternetGateway]
ReadPrec CreateInternetGateway
Int -> ReadS CreateInternetGateway
ReadS [CreateInternetGateway]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateInternetGateway]
$creadListPrec :: ReadPrec [CreateInternetGateway]
readPrec :: ReadPrec CreateInternetGateway
$creadPrec :: ReadPrec CreateInternetGateway
readList :: ReadS [CreateInternetGateway]
$creadList :: ReadS [CreateInternetGateway]
readsPrec :: Int -> ReadS CreateInternetGateway
$creadsPrec :: Int -> ReadS CreateInternetGateway
Prelude.Read, Int -> CreateInternetGateway -> ShowS
[CreateInternetGateway] -> ShowS
CreateInternetGateway -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateInternetGateway] -> ShowS
$cshowList :: [CreateInternetGateway] -> ShowS
show :: CreateInternetGateway -> String
$cshow :: CreateInternetGateway -> String
showsPrec :: Int -> CreateInternetGateway -> ShowS
$cshowsPrec :: Int -> CreateInternetGateway -> ShowS
Prelude.Show, forall x. Rep CreateInternetGateway x -> CreateInternetGateway
forall x. CreateInternetGateway -> Rep CreateInternetGateway x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateInternetGateway x -> CreateInternetGateway
$cfrom :: forall x. CreateInternetGateway -> Rep CreateInternetGateway x
Prelude.Generic)

-- |
-- Create a value of 'CreateInternetGateway' 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', 'createInternetGateway_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@.
--
-- 'tagSpecifications', 'createInternetGateway_tagSpecifications' - The tags to assign to the internet gateway.
newCreateInternetGateway ::
  CreateInternetGateway
newCreateInternetGateway :: CreateInternetGateway
newCreateInternetGateway =
  CreateInternetGateway'
    { $sel:dryRun:CreateInternetGateway' :: Maybe Bool
dryRun = forall a. Maybe a
Prelude.Nothing,
      $sel:tagSpecifications:CreateInternetGateway' :: Maybe [TagSpecification]
tagSpecifications = forall a. Maybe a
Prelude.Nothing
    }

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

-- | The tags to assign to the internet gateway.
createInternetGateway_tagSpecifications :: Lens.Lens' CreateInternetGateway (Prelude.Maybe [TagSpecification])
createInternetGateway_tagSpecifications :: Lens' CreateInternetGateway (Maybe [TagSpecification])
createInternetGateway_tagSpecifications = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInternetGateway' {Maybe [TagSpecification]
tagSpecifications :: Maybe [TagSpecification]
$sel:tagSpecifications:CreateInternetGateway' :: CreateInternetGateway -> Maybe [TagSpecification]
tagSpecifications} -> Maybe [TagSpecification]
tagSpecifications) (\s :: CreateInternetGateway
s@CreateInternetGateway' {} Maybe [TagSpecification]
a -> CreateInternetGateway
s {$sel:tagSpecifications:CreateInternetGateway' :: Maybe [TagSpecification]
tagSpecifications = Maybe [TagSpecification]
a} :: CreateInternetGateway) 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 CreateInternetGateway where
  type
    AWSResponse CreateInternetGateway =
      CreateInternetGatewayResponse
  request :: (Service -> Service)
-> CreateInternetGateway -> Request CreateInternetGateway
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 CreateInternetGateway
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateInternetGateway)))
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 InternetGateway -> Int -> CreateInternetGatewayResponse
CreateInternetGatewayResponse'
            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
"internetGateway")
            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 CreateInternetGateway where
  hashWithSalt :: Int -> CreateInternetGateway -> Int
hashWithSalt Int
_salt CreateInternetGateway' {Maybe Bool
Maybe [TagSpecification]
tagSpecifications :: Maybe [TagSpecification]
dryRun :: Maybe Bool
$sel:tagSpecifications:CreateInternetGateway' :: CreateInternetGateway -> Maybe [TagSpecification]
$sel:dryRun:CreateInternetGateway' :: CreateInternetGateway -> 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 CreateInternetGateway where
  rnf :: CreateInternetGateway -> ()
rnf CreateInternetGateway' {Maybe Bool
Maybe [TagSpecification]
tagSpecifications :: Maybe [TagSpecification]
dryRun :: Maybe Bool
$sel:tagSpecifications:CreateInternetGateway' :: CreateInternetGateway -> Maybe [TagSpecification]
$sel:dryRun:CreateInternetGateway' :: CreateInternetGateway -> 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 CreateInternetGateway where
  toHeaders :: CreateInternetGateway -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery CreateInternetGateway where
  toQuery :: CreateInternetGateway -> QueryString
toQuery CreateInternetGateway' {Maybe Bool
Maybe [TagSpecification]
tagSpecifications :: Maybe [TagSpecification]
dryRun :: Maybe Bool
$sel:tagSpecifications:CreateInternetGateway' :: CreateInternetGateway -> Maybe [TagSpecification]
$sel:dryRun:CreateInternetGateway' :: CreateInternetGateway -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"CreateInternetGateway" :: 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:/ 'newCreateInternetGatewayResponse' smart constructor.
data CreateInternetGatewayResponse = CreateInternetGatewayResponse'
  { -- | Information about the internet gateway.
    CreateInternetGatewayResponse -> Maybe InternetGateway
internetGateway :: Prelude.Maybe InternetGateway,
    -- | The response's http status code.
    CreateInternetGatewayResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateInternetGatewayResponse
-> CreateInternetGatewayResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateInternetGatewayResponse
-> CreateInternetGatewayResponse -> Bool
$c/= :: CreateInternetGatewayResponse
-> CreateInternetGatewayResponse -> Bool
== :: CreateInternetGatewayResponse
-> CreateInternetGatewayResponse -> Bool
$c== :: CreateInternetGatewayResponse
-> CreateInternetGatewayResponse -> Bool
Prelude.Eq, ReadPrec [CreateInternetGatewayResponse]
ReadPrec CreateInternetGatewayResponse
Int -> ReadS CreateInternetGatewayResponse
ReadS [CreateInternetGatewayResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateInternetGatewayResponse]
$creadListPrec :: ReadPrec [CreateInternetGatewayResponse]
readPrec :: ReadPrec CreateInternetGatewayResponse
$creadPrec :: ReadPrec CreateInternetGatewayResponse
readList :: ReadS [CreateInternetGatewayResponse]
$creadList :: ReadS [CreateInternetGatewayResponse]
readsPrec :: Int -> ReadS CreateInternetGatewayResponse
$creadsPrec :: Int -> ReadS CreateInternetGatewayResponse
Prelude.Read, Int -> CreateInternetGatewayResponse -> ShowS
[CreateInternetGatewayResponse] -> ShowS
CreateInternetGatewayResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateInternetGatewayResponse] -> ShowS
$cshowList :: [CreateInternetGatewayResponse] -> ShowS
show :: CreateInternetGatewayResponse -> String
$cshow :: CreateInternetGatewayResponse -> String
showsPrec :: Int -> CreateInternetGatewayResponse -> ShowS
$cshowsPrec :: Int -> CreateInternetGatewayResponse -> ShowS
Prelude.Show, forall x.
Rep CreateInternetGatewayResponse x
-> CreateInternetGatewayResponse
forall x.
CreateInternetGatewayResponse
-> Rep CreateInternetGatewayResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateInternetGatewayResponse x
-> CreateInternetGatewayResponse
$cfrom :: forall x.
CreateInternetGatewayResponse
-> Rep CreateInternetGatewayResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateInternetGatewayResponse' 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:
--
-- 'internetGateway', 'createInternetGatewayResponse_internetGateway' - Information about the internet gateway.
--
-- 'httpStatus', 'createInternetGatewayResponse_httpStatus' - The response's http status code.
newCreateInternetGatewayResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateInternetGatewayResponse
newCreateInternetGatewayResponse :: Int -> CreateInternetGatewayResponse
newCreateInternetGatewayResponse Int
pHttpStatus_ =
  CreateInternetGatewayResponse'
    { $sel:internetGateway:CreateInternetGatewayResponse' :: Maybe InternetGateway
internetGateway =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateInternetGatewayResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the internet gateway.
createInternetGatewayResponse_internetGateway :: Lens.Lens' CreateInternetGatewayResponse (Prelude.Maybe InternetGateway)
createInternetGatewayResponse_internetGateway :: Lens' CreateInternetGatewayResponse (Maybe InternetGateway)
createInternetGatewayResponse_internetGateway = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInternetGatewayResponse' {Maybe InternetGateway
internetGateway :: Maybe InternetGateway
$sel:internetGateway:CreateInternetGatewayResponse' :: CreateInternetGatewayResponse -> Maybe InternetGateway
internetGateway} -> Maybe InternetGateway
internetGateway) (\s :: CreateInternetGatewayResponse
s@CreateInternetGatewayResponse' {} Maybe InternetGateway
a -> CreateInternetGatewayResponse
s {$sel:internetGateway:CreateInternetGatewayResponse' :: Maybe InternetGateway
internetGateway = Maybe InternetGateway
a} :: CreateInternetGatewayResponse)

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

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