{-# 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.GlobalAccelerator.RemoveEndpoints
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Remove endpoints from an endpoint group.
--
-- The @RemoveEndpoints@ API operation is the recommended option for
-- removing endpoints. The alternative is to remove endpoints by updating
-- an endpoint group by using the
-- <https://docs.aws.amazon.com/global-accelerator/latest/api/API_UpdateEndpointGroup.html UpdateEndpointGroup>
-- API operation. There are two advantages to using @AddEndpoints@ to
-- remove endpoints instead:
--
-- -   It\'s more convenient, because you only need to specify the
--     endpoints that you want to remove. With the @UpdateEndpointGroup@
--     API operation, you must specify all of the endpoints in the endpoint
--     group except the ones that you want to remove from the group.
--
-- -   It\'s faster, because Global Accelerator doesn\'t need to resolve
--     any endpoints. With the @UpdateEndpointGroup@ API operation, Global
--     Accelerator must resolve all of the endpoints that remain in the
--     group.
module Amazonka.GlobalAccelerator.RemoveEndpoints
  ( -- * Creating a Request
    RemoveEndpoints (..),
    newRemoveEndpoints,

    -- * Request Lenses
    removeEndpoints_endpointIdentifiers,
    removeEndpoints_endpointGroupArn,

    -- * Destructuring the Response
    RemoveEndpointsResponse (..),
    newRemoveEndpointsResponse,
  )
where

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

-- | /See:/ 'newRemoveEndpoints' smart constructor.
data RemoveEndpoints = RemoveEndpoints'
  { -- | The identifiers of the endpoints that you want to remove.
    RemoveEndpoints -> NonEmpty EndpointIdentifier
endpointIdentifiers :: Prelude.NonEmpty EndpointIdentifier,
    -- | The Amazon Resource Name (ARN) of the endpoint group.
    RemoveEndpoints -> Text
endpointGroupArn :: Prelude.Text
  }
  deriving (RemoveEndpoints -> RemoveEndpoints -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemoveEndpoints -> RemoveEndpoints -> Bool
$c/= :: RemoveEndpoints -> RemoveEndpoints -> Bool
== :: RemoveEndpoints -> RemoveEndpoints -> Bool
$c== :: RemoveEndpoints -> RemoveEndpoints -> Bool
Prelude.Eq, ReadPrec [RemoveEndpoints]
ReadPrec RemoveEndpoints
Int -> ReadS RemoveEndpoints
ReadS [RemoveEndpoints]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemoveEndpoints]
$creadListPrec :: ReadPrec [RemoveEndpoints]
readPrec :: ReadPrec RemoveEndpoints
$creadPrec :: ReadPrec RemoveEndpoints
readList :: ReadS [RemoveEndpoints]
$creadList :: ReadS [RemoveEndpoints]
readsPrec :: Int -> ReadS RemoveEndpoints
$creadsPrec :: Int -> ReadS RemoveEndpoints
Prelude.Read, Int -> RemoveEndpoints -> ShowS
[RemoveEndpoints] -> ShowS
RemoveEndpoints -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemoveEndpoints] -> ShowS
$cshowList :: [RemoveEndpoints] -> ShowS
show :: RemoveEndpoints -> String
$cshow :: RemoveEndpoints -> String
showsPrec :: Int -> RemoveEndpoints -> ShowS
$cshowsPrec :: Int -> RemoveEndpoints -> ShowS
Prelude.Show, forall x. Rep RemoveEndpoints x -> RemoveEndpoints
forall x. RemoveEndpoints -> Rep RemoveEndpoints x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RemoveEndpoints x -> RemoveEndpoints
$cfrom :: forall x. RemoveEndpoints -> Rep RemoveEndpoints x
Prelude.Generic)

-- |
-- Create a value of 'RemoveEndpoints' 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:
--
-- 'endpointIdentifiers', 'removeEndpoints_endpointIdentifiers' - The identifiers of the endpoints that you want to remove.
--
-- 'endpointGroupArn', 'removeEndpoints_endpointGroupArn' - The Amazon Resource Name (ARN) of the endpoint group.
newRemoveEndpoints ::
  -- | 'endpointIdentifiers'
  Prelude.NonEmpty EndpointIdentifier ->
  -- | 'endpointGroupArn'
  Prelude.Text ->
  RemoveEndpoints
newRemoveEndpoints :: NonEmpty EndpointIdentifier -> Text -> RemoveEndpoints
newRemoveEndpoints
  NonEmpty EndpointIdentifier
pEndpointIdentifiers_
  Text
pEndpointGroupArn_ =
    RemoveEndpoints'
      { $sel:endpointIdentifiers:RemoveEndpoints' :: NonEmpty EndpointIdentifier
endpointIdentifiers =
          forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty EndpointIdentifier
pEndpointIdentifiers_,
        $sel:endpointGroupArn:RemoveEndpoints' :: Text
endpointGroupArn = Text
pEndpointGroupArn_
      }

-- | The identifiers of the endpoints that you want to remove.
removeEndpoints_endpointIdentifiers :: Lens.Lens' RemoveEndpoints (Prelude.NonEmpty EndpointIdentifier)
removeEndpoints_endpointIdentifiers :: Lens' RemoveEndpoints (NonEmpty EndpointIdentifier)
removeEndpoints_endpointIdentifiers = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveEndpoints' {NonEmpty EndpointIdentifier
endpointIdentifiers :: NonEmpty EndpointIdentifier
$sel:endpointIdentifiers:RemoveEndpoints' :: RemoveEndpoints -> NonEmpty EndpointIdentifier
endpointIdentifiers} -> NonEmpty EndpointIdentifier
endpointIdentifiers) (\s :: RemoveEndpoints
s@RemoveEndpoints' {} NonEmpty EndpointIdentifier
a -> RemoveEndpoints
s {$sel:endpointIdentifiers:RemoveEndpoints' :: NonEmpty EndpointIdentifier
endpointIdentifiers = NonEmpty EndpointIdentifier
a} :: RemoveEndpoints) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Resource Name (ARN) of the endpoint group.
removeEndpoints_endpointGroupArn :: Lens.Lens' RemoveEndpoints Prelude.Text
removeEndpoints_endpointGroupArn :: Lens' RemoveEndpoints Text
removeEndpoints_endpointGroupArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveEndpoints' {Text
endpointGroupArn :: Text
$sel:endpointGroupArn:RemoveEndpoints' :: RemoveEndpoints -> Text
endpointGroupArn} -> Text
endpointGroupArn) (\s :: RemoveEndpoints
s@RemoveEndpoints' {} Text
a -> RemoveEndpoints
s {$sel:endpointGroupArn:RemoveEndpoints' :: Text
endpointGroupArn = Text
a} :: RemoveEndpoints)

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

instance Prelude.Hashable RemoveEndpoints where
  hashWithSalt :: Int -> RemoveEndpoints -> Int
hashWithSalt Int
_salt RemoveEndpoints' {NonEmpty EndpointIdentifier
Text
endpointGroupArn :: Text
endpointIdentifiers :: NonEmpty EndpointIdentifier
$sel:endpointGroupArn:RemoveEndpoints' :: RemoveEndpoints -> Text
$sel:endpointIdentifiers:RemoveEndpoints' :: RemoveEndpoints -> NonEmpty EndpointIdentifier
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty EndpointIdentifier
endpointIdentifiers
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
endpointGroupArn

instance Prelude.NFData RemoveEndpoints where
  rnf :: RemoveEndpoints -> ()
rnf RemoveEndpoints' {NonEmpty EndpointIdentifier
Text
endpointGroupArn :: Text
endpointIdentifiers :: NonEmpty EndpointIdentifier
$sel:endpointGroupArn:RemoveEndpoints' :: RemoveEndpoints -> Text
$sel:endpointIdentifiers:RemoveEndpoints' :: RemoveEndpoints -> NonEmpty EndpointIdentifier
..} =
    forall a. NFData a => a -> ()
Prelude.rnf NonEmpty EndpointIdentifier
endpointIdentifiers
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
endpointGroupArn

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

instance Data.ToJSON RemoveEndpoints where
  toJSON :: RemoveEndpoints -> Value
toJSON RemoveEndpoints' {NonEmpty EndpointIdentifier
Text
endpointGroupArn :: Text
endpointIdentifiers :: NonEmpty EndpointIdentifier
$sel:endpointGroupArn:RemoveEndpoints' :: RemoveEndpoints -> Text
$sel:endpointIdentifiers:RemoveEndpoints' :: RemoveEndpoints -> NonEmpty EndpointIdentifier
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"EndpointIdentifiers" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty EndpointIdentifier
endpointIdentifiers),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"EndpointGroupArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
endpointGroupArn)
          ]
      )

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

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

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

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

instance Prelude.NFData RemoveEndpointsResponse where
  rnf :: RemoveEndpointsResponse -> ()
rnf RemoveEndpointsResponse
_ = ()