{-# 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-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)
--
-- 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_staticMembers,
    modifyDBClusterEndpoint_endpointType,
    modifyDBClusterEndpoint_excludedMembers,
    modifyDBClusterEndpoint_dbClusterEndpointIdentifier,

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

    -- * Response Lenses
    dbClusterEndpoint_status,
    dbClusterEndpoint_dbClusterIdentifier,
    dbClusterEndpoint_dbClusterEndpointArn,
    dbClusterEndpoint_customEndpointType,
    dbClusterEndpoint_staticMembers,
    dbClusterEndpoint_endpointType,
    dbClusterEndpoint_dbClusterEndpointIdentifier,
    dbClusterEndpoint_endpoint,
    dbClusterEndpoint_dbClusterEndpointResourceIdentifier,
    dbClusterEndpoint_excludedMembers,
  )
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:/ 'newModifyDBClusterEndpoint' smart constructor.
data ModifyDBClusterEndpoint = ModifyDBClusterEndpoint'
  { -- | List of DB instance identifiers that are part of the custom endpoint
    -- group.
    ModifyDBClusterEndpoint -> Maybe [Text]
staticMembers :: Prelude.Maybe [Prelude.Text],
    -- | 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],
    -- | The identifier of the endpoint to modify. This parameter is stored as a
    -- lowercase string.
    ModifyDBClusterEndpoint -> Text
dbClusterEndpointIdentifier :: Prelude.Text
  }
  deriving (ModifyDBClusterEndpoint -> ModifyDBClusterEndpoint -> Bool
(ModifyDBClusterEndpoint -> ModifyDBClusterEndpoint -> Bool)
-> (ModifyDBClusterEndpoint -> ModifyDBClusterEndpoint -> Bool)
-> Eq ModifyDBClusterEndpoint
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]
(Int -> ReadS ModifyDBClusterEndpoint)
-> ReadS [ModifyDBClusterEndpoint]
-> ReadPrec ModifyDBClusterEndpoint
-> ReadPrec [ModifyDBClusterEndpoint]
-> Read 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
(Int -> ModifyDBClusterEndpoint -> ShowS)
-> (ModifyDBClusterEndpoint -> String)
-> ([ModifyDBClusterEndpoint] -> ShowS)
-> Show ModifyDBClusterEndpoint
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.
 ModifyDBClusterEndpoint -> Rep ModifyDBClusterEndpoint x)
-> (forall x.
    Rep ModifyDBClusterEndpoint x -> ModifyDBClusterEndpoint)
-> Generic ModifyDBClusterEndpoint
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:
--
-- 'staticMembers', 'modifyDBClusterEndpoint_staticMembers' - List of DB instance identifiers that are part of the custom endpoint
-- group.
--
-- '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.
--
-- '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' :: Maybe [Text]
-> Maybe Text -> Maybe [Text] -> Text -> ModifyDBClusterEndpoint
ModifyDBClusterEndpoint'
      { $sel:staticMembers:ModifyDBClusterEndpoint' :: Maybe [Text]
staticMembers =
          Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:endpointType:ModifyDBClusterEndpoint' :: Maybe Text
endpointType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:excludedMembers:ModifyDBClusterEndpoint' :: Maybe [Text]
excludedMembers = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:dbClusterEndpointIdentifier:ModifyDBClusterEndpoint' :: Text
dbClusterEndpointIdentifier =
          Text
pDBClusterEndpointIdentifier_
      }

-- | List of DB instance identifiers that are part of the custom endpoint
-- group.
modifyDBClusterEndpoint_staticMembers :: Lens.Lens' ModifyDBClusterEndpoint (Prelude.Maybe [Prelude.Text])
modifyDBClusterEndpoint_staticMembers :: (Maybe [Text] -> f (Maybe [Text]))
-> ModifyDBClusterEndpoint -> f ModifyDBClusterEndpoint
modifyDBClusterEndpoint_staticMembers = (ModifyDBClusterEndpoint -> Maybe [Text])
-> (ModifyDBClusterEndpoint
    -> Maybe [Text] -> ModifyDBClusterEndpoint)
-> Lens
     ModifyDBClusterEndpoint
     ModifyDBClusterEndpoint
     (Maybe [Text])
     (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> ModifyDBClusterEndpoint -> f ModifyDBClusterEndpoint)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ModifyDBClusterEndpoint
-> f ModifyDBClusterEndpoint
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The type of the endpoint. One of: @READER@, @WRITER@, @ANY@.
modifyDBClusterEndpoint_endpointType :: Lens.Lens' ModifyDBClusterEndpoint (Prelude.Maybe Prelude.Text)
modifyDBClusterEndpoint_endpointType :: (Maybe Text -> f (Maybe Text))
-> ModifyDBClusterEndpoint -> f ModifyDBClusterEndpoint
modifyDBClusterEndpoint_endpointType = (ModifyDBClusterEndpoint -> Maybe Text)
-> (ModifyDBClusterEndpoint
    -> Maybe Text -> ModifyDBClusterEndpoint)
-> Lens
     ModifyDBClusterEndpoint
     ModifyDBClusterEndpoint
     (Maybe Text)
     (Maybe Text)
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 :: (Maybe [Text] -> f (Maybe [Text]))
-> ModifyDBClusterEndpoint -> f ModifyDBClusterEndpoint
modifyDBClusterEndpoint_excludedMembers = (ModifyDBClusterEndpoint -> Maybe [Text])
-> (ModifyDBClusterEndpoint
    -> Maybe [Text] -> ModifyDBClusterEndpoint)
-> Lens
     ModifyDBClusterEndpoint
     ModifyDBClusterEndpoint
     (Maybe [Text])
     (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> ModifyDBClusterEndpoint -> f ModifyDBClusterEndpoint)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ModifyDBClusterEndpoint
-> f ModifyDBClusterEndpoint
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
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 :: (Text -> f Text)
-> ModifyDBClusterEndpoint -> f ModifyDBClusterEndpoint
modifyDBClusterEndpoint_dbClusterEndpointIdentifier = (ModifyDBClusterEndpoint -> Text)
-> (ModifyDBClusterEndpoint -> Text -> ModifyDBClusterEndpoint)
-> Lens ModifyDBClusterEndpoint ModifyDBClusterEndpoint Text Text
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 :: ModifyDBClusterEndpoint -> Request ModifyDBClusterEndpoint
request = Service
-> ModifyDBClusterEndpoint -> Request ModifyDBClusterEndpoint
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy ModifyDBClusterEndpoint
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ModifyDBClusterEndpoint)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse ModifyDBClusterEndpoint))
-> Logger
-> Service
-> Proxy ModifyDBClusterEndpoint
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ModifyDBClusterEndpoint)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"ModifyDBClusterEndpointResult"
      (\Int
s ResponseHeaders
h [Node]
x -> [Node] -> Either String DBClusterEndpoint
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)

instance Prelude.Hashable ModifyDBClusterEndpoint

instance Prelude.NFData ModifyDBClusterEndpoint

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

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

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