{-# 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.RDS.Types.DBInstanceRole
-- 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.RDS.Types.DBInstanceRole where

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

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

-- |
-- Create a value of 'DBInstanceRole' 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', 'dbInstanceRole_status' - Describes the state of association between the IAM role and the DB
-- instance. The Status property returns one of the following values:
--
-- -   @ACTIVE@ - the IAM role ARN is associated with the DB instance and
--     can be used to access other Amazon Web Services services on your
--     behalf.
--
-- -   @PENDING@ - the IAM role ARN is being associated with the DB
--     instance.
--
-- -   @INVALID@ - the IAM role ARN is associated with the DB instance, but
--     the DB instance is unable to assume the IAM role in order to access
--     other Amazon Web Services services on your behalf.
--
-- 'featureName', 'dbInstanceRole_featureName' - The name of the feature associated with the Amazon Web Services Identity
-- and Access Management (IAM) role. For the list of supported feature
-- names, see @DBEngineVersion@.
--
-- 'roleArn', 'dbInstanceRole_roleArn' - The Amazon Resource Name (ARN) of the IAM role that is associated with
-- the DB instance.
newDBInstanceRole ::
  DBInstanceRole
newDBInstanceRole :: DBInstanceRole
newDBInstanceRole =
  DBInstanceRole' :: Maybe Text -> Maybe Text -> Maybe Text -> DBInstanceRole
DBInstanceRole'
    { $sel:status:DBInstanceRole' :: Maybe Text
status = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:featureName:DBInstanceRole' :: Maybe Text
featureName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:DBInstanceRole' :: Maybe Text
roleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

-- | The name of the feature associated with the Amazon Web Services Identity
-- and Access Management (IAM) role. For the list of supported feature
-- names, see @DBEngineVersion@.
dbInstanceRole_featureName :: Lens.Lens' DBInstanceRole (Prelude.Maybe Prelude.Text)
dbInstanceRole_featureName :: (Maybe Text -> f (Maybe Text))
-> DBInstanceRole -> f DBInstanceRole
dbInstanceRole_featureName = (DBInstanceRole -> Maybe Text)
-> (DBInstanceRole -> Maybe Text -> DBInstanceRole)
-> Lens DBInstanceRole DBInstanceRole (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBInstanceRole' {Maybe Text
featureName :: Maybe Text
$sel:featureName:DBInstanceRole' :: DBInstanceRole -> Maybe Text
featureName} -> Maybe Text
featureName) (\s :: DBInstanceRole
s@DBInstanceRole' {} Maybe Text
a -> DBInstanceRole
s {$sel:featureName:DBInstanceRole' :: Maybe Text
featureName = Maybe Text
a} :: DBInstanceRole)

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

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

instance Prelude.NFData DBInstanceRole