{-# 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.APIGateway.Types.EndpointConfiguration
-- 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.APIGateway.Types.EndpointConfiguration where

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

-- | The endpoint configuration to indicate the types of endpoints an API
-- (RestApi) or its custom domain name (DomainName) has.
--
-- /See:/ 'newEndpointConfiguration' smart constructor.
data EndpointConfiguration = EndpointConfiguration'
  { -- | A list of endpoint types of an API (RestApi) or its custom domain name
    -- (DomainName). For an edge-optimized API and its custom domain name, the
    -- endpoint type is @\"EDGE\"@. For a regional API and its custom domain
    -- name, the endpoint type is @REGIONAL@. For a private API, the endpoint
    -- type is @PRIVATE@.
    EndpointConfiguration -> Maybe [EndpointType]
types :: Prelude.Maybe [EndpointType],
    -- | A list of VpcEndpointIds of an API (RestApi) against which to create
    -- Route53 ALIASes. It is only supported for @PRIVATE@ endpoint type.
    EndpointConfiguration -> Maybe [Text]
vpcEndpointIds :: Prelude.Maybe [Prelude.Text]
  }
  deriving (EndpointConfiguration -> EndpointConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EndpointConfiguration -> EndpointConfiguration -> Bool
$c/= :: EndpointConfiguration -> EndpointConfiguration -> Bool
== :: EndpointConfiguration -> EndpointConfiguration -> Bool
$c== :: EndpointConfiguration -> EndpointConfiguration -> Bool
Prelude.Eq, ReadPrec [EndpointConfiguration]
ReadPrec EndpointConfiguration
Int -> ReadS EndpointConfiguration
ReadS [EndpointConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EndpointConfiguration]
$creadListPrec :: ReadPrec [EndpointConfiguration]
readPrec :: ReadPrec EndpointConfiguration
$creadPrec :: ReadPrec EndpointConfiguration
readList :: ReadS [EndpointConfiguration]
$creadList :: ReadS [EndpointConfiguration]
readsPrec :: Int -> ReadS EndpointConfiguration
$creadsPrec :: Int -> ReadS EndpointConfiguration
Prelude.Read, Int -> EndpointConfiguration -> ShowS
[EndpointConfiguration] -> ShowS
EndpointConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EndpointConfiguration] -> ShowS
$cshowList :: [EndpointConfiguration] -> ShowS
show :: EndpointConfiguration -> String
$cshow :: EndpointConfiguration -> String
showsPrec :: Int -> EndpointConfiguration -> ShowS
$cshowsPrec :: Int -> EndpointConfiguration -> ShowS
Prelude.Show, forall x. Rep EndpointConfiguration x -> EndpointConfiguration
forall x. EndpointConfiguration -> Rep EndpointConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EndpointConfiguration x -> EndpointConfiguration
$cfrom :: forall x. EndpointConfiguration -> Rep EndpointConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'EndpointConfiguration' 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:
--
-- 'types', 'endpointConfiguration_types' - A list of endpoint types of an API (RestApi) or its custom domain name
-- (DomainName). For an edge-optimized API and its custom domain name, the
-- endpoint type is @\"EDGE\"@. For a regional API and its custom domain
-- name, the endpoint type is @REGIONAL@. For a private API, the endpoint
-- type is @PRIVATE@.
--
-- 'vpcEndpointIds', 'endpointConfiguration_vpcEndpointIds' - A list of VpcEndpointIds of an API (RestApi) against which to create
-- Route53 ALIASes. It is only supported for @PRIVATE@ endpoint type.
newEndpointConfiguration ::
  EndpointConfiguration
newEndpointConfiguration :: EndpointConfiguration
newEndpointConfiguration =
  EndpointConfiguration'
    { $sel:types:EndpointConfiguration' :: Maybe [EndpointType]
types = forall a. Maybe a
Prelude.Nothing,
      $sel:vpcEndpointIds:EndpointConfiguration' :: Maybe [Text]
vpcEndpointIds = forall a. Maybe a
Prelude.Nothing
    }

-- | A list of endpoint types of an API (RestApi) or its custom domain name
-- (DomainName). For an edge-optimized API and its custom domain name, the
-- endpoint type is @\"EDGE\"@. For a regional API and its custom domain
-- name, the endpoint type is @REGIONAL@. For a private API, the endpoint
-- type is @PRIVATE@.
endpointConfiguration_types :: Lens.Lens' EndpointConfiguration (Prelude.Maybe [EndpointType])
endpointConfiguration_types :: Lens' EndpointConfiguration (Maybe [EndpointType])
endpointConfiguration_types = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointConfiguration' {Maybe [EndpointType]
types :: Maybe [EndpointType]
$sel:types:EndpointConfiguration' :: EndpointConfiguration -> Maybe [EndpointType]
types} -> Maybe [EndpointType]
types) (\s :: EndpointConfiguration
s@EndpointConfiguration' {} Maybe [EndpointType]
a -> EndpointConfiguration
s {$sel:types:EndpointConfiguration' :: Maybe [EndpointType]
types = Maybe [EndpointType]
a} :: EndpointConfiguration) 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

-- | A list of VpcEndpointIds of an API (RestApi) against which to create
-- Route53 ALIASes. It is only supported for @PRIVATE@ endpoint type.
endpointConfiguration_vpcEndpointIds :: Lens.Lens' EndpointConfiguration (Prelude.Maybe [Prelude.Text])
endpointConfiguration_vpcEndpointIds :: Lens' EndpointConfiguration (Maybe [Text])
endpointConfiguration_vpcEndpointIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointConfiguration' {Maybe [Text]
vpcEndpointIds :: Maybe [Text]
$sel:vpcEndpointIds:EndpointConfiguration' :: EndpointConfiguration -> Maybe [Text]
vpcEndpointIds} -> Maybe [Text]
vpcEndpointIds) (\s :: EndpointConfiguration
s@EndpointConfiguration' {} Maybe [Text]
a -> EndpointConfiguration
s {$sel:vpcEndpointIds:EndpointConfiguration' :: Maybe [Text]
vpcEndpointIds = Maybe [Text]
a} :: EndpointConfiguration) 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 Data.FromJSON EndpointConfiguration where
  parseJSON :: Value -> Parser EndpointConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EndpointConfiguration"
      ( \Object
x ->
          Maybe [EndpointType] -> Maybe [Text] -> EndpointConfiguration
EndpointConfiguration'
            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
"types" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"vpcEndpointIds"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable EndpointConfiguration where
  hashWithSalt :: Int -> EndpointConfiguration -> Int
hashWithSalt Int
_salt EndpointConfiguration' {Maybe [Text]
Maybe [EndpointType]
vpcEndpointIds :: Maybe [Text]
types :: Maybe [EndpointType]
$sel:vpcEndpointIds:EndpointConfiguration' :: EndpointConfiguration -> Maybe [Text]
$sel:types:EndpointConfiguration' :: EndpointConfiguration -> Maybe [EndpointType]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [EndpointType]
types
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
vpcEndpointIds

instance Prelude.NFData EndpointConfiguration where
  rnf :: EndpointConfiguration -> ()
rnf EndpointConfiguration' {Maybe [Text]
Maybe [EndpointType]
vpcEndpointIds :: Maybe [Text]
types :: Maybe [EndpointType]
$sel:vpcEndpointIds:EndpointConfiguration' :: EndpointConfiguration -> Maybe [Text]
$sel:types:EndpointConfiguration' :: EndpointConfiguration -> Maybe [EndpointType]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [EndpointType]
types
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
vpcEndpointIds

instance Data.ToJSON EndpointConfiguration where
  toJSON :: EndpointConfiguration -> Value
toJSON EndpointConfiguration' {Maybe [Text]
Maybe [EndpointType]
vpcEndpointIds :: Maybe [Text]
types :: Maybe [EndpointType]
$sel:vpcEndpointIds:EndpointConfiguration' :: EndpointConfiguration -> Maybe [Text]
$sel:types:EndpointConfiguration' :: EndpointConfiguration -> Maybe [EndpointType]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"types" 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 [EndpointType]
types,
            (Key
"vpcEndpointIds" 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]
vpcEndpointIds
          ]
      )