{-# 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.AddRoleToDBCluster
-- 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 Identity and Access Management (IAM) role from an Amazon
-- Aurora DB cluster. For more information, see
-- <https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Integrating.Authorizing.html Authorizing Amazon Aurora MySQL to Access Other Amazon Web Services Services on Your Behalf>
-- in the /Amazon Aurora User Guide/.
--
-- This action only applies to Aurora DB clusters.
module Amazonka.RDS.AddRoleToDBCluster
  ( -- * Creating a Request
    AddRoleToDBCluster (..),
    newAddRoleToDBCluster,

    -- * Request Lenses
    addRoleToDBCluster_featureName,
    addRoleToDBCluster_dbClusterIdentifier,
    addRoleToDBCluster_roleArn,

    -- * Destructuring the Response
    AddRoleToDBClusterResponse (..),
    newAddRoleToDBClusterResponse,
  )
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:/ 'newAddRoleToDBCluster' smart constructor.
data AddRoleToDBCluster = AddRoleToDBCluster'
  { -- | The name of the feature for the DB cluster that the IAM role is to be
    -- associated with. For the list of supported feature names, see
    -- DBEngineVersion.
    AddRoleToDBCluster -> Maybe Text
featureName :: Prelude.Maybe Prelude.Text,
    -- | The name of the DB cluster to associate the IAM role with.
    AddRoleToDBCluster -> Text
dbClusterIdentifier :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the IAM role to associate with the
    -- Aurora DB cluster, for example,
    -- @arn:aws:iam::123456789012:role\/AuroraAccessRole@.
    AddRoleToDBCluster -> Text
roleArn :: Prelude.Text
  }
  deriving (AddRoleToDBCluster -> AddRoleToDBCluster -> Bool
(AddRoleToDBCluster -> AddRoleToDBCluster -> Bool)
-> (AddRoleToDBCluster -> AddRoleToDBCluster -> Bool)
-> Eq AddRoleToDBCluster
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddRoleToDBCluster -> AddRoleToDBCluster -> Bool
$c/= :: AddRoleToDBCluster -> AddRoleToDBCluster -> Bool
== :: AddRoleToDBCluster -> AddRoleToDBCluster -> Bool
$c== :: AddRoleToDBCluster -> AddRoleToDBCluster -> Bool
Prelude.Eq, ReadPrec [AddRoleToDBCluster]
ReadPrec AddRoleToDBCluster
Int -> ReadS AddRoleToDBCluster
ReadS [AddRoleToDBCluster]
(Int -> ReadS AddRoleToDBCluster)
-> ReadS [AddRoleToDBCluster]
-> ReadPrec AddRoleToDBCluster
-> ReadPrec [AddRoleToDBCluster]
-> Read AddRoleToDBCluster
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AddRoleToDBCluster]
$creadListPrec :: ReadPrec [AddRoleToDBCluster]
readPrec :: ReadPrec AddRoleToDBCluster
$creadPrec :: ReadPrec AddRoleToDBCluster
readList :: ReadS [AddRoleToDBCluster]
$creadList :: ReadS [AddRoleToDBCluster]
readsPrec :: Int -> ReadS AddRoleToDBCluster
$creadsPrec :: Int -> ReadS AddRoleToDBCluster
Prelude.Read, Int -> AddRoleToDBCluster -> ShowS
[AddRoleToDBCluster] -> ShowS
AddRoleToDBCluster -> String
(Int -> AddRoleToDBCluster -> ShowS)
-> (AddRoleToDBCluster -> String)
-> ([AddRoleToDBCluster] -> ShowS)
-> Show AddRoleToDBCluster
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddRoleToDBCluster] -> ShowS
$cshowList :: [AddRoleToDBCluster] -> ShowS
show :: AddRoleToDBCluster -> String
$cshow :: AddRoleToDBCluster -> String
showsPrec :: Int -> AddRoleToDBCluster -> ShowS
$cshowsPrec :: Int -> AddRoleToDBCluster -> ShowS
Prelude.Show, (forall x. AddRoleToDBCluster -> Rep AddRoleToDBCluster x)
-> (forall x. Rep AddRoleToDBCluster x -> AddRoleToDBCluster)
-> Generic AddRoleToDBCluster
forall x. Rep AddRoleToDBCluster x -> AddRoleToDBCluster
forall x. AddRoleToDBCluster -> Rep AddRoleToDBCluster x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AddRoleToDBCluster x -> AddRoleToDBCluster
$cfrom :: forall x. AddRoleToDBCluster -> Rep AddRoleToDBCluster x
Prelude.Generic)

-- |
-- Create a value of 'AddRoleToDBCluster' 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:
--
-- 'featureName', 'addRoleToDBCluster_featureName' - The name of the feature for the DB cluster that the IAM role is to be
-- associated with. For the list of supported feature names, see
-- DBEngineVersion.
--
-- 'dbClusterIdentifier', 'addRoleToDBCluster_dbClusterIdentifier' - The name of the DB cluster to associate the IAM role with.
--
-- 'roleArn', 'addRoleToDBCluster_roleArn' - The Amazon Resource Name (ARN) of the IAM role to associate with the
-- Aurora DB cluster, for example,
-- @arn:aws:iam::123456789012:role\/AuroraAccessRole@.
newAddRoleToDBCluster ::
  -- | 'dbClusterIdentifier'
  Prelude.Text ->
  -- | 'roleArn'
  Prelude.Text ->
  AddRoleToDBCluster
newAddRoleToDBCluster :: Text -> Text -> AddRoleToDBCluster
newAddRoleToDBCluster Text
pDBClusterIdentifier_ Text
pRoleArn_ =
  AddRoleToDBCluster' :: Maybe Text -> Text -> Text -> AddRoleToDBCluster
AddRoleToDBCluster'
    { $sel:featureName:AddRoleToDBCluster' :: Maybe Text
featureName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:dbClusterIdentifier:AddRoleToDBCluster' :: Text
dbClusterIdentifier = Text
pDBClusterIdentifier_,
      $sel:roleArn:AddRoleToDBCluster' :: Text
roleArn = Text
pRoleArn_
    }

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

-- | The name of the DB cluster to associate the IAM role with.
addRoleToDBCluster_dbClusterIdentifier :: Lens.Lens' AddRoleToDBCluster Prelude.Text
addRoleToDBCluster_dbClusterIdentifier :: (Text -> f Text) -> AddRoleToDBCluster -> f AddRoleToDBCluster
addRoleToDBCluster_dbClusterIdentifier = (AddRoleToDBCluster -> Text)
-> (AddRoleToDBCluster -> Text -> AddRoleToDBCluster)
-> Lens AddRoleToDBCluster AddRoleToDBCluster Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddRoleToDBCluster' {Text
dbClusterIdentifier :: Text
$sel:dbClusterIdentifier:AddRoleToDBCluster' :: AddRoleToDBCluster -> Text
dbClusterIdentifier} -> Text
dbClusterIdentifier) (\s :: AddRoleToDBCluster
s@AddRoleToDBCluster' {} Text
a -> AddRoleToDBCluster
s {$sel:dbClusterIdentifier:AddRoleToDBCluster' :: Text
dbClusterIdentifier = Text
a} :: AddRoleToDBCluster)

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

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

instance Prelude.Hashable AddRoleToDBCluster

instance Prelude.NFData AddRoleToDBCluster

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

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

instance Core.ToQuery AddRoleToDBCluster where
  toQuery :: AddRoleToDBCluster -> QueryString
toQuery AddRoleToDBCluster' {Maybe Text
Text
roleArn :: Text
dbClusterIdentifier :: Text
featureName :: Maybe Text
$sel:roleArn:AddRoleToDBCluster' :: AddRoleToDBCluster -> Text
$sel:dbClusterIdentifier:AddRoleToDBCluster' :: AddRoleToDBCluster -> Text
$sel:featureName:AddRoleToDBCluster' :: AddRoleToDBCluster -> Maybe 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
"AddRoleToDBCluster" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2014-10-31" :: Prelude.ByteString),
        ByteString
"FeatureName" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
featureName,
        ByteString
"DBClusterIdentifier" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
dbClusterIdentifier,
        ByteString
"RoleArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
roleArn
      ]

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

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

instance Prelude.NFData AddRoleToDBClusterResponse