{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.DescribeActivityType
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns information about the specified activity type. This includes
-- configuration settings provided when the type was registered and other
-- general information about the type.
--
-- __Access Control__
--
-- You can use IAM policies to control this action\'s access to Amazon SWF
-- resources as follows:
--
-- -   Use a @Resource@ element with the domain name to limit the action to
--     only specified domains.
--
-- -   Use an @Action@ element to allow or deny permission to call this
--     action.
--
-- -   Constrain the following parameters by using a @Condition@ element
--     with the appropriate keys.
--
--     -   @activityType.name@: String constraint. The key is
--         @swf:activityType.name@.
--
--     -   @activityType.version@: String constraint. The key is
--         @swf:activityType.version@.
--
-- If the caller doesn\'t have sufficient permissions to invoke the action,
-- or the parameter values fall outside the specified constraints, the
-- action fails. The associated event attribute\'s @cause@ parameter is set
-- to @OPERATION_NOT_PERMITTED@. For details and example IAM policies, see
-- <https://docs.aws.amazon.com/amazonswf/latest/developerguide/swf-dev-iam.html Using IAM to Manage Access to Amazon SWF Workflows>
-- in the /Amazon SWF Developer Guide/.
module Amazonka.SWF.DescribeActivityType
  ( -- * Creating a Request
    DescribeActivityType (..),
    newDescribeActivityType,

    -- * Request Lenses
    describeActivityType_domain,
    describeActivityType_activityType,

    -- * Destructuring the Response
    DescribeActivityTypeResponse (..),
    newDescribeActivityTypeResponse,

    -- * Response Lenses
    describeActivityTypeResponse_httpStatus,
    describeActivityTypeResponse_typeInfo,
    describeActivityTypeResponse_configuration,
  )
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
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SWF.Types

-- | /See:/ 'newDescribeActivityType' smart constructor.
data DescribeActivityType = DescribeActivityType'
  { -- | The name of the domain in which the activity type is registered.
    DescribeActivityType -> Text
domain :: Prelude.Text,
    -- | The activity type to get information about. Activity types are
    -- identified by the @name@ and @version@ that were supplied when the
    -- activity was registered.
    DescribeActivityType -> ActivityType
activityType :: ActivityType
  }
  deriving (DescribeActivityType -> DescribeActivityType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeActivityType -> DescribeActivityType -> Bool
$c/= :: DescribeActivityType -> DescribeActivityType -> Bool
== :: DescribeActivityType -> DescribeActivityType -> Bool
$c== :: DescribeActivityType -> DescribeActivityType -> Bool
Prelude.Eq, ReadPrec [DescribeActivityType]
ReadPrec DescribeActivityType
Int -> ReadS DescribeActivityType
ReadS [DescribeActivityType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeActivityType]
$creadListPrec :: ReadPrec [DescribeActivityType]
readPrec :: ReadPrec DescribeActivityType
$creadPrec :: ReadPrec DescribeActivityType
readList :: ReadS [DescribeActivityType]
$creadList :: ReadS [DescribeActivityType]
readsPrec :: Int -> ReadS DescribeActivityType
$creadsPrec :: Int -> ReadS DescribeActivityType
Prelude.Read, Int -> DescribeActivityType -> ShowS
[DescribeActivityType] -> ShowS
DescribeActivityType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeActivityType] -> ShowS
$cshowList :: [DescribeActivityType] -> ShowS
show :: DescribeActivityType -> String
$cshow :: DescribeActivityType -> String
showsPrec :: Int -> DescribeActivityType -> ShowS
$cshowsPrec :: Int -> DescribeActivityType -> ShowS
Prelude.Show, forall x. Rep DescribeActivityType x -> DescribeActivityType
forall x. DescribeActivityType -> Rep DescribeActivityType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeActivityType x -> DescribeActivityType
$cfrom :: forall x. DescribeActivityType -> Rep DescribeActivityType x
Prelude.Generic)

-- |
-- Create a value of 'DescribeActivityType' 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:
--
-- 'domain', 'describeActivityType_domain' - The name of the domain in which the activity type is registered.
--
-- 'activityType', 'describeActivityType_activityType' - The activity type to get information about. Activity types are
-- identified by the @name@ and @version@ that were supplied when the
-- activity was registered.
newDescribeActivityType ::
  -- | 'domain'
  Prelude.Text ->
  -- | 'activityType'
  ActivityType ->
  DescribeActivityType
newDescribeActivityType :: Text -> ActivityType -> DescribeActivityType
newDescribeActivityType Text
pDomain_ ActivityType
pActivityType_ =
  DescribeActivityType'
    { $sel:domain:DescribeActivityType' :: Text
domain = Text
pDomain_,
      $sel:activityType:DescribeActivityType' :: ActivityType
activityType = ActivityType
pActivityType_
    }

-- | The name of the domain in which the activity type is registered.
describeActivityType_domain :: Lens.Lens' DescribeActivityType Prelude.Text
describeActivityType_domain :: Lens' DescribeActivityType Text
describeActivityType_domain = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeActivityType' {Text
domain :: Text
$sel:domain:DescribeActivityType' :: DescribeActivityType -> Text
domain} -> Text
domain) (\s :: DescribeActivityType
s@DescribeActivityType' {} Text
a -> DescribeActivityType
s {$sel:domain:DescribeActivityType' :: Text
domain = Text
a} :: DescribeActivityType)

-- | The activity type to get information about. Activity types are
-- identified by the @name@ and @version@ that were supplied when the
-- activity was registered.
describeActivityType_activityType :: Lens.Lens' DescribeActivityType ActivityType
describeActivityType_activityType :: Lens' DescribeActivityType ActivityType
describeActivityType_activityType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeActivityType' {ActivityType
activityType :: ActivityType
$sel:activityType:DescribeActivityType' :: DescribeActivityType -> ActivityType
activityType} -> ActivityType
activityType) (\s :: DescribeActivityType
s@DescribeActivityType' {} ActivityType
a -> DescribeActivityType
s {$sel:activityType:DescribeActivityType' :: ActivityType
activityType = ActivityType
a} :: DescribeActivityType)

instance Core.AWSRequest DescribeActivityType where
  type
    AWSResponse DescribeActivityType =
      DescribeActivityTypeResponse
  request :: (Service -> Service)
-> DescribeActivityType -> Request DescribeActivityType
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeActivityType
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeActivityType)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int
-> ActivityTypeInfo
-> ActivityTypeConfiguration
-> DescribeActivityTypeResponse
DescribeActivityTypeResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"typeInfo")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"configuration")
      )

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

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

instance Data.ToHeaders DescribeActivityType where
  toHeaders :: DescribeActivityType -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"SimpleWorkflowService.DescribeActivityType" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

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

instance Data.ToPath DescribeActivityType where
  toPath :: DescribeActivityType -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery DescribeActivityType where
  toQuery :: DescribeActivityType -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | Detailed information about an activity type.
--
-- /See:/ 'newDescribeActivityTypeResponse' smart constructor.
data DescribeActivityTypeResponse = DescribeActivityTypeResponse'
  { -- | The response's http status code.
    DescribeActivityTypeResponse -> Int
httpStatus :: Prelude.Int,
    -- | General information about the activity type.
    --
    -- The status of activity type (returned in the ActivityTypeInfo structure)
    -- can be one of the following.
    --
    -- -   @REGISTERED@ – The type is registered and available. Workers
    --     supporting this type should be running.
    --
    -- -   @DEPRECATED@ – The type was deprecated using DeprecateActivityType,
    --     but is still in use. You should keep workers supporting this type
    --     running. You cannot create new tasks of this type.
    DescribeActivityTypeResponse -> ActivityTypeInfo
typeInfo :: ActivityTypeInfo,
    -- | The configuration settings registered with the activity type.
    DescribeActivityTypeResponse -> ActivityTypeConfiguration
configuration :: ActivityTypeConfiguration
  }
  deriving (DescribeActivityTypeResponse
-> DescribeActivityTypeResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeActivityTypeResponse
-> DescribeActivityTypeResponse -> Bool
$c/= :: DescribeActivityTypeResponse
-> DescribeActivityTypeResponse -> Bool
== :: DescribeActivityTypeResponse
-> DescribeActivityTypeResponse -> Bool
$c== :: DescribeActivityTypeResponse
-> DescribeActivityTypeResponse -> Bool
Prelude.Eq, ReadPrec [DescribeActivityTypeResponse]
ReadPrec DescribeActivityTypeResponse
Int -> ReadS DescribeActivityTypeResponse
ReadS [DescribeActivityTypeResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeActivityTypeResponse]
$creadListPrec :: ReadPrec [DescribeActivityTypeResponse]
readPrec :: ReadPrec DescribeActivityTypeResponse
$creadPrec :: ReadPrec DescribeActivityTypeResponse
readList :: ReadS [DescribeActivityTypeResponse]
$creadList :: ReadS [DescribeActivityTypeResponse]
readsPrec :: Int -> ReadS DescribeActivityTypeResponse
$creadsPrec :: Int -> ReadS DescribeActivityTypeResponse
Prelude.Read, Int -> DescribeActivityTypeResponse -> ShowS
[DescribeActivityTypeResponse] -> ShowS
DescribeActivityTypeResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeActivityTypeResponse] -> ShowS
$cshowList :: [DescribeActivityTypeResponse] -> ShowS
show :: DescribeActivityTypeResponse -> String
$cshow :: DescribeActivityTypeResponse -> String
showsPrec :: Int -> DescribeActivityTypeResponse -> ShowS
$cshowsPrec :: Int -> DescribeActivityTypeResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeActivityTypeResponse x -> DescribeActivityTypeResponse
forall x.
DescribeActivityTypeResponse -> Rep DescribeActivityTypeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeActivityTypeResponse x -> DescribeActivityTypeResponse
$cfrom :: forall x.
DescribeActivityTypeResponse -> Rep DescribeActivityTypeResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeActivityTypeResponse' 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:
--
-- 'httpStatus', 'describeActivityTypeResponse_httpStatus' - The response's http status code.
--
-- 'typeInfo', 'describeActivityTypeResponse_typeInfo' - General information about the activity type.
--
-- The status of activity type (returned in the ActivityTypeInfo structure)
-- can be one of the following.
--
-- -   @REGISTERED@ – The type is registered and available. Workers
--     supporting this type should be running.
--
-- -   @DEPRECATED@ – The type was deprecated using DeprecateActivityType,
--     but is still in use. You should keep workers supporting this type
--     running. You cannot create new tasks of this type.
--
-- 'configuration', 'describeActivityTypeResponse_configuration' - The configuration settings registered with the activity type.
newDescribeActivityTypeResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'typeInfo'
  ActivityTypeInfo ->
  -- | 'configuration'
  ActivityTypeConfiguration ->
  DescribeActivityTypeResponse
newDescribeActivityTypeResponse :: Int
-> ActivityTypeInfo
-> ActivityTypeConfiguration
-> DescribeActivityTypeResponse
newDescribeActivityTypeResponse
  Int
pHttpStatus_
  ActivityTypeInfo
pTypeInfo_
  ActivityTypeConfiguration
pConfiguration_ =
    DescribeActivityTypeResponse'
      { $sel:httpStatus:DescribeActivityTypeResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:typeInfo:DescribeActivityTypeResponse' :: ActivityTypeInfo
typeInfo = ActivityTypeInfo
pTypeInfo_,
        $sel:configuration:DescribeActivityTypeResponse' :: ActivityTypeConfiguration
configuration = ActivityTypeConfiguration
pConfiguration_
      }

-- | The response's http status code.
describeActivityTypeResponse_httpStatus :: Lens.Lens' DescribeActivityTypeResponse Prelude.Int
describeActivityTypeResponse_httpStatus :: Lens' DescribeActivityTypeResponse Int
describeActivityTypeResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeActivityTypeResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeActivityTypeResponse' :: DescribeActivityTypeResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeActivityTypeResponse
s@DescribeActivityTypeResponse' {} Int
a -> DescribeActivityTypeResponse
s {$sel:httpStatus:DescribeActivityTypeResponse' :: Int
httpStatus = Int
a} :: DescribeActivityTypeResponse)

-- | General information about the activity type.
--
-- The status of activity type (returned in the ActivityTypeInfo structure)
-- can be one of the following.
--
-- -   @REGISTERED@ – The type is registered and available. Workers
--     supporting this type should be running.
--
-- -   @DEPRECATED@ – The type was deprecated using DeprecateActivityType,
--     but is still in use. You should keep workers supporting this type
--     running. You cannot create new tasks of this type.
describeActivityTypeResponse_typeInfo :: Lens.Lens' DescribeActivityTypeResponse ActivityTypeInfo
describeActivityTypeResponse_typeInfo :: Lens' DescribeActivityTypeResponse ActivityTypeInfo
describeActivityTypeResponse_typeInfo = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeActivityTypeResponse' {ActivityTypeInfo
typeInfo :: ActivityTypeInfo
$sel:typeInfo:DescribeActivityTypeResponse' :: DescribeActivityTypeResponse -> ActivityTypeInfo
typeInfo} -> ActivityTypeInfo
typeInfo) (\s :: DescribeActivityTypeResponse
s@DescribeActivityTypeResponse' {} ActivityTypeInfo
a -> DescribeActivityTypeResponse
s {$sel:typeInfo:DescribeActivityTypeResponse' :: ActivityTypeInfo
typeInfo = ActivityTypeInfo
a} :: DescribeActivityTypeResponse)

-- | The configuration settings registered with the activity type.
describeActivityTypeResponse_configuration :: Lens.Lens' DescribeActivityTypeResponse ActivityTypeConfiguration
describeActivityTypeResponse_configuration :: Lens' DescribeActivityTypeResponse ActivityTypeConfiguration
describeActivityTypeResponse_configuration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeActivityTypeResponse' {ActivityTypeConfiguration
configuration :: ActivityTypeConfiguration
$sel:configuration:DescribeActivityTypeResponse' :: DescribeActivityTypeResponse -> ActivityTypeConfiguration
configuration} -> ActivityTypeConfiguration
configuration) (\s :: DescribeActivityTypeResponse
s@DescribeActivityTypeResponse' {} ActivityTypeConfiguration
a -> DescribeActivityTypeResponse
s {$sel:configuration:DescribeActivityTypeResponse' :: ActivityTypeConfiguration
configuration = ActivityTypeConfiguration
a} :: DescribeActivityTypeResponse)

instance Prelude.NFData DescribeActivityTypeResponse where
  rnf :: DescribeActivityTypeResponse -> ()
rnf DescribeActivityTypeResponse' {Int
ActivityTypeInfo
ActivityTypeConfiguration
configuration :: ActivityTypeConfiguration
typeInfo :: ActivityTypeInfo
httpStatus :: Int
$sel:configuration:DescribeActivityTypeResponse' :: DescribeActivityTypeResponse -> ActivityTypeConfiguration
$sel:typeInfo:DescribeActivityTypeResponse' :: DescribeActivityTypeResponse -> ActivityTypeInfo
$sel:httpStatus:DescribeActivityTypeResponse' :: DescribeActivityTypeResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ActivityTypeInfo
typeInfo
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ActivityTypeConfiguration
configuration