{-# 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.APIGateway.CreateVpcLink
-- 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 VPC link, under the caller\'s account in a selected region, in
-- an asynchronous operation that typically takes 2-4 minutes to complete
-- and become operational. The caller must have permissions to create and
-- update VPC Endpoint services.
module Amazonka.APIGateway.CreateVpcLink
  ( -- * Creating a Request
    CreateVpcLink (..),
    newCreateVpcLink,

    -- * Request Lenses
    createVpcLink_description,
    createVpcLink_tags,
    createVpcLink_name,
    createVpcLink_targetArns,

    -- * Destructuring the Response
    VpcLink (..),
    newVpcLink,

    -- * Response Lenses
    vpcLink_description,
    vpcLink_id,
    vpcLink_name,
    vpcLink_status,
    vpcLink_statusMessage,
    vpcLink_tags,
    vpcLink_targetArns,
  )
where

import Amazonka.APIGateway.Types
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

-- | Creates a VPC link, under the caller\'s account in a selected region, in
-- an asynchronous operation that typically takes 2-4 minutes to complete
-- and become operational. The caller must have permissions to create and
-- update VPC Endpoint services.
--
-- /See:/ 'newCreateVpcLink' smart constructor.
data CreateVpcLink = CreateVpcLink'
  { -- | The description of the VPC link.
    CreateVpcLink -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The key-value map of strings. The valid character set is
    -- [a-zA-Z+-=._:\/]. The tag key can be up to 128 characters and must not
    -- start with @aws:@. The tag value can be up to 256 characters.
    CreateVpcLink -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The name used to label and identify the VPC link.
    CreateVpcLink -> Text
name :: Prelude.Text,
    -- | The ARN of the network load balancer of the VPC targeted by the VPC
    -- link. The network load balancer must be owned by the same AWS account of
    -- the API owner.
    CreateVpcLink -> [Text]
targetArns :: [Prelude.Text]
  }
  deriving (CreateVpcLink -> CreateVpcLink -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateVpcLink -> CreateVpcLink -> Bool
$c/= :: CreateVpcLink -> CreateVpcLink -> Bool
== :: CreateVpcLink -> CreateVpcLink -> Bool
$c== :: CreateVpcLink -> CreateVpcLink -> Bool
Prelude.Eq, ReadPrec [CreateVpcLink]
ReadPrec CreateVpcLink
Int -> ReadS CreateVpcLink
ReadS [CreateVpcLink]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateVpcLink]
$creadListPrec :: ReadPrec [CreateVpcLink]
readPrec :: ReadPrec CreateVpcLink
$creadPrec :: ReadPrec CreateVpcLink
readList :: ReadS [CreateVpcLink]
$creadList :: ReadS [CreateVpcLink]
readsPrec :: Int -> ReadS CreateVpcLink
$creadsPrec :: Int -> ReadS CreateVpcLink
Prelude.Read, Int -> CreateVpcLink -> ShowS
[CreateVpcLink] -> ShowS
CreateVpcLink -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateVpcLink] -> ShowS
$cshowList :: [CreateVpcLink] -> ShowS
show :: CreateVpcLink -> String
$cshow :: CreateVpcLink -> String
showsPrec :: Int -> CreateVpcLink -> ShowS
$cshowsPrec :: Int -> CreateVpcLink -> ShowS
Prelude.Show, forall x. Rep CreateVpcLink x -> CreateVpcLink
forall x. CreateVpcLink -> Rep CreateVpcLink x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateVpcLink x -> CreateVpcLink
$cfrom :: forall x. CreateVpcLink -> Rep CreateVpcLink x
Prelude.Generic)

-- |
-- Create a value of 'CreateVpcLink' 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:
--
-- 'description', 'createVpcLink_description' - The description of the VPC link.
--
-- 'tags', 'createVpcLink_tags' - The key-value map of strings. The valid character set is
-- [a-zA-Z+-=._:\/]. The tag key can be up to 128 characters and must not
-- start with @aws:@. The tag value can be up to 256 characters.
--
-- 'name', 'createVpcLink_name' - The name used to label and identify the VPC link.
--
-- 'targetArns', 'createVpcLink_targetArns' - The ARN of the network load balancer of the VPC targeted by the VPC
-- link. The network load balancer must be owned by the same AWS account of
-- the API owner.
newCreateVpcLink ::
  -- | 'name'
  Prelude.Text ->
  CreateVpcLink
newCreateVpcLink :: Text -> CreateVpcLink
newCreateVpcLink Text
pName_ =
  CreateVpcLink'
    { $sel:description:CreateVpcLink' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateVpcLink' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:name:CreateVpcLink' :: Text
name = Text
pName_,
      $sel:targetArns:CreateVpcLink' :: [Text]
targetArns = forall a. Monoid a => a
Prelude.mempty
    }

-- | The description of the VPC link.
createVpcLink_description :: Lens.Lens' CreateVpcLink (Prelude.Maybe Prelude.Text)
createVpcLink_description :: Lens' CreateVpcLink (Maybe Text)
createVpcLink_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateVpcLink' {Maybe Text
description :: Maybe Text
$sel:description:CreateVpcLink' :: CreateVpcLink -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateVpcLink
s@CreateVpcLink' {} Maybe Text
a -> CreateVpcLink
s {$sel:description:CreateVpcLink' :: Maybe Text
description = Maybe Text
a} :: CreateVpcLink)

-- | The key-value map of strings. The valid character set is
-- [a-zA-Z+-=._:\/]. The tag key can be up to 128 characters and must not
-- start with @aws:@. The tag value can be up to 256 characters.
createVpcLink_tags :: Lens.Lens' CreateVpcLink (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createVpcLink_tags :: Lens' CreateVpcLink (Maybe (HashMap Text Text))
createVpcLink_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateVpcLink' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateVpcLink' :: CreateVpcLink -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateVpcLink
s@CreateVpcLink' {} Maybe (HashMap Text Text)
a -> CreateVpcLink
s {$sel:tags:CreateVpcLink' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateVpcLink) 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

-- | The name used to label and identify the VPC link.
createVpcLink_name :: Lens.Lens' CreateVpcLink Prelude.Text
createVpcLink_name :: Lens' CreateVpcLink Text
createVpcLink_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateVpcLink' {Text
name :: Text
$sel:name:CreateVpcLink' :: CreateVpcLink -> Text
name} -> Text
name) (\s :: CreateVpcLink
s@CreateVpcLink' {} Text
a -> CreateVpcLink
s {$sel:name:CreateVpcLink' :: Text
name = Text
a} :: CreateVpcLink)

-- | The ARN of the network load balancer of the VPC targeted by the VPC
-- link. The network load balancer must be owned by the same AWS account of
-- the API owner.
createVpcLink_targetArns :: Lens.Lens' CreateVpcLink [Prelude.Text]
createVpcLink_targetArns :: Lens' CreateVpcLink [Text]
createVpcLink_targetArns = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateVpcLink' {[Text]
targetArns :: [Text]
$sel:targetArns:CreateVpcLink' :: CreateVpcLink -> [Text]
targetArns} -> [Text]
targetArns) (\s :: CreateVpcLink
s@CreateVpcLink' {} [Text]
a -> CreateVpcLink
s {$sel:targetArns:CreateVpcLink' :: [Text]
targetArns = [Text]
a} :: CreateVpcLink) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest CreateVpcLink where
  type AWSResponse CreateVpcLink = VpcLink
  request :: (Service -> Service) -> CreateVpcLink -> Request CreateVpcLink
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateVpcLink
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateVpcLink)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)

instance Prelude.Hashable CreateVpcLink where
  hashWithSalt :: Int -> CreateVpcLink -> Int
hashWithSalt Int
_salt CreateVpcLink' {[Text]
Maybe Text
Maybe (HashMap Text Text)
Text
targetArns :: [Text]
name :: Text
tags :: Maybe (HashMap Text Text)
description :: Maybe Text
$sel:targetArns:CreateVpcLink' :: CreateVpcLink -> [Text]
$sel:name:CreateVpcLink' :: CreateVpcLink -> Text
$sel:tags:CreateVpcLink' :: CreateVpcLink -> Maybe (HashMap Text Text)
$sel:description:CreateVpcLink' :: CreateVpcLink -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
targetArns

instance Prelude.NFData CreateVpcLink where
  rnf :: CreateVpcLink -> ()
rnf CreateVpcLink' {[Text]
Maybe Text
Maybe (HashMap Text Text)
Text
targetArns :: [Text]
name :: Text
tags :: Maybe (HashMap Text Text)
description :: Maybe Text
$sel:targetArns:CreateVpcLink' :: CreateVpcLink -> [Text]
$sel:name:CreateVpcLink' :: CreateVpcLink -> Text
$sel:tags:CreateVpcLink' :: CreateVpcLink -> Maybe (HashMap Text Text)
$sel:description:CreateVpcLink' :: CreateVpcLink -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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]
targetArns

instance Data.ToHeaders CreateVpcLink where
  toHeaders :: CreateVpcLink -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Accept"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"application/json" :: Prelude.ByteString)
          ]
      )

instance Data.ToJSON CreateVpcLink where
  toJSON :: CreateVpcLink -> Value
toJSON CreateVpcLink' {[Text]
Maybe Text
Maybe (HashMap Text Text)
Text
targetArns :: [Text]
name :: Text
tags :: Maybe (HashMap Text Text)
description :: Maybe Text
$sel:targetArns:CreateVpcLink' :: CreateVpcLink -> [Text]
$sel:name:CreateVpcLink' :: CreateVpcLink -> Text
$sel:tags:CreateVpcLink' :: CreateVpcLink -> Maybe (HashMap Text Text)
$sel:description:CreateVpcLink' :: CreateVpcLink -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"description" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            (Key
"tags" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
            forall a. a -> Maybe a
Prelude.Just (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"targetArns" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
targetArns)
          ]
      )

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

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