{-# 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.Discovery.Types.ExportFilter
-- 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.Discovery.Types.ExportFilter 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

-- | Used to select which agent\'s data is to be exported. A single agent ID
-- may be selected for export using the
-- <http://docs.aws.amazon.com/application-discovery/latest/APIReference/API_StartExportTask.html StartExportTask>
-- action.
--
-- /See:/ 'newExportFilter' smart constructor.
data ExportFilter = ExportFilter'
  { -- | A single @ExportFilter@ name. Supported filters: @agentIds@.
    ExportFilter -> Text
name :: Prelude.Text,
    -- | A single agent ID for a Discovery Agent. An agent ID can be found using
    -- the
    -- <http://docs.aws.amazon.com/application-discovery/latest/APIReference/API_DescribeAgents.html DescribeAgents>
    -- action. Typically an ADS agent ID is in the form @o-0123456789abcdef0@.
    ExportFilter -> [Text]
values :: [Prelude.Text],
    -- | Supported condition: @EQUALS@
    ExportFilter -> Text
condition :: Prelude.Text
  }
  deriving (ExportFilter -> ExportFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExportFilter -> ExportFilter -> Bool
$c/= :: ExportFilter -> ExportFilter -> Bool
== :: ExportFilter -> ExportFilter -> Bool
$c== :: ExportFilter -> ExportFilter -> Bool
Prelude.Eq, ReadPrec [ExportFilter]
ReadPrec ExportFilter
Int -> ReadS ExportFilter
ReadS [ExportFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExportFilter]
$creadListPrec :: ReadPrec [ExportFilter]
readPrec :: ReadPrec ExportFilter
$creadPrec :: ReadPrec ExportFilter
readList :: ReadS [ExportFilter]
$creadList :: ReadS [ExportFilter]
readsPrec :: Int -> ReadS ExportFilter
$creadsPrec :: Int -> ReadS ExportFilter
Prelude.Read, Int -> ExportFilter -> ShowS
[ExportFilter] -> ShowS
ExportFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExportFilter] -> ShowS
$cshowList :: [ExportFilter] -> ShowS
show :: ExportFilter -> String
$cshow :: ExportFilter -> String
showsPrec :: Int -> ExportFilter -> ShowS
$cshowsPrec :: Int -> ExportFilter -> ShowS
Prelude.Show, forall x. Rep ExportFilter x -> ExportFilter
forall x. ExportFilter -> Rep ExportFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExportFilter x -> ExportFilter
$cfrom :: forall x. ExportFilter -> Rep ExportFilter x
Prelude.Generic)

-- |
-- Create a value of 'ExportFilter' 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', 'exportFilter_name' - A single @ExportFilter@ name. Supported filters: @agentIds@.
--
-- 'values', 'exportFilter_values' - A single agent ID for a Discovery Agent. An agent ID can be found using
-- the
-- <http://docs.aws.amazon.com/application-discovery/latest/APIReference/API_DescribeAgents.html DescribeAgents>
-- action. Typically an ADS agent ID is in the form @o-0123456789abcdef0@.
--
-- 'condition', 'exportFilter_condition' - Supported condition: @EQUALS@
newExportFilter ::
  -- | 'name'
  Prelude.Text ->
  -- | 'condition'
  Prelude.Text ->
  ExportFilter
newExportFilter :: Text -> Text -> ExportFilter
newExportFilter Text
pName_ Text
pCondition_ =
  ExportFilter'
    { $sel:name:ExportFilter' :: Text
name = Text
pName_,
      $sel:values:ExportFilter' :: [Text]
values = forall a. Monoid a => a
Prelude.mempty,
      $sel:condition:ExportFilter' :: Text
condition = Text
pCondition_
    }

-- | A single @ExportFilter@ name. Supported filters: @agentIds@.
exportFilter_name :: Lens.Lens' ExportFilter Prelude.Text
exportFilter_name :: Lens' ExportFilter Text
exportFilter_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportFilter' {Text
name :: Text
$sel:name:ExportFilter' :: ExportFilter -> Text
name} -> Text
name) (\s :: ExportFilter
s@ExportFilter' {} Text
a -> ExportFilter
s {$sel:name:ExportFilter' :: Text
name = Text
a} :: ExportFilter)

-- | A single agent ID for a Discovery Agent. An agent ID can be found using
-- the
-- <http://docs.aws.amazon.com/application-discovery/latest/APIReference/API_DescribeAgents.html DescribeAgents>
-- action. Typically an ADS agent ID is in the form @o-0123456789abcdef0@.
exportFilter_values :: Lens.Lens' ExportFilter [Prelude.Text]
exportFilter_values :: Lens' ExportFilter [Text]
exportFilter_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportFilter' {[Text]
values :: [Text]
$sel:values:ExportFilter' :: ExportFilter -> [Text]
values} -> [Text]
values) (\s :: ExportFilter
s@ExportFilter' {} [Text]
a -> ExportFilter
s {$sel:values:ExportFilter' :: [Text]
values = [Text]
a} :: ExportFilter) 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

-- | Supported condition: @EQUALS@
exportFilter_condition :: Lens.Lens' ExportFilter Prelude.Text
exportFilter_condition :: Lens' ExportFilter Text
exportFilter_condition = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportFilter' {Text
condition :: Text
$sel:condition:ExportFilter' :: ExportFilter -> Text
condition} -> Text
condition) (\s :: ExportFilter
s@ExportFilter' {} Text
a -> ExportFilter
s {$sel:condition:ExportFilter' :: Text
condition = Text
a} :: ExportFilter)

instance Prelude.Hashable ExportFilter where
  hashWithSalt :: Int -> ExportFilter -> Int
hashWithSalt Int
_salt ExportFilter' {[Text]
Text
condition :: Text
values :: [Text]
name :: Text
$sel:condition:ExportFilter' :: ExportFilter -> Text
$sel:values:ExportFilter' :: ExportFilter -> [Text]
$sel:name:ExportFilter' :: ExportFilter -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
values
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
condition

instance Prelude.NFData ExportFilter where
  rnf :: ExportFilter -> ()
rnf ExportFilter' {[Text]
Text
condition :: Text
values :: [Text]
name :: Text
$sel:condition:ExportFilter' :: ExportFilter -> Text
$sel:values:ExportFilter' :: ExportFilter -> [Text]
$sel:name:ExportFilter' :: ExportFilter -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
values
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
condition

instance Data.ToJSON ExportFilter where
  toJSON :: ExportFilter -> Value
toJSON ExportFilter' {[Text]
Text
condition :: Text
values :: [Text]
name :: Text
$sel:condition:ExportFilter' :: ExportFilter -> Text
$sel:values:ExportFilter' :: ExportFilter -> [Text]
$sel:name:ExportFilter' :: ExportFilter -> Text
..} =
    [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..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"values" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
values),
            forall a. a -> Maybe a
Prelude.Just (Key
"condition" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
condition)
          ]
      )