{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.AppStream.Types.AccessEndpoint
-- 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)
module Amazonka.AppStream.Types.AccessEndpoint where

import Amazonka.AppStream.Types.AccessEndpointType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes an interface VPC endpoint (interface endpoint) that lets you
-- create a private connection between the virtual private cloud (VPC) that
-- you specify and AppStream 2.0. When you specify an interface endpoint
-- for a stack, users of the stack can connect to AppStream 2.0 only
-- through that endpoint. When you specify an interface endpoint for an
-- image builder, administrators can connect to the image builder only
-- through that endpoint.
--
-- /See:/ 'newAccessEndpoint' smart constructor.
data AccessEndpoint = AccessEndpoint'
  { -- | The identifier (ID) of the VPC in which the interface endpoint is used.
    AccessEndpoint -> Maybe Text
vpceId :: Prelude.Maybe Prelude.Text,
    -- | The type of interface endpoint.
    AccessEndpoint -> AccessEndpointType
endpointType :: AccessEndpointType
  }
  deriving (AccessEndpoint -> AccessEndpoint -> Bool
(AccessEndpoint -> AccessEndpoint -> Bool)
-> (AccessEndpoint -> AccessEndpoint -> Bool) -> Eq AccessEndpoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccessEndpoint -> AccessEndpoint -> Bool
$c/= :: AccessEndpoint -> AccessEndpoint -> Bool
== :: AccessEndpoint -> AccessEndpoint -> Bool
$c== :: AccessEndpoint -> AccessEndpoint -> Bool
Prelude.Eq, ReadPrec [AccessEndpoint]
ReadPrec AccessEndpoint
Int -> ReadS AccessEndpoint
ReadS [AccessEndpoint]
(Int -> ReadS AccessEndpoint)
-> ReadS [AccessEndpoint]
-> ReadPrec AccessEndpoint
-> ReadPrec [AccessEndpoint]
-> Read AccessEndpoint
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AccessEndpoint]
$creadListPrec :: ReadPrec [AccessEndpoint]
readPrec :: ReadPrec AccessEndpoint
$creadPrec :: ReadPrec AccessEndpoint
readList :: ReadS [AccessEndpoint]
$creadList :: ReadS [AccessEndpoint]
readsPrec :: Int -> ReadS AccessEndpoint
$creadsPrec :: Int -> ReadS AccessEndpoint
Prelude.Read, Int -> AccessEndpoint -> ShowS
[AccessEndpoint] -> ShowS
AccessEndpoint -> String
(Int -> AccessEndpoint -> ShowS)
-> (AccessEndpoint -> String)
-> ([AccessEndpoint] -> ShowS)
-> Show AccessEndpoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccessEndpoint] -> ShowS
$cshowList :: [AccessEndpoint] -> ShowS
show :: AccessEndpoint -> String
$cshow :: AccessEndpoint -> String
showsPrec :: Int -> AccessEndpoint -> ShowS
$cshowsPrec :: Int -> AccessEndpoint -> ShowS
Prelude.Show, (forall x. AccessEndpoint -> Rep AccessEndpoint x)
-> (forall x. Rep AccessEndpoint x -> AccessEndpoint)
-> Generic AccessEndpoint
forall x. Rep AccessEndpoint x -> AccessEndpoint
forall x. AccessEndpoint -> Rep AccessEndpoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AccessEndpoint x -> AccessEndpoint
$cfrom :: forall x. AccessEndpoint -> Rep AccessEndpoint x
Prelude.Generic)

-- |
-- Create a value of 'AccessEndpoint' 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:
--
-- 'vpceId', 'accessEndpoint_vpceId' - The identifier (ID) of the VPC in which the interface endpoint is used.
--
-- 'endpointType', 'accessEndpoint_endpointType' - The type of interface endpoint.
newAccessEndpoint ::
  -- | 'endpointType'
  AccessEndpointType ->
  AccessEndpoint
newAccessEndpoint :: AccessEndpointType -> AccessEndpoint
newAccessEndpoint AccessEndpointType
pEndpointType_ =
  AccessEndpoint' :: Maybe Text -> AccessEndpointType -> AccessEndpoint
AccessEndpoint'
    { $sel:vpceId:AccessEndpoint' :: Maybe Text
vpceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endpointType:AccessEndpoint' :: AccessEndpointType
endpointType = AccessEndpointType
pEndpointType_
    }

-- | The identifier (ID) of the VPC in which the interface endpoint is used.
accessEndpoint_vpceId :: Lens.Lens' AccessEndpoint (Prelude.Maybe Prelude.Text)
accessEndpoint_vpceId :: (Maybe Text -> f (Maybe Text))
-> AccessEndpoint -> f AccessEndpoint
accessEndpoint_vpceId = (AccessEndpoint -> Maybe Text)
-> (AccessEndpoint -> Maybe Text -> AccessEndpoint)
-> Lens AccessEndpoint AccessEndpoint (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessEndpoint' {Maybe Text
vpceId :: Maybe Text
$sel:vpceId:AccessEndpoint' :: AccessEndpoint -> Maybe Text
vpceId} -> Maybe Text
vpceId) (\s :: AccessEndpoint
s@AccessEndpoint' {} Maybe Text
a -> AccessEndpoint
s {$sel:vpceId:AccessEndpoint' :: Maybe Text
vpceId = Maybe Text
a} :: AccessEndpoint)

-- | The type of interface endpoint.
accessEndpoint_endpointType :: Lens.Lens' AccessEndpoint AccessEndpointType
accessEndpoint_endpointType :: (AccessEndpointType -> f AccessEndpointType)
-> AccessEndpoint -> f AccessEndpoint
accessEndpoint_endpointType = (AccessEndpoint -> AccessEndpointType)
-> (AccessEndpoint -> AccessEndpointType -> AccessEndpoint)
-> Lens
     AccessEndpoint AccessEndpoint AccessEndpointType AccessEndpointType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessEndpoint' {AccessEndpointType
endpointType :: AccessEndpointType
$sel:endpointType:AccessEndpoint' :: AccessEndpoint -> AccessEndpointType
endpointType} -> AccessEndpointType
endpointType) (\s :: AccessEndpoint
s@AccessEndpoint' {} AccessEndpointType
a -> AccessEndpoint
s {$sel:endpointType:AccessEndpoint' :: AccessEndpointType
endpointType = AccessEndpointType
a} :: AccessEndpoint)

instance Core.FromJSON AccessEndpoint where
  parseJSON :: Value -> Parser AccessEndpoint
parseJSON =
    String
-> (Object -> Parser AccessEndpoint)
-> Value
-> Parser AccessEndpoint
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AccessEndpoint"
      ( \Object
x ->
          Maybe Text -> AccessEndpointType -> AccessEndpoint
AccessEndpoint'
            (Maybe Text -> AccessEndpointType -> AccessEndpoint)
-> Parser (Maybe Text)
-> Parser (AccessEndpointType -> AccessEndpoint)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"VpceId")
            Parser (AccessEndpointType -> AccessEndpoint)
-> Parser AccessEndpointType -> Parser AccessEndpoint
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser AccessEndpointType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"EndpointType")
      )

instance Prelude.Hashable AccessEndpoint

instance Prelude.NFData AccessEndpoint

instance Core.ToJSON AccessEndpoint where
  toJSON :: AccessEndpoint -> Value
toJSON AccessEndpoint' {Maybe Text
AccessEndpointType
endpointType :: AccessEndpointType
vpceId :: Maybe Text
$sel:endpointType:AccessEndpoint' :: AccessEndpoint -> AccessEndpointType
$sel:vpceId:AccessEndpoint' :: AccessEndpoint -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"VpceId" 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
vpceId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"EndpointType" Text -> AccessEndpointType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AccessEndpointType
endpointType)
          ]
      )