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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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: @agentId@.
    ExportFilter -> Text
name :: Prelude.Text,
    -- | A single @agentId@ for a Discovery Agent. An @agentId@ can be found
    -- using the
    -- <http://docs.aws.amazon.com/application-discovery/latest/APIReference/API_DescribeExportTasks.html DescribeAgents>
    -- action. Typically an ADS @agentId@ is in the form @o-0123456789abcdef0@.
    ExportFilter -> [Text]
values :: [Prelude.Text],
    -- | Supported condition: @EQUALS@
    ExportFilter -> Text
condition :: Prelude.Text
  }
  deriving (ExportFilter -> ExportFilter -> Bool
(ExportFilter -> ExportFilter -> Bool)
-> (ExportFilter -> ExportFilter -> Bool) -> Eq ExportFilter
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]
(Int -> ReadS ExportFilter)
-> ReadS [ExportFilter]
-> ReadPrec ExportFilter
-> ReadPrec [ExportFilter]
-> Read 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
(Int -> ExportFilter -> ShowS)
-> (ExportFilter -> String)
-> ([ExportFilter] -> ShowS)
-> Show ExportFilter
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. ExportFilter -> Rep ExportFilter x)
-> (forall x. Rep ExportFilter x -> ExportFilter)
-> Generic ExportFilter
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: @agentId@.
--
-- 'values', 'exportFilter_values' - A single @agentId@ for a Discovery Agent. An @agentId@ can be found
-- using the
-- <http://docs.aws.amazon.com/application-discovery/latest/APIReference/API_DescribeExportTasks.html DescribeAgents>
-- action. Typically an ADS @agentId@ 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' :: Text -> [Text] -> Text -> ExportFilter
ExportFilter'
    { $sel:name:ExportFilter' :: Text
name = Text
pName_,
      $sel:values:ExportFilter' :: [Text]
values = [Text]
forall a. Monoid a => a
Prelude.mempty,
      $sel:condition:ExportFilter' :: Text
condition = Text
pCondition_
    }

-- | A single @ExportFilter@ name. Supported filters: @agentId@.
exportFilter_name :: Lens.Lens' ExportFilter Prelude.Text
exportFilter_name :: (Text -> f Text) -> ExportFilter -> f ExportFilter
exportFilter_name = (ExportFilter -> Text)
-> (ExportFilter -> Text -> ExportFilter)
-> Lens ExportFilter ExportFilter Text Text
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 @agentId@ for a Discovery Agent. An @agentId@ can be found
-- using the
-- <http://docs.aws.amazon.com/application-discovery/latest/APIReference/API_DescribeExportTasks.html DescribeAgents>
-- action. Typically an ADS @agentId@ is in the form @o-0123456789abcdef0@.
exportFilter_values :: Lens.Lens' ExportFilter [Prelude.Text]
exportFilter_values :: ([Text] -> f [Text]) -> ExportFilter -> f ExportFilter
exportFilter_values = (ExportFilter -> [Text])
-> (ExportFilter -> [Text] -> ExportFilter)
-> Lens ExportFilter ExportFilter [Text] [Text]
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) (([Text] -> f [Text]) -> ExportFilter -> f ExportFilter)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> ExportFilter
-> f ExportFilter
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

-- | Supported condition: @EQUALS@
exportFilter_condition :: Lens.Lens' ExportFilter Prelude.Text
exportFilter_condition :: (Text -> f Text) -> ExportFilter -> f ExportFilter
exportFilter_condition = (ExportFilter -> Text)
-> (ExportFilter -> Text -> ExportFilter)
-> Lens ExportFilter ExportFilter Text Text
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

instance Prelude.NFData ExportFilter

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"condition" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
condition)
          ]
      )