{-# 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.OpenSearch.DeleteOutboundConnection
-- 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)
--
-- Allows the local domain owner to delete an existing outbound
-- cross-cluster connection.
module Amazonka.OpenSearch.DeleteOutboundConnection
  ( -- * Creating a Request
    DeleteOutboundConnection (..),
    newDeleteOutboundConnection,

    -- * Request Lenses
    deleteOutboundConnection_connectionId,

    -- * Destructuring the Response
    DeleteOutboundConnectionResponse (..),
    newDeleteOutboundConnectionResponse,

    -- * Response Lenses
    deleteOutboundConnectionResponse_connection,
    deleteOutboundConnectionResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.OpenSearch.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Container for the parameters to the @ DeleteOutboundConnection @
-- operation.
--
-- /See:/ 'newDeleteOutboundConnection' smart constructor.
data DeleteOutboundConnection = DeleteOutboundConnection'
  { -- | The ID of the outbound connection you want to permanently delete.
    DeleteOutboundConnection -> Text
connectionId :: Prelude.Text
  }
  deriving (DeleteOutboundConnection -> DeleteOutboundConnection -> Bool
(DeleteOutboundConnection -> DeleteOutboundConnection -> Bool)
-> (DeleteOutboundConnection -> DeleteOutboundConnection -> Bool)
-> Eq DeleteOutboundConnection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteOutboundConnection -> DeleteOutboundConnection -> Bool
$c/= :: DeleteOutboundConnection -> DeleteOutboundConnection -> Bool
== :: DeleteOutboundConnection -> DeleteOutboundConnection -> Bool
$c== :: DeleteOutboundConnection -> DeleteOutboundConnection -> Bool
Prelude.Eq, ReadPrec [DeleteOutboundConnection]
ReadPrec DeleteOutboundConnection
Int -> ReadS DeleteOutboundConnection
ReadS [DeleteOutboundConnection]
(Int -> ReadS DeleteOutboundConnection)
-> ReadS [DeleteOutboundConnection]
-> ReadPrec DeleteOutboundConnection
-> ReadPrec [DeleteOutboundConnection]
-> Read DeleteOutboundConnection
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteOutboundConnection]
$creadListPrec :: ReadPrec [DeleteOutboundConnection]
readPrec :: ReadPrec DeleteOutboundConnection
$creadPrec :: ReadPrec DeleteOutboundConnection
readList :: ReadS [DeleteOutboundConnection]
$creadList :: ReadS [DeleteOutboundConnection]
readsPrec :: Int -> ReadS DeleteOutboundConnection
$creadsPrec :: Int -> ReadS DeleteOutboundConnection
Prelude.Read, Int -> DeleteOutboundConnection -> ShowS
[DeleteOutboundConnection] -> ShowS
DeleteOutboundConnection -> String
(Int -> DeleteOutboundConnection -> ShowS)
-> (DeleteOutboundConnection -> String)
-> ([DeleteOutboundConnection] -> ShowS)
-> Show DeleteOutboundConnection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteOutboundConnection] -> ShowS
$cshowList :: [DeleteOutboundConnection] -> ShowS
show :: DeleteOutboundConnection -> String
$cshow :: DeleteOutboundConnection -> String
showsPrec :: Int -> DeleteOutboundConnection -> ShowS
$cshowsPrec :: Int -> DeleteOutboundConnection -> ShowS
Prelude.Show, (forall x.
 DeleteOutboundConnection -> Rep DeleteOutboundConnection x)
-> (forall x.
    Rep DeleteOutboundConnection x -> DeleteOutboundConnection)
-> Generic DeleteOutboundConnection
forall x.
Rep DeleteOutboundConnection x -> DeleteOutboundConnection
forall x.
DeleteOutboundConnection -> Rep DeleteOutboundConnection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteOutboundConnection x -> DeleteOutboundConnection
$cfrom :: forall x.
DeleteOutboundConnection -> Rep DeleteOutboundConnection x
Prelude.Generic)

-- |
-- Create a value of 'DeleteOutboundConnection' 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:
--
-- 'connectionId', 'deleteOutboundConnection_connectionId' - The ID of the outbound connection you want to permanently delete.
newDeleteOutboundConnection ::
  -- | 'connectionId'
  Prelude.Text ->
  DeleteOutboundConnection
newDeleteOutboundConnection :: Text -> DeleteOutboundConnection
newDeleteOutboundConnection Text
pConnectionId_ =
  DeleteOutboundConnection' :: Text -> DeleteOutboundConnection
DeleteOutboundConnection'
    { $sel:connectionId:DeleteOutboundConnection' :: Text
connectionId =
        Text
pConnectionId_
    }

-- | The ID of the outbound connection you want to permanently delete.
deleteOutboundConnection_connectionId :: Lens.Lens' DeleteOutboundConnection Prelude.Text
deleteOutboundConnection_connectionId :: (Text -> f Text)
-> DeleteOutboundConnection -> f DeleteOutboundConnection
deleteOutboundConnection_connectionId = (DeleteOutboundConnection -> Text)
-> (DeleteOutboundConnection -> Text -> DeleteOutboundConnection)
-> Lens DeleteOutboundConnection DeleteOutboundConnection Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteOutboundConnection' {Text
connectionId :: Text
$sel:connectionId:DeleteOutboundConnection' :: DeleteOutboundConnection -> Text
connectionId} -> Text
connectionId) (\s :: DeleteOutboundConnection
s@DeleteOutboundConnection' {} Text
a -> DeleteOutboundConnection
s {$sel:connectionId:DeleteOutboundConnection' :: Text
connectionId = Text
a} :: DeleteOutboundConnection)

instance Core.AWSRequest DeleteOutboundConnection where
  type
    AWSResponse DeleteOutboundConnection =
      DeleteOutboundConnectionResponse
  request :: DeleteOutboundConnection -> Request DeleteOutboundConnection
request = Service
-> DeleteOutboundConnection -> Request DeleteOutboundConnection
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteOutboundConnection
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteOutboundConnection)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteOutboundConnection))
-> Logger
-> Service
-> Proxy DeleteOutboundConnection
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteOutboundConnection)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe OutboundConnection -> Int -> DeleteOutboundConnectionResponse
DeleteOutboundConnectionResponse'
            (Maybe OutboundConnection
 -> Int -> DeleteOutboundConnectionResponse)
-> Either String (Maybe OutboundConnection)
-> Either String (Int -> DeleteOutboundConnectionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe OutboundConnection)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Connection")
            Either String (Int -> DeleteOutboundConnectionResponse)
-> Either String Int
-> Either String DeleteOutboundConnectionResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteOutboundConnection

instance Prelude.NFData DeleteOutboundConnection

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

instance Core.ToPath DeleteOutboundConnection where
  toPath :: DeleteOutboundConnection -> ByteString
toPath DeleteOutboundConnection' {Text
connectionId :: Text
$sel:connectionId:DeleteOutboundConnection' :: DeleteOutboundConnection -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2021-01-01/opensearch/cc/outboundConnection/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
connectionId
      ]

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

-- | The result of a @ DeleteOutboundConnection @ operation. Contains details
-- about the deleted outbound connection.
--
-- /See:/ 'newDeleteOutboundConnectionResponse' smart constructor.
data DeleteOutboundConnectionResponse = DeleteOutboundConnectionResponse'
  { -- | The @ OutboundConnection @ of the deleted outbound connection.
    DeleteOutboundConnectionResponse -> Maybe OutboundConnection
connection :: Prelude.Maybe OutboundConnection,
    -- | The response's http status code.
    DeleteOutboundConnectionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteOutboundConnectionResponse
-> DeleteOutboundConnectionResponse -> Bool
(DeleteOutboundConnectionResponse
 -> DeleteOutboundConnectionResponse -> Bool)
-> (DeleteOutboundConnectionResponse
    -> DeleteOutboundConnectionResponse -> Bool)
-> Eq DeleteOutboundConnectionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteOutboundConnectionResponse
-> DeleteOutboundConnectionResponse -> Bool
$c/= :: DeleteOutboundConnectionResponse
-> DeleteOutboundConnectionResponse -> Bool
== :: DeleteOutboundConnectionResponse
-> DeleteOutboundConnectionResponse -> Bool
$c== :: DeleteOutboundConnectionResponse
-> DeleteOutboundConnectionResponse -> Bool
Prelude.Eq, ReadPrec [DeleteOutboundConnectionResponse]
ReadPrec DeleteOutboundConnectionResponse
Int -> ReadS DeleteOutboundConnectionResponse
ReadS [DeleteOutboundConnectionResponse]
(Int -> ReadS DeleteOutboundConnectionResponse)
-> ReadS [DeleteOutboundConnectionResponse]
-> ReadPrec DeleteOutboundConnectionResponse
-> ReadPrec [DeleteOutboundConnectionResponse]
-> Read DeleteOutboundConnectionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteOutboundConnectionResponse]
$creadListPrec :: ReadPrec [DeleteOutboundConnectionResponse]
readPrec :: ReadPrec DeleteOutboundConnectionResponse
$creadPrec :: ReadPrec DeleteOutboundConnectionResponse
readList :: ReadS [DeleteOutboundConnectionResponse]
$creadList :: ReadS [DeleteOutboundConnectionResponse]
readsPrec :: Int -> ReadS DeleteOutboundConnectionResponse
$creadsPrec :: Int -> ReadS DeleteOutboundConnectionResponse
Prelude.Read, Int -> DeleteOutboundConnectionResponse -> ShowS
[DeleteOutboundConnectionResponse] -> ShowS
DeleteOutboundConnectionResponse -> String
(Int -> DeleteOutboundConnectionResponse -> ShowS)
-> (DeleteOutboundConnectionResponse -> String)
-> ([DeleteOutboundConnectionResponse] -> ShowS)
-> Show DeleteOutboundConnectionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteOutboundConnectionResponse] -> ShowS
$cshowList :: [DeleteOutboundConnectionResponse] -> ShowS
show :: DeleteOutboundConnectionResponse -> String
$cshow :: DeleteOutboundConnectionResponse -> String
showsPrec :: Int -> DeleteOutboundConnectionResponse -> ShowS
$cshowsPrec :: Int -> DeleteOutboundConnectionResponse -> ShowS
Prelude.Show, (forall x.
 DeleteOutboundConnectionResponse
 -> Rep DeleteOutboundConnectionResponse x)
-> (forall x.
    Rep DeleteOutboundConnectionResponse x
    -> DeleteOutboundConnectionResponse)
-> Generic DeleteOutboundConnectionResponse
forall x.
Rep DeleteOutboundConnectionResponse x
-> DeleteOutboundConnectionResponse
forall x.
DeleteOutboundConnectionResponse
-> Rep DeleteOutboundConnectionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteOutboundConnectionResponse x
-> DeleteOutboundConnectionResponse
$cfrom :: forall x.
DeleteOutboundConnectionResponse
-> Rep DeleteOutboundConnectionResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteOutboundConnectionResponse' 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:
--
-- 'connection', 'deleteOutboundConnectionResponse_connection' - The @ OutboundConnection @ of the deleted outbound connection.
--
-- 'httpStatus', 'deleteOutboundConnectionResponse_httpStatus' - The response's http status code.
newDeleteOutboundConnectionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteOutboundConnectionResponse
newDeleteOutboundConnectionResponse :: Int -> DeleteOutboundConnectionResponse
newDeleteOutboundConnectionResponse Int
pHttpStatus_ =
  DeleteOutboundConnectionResponse' :: Maybe OutboundConnection -> Int -> DeleteOutboundConnectionResponse
DeleteOutboundConnectionResponse'
    { $sel:connection:DeleteOutboundConnectionResponse' :: Maybe OutboundConnection
connection =
        Maybe OutboundConnection
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteOutboundConnectionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The @ OutboundConnection @ of the deleted outbound connection.
deleteOutboundConnectionResponse_connection :: Lens.Lens' DeleteOutboundConnectionResponse (Prelude.Maybe OutboundConnection)
deleteOutboundConnectionResponse_connection :: (Maybe OutboundConnection -> f (Maybe OutboundConnection))
-> DeleteOutboundConnectionResponse
-> f DeleteOutboundConnectionResponse
deleteOutboundConnectionResponse_connection = (DeleteOutboundConnectionResponse -> Maybe OutboundConnection)
-> (DeleteOutboundConnectionResponse
    -> Maybe OutboundConnection -> DeleteOutboundConnectionResponse)
-> Lens
     DeleteOutboundConnectionResponse
     DeleteOutboundConnectionResponse
     (Maybe OutboundConnection)
     (Maybe OutboundConnection)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteOutboundConnectionResponse' {Maybe OutboundConnection
connection :: Maybe OutboundConnection
$sel:connection:DeleteOutboundConnectionResponse' :: DeleteOutboundConnectionResponse -> Maybe OutboundConnection
connection} -> Maybe OutboundConnection
connection) (\s :: DeleteOutboundConnectionResponse
s@DeleteOutboundConnectionResponse' {} Maybe OutboundConnection
a -> DeleteOutboundConnectionResponse
s {$sel:connection:DeleteOutboundConnectionResponse' :: Maybe OutboundConnection
connection = Maybe OutboundConnection
a} :: DeleteOutboundConnectionResponse)

-- | The response's http status code.
deleteOutboundConnectionResponse_httpStatus :: Lens.Lens' DeleteOutboundConnectionResponse Prelude.Int
deleteOutboundConnectionResponse_httpStatus :: (Int -> f Int)
-> DeleteOutboundConnectionResponse
-> f DeleteOutboundConnectionResponse
deleteOutboundConnectionResponse_httpStatus = (DeleteOutboundConnectionResponse -> Int)
-> (DeleteOutboundConnectionResponse
    -> Int -> DeleteOutboundConnectionResponse)
-> Lens
     DeleteOutboundConnectionResponse
     DeleteOutboundConnectionResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteOutboundConnectionResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteOutboundConnectionResponse' :: DeleteOutboundConnectionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DeleteOutboundConnectionResponse
s@DeleteOutboundConnectionResponse' {} Int
a -> DeleteOutboundConnectionResponse
s {$sel:httpStatus:DeleteOutboundConnectionResponse' :: Int
httpStatus = Int
a} :: DeleteOutboundConnectionResponse)

instance
  Prelude.NFData
    DeleteOutboundConnectionResponse