{-# 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-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)
--
-- 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@.
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.Lens as Lens
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 the list of supported feature names, see
    -- DBEngineVersion.
    AddRoleToDBInstance -> Text
featureName :: Prelude.Text
  }
  deriving (AddRoleToDBInstance -> AddRoleToDBInstance -> Bool
(AddRoleToDBInstance -> AddRoleToDBInstance -> Bool)
-> (AddRoleToDBInstance -> AddRoleToDBInstance -> Bool)
-> Eq AddRoleToDBInstance
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]
(Int -> ReadS AddRoleToDBInstance)
-> ReadS [AddRoleToDBInstance]
-> ReadPrec AddRoleToDBInstance
-> ReadPrec [AddRoleToDBInstance]
-> Read 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
(Int -> AddRoleToDBInstance -> ShowS)
-> (AddRoleToDBInstance -> String)
-> ([AddRoleToDBInstance] -> ShowS)
-> Show AddRoleToDBInstance
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. AddRoleToDBInstance -> Rep AddRoleToDBInstance x)
-> (forall x. Rep AddRoleToDBInstance x -> AddRoleToDBInstance)
-> Generic AddRoleToDBInstance
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 the list of 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' :: Text -> Text -> Text -> AddRoleToDBInstance
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 :: (Text -> f Text) -> AddRoleToDBInstance -> f AddRoleToDBInstance
addRoleToDBInstance_dbInstanceIdentifier = (AddRoleToDBInstance -> Text)
-> (AddRoleToDBInstance -> Text -> AddRoleToDBInstance)
-> Lens AddRoleToDBInstance AddRoleToDBInstance Text Text
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 :: (Text -> f Text) -> AddRoleToDBInstance -> f AddRoleToDBInstance
addRoleToDBInstance_roleArn = (AddRoleToDBInstance -> Text)
-> (AddRoleToDBInstance -> Text -> AddRoleToDBInstance)
-> Lens AddRoleToDBInstance AddRoleToDBInstance Text Text
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 the list of supported feature names, see
-- DBEngineVersion.
addRoleToDBInstance_featureName :: Lens.Lens' AddRoleToDBInstance Prelude.Text
addRoleToDBInstance_featureName :: (Text -> f Text) -> AddRoleToDBInstance -> f AddRoleToDBInstance
addRoleToDBInstance_featureName = (AddRoleToDBInstance -> Text)
-> (AddRoleToDBInstance -> Text -> AddRoleToDBInstance)
-> Lens AddRoleToDBInstance AddRoleToDBInstance Text Text
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 :: AddRoleToDBInstance -> Request AddRoleToDBInstance
request = Service -> AddRoleToDBInstance -> Request AddRoleToDBInstance
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy AddRoleToDBInstance
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AddRoleToDBInstance)))
response =
    AWSResponse AddRoleToDBInstance
-> Logger
-> Service
-> Proxy AddRoleToDBInstance
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AddRoleToDBInstance)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse AddRoleToDBInstance
AddRoleToDBInstanceResponse
AddRoleToDBInstanceResponse'

instance Prelude.Hashable AddRoleToDBInstance

instance Prelude.NFData AddRoleToDBInstance

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

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

instance Core.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
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"AddRoleToDBInstance" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2014-10-31" :: Prelude.ByteString),
        ByteString
"DBInstanceIdentifier" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
dbInstanceIdentifier,
        ByteString
"RoleArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
roleArn,
        ByteString
"FeatureName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
featureName
      ]

-- | /See:/ 'newAddRoleToDBInstanceResponse' smart constructor.
data AddRoleToDBInstanceResponse = AddRoleToDBInstanceResponse'
  {
  }
  deriving (AddRoleToDBInstanceResponse -> AddRoleToDBInstanceResponse -> Bool
(AddRoleToDBInstanceResponse
 -> AddRoleToDBInstanceResponse -> Bool)
-> (AddRoleToDBInstanceResponse
    -> AddRoleToDBInstanceResponse -> Bool)
-> Eq AddRoleToDBInstanceResponse
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]
(Int -> ReadS AddRoleToDBInstanceResponse)
-> ReadS [AddRoleToDBInstanceResponse]
-> ReadPrec AddRoleToDBInstanceResponse
-> ReadPrec [AddRoleToDBInstanceResponse]
-> Read 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
(Int -> AddRoleToDBInstanceResponse -> ShowS)
-> (AddRoleToDBInstanceResponse -> String)
-> ([AddRoleToDBInstanceResponse] -> ShowS)
-> Show AddRoleToDBInstanceResponse
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.
 AddRoleToDBInstanceResponse -> Rep AddRoleToDBInstanceResponse x)
-> (forall x.
    Rep AddRoleToDBInstanceResponse x -> AddRoleToDBInstanceResponse)
-> Generic AddRoleToDBInstanceResponse
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