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

import Amazonka.APIGateway.Types.EndpointType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(EndpointConfiguration -> EndpointConfiguration -> Bool)
-> (EndpointConfiguration -> EndpointConfiguration -> Bool)
-> Eq EndpointConfiguration
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]
(Int -> ReadS EndpointConfiguration)
-> ReadS [EndpointConfiguration]
-> ReadPrec EndpointConfiguration
-> ReadPrec [EndpointConfiguration]
-> Read 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
(Int -> EndpointConfiguration -> ShowS)
-> (EndpointConfiguration -> String)
-> ([EndpointConfiguration] -> ShowS)
-> Show EndpointConfiguration
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. EndpointConfiguration -> Rep EndpointConfiguration x)
-> (forall x. Rep EndpointConfiguration x -> EndpointConfiguration)
-> Generic EndpointConfiguration
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' :: Maybe [EndpointType] -> Maybe [Text] -> EndpointConfiguration
EndpointConfiguration'
    { $sel:types:EndpointConfiguration' :: Maybe [EndpointType]
types = Maybe [EndpointType]
forall a. Maybe a
Prelude.Nothing,
      $sel:vpcEndpointIds:EndpointConfiguration' :: Maybe [Text]
vpcEndpointIds = Maybe [Text]
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 :: (Maybe [EndpointType] -> f (Maybe [EndpointType]))
-> EndpointConfiguration -> f EndpointConfiguration
endpointConfiguration_types = (EndpointConfiguration -> Maybe [EndpointType])
-> (EndpointConfiguration
    -> Maybe [EndpointType] -> EndpointConfiguration)
-> Lens
     EndpointConfiguration
     EndpointConfiguration
     (Maybe [EndpointType])
     (Maybe [EndpointType])
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) ((Maybe [EndpointType] -> f (Maybe [EndpointType]))
 -> EndpointConfiguration -> f EndpointConfiguration)
-> ((Maybe [EndpointType] -> f (Maybe [EndpointType]))
    -> Maybe [EndpointType] -> f (Maybe [EndpointType]))
-> (Maybe [EndpointType] -> f (Maybe [EndpointType]))
-> EndpointConfiguration
-> f EndpointConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [EndpointType] [EndpointType] [EndpointType] [EndpointType]
-> Iso
     (Maybe [EndpointType])
     (Maybe [EndpointType])
     (Maybe [EndpointType])
     (Maybe [EndpointType])
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 [EndpointType] [EndpointType] [EndpointType] [EndpointType]
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 :: (Maybe [Text] -> f (Maybe [Text]))
-> EndpointConfiguration -> f EndpointConfiguration
endpointConfiguration_vpcEndpointIds = (EndpointConfiguration -> Maybe [Text])
-> (EndpointConfiguration -> Maybe [Text] -> EndpointConfiguration)
-> Lens
     EndpointConfiguration
     EndpointConfiguration
     (Maybe [Text])
     (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> EndpointConfiguration -> f EndpointConfiguration)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> EndpointConfiguration
-> f EndpointConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON EndpointConfiguration where
  parseJSON :: Value -> Parser EndpointConfiguration
parseJSON =
    String
-> (Object -> Parser EndpointConfiguration)
-> Value
-> Parser EndpointConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EndpointConfiguration"
      ( \Object
x ->
          Maybe [EndpointType] -> Maybe [Text] -> EndpointConfiguration
EndpointConfiguration'
            (Maybe [EndpointType] -> Maybe [Text] -> EndpointConfiguration)
-> Parser (Maybe [EndpointType])
-> Parser (Maybe [Text] -> EndpointConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [EndpointType]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"types" Parser (Maybe (Maybe [EndpointType]))
-> Maybe [EndpointType] -> Parser (Maybe [EndpointType])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [EndpointType]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe [Text] -> EndpointConfiguration)
-> Parser (Maybe [Text]) -> Parser EndpointConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"vpcEndpointIds"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable EndpointConfiguration

instance Prelude.NFData EndpointConfiguration

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