{-# 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-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 remote domain owner to delete an existing inbound
-- cross-cluster connection.
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.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 @ 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
(DeleteInboundConnection -> DeleteInboundConnection -> Bool)
-> (DeleteInboundConnection -> DeleteInboundConnection -> Bool)
-> Eq DeleteInboundConnection
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]
(Int -> ReadS DeleteInboundConnection)
-> ReadS [DeleteInboundConnection]
-> ReadPrec DeleteInboundConnection
-> ReadPrec [DeleteInboundConnection]
-> Read 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
(Int -> DeleteInboundConnection -> ShowS)
-> (DeleteInboundConnection -> String)
-> ([DeleteInboundConnection] -> ShowS)
-> Show DeleteInboundConnection
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.
 DeleteInboundConnection -> Rep DeleteInboundConnection x)
-> (forall x.
    Rep DeleteInboundConnection x -> DeleteInboundConnection)
-> Generic DeleteInboundConnection
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' :: Text -> DeleteInboundConnection
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 :: (Text -> f Text)
-> DeleteInboundConnection -> f DeleteInboundConnection
deleteInboundConnection_connectionId = (DeleteInboundConnection -> Text)
-> (DeleteInboundConnection -> Text -> DeleteInboundConnection)
-> Lens DeleteInboundConnection DeleteInboundConnection Text Text
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 :: DeleteInboundConnection -> Request DeleteInboundConnection
request = Service
-> DeleteInboundConnection -> Request DeleteInboundConnection
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteInboundConnection
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteInboundConnection)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteInboundConnection))
-> Logger
-> Service
-> Proxy DeleteInboundConnection
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteInboundConnection)))
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 InboundConnection -> Int -> DeleteInboundConnectionResponse
DeleteInboundConnectionResponse'
            (Maybe InboundConnection -> Int -> DeleteInboundConnectionResponse)
-> Either String (Maybe InboundConnection)
-> Either String (Int -> DeleteInboundConnectionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe InboundConnection)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Connection")
            Either String (Int -> DeleteInboundConnectionResponse)
-> Either String Int
-> Either String DeleteInboundConnectionResponse
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 DeleteInboundConnection

instance Prelude.NFData DeleteInboundConnection

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

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

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

-- | The result of a @ DeleteInboundConnection @ operation. Contains details
-- about the deleted inbound connection.
--
-- /See:/ 'newDeleteInboundConnectionResponse' smart constructor.
data DeleteInboundConnectionResponse = DeleteInboundConnectionResponse'
  { -- | The @ InboundConnection @ of 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
(DeleteInboundConnectionResponse
 -> DeleteInboundConnectionResponse -> Bool)
-> (DeleteInboundConnectionResponse
    -> DeleteInboundConnectionResponse -> Bool)
-> Eq DeleteInboundConnectionResponse
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]
(Int -> ReadS DeleteInboundConnectionResponse)
-> ReadS [DeleteInboundConnectionResponse]
-> ReadPrec DeleteInboundConnectionResponse
-> ReadPrec [DeleteInboundConnectionResponse]
-> Read 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
(Int -> DeleteInboundConnectionResponse -> ShowS)
-> (DeleteInboundConnectionResponse -> String)
-> ([DeleteInboundConnectionResponse] -> ShowS)
-> Show DeleteInboundConnectionResponse
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.
 DeleteInboundConnectionResponse
 -> Rep DeleteInboundConnectionResponse x)
-> (forall x.
    Rep DeleteInboundConnectionResponse x
    -> DeleteInboundConnectionResponse)
-> Generic DeleteInboundConnectionResponse
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 @ InboundConnection @ of 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' :: Maybe InboundConnection -> Int -> DeleteInboundConnectionResponse
DeleteInboundConnectionResponse'
    { $sel:connection:DeleteInboundConnectionResponse' :: Maybe InboundConnection
connection =
        Maybe InboundConnection
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteInboundConnectionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The @ InboundConnection @ of the deleted inbound connection.
deleteInboundConnectionResponse_connection :: Lens.Lens' DeleteInboundConnectionResponse (Prelude.Maybe InboundConnection)
deleteInboundConnectionResponse_connection :: (Maybe InboundConnection -> f (Maybe InboundConnection))
-> DeleteInboundConnectionResponse
-> f DeleteInboundConnectionResponse
deleteInboundConnectionResponse_connection = (DeleteInboundConnectionResponse -> Maybe InboundConnection)
-> (DeleteInboundConnectionResponse
    -> Maybe InboundConnection -> DeleteInboundConnectionResponse)
-> Lens
     DeleteInboundConnectionResponse
     DeleteInboundConnectionResponse
     (Maybe InboundConnection)
     (Maybe InboundConnection)
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 :: (Int -> f Int)
-> DeleteInboundConnectionResponse
-> f DeleteInboundConnectionResponse
deleteInboundConnectionResponse_httpStatus = (DeleteInboundConnectionResponse -> Int)
-> (DeleteInboundConnectionResponse
    -> Int -> DeleteInboundConnectionResponse)
-> Lens
     DeleteInboundConnectionResponse
     DeleteInboundConnectionResponse
     Int
     Int
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