{-# 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.AuditManager.Types.CreateDelegationRequest
-- 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.AuditManager.Types.CreateDelegationRequest where

import Amazonka.AuditManager.Types.RoleType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A collection of attributes used to create a delegation for an assessment
-- in Audit Manager.
--
-- /See:/ 'newCreateDelegationRequest' smart constructor.
data CreateDelegationRequest = CreateDelegationRequest'
  { -- | The type of customer persona.
    --
    -- In @CreateAssessment@, @roleType@ can only be @PROCESS_OWNER@.
    --
    -- In @UpdateSettings@, @roleType@ can only be @PROCESS_OWNER@.
    --
    -- In @BatchCreateDelegationByAssessment@, @roleType@ can only be
    -- @RESOURCE_OWNER@.
    CreateDelegationRequest -> Maybe RoleType
roleType :: Prelude.Maybe RoleType,
    -- | The unique identifier for the control set.
    CreateDelegationRequest -> Maybe Text
controlSetId :: Prelude.Maybe Prelude.Text,
    -- | A comment related to the delegation request.
    CreateDelegationRequest -> Maybe Text
comment :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the IAM role.
    CreateDelegationRequest -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text
  }
  deriving (CreateDelegationRequest -> CreateDelegationRequest -> Bool
(CreateDelegationRequest -> CreateDelegationRequest -> Bool)
-> (CreateDelegationRequest -> CreateDelegationRequest -> Bool)
-> Eq CreateDelegationRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDelegationRequest -> CreateDelegationRequest -> Bool
$c/= :: CreateDelegationRequest -> CreateDelegationRequest -> Bool
== :: CreateDelegationRequest -> CreateDelegationRequest -> Bool
$c== :: CreateDelegationRequest -> CreateDelegationRequest -> Bool
Prelude.Eq, ReadPrec [CreateDelegationRequest]
ReadPrec CreateDelegationRequest
Int -> ReadS CreateDelegationRequest
ReadS [CreateDelegationRequest]
(Int -> ReadS CreateDelegationRequest)
-> ReadS [CreateDelegationRequest]
-> ReadPrec CreateDelegationRequest
-> ReadPrec [CreateDelegationRequest]
-> Read CreateDelegationRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDelegationRequest]
$creadListPrec :: ReadPrec [CreateDelegationRequest]
readPrec :: ReadPrec CreateDelegationRequest
$creadPrec :: ReadPrec CreateDelegationRequest
readList :: ReadS [CreateDelegationRequest]
$creadList :: ReadS [CreateDelegationRequest]
readsPrec :: Int -> ReadS CreateDelegationRequest
$creadsPrec :: Int -> ReadS CreateDelegationRequest
Prelude.Read, Int -> CreateDelegationRequest -> ShowS
[CreateDelegationRequest] -> ShowS
CreateDelegationRequest -> String
(Int -> CreateDelegationRequest -> ShowS)
-> (CreateDelegationRequest -> String)
-> ([CreateDelegationRequest] -> ShowS)
-> Show CreateDelegationRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDelegationRequest] -> ShowS
$cshowList :: [CreateDelegationRequest] -> ShowS
show :: CreateDelegationRequest -> String
$cshow :: CreateDelegationRequest -> String
showsPrec :: Int -> CreateDelegationRequest -> ShowS
$cshowsPrec :: Int -> CreateDelegationRequest -> ShowS
Prelude.Show, (forall x.
 CreateDelegationRequest -> Rep CreateDelegationRequest x)
-> (forall x.
    Rep CreateDelegationRequest x -> CreateDelegationRequest)
-> Generic CreateDelegationRequest
forall x. Rep CreateDelegationRequest x -> CreateDelegationRequest
forall x. CreateDelegationRequest -> Rep CreateDelegationRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateDelegationRequest x -> CreateDelegationRequest
$cfrom :: forall x. CreateDelegationRequest -> Rep CreateDelegationRequest x
Prelude.Generic)

-- |
-- Create a value of 'CreateDelegationRequest' 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:
--
-- 'roleType', 'createDelegationRequest_roleType' - The type of customer persona.
--
-- In @CreateAssessment@, @roleType@ can only be @PROCESS_OWNER@.
--
-- In @UpdateSettings@, @roleType@ can only be @PROCESS_OWNER@.
--
-- In @BatchCreateDelegationByAssessment@, @roleType@ can only be
-- @RESOURCE_OWNER@.
--
-- 'controlSetId', 'createDelegationRequest_controlSetId' - The unique identifier for the control set.
--
-- 'comment', 'createDelegationRequest_comment' - A comment related to the delegation request.
--
-- 'roleArn', 'createDelegationRequest_roleArn' - The Amazon Resource Name (ARN) of the IAM role.
newCreateDelegationRequest ::
  CreateDelegationRequest
newCreateDelegationRequest :: CreateDelegationRequest
newCreateDelegationRequest =
  CreateDelegationRequest' :: Maybe RoleType
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> CreateDelegationRequest
CreateDelegationRequest'
    { $sel:roleType:CreateDelegationRequest' :: Maybe RoleType
roleType =
        Maybe RoleType
forall a. Maybe a
Prelude.Nothing,
      $sel:controlSetId:CreateDelegationRequest' :: Maybe Text
controlSetId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:comment:CreateDelegationRequest' :: Maybe Text
comment = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:CreateDelegationRequest' :: Maybe Text
roleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The type of customer persona.
--
-- In @CreateAssessment@, @roleType@ can only be @PROCESS_OWNER@.
--
-- In @UpdateSettings@, @roleType@ can only be @PROCESS_OWNER@.
--
-- In @BatchCreateDelegationByAssessment@, @roleType@ can only be
-- @RESOURCE_OWNER@.
createDelegationRequest_roleType :: Lens.Lens' CreateDelegationRequest (Prelude.Maybe RoleType)
createDelegationRequest_roleType :: (Maybe RoleType -> f (Maybe RoleType))
-> CreateDelegationRequest -> f CreateDelegationRequest
createDelegationRequest_roleType = (CreateDelegationRequest -> Maybe RoleType)
-> (CreateDelegationRequest
    -> Maybe RoleType -> CreateDelegationRequest)
-> Lens
     CreateDelegationRequest
     CreateDelegationRequest
     (Maybe RoleType)
     (Maybe RoleType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDelegationRequest' {Maybe RoleType
roleType :: Maybe RoleType
$sel:roleType:CreateDelegationRequest' :: CreateDelegationRequest -> Maybe RoleType
roleType} -> Maybe RoleType
roleType) (\s :: CreateDelegationRequest
s@CreateDelegationRequest' {} Maybe RoleType
a -> CreateDelegationRequest
s {$sel:roleType:CreateDelegationRequest' :: Maybe RoleType
roleType = Maybe RoleType
a} :: CreateDelegationRequest)

-- | The unique identifier for the control set.
createDelegationRequest_controlSetId :: Lens.Lens' CreateDelegationRequest (Prelude.Maybe Prelude.Text)
createDelegationRequest_controlSetId :: (Maybe Text -> f (Maybe Text))
-> CreateDelegationRequest -> f CreateDelegationRequest
createDelegationRequest_controlSetId = (CreateDelegationRequest -> Maybe Text)
-> (CreateDelegationRequest
    -> Maybe Text -> CreateDelegationRequest)
-> Lens
     CreateDelegationRequest
     CreateDelegationRequest
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDelegationRequest' {Maybe Text
controlSetId :: Maybe Text
$sel:controlSetId:CreateDelegationRequest' :: CreateDelegationRequest -> Maybe Text
controlSetId} -> Maybe Text
controlSetId) (\s :: CreateDelegationRequest
s@CreateDelegationRequest' {} Maybe Text
a -> CreateDelegationRequest
s {$sel:controlSetId:CreateDelegationRequest' :: Maybe Text
controlSetId = Maybe Text
a} :: CreateDelegationRequest)

-- | A comment related to the delegation request.
createDelegationRequest_comment :: Lens.Lens' CreateDelegationRequest (Prelude.Maybe Prelude.Text)
createDelegationRequest_comment :: (Maybe Text -> f (Maybe Text))
-> CreateDelegationRequest -> f CreateDelegationRequest
createDelegationRequest_comment = (CreateDelegationRequest -> Maybe Text)
-> (CreateDelegationRequest
    -> Maybe Text -> CreateDelegationRequest)
-> Lens
     CreateDelegationRequest
     CreateDelegationRequest
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDelegationRequest' {Maybe Text
comment :: Maybe Text
$sel:comment:CreateDelegationRequest' :: CreateDelegationRequest -> Maybe Text
comment} -> Maybe Text
comment) (\s :: CreateDelegationRequest
s@CreateDelegationRequest' {} Maybe Text
a -> CreateDelegationRequest
s {$sel:comment:CreateDelegationRequest' :: Maybe Text
comment = Maybe Text
a} :: CreateDelegationRequest)

-- | The Amazon Resource Name (ARN) of the IAM role.
createDelegationRequest_roleArn :: Lens.Lens' CreateDelegationRequest (Prelude.Maybe Prelude.Text)
createDelegationRequest_roleArn :: (Maybe Text -> f (Maybe Text))
-> CreateDelegationRequest -> f CreateDelegationRequest
createDelegationRequest_roleArn = (CreateDelegationRequest -> Maybe Text)
-> (CreateDelegationRequest
    -> Maybe Text -> CreateDelegationRequest)
-> Lens
     CreateDelegationRequest
     CreateDelegationRequest
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDelegationRequest' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:CreateDelegationRequest' :: CreateDelegationRequest -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: CreateDelegationRequest
s@CreateDelegationRequest' {} Maybe Text
a -> CreateDelegationRequest
s {$sel:roleArn:CreateDelegationRequest' :: Maybe Text
roleArn = Maybe Text
a} :: CreateDelegationRequest)

instance Core.FromJSON CreateDelegationRequest where
  parseJSON :: Value -> Parser CreateDelegationRequest
parseJSON =
    String
-> (Object -> Parser CreateDelegationRequest)
-> Value
-> Parser CreateDelegationRequest
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CreateDelegationRequest"
      ( \Object
x ->
          Maybe RoleType
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> CreateDelegationRequest
CreateDelegationRequest'
            (Maybe RoleType
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> CreateDelegationRequest)
-> Parser (Maybe RoleType)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> CreateDelegationRequest)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe RoleType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"roleType")
            Parser
  (Maybe Text -> Maybe Text -> Maybe Text -> CreateDelegationRequest)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> CreateDelegationRequest)
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
"controlSetId")
            Parser (Maybe Text -> Maybe Text -> CreateDelegationRequest)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> CreateDelegationRequest)
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
"comment")
            Parser (Maybe Text -> CreateDelegationRequest)
-> Parser (Maybe Text) -> Parser CreateDelegationRequest
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
"roleArn")
      )

instance Prelude.Hashable CreateDelegationRequest

instance Prelude.NFData CreateDelegationRequest

instance Core.ToJSON CreateDelegationRequest where
  toJSON :: CreateDelegationRequest -> Value
toJSON CreateDelegationRequest' {Maybe Text
Maybe RoleType
roleArn :: Maybe Text
comment :: Maybe Text
controlSetId :: Maybe Text
roleType :: Maybe RoleType
$sel:roleArn:CreateDelegationRequest' :: CreateDelegationRequest -> Maybe Text
$sel:comment:CreateDelegationRequest' :: CreateDelegationRequest -> Maybe Text
$sel:controlSetId:CreateDelegationRequest' :: CreateDelegationRequest -> Maybe Text
$sel:roleType:CreateDelegationRequest' :: CreateDelegationRequest -> Maybe RoleType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"roleType" Text -> RoleType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (RoleType -> Pair) -> Maybe RoleType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RoleType
roleType,
            (Text
"controlSetId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
controlSetId,
            (Text
"comment" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
comment,
            (Text
"roleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
roleArn
          ]
      )