{-# 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-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.ServiceFilter 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.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.
    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
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]
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
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. 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.
--
-- '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'
    { $sel:condition:ServiceFilter' :: Maybe FilterCondition
condition = forall a. Maybe a
Prelude.Nothing,
      $sel:name:ServiceFilter' :: ServiceFilterName
name = ServiceFilterName
pName_,
      $sel:values:ServiceFilter' :: [Text]
values = 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.
serviceFilter_condition :: Lens.Lens' ServiceFilter (Prelude.Maybe FilterCondition)
serviceFilter_condition :: Lens' ServiceFilter (Maybe FilterCondition)
serviceFilter_condition = 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 :: Lens' ServiceFilter ServiceFilterName
serviceFilter_name = 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 :: Lens' ServiceFilter [Text]
serviceFilter_values = 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) 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 ServiceFilter where
  hashWithSalt :: Int -> ServiceFilter -> Int
hashWithSalt Int
_salt 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
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FilterCondition
condition
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ServiceFilterName
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
values

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

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