{-# 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.Redshift.Types.ClusterIamRole
-- 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.Redshift.Types.ClusterIamRole where

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

-- | An Identity and Access Management (IAM) role that can be used by the
-- associated Amazon Redshift cluster to access other Amazon Web Services
-- services.
--
-- /See:/ 'newClusterIamRole' smart constructor.
data ClusterIamRole = ClusterIamRole'
  { -- | The Amazon Resource Name (ARN) of the IAM role, for example,
    -- @arn:aws:iam::123456789012:role\/RedshiftCopyUnload@.
    ClusterIamRole -> Maybe Text
iamRoleArn :: Prelude.Maybe Prelude.Text,
    -- | A value that describes the status of the IAM role\'s association with an
    -- Amazon Redshift cluster.
    --
    -- The following are possible statuses and descriptions.
    --
    -- -   @in-sync@: The role is available for use by the cluster.
    --
    -- -   @adding@: The role is in the process of being associated with the
    --     cluster.
    --
    -- -   @removing@: The role is in the process of being disassociated with
    --     the cluster.
    ClusterIamRole -> Maybe Text
applyStatus :: Prelude.Maybe Prelude.Text
  }
  deriving (ClusterIamRole -> ClusterIamRole -> Bool
(ClusterIamRole -> ClusterIamRole -> Bool)
-> (ClusterIamRole -> ClusterIamRole -> Bool) -> Eq ClusterIamRole
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ClusterIamRole -> ClusterIamRole -> Bool
$c/= :: ClusterIamRole -> ClusterIamRole -> Bool
== :: ClusterIamRole -> ClusterIamRole -> Bool
$c== :: ClusterIamRole -> ClusterIamRole -> Bool
Prelude.Eq, ReadPrec [ClusterIamRole]
ReadPrec ClusterIamRole
Int -> ReadS ClusterIamRole
ReadS [ClusterIamRole]
(Int -> ReadS ClusterIamRole)
-> ReadS [ClusterIamRole]
-> ReadPrec ClusterIamRole
-> ReadPrec [ClusterIamRole]
-> Read ClusterIamRole
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ClusterIamRole]
$creadListPrec :: ReadPrec [ClusterIamRole]
readPrec :: ReadPrec ClusterIamRole
$creadPrec :: ReadPrec ClusterIamRole
readList :: ReadS [ClusterIamRole]
$creadList :: ReadS [ClusterIamRole]
readsPrec :: Int -> ReadS ClusterIamRole
$creadsPrec :: Int -> ReadS ClusterIamRole
Prelude.Read, Int -> ClusterIamRole -> ShowS
[ClusterIamRole] -> ShowS
ClusterIamRole -> String
(Int -> ClusterIamRole -> ShowS)
-> (ClusterIamRole -> String)
-> ([ClusterIamRole] -> ShowS)
-> Show ClusterIamRole
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ClusterIamRole] -> ShowS
$cshowList :: [ClusterIamRole] -> ShowS
show :: ClusterIamRole -> String
$cshow :: ClusterIamRole -> String
showsPrec :: Int -> ClusterIamRole -> ShowS
$cshowsPrec :: Int -> ClusterIamRole -> ShowS
Prelude.Show, (forall x. ClusterIamRole -> Rep ClusterIamRole x)
-> (forall x. Rep ClusterIamRole x -> ClusterIamRole)
-> Generic ClusterIamRole
forall x. Rep ClusterIamRole x -> ClusterIamRole
forall x. ClusterIamRole -> Rep ClusterIamRole x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ClusterIamRole x -> ClusterIamRole
$cfrom :: forall x. ClusterIamRole -> Rep ClusterIamRole x
Prelude.Generic)

-- |
-- Create a value of 'ClusterIamRole' 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:
--
-- 'iamRoleArn', 'clusterIamRole_iamRoleArn' - The Amazon Resource Name (ARN) of the IAM role, for example,
-- @arn:aws:iam::123456789012:role\/RedshiftCopyUnload@.
--
-- 'applyStatus', 'clusterIamRole_applyStatus' - A value that describes the status of the IAM role\'s association with an
-- Amazon Redshift cluster.
--
-- The following are possible statuses and descriptions.
--
-- -   @in-sync@: The role is available for use by the cluster.
--
-- -   @adding@: The role is in the process of being associated with the
--     cluster.
--
-- -   @removing@: The role is in the process of being disassociated with
--     the cluster.
newClusterIamRole ::
  ClusterIamRole
newClusterIamRole :: ClusterIamRole
newClusterIamRole =
  ClusterIamRole' :: Maybe Text -> Maybe Text -> ClusterIamRole
ClusterIamRole'
    { $sel:iamRoleArn:ClusterIamRole' :: Maybe Text
iamRoleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:applyStatus:ClusterIamRole' :: Maybe Text
applyStatus = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the IAM role, for example,
-- @arn:aws:iam::123456789012:role\/RedshiftCopyUnload@.
clusterIamRole_iamRoleArn :: Lens.Lens' ClusterIamRole (Prelude.Maybe Prelude.Text)
clusterIamRole_iamRoleArn :: (Maybe Text -> f (Maybe Text))
-> ClusterIamRole -> f ClusterIamRole
clusterIamRole_iamRoleArn = (ClusterIamRole -> Maybe Text)
-> (ClusterIamRole -> Maybe Text -> ClusterIamRole)
-> Lens ClusterIamRole ClusterIamRole (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClusterIamRole' {Maybe Text
iamRoleArn :: Maybe Text
$sel:iamRoleArn:ClusterIamRole' :: ClusterIamRole -> Maybe Text
iamRoleArn} -> Maybe Text
iamRoleArn) (\s :: ClusterIamRole
s@ClusterIamRole' {} Maybe Text
a -> ClusterIamRole
s {$sel:iamRoleArn:ClusterIamRole' :: Maybe Text
iamRoleArn = Maybe Text
a} :: ClusterIamRole)

-- | A value that describes the status of the IAM role\'s association with an
-- Amazon Redshift cluster.
--
-- The following are possible statuses and descriptions.
--
-- -   @in-sync@: The role is available for use by the cluster.
--
-- -   @adding@: The role is in the process of being associated with the
--     cluster.
--
-- -   @removing@: The role is in the process of being disassociated with
--     the cluster.
clusterIamRole_applyStatus :: Lens.Lens' ClusterIamRole (Prelude.Maybe Prelude.Text)
clusterIamRole_applyStatus :: (Maybe Text -> f (Maybe Text))
-> ClusterIamRole -> f ClusterIamRole
clusterIamRole_applyStatus = (ClusterIamRole -> Maybe Text)
-> (ClusterIamRole -> Maybe Text -> ClusterIamRole)
-> Lens ClusterIamRole ClusterIamRole (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClusterIamRole' {Maybe Text
applyStatus :: Maybe Text
$sel:applyStatus:ClusterIamRole' :: ClusterIamRole -> Maybe Text
applyStatus} -> Maybe Text
applyStatus) (\s :: ClusterIamRole
s@ClusterIamRole' {} Maybe Text
a -> ClusterIamRole
s {$sel:applyStatus:ClusterIamRole' :: Maybe Text
applyStatus = Maybe Text
a} :: ClusterIamRole)

instance Core.FromXML ClusterIamRole where
  parseXML :: [Node] -> Either String ClusterIamRole
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> ClusterIamRole
ClusterIamRole'
      (Maybe Text -> Maybe Text -> ClusterIamRole)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> ClusterIamRole)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"IamRoleArn")
      Either String (Maybe Text -> ClusterIamRole)
-> Either String (Maybe Text) -> Either String ClusterIamRole
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ApplyStatus")

instance Prelude.Hashable ClusterIamRole

instance Prelude.NFData ClusterIamRole