{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.AddRoleToDBInstance
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Associates an Amazon Web Services Identity and Access Management (IAM)
-- role with a DB instance.
--
-- To add a role to a DB instance, the status of the DB instance must be
-- @available@.
--
-- This command doesn\'t apply to RDS Custom.
module Amazonka.RDS.AddRoleToDBInstance
  ( -- * Creating a Request
    AddRoleToDBInstance (..),
    newAddRoleToDBInstance,

    -- * Request Lenses
    addRoleToDBInstance_dbInstanceIdentifier,
    addRoleToDBInstance_roleArn,
    addRoleToDBInstance_featureName,

    -- * Destructuring the Response
    AddRoleToDBInstanceResponse (..),
    newAddRoleToDBInstanceResponse,
  )
where

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
import Amazonka.RDS.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newAddRoleToDBInstance' smart constructor.
data AddRoleToDBInstance = AddRoleToDBInstance'
  { -- | The name of the DB instance to associate the IAM role with.
    AddRoleToDBInstance -> Text
dbInstanceIdentifier :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the IAM role to associate with the DB
    -- instance, for example @arn:aws:iam::123456789012:role\/AccessRole@.
    AddRoleToDBInstance -> Text
roleArn :: Prelude.Text,
    -- | The name of the feature for the DB instance that the IAM role is to be
    -- associated with. For information about supported feature names, see
    -- DBEngineVersion.
    AddRoleToDBInstance -> Text
featureName :: Prelude.Text
  }
  deriving (AddRoleToDBInstance -> AddRoleToDBInstance -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddRoleToDBInstance -> AddRoleToDBInstance -> Bool
$c/= :: AddRoleToDBInstance -> AddRoleToDBInstance -> Bool
== :: AddRoleToDBInstance -> AddRoleToDBInstance -> Bool
$c== :: AddRoleToDBInstance -> AddRoleToDBInstance -> Bool
Prelude.Eq, ReadPrec [AddRoleToDBInstance]
ReadPrec AddRoleToDBInstance
Int -> ReadS AddRoleToDBInstance
ReadS [AddRoleToDBInstance]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AddRoleToDBInstance]
$creadListPrec :: ReadPrec [AddRoleToDBInstance]
readPrec :: ReadPrec AddRoleToDBInstance
$creadPrec :: ReadPrec AddRoleToDBInstance
readList :: ReadS [AddRoleToDBInstance]
$creadList :: ReadS [AddRoleToDBInstance]
readsPrec :: Int -> ReadS AddRoleToDBInstance
$creadsPrec :: Int -> ReadS AddRoleToDBInstance
Prelude.Read, Int -> AddRoleToDBInstance -> ShowS
[AddRoleToDBInstance] -> ShowS
AddRoleToDBInstance -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddRoleToDBInstance] -> ShowS
$cshowList :: [AddRoleToDBInstance] -> ShowS
show :: AddRoleToDBInstance -> String
$cshow :: AddRoleToDBInstance -> String
showsPrec :: Int -> AddRoleToDBInstance -> ShowS
$cshowsPrec :: Int -> AddRoleToDBInstance -> ShowS
Prelude.Show, forall x. Rep AddRoleToDBInstance x -> AddRoleToDBInstance
forall x. AddRoleToDBInstance -> Rep AddRoleToDBInstance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AddRoleToDBInstance x -> AddRoleToDBInstance
$cfrom :: forall x. AddRoleToDBInstance -> Rep AddRoleToDBInstance x
Prelude.Generic)

-- |
-- Create a value of 'AddRoleToDBInstance' 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:
--
-- 'dbInstanceIdentifier', 'addRoleToDBInstance_dbInstanceIdentifier' - The name of the DB instance to associate the IAM role with.
--
-- 'roleArn', 'addRoleToDBInstance_roleArn' - The Amazon Resource Name (ARN) of the IAM role to associate with the DB
-- instance, for example @arn:aws:iam::123456789012:role\/AccessRole@.
--
-- 'featureName', 'addRoleToDBInstance_featureName' - The name of the feature for the DB instance that the IAM role is to be
-- associated with. For information about supported feature names, see
-- DBEngineVersion.
newAddRoleToDBInstance ::
  -- | 'dbInstanceIdentifier'
  Prelude.Text ->
  -- | 'roleArn'
  Prelude.Text ->
  -- | 'featureName'
  Prelude.Text ->
  AddRoleToDBInstance
newAddRoleToDBInstance :: Text -> Text -> Text -> AddRoleToDBInstance
newAddRoleToDBInstance
  Text
pDBInstanceIdentifier_
  Text
pRoleArn_
  Text
pFeatureName_ =
    AddRoleToDBInstance'
      { $sel:dbInstanceIdentifier:AddRoleToDBInstance' :: Text
dbInstanceIdentifier =
          Text
pDBInstanceIdentifier_,
        $sel:roleArn:AddRoleToDBInstance' :: Text
roleArn = Text
pRoleArn_,
        $sel:featureName:AddRoleToDBInstance' :: Text
featureName = Text
pFeatureName_
      }

-- | The name of the DB instance to associate the IAM role with.
addRoleToDBInstance_dbInstanceIdentifier :: Lens.Lens' AddRoleToDBInstance Prelude.Text
addRoleToDBInstance_dbInstanceIdentifier :: Lens' AddRoleToDBInstance Text
addRoleToDBInstance_dbInstanceIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddRoleToDBInstance' {Text
dbInstanceIdentifier :: Text
$sel:dbInstanceIdentifier:AddRoleToDBInstance' :: AddRoleToDBInstance -> Text
dbInstanceIdentifier} -> Text
dbInstanceIdentifier) (\s :: AddRoleToDBInstance
s@AddRoleToDBInstance' {} Text
a -> AddRoleToDBInstance
s {$sel:dbInstanceIdentifier:AddRoleToDBInstance' :: Text
dbInstanceIdentifier = Text
a} :: AddRoleToDBInstance)

-- | The Amazon Resource Name (ARN) of the IAM role to associate with the DB
-- instance, for example @arn:aws:iam::123456789012:role\/AccessRole@.
addRoleToDBInstance_roleArn :: Lens.Lens' AddRoleToDBInstance Prelude.Text
addRoleToDBInstance_roleArn :: Lens' AddRoleToDBInstance Text
addRoleToDBInstance_roleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddRoleToDBInstance' {Text
roleArn :: Text
$sel:roleArn:AddRoleToDBInstance' :: AddRoleToDBInstance -> Text
roleArn} -> Text
roleArn) (\s :: AddRoleToDBInstance
s@AddRoleToDBInstance' {} Text
a -> AddRoleToDBInstance
s {$sel:roleArn:AddRoleToDBInstance' :: Text
roleArn = Text
a} :: AddRoleToDBInstance)

-- | The name of the feature for the DB instance that the IAM role is to be
-- associated with. For information about supported feature names, see
-- DBEngineVersion.
addRoleToDBInstance_featureName :: Lens.Lens' AddRoleToDBInstance Prelude.Text
addRoleToDBInstance_featureName :: Lens' AddRoleToDBInstance Text
addRoleToDBInstance_featureName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddRoleToDBInstance' {Text
featureName :: Text
$sel:featureName:AddRoleToDBInstance' :: AddRoleToDBInstance -> Text
featureName} -> Text
featureName) (\s :: AddRoleToDBInstance
s@AddRoleToDBInstance' {} Text
a -> AddRoleToDBInstance
s {$sel:featureName:AddRoleToDBInstance' :: Text
featureName = Text
a} :: AddRoleToDBInstance)

instance Core.AWSRequest AddRoleToDBInstance where
  type
    AWSResponse AddRoleToDBInstance =
      AddRoleToDBInstanceResponse
  request :: (Service -> Service)
-> AddRoleToDBInstance -> Request AddRoleToDBInstance
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy AddRoleToDBInstance
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AddRoleToDBInstance)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AddRoleToDBInstanceResponse
AddRoleToDBInstanceResponse'

instance Prelude.Hashable AddRoleToDBInstance where
  hashWithSalt :: Int -> AddRoleToDBInstance -> Int
hashWithSalt Int
_salt AddRoleToDBInstance' {Text
featureName :: Text
roleArn :: Text
dbInstanceIdentifier :: Text
$sel:featureName:AddRoleToDBInstance' :: AddRoleToDBInstance -> Text
$sel:roleArn:AddRoleToDBInstance' :: AddRoleToDBInstance -> Text
$sel:dbInstanceIdentifier:AddRoleToDBInstance' :: AddRoleToDBInstance -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
dbInstanceIdentifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
roleArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
featureName

instance Prelude.NFData AddRoleToDBInstance where
  rnf :: AddRoleToDBInstance -> ()
rnf AddRoleToDBInstance' {Text
featureName :: Text
roleArn :: Text
dbInstanceIdentifier :: Text
$sel:featureName:AddRoleToDBInstance' :: AddRoleToDBInstance -> Text
$sel:roleArn:AddRoleToDBInstance' :: AddRoleToDBInstance -> Text
$sel:dbInstanceIdentifier:AddRoleToDBInstance' :: AddRoleToDBInstance -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
dbInstanceIdentifier
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
roleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
featureName

instance Data.ToHeaders AddRoleToDBInstance where
  toHeaders :: AddRoleToDBInstance -> [Header]
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath AddRoleToDBInstance where
  toPath :: AddRoleToDBInstance -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery AddRoleToDBInstance where
  toQuery :: AddRoleToDBInstance -> QueryString
toQuery AddRoleToDBInstance' {Text
featureName :: Text
roleArn :: Text
dbInstanceIdentifier :: Text
$sel:featureName:AddRoleToDBInstance' :: AddRoleToDBInstance -> Text
$sel:roleArn:AddRoleToDBInstance' :: AddRoleToDBInstance -> Text
$sel:dbInstanceIdentifier:AddRoleToDBInstance' :: AddRoleToDBInstance -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"AddRoleToDBInstance" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2014-10-31" :: Prelude.ByteString),
        ByteString
"DBInstanceIdentifier" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
dbInstanceIdentifier,
        ByteString
"RoleArn" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
roleArn,
        ByteString
"FeatureName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
featureName
      ]

-- | /See:/ 'newAddRoleToDBInstanceResponse' smart constructor.
data AddRoleToDBInstanceResponse = AddRoleToDBInstanceResponse'
  {
  }
  deriving (AddRoleToDBInstanceResponse -> AddRoleToDBInstanceResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddRoleToDBInstanceResponse -> AddRoleToDBInstanceResponse -> Bool
$c/= :: AddRoleToDBInstanceResponse -> AddRoleToDBInstanceResponse -> Bool
== :: AddRoleToDBInstanceResponse -> AddRoleToDBInstanceResponse -> Bool
$c== :: AddRoleToDBInstanceResponse -> AddRoleToDBInstanceResponse -> Bool
Prelude.Eq, ReadPrec [AddRoleToDBInstanceResponse]
ReadPrec AddRoleToDBInstanceResponse
Int -> ReadS AddRoleToDBInstanceResponse
ReadS [AddRoleToDBInstanceResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AddRoleToDBInstanceResponse]
$creadListPrec :: ReadPrec [AddRoleToDBInstanceResponse]
readPrec :: ReadPrec AddRoleToDBInstanceResponse
$creadPrec :: ReadPrec AddRoleToDBInstanceResponse
readList :: ReadS [AddRoleToDBInstanceResponse]
$creadList :: ReadS [AddRoleToDBInstanceResponse]
readsPrec :: Int -> ReadS AddRoleToDBInstanceResponse
$creadsPrec :: Int -> ReadS AddRoleToDBInstanceResponse
Prelude.Read, Int -> AddRoleToDBInstanceResponse -> ShowS
[AddRoleToDBInstanceResponse] -> ShowS
AddRoleToDBInstanceResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddRoleToDBInstanceResponse] -> ShowS
$cshowList :: [AddRoleToDBInstanceResponse] -> ShowS
show :: AddRoleToDBInstanceResponse -> String
$cshow :: AddRoleToDBInstanceResponse -> String
showsPrec :: Int -> AddRoleToDBInstanceResponse -> ShowS
$cshowsPrec :: Int -> AddRoleToDBInstanceResponse -> ShowS
Prelude.Show, forall x.
Rep AddRoleToDBInstanceResponse x -> AddRoleToDBInstanceResponse
forall x.
AddRoleToDBInstanceResponse -> Rep AddRoleToDBInstanceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AddRoleToDBInstanceResponse x -> AddRoleToDBInstanceResponse
$cfrom :: forall x.
AddRoleToDBInstanceResponse -> Rep AddRoleToDBInstanceResponse x
Prelude.Generic)

-- |
-- Create a value of 'AddRoleToDBInstanceResponse' 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.
newAddRoleToDBInstanceResponse ::
  AddRoleToDBInstanceResponse
newAddRoleToDBInstanceResponse :: AddRoleToDBInstanceResponse
newAddRoleToDBInstanceResponse =
  AddRoleToDBInstanceResponse
AddRoleToDBInstanceResponse'

instance Prelude.NFData AddRoleToDBInstanceResponse where
  rnf :: AddRoleToDBInstanceResponse -> ()
rnf AddRoleToDBInstanceResponse
_ = ()