{-# 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.DocumentDB.Types.DBClusterRole
-- 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.DocumentDB.Types.DBClusterRole where

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

-- | Describes an Identity and Access Management (IAM) role that is
-- associated with a cluster.
--
-- /See:/ 'newDBClusterRole' smart constructor.
data DBClusterRole = DBClusterRole'
  { -- | Describes the state of association between the IAMrole and the cluster.
    -- The @Status@ property returns one of the following values:
    --
    -- -   @ACTIVE@ - The IAMrole ARN is associated with the cluster and can be
    --     used to access other Amazon Web Services services on your behalf.
    --
    -- -   @PENDING@ - The IAMrole ARN is being associated with the cluster.
    --
    -- -   @INVALID@ - The IAMrole ARN is associated with the cluster, but the
    --     cluster cannot assume the IAMrole to access other Amazon Web
    --     Services services on your behalf.
    DBClusterRole -> Maybe Text
status :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the IAMrole that is associated with
    -- the DB cluster.
    DBClusterRole -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text
  }
  deriving (DBClusterRole -> DBClusterRole -> Bool
(DBClusterRole -> DBClusterRole -> Bool)
-> (DBClusterRole -> DBClusterRole -> Bool) -> Eq DBClusterRole
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DBClusterRole -> DBClusterRole -> Bool
$c/= :: DBClusterRole -> DBClusterRole -> Bool
== :: DBClusterRole -> DBClusterRole -> Bool
$c== :: DBClusterRole -> DBClusterRole -> Bool
Prelude.Eq, ReadPrec [DBClusterRole]
ReadPrec DBClusterRole
Int -> ReadS DBClusterRole
ReadS [DBClusterRole]
(Int -> ReadS DBClusterRole)
-> ReadS [DBClusterRole]
-> ReadPrec DBClusterRole
-> ReadPrec [DBClusterRole]
-> Read DBClusterRole
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DBClusterRole]
$creadListPrec :: ReadPrec [DBClusterRole]
readPrec :: ReadPrec DBClusterRole
$creadPrec :: ReadPrec DBClusterRole
readList :: ReadS [DBClusterRole]
$creadList :: ReadS [DBClusterRole]
readsPrec :: Int -> ReadS DBClusterRole
$creadsPrec :: Int -> ReadS DBClusterRole
Prelude.Read, Int -> DBClusterRole -> ShowS
[DBClusterRole] -> ShowS
DBClusterRole -> String
(Int -> DBClusterRole -> ShowS)
-> (DBClusterRole -> String)
-> ([DBClusterRole] -> ShowS)
-> Show DBClusterRole
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DBClusterRole] -> ShowS
$cshowList :: [DBClusterRole] -> ShowS
show :: DBClusterRole -> String
$cshow :: DBClusterRole -> String
showsPrec :: Int -> DBClusterRole -> ShowS
$cshowsPrec :: Int -> DBClusterRole -> ShowS
Prelude.Show, (forall x. DBClusterRole -> Rep DBClusterRole x)
-> (forall x. Rep DBClusterRole x -> DBClusterRole)
-> Generic DBClusterRole
forall x. Rep DBClusterRole x -> DBClusterRole
forall x. DBClusterRole -> Rep DBClusterRole x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DBClusterRole x -> DBClusterRole
$cfrom :: forall x. DBClusterRole -> Rep DBClusterRole x
Prelude.Generic)

-- |
-- Create a value of 'DBClusterRole' 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:
--
-- 'status', 'dbClusterRole_status' - Describes the state of association between the IAMrole and the cluster.
-- The @Status@ property returns one of the following values:
--
-- -   @ACTIVE@ - The IAMrole ARN is associated with the cluster and can be
--     used to access other Amazon Web Services services on your behalf.
--
-- -   @PENDING@ - The IAMrole ARN is being associated with the cluster.
--
-- -   @INVALID@ - The IAMrole ARN is associated with the cluster, but the
--     cluster cannot assume the IAMrole to access other Amazon Web
--     Services services on your behalf.
--
-- 'roleArn', 'dbClusterRole_roleArn' - The Amazon Resource Name (ARN) of the IAMrole that is associated with
-- the DB cluster.
newDBClusterRole ::
  DBClusterRole
newDBClusterRole :: DBClusterRole
newDBClusterRole =
  DBClusterRole' :: Maybe Text -> Maybe Text -> DBClusterRole
DBClusterRole'
    { $sel:status:DBClusterRole' :: Maybe Text
status = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:DBClusterRole' :: Maybe Text
roleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Describes the state of association between the IAMrole and the cluster.
-- The @Status@ property returns one of the following values:
--
-- -   @ACTIVE@ - The IAMrole ARN is associated with the cluster and can be
--     used to access other Amazon Web Services services on your behalf.
--
-- -   @PENDING@ - The IAMrole ARN is being associated with the cluster.
--
-- -   @INVALID@ - The IAMrole ARN is associated with the cluster, but the
--     cluster cannot assume the IAMrole to access other Amazon Web
--     Services services on your behalf.
dbClusterRole_status :: Lens.Lens' DBClusterRole (Prelude.Maybe Prelude.Text)
dbClusterRole_status :: (Maybe Text -> f (Maybe Text)) -> DBClusterRole -> f DBClusterRole
dbClusterRole_status = (DBClusterRole -> Maybe Text)
-> (DBClusterRole -> Maybe Text -> DBClusterRole)
-> Lens DBClusterRole DBClusterRole (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBClusterRole' {Maybe Text
status :: Maybe Text
$sel:status:DBClusterRole' :: DBClusterRole -> Maybe Text
status} -> Maybe Text
status) (\s :: DBClusterRole
s@DBClusterRole' {} Maybe Text
a -> DBClusterRole
s {$sel:status:DBClusterRole' :: Maybe Text
status = Maybe Text
a} :: DBClusterRole)

-- | The Amazon Resource Name (ARN) of the IAMrole that is associated with
-- the DB cluster.
dbClusterRole_roleArn :: Lens.Lens' DBClusterRole (Prelude.Maybe Prelude.Text)
dbClusterRole_roleArn :: (Maybe Text -> f (Maybe Text)) -> DBClusterRole -> f DBClusterRole
dbClusterRole_roleArn = (DBClusterRole -> Maybe Text)
-> (DBClusterRole -> Maybe Text -> DBClusterRole)
-> Lens DBClusterRole DBClusterRole (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBClusterRole' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:DBClusterRole' :: DBClusterRole -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: DBClusterRole
s@DBClusterRole' {} Maybe Text
a -> DBClusterRole
s {$sel:roleArn:DBClusterRole' :: Maybe Text
roleArn = Maybe Text
a} :: DBClusterRole)

instance Core.FromXML DBClusterRole where
  parseXML :: [Node] -> Either String DBClusterRole
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> DBClusterRole
DBClusterRole'
      (Maybe Text -> Maybe Text -> DBClusterRole)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> DBClusterRole)
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
"Status")
      Either String (Maybe Text -> DBClusterRole)
-> Either String (Maybe Text) -> Either String DBClusterRole
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
"RoleArn")

instance Prelude.Hashable DBClusterRole

instance Prelude.NFData DBClusterRole