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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(WorkflowExecutionCount -> WorkflowExecutionCount -> Bool)
-> (WorkflowExecutionCount -> WorkflowExecutionCount -> Bool)
-> Eq WorkflowExecutionCount
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]
(Int -> ReadS WorkflowExecutionCount)
-> ReadS [WorkflowExecutionCount]
-> ReadPrec WorkflowExecutionCount
-> ReadPrec [WorkflowExecutionCount]
-> Read 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
(Int -> WorkflowExecutionCount -> ShowS)
-> (WorkflowExecutionCount -> String)
-> ([WorkflowExecutionCount] -> ShowS)
-> Show WorkflowExecutionCount
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. WorkflowExecutionCount -> Rep WorkflowExecutionCount x)
-> (forall x.
    Rep WorkflowExecutionCount x -> WorkflowExecutionCount)
-> Generic WorkflowExecutionCount
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' :: Maybe Bool -> Natural -> WorkflowExecutionCount
WorkflowExecutionCount'
    { $sel:truncated:WorkflowExecutionCount' :: Maybe Bool
truncated =
        Maybe Bool
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 :: (Maybe Bool -> f (Maybe Bool))
-> WorkflowExecutionCount -> f WorkflowExecutionCount
workflowExecutionCount_truncated = (WorkflowExecutionCount -> Maybe Bool)
-> (WorkflowExecutionCount -> Maybe Bool -> WorkflowExecutionCount)
-> Lens
     WorkflowExecutionCount
     WorkflowExecutionCount
     (Maybe Bool)
     (Maybe Bool)
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 :: (Natural -> f Natural)
-> WorkflowExecutionCount -> f WorkflowExecutionCount
workflowExecutionCount_count = (WorkflowExecutionCount -> Natural)
-> (WorkflowExecutionCount -> Natural -> WorkflowExecutionCount)
-> Lens
     WorkflowExecutionCount WorkflowExecutionCount Natural Natural
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 Core.FromJSON WorkflowExecutionCount where
  parseJSON :: Value -> Parser WorkflowExecutionCount
parseJSON =
    String
-> (Object -> Parser WorkflowExecutionCount)
-> Value
-> Parser WorkflowExecutionCount
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"WorkflowExecutionCount"
      ( \Object
x ->
          Maybe Bool -> Natural -> WorkflowExecutionCount
WorkflowExecutionCount'
            (Maybe Bool -> Natural -> WorkflowExecutionCount)
-> Parser (Maybe Bool)
-> Parser (Natural -> WorkflowExecutionCount)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"truncated")
            Parser (Natural -> WorkflowExecutionCount)
-> Parser Natural -> Parser WorkflowExecutionCount
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"count")
      )

instance Prelude.Hashable WorkflowExecutionCount

instance Prelude.NFData WorkflowExecutionCount