{-# 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.ServiceFilter
-- 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.ServiceFilter 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.ServiceFilterName

-- | A complex type that lets you specify the namespaces that you want to
-- list services for.
--
-- /See:/ 'newServiceFilter' smart constructor.
data ServiceFilter = ServiceFilter'
  { -- | The operator that you want to use to determine whether a service is
    -- returned by @ListServices@. Valid values for @Condition@ include the
    -- following:
    --
    -- -   @EQ@: When you specify @EQ@, specify one namespace ID for @Values@.
    --     @EQ@ is the default condition and can be omitted.
    --
    -- -   @IN@: When you specify @IN@, specify a list of the IDs for the
    --     namespaces that you want @ListServices@ to return a list of services
    --     for.
    --
    -- -   @BETWEEN@: Not applicable.
    ServiceFilter -> Maybe FilterCondition
condition :: Prelude.Maybe FilterCondition,
    -- | Specify @NAMESPACE_ID@.
    ServiceFilter -> ServiceFilterName
name :: ServiceFilterName,
    -- | The values that are applicable to the value that you specify for
    -- @Condition@ to filter the list of services.
    ServiceFilter -> [Text]
values :: [Prelude.Text]
  }
  deriving (ServiceFilter -> ServiceFilter -> Bool
(ServiceFilter -> ServiceFilter -> Bool)
-> (ServiceFilter -> ServiceFilter -> Bool) -> Eq ServiceFilter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ServiceFilter -> ServiceFilter -> Bool
$c/= :: ServiceFilter -> ServiceFilter -> Bool
== :: ServiceFilter -> ServiceFilter -> Bool
$c== :: ServiceFilter -> ServiceFilter -> Bool
Prelude.Eq, ReadPrec [ServiceFilter]
ReadPrec ServiceFilter
Int -> ReadS ServiceFilter
ReadS [ServiceFilter]
(Int -> ReadS ServiceFilter)
-> ReadS [ServiceFilter]
-> ReadPrec ServiceFilter
-> ReadPrec [ServiceFilter]
-> Read ServiceFilter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ServiceFilter]
$creadListPrec :: ReadPrec [ServiceFilter]
readPrec :: ReadPrec ServiceFilter
$creadPrec :: ReadPrec ServiceFilter
readList :: ReadS [ServiceFilter]
$creadList :: ReadS [ServiceFilter]
readsPrec :: Int -> ReadS ServiceFilter
$creadsPrec :: Int -> ReadS ServiceFilter
Prelude.Read, Int -> ServiceFilter -> ShowS
[ServiceFilter] -> ShowS
ServiceFilter -> String
(Int -> ServiceFilter -> ShowS)
-> (ServiceFilter -> String)
-> ([ServiceFilter] -> ShowS)
-> Show ServiceFilter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ServiceFilter] -> ShowS
$cshowList :: [ServiceFilter] -> ShowS
show :: ServiceFilter -> String
$cshow :: ServiceFilter -> String
showsPrec :: Int -> ServiceFilter -> ShowS
$cshowsPrec :: Int -> ServiceFilter -> ShowS
Prelude.Show, (forall x. ServiceFilter -> Rep ServiceFilter x)
-> (forall x. Rep ServiceFilter x -> ServiceFilter)
-> Generic ServiceFilter
forall x. Rep ServiceFilter x -> ServiceFilter
forall x. ServiceFilter -> Rep ServiceFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ServiceFilter x -> ServiceFilter
$cfrom :: forall x. ServiceFilter -> Rep ServiceFilter x
Prelude.Generic)

-- |
-- Create a value of 'ServiceFilter' 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', 'serviceFilter_condition' - The operator that you want to use to determine whether a service is
-- returned by @ListServices@. Valid values for @Condition@ include the
-- following:
--
-- -   @EQ@: When you specify @EQ@, specify one namespace ID for @Values@.
--     @EQ@ is the default condition and can be omitted.
--
-- -   @IN@: When you specify @IN@, specify a list of the IDs for the
--     namespaces that you want @ListServices@ to return a list of services
--     for.
--
-- -   @BETWEEN@: Not applicable.
--
-- 'name', 'serviceFilter_name' - Specify @NAMESPACE_ID@.
--
-- 'values', 'serviceFilter_values' - The values that are applicable to the value that you specify for
-- @Condition@ to filter the list of services.
newServiceFilter ::
  -- | 'name'
  ServiceFilterName ->
  ServiceFilter
newServiceFilter :: ServiceFilterName -> ServiceFilter
newServiceFilter ServiceFilterName
pName_ =
  ServiceFilter' :: Maybe FilterCondition
-> ServiceFilterName -> [Text] -> ServiceFilter
ServiceFilter'
    { $sel:condition:ServiceFilter' :: Maybe FilterCondition
condition = Maybe FilterCondition
forall a. Maybe a
Prelude.Nothing,
      $sel:name:ServiceFilter' :: ServiceFilterName
name = ServiceFilterName
pName_,
      $sel:values:ServiceFilter' :: [Text]
values = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The operator that you want to use to determine whether a service is
-- returned by @ListServices@. Valid values for @Condition@ include the
-- following:
--
-- -   @EQ@: When you specify @EQ@, specify one namespace ID for @Values@.
--     @EQ@ is the default condition and can be omitted.
--
-- -   @IN@: When you specify @IN@, specify a list of the IDs for the
--     namespaces that you want @ListServices@ to return a list of services
--     for.
--
-- -   @BETWEEN@: Not applicable.
serviceFilter_condition :: Lens.Lens' ServiceFilter (Prelude.Maybe FilterCondition)
serviceFilter_condition :: (Maybe FilterCondition -> f (Maybe FilterCondition))
-> ServiceFilter -> f ServiceFilter
serviceFilter_condition = (ServiceFilter -> Maybe FilterCondition)
-> (ServiceFilter -> Maybe FilterCondition -> ServiceFilter)
-> Lens
     ServiceFilter
     ServiceFilter
     (Maybe FilterCondition)
     (Maybe FilterCondition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceFilter' {Maybe FilterCondition
condition :: Maybe FilterCondition
$sel:condition:ServiceFilter' :: ServiceFilter -> Maybe FilterCondition
condition} -> Maybe FilterCondition
condition) (\s :: ServiceFilter
s@ServiceFilter' {} Maybe FilterCondition
a -> ServiceFilter
s {$sel:condition:ServiceFilter' :: Maybe FilterCondition
condition = Maybe FilterCondition
a} :: ServiceFilter)

-- | Specify @NAMESPACE_ID@.
serviceFilter_name :: Lens.Lens' ServiceFilter ServiceFilterName
serviceFilter_name :: (ServiceFilterName -> f ServiceFilterName)
-> ServiceFilter -> f ServiceFilter
serviceFilter_name = (ServiceFilter -> ServiceFilterName)
-> (ServiceFilter -> ServiceFilterName -> ServiceFilter)
-> Lens
     ServiceFilter ServiceFilter ServiceFilterName ServiceFilterName
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceFilter' {ServiceFilterName
name :: ServiceFilterName
$sel:name:ServiceFilter' :: ServiceFilter -> ServiceFilterName
name} -> ServiceFilterName
name) (\s :: ServiceFilter
s@ServiceFilter' {} ServiceFilterName
a -> ServiceFilter
s {$sel:name:ServiceFilter' :: ServiceFilterName
name = ServiceFilterName
a} :: ServiceFilter)

-- | The values that are applicable to the value that you specify for
-- @Condition@ to filter the list of services.
serviceFilter_values :: Lens.Lens' ServiceFilter [Prelude.Text]
serviceFilter_values :: ([Text] -> f [Text]) -> ServiceFilter -> f ServiceFilter
serviceFilter_values = (ServiceFilter -> [Text])
-> (ServiceFilter -> [Text] -> ServiceFilter)
-> Lens ServiceFilter ServiceFilter [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceFilter' {[Text]
values :: [Text]
$sel:values:ServiceFilter' :: ServiceFilter -> [Text]
values} -> [Text]
values) (\s :: ServiceFilter
s@ServiceFilter' {} [Text]
a -> ServiceFilter
s {$sel:values:ServiceFilter' :: [Text]
values = [Text]
a} :: ServiceFilter) (([Text] -> f [Text]) -> ServiceFilter -> f ServiceFilter)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> ServiceFilter
-> f ServiceFilter
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 ServiceFilter

instance Prelude.NFData ServiceFilter

instance Core.ToJSON ServiceFilter where
  toJSON :: ServiceFilter -> Value
toJSON ServiceFilter' {[Text]
Maybe FilterCondition
ServiceFilterName
values :: [Text]
name :: ServiceFilterName
condition :: Maybe FilterCondition
$sel:values:ServiceFilter' :: ServiceFilter -> [Text]
$sel:name:ServiceFilter' :: ServiceFilter -> ServiceFilterName
$sel:condition:ServiceFilter' :: ServiceFilter -> 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 -> ServiceFilterName -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ServiceFilterName
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)
          ]
      )