{-# 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.DeleteInboundConnection
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Allows the destination Amazon OpenSearch Service domain owner to delete
-- an existing inbound cross-cluster search connection. For more
-- information, see
-- <https://docs.aws.amazon.com/opensearch-service/latest/developerguide/cross-cluster-search.html Cross-cluster search for Amazon OpenSearch Service>.
module Amazonka.OpenSearch.DeleteInboundConnection
  ( -- * Creating a Request
    DeleteInboundConnection (..),
    newDeleteInboundConnection,

    -- * Request Lenses
    deleteInboundConnection_connectionId,

    -- * Destructuring the Response
    DeleteInboundConnectionResponse (..),
    newDeleteInboundConnectionResponse,

    -- * Response Lenses
    deleteInboundConnectionResponse_connection,
    deleteInboundConnectionResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 @DeleteInboundConnection@ operation.
--
-- /See:/ 'newDeleteInboundConnection' smart constructor.
data DeleteInboundConnection = DeleteInboundConnection'
  { -- | The ID of the inbound connection to permanently delete.
    DeleteInboundConnection -> Text
connectionId :: Prelude.Text
  }
  deriving (DeleteInboundConnection -> DeleteInboundConnection -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteInboundConnection -> DeleteInboundConnection -> Bool
$c/= :: DeleteInboundConnection -> DeleteInboundConnection -> Bool
== :: DeleteInboundConnection -> DeleteInboundConnection -> Bool
$c== :: DeleteInboundConnection -> DeleteInboundConnection -> Bool
Prelude.Eq, ReadPrec [DeleteInboundConnection]
ReadPrec DeleteInboundConnection
Int -> ReadS DeleteInboundConnection
ReadS [DeleteInboundConnection]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteInboundConnection]
$creadListPrec :: ReadPrec [DeleteInboundConnection]
readPrec :: ReadPrec DeleteInboundConnection
$creadPrec :: ReadPrec DeleteInboundConnection
readList :: ReadS [DeleteInboundConnection]
$creadList :: ReadS [DeleteInboundConnection]
readsPrec :: Int -> ReadS DeleteInboundConnection
$creadsPrec :: Int -> ReadS DeleteInboundConnection
Prelude.Read, Int -> DeleteInboundConnection -> ShowS
[DeleteInboundConnection] -> ShowS
DeleteInboundConnection -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteInboundConnection] -> ShowS
$cshowList :: [DeleteInboundConnection] -> ShowS
show :: DeleteInboundConnection -> String
$cshow :: DeleteInboundConnection -> String
showsPrec :: Int -> DeleteInboundConnection -> ShowS
$cshowsPrec :: Int -> DeleteInboundConnection -> ShowS
Prelude.Show, forall x. Rep DeleteInboundConnection x -> DeleteInboundConnection
forall x. DeleteInboundConnection -> Rep DeleteInboundConnection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteInboundConnection x -> DeleteInboundConnection
$cfrom :: forall x. DeleteInboundConnection -> Rep DeleteInboundConnection x
Prelude.Generic)

-- |
-- Create a value of 'DeleteInboundConnection' 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', 'deleteInboundConnection_connectionId' - The ID of the inbound connection to permanently delete.
newDeleteInboundConnection ::
  -- | 'connectionId'
  Prelude.Text ->
  DeleteInboundConnection
newDeleteInboundConnection :: Text -> DeleteInboundConnection
newDeleteInboundConnection Text
pConnectionId_ =
  DeleteInboundConnection'
    { $sel:connectionId:DeleteInboundConnection' :: Text
connectionId =
        Text
pConnectionId_
    }

-- | The ID of the inbound connection to permanently delete.
deleteInboundConnection_connectionId :: Lens.Lens' DeleteInboundConnection Prelude.Text
deleteInboundConnection_connectionId :: Lens' DeleteInboundConnection Text
deleteInboundConnection_connectionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteInboundConnection' {Text
connectionId :: Text
$sel:connectionId:DeleteInboundConnection' :: DeleteInboundConnection -> Text
connectionId} -> Text
connectionId) (\s :: DeleteInboundConnection
s@DeleteInboundConnection' {} Text
a -> DeleteInboundConnection
s {$sel:connectionId:DeleteInboundConnection' :: Text
connectionId = Text
a} :: DeleteInboundConnection)

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

instance Prelude.Hashable DeleteInboundConnection where
  hashWithSalt :: Int -> DeleteInboundConnection -> Int
hashWithSalt Int
_salt DeleteInboundConnection' {Text
connectionId :: Text
$sel:connectionId:DeleteInboundConnection' :: DeleteInboundConnection -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
connectionId

instance Prelude.NFData DeleteInboundConnection where
  rnf :: DeleteInboundConnection -> ()
rnf DeleteInboundConnection' {Text
connectionId :: Text
$sel:connectionId:DeleteInboundConnection' :: DeleteInboundConnection -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
connectionId

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

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

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

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

-- |
-- Create a value of 'DeleteInboundConnectionResponse' 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', 'deleteInboundConnectionResponse_connection' - The deleted inbound connection.
--
-- 'httpStatus', 'deleteInboundConnectionResponse_httpStatus' - The response's http status code.
newDeleteInboundConnectionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteInboundConnectionResponse
newDeleteInboundConnectionResponse :: Int -> DeleteInboundConnectionResponse
newDeleteInboundConnectionResponse Int
pHttpStatus_ =
  DeleteInboundConnectionResponse'
    { $sel:connection:DeleteInboundConnectionResponse' :: Maybe InboundConnection
connection =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteInboundConnectionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The deleted inbound connection.
deleteInboundConnectionResponse_connection :: Lens.Lens' DeleteInboundConnectionResponse (Prelude.Maybe InboundConnection)
deleteInboundConnectionResponse_connection :: Lens' DeleteInboundConnectionResponse (Maybe InboundConnection)
deleteInboundConnectionResponse_connection = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteInboundConnectionResponse' {Maybe InboundConnection
connection :: Maybe InboundConnection
$sel:connection:DeleteInboundConnectionResponse' :: DeleteInboundConnectionResponse -> Maybe InboundConnection
connection} -> Maybe InboundConnection
connection) (\s :: DeleteInboundConnectionResponse
s@DeleteInboundConnectionResponse' {} Maybe InboundConnection
a -> DeleteInboundConnectionResponse
s {$sel:connection:DeleteInboundConnectionResponse' :: Maybe InboundConnection
connection = Maybe InboundConnection
a} :: DeleteInboundConnectionResponse)

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

instance
  Prelude.NFData
    DeleteInboundConnectionResponse
  where
  rnf :: DeleteInboundConnectionResponse -> ()
rnf DeleteInboundConnectionResponse' {Int
Maybe InboundConnection
httpStatus :: Int
connection :: Maybe InboundConnection
$sel:httpStatus:DeleteInboundConnectionResponse' :: DeleteInboundConnectionResponse -> Int
$sel:connection:DeleteInboundConnectionResponse' :: DeleteInboundConnectionResponse -> Maybe InboundConnection
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe InboundConnection
connection
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus