{-# 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.SWF.Types.WorkflowExecutionCount
-- 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.SWF.Types.WorkflowExecutionCount 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

-- | Contains the count of workflow executions returned from
-- CountOpenWorkflowExecutions or CountClosedWorkflowExecutions
--
-- /See:/ 'newWorkflowExecutionCount' smart constructor.
data WorkflowExecutionCount = WorkflowExecutionCount'
  { -- | If set to true, indicates that the actual count was more than the
    -- maximum supported by this API and the count returned is the truncated
    -- value.
    WorkflowExecutionCount -> Maybe Bool
truncated :: Prelude.Maybe Prelude.Bool,
    -- | The number of workflow executions.
    WorkflowExecutionCount -> Natural
count :: Prelude.Natural
  }
  deriving (WorkflowExecutionCount -> WorkflowExecutionCount -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WorkflowExecutionCount -> WorkflowExecutionCount -> Bool
$c/= :: WorkflowExecutionCount -> WorkflowExecutionCount -> Bool
== :: WorkflowExecutionCount -> WorkflowExecutionCount -> Bool
$c== :: WorkflowExecutionCount -> WorkflowExecutionCount -> Bool
Prelude.Eq, ReadPrec [WorkflowExecutionCount]
ReadPrec WorkflowExecutionCount
Int -> ReadS WorkflowExecutionCount
ReadS [WorkflowExecutionCount]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WorkflowExecutionCount]
$creadListPrec :: ReadPrec [WorkflowExecutionCount]
readPrec :: ReadPrec WorkflowExecutionCount
$creadPrec :: ReadPrec WorkflowExecutionCount
readList :: ReadS [WorkflowExecutionCount]
$creadList :: ReadS [WorkflowExecutionCount]
readsPrec :: Int -> ReadS WorkflowExecutionCount
$creadsPrec :: Int -> ReadS WorkflowExecutionCount
Prelude.Read, Int -> WorkflowExecutionCount -> ShowS
[WorkflowExecutionCount] -> ShowS
WorkflowExecutionCount -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WorkflowExecutionCount] -> ShowS
$cshowList :: [WorkflowExecutionCount] -> ShowS
show :: WorkflowExecutionCount -> String
$cshow :: WorkflowExecutionCount -> String
showsPrec :: Int -> WorkflowExecutionCount -> ShowS
$cshowsPrec :: Int -> WorkflowExecutionCount -> ShowS
Prelude.Show, forall x. Rep WorkflowExecutionCount x -> WorkflowExecutionCount
forall x. WorkflowExecutionCount -> Rep WorkflowExecutionCount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WorkflowExecutionCount x -> WorkflowExecutionCount
$cfrom :: forall x. WorkflowExecutionCount -> Rep WorkflowExecutionCount x
Prelude.Generic)

-- |
-- Create a value of 'WorkflowExecutionCount' 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:
--
-- 'truncated', 'workflowExecutionCount_truncated' - If set to true, indicates that the actual count was more than the
-- maximum supported by this API and the count returned is the truncated
-- value.
--
-- 'count', 'workflowExecutionCount_count' - The number of workflow executions.
newWorkflowExecutionCount ::
  -- | 'count'
  Prelude.Natural ->
  WorkflowExecutionCount
newWorkflowExecutionCount :: Natural -> WorkflowExecutionCount
newWorkflowExecutionCount Natural
pCount_ =
  WorkflowExecutionCount'
    { $sel:truncated:WorkflowExecutionCount' :: Maybe Bool
truncated =
        forall a. Maybe a
Prelude.Nothing,
      $sel:count:WorkflowExecutionCount' :: Natural
count = Natural
pCount_
    }

-- | If set to true, indicates that the actual count was more than the
-- maximum supported by this API and the count returned is the truncated
-- value.
workflowExecutionCount_truncated :: Lens.Lens' WorkflowExecutionCount (Prelude.Maybe Prelude.Bool)
workflowExecutionCount_truncated :: Lens' WorkflowExecutionCount (Maybe Bool)
workflowExecutionCount_truncated = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkflowExecutionCount' {Maybe Bool
truncated :: Maybe Bool
$sel:truncated:WorkflowExecutionCount' :: WorkflowExecutionCount -> Maybe Bool
truncated} -> Maybe Bool
truncated) (\s :: WorkflowExecutionCount
s@WorkflowExecutionCount' {} Maybe Bool
a -> WorkflowExecutionCount
s {$sel:truncated:WorkflowExecutionCount' :: Maybe Bool
truncated = Maybe Bool
a} :: WorkflowExecutionCount)

-- | The number of workflow executions.
workflowExecutionCount_count :: Lens.Lens' WorkflowExecutionCount Prelude.Natural
workflowExecutionCount_count :: Lens' WorkflowExecutionCount Natural
workflowExecutionCount_count = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkflowExecutionCount' {Natural
count :: Natural
$sel:count:WorkflowExecutionCount' :: WorkflowExecutionCount -> Natural
count} -> Natural
count) (\s :: WorkflowExecutionCount
s@WorkflowExecutionCount' {} Natural
a -> WorkflowExecutionCount
s {$sel:count:WorkflowExecutionCount' :: Natural
count = Natural
a} :: WorkflowExecutionCount)

instance Data.FromJSON WorkflowExecutionCount where
  parseJSON :: Value -> Parser WorkflowExecutionCount
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"WorkflowExecutionCount"
      ( \Object
x ->
          Maybe Bool -> Natural -> WorkflowExecutionCount
WorkflowExecutionCount'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"truncated")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"count")
      )

instance Prelude.Hashable WorkflowExecutionCount where
  hashWithSalt :: Int -> WorkflowExecutionCount -> Int
hashWithSalt Int
_salt WorkflowExecutionCount' {Natural
Maybe Bool
count :: Natural
truncated :: Maybe Bool
$sel:count:WorkflowExecutionCount' :: WorkflowExecutionCount -> Natural
$sel:truncated:WorkflowExecutionCount' :: WorkflowExecutionCount -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
truncated
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
count

instance Prelude.NFData WorkflowExecutionCount where
  rnf :: WorkflowExecutionCount -> ()
rnf WorkflowExecutionCount' {Natural
Maybe Bool
count :: Natural
truncated :: Maybe Bool
$sel:count:WorkflowExecutionCount' :: WorkflowExecutionCount -> Natural
$sel:truncated:WorkflowExecutionCount' :: WorkflowExecutionCount -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
truncated
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
count