{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | A collection of attributes that\'s used to create a delegation for an
-- assessment in Audit Manager.
--
-- /See:/ 'newCreateDelegationRequest' smart constructor.
data CreateDelegationRequest = CreateDelegationRequest'
  { -- | A comment that\'s related to the delegation request.
    CreateDelegationRequest -> Maybe Text
comment :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier for the control set.
    CreateDelegationRequest -> Maybe Text
controlSetId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the IAM role.
    CreateDelegationRequest -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text,
    -- | 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
  }
  deriving (CreateDelegationRequest -> CreateDelegationRequest -> Bool
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]
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
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. 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:
--
-- 'comment', 'createDelegationRequest_comment' - A comment that\'s related to the delegation request.
--
-- 'controlSetId', 'createDelegationRequest_controlSetId' - The unique identifier for the control set.
--
-- 'roleArn', 'createDelegationRequest_roleArn' - The Amazon Resource Name (ARN) of the IAM role.
--
-- '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@.
newCreateDelegationRequest ::
  CreateDelegationRequest
newCreateDelegationRequest :: CreateDelegationRequest
newCreateDelegationRequest =
  CreateDelegationRequest'
    { $sel:comment:CreateDelegationRequest' :: Maybe Text
comment = forall a. Maybe a
Prelude.Nothing,
      $sel:controlSetId:CreateDelegationRequest' :: Maybe Text
controlSetId = forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:CreateDelegationRequest' :: Maybe Text
roleArn = forall a. Maybe a
Prelude.Nothing,
      $sel:roleType:CreateDelegationRequest' :: Maybe RoleType
roleType = forall a. Maybe a
Prelude.Nothing
    }

-- | A comment that\'s related to the delegation request.
createDelegationRequest_comment :: Lens.Lens' CreateDelegationRequest (Prelude.Maybe Prelude.Text)
createDelegationRequest_comment :: Lens' CreateDelegationRequest (Maybe Text)
createDelegationRequest_comment = 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 unique identifier for the control set.
createDelegationRequest_controlSetId :: Lens.Lens' CreateDelegationRequest (Prelude.Maybe Prelude.Text)
createDelegationRequest_controlSetId :: Lens' CreateDelegationRequest (Maybe Text)
createDelegationRequest_controlSetId = 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)

-- | The Amazon Resource Name (ARN) of the IAM role.
createDelegationRequest_roleArn :: Lens.Lens' CreateDelegationRequest (Prelude.Maybe Prelude.Text)
createDelegationRequest_roleArn :: Lens' CreateDelegationRequest (Maybe Text)
createDelegationRequest_roleArn = 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)

-- | 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 :: Lens' CreateDelegationRequest (Maybe RoleType)
createDelegationRequest_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)

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

instance Prelude.Hashable CreateDelegationRequest where
  hashWithSalt :: Int -> CreateDelegationRequest -> Int
hashWithSalt Int
_salt CreateDelegationRequest' {Maybe Text
Maybe RoleType
roleType :: Maybe RoleType
roleArn :: Maybe Text
controlSetId :: Maybe Text
comment :: Maybe Text
$sel:roleType:CreateDelegationRequest' :: CreateDelegationRequest -> Maybe RoleType
$sel:roleArn:CreateDelegationRequest' :: CreateDelegationRequest -> Maybe Text
$sel:controlSetId:CreateDelegationRequest' :: CreateDelegationRequest -> Maybe Text
$sel:comment:CreateDelegationRequest' :: CreateDelegationRequest -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
comment
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
controlSetId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
roleArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RoleType
roleType

instance Prelude.NFData CreateDelegationRequest where
  rnf :: CreateDelegationRequest -> ()
rnf CreateDelegationRequest' {Maybe Text
Maybe RoleType
roleType :: Maybe RoleType
roleArn :: Maybe Text
controlSetId :: Maybe Text
comment :: Maybe Text
$sel:roleType:CreateDelegationRequest' :: CreateDelegationRequest -> Maybe RoleType
$sel:roleArn:CreateDelegationRequest' :: CreateDelegationRequest -> Maybe Text
$sel:controlSetId:CreateDelegationRequest' :: CreateDelegationRequest -> Maybe Text
$sel:comment:CreateDelegationRequest' :: CreateDelegationRequest -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
comment
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
controlSetId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
roleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RoleType
roleType

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