{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- 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_status,
    vpcLink_targetArns,
    vpcLink_name,
    vpcLink_statusMessage,
    vpcLink_id,
    vpcLink_description,
    vpcLink_tags,
  )
where

import Amazonka.APIGateway.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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),
    -- | [Required] The name used to label and identify the VPC link.
    CreateVpcLink -> Text
name :: Prelude.Text,
    -- | [Required] 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
(CreateVpcLink -> CreateVpcLink -> Bool)
-> (CreateVpcLink -> CreateVpcLink -> Bool) -> Eq CreateVpcLink
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]
(Int -> ReadS CreateVpcLink)
-> ReadS [CreateVpcLink]
-> ReadPrec CreateVpcLink
-> ReadPrec [CreateVpcLink]
-> Read 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
(Int -> CreateVpcLink -> ShowS)
-> (CreateVpcLink -> String)
-> ([CreateVpcLink] -> ShowS)
-> Show CreateVpcLink
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. CreateVpcLink -> Rep CreateVpcLink x)
-> (forall x. Rep CreateVpcLink x -> CreateVpcLink)
-> Generic CreateVpcLink
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' - [Required] The name used to label and identify the VPC link.
--
-- 'targetArns', 'createVpcLink_targetArns' - [Required] 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' :: Maybe Text
-> Maybe (HashMap Text Text) -> Text -> [Text] -> CreateVpcLink
CreateVpcLink'
    { $sel:description:CreateVpcLink' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateVpcLink' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CreateVpcLink' :: Text
name = Text
pName_,
      $sel:targetArns:CreateVpcLink' :: [Text]
targetArns = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The description of the VPC link.
createVpcLink_description :: Lens.Lens' CreateVpcLink (Prelude.Maybe Prelude.Text)
createVpcLink_description :: (Maybe Text -> f (Maybe Text)) -> CreateVpcLink -> f CreateVpcLink
createVpcLink_description = (CreateVpcLink -> Maybe Text)
-> (CreateVpcLink -> Maybe Text -> CreateVpcLink)
-> Lens CreateVpcLink CreateVpcLink (Maybe Text) (Maybe Text)
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 :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateVpcLink -> f CreateVpcLink
createVpcLink_tags = (CreateVpcLink -> Maybe (HashMap Text Text))
-> (CreateVpcLink -> Maybe (HashMap Text Text) -> CreateVpcLink)
-> Lens
     CreateVpcLink
     CreateVpcLink
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> CreateVpcLink -> f CreateVpcLink)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateVpcLink
-> f CreateVpcLink
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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 AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | [Required] The name used to label and identify the VPC link.
createVpcLink_name :: Lens.Lens' CreateVpcLink Prelude.Text
createVpcLink_name :: (Text -> f Text) -> CreateVpcLink -> f CreateVpcLink
createVpcLink_name = (CreateVpcLink -> Text)
-> (CreateVpcLink -> Text -> CreateVpcLink)
-> Lens CreateVpcLink CreateVpcLink Text Text
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)

-- | [Required] 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 :: ([Text] -> f [Text]) -> CreateVpcLink -> f CreateVpcLink
createVpcLink_targetArns = (CreateVpcLink -> [Text])
-> (CreateVpcLink -> [Text] -> CreateVpcLink)
-> Lens CreateVpcLink CreateVpcLink [Text] [Text]
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) (([Text] -> f [Text]) -> CreateVpcLink -> f CreateVpcLink)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> CreateVpcLink
-> f CreateVpcLink
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
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 :: CreateVpcLink -> Request CreateVpcLink
request = Service -> CreateVpcLink -> Request CreateVpcLink
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateVpcLink
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateVpcLink)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateVpcLink))
-> Logger
-> Service
-> Proxy CreateVpcLink
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateVpcLink)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> Object -> Either String VpcLink
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable CreateVpcLink

instance Prelude.NFData CreateVpcLink

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

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            (Text
"tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"targetArns" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
targetArns)
          ]
      )

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

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