{-# 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.ActivityType
-- 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.ActivityType 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

-- | Represents an activity type.
--
-- /See:/ 'newActivityType' smart constructor.
data ActivityType = ActivityType'
  { -- | The name of this activity.
    --
    -- The combination of activity type name and version must be unique within
    -- a domain.
    ActivityType -> Text
name :: Prelude.Text,
    -- | The version of this activity.
    --
    -- The combination of activity type name and version must be unique with in
    -- a domain.
    ActivityType -> Text
version :: Prelude.Text
  }
  deriving (ActivityType -> ActivityType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActivityType -> ActivityType -> Bool
$c/= :: ActivityType -> ActivityType -> Bool
== :: ActivityType -> ActivityType -> Bool
$c== :: ActivityType -> ActivityType -> Bool
Prelude.Eq, ReadPrec [ActivityType]
ReadPrec ActivityType
Int -> ReadS ActivityType
ReadS [ActivityType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ActivityType]
$creadListPrec :: ReadPrec [ActivityType]
readPrec :: ReadPrec ActivityType
$creadPrec :: ReadPrec ActivityType
readList :: ReadS [ActivityType]
$creadList :: ReadS [ActivityType]
readsPrec :: Int -> ReadS ActivityType
$creadsPrec :: Int -> ReadS ActivityType
Prelude.Read, Int -> ActivityType -> ShowS
[ActivityType] -> ShowS
ActivityType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ActivityType] -> ShowS
$cshowList :: [ActivityType] -> ShowS
show :: ActivityType -> String
$cshow :: ActivityType -> String
showsPrec :: Int -> ActivityType -> ShowS
$cshowsPrec :: Int -> ActivityType -> ShowS
Prelude.Show, forall x. Rep ActivityType x -> ActivityType
forall x. ActivityType -> Rep ActivityType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ActivityType x -> ActivityType
$cfrom :: forall x. ActivityType -> Rep ActivityType x
Prelude.Generic)

-- |
-- Create a value of 'ActivityType' 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:
--
-- 'name', 'activityType_name' - The name of this activity.
--
-- The combination of activity type name and version must be unique within
-- a domain.
--
-- 'version', 'activityType_version' - The version of this activity.
--
-- The combination of activity type name and version must be unique with in
-- a domain.
newActivityType ::
  -- | 'name'
  Prelude.Text ->
  -- | 'version'
  Prelude.Text ->
  ActivityType
newActivityType :: Text -> Text -> ActivityType
newActivityType Text
pName_ Text
pVersion_ =
  ActivityType' {$sel:name:ActivityType' :: Text
name = Text
pName_, $sel:version:ActivityType' :: Text
version = Text
pVersion_}

-- | The name of this activity.
--
-- The combination of activity type name and version must be unique within
-- a domain.
activityType_name :: Lens.Lens' ActivityType Prelude.Text
activityType_name :: Lens' ActivityType Text
activityType_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActivityType' {Text
name :: Text
$sel:name:ActivityType' :: ActivityType -> Text
name} -> Text
name) (\s :: ActivityType
s@ActivityType' {} Text
a -> ActivityType
s {$sel:name:ActivityType' :: Text
name = Text
a} :: ActivityType)

-- | The version of this activity.
--
-- The combination of activity type name and version must be unique with in
-- a domain.
activityType_version :: Lens.Lens' ActivityType Prelude.Text
activityType_version :: Lens' ActivityType Text
activityType_version = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActivityType' {Text
version :: Text
$sel:version:ActivityType' :: ActivityType -> Text
version} -> Text
version) (\s :: ActivityType
s@ActivityType' {} Text
a -> ActivityType
s {$sel:version:ActivityType' :: Text
version = Text
a} :: ActivityType)

instance Data.FromJSON ActivityType where
  parseJSON :: Value -> Parser ActivityType
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ActivityType"
      ( \Object
x ->
          Text -> Text -> ActivityType
ActivityType'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"name")
            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
"version")
      )

instance Prelude.Hashable ActivityType where
  hashWithSalt :: Int -> ActivityType -> Int
hashWithSalt Int
_salt ActivityType' {Text
version :: Text
name :: Text
$sel:version:ActivityType' :: ActivityType -> Text
$sel:name:ActivityType' :: ActivityType -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
version

instance Prelude.NFData ActivityType where
  rnf :: ActivityType -> ()
rnf ActivityType' {Text
version :: Text
name :: Text
$sel:version:ActivityType' :: ActivityType -> Text
$sel:name:ActivityType' :: ActivityType -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
name seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
version

instance Data.ToJSON ActivityType where
  toJSON :: ActivityType -> Value
toJSON ActivityType' {Text
version :: Text
name :: Text
$sel:version:ActivityType' :: ActivityType -> Text
$sel:name:ActivityType' :: ActivityType -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"version" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
version)
          ]
      )