{-# 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.Route53AutoNaming.Types.NamespaceFilter
-- 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.Route53AutoNaming.Types.NamespaceFilter where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Route53AutoNaming.Types.FilterCondition
import Amazonka.Route53AutoNaming.Types.NamespaceFilterName

-- | A complex type that identifies the namespaces that you want to list. You
-- can choose to list public or private namespaces.
--
-- /See:/ 'newNamespaceFilter' smart constructor.
data NamespaceFilter = NamespaceFilter'
  { -- | The operator that you want to use to determine whether @ListNamespaces@
    -- returns a namespace. Valid values for @condition@ include:
    --
    -- [EQ]
    --     When you specify @EQ@ for the condition, you can choose to list only
    --     public namespaces or private namespaces, but not both. @EQ@ is the
    --     default condition and can be omitted.
    --
    -- [IN]
    --     When you specify @IN@ for the condition, you can choose to list
    --     public namespaces, private namespaces, or both.
    --
    -- [BETWEEN]
    --     Not applicable
    NamespaceFilter -> Maybe FilterCondition
condition :: Prelude.Maybe FilterCondition,
    -- | Specify @TYPE@.
    NamespaceFilter -> NamespaceFilterName
name :: NamespaceFilterName,
    -- | If you specify @EQ@ for @Condition@, specify either @DNS_PUBLIC@ or
    -- @DNS_PRIVATE@.
    --
    -- If you specify @IN@ for @Condition@, you can specify @DNS_PUBLIC@,
    -- @DNS_PRIVATE@, or both.
    NamespaceFilter -> [Text]
values :: [Prelude.Text]
  }
  deriving (NamespaceFilter -> NamespaceFilter -> Bool
(NamespaceFilter -> NamespaceFilter -> Bool)
-> (NamespaceFilter -> NamespaceFilter -> Bool)
-> Eq NamespaceFilter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NamespaceFilter -> NamespaceFilter -> Bool
$c/= :: NamespaceFilter -> NamespaceFilter -> Bool
== :: NamespaceFilter -> NamespaceFilter -> Bool
$c== :: NamespaceFilter -> NamespaceFilter -> Bool
Prelude.Eq, ReadPrec [NamespaceFilter]
ReadPrec NamespaceFilter
Int -> ReadS NamespaceFilter
ReadS [NamespaceFilter]
(Int -> ReadS NamespaceFilter)
-> ReadS [NamespaceFilter]
-> ReadPrec NamespaceFilter
-> ReadPrec [NamespaceFilter]
-> Read NamespaceFilter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NamespaceFilter]
$creadListPrec :: ReadPrec [NamespaceFilter]
readPrec :: ReadPrec NamespaceFilter
$creadPrec :: ReadPrec NamespaceFilter
readList :: ReadS [NamespaceFilter]
$creadList :: ReadS [NamespaceFilter]
readsPrec :: Int -> ReadS NamespaceFilter
$creadsPrec :: Int -> ReadS NamespaceFilter
Prelude.Read, Int -> NamespaceFilter -> ShowS
[NamespaceFilter] -> ShowS
NamespaceFilter -> String
(Int -> NamespaceFilter -> ShowS)
-> (NamespaceFilter -> String)
-> ([NamespaceFilter] -> ShowS)
-> Show NamespaceFilter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NamespaceFilter] -> ShowS
$cshowList :: [NamespaceFilter] -> ShowS
show :: NamespaceFilter -> String
$cshow :: NamespaceFilter -> String
showsPrec :: Int -> NamespaceFilter -> ShowS
$cshowsPrec :: Int -> NamespaceFilter -> ShowS
Prelude.Show, (forall x. NamespaceFilter -> Rep NamespaceFilter x)
-> (forall x. Rep NamespaceFilter x -> NamespaceFilter)
-> Generic NamespaceFilter
forall x. Rep NamespaceFilter x -> NamespaceFilter
forall x. NamespaceFilter -> Rep NamespaceFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NamespaceFilter x -> NamespaceFilter
$cfrom :: forall x. NamespaceFilter -> Rep NamespaceFilter x
Prelude.Generic)

-- |
-- Create a value of 'NamespaceFilter' 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:
--
-- 'condition', 'namespaceFilter_condition' - The operator that you want to use to determine whether @ListNamespaces@
-- returns a namespace. Valid values for @condition@ include:
--
-- [EQ]
--     When you specify @EQ@ for the condition, you can choose to list only
--     public namespaces or private namespaces, but not both. @EQ@ is the
--     default condition and can be omitted.
--
-- [IN]
--     When you specify @IN@ for the condition, you can choose to list
--     public namespaces, private namespaces, or both.
--
-- [BETWEEN]
--     Not applicable
--
-- 'name', 'namespaceFilter_name' - Specify @TYPE@.
--
-- 'values', 'namespaceFilter_values' - If you specify @EQ@ for @Condition@, specify either @DNS_PUBLIC@ or
-- @DNS_PRIVATE@.
--
-- If you specify @IN@ for @Condition@, you can specify @DNS_PUBLIC@,
-- @DNS_PRIVATE@, or both.
newNamespaceFilter ::
  -- | 'name'
  NamespaceFilterName ->
  NamespaceFilter
newNamespaceFilter :: NamespaceFilterName -> NamespaceFilter
newNamespaceFilter NamespaceFilterName
pName_ =
  NamespaceFilter' :: Maybe FilterCondition
-> NamespaceFilterName -> [Text] -> NamespaceFilter
NamespaceFilter'
    { $sel:condition:NamespaceFilter' :: Maybe FilterCondition
condition = Maybe FilterCondition
forall a. Maybe a
Prelude.Nothing,
      $sel:name:NamespaceFilter' :: NamespaceFilterName
name = NamespaceFilterName
pName_,
      $sel:values:NamespaceFilter' :: [Text]
values = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The operator that you want to use to determine whether @ListNamespaces@
-- returns a namespace. Valid values for @condition@ include:
--
-- [EQ]
--     When you specify @EQ@ for the condition, you can choose to list only
--     public namespaces or private namespaces, but not both. @EQ@ is the
--     default condition and can be omitted.
--
-- [IN]
--     When you specify @IN@ for the condition, you can choose to list
--     public namespaces, private namespaces, or both.
--
-- [BETWEEN]
--     Not applicable
namespaceFilter_condition :: Lens.Lens' NamespaceFilter (Prelude.Maybe FilterCondition)
namespaceFilter_condition :: (Maybe FilterCondition -> f (Maybe FilterCondition))
-> NamespaceFilter -> f NamespaceFilter
namespaceFilter_condition = (NamespaceFilter -> Maybe FilterCondition)
-> (NamespaceFilter -> Maybe FilterCondition -> NamespaceFilter)
-> Lens
     NamespaceFilter
     NamespaceFilter
     (Maybe FilterCondition)
     (Maybe FilterCondition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NamespaceFilter' {Maybe FilterCondition
condition :: Maybe FilterCondition
$sel:condition:NamespaceFilter' :: NamespaceFilter -> Maybe FilterCondition
condition} -> Maybe FilterCondition
condition) (\s :: NamespaceFilter
s@NamespaceFilter' {} Maybe FilterCondition
a -> NamespaceFilter
s {$sel:condition:NamespaceFilter' :: Maybe FilterCondition
condition = Maybe FilterCondition
a} :: NamespaceFilter)

-- | Specify @TYPE@.
namespaceFilter_name :: Lens.Lens' NamespaceFilter NamespaceFilterName
namespaceFilter_name :: (NamespaceFilterName -> f NamespaceFilterName)
-> NamespaceFilter -> f NamespaceFilter
namespaceFilter_name = (NamespaceFilter -> NamespaceFilterName)
-> (NamespaceFilter -> NamespaceFilterName -> NamespaceFilter)
-> Lens
     NamespaceFilter
     NamespaceFilter
     NamespaceFilterName
     NamespaceFilterName
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NamespaceFilter' {NamespaceFilterName
name :: NamespaceFilterName
$sel:name:NamespaceFilter' :: NamespaceFilter -> NamespaceFilterName
name} -> NamespaceFilterName
name) (\s :: NamespaceFilter
s@NamespaceFilter' {} NamespaceFilterName
a -> NamespaceFilter
s {$sel:name:NamespaceFilter' :: NamespaceFilterName
name = NamespaceFilterName
a} :: NamespaceFilter)

-- | If you specify @EQ@ for @Condition@, specify either @DNS_PUBLIC@ or
-- @DNS_PRIVATE@.
--
-- If you specify @IN@ for @Condition@, you can specify @DNS_PUBLIC@,
-- @DNS_PRIVATE@, or both.
namespaceFilter_values :: Lens.Lens' NamespaceFilter [Prelude.Text]
namespaceFilter_values :: ([Text] -> f [Text]) -> NamespaceFilter -> f NamespaceFilter
namespaceFilter_values = (NamespaceFilter -> [Text])
-> (NamespaceFilter -> [Text] -> NamespaceFilter)
-> Lens NamespaceFilter NamespaceFilter [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NamespaceFilter' {[Text]
values :: [Text]
$sel:values:NamespaceFilter' :: NamespaceFilter -> [Text]
values} -> [Text]
values) (\s :: NamespaceFilter
s@NamespaceFilter' {} [Text]
a -> NamespaceFilter
s {$sel:values:NamespaceFilter' :: [Text]
values = [Text]
a} :: NamespaceFilter) (([Text] -> f [Text]) -> NamespaceFilter -> f NamespaceFilter)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> NamespaceFilter
-> f NamespaceFilter
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable NamespaceFilter

instance Prelude.NFData NamespaceFilter

instance Core.ToJSON NamespaceFilter where
  toJSON :: NamespaceFilter -> Value
toJSON NamespaceFilter' {[Text]
Maybe FilterCondition
NamespaceFilterName
values :: [Text]
name :: NamespaceFilterName
condition :: Maybe FilterCondition
$sel:values:NamespaceFilter' :: NamespaceFilter -> [Text]
$sel:name:NamespaceFilter' :: NamespaceFilter -> NamespaceFilterName
$sel:condition:NamespaceFilter' :: NamespaceFilter -> Maybe FilterCondition
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Condition" Text -> FilterCondition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (FilterCondition -> Pair) -> Maybe FilterCondition -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FilterCondition
condition,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> NamespaceFilterName -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NamespaceFilterName
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Values" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
values)
          ]
      )