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

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

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