{-# 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.CodeCommit.Types.OriginApprovalRuleTemplate
-- 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.CodeCommit.Types.OriginApprovalRuleTemplate where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Returns information about the template that created the approval rule
-- for a pull request.
--
-- /See:/ 'newOriginApprovalRuleTemplate' smart constructor.
data OriginApprovalRuleTemplate = OriginApprovalRuleTemplate'
  { -- | The ID of the template that created the approval rule.
    OriginApprovalRuleTemplate -> Maybe Text
approvalRuleTemplateId :: Prelude.Maybe Prelude.Text,
    -- | The name of the template that created the approval rule.
    OriginApprovalRuleTemplate -> Maybe Text
approvalRuleTemplateName :: Prelude.Maybe Prelude.Text
  }
  deriving (OriginApprovalRuleTemplate -> OriginApprovalRuleTemplate -> Bool
(OriginApprovalRuleTemplate -> OriginApprovalRuleTemplate -> Bool)
-> (OriginApprovalRuleTemplate
    -> OriginApprovalRuleTemplate -> Bool)
-> Eq OriginApprovalRuleTemplate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OriginApprovalRuleTemplate -> OriginApprovalRuleTemplate -> Bool
$c/= :: OriginApprovalRuleTemplate -> OriginApprovalRuleTemplate -> Bool
== :: OriginApprovalRuleTemplate -> OriginApprovalRuleTemplate -> Bool
$c== :: OriginApprovalRuleTemplate -> OriginApprovalRuleTemplate -> Bool
Prelude.Eq, ReadPrec [OriginApprovalRuleTemplate]
ReadPrec OriginApprovalRuleTemplate
Int -> ReadS OriginApprovalRuleTemplate
ReadS [OriginApprovalRuleTemplate]
(Int -> ReadS OriginApprovalRuleTemplate)
-> ReadS [OriginApprovalRuleTemplate]
-> ReadPrec OriginApprovalRuleTemplate
-> ReadPrec [OriginApprovalRuleTemplate]
-> Read OriginApprovalRuleTemplate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OriginApprovalRuleTemplate]
$creadListPrec :: ReadPrec [OriginApprovalRuleTemplate]
readPrec :: ReadPrec OriginApprovalRuleTemplate
$creadPrec :: ReadPrec OriginApprovalRuleTemplate
readList :: ReadS [OriginApprovalRuleTemplate]
$creadList :: ReadS [OriginApprovalRuleTemplate]
readsPrec :: Int -> ReadS OriginApprovalRuleTemplate
$creadsPrec :: Int -> ReadS OriginApprovalRuleTemplate
Prelude.Read, Int -> OriginApprovalRuleTemplate -> ShowS
[OriginApprovalRuleTemplate] -> ShowS
OriginApprovalRuleTemplate -> String
(Int -> OriginApprovalRuleTemplate -> ShowS)
-> (OriginApprovalRuleTemplate -> String)
-> ([OriginApprovalRuleTemplate] -> ShowS)
-> Show OriginApprovalRuleTemplate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OriginApprovalRuleTemplate] -> ShowS
$cshowList :: [OriginApprovalRuleTemplate] -> ShowS
show :: OriginApprovalRuleTemplate -> String
$cshow :: OriginApprovalRuleTemplate -> String
showsPrec :: Int -> OriginApprovalRuleTemplate -> ShowS
$cshowsPrec :: Int -> OriginApprovalRuleTemplate -> ShowS
Prelude.Show, (forall x.
 OriginApprovalRuleTemplate -> Rep OriginApprovalRuleTemplate x)
-> (forall x.
    Rep OriginApprovalRuleTemplate x -> OriginApprovalRuleTemplate)
-> Generic OriginApprovalRuleTemplate
forall x.
Rep OriginApprovalRuleTemplate x -> OriginApprovalRuleTemplate
forall x.
OriginApprovalRuleTemplate -> Rep OriginApprovalRuleTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep OriginApprovalRuleTemplate x -> OriginApprovalRuleTemplate
$cfrom :: forall x.
OriginApprovalRuleTemplate -> Rep OriginApprovalRuleTemplate x
Prelude.Generic)

-- |
-- Create a value of 'OriginApprovalRuleTemplate' 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:
--
-- 'approvalRuleTemplateId', 'originApprovalRuleTemplate_approvalRuleTemplateId' - The ID of the template that created the approval rule.
--
-- 'approvalRuleTemplateName', 'originApprovalRuleTemplate_approvalRuleTemplateName' - The name of the template that created the approval rule.
newOriginApprovalRuleTemplate ::
  OriginApprovalRuleTemplate
newOriginApprovalRuleTemplate :: OriginApprovalRuleTemplate
newOriginApprovalRuleTemplate =
  OriginApprovalRuleTemplate' :: Maybe Text -> Maybe Text -> OriginApprovalRuleTemplate
OriginApprovalRuleTemplate'
    { $sel:approvalRuleTemplateId:OriginApprovalRuleTemplate' :: Maybe Text
approvalRuleTemplateId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:approvalRuleTemplateName:OriginApprovalRuleTemplate' :: Maybe Text
approvalRuleTemplateName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the template that created the approval rule.
originApprovalRuleTemplate_approvalRuleTemplateId :: Lens.Lens' OriginApprovalRuleTemplate (Prelude.Maybe Prelude.Text)
originApprovalRuleTemplate_approvalRuleTemplateId :: (Maybe Text -> f (Maybe Text))
-> OriginApprovalRuleTemplate -> f OriginApprovalRuleTemplate
originApprovalRuleTemplate_approvalRuleTemplateId = (OriginApprovalRuleTemplate -> Maybe Text)
-> (OriginApprovalRuleTemplate
    -> Maybe Text -> OriginApprovalRuleTemplate)
-> Lens
     OriginApprovalRuleTemplate
     OriginApprovalRuleTemplate
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OriginApprovalRuleTemplate' {Maybe Text
approvalRuleTemplateId :: Maybe Text
$sel:approvalRuleTemplateId:OriginApprovalRuleTemplate' :: OriginApprovalRuleTemplate -> Maybe Text
approvalRuleTemplateId} -> Maybe Text
approvalRuleTemplateId) (\s :: OriginApprovalRuleTemplate
s@OriginApprovalRuleTemplate' {} Maybe Text
a -> OriginApprovalRuleTemplate
s {$sel:approvalRuleTemplateId:OriginApprovalRuleTemplate' :: Maybe Text
approvalRuleTemplateId = Maybe Text
a} :: OriginApprovalRuleTemplate)

-- | The name of the template that created the approval rule.
originApprovalRuleTemplate_approvalRuleTemplateName :: Lens.Lens' OriginApprovalRuleTemplate (Prelude.Maybe Prelude.Text)
originApprovalRuleTemplate_approvalRuleTemplateName :: (Maybe Text -> f (Maybe Text))
-> OriginApprovalRuleTemplate -> f OriginApprovalRuleTemplate
originApprovalRuleTemplate_approvalRuleTemplateName = (OriginApprovalRuleTemplate -> Maybe Text)
-> (OriginApprovalRuleTemplate
    -> Maybe Text -> OriginApprovalRuleTemplate)
-> Lens
     OriginApprovalRuleTemplate
     OriginApprovalRuleTemplate
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OriginApprovalRuleTemplate' {Maybe Text
approvalRuleTemplateName :: Maybe Text
$sel:approvalRuleTemplateName:OriginApprovalRuleTemplate' :: OriginApprovalRuleTemplate -> Maybe Text
approvalRuleTemplateName} -> Maybe Text
approvalRuleTemplateName) (\s :: OriginApprovalRuleTemplate
s@OriginApprovalRuleTemplate' {} Maybe Text
a -> OriginApprovalRuleTemplate
s {$sel:approvalRuleTemplateName:OriginApprovalRuleTemplate' :: Maybe Text
approvalRuleTemplateName = Maybe Text
a} :: OriginApprovalRuleTemplate)

instance Core.FromJSON OriginApprovalRuleTemplate where
  parseJSON :: Value -> Parser OriginApprovalRuleTemplate
parseJSON =
    String
-> (Object -> Parser OriginApprovalRuleTemplate)
-> Value
-> Parser OriginApprovalRuleTemplate
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"OriginApprovalRuleTemplate"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> OriginApprovalRuleTemplate
OriginApprovalRuleTemplate'
            (Maybe Text -> Maybe Text -> OriginApprovalRuleTemplate)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> OriginApprovalRuleTemplate)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"approvalRuleTemplateId")
            Parser (Maybe Text -> OriginApprovalRuleTemplate)
-> Parser (Maybe Text) -> Parser OriginApprovalRuleTemplate
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"approvalRuleTemplateName")
      )

instance Prelude.Hashable OriginApprovalRuleTemplate

instance Prelude.NFData OriginApprovalRuleTemplate