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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ActivityType -> ActivityType -> Bool)
-> (ActivityType -> ActivityType -> Bool) -> Eq ActivityType
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]
(Int -> ReadS ActivityType)
-> ReadS [ActivityType]
-> ReadPrec ActivityType
-> ReadPrec [ActivityType]
-> Read 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
(Int -> ActivityType -> ShowS)
-> (ActivityType -> String)
-> ([ActivityType] -> ShowS)
-> Show ActivityType
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. ActivityType -> Rep ActivityType x)
-> (forall x. Rep ActivityType x -> ActivityType)
-> Generic ActivityType
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' :: Text -> Text -> ActivityType
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 :: (Text -> f Text) -> ActivityType -> f ActivityType
activityType_name = (ActivityType -> Text)
-> (ActivityType -> Text -> ActivityType)
-> Lens ActivityType ActivityType Text Text
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 :: (Text -> f Text) -> ActivityType -> f ActivityType
activityType_version = (ActivityType -> Text)
-> (ActivityType -> Text -> ActivityType)
-> Lens ActivityType ActivityType Text Text
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 Core.FromJSON ActivityType where
  parseJSON :: Value -> Parser ActivityType
parseJSON =
    String
-> (Object -> Parser ActivityType) -> Value -> Parser ActivityType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ActivityType"
      ( \Object
x ->
          Text -> Text -> ActivityType
ActivityType'
            (Text -> Text -> ActivityType)
-> Parser Text -> Parser (Text -> ActivityType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"name") Parser (Text -> ActivityType) -> Parser Text -> Parser ActivityType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"version")
      )

instance Prelude.Hashable ActivityType

instance Prelude.NFData ActivityType

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"version" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
version)
          ]
      )