{-# 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.OperationFilter
-- 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.OperationFilter 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.OperationFilterName

-- | A complex type that lets you select the operations that you want to
-- list.
--
-- /See:/ 'newOperationFilter' smart constructor.
data OperationFilter = OperationFilter'
  { -- | The operator that you want to use to determine whether an operation
    -- matches the specified value. Valid values for condition include:
    --
    -- -   @EQ@: When you specify @EQ@ for the condition, you can specify only
    --     one value. @EQ@ is supported for @NAMESPACE_ID@, @SERVICE_ID@,
    --     @STATUS@, and @TYPE@. @EQ@ is the default condition and can be
    --     omitted.
    --
    -- -   @IN@: When you specify @IN@ for the condition, you can specify a
    --     list of one or more values. @IN@ is supported for @STATUS@ and
    --     @TYPE@. An operation must match one of the specified values to be
    --     returned in the response.
    --
    -- -   @BETWEEN@: Specify a start date and an end date in Unix date\/time
    --     format and Coordinated Universal Time (UTC). The start date must be
    --     the first value. @BETWEEN@ is supported for @UPDATE_DATE@.
    OperationFilter -> Maybe FilterCondition
condition :: Prelude.Maybe FilterCondition,
    -- | Specify the operations that you want to get:
    --
    -- -   __NAMESPACE_ID__: Gets operations related to specified namespaces.
    --
    -- -   __SERVICE_ID__: Gets operations related to specified services.
    --
    -- -   __STATUS__: Gets operations based on the status of the operations:
    --     @SUBMITTED@, @PENDING@, @SUCCEED@, or @FAIL@.
    --
    -- -   __TYPE__: Gets specified types of operation.
    --
    -- -   __UPDATE_DATE__: Gets operations that changed status during a
    --     specified date\/time range.
    OperationFilter -> OperationFilterName
name :: OperationFilterName,
    -- | Specify values that are applicable to the value that you specify for
    -- @Name@:
    --
    -- -   __NAMESPACE_ID__: Specify one namespace ID.
    --
    -- -   __SERVICE_ID__: Specify one service ID.
    --
    -- -   __STATUS__: Specify one or more statuses: @SUBMITTED@, @PENDING@,
    --     @SUCCEED@, or @FAIL@.
    --
    -- -   __TYPE__: Specify one or more of the following types:
    --     @CREATE_NAMESPACE@, @DELETE_NAMESPACE@, @UPDATE_SERVICE@,
    --     @REGISTER_INSTANCE@, or @DEREGISTER_INSTANCE@.
    --
    -- -   __UPDATE_DATE__: Specify a start date and an end date in Unix
    --     date\/time format and Coordinated Universal Time (UTC). The start
    --     date must be the first value.
    OperationFilter -> [Text]
values :: [Prelude.Text]
  }
  deriving (OperationFilter -> OperationFilter -> Bool
(OperationFilter -> OperationFilter -> Bool)
-> (OperationFilter -> OperationFilter -> Bool)
-> Eq OperationFilter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OperationFilter -> OperationFilter -> Bool
$c/= :: OperationFilter -> OperationFilter -> Bool
== :: OperationFilter -> OperationFilter -> Bool
$c== :: OperationFilter -> OperationFilter -> Bool
Prelude.Eq, ReadPrec [OperationFilter]
ReadPrec OperationFilter
Int -> ReadS OperationFilter
ReadS [OperationFilter]
(Int -> ReadS OperationFilter)
-> ReadS [OperationFilter]
-> ReadPrec OperationFilter
-> ReadPrec [OperationFilter]
-> Read OperationFilter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OperationFilter]
$creadListPrec :: ReadPrec [OperationFilter]
readPrec :: ReadPrec OperationFilter
$creadPrec :: ReadPrec OperationFilter
readList :: ReadS [OperationFilter]
$creadList :: ReadS [OperationFilter]
readsPrec :: Int -> ReadS OperationFilter
$creadsPrec :: Int -> ReadS OperationFilter
Prelude.Read, Int -> OperationFilter -> ShowS
[OperationFilter] -> ShowS
OperationFilter -> String
(Int -> OperationFilter -> ShowS)
-> (OperationFilter -> String)
-> ([OperationFilter] -> ShowS)
-> Show OperationFilter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OperationFilter] -> ShowS
$cshowList :: [OperationFilter] -> ShowS
show :: OperationFilter -> String
$cshow :: OperationFilter -> String
showsPrec :: Int -> OperationFilter -> ShowS
$cshowsPrec :: Int -> OperationFilter -> ShowS
Prelude.Show, (forall x. OperationFilter -> Rep OperationFilter x)
-> (forall x. Rep OperationFilter x -> OperationFilter)
-> Generic OperationFilter
forall x. Rep OperationFilter x -> OperationFilter
forall x. OperationFilter -> Rep OperationFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OperationFilter x -> OperationFilter
$cfrom :: forall x. OperationFilter -> Rep OperationFilter x
Prelude.Generic)

-- |
-- Create a value of 'OperationFilter' 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', 'operationFilter_condition' - The operator that you want to use to determine whether an operation
-- matches the specified value. Valid values for condition include:
--
-- -   @EQ@: When you specify @EQ@ for the condition, you can specify only
--     one value. @EQ@ is supported for @NAMESPACE_ID@, @SERVICE_ID@,
--     @STATUS@, and @TYPE@. @EQ@ is the default condition and can be
--     omitted.
--
-- -   @IN@: When you specify @IN@ for the condition, you can specify a
--     list of one or more values. @IN@ is supported for @STATUS@ and
--     @TYPE@. An operation must match one of the specified values to be
--     returned in the response.
--
-- -   @BETWEEN@: Specify a start date and an end date in Unix date\/time
--     format and Coordinated Universal Time (UTC). The start date must be
--     the first value. @BETWEEN@ is supported for @UPDATE_DATE@.
--
-- 'name', 'operationFilter_name' - Specify the operations that you want to get:
--
-- -   __NAMESPACE_ID__: Gets operations related to specified namespaces.
--
-- -   __SERVICE_ID__: Gets operations related to specified services.
--
-- -   __STATUS__: Gets operations based on the status of the operations:
--     @SUBMITTED@, @PENDING@, @SUCCEED@, or @FAIL@.
--
-- -   __TYPE__: Gets specified types of operation.
--
-- -   __UPDATE_DATE__: Gets operations that changed status during a
--     specified date\/time range.
--
-- 'values', 'operationFilter_values' - Specify values that are applicable to the value that you specify for
-- @Name@:
--
-- -   __NAMESPACE_ID__: Specify one namespace ID.
--
-- -   __SERVICE_ID__: Specify one service ID.
--
-- -   __STATUS__: Specify one or more statuses: @SUBMITTED@, @PENDING@,
--     @SUCCEED@, or @FAIL@.
--
-- -   __TYPE__: Specify one or more of the following types:
--     @CREATE_NAMESPACE@, @DELETE_NAMESPACE@, @UPDATE_SERVICE@,
--     @REGISTER_INSTANCE@, or @DEREGISTER_INSTANCE@.
--
-- -   __UPDATE_DATE__: Specify a start date and an end date in Unix
--     date\/time format and Coordinated Universal Time (UTC). The start
--     date must be the first value.
newOperationFilter ::
  -- | 'name'
  OperationFilterName ->
  OperationFilter
newOperationFilter :: OperationFilterName -> OperationFilter
newOperationFilter OperationFilterName
pName_ =
  OperationFilter' :: Maybe FilterCondition
-> OperationFilterName -> [Text] -> OperationFilter
OperationFilter'
    { $sel:condition:OperationFilter' :: Maybe FilterCondition
condition = Maybe FilterCondition
forall a. Maybe a
Prelude.Nothing,
      $sel:name:OperationFilter' :: OperationFilterName
name = OperationFilterName
pName_,
      $sel:values:OperationFilter' :: [Text]
values = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The operator that you want to use to determine whether an operation
-- matches the specified value. Valid values for condition include:
--
-- -   @EQ@: When you specify @EQ@ for the condition, you can specify only
--     one value. @EQ@ is supported for @NAMESPACE_ID@, @SERVICE_ID@,
--     @STATUS@, and @TYPE@. @EQ@ is the default condition and can be
--     omitted.
--
-- -   @IN@: When you specify @IN@ for the condition, you can specify a
--     list of one or more values. @IN@ is supported for @STATUS@ and
--     @TYPE@. An operation must match one of the specified values to be
--     returned in the response.
--
-- -   @BETWEEN@: Specify a start date and an end date in Unix date\/time
--     format and Coordinated Universal Time (UTC). The start date must be
--     the first value. @BETWEEN@ is supported for @UPDATE_DATE@.
operationFilter_condition :: Lens.Lens' OperationFilter (Prelude.Maybe FilterCondition)
operationFilter_condition :: (Maybe FilterCondition -> f (Maybe FilterCondition))
-> OperationFilter -> f OperationFilter
operationFilter_condition = (OperationFilter -> Maybe FilterCondition)
-> (OperationFilter -> Maybe FilterCondition -> OperationFilter)
-> Lens
     OperationFilter
     OperationFilter
     (Maybe FilterCondition)
     (Maybe FilterCondition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OperationFilter' {Maybe FilterCondition
condition :: Maybe FilterCondition
$sel:condition:OperationFilter' :: OperationFilter -> Maybe FilterCondition
condition} -> Maybe FilterCondition
condition) (\s :: OperationFilter
s@OperationFilter' {} Maybe FilterCondition
a -> OperationFilter
s {$sel:condition:OperationFilter' :: Maybe FilterCondition
condition = Maybe FilterCondition
a} :: OperationFilter)

-- | Specify the operations that you want to get:
--
-- -   __NAMESPACE_ID__: Gets operations related to specified namespaces.
--
-- -   __SERVICE_ID__: Gets operations related to specified services.
--
-- -   __STATUS__: Gets operations based on the status of the operations:
--     @SUBMITTED@, @PENDING@, @SUCCEED@, or @FAIL@.
--
-- -   __TYPE__: Gets specified types of operation.
--
-- -   __UPDATE_DATE__: Gets operations that changed status during a
--     specified date\/time range.
operationFilter_name :: Lens.Lens' OperationFilter OperationFilterName
operationFilter_name :: (OperationFilterName -> f OperationFilterName)
-> OperationFilter -> f OperationFilter
operationFilter_name = (OperationFilter -> OperationFilterName)
-> (OperationFilter -> OperationFilterName -> OperationFilter)
-> Lens
     OperationFilter
     OperationFilter
     OperationFilterName
     OperationFilterName
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OperationFilter' {OperationFilterName
name :: OperationFilterName
$sel:name:OperationFilter' :: OperationFilter -> OperationFilterName
name} -> OperationFilterName
name) (\s :: OperationFilter
s@OperationFilter' {} OperationFilterName
a -> OperationFilter
s {$sel:name:OperationFilter' :: OperationFilterName
name = OperationFilterName
a} :: OperationFilter)

-- | Specify values that are applicable to the value that you specify for
-- @Name@:
--
-- -   __NAMESPACE_ID__: Specify one namespace ID.
--
-- -   __SERVICE_ID__: Specify one service ID.
--
-- -   __STATUS__: Specify one or more statuses: @SUBMITTED@, @PENDING@,
--     @SUCCEED@, or @FAIL@.
--
-- -   __TYPE__: Specify one or more of the following types:
--     @CREATE_NAMESPACE@, @DELETE_NAMESPACE@, @UPDATE_SERVICE@,
--     @REGISTER_INSTANCE@, or @DEREGISTER_INSTANCE@.
--
-- -   __UPDATE_DATE__: Specify a start date and an end date in Unix
--     date\/time format and Coordinated Universal Time (UTC). The start
--     date must be the first value.
operationFilter_values :: Lens.Lens' OperationFilter [Prelude.Text]
operationFilter_values :: ([Text] -> f [Text]) -> OperationFilter -> f OperationFilter
operationFilter_values = (OperationFilter -> [Text])
-> (OperationFilter -> [Text] -> OperationFilter)
-> Lens OperationFilter OperationFilter [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OperationFilter' {[Text]
values :: [Text]
$sel:values:OperationFilter' :: OperationFilter -> [Text]
values} -> [Text]
values) (\s :: OperationFilter
s@OperationFilter' {} [Text]
a -> OperationFilter
s {$sel:values:OperationFilter' :: [Text]
values = [Text]
a} :: OperationFilter) (([Text] -> f [Text]) -> OperationFilter -> f OperationFilter)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> OperationFilter
-> f OperationFilter
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 OperationFilter

instance Prelude.NFData OperationFilter

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