{-# 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.RegisterRdsDbInstance
-- 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)
--
-- Registers an Amazon RDS instance with a stack.
--
-- __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.RegisterRdsDbInstance
  ( -- * Creating a Request
    RegisterRdsDbInstance (..),
    newRegisterRdsDbInstance,

    -- * Request Lenses
    registerRdsDbInstance_stackId,
    registerRdsDbInstance_rdsDbInstanceArn,
    registerRdsDbInstance_dbUser,
    registerRdsDbInstance_dbPassword,

    -- * Destructuring the Response
    RegisterRdsDbInstanceResponse (..),
    newRegisterRdsDbInstanceResponse,
  )
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:/ 'newRegisterRdsDbInstance' smart constructor.
data RegisterRdsDbInstance = RegisterRdsDbInstance'
  { -- | The stack ID.
    RegisterRdsDbInstance -> Text
stackId :: Prelude.Text,
    -- | The Amazon RDS instance\'s ARN.
    RegisterRdsDbInstance -> Text
rdsDbInstanceArn :: Prelude.Text,
    -- | The database\'s master user name.
    RegisterRdsDbInstance -> Text
dbUser :: Prelude.Text,
    -- | The database password.
    RegisterRdsDbInstance -> Text
dbPassword :: Prelude.Text
  }
  deriving (RegisterRdsDbInstance -> RegisterRdsDbInstance -> Bool
(RegisterRdsDbInstance -> RegisterRdsDbInstance -> Bool)
-> (RegisterRdsDbInstance -> RegisterRdsDbInstance -> Bool)
-> Eq RegisterRdsDbInstance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegisterRdsDbInstance -> RegisterRdsDbInstance -> Bool
$c/= :: RegisterRdsDbInstance -> RegisterRdsDbInstance -> Bool
== :: RegisterRdsDbInstance -> RegisterRdsDbInstance -> Bool
$c== :: RegisterRdsDbInstance -> RegisterRdsDbInstance -> Bool
Prelude.Eq, ReadPrec [RegisterRdsDbInstance]
ReadPrec RegisterRdsDbInstance
Int -> ReadS RegisterRdsDbInstance
ReadS [RegisterRdsDbInstance]
(Int -> ReadS RegisterRdsDbInstance)
-> ReadS [RegisterRdsDbInstance]
-> ReadPrec RegisterRdsDbInstance
-> ReadPrec [RegisterRdsDbInstance]
-> Read RegisterRdsDbInstance
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegisterRdsDbInstance]
$creadListPrec :: ReadPrec [RegisterRdsDbInstance]
readPrec :: ReadPrec RegisterRdsDbInstance
$creadPrec :: ReadPrec RegisterRdsDbInstance
readList :: ReadS [RegisterRdsDbInstance]
$creadList :: ReadS [RegisterRdsDbInstance]
readsPrec :: Int -> ReadS RegisterRdsDbInstance
$creadsPrec :: Int -> ReadS RegisterRdsDbInstance
Prelude.Read, Int -> RegisterRdsDbInstance -> ShowS
[RegisterRdsDbInstance] -> ShowS
RegisterRdsDbInstance -> String
(Int -> RegisterRdsDbInstance -> ShowS)
-> (RegisterRdsDbInstance -> String)
-> ([RegisterRdsDbInstance] -> ShowS)
-> Show RegisterRdsDbInstance
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegisterRdsDbInstance] -> ShowS
$cshowList :: [RegisterRdsDbInstance] -> ShowS
show :: RegisterRdsDbInstance -> String
$cshow :: RegisterRdsDbInstance -> String
showsPrec :: Int -> RegisterRdsDbInstance -> ShowS
$cshowsPrec :: Int -> RegisterRdsDbInstance -> ShowS
Prelude.Show, (forall x. RegisterRdsDbInstance -> Rep RegisterRdsDbInstance x)
-> (forall x. Rep RegisterRdsDbInstance x -> RegisterRdsDbInstance)
-> Generic RegisterRdsDbInstance
forall x. Rep RegisterRdsDbInstance x -> RegisterRdsDbInstance
forall x. RegisterRdsDbInstance -> Rep RegisterRdsDbInstance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RegisterRdsDbInstance x -> RegisterRdsDbInstance
$cfrom :: forall x. RegisterRdsDbInstance -> Rep RegisterRdsDbInstance x
Prelude.Generic)

-- |
-- Create a value of 'RegisterRdsDbInstance' 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:
--
-- 'stackId', 'registerRdsDbInstance_stackId' - The stack ID.
--
-- 'rdsDbInstanceArn', 'registerRdsDbInstance_rdsDbInstanceArn' - The Amazon RDS instance\'s ARN.
--
-- 'dbUser', 'registerRdsDbInstance_dbUser' - The database\'s master user name.
--
-- 'dbPassword', 'registerRdsDbInstance_dbPassword' - The database password.
newRegisterRdsDbInstance ::
  -- | 'stackId'
  Prelude.Text ->
  -- | 'rdsDbInstanceArn'
  Prelude.Text ->
  -- | 'dbUser'
  Prelude.Text ->
  -- | 'dbPassword'
  Prelude.Text ->
  RegisterRdsDbInstance
newRegisterRdsDbInstance :: Text -> Text -> Text -> Text -> RegisterRdsDbInstance
newRegisterRdsDbInstance
  Text
pStackId_
  Text
pRdsDbInstanceArn_
  Text
pDbUser_
  Text
pDbPassword_ =
    RegisterRdsDbInstance' :: Text -> Text -> Text -> Text -> RegisterRdsDbInstance
RegisterRdsDbInstance'
      { $sel:stackId:RegisterRdsDbInstance' :: Text
stackId = Text
pStackId_,
        $sel:rdsDbInstanceArn:RegisterRdsDbInstance' :: Text
rdsDbInstanceArn = Text
pRdsDbInstanceArn_,
        $sel:dbUser:RegisterRdsDbInstance' :: Text
dbUser = Text
pDbUser_,
        $sel:dbPassword:RegisterRdsDbInstance' :: Text
dbPassword = Text
pDbPassword_
      }

-- | The stack ID.
registerRdsDbInstance_stackId :: Lens.Lens' RegisterRdsDbInstance Prelude.Text
registerRdsDbInstance_stackId :: (Text -> f Text)
-> RegisterRdsDbInstance -> f RegisterRdsDbInstance
registerRdsDbInstance_stackId = (RegisterRdsDbInstance -> Text)
-> (RegisterRdsDbInstance -> Text -> RegisterRdsDbInstance)
-> Lens RegisterRdsDbInstance RegisterRdsDbInstance Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterRdsDbInstance' {Text
stackId :: Text
$sel:stackId:RegisterRdsDbInstance' :: RegisterRdsDbInstance -> Text
stackId} -> Text
stackId) (\s :: RegisterRdsDbInstance
s@RegisterRdsDbInstance' {} Text
a -> RegisterRdsDbInstance
s {$sel:stackId:RegisterRdsDbInstance' :: Text
stackId = Text
a} :: RegisterRdsDbInstance)

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

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

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

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

instance Prelude.Hashable RegisterRdsDbInstance

instance Prelude.NFData RegisterRdsDbInstance

instance Core.ToHeaders RegisterRdsDbInstance where
  toHeaders :: RegisterRdsDbInstance -> [Header]
toHeaders =
    [Header] -> RegisterRdsDbInstance -> [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.RegisterRdsDbInstance" ::
                          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 RegisterRdsDbInstance where
  toJSON :: RegisterRdsDbInstance -> Value
toJSON RegisterRdsDbInstance' {Text
dbPassword :: Text
dbUser :: Text
rdsDbInstanceArn :: Text
stackId :: Text
$sel:dbPassword:RegisterRdsDbInstance' :: RegisterRdsDbInstance -> Text
$sel:dbUser:RegisterRdsDbInstance' :: RegisterRdsDbInstance -> Text
$sel:rdsDbInstanceArn:RegisterRdsDbInstance' :: RegisterRdsDbInstance -> Text
$sel:stackId:RegisterRdsDbInstance' :: RegisterRdsDbInstance -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"StackId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
stackId),
            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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DbUser" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
dbUser),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DbPassword" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
dbPassword)
          ]
      )

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

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

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

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

instance Prelude.NFData RegisterRdsDbInstanceResponse