{-# 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.ModifyDBClusterEndpoint
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Modifies the properties of an endpoint in an Amazon Aurora DB cluster.
--
-- This action only applies to Aurora DB clusters.
module Amazonka.RDS.ModifyDBClusterEndpoint
  ( -- * Creating a Request
    ModifyDBClusterEndpoint (..),
    newModifyDBClusterEndpoint,

    -- * Request Lenses
    modifyDBClusterEndpoint_endpointType,
    modifyDBClusterEndpoint_excludedMembers,
    modifyDBClusterEndpoint_staticMembers,
    modifyDBClusterEndpoint_dbClusterEndpointIdentifier,

    -- * Destructuring the Response
    DBClusterEndpoint (..),
    newDBClusterEndpoint,

    -- * Response Lenses
    dbClusterEndpoint_customEndpointType,
    dbClusterEndpoint_dbClusterEndpointArn,
    dbClusterEndpoint_dbClusterEndpointIdentifier,
    dbClusterEndpoint_dbClusterEndpointResourceIdentifier,
    dbClusterEndpoint_dbClusterIdentifier,
    dbClusterEndpoint_endpoint,
    dbClusterEndpoint_endpointType,
    dbClusterEndpoint_excludedMembers,
    dbClusterEndpoint_staticMembers,
    dbClusterEndpoint_status,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.RDS.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newModifyDBClusterEndpoint' smart constructor.
data ModifyDBClusterEndpoint = ModifyDBClusterEndpoint'
  { -- | The type of the endpoint. One of: @READER@, @WRITER@, @ANY@.
    ModifyDBClusterEndpoint -> Maybe Text
endpointType :: Prelude.Maybe Prelude.Text,
    -- | List of DB instance identifiers that aren\'t part of the custom endpoint
    -- group. All other eligible instances are reachable through the custom
    -- endpoint. Only relevant if the list of static members is empty.
    ModifyDBClusterEndpoint -> Maybe [Text]
excludedMembers :: Prelude.Maybe [Prelude.Text],
    -- | List of DB instance identifiers that are part of the custom endpoint
    -- group.
    ModifyDBClusterEndpoint -> Maybe [Text]
staticMembers :: Prelude.Maybe [Prelude.Text],
    -- | The identifier of the endpoint to modify. This parameter is stored as a
    -- lowercase string.
    ModifyDBClusterEndpoint -> Text
dbClusterEndpointIdentifier :: Prelude.Text
  }
  deriving (ModifyDBClusterEndpoint -> ModifyDBClusterEndpoint -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModifyDBClusterEndpoint -> ModifyDBClusterEndpoint -> Bool
$c/= :: ModifyDBClusterEndpoint -> ModifyDBClusterEndpoint -> Bool
== :: ModifyDBClusterEndpoint -> ModifyDBClusterEndpoint -> Bool
$c== :: ModifyDBClusterEndpoint -> ModifyDBClusterEndpoint -> Bool
Prelude.Eq, ReadPrec [ModifyDBClusterEndpoint]
ReadPrec ModifyDBClusterEndpoint
Int -> ReadS ModifyDBClusterEndpoint
ReadS [ModifyDBClusterEndpoint]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModifyDBClusterEndpoint]
$creadListPrec :: ReadPrec [ModifyDBClusterEndpoint]
readPrec :: ReadPrec ModifyDBClusterEndpoint
$creadPrec :: ReadPrec ModifyDBClusterEndpoint
readList :: ReadS [ModifyDBClusterEndpoint]
$creadList :: ReadS [ModifyDBClusterEndpoint]
readsPrec :: Int -> ReadS ModifyDBClusterEndpoint
$creadsPrec :: Int -> ReadS ModifyDBClusterEndpoint
Prelude.Read, Int -> ModifyDBClusterEndpoint -> ShowS
[ModifyDBClusterEndpoint] -> ShowS
ModifyDBClusterEndpoint -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModifyDBClusterEndpoint] -> ShowS
$cshowList :: [ModifyDBClusterEndpoint] -> ShowS
show :: ModifyDBClusterEndpoint -> String
$cshow :: ModifyDBClusterEndpoint -> String
showsPrec :: Int -> ModifyDBClusterEndpoint -> ShowS
$cshowsPrec :: Int -> ModifyDBClusterEndpoint -> ShowS
Prelude.Show, forall x. Rep ModifyDBClusterEndpoint x -> ModifyDBClusterEndpoint
forall x. ModifyDBClusterEndpoint -> Rep ModifyDBClusterEndpoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModifyDBClusterEndpoint x -> ModifyDBClusterEndpoint
$cfrom :: forall x. ModifyDBClusterEndpoint -> Rep ModifyDBClusterEndpoint x
Prelude.Generic)

-- |
-- Create a value of 'ModifyDBClusterEndpoint' 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:
--
-- 'endpointType', 'modifyDBClusterEndpoint_endpointType' - The type of the endpoint. One of: @READER@, @WRITER@, @ANY@.
--
-- 'excludedMembers', 'modifyDBClusterEndpoint_excludedMembers' - List of DB instance identifiers that aren\'t part of the custom endpoint
-- group. All other eligible instances are reachable through the custom
-- endpoint. Only relevant if the list of static members is empty.
--
-- 'staticMembers', 'modifyDBClusterEndpoint_staticMembers' - List of DB instance identifiers that are part of the custom endpoint
-- group.
--
-- 'dbClusterEndpointIdentifier', 'modifyDBClusterEndpoint_dbClusterEndpointIdentifier' - The identifier of the endpoint to modify. This parameter is stored as a
-- lowercase string.
newModifyDBClusterEndpoint ::
  -- | 'dbClusterEndpointIdentifier'
  Prelude.Text ->
  ModifyDBClusterEndpoint
newModifyDBClusterEndpoint :: Text -> ModifyDBClusterEndpoint
newModifyDBClusterEndpoint
  Text
pDBClusterEndpointIdentifier_ =
    ModifyDBClusterEndpoint'
      { $sel:endpointType:ModifyDBClusterEndpoint' :: Maybe Text
endpointType =
          forall a. Maybe a
Prelude.Nothing,
        $sel:excludedMembers:ModifyDBClusterEndpoint' :: Maybe [Text]
excludedMembers = forall a. Maybe a
Prelude.Nothing,
        $sel:staticMembers:ModifyDBClusterEndpoint' :: Maybe [Text]
staticMembers = forall a. Maybe a
Prelude.Nothing,
        $sel:dbClusterEndpointIdentifier:ModifyDBClusterEndpoint' :: Text
dbClusterEndpointIdentifier =
          Text
pDBClusterEndpointIdentifier_
      }

-- | The type of the endpoint. One of: @READER@, @WRITER@, @ANY@.
modifyDBClusterEndpoint_endpointType :: Lens.Lens' ModifyDBClusterEndpoint (Prelude.Maybe Prelude.Text)
modifyDBClusterEndpoint_endpointType :: Lens' ModifyDBClusterEndpoint (Maybe Text)
modifyDBClusterEndpoint_endpointType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyDBClusterEndpoint' {Maybe Text
endpointType :: Maybe Text
$sel:endpointType:ModifyDBClusterEndpoint' :: ModifyDBClusterEndpoint -> Maybe Text
endpointType} -> Maybe Text
endpointType) (\s :: ModifyDBClusterEndpoint
s@ModifyDBClusterEndpoint' {} Maybe Text
a -> ModifyDBClusterEndpoint
s {$sel:endpointType:ModifyDBClusterEndpoint' :: Maybe Text
endpointType = Maybe Text
a} :: ModifyDBClusterEndpoint)

-- | List of DB instance identifiers that aren\'t part of the custom endpoint
-- group. All other eligible instances are reachable through the custom
-- endpoint. Only relevant if the list of static members is empty.
modifyDBClusterEndpoint_excludedMembers :: Lens.Lens' ModifyDBClusterEndpoint (Prelude.Maybe [Prelude.Text])
modifyDBClusterEndpoint_excludedMembers :: Lens' ModifyDBClusterEndpoint (Maybe [Text])
modifyDBClusterEndpoint_excludedMembers = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyDBClusterEndpoint' {Maybe [Text]
excludedMembers :: Maybe [Text]
$sel:excludedMembers:ModifyDBClusterEndpoint' :: ModifyDBClusterEndpoint -> Maybe [Text]
excludedMembers} -> Maybe [Text]
excludedMembers) (\s :: ModifyDBClusterEndpoint
s@ModifyDBClusterEndpoint' {} Maybe [Text]
a -> ModifyDBClusterEndpoint
s {$sel:excludedMembers:ModifyDBClusterEndpoint' :: Maybe [Text]
excludedMembers = Maybe [Text]
a} :: ModifyDBClusterEndpoint) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | List of DB instance identifiers that are part of the custom endpoint
-- group.
modifyDBClusterEndpoint_staticMembers :: Lens.Lens' ModifyDBClusterEndpoint (Prelude.Maybe [Prelude.Text])
modifyDBClusterEndpoint_staticMembers :: Lens' ModifyDBClusterEndpoint (Maybe [Text])
modifyDBClusterEndpoint_staticMembers = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyDBClusterEndpoint' {Maybe [Text]
staticMembers :: Maybe [Text]
$sel:staticMembers:ModifyDBClusterEndpoint' :: ModifyDBClusterEndpoint -> Maybe [Text]
staticMembers} -> Maybe [Text]
staticMembers) (\s :: ModifyDBClusterEndpoint
s@ModifyDBClusterEndpoint' {} Maybe [Text]
a -> ModifyDBClusterEndpoint
s {$sel:staticMembers:ModifyDBClusterEndpoint' :: Maybe [Text]
staticMembers = Maybe [Text]
a} :: ModifyDBClusterEndpoint) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The identifier of the endpoint to modify. This parameter is stored as a
-- lowercase string.
modifyDBClusterEndpoint_dbClusterEndpointIdentifier :: Lens.Lens' ModifyDBClusterEndpoint Prelude.Text
modifyDBClusterEndpoint_dbClusterEndpointIdentifier :: Lens' ModifyDBClusterEndpoint Text
modifyDBClusterEndpoint_dbClusterEndpointIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyDBClusterEndpoint' {Text
dbClusterEndpointIdentifier :: Text
$sel:dbClusterEndpointIdentifier:ModifyDBClusterEndpoint' :: ModifyDBClusterEndpoint -> Text
dbClusterEndpointIdentifier} -> Text
dbClusterEndpointIdentifier) (\s :: ModifyDBClusterEndpoint
s@ModifyDBClusterEndpoint' {} Text
a -> ModifyDBClusterEndpoint
s {$sel:dbClusterEndpointIdentifier:ModifyDBClusterEndpoint' :: Text
dbClusterEndpointIdentifier = Text
a} :: ModifyDBClusterEndpoint)

instance Core.AWSRequest ModifyDBClusterEndpoint where
  type
    AWSResponse ModifyDBClusterEndpoint =
      DBClusterEndpoint
  request :: (Service -> Service)
-> ModifyDBClusterEndpoint -> Request ModifyDBClusterEndpoint
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ModifyDBClusterEndpoint
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ModifyDBClusterEndpoint)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"ModifyDBClusterEndpointResult"
      (\Int
s ResponseHeaders
h [Node]
x -> forall a. FromXML a => [Node] -> Either String a
Data.parseXML [Node]
x)

instance Prelude.Hashable ModifyDBClusterEndpoint where
  hashWithSalt :: Int -> ModifyDBClusterEndpoint -> Int
hashWithSalt Int
_salt ModifyDBClusterEndpoint' {Maybe [Text]
Maybe Text
Text
dbClusterEndpointIdentifier :: Text
staticMembers :: Maybe [Text]
excludedMembers :: Maybe [Text]
endpointType :: Maybe Text
$sel:dbClusterEndpointIdentifier:ModifyDBClusterEndpoint' :: ModifyDBClusterEndpoint -> Text
$sel:staticMembers:ModifyDBClusterEndpoint' :: ModifyDBClusterEndpoint -> Maybe [Text]
$sel:excludedMembers:ModifyDBClusterEndpoint' :: ModifyDBClusterEndpoint -> Maybe [Text]
$sel:endpointType:ModifyDBClusterEndpoint' :: ModifyDBClusterEndpoint -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
endpointType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
excludedMembers
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
staticMembers
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
dbClusterEndpointIdentifier

instance Prelude.NFData ModifyDBClusterEndpoint where
  rnf :: ModifyDBClusterEndpoint -> ()
rnf ModifyDBClusterEndpoint' {Maybe [Text]
Maybe Text
Text
dbClusterEndpointIdentifier :: Text
staticMembers :: Maybe [Text]
excludedMembers :: Maybe [Text]
endpointType :: Maybe Text
$sel:dbClusterEndpointIdentifier:ModifyDBClusterEndpoint' :: ModifyDBClusterEndpoint -> Text
$sel:staticMembers:ModifyDBClusterEndpoint' :: ModifyDBClusterEndpoint -> Maybe [Text]
$sel:excludedMembers:ModifyDBClusterEndpoint' :: ModifyDBClusterEndpoint -> Maybe [Text]
$sel:endpointType:ModifyDBClusterEndpoint' :: ModifyDBClusterEndpoint -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
endpointType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
excludedMembers
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
staticMembers
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
dbClusterEndpointIdentifier

instance Data.ToHeaders ModifyDBClusterEndpoint where
  toHeaders :: ModifyDBClusterEndpoint -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery ModifyDBClusterEndpoint where
  toQuery :: ModifyDBClusterEndpoint -> QueryString
toQuery ModifyDBClusterEndpoint' {Maybe [Text]
Maybe Text
Text
dbClusterEndpointIdentifier :: Text
staticMembers :: Maybe [Text]
excludedMembers :: Maybe [Text]
endpointType :: Maybe Text
$sel:dbClusterEndpointIdentifier:ModifyDBClusterEndpoint' :: ModifyDBClusterEndpoint -> Text
$sel:staticMembers:ModifyDBClusterEndpoint' :: ModifyDBClusterEndpoint -> Maybe [Text]
$sel:excludedMembers:ModifyDBClusterEndpoint' :: ModifyDBClusterEndpoint -> Maybe [Text]
$sel:endpointType:ModifyDBClusterEndpoint' :: ModifyDBClusterEndpoint -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"ModifyDBClusterEndpoint" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2014-10-31" :: Prelude.ByteString),
        ByteString
"EndpointType" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
endpointType,
        ByteString
"ExcludedMembers"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            ( forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member"
                forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
excludedMembers
            ),
        ByteString
"StaticMembers"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            ( forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member"
                forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
staticMembers
            ),
        ByteString
"DBClusterEndpointIdentifier"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
dbClusterEndpointIdentifier
      ]