{-# 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.CodeStarNotifications.Types.ListTargetsFilter
-- 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.CodeStarNotifications.Types.ListTargetsFilter where

import Amazonka.CodeStarNotifications.Types.ListTargetsFilterName
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

-- | Information about a filter to apply to the list of returned targets. You
-- can filter by target type, address, or status. For example, to filter
-- results to notification rules that have active Chatbot topics as
-- targets, you could specify a ListTargetsFilter Name as @TargetType@ and
-- a Value of @SNS@, and a Name of @TARGET_STATUS@ and a Value of @ACTIVE@.
--
-- /See:/ 'newListTargetsFilter' smart constructor.
data ListTargetsFilter = ListTargetsFilter'
  { -- | The name of the attribute you want to use to filter the returned
    -- targets.
    ListTargetsFilter -> ListTargetsFilterName
name :: ListTargetsFilterName,
    -- | The value of the attribute you want to use to filter the returned
    -- targets. For example, if you specify @SNS@ for the Target type, you
    -- could specify an Amazon Resource Name (ARN) for a topic as the value.
    ListTargetsFilter -> Text
value :: Prelude.Text
  }
  deriving (ListTargetsFilter -> ListTargetsFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTargetsFilter -> ListTargetsFilter -> Bool
$c/= :: ListTargetsFilter -> ListTargetsFilter -> Bool
== :: ListTargetsFilter -> ListTargetsFilter -> Bool
$c== :: ListTargetsFilter -> ListTargetsFilter -> Bool
Prelude.Eq, ReadPrec [ListTargetsFilter]
ReadPrec ListTargetsFilter
Int -> ReadS ListTargetsFilter
ReadS [ListTargetsFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTargetsFilter]
$creadListPrec :: ReadPrec [ListTargetsFilter]
readPrec :: ReadPrec ListTargetsFilter
$creadPrec :: ReadPrec ListTargetsFilter
readList :: ReadS [ListTargetsFilter]
$creadList :: ReadS [ListTargetsFilter]
readsPrec :: Int -> ReadS ListTargetsFilter
$creadsPrec :: Int -> ReadS ListTargetsFilter
Prelude.Read, Int -> ListTargetsFilter -> ShowS
[ListTargetsFilter] -> ShowS
ListTargetsFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTargetsFilter] -> ShowS
$cshowList :: [ListTargetsFilter] -> ShowS
show :: ListTargetsFilter -> String
$cshow :: ListTargetsFilter -> String
showsPrec :: Int -> ListTargetsFilter -> ShowS
$cshowsPrec :: Int -> ListTargetsFilter -> ShowS
Prelude.Show, forall x. Rep ListTargetsFilter x -> ListTargetsFilter
forall x. ListTargetsFilter -> Rep ListTargetsFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTargetsFilter x -> ListTargetsFilter
$cfrom :: forall x. ListTargetsFilter -> Rep ListTargetsFilter x
Prelude.Generic)

-- |
-- Create a value of 'ListTargetsFilter' 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:
--
-- 'name', 'listTargetsFilter_name' - The name of the attribute you want to use to filter the returned
-- targets.
--
-- 'value', 'listTargetsFilter_value' - The value of the attribute you want to use to filter the returned
-- targets. For example, if you specify @SNS@ for the Target type, you
-- could specify an Amazon Resource Name (ARN) for a topic as the value.
newListTargetsFilter ::
  -- | 'name'
  ListTargetsFilterName ->
  -- | 'value'
  Prelude.Text ->
  ListTargetsFilter
newListTargetsFilter :: ListTargetsFilterName -> Text -> ListTargetsFilter
newListTargetsFilter ListTargetsFilterName
pName_ Text
pValue_ =
  ListTargetsFilter' {$sel:name:ListTargetsFilter' :: ListTargetsFilterName
name = ListTargetsFilterName
pName_, $sel:value:ListTargetsFilter' :: Text
value = Text
pValue_}

-- | The name of the attribute you want to use to filter the returned
-- targets.
listTargetsFilter_name :: Lens.Lens' ListTargetsFilter ListTargetsFilterName
listTargetsFilter_name :: Lens' ListTargetsFilter ListTargetsFilterName
listTargetsFilter_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTargetsFilter' {ListTargetsFilterName
name :: ListTargetsFilterName
$sel:name:ListTargetsFilter' :: ListTargetsFilter -> ListTargetsFilterName
name} -> ListTargetsFilterName
name) (\s :: ListTargetsFilter
s@ListTargetsFilter' {} ListTargetsFilterName
a -> ListTargetsFilter
s {$sel:name:ListTargetsFilter' :: ListTargetsFilterName
name = ListTargetsFilterName
a} :: ListTargetsFilter)

-- | The value of the attribute you want to use to filter the returned
-- targets. For example, if you specify @SNS@ for the Target type, you
-- could specify an Amazon Resource Name (ARN) for a topic as the value.
listTargetsFilter_value :: Lens.Lens' ListTargetsFilter Prelude.Text
listTargetsFilter_value :: Lens' ListTargetsFilter Text
listTargetsFilter_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTargetsFilter' {Text
value :: Text
$sel:value:ListTargetsFilter' :: ListTargetsFilter -> Text
value} -> Text
value) (\s :: ListTargetsFilter
s@ListTargetsFilter' {} Text
a -> ListTargetsFilter
s {$sel:value:ListTargetsFilter' :: Text
value = Text
a} :: ListTargetsFilter)

instance Prelude.Hashable ListTargetsFilter where
  hashWithSalt :: Int -> ListTargetsFilter -> Int
hashWithSalt Int
_salt ListTargetsFilter' {Text
ListTargetsFilterName
value :: Text
name :: ListTargetsFilterName
$sel:value:ListTargetsFilter' :: ListTargetsFilter -> Text
$sel:name:ListTargetsFilter' :: ListTargetsFilter -> ListTargetsFilterName
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ListTargetsFilterName
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
value

instance Prelude.NFData ListTargetsFilter where
  rnf :: ListTargetsFilter -> ()
rnf ListTargetsFilter' {Text
ListTargetsFilterName
value :: Text
name :: ListTargetsFilterName
$sel:value:ListTargetsFilter' :: ListTargetsFilter -> Text
$sel:name:ListTargetsFilter' :: ListTargetsFilter -> ListTargetsFilterName
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ListTargetsFilterName
name seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
value

instance Data.ToJSON ListTargetsFilter where
  toJSON :: ListTargetsFilter -> Value
toJSON ListTargetsFilter' {Text
ListTargetsFilterName
value :: Text
name :: ListTargetsFilterName
$sel:value:ListTargetsFilter' :: ListTargetsFilter -> Text
$sel:name:ListTargetsFilter' :: ListTargetsFilter -> ListTargetsFilterName
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ListTargetsFilterName
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
value)
          ]
      )