{-# 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.OpsWorks.UpdateRdsDbInstance
-- 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)
--
-- Updates an Amazon RDS instance.
--
-- __Required Permissions__: To use this action, an IAM user must have a
-- Manage permissions level for the stack, or an attached policy that
-- explicitly grants permissions. For more information on user permissions,
-- see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/opsworks-security-users.html Managing User Permissions>.
module Amazonka.OpsWorks.UpdateRdsDbInstance
  ( -- * Creating a Request
    UpdateRdsDbInstance (..),
    newUpdateRdsDbInstance,

    -- * Request Lenses
    updateRdsDbInstance_dbUser,
    updateRdsDbInstance_dbPassword,
    updateRdsDbInstance_rdsDbInstanceArn,

    -- * Destructuring the Response
    UpdateRdsDbInstanceResponse (..),
    newUpdateRdsDbInstanceResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.OpsWorks.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateRdsDbInstance' smart constructor.
data UpdateRdsDbInstance = UpdateRdsDbInstance'
  { -- | The master user name.
    UpdateRdsDbInstance -> Maybe Text
dbUser :: Prelude.Maybe Prelude.Text,
    -- | The database password.
    UpdateRdsDbInstance -> Maybe Text
dbPassword :: Prelude.Maybe Prelude.Text,
    -- | The Amazon RDS instance\'s ARN.
    UpdateRdsDbInstance -> Text
rdsDbInstanceArn :: Prelude.Text
  }
  deriving (UpdateRdsDbInstance -> UpdateRdsDbInstance -> Bool
(UpdateRdsDbInstance -> UpdateRdsDbInstance -> Bool)
-> (UpdateRdsDbInstance -> UpdateRdsDbInstance -> Bool)
-> Eq UpdateRdsDbInstance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateRdsDbInstance -> UpdateRdsDbInstance -> Bool
$c/= :: UpdateRdsDbInstance -> UpdateRdsDbInstance -> Bool
== :: UpdateRdsDbInstance -> UpdateRdsDbInstance -> Bool
$c== :: UpdateRdsDbInstance -> UpdateRdsDbInstance -> Bool
Prelude.Eq, ReadPrec [UpdateRdsDbInstance]
ReadPrec UpdateRdsDbInstance
Int -> ReadS UpdateRdsDbInstance
ReadS [UpdateRdsDbInstance]
(Int -> ReadS UpdateRdsDbInstance)
-> ReadS [UpdateRdsDbInstance]
-> ReadPrec UpdateRdsDbInstance
-> ReadPrec [UpdateRdsDbInstance]
-> Read UpdateRdsDbInstance
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateRdsDbInstance]
$creadListPrec :: ReadPrec [UpdateRdsDbInstance]
readPrec :: ReadPrec UpdateRdsDbInstance
$creadPrec :: ReadPrec UpdateRdsDbInstance
readList :: ReadS [UpdateRdsDbInstance]
$creadList :: ReadS [UpdateRdsDbInstance]
readsPrec :: Int -> ReadS UpdateRdsDbInstance
$creadsPrec :: Int -> ReadS UpdateRdsDbInstance
Prelude.Read, Int -> UpdateRdsDbInstance -> ShowS
[UpdateRdsDbInstance] -> ShowS
UpdateRdsDbInstance -> String
(Int -> UpdateRdsDbInstance -> ShowS)
-> (UpdateRdsDbInstance -> String)
-> ([UpdateRdsDbInstance] -> ShowS)
-> Show UpdateRdsDbInstance
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateRdsDbInstance] -> ShowS
$cshowList :: [UpdateRdsDbInstance] -> ShowS
show :: UpdateRdsDbInstance -> String
$cshow :: UpdateRdsDbInstance -> String
showsPrec :: Int -> UpdateRdsDbInstance -> ShowS
$cshowsPrec :: Int -> UpdateRdsDbInstance -> ShowS
Prelude.Show, (forall x. UpdateRdsDbInstance -> Rep UpdateRdsDbInstance x)
-> (forall x. Rep UpdateRdsDbInstance x -> UpdateRdsDbInstance)
-> Generic UpdateRdsDbInstance
forall x. Rep UpdateRdsDbInstance x -> UpdateRdsDbInstance
forall x. UpdateRdsDbInstance -> Rep UpdateRdsDbInstance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateRdsDbInstance x -> UpdateRdsDbInstance
$cfrom :: forall x. UpdateRdsDbInstance -> Rep UpdateRdsDbInstance x
Prelude.Generic)

-- |
-- Create a value of 'UpdateRdsDbInstance' 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:
--
-- 'dbUser', 'updateRdsDbInstance_dbUser' - The master user name.
--
-- 'dbPassword', 'updateRdsDbInstance_dbPassword' - The database password.
--
-- 'rdsDbInstanceArn', 'updateRdsDbInstance_rdsDbInstanceArn' - The Amazon RDS instance\'s ARN.
newUpdateRdsDbInstance ::
  -- | 'rdsDbInstanceArn'
  Prelude.Text ->
  UpdateRdsDbInstance
newUpdateRdsDbInstance :: Text -> UpdateRdsDbInstance
newUpdateRdsDbInstance Text
pRdsDbInstanceArn_ =
  UpdateRdsDbInstance' :: Maybe Text -> Maybe Text -> Text -> UpdateRdsDbInstance
UpdateRdsDbInstance'
    { $sel:dbUser:UpdateRdsDbInstance' :: Maybe Text
dbUser = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:dbPassword:UpdateRdsDbInstance' :: Maybe Text
dbPassword = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:rdsDbInstanceArn:UpdateRdsDbInstance' :: Text
rdsDbInstanceArn = Text
pRdsDbInstanceArn_
    }

-- | The master user name.
updateRdsDbInstance_dbUser :: Lens.Lens' UpdateRdsDbInstance (Prelude.Maybe Prelude.Text)
updateRdsDbInstance_dbUser :: (Maybe Text -> f (Maybe Text))
-> UpdateRdsDbInstance -> f UpdateRdsDbInstance
updateRdsDbInstance_dbUser = (UpdateRdsDbInstance -> Maybe Text)
-> (UpdateRdsDbInstance -> Maybe Text -> UpdateRdsDbInstance)
-> Lens
     UpdateRdsDbInstance UpdateRdsDbInstance (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRdsDbInstance' {Maybe Text
dbUser :: Maybe Text
$sel:dbUser:UpdateRdsDbInstance' :: UpdateRdsDbInstance -> Maybe Text
dbUser} -> Maybe Text
dbUser) (\s :: UpdateRdsDbInstance
s@UpdateRdsDbInstance' {} Maybe Text
a -> UpdateRdsDbInstance
s {$sel:dbUser:UpdateRdsDbInstance' :: Maybe Text
dbUser = Maybe Text
a} :: UpdateRdsDbInstance)

-- | The database password.
updateRdsDbInstance_dbPassword :: Lens.Lens' UpdateRdsDbInstance (Prelude.Maybe Prelude.Text)
updateRdsDbInstance_dbPassword :: (Maybe Text -> f (Maybe Text))
-> UpdateRdsDbInstance -> f UpdateRdsDbInstance
updateRdsDbInstance_dbPassword = (UpdateRdsDbInstance -> Maybe Text)
-> (UpdateRdsDbInstance -> Maybe Text -> UpdateRdsDbInstance)
-> Lens
     UpdateRdsDbInstance UpdateRdsDbInstance (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRdsDbInstance' {Maybe Text
dbPassword :: Maybe Text
$sel:dbPassword:UpdateRdsDbInstance' :: UpdateRdsDbInstance -> Maybe Text
dbPassword} -> Maybe Text
dbPassword) (\s :: UpdateRdsDbInstance
s@UpdateRdsDbInstance' {} Maybe Text
a -> UpdateRdsDbInstance
s {$sel:dbPassword:UpdateRdsDbInstance' :: Maybe Text
dbPassword = Maybe Text
a} :: UpdateRdsDbInstance)

-- | The Amazon RDS instance\'s ARN.
updateRdsDbInstance_rdsDbInstanceArn :: Lens.Lens' UpdateRdsDbInstance Prelude.Text
updateRdsDbInstance_rdsDbInstanceArn :: (Text -> f Text) -> UpdateRdsDbInstance -> f UpdateRdsDbInstance
updateRdsDbInstance_rdsDbInstanceArn = (UpdateRdsDbInstance -> Text)
-> (UpdateRdsDbInstance -> Text -> UpdateRdsDbInstance)
-> Lens UpdateRdsDbInstance UpdateRdsDbInstance Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRdsDbInstance' {Text
rdsDbInstanceArn :: Text
$sel:rdsDbInstanceArn:UpdateRdsDbInstance' :: UpdateRdsDbInstance -> Text
rdsDbInstanceArn} -> Text
rdsDbInstanceArn) (\s :: UpdateRdsDbInstance
s@UpdateRdsDbInstance' {} Text
a -> UpdateRdsDbInstance
s {$sel:rdsDbInstanceArn:UpdateRdsDbInstance' :: Text
rdsDbInstanceArn = Text
a} :: UpdateRdsDbInstance)

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

instance Prelude.Hashable UpdateRdsDbInstance

instance Prelude.NFData UpdateRdsDbInstance

instance Core.ToHeaders UpdateRdsDbInstance where
  toHeaders :: UpdateRdsDbInstance -> [Header]
toHeaders =
    [Header] -> UpdateRdsDbInstance -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"OpsWorks_20130218.UpdateRdsDbInstance" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON UpdateRdsDbInstance where
  toJSON :: UpdateRdsDbInstance -> Value
toJSON UpdateRdsDbInstance' {Maybe Text
Text
rdsDbInstanceArn :: Text
dbPassword :: Maybe Text
dbUser :: Maybe Text
$sel:rdsDbInstanceArn:UpdateRdsDbInstance' :: UpdateRdsDbInstance -> Text
$sel:dbPassword:UpdateRdsDbInstance' :: UpdateRdsDbInstance -> Maybe Text
$sel:dbUser:UpdateRdsDbInstance' :: UpdateRdsDbInstance -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DbUser" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
dbUser,
            (Text
"DbPassword" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
dbPassword,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"RdsDbInstanceArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
rdsDbInstanceArn)
          ]
      )

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

instance Core.ToQuery UpdateRdsDbInstance where
  toQuery :: UpdateRdsDbInstance -> QueryString
toQuery = QueryString -> UpdateRdsDbInstance -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

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

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

instance Prelude.NFData UpdateRdsDbInstanceResponse