{-# 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.CodePipeline.Types.ActionTypeId
-- 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.CodePipeline.Types.ActionTypeId where

import Amazonka.CodePipeline.Types.ActionCategory
import Amazonka.CodePipeline.Types.ActionOwner
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents information about an action type.
--
-- /See:/ 'newActionTypeId' smart constructor.
data ActionTypeId = ActionTypeId'
  { -- | A category defines what kind of action can be taken in the stage, and
    -- constrains the provider type for the action. Valid categories are
    -- limited to one of the following values.
    --
    -- -   Source
    --
    -- -   Build
    --
    -- -   Test
    --
    -- -   Deploy
    --
    -- -   Invoke
    --
    -- -   Approval
    ActionTypeId -> ActionCategory
category :: ActionCategory,
    -- | The creator of the action being called. There are three valid values for
    -- the @Owner@ field in the action category section within your pipeline
    -- structure: @AWS@, @ThirdParty@, and @Custom@. For more information, see
    -- <https://docs.aws.amazon.com/codepipeline/latest/userguide/reference-pipeline-structure.html#actions-valid-providers Valid Action Types and Providers in CodePipeline>.
    ActionTypeId -> ActionOwner
owner :: ActionOwner,
    -- | The provider of the service being called by the action. Valid providers
    -- are determined by the action category. For example, an action in the
    -- Deploy category type might have a provider of AWS CodeDeploy, which
    -- would be specified as CodeDeploy. For more information, see
    -- <https://docs.aws.amazon.com/codepipeline/latest/userguide/reference-pipeline-structure.html#actions-valid-providers Valid Action Types and Providers in CodePipeline>.
    ActionTypeId -> Text
provider :: Prelude.Text,
    -- | A string that describes the action version.
    ActionTypeId -> Text
version :: Prelude.Text
  }
  deriving (ActionTypeId -> ActionTypeId -> Bool
(ActionTypeId -> ActionTypeId -> Bool)
-> (ActionTypeId -> ActionTypeId -> Bool) -> Eq ActionTypeId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActionTypeId -> ActionTypeId -> Bool
$c/= :: ActionTypeId -> ActionTypeId -> Bool
== :: ActionTypeId -> ActionTypeId -> Bool
$c== :: ActionTypeId -> ActionTypeId -> Bool
Prelude.Eq, ReadPrec [ActionTypeId]
ReadPrec ActionTypeId
Int -> ReadS ActionTypeId
ReadS [ActionTypeId]
(Int -> ReadS ActionTypeId)
-> ReadS [ActionTypeId]
-> ReadPrec ActionTypeId
-> ReadPrec [ActionTypeId]
-> Read ActionTypeId
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ActionTypeId]
$creadListPrec :: ReadPrec [ActionTypeId]
readPrec :: ReadPrec ActionTypeId
$creadPrec :: ReadPrec ActionTypeId
readList :: ReadS [ActionTypeId]
$creadList :: ReadS [ActionTypeId]
readsPrec :: Int -> ReadS ActionTypeId
$creadsPrec :: Int -> ReadS ActionTypeId
Prelude.Read, Int -> ActionTypeId -> ShowS
[ActionTypeId] -> ShowS
ActionTypeId -> String
(Int -> ActionTypeId -> ShowS)
-> (ActionTypeId -> String)
-> ([ActionTypeId] -> ShowS)
-> Show ActionTypeId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ActionTypeId] -> ShowS
$cshowList :: [ActionTypeId] -> ShowS
show :: ActionTypeId -> String
$cshow :: ActionTypeId -> String
showsPrec :: Int -> ActionTypeId -> ShowS
$cshowsPrec :: Int -> ActionTypeId -> ShowS
Prelude.Show, (forall x. ActionTypeId -> Rep ActionTypeId x)
-> (forall x. Rep ActionTypeId x -> ActionTypeId)
-> Generic ActionTypeId
forall x. Rep ActionTypeId x -> ActionTypeId
forall x. ActionTypeId -> Rep ActionTypeId x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ActionTypeId x -> ActionTypeId
$cfrom :: forall x. ActionTypeId -> Rep ActionTypeId x
Prelude.Generic)

-- |
-- Create a value of 'ActionTypeId' 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:
--
-- 'category', 'actionTypeId_category' - A category defines what kind of action can be taken in the stage, and
-- constrains the provider type for the action. Valid categories are
-- limited to one of the following values.
--
-- -   Source
--
-- -   Build
--
-- -   Test
--
-- -   Deploy
--
-- -   Invoke
--
-- -   Approval
--
-- 'owner', 'actionTypeId_owner' - The creator of the action being called. There are three valid values for
-- the @Owner@ field in the action category section within your pipeline
-- structure: @AWS@, @ThirdParty@, and @Custom@. For more information, see
-- <https://docs.aws.amazon.com/codepipeline/latest/userguide/reference-pipeline-structure.html#actions-valid-providers Valid Action Types and Providers in CodePipeline>.
--
-- 'provider', 'actionTypeId_provider' - The provider of the service being called by the action. Valid providers
-- are determined by the action category. For example, an action in the
-- Deploy category type might have a provider of AWS CodeDeploy, which
-- would be specified as CodeDeploy. For more information, see
-- <https://docs.aws.amazon.com/codepipeline/latest/userguide/reference-pipeline-structure.html#actions-valid-providers Valid Action Types and Providers in CodePipeline>.
--
-- 'version', 'actionTypeId_version' - A string that describes the action version.
newActionTypeId ::
  -- | 'category'
  ActionCategory ->
  -- | 'owner'
  ActionOwner ->
  -- | 'provider'
  Prelude.Text ->
  -- | 'version'
  Prelude.Text ->
  ActionTypeId
newActionTypeId :: ActionCategory -> ActionOwner -> Text -> Text -> ActionTypeId
newActionTypeId
  ActionCategory
pCategory_
  ActionOwner
pOwner_
  Text
pProvider_
  Text
pVersion_ =
    ActionTypeId' :: ActionCategory -> ActionOwner -> Text -> Text -> ActionTypeId
ActionTypeId'
      { $sel:category:ActionTypeId' :: ActionCategory
category = ActionCategory
pCategory_,
        $sel:owner:ActionTypeId' :: ActionOwner
owner = ActionOwner
pOwner_,
        $sel:provider:ActionTypeId' :: Text
provider = Text
pProvider_,
        $sel:version:ActionTypeId' :: Text
version = Text
pVersion_
      }

-- | A category defines what kind of action can be taken in the stage, and
-- constrains the provider type for the action. Valid categories are
-- limited to one of the following values.
--
-- -   Source
--
-- -   Build
--
-- -   Test
--
-- -   Deploy
--
-- -   Invoke
--
-- -   Approval
actionTypeId_category :: Lens.Lens' ActionTypeId ActionCategory
actionTypeId_category :: (ActionCategory -> f ActionCategory)
-> ActionTypeId -> f ActionTypeId
actionTypeId_category = (ActionTypeId -> ActionCategory)
-> (ActionTypeId -> ActionCategory -> ActionTypeId)
-> Lens ActionTypeId ActionTypeId ActionCategory ActionCategory
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionTypeId' {ActionCategory
category :: ActionCategory
$sel:category:ActionTypeId' :: ActionTypeId -> ActionCategory
category} -> ActionCategory
category) (\s :: ActionTypeId
s@ActionTypeId' {} ActionCategory
a -> ActionTypeId
s {$sel:category:ActionTypeId' :: ActionCategory
category = ActionCategory
a} :: ActionTypeId)

-- | The creator of the action being called. There are three valid values for
-- the @Owner@ field in the action category section within your pipeline
-- structure: @AWS@, @ThirdParty@, and @Custom@. For more information, see
-- <https://docs.aws.amazon.com/codepipeline/latest/userguide/reference-pipeline-structure.html#actions-valid-providers Valid Action Types and Providers in CodePipeline>.
actionTypeId_owner :: Lens.Lens' ActionTypeId ActionOwner
actionTypeId_owner :: (ActionOwner -> f ActionOwner) -> ActionTypeId -> f ActionTypeId
actionTypeId_owner = (ActionTypeId -> ActionOwner)
-> (ActionTypeId -> ActionOwner -> ActionTypeId)
-> Lens ActionTypeId ActionTypeId ActionOwner ActionOwner
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionTypeId' {ActionOwner
owner :: ActionOwner
$sel:owner:ActionTypeId' :: ActionTypeId -> ActionOwner
owner} -> ActionOwner
owner) (\s :: ActionTypeId
s@ActionTypeId' {} ActionOwner
a -> ActionTypeId
s {$sel:owner:ActionTypeId' :: ActionOwner
owner = ActionOwner
a} :: ActionTypeId)

-- | The provider of the service being called by the action. Valid providers
-- are determined by the action category. For example, an action in the
-- Deploy category type might have a provider of AWS CodeDeploy, which
-- would be specified as CodeDeploy. For more information, see
-- <https://docs.aws.amazon.com/codepipeline/latest/userguide/reference-pipeline-structure.html#actions-valid-providers Valid Action Types and Providers in CodePipeline>.
actionTypeId_provider :: Lens.Lens' ActionTypeId Prelude.Text
actionTypeId_provider :: (Text -> f Text) -> ActionTypeId -> f ActionTypeId
actionTypeId_provider = (ActionTypeId -> Text)
-> (ActionTypeId -> Text -> ActionTypeId)
-> Lens ActionTypeId ActionTypeId Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionTypeId' {Text
provider :: Text
$sel:provider:ActionTypeId' :: ActionTypeId -> Text
provider} -> Text
provider) (\s :: ActionTypeId
s@ActionTypeId' {} Text
a -> ActionTypeId
s {$sel:provider:ActionTypeId' :: Text
provider = Text
a} :: ActionTypeId)

-- | A string that describes the action version.
actionTypeId_version :: Lens.Lens' ActionTypeId Prelude.Text
actionTypeId_version :: (Text -> f Text) -> ActionTypeId -> f ActionTypeId
actionTypeId_version = (ActionTypeId -> Text)
-> (ActionTypeId -> Text -> ActionTypeId)
-> Lens ActionTypeId ActionTypeId Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionTypeId' {Text
version :: Text
$sel:version:ActionTypeId' :: ActionTypeId -> Text
version} -> Text
version) (\s :: ActionTypeId
s@ActionTypeId' {} Text
a -> ActionTypeId
s {$sel:version:ActionTypeId' :: Text
version = Text
a} :: ActionTypeId)

instance Core.FromJSON ActionTypeId where
  parseJSON :: Value -> Parser ActionTypeId
parseJSON =
    String
-> (Object -> Parser ActionTypeId) -> Value -> Parser ActionTypeId
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ActionTypeId"
      ( \Object
x ->
          ActionCategory -> ActionOwner -> Text -> Text -> ActionTypeId
ActionTypeId'
            (ActionCategory -> ActionOwner -> Text -> Text -> ActionTypeId)
-> Parser ActionCategory
-> Parser (ActionOwner -> Text -> Text -> ActionTypeId)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser ActionCategory
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"category")
            Parser (ActionOwner -> Text -> Text -> ActionTypeId)
-> Parser ActionOwner -> Parser (Text -> Text -> ActionTypeId)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ActionOwner
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"owner")
            Parser (Text -> Text -> ActionTypeId)
-> Parser Text -> Parser (Text -> ActionTypeId)
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
"provider")
            Parser (Text -> ActionTypeId) -> Parser Text -> Parser ActionTypeId
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 ActionTypeId

instance Prelude.NFData ActionTypeId

instance Core.ToJSON ActionTypeId where
  toJSON :: ActionTypeId -> Value
toJSON ActionTypeId' {Text
ActionCategory
ActionOwner
version :: Text
provider :: Text
owner :: ActionOwner
category :: ActionCategory
$sel:version:ActionTypeId' :: ActionTypeId -> Text
$sel:provider:ActionTypeId' :: ActionTypeId -> Text
$sel:owner:ActionTypeId' :: ActionTypeId -> ActionOwner
$sel:category:ActionTypeId' :: ActionTypeId -> ActionCategory
..} =
    [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
"category" Text -> ActionCategory -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ActionCategory
category),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"owner" Text -> ActionOwner -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ActionOwner
owner),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"provider" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
provider),
            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)
          ]
      )