{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:vpceId:AccessEndpoint' :: Maybe Text
vpceId = 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 :: Lens' AccessEndpoint (Maybe Text)
accessEndpoint_vpceId = 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 :: Lens' AccessEndpoint AccessEndpointType
accessEndpoint_endpointType = 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 Data.FromJSON AccessEndpoint where
  parseJSON :: Value -> Parser AccessEndpoint
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AccessEndpoint"
      ( \Object
x ->
          Maybe Text -> AccessEndpointType -> AccessEndpoint
AccessEndpoint'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"VpceId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"EndpointType")
      )

instance Prelude.Hashable AccessEndpoint where
  hashWithSalt :: Int -> AccessEndpoint -> Int
hashWithSalt Int
_salt AccessEndpoint' {Maybe Text
AccessEndpointType
endpointType :: AccessEndpointType
vpceId :: Maybe Text
$sel:endpointType:AccessEndpoint' :: AccessEndpoint -> AccessEndpointType
$sel:vpceId:AccessEndpoint' :: AccessEndpoint -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
vpceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` AccessEndpointType
endpointType

instance Prelude.NFData AccessEndpoint where
  rnf :: AccessEndpoint -> ()
rnf AccessEndpoint' {Maybe Text
AccessEndpointType
endpointType :: AccessEndpointType
vpceId :: Maybe Text
$sel:endpointType:AccessEndpoint' :: AccessEndpoint -> AccessEndpointType
$sel:vpceId:AccessEndpoint' :: AccessEndpoint -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
vpceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf AccessEndpointType
endpointType

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"VpceId" 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
vpceId,
            forall a. a -> Maybe a
Prelude.Just (Key
"EndpointType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= AccessEndpointType
endpointType)
          ]
      )