{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Route53AutoNaming.Types.NamespaceFilter where

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
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'
  { -- | Specify the operator that you want to use to determine whether a
    -- namespace matches the specified value. Valid values for @Condition@ are
    -- one of the following.
    --
    -- -   @EQ@: When you specify @EQ@ for @Condition@, you can specify only
    --     one value. @EQ@ is supported for @TYPE@, @NAME@, and @HTTP_NAME@.
    --     @EQ@ is the default condition and can be omitted.
    --
    -- -   @BEGINS_WITH@: When you specify @BEGINS_WITH@ for @Condition@, you
    --     can specify only one value. @BEGINS_WITH@ is supported for @TYPE@,
    --     @NAME@, and @HTTP_NAME@.
    NamespaceFilter -> Maybe FilterCondition
condition :: Prelude.Maybe FilterCondition,
    -- | Specify the namespaces that you want to get using one of the following.
    --
    -- -   @TYPE@: Gets the namespaces of the specified type.
    --
    -- -   @NAME@: Gets the namespaces with the specified name.
    --
    -- -   @HTTP_NAME@: Gets the namespaces with the specified HTTP name.
    NamespaceFilter -> NamespaceFilterName
name :: NamespaceFilterName,
    -- | Specify the values that are applicable to the value that you specify for
    -- @Name@.
    --
    -- -   @TYPE@: Specify @HTTP@, @DNS_PUBLIC@, or @DNS_PRIVATE@.
    --
    -- -   @NAME@: Specify the name of the namespace, which is found in
    --     @Namespace.Name@.
    --
    -- -   @HTTP_NAME@: Specify the HTTP name of the namespace, which is found
    --     in @Namespace.Properties.HttpProperties.HttpName@.
    NamespaceFilter -> [Text]
values :: [Prelude.Text]
  }
  deriving (NamespaceFilter -> NamespaceFilter -> Bool
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]
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
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. 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' - Specify the operator that you want to use to determine whether a
-- namespace matches the specified value. Valid values for @Condition@ are
-- one of the following.
--
-- -   @EQ@: When you specify @EQ@ for @Condition@, you can specify only
--     one value. @EQ@ is supported for @TYPE@, @NAME@, and @HTTP_NAME@.
--     @EQ@ is the default condition and can be omitted.
--
-- -   @BEGINS_WITH@: When you specify @BEGINS_WITH@ for @Condition@, you
--     can specify only one value. @BEGINS_WITH@ is supported for @TYPE@,
--     @NAME@, and @HTTP_NAME@.
--
-- 'name', 'namespaceFilter_name' - Specify the namespaces that you want to get using one of the following.
--
-- -   @TYPE@: Gets the namespaces of the specified type.
--
-- -   @NAME@: Gets the namespaces with the specified name.
--
-- -   @HTTP_NAME@: Gets the namespaces with the specified HTTP name.
--
-- 'values', 'namespaceFilter_values' - Specify the values that are applicable to the value that you specify for
-- @Name@.
--
-- -   @TYPE@: Specify @HTTP@, @DNS_PUBLIC@, or @DNS_PRIVATE@.
--
-- -   @NAME@: Specify the name of the namespace, which is found in
--     @Namespace.Name@.
--
-- -   @HTTP_NAME@: Specify the HTTP name of the namespace, which is found
--     in @Namespace.Properties.HttpProperties.HttpName@.
newNamespaceFilter ::
  -- | 'name'
  NamespaceFilterName ->
  NamespaceFilter
newNamespaceFilter :: NamespaceFilterName -> NamespaceFilter
newNamespaceFilter NamespaceFilterName
pName_ =
  NamespaceFilter'
    { $sel:condition:NamespaceFilter' :: Maybe FilterCondition
condition = forall a. Maybe a
Prelude.Nothing,
      $sel:name:NamespaceFilter' :: NamespaceFilterName
name = NamespaceFilterName
pName_,
      $sel:values:NamespaceFilter' :: [Text]
values = forall a. Monoid a => a
Prelude.mempty
    }

-- | Specify the operator that you want to use to determine whether a
-- namespace matches the specified value. Valid values for @Condition@ are
-- one of the following.
--
-- -   @EQ@: When you specify @EQ@ for @Condition@, you can specify only
--     one value. @EQ@ is supported for @TYPE@, @NAME@, and @HTTP_NAME@.
--     @EQ@ is the default condition and can be omitted.
--
-- -   @BEGINS_WITH@: When you specify @BEGINS_WITH@ for @Condition@, you
--     can specify only one value. @BEGINS_WITH@ is supported for @TYPE@,
--     @NAME@, and @HTTP_NAME@.
namespaceFilter_condition :: Lens.Lens' NamespaceFilter (Prelude.Maybe FilterCondition)
namespaceFilter_condition :: Lens' NamespaceFilter (Maybe FilterCondition)
namespaceFilter_condition = 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 the namespaces that you want to get using one of the following.
--
-- -   @TYPE@: Gets the namespaces of the specified type.
--
-- -   @NAME@: Gets the namespaces with the specified name.
--
-- -   @HTTP_NAME@: Gets the namespaces with the specified HTTP name.
namespaceFilter_name :: Lens.Lens' NamespaceFilter NamespaceFilterName
namespaceFilter_name :: Lens' NamespaceFilter NamespaceFilterName
namespaceFilter_name = 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)

-- | Specify the values that are applicable to the value that you specify for
-- @Name@.
--
-- -   @TYPE@: Specify @HTTP@, @DNS_PUBLIC@, or @DNS_PRIVATE@.
--
-- -   @NAME@: Specify the name of the namespace, which is found in
--     @Namespace.Name@.
--
-- -   @HTTP_NAME@: Specify the HTTP name of the namespace, which is found
--     in @Namespace.Properties.HttpProperties.HttpName@.
namespaceFilter_values :: Lens.Lens' NamespaceFilter [Prelude.Text]
namespaceFilter_values :: Lens' NamespaceFilter [Text]
namespaceFilter_values = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable NamespaceFilter where
  hashWithSalt :: Int -> NamespaceFilter -> Int
hashWithSalt Int
_salt 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
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FilterCondition
condition
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NamespaceFilterName
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
values

instance Prelude.NFData NamespaceFilter where
  rnf :: NamespaceFilter -> ()
rnf 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
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe FilterCondition
condition
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NamespaceFilterName
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
values

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Condition" 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 FilterCondition
condition,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NamespaceFilterName
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Values" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
values)
          ]
      )