{-# 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.IotTwinMaker.Types.TabularConditions
-- 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.IotTwinMaker.Types.TabularConditions where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IotTwinMaker.Types.OrderBy
import Amazonka.IotTwinMaker.Types.PropertyFilter
import qualified Amazonka.Prelude as Prelude

-- | The tabular conditions.
--
-- /See:/ 'newTabularConditions' smart constructor.
data TabularConditions = TabularConditions'
  { -- | Filter criteria that orders the output. It can be sorted in ascending or
    -- descending order.
    TabularConditions -> Maybe (NonEmpty OrderBy)
orderBy :: Prelude.Maybe (Prelude.NonEmpty OrderBy),
    -- | You can filter the request using various logical operators and a
    -- key-value format. For example:
    --
    -- @{\"key\": \"serverType\", \"value\": \"webServer\"}@
    TabularConditions -> Maybe (NonEmpty PropertyFilter)
propertyFilters :: Prelude.Maybe (Prelude.NonEmpty PropertyFilter)
  }
  deriving (TabularConditions -> TabularConditions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TabularConditions -> TabularConditions -> Bool
$c/= :: TabularConditions -> TabularConditions -> Bool
== :: TabularConditions -> TabularConditions -> Bool
$c== :: TabularConditions -> TabularConditions -> Bool
Prelude.Eq, ReadPrec [TabularConditions]
ReadPrec TabularConditions
Int -> ReadS TabularConditions
ReadS [TabularConditions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TabularConditions]
$creadListPrec :: ReadPrec [TabularConditions]
readPrec :: ReadPrec TabularConditions
$creadPrec :: ReadPrec TabularConditions
readList :: ReadS [TabularConditions]
$creadList :: ReadS [TabularConditions]
readsPrec :: Int -> ReadS TabularConditions
$creadsPrec :: Int -> ReadS TabularConditions
Prelude.Read, Int -> TabularConditions -> ShowS
[TabularConditions] -> ShowS
TabularConditions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TabularConditions] -> ShowS
$cshowList :: [TabularConditions] -> ShowS
show :: TabularConditions -> String
$cshow :: TabularConditions -> String
showsPrec :: Int -> TabularConditions -> ShowS
$cshowsPrec :: Int -> TabularConditions -> ShowS
Prelude.Show, forall x. Rep TabularConditions x -> TabularConditions
forall x. TabularConditions -> Rep TabularConditions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TabularConditions x -> TabularConditions
$cfrom :: forall x. TabularConditions -> Rep TabularConditions x
Prelude.Generic)

-- |
-- Create a value of 'TabularConditions' 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:
--
-- 'orderBy', 'tabularConditions_orderBy' - Filter criteria that orders the output. It can be sorted in ascending or
-- descending order.
--
-- 'propertyFilters', 'tabularConditions_propertyFilters' - You can filter the request using various logical operators and a
-- key-value format. For example:
--
-- @{\"key\": \"serverType\", \"value\": \"webServer\"}@
newTabularConditions ::
  TabularConditions
newTabularConditions :: TabularConditions
newTabularConditions =
  TabularConditions'
    { $sel:orderBy:TabularConditions' :: Maybe (NonEmpty OrderBy)
orderBy = forall a. Maybe a
Prelude.Nothing,
      $sel:propertyFilters:TabularConditions' :: Maybe (NonEmpty PropertyFilter)
propertyFilters = forall a. Maybe a
Prelude.Nothing
    }

-- | Filter criteria that orders the output. It can be sorted in ascending or
-- descending order.
tabularConditions_orderBy :: Lens.Lens' TabularConditions (Prelude.Maybe (Prelude.NonEmpty OrderBy))
tabularConditions_orderBy :: Lens' TabularConditions (Maybe (NonEmpty OrderBy))
tabularConditions_orderBy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TabularConditions' {Maybe (NonEmpty OrderBy)
orderBy :: Maybe (NonEmpty OrderBy)
$sel:orderBy:TabularConditions' :: TabularConditions -> Maybe (NonEmpty OrderBy)
orderBy} -> Maybe (NonEmpty OrderBy)
orderBy) (\s :: TabularConditions
s@TabularConditions' {} Maybe (NonEmpty OrderBy)
a -> TabularConditions
s {$sel:orderBy:TabularConditions' :: Maybe (NonEmpty OrderBy)
orderBy = Maybe (NonEmpty OrderBy)
a} :: TabularConditions) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | You can filter the request using various logical operators and a
-- key-value format. For example:
--
-- @{\"key\": \"serverType\", \"value\": \"webServer\"}@
tabularConditions_propertyFilters :: Lens.Lens' TabularConditions (Prelude.Maybe (Prelude.NonEmpty PropertyFilter))
tabularConditions_propertyFilters :: Lens' TabularConditions (Maybe (NonEmpty PropertyFilter))
tabularConditions_propertyFilters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TabularConditions' {Maybe (NonEmpty PropertyFilter)
propertyFilters :: Maybe (NonEmpty PropertyFilter)
$sel:propertyFilters:TabularConditions' :: TabularConditions -> Maybe (NonEmpty PropertyFilter)
propertyFilters} -> Maybe (NonEmpty PropertyFilter)
propertyFilters) (\s :: TabularConditions
s@TabularConditions' {} Maybe (NonEmpty PropertyFilter)
a -> TabularConditions
s {$sel:propertyFilters:TabularConditions' :: Maybe (NonEmpty PropertyFilter)
propertyFilters = Maybe (NonEmpty PropertyFilter)
a} :: TabularConditions) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable TabularConditions where
  hashWithSalt :: Int -> TabularConditions -> Int
hashWithSalt Int
_salt TabularConditions' {Maybe (NonEmpty OrderBy)
Maybe (NonEmpty PropertyFilter)
propertyFilters :: Maybe (NonEmpty PropertyFilter)
orderBy :: Maybe (NonEmpty OrderBy)
$sel:propertyFilters:TabularConditions' :: TabularConditions -> Maybe (NonEmpty PropertyFilter)
$sel:orderBy:TabularConditions' :: TabularConditions -> Maybe (NonEmpty OrderBy)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty OrderBy)
orderBy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty PropertyFilter)
propertyFilters

instance Prelude.NFData TabularConditions where
  rnf :: TabularConditions -> ()
rnf TabularConditions' {Maybe (NonEmpty OrderBy)
Maybe (NonEmpty PropertyFilter)
propertyFilters :: Maybe (NonEmpty PropertyFilter)
orderBy :: Maybe (NonEmpty OrderBy)
$sel:propertyFilters:TabularConditions' :: TabularConditions -> Maybe (NonEmpty PropertyFilter)
$sel:orderBy:TabularConditions' :: TabularConditions -> Maybe (NonEmpty OrderBy)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty OrderBy)
orderBy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty PropertyFilter)
propertyFilters

instance Data.ToJSON TabularConditions where
  toJSON :: TabularConditions -> Value
toJSON TabularConditions' {Maybe (NonEmpty OrderBy)
Maybe (NonEmpty PropertyFilter)
propertyFilters :: Maybe (NonEmpty PropertyFilter)
orderBy :: Maybe (NonEmpty OrderBy)
$sel:propertyFilters:TabularConditions' :: TabularConditions -> Maybe (NonEmpty PropertyFilter)
$sel:orderBy:TabularConditions' :: TabularConditions -> Maybe (NonEmpty OrderBy)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"orderBy" 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 (NonEmpty OrderBy)
orderBy,
            (Key
"propertyFilters" 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 (NonEmpty PropertyFilter)
propertyFilters
          ]
      )