{-# 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.AppMesh.Types.EgressFilter
-- 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.AppMesh.Types.EgressFilter where

import Amazonka.AppMesh.Types.EgressFilterType
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

-- | An object that represents the egress filter rules for a service mesh.
--
-- /See:/ 'newEgressFilter' smart constructor.
data EgressFilter = EgressFilter'
  { -- | The egress filter type. By default, the type is @DROP_ALL@, which allows
    -- egress only from virtual nodes to other defined resources in the service
    -- mesh (and any traffic to @*.amazonaws.com@ for Amazon Web Services API
    -- calls). You can set the egress filter type to @ALLOW_ALL@ to allow
    -- egress to any endpoint inside or outside of the service mesh.
    EgressFilter -> EgressFilterType
type' :: EgressFilterType
  }
  deriving (EgressFilter -> EgressFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EgressFilter -> EgressFilter -> Bool
$c/= :: EgressFilter -> EgressFilter -> Bool
== :: EgressFilter -> EgressFilter -> Bool
$c== :: EgressFilter -> EgressFilter -> Bool
Prelude.Eq, ReadPrec [EgressFilter]
ReadPrec EgressFilter
Int -> ReadS EgressFilter
ReadS [EgressFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EgressFilter]
$creadListPrec :: ReadPrec [EgressFilter]
readPrec :: ReadPrec EgressFilter
$creadPrec :: ReadPrec EgressFilter
readList :: ReadS [EgressFilter]
$creadList :: ReadS [EgressFilter]
readsPrec :: Int -> ReadS EgressFilter
$creadsPrec :: Int -> ReadS EgressFilter
Prelude.Read, Int -> EgressFilter -> ShowS
[EgressFilter] -> ShowS
EgressFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EgressFilter] -> ShowS
$cshowList :: [EgressFilter] -> ShowS
show :: EgressFilter -> String
$cshow :: EgressFilter -> String
showsPrec :: Int -> EgressFilter -> ShowS
$cshowsPrec :: Int -> EgressFilter -> ShowS
Prelude.Show, forall x. Rep EgressFilter x -> EgressFilter
forall x. EgressFilter -> Rep EgressFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EgressFilter x -> EgressFilter
$cfrom :: forall x. EgressFilter -> Rep EgressFilter x
Prelude.Generic)

-- |
-- Create a value of 'EgressFilter' 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:
--
-- 'type'', 'egressFilter_type' - The egress filter type. By default, the type is @DROP_ALL@, which allows
-- egress only from virtual nodes to other defined resources in the service
-- mesh (and any traffic to @*.amazonaws.com@ for Amazon Web Services API
-- calls). You can set the egress filter type to @ALLOW_ALL@ to allow
-- egress to any endpoint inside or outside of the service mesh.
newEgressFilter ::
  -- | 'type''
  EgressFilterType ->
  EgressFilter
newEgressFilter :: EgressFilterType -> EgressFilter
newEgressFilter EgressFilterType
pType_ =
  EgressFilter' {$sel:type':EgressFilter' :: EgressFilterType
type' = EgressFilterType
pType_}

-- | The egress filter type. By default, the type is @DROP_ALL@, which allows
-- egress only from virtual nodes to other defined resources in the service
-- mesh (and any traffic to @*.amazonaws.com@ for Amazon Web Services API
-- calls). You can set the egress filter type to @ALLOW_ALL@ to allow
-- egress to any endpoint inside or outside of the service mesh.
egressFilter_type :: Lens.Lens' EgressFilter EgressFilterType
egressFilter_type :: Lens' EgressFilter EgressFilterType
egressFilter_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EgressFilter' {EgressFilterType
type' :: EgressFilterType
$sel:type':EgressFilter' :: EgressFilter -> EgressFilterType
type'} -> EgressFilterType
type') (\s :: EgressFilter
s@EgressFilter' {} EgressFilterType
a -> EgressFilter
s {$sel:type':EgressFilter' :: EgressFilterType
type' = EgressFilterType
a} :: EgressFilter)

instance Data.FromJSON EgressFilter where
  parseJSON :: Value -> Parser EgressFilter
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EgressFilter"
      (\Object
x -> EgressFilterType -> EgressFilter
EgressFilter' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"type"))

instance Prelude.Hashable EgressFilter where
  hashWithSalt :: Int -> EgressFilter -> Int
hashWithSalt Int
_salt EgressFilter' {EgressFilterType
type' :: EgressFilterType
$sel:type':EgressFilter' :: EgressFilter -> EgressFilterType
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` EgressFilterType
type'

instance Prelude.NFData EgressFilter where
  rnf :: EgressFilter -> ()
rnf EgressFilter' {EgressFilterType
type' :: EgressFilterType
$sel:type':EgressFilter' :: EgressFilter -> EgressFilterType
..} = forall a. NFData a => a -> ()
Prelude.rnf EgressFilterType
type'

instance Data.ToJSON EgressFilter where
  toJSON :: EgressFilter -> Value
toJSON EgressFilter' {EgressFilterType
type' :: EgressFilterType
$sel:type':EgressFilter' :: EgressFilter -> EgressFilterType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= EgressFilterType
type')]
      )