{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.DBProxyTarget
-- 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)
module Amazonka.RDS.Types.DBProxyTarget where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.RDS.Types.TargetHealth
import Amazonka.RDS.Types.TargetRole
import Amazonka.RDS.Types.TargetType

-- | Contains the details for an RDS Proxy target. It represents an RDS DB
-- instance or Aurora DB cluster that the proxy can connect to. One or more
-- targets are associated with an RDS Proxy target group.
--
-- This data type is used as a response element in the
-- @DescribeDBProxyTargets@ action.
--
-- /See:/ 'newDBProxyTarget' smart constructor.
data DBProxyTarget = DBProxyTarget'
  { -- | The Amazon Resource Name (ARN) for the RDS DB instance or Aurora DB
    -- cluster.
    DBProxyTarget -> Maybe Text
targetArn :: Prelude.Maybe Prelude.Text,
    -- | Information about the connection health of the RDS Proxy target.
    DBProxyTarget -> Maybe TargetHealth
targetHealth :: Prelude.Maybe TargetHealth,
    -- | The DB cluster identifier when the target represents an Aurora DB
    -- cluster. This field is blank when the target represents an RDS DB
    -- instance.
    DBProxyTarget -> Maybe Text
trackedClusterId :: Prelude.Maybe Prelude.Text,
    -- | A value that indicates whether the target of the proxy can be used for
    -- read\/write or read-only operations.
    DBProxyTarget -> Maybe TargetRole
role' :: Prelude.Maybe TargetRole,
    -- | The identifier representing the target. It can be the instance
    -- identifier for an RDS DB instance, or the cluster identifier for an
    -- Aurora DB cluster.
    DBProxyTarget -> Maybe Text
rdsResourceId :: Prelude.Maybe Prelude.Text,
    -- | Specifies the kind of database, such as an RDS DB instance or an Aurora
    -- DB cluster, that the target represents.
    DBProxyTarget -> Maybe TargetType
type' :: Prelude.Maybe TargetType,
    -- | The writer endpoint for the RDS DB instance or Aurora DB cluster.
    DBProxyTarget -> Maybe Text
endpoint :: Prelude.Maybe Prelude.Text,
    -- | The port that the RDS Proxy uses to connect to the target RDS DB
    -- instance or Aurora DB cluster.
    DBProxyTarget -> Maybe Int
port :: Prelude.Maybe Prelude.Int
  }
  deriving (DBProxyTarget -> DBProxyTarget -> Bool
(DBProxyTarget -> DBProxyTarget -> Bool)
-> (DBProxyTarget -> DBProxyTarget -> Bool) -> Eq DBProxyTarget
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DBProxyTarget -> DBProxyTarget -> Bool
$c/= :: DBProxyTarget -> DBProxyTarget -> Bool
== :: DBProxyTarget -> DBProxyTarget -> Bool
$c== :: DBProxyTarget -> DBProxyTarget -> Bool
Prelude.Eq, ReadPrec [DBProxyTarget]
ReadPrec DBProxyTarget
Int -> ReadS DBProxyTarget
ReadS [DBProxyTarget]
(Int -> ReadS DBProxyTarget)
-> ReadS [DBProxyTarget]
-> ReadPrec DBProxyTarget
-> ReadPrec [DBProxyTarget]
-> Read DBProxyTarget
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DBProxyTarget]
$creadListPrec :: ReadPrec [DBProxyTarget]
readPrec :: ReadPrec DBProxyTarget
$creadPrec :: ReadPrec DBProxyTarget
readList :: ReadS [DBProxyTarget]
$creadList :: ReadS [DBProxyTarget]
readsPrec :: Int -> ReadS DBProxyTarget
$creadsPrec :: Int -> ReadS DBProxyTarget
Prelude.Read, Int -> DBProxyTarget -> ShowS
[DBProxyTarget] -> ShowS
DBProxyTarget -> String
(Int -> DBProxyTarget -> ShowS)
-> (DBProxyTarget -> String)
-> ([DBProxyTarget] -> ShowS)
-> Show DBProxyTarget
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DBProxyTarget] -> ShowS
$cshowList :: [DBProxyTarget] -> ShowS
show :: DBProxyTarget -> String
$cshow :: DBProxyTarget -> String
showsPrec :: Int -> DBProxyTarget -> ShowS
$cshowsPrec :: Int -> DBProxyTarget -> ShowS
Prelude.Show, (forall x. DBProxyTarget -> Rep DBProxyTarget x)
-> (forall x. Rep DBProxyTarget x -> DBProxyTarget)
-> Generic DBProxyTarget
forall x. Rep DBProxyTarget x -> DBProxyTarget
forall x. DBProxyTarget -> Rep DBProxyTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DBProxyTarget x -> DBProxyTarget
$cfrom :: forall x. DBProxyTarget -> Rep DBProxyTarget x
Prelude.Generic)

-- |
-- Create a value of 'DBProxyTarget' 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:
--
-- 'targetArn', 'dbProxyTarget_targetArn' - The Amazon Resource Name (ARN) for the RDS DB instance or Aurora DB
-- cluster.
--
-- 'targetHealth', 'dbProxyTarget_targetHealth' - Information about the connection health of the RDS Proxy target.
--
-- 'trackedClusterId', 'dbProxyTarget_trackedClusterId' - The DB cluster identifier when the target represents an Aurora DB
-- cluster. This field is blank when the target represents an RDS DB
-- instance.
--
-- 'role'', 'dbProxyTarget_role' - A value that indicates whether the target of the proxy can be used for
-- read\/write or read-only operations.
--
-- 'rdsResourceId', 'dbProxyTarget_rdsResourceId' - The identifier representing the target. It can be the instance
-- identifier for an RDS DB instance, or the cluster identifier for an
-- Aurora DB cluster.
--
-- 'type'', 'dbProxyTarget_type' - Specifies the kind of database, such as an RDS DB instance or an Aurora
-- DB cluster, that the target represents.
--
-- 'endpoint', 'dbProxyTarget_endpoint' - The writer endpoint for the RDS DB instance or Aurora DB cluster.
--
-- 'port', 'dbProxyTarget_port' - The port that the RDS Proxy uses to connect to the target RDS DB
-- instance or Aurora DB cluster.
newDBProxyTarget ::
  DBProxyTarget
newDBProxyTarget :: DBProxyTarget
newDBProxyTarget =
  DBProxyTarget' :: Maybe Text
-> Maybe TargetHealth
-> Maybe Text
-> Maybe TargetRole
-> Maybe Text
-> Maybe TargetType
-> Maybe Text
-> Maybe Int
-> DBProxyTarget
DBProxyTarget'
    { $sel:targetArn:DBProxyTarget' :: Maybe Text
targetArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:targetHealth:DBProxyTarget' :: Maybe TargetHealth
targetHealth = Maybe TargetHealth
forall a. Maybe a
Prelude.Nothing,
      $sel:trackedClusterId:DBProxyTarget' :: Maybe Text
trackedClusterId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:role':DBProxyTarget' :: Maybe TargetRole
role' = Maybe TargetRole
forall a. Maybe a
Prelude.Nothing,
      $sel:rdsResourceId:DBProxyTarget' :: Maybe Text
rdsResourceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':DBProxyTarget' :: Maybe TargetType
type' = Maybe TargetType
forall a. Maybe a
Prelude.Nothing,
      $sel:endpoint:DBProxyTarget' :: Maybe Text
endpoint = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:port:DBProxyTarget' :: Maybe Int
port = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) for the RDS DB instance or Aurora DB
-- cluster.
dbProxyTarget_targetArn :: Lens.Lens' DBProxyTarget (Prelude.Maybe Prelude.Text)
dbProxyTarget_targetArn :: (Maybe Text -> f (Maybe Text)) -> DBProxyTarget -> f DBProxyTarget
dbProxyTarget_targetArn = (DBProxyTarget -> Maybe Text)
-> (DBProxyTarget -> Maybe Text -> DBProxyTarget)
-> Lens DBProxyTarget DBProxyTarget (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBProxyTarget' {Maybe Text
targetArn :: Maybe Text
$sel:targetArn:DBProxyTarget' :: DBProxyTarget -> Maybe Text
targetArn} -> Maybe Text
targetArn) (\s :: DBProxyTarget
s@DBProxyTarget' {} Maybe Text
a -> DBProxyTarget
s {$sel:targetArn:DBProxyTarget' :: Maybe Text
targetArn = Maybe Text
a} :: DBProxyTarget)

-- | Information about the connection health of the RDS Proxy target.
dbProxyTarget_targetHealth :: Lens.Lens' DBProxyTarget (Prelude.Maybe TargetHealth)
dbProxyTarget_targetHealth :: (Maybe TargetHealth -> f (Maybe TargetHealth))
-> DBProxyTarget -> f DBProxyTarget
dbProxyTarget_targetHealth = (DBProxyTarget -> Maybe TargetHealth)
-> (DBProxyTarget -> Maybe TargetHealth -> DBProxyTarget)
-> Lens
     DBProxyTarget
     DBProxyTarget
     (Maybe TargetHealth)
     (Maybe TargetHealth)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBProxyTarget' {Maybe TargetHealth
targetHealth :: Maybe TargetHealth
$sel:targetHealth:DBProxyTarget' :: DBProxyTarget -> Maybe TargetHealth
targetHealth} -> Maybe TargetHealth
targetHealth) (\s :: DBProxyTarget
s@DBProxyTarget' {} Maybe TargetHealth
a -> DBProxyTarget
s {$sel:targetHealth:DBProxyTarget' :: Maybe TargetHealth
targetHealth = Maybe TargetHealth
a} :: DBProxyTarget)

-- | The DB cluster identifier when the target represents an Aurora DB
-- cluster. This field is blank when the target represents an RDS DB
-- instance.
dbProxyTarget_trackedClusterId :: Lens.Lens' DBProxyTarget (Prelude.Maybe Prelude.Text)
dbProxyTarget_trackedClusterId :: (Maybe Text -> f (Maybe Text)) -> DBProxyTarget -> f DBProxyTarget
dbProxyTarget_trackedClusterId = (DBProxyTarget -> Maybe Text)
-> (DBProxyTarget -> Maybe Text -> DBProxyTarget)
-> Lens DBProxyTarget DBProxyTarget (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBProxyTarget' {Maybe Text
trackedClusterId :: Maybe Text
$sel:trackedClusterId:DBProxyTarget' :: DBProxyTarget -> Maybe Text
trackedClusterId} -> Maybe Text
trackedClusterId) (\s :: DBProxyTarget
s@DBProxyTarget' {} Maybe Text
a -> DBProxyTarget
s {$sel:trackedClusterId:DBProxyTarget' :: Maybe Text
trackedClusterId = Maybe Text
a} :: DBProxyTarget)

-- | A value that indicates whether the target of the proxy can be used for
-- read\/write or read-only operations.
dbProxyTarget_role :: Lens.Lens' DBProxyTarget (Prelude.Maybe TargetRole)
dbProxyTarget_role :: (Maybe TargetRole -> f (Maybe TargetRole))
-> DBProxyTarget -> f DBProxyTarget
dbProxyTarget_role = (DBProxyTarget -> Maybe TargetRole)
-> (DBProxyTarget -> Maybe TargetRole -> DBProxyTarget)
-> Lens
     DBProxyTarget DBProxyTarget (Maybe TargetRole) (Maybe TargetRole)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBProxyTarget' {Maybe TargetRole
role' :: Maybe TargetRole
$sel:role':DBProxyTarget' :: DBProxyTarget -> Maybe TargetRole
role'} -> Maybe TargetRole
role') (\s :: DBProxyTarget
s@DBProxyTarget' {} Maybe TargetRole
a -> DBProxyTarget
s {$sel:role':DBProxyTarget' :: Maybe TargetRole
role' = Maybe TargetRole
a} :: DBProxyTarget)

-- | The identifier representing the target. It can be the instance
-- identifier for an RDS DB instance, or the cluster identifier for an
-- Aurora DB cluster.
dbProxyTarget_rdsResourceId :: Lens.Lens' DBProxyTarget (Prelude.Maybe Prelude.Text)
dbProxyTarget_rdsResourceId :: (Maybe Text -> f (Maybe Text)) -> DBProxyTarget -> f DBProxyTarget
dbProxyTarget_rdsResourceId = (DBProxyTarget -> Maybe Text)
-> (DBProxyTarget -> Maybe Text -> DBProxyTarget)
-> Lens DBProxyTarget DBProxyTarget (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBProxyTarget' {Maybe Text
rdsResourceId :: Maybe Text
$sel:rdsResourceId:DBProxyTarget' :: DBProxyTarget -> Maybe Text
rdsResourceId} -> Maybe Text
rdsResourceId) (\s :: DBProxyTarget
s@DBProxyTarget' {} Maybe Text
a -> DBProxyTarget
s {$sel:rdsResourceId:DBProxyTarget' :: Maybe Text
rdsResourceId = Maybe Text
a} :: DBProxyTarget)

-- | Specifies the kind of database, such as an RDS DB instance or an Aurora
-- DB cluster, that the target represents.
dbProxyTarget_type :: Lens.Lens' DBProxyTarget (Prelude.Maybe TargetType)
dbProxyTarget_type :: (Maybe TargetType -> f (Maybe TargetType))
-> DBProxyTarget -> f DBProxyTarget
dbProxyTarget_type = (DBProxyTarget -> Maybe TargetType)
-> (DBProxyTarget -> Maybe TargetType -> DBProxyTarget)
-> Lens
     DBProxyTarget DBProxyTarget (Maybe TargetType) (Maybe TargetType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBProxyTarget' {Maybe TargetType
type' :: Maybe TargetType
$sel:type':DBProxyTarget' :: DBProxyTarget -> Maybe TargetType
type'} -> Maybe TargetType
type') (\s :: DBProxyTarget
s@DBProxyTarget' {} Maybe TargetType
a -> DBProxyTarget
s {$sel:type':DBProxyTarget' :: Maybe TargetType
type' = Maybe TargetType
a} :: DBProxyTarget)

-- | The writer endpoint for the RDS DB instance or Aurora DB cluster.
dbProxyTarget_endpoint :: Lens.Lens' DBProxyTarget (Prelude.Maybe Prelude.Text)
dbProxyTarget_endpoint :: (Maybe Text -> f (Maybe Text)) -> DBProxyTarget -> f DBProxyTarget
dbProxyTarget_endpoint = (DBProxyTarget -> Maybe Text)
-> (DBProxyTarget -> Maybe Text -> DBProxyTarget)
-> Lens DBProxyTarget DBProxyTarget (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBProxyTarget' {Maybe Text
endpoint :: Maybe Text
$sel:endpoint:DBProxyTarget' :: DBProxyTarget -> Maybe Text
endpoint} -> Maybe Text
endpoint) (\s :: DBProxyTarget
s@DBProxyTarget' {} Maybe Text
a -> DBProxyTarget
s {$sel:endpoint:DBProxyTarget' :: Maybe Text
endpoint = Maybe Text
a} :: DBProxyTarget)

-- | The port that the RDS Proxy uses to connect to the target RDS DB
-- instance or Aurora DB cluster.
dbProxyTarget_port :: Lens.Lens' DBProxyTarget (Prelude.Maybe Prelude.Int)
dbProxyTarget_port :: (Maybe Int -> f (Maybe Int)) -> DBProxyTarget -> f DBProxyTarget
dbProxyTarget_port = (DBProxyTarget -> Maybe Int)
-> (DBProxyTarget -> Maybe Int -> DBProxyTarget)
-> Lens DBProxyTarget DBProxyTarget (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBProxyTarget' {Maybe Int
port :: Maybe Int
$sel:port:DBProxyTarget' :: DBProxyTarget -> Maybe Int
port} -> Maybe Int
port) (\s :: DBProxyTarget
s@DBProxyTarget' {} Maybe Int
a -> DBProxyTarget
s {$sel:port:DBProxyTarget' :: Maybe Int
port = Maybe Int
a} :: DBProxyTarget)

instance Core.FromXML DBProxyTarget where
  parseXML :: [Node] -> Either String DBProxyTarget
parseXML [Node]
x =
    Maybe Text
-> Maybe TargetHealth
-> Maybe Text
-> Maybe TargetRole
-> Maybe Text
-> Maybe TargetType
-> Maybe Text
-> Maybe Int
-> DBProxyTarget
DBProxyTarget'
      (Maybe Text
 -> Maybe TargetHealth
 -> Maybe Text
 -> Maybe TargetRole
 -> Maybe Text
 -> Maybe TargetType
 -> Maybe Text
 -> Maybe Int
 -> DBProxyTarget)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe TargetHealth
      -> Maybe Text
      -> Maybe TargetRole
      -> Maybe Text
      -> Maybe TargetType
      -> Maybe Text
      -> Maybe Int
      -> DBProxyTarget)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"TargetArn")
      Either
  String
  (Maybe TargetHealth
   -> Maybe Text
   -> Maybe TargetRole
   -> Maybe Text
   -> Maybe TargetType
   -> Maybe Text
   -> Maybe Int
   -> DBProxyTarget)
-> Either String (Maybe TargetHealth)
-> Either
     String
     (Maybe Text
      -> Maybe TargetRole
      -> Maybe Text
      -> Maybe TargetType
      -> Maybe Text
      -> Maybe Int
      -> DBProxyTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe TargetHealth)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"TargetHealth")
      Either
  String
  (Maybe Text
   -> Maybe TargetRole
   -> Maybe Text
   -> Maybe TargetType
   -> Maybe Text
   -> Maybe Int
   -> DBProxyTarget)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe TargetRole
      -> Maybe Text
      -> Maybe TargetType
      -> Maybe Text
      -> Maybe Int
      -> DBProxyTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"TrackedClusterId")
      Either
  String
  (Maybe TargetRole
   -> Maybe Text
   -> Maybe TargetType
   -> Maybe Text
   -> Maybe Int
   -> DBProxyTarget)
-> Either String (Maybe TargetRole)
-> Either
     String
     (Maybe Text
      -> Maybe TargetType -> Maybe Text -> Maybe Int -> DBProxyTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe TargetRole)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Role")
      Either
  String
  (Maybe Text
   -> Maybe TargetType -> Maybe Text -> Maybe Int -> DBProxyTarget)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe TargetType -> Maybe Text -> Maybe Int -> DBProxyTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"RdsResourceId")
      Either
  String
  (Maybe TargetType -> Maybe Text -> Maybe Int -> DBProxyTarget)
-> Either String (Maybe TargetType)
-> Either String (Maybe Text -> Maybe Int -> DBProxyTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe TargetType)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Type")
      Either String (Maybe Text -> Maybe Int -> DBProxyTarget)
-> Either String (Maybe Text)
-> Either String (Maybe Int -> DBProxyTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Endpoint")
      Either String (Maybe Int -> DBProxyTarget)
-> Either String (Maybe Int) -> Either String DBProxyTarget
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Int)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Port")

instance Prelude.Hashable DBProxyTarget

instance Prelude.NFData DBProxyTarget