{-# 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.Glue.BatchDeleteConnection
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes a list of connection definitions from the Data Catalog.
module Amazonka.Glue.BatchDeleteConnection
  ( -- * Creating a Request
    BatchDeleteConnection (..),
    newBatchDeleteConnection,

    -- * Request Lenses
    batchDeleteConnection_catalogId,
    batchDeleteConnection_connectionNameList,

    -- * Destructuring the Response
    BatchDeleteConnectionResponse (..),
    newBatchDeleteConnectionResponse,

    -- * Response Lenses
    batchDeleteConnectionResponse_errors,
    batchDeleteConnectionResponse_succeeded,
    batchDeleteConnectionResponse_httpStatus,
  )
where

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

-- | /See:/ 'newBatchDeleteConnection' smart constructor.
data BatchDeleteConnection = BatchDeleteConnection'
  { -- | The ID of the Data Catalog in which the connections reside. If none is
    -- provided, the Amazon Web Services account ID is used by default.
    BatchDeleteConnection -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
    -- | A list of names of the connections to delete.
    BatchDeleteConnection -> [Text]
connectionNameList :: [Prelude.Text]
  }
  deriving (BatchDeleteConnection -> BatchDeleteConnection -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchDeleteConnection -> BatchDeleteConnection -> Bool
$c/= :: BatchDeleteConnection -> BatchDeleteConnection -> Bool
== :: BatchDeleteConnection -> BatchDeleteConnection -> Bool
$c== :: BatchDeleteConnection -> BatchDeleteConnection -> Bool
Prelude.Eq, ReadPrec [BatchDeleteConnection]
ReadPrec BatchDeleteConnection
Int -> ReadS BatchDeleteConnection
ReadS [BatchDeleteConnection]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchDeleteConnection]
$creadListPrec :: ReadPrec [BatchDeleteConnection]
readPrec :: ReadPrec BatchDeleteConnection
$creadPrec :: ReadPrec BatchDeleteConnection
readList :: ReadS [BatchDeleteConnection]
$creadList :: ReadS [BatchDeleteConnection]
readsPrec :: Int -> ReadS BatchDeleteConnection
$creadsPrec :: Int -> ReadS BatchDeleteConnection
Prelude.Read, Int -> BatchDeleteConnection -> ShowS
[BatchDeleteConnection] -> ShowS
BatchDeleteConnection -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchDeleteConnection] -> ShowS
$cshowList :: [BatchDeleteConnection] -> ShowS
show :: BatchDeleteConnection -> String
$cshow :: BatchDeleteConnection -> String
showsPrec :: Int -> BatchDeleteConnection -> ShowS
$cshowsPrec :: Int -> BatchDeleteConnection -> ShowS
Prelude.Show, forall x. Rep BatchDeleteConnection x -> BatchDeleteConnection
forall x. BatchDeleteConnection -> Rep BatchDeleteConnection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchDeleteConnection x -> BatchDeleteConnection
$cfrom :: forall x. BatchDeleteConnection -> Rep BatchDeleteConnection x
Prelude.Generic)

-- |
-- Create a value of 'BatchDeleteConnection' 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:
--
-- 'catalogId', 'batchDeleteConnection_catalogId' - The ID of the Data Catalog in which the connections reside. If none is
-- provided, the Amazon Web Services account ID is used by default.
--
-- 'connectionNameList', 'batchDeleteConnection_connectionNameList' - A list of names of the connections to delete.
newBatchDeleteConnection ::
  BatchDeleteConnection
newBatchDeleteConnection :: BatchDeleteConnection
newBatchDeleteConnection =
  BatchDeleteConnection'
    { $sel:catalogId:BatchDeleteConnection' :: Maybe Text
catalogId = forall a. Maybe a
Prelude.Nothing,
      $sel:connectionNameList:BatchDeleteConnection' :: [Text]
connectionNameList = forall a. Monoid a => a
Prelude.mempty
    }

-- | The ID of the Data Catalog in which the connections reside. If none is
-- provided, the Amazon Web Services account ID is used by default.
batchDeleteConnection_catalogId :: Lens.Lens' BatchDeleteConnection (Prelude.Maybe Prelude.Text)
batchDeleteConnection_catalogId :: Lens' BatchDeleteConnection (Maybe Text)
batchDeleteConnection_catalogId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDeleteConnection' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:BatchDeleteConnection' :: BatchDeleteConnection -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: BatchDeleteConnection
s@BatchDeleteConnection' {} Maybe Text
a -> BatchDeleteConnection
s {$sel:catalogId:BatchDeleteConnection' :: Maybe Text
catalogId = Maybe Text
a} :: BatchDeleteConnection)

-- | A list of names of the connections to delete.
batchDeleteConnection_connectionNameList :: Lens.Lens' BatchDeleteConnection [Prelude.Text]
batchDeleteConnection_connectionNameList :: Lens' BatchDeleteConnection [Text]
batchDeleteConnection_connectionNameList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDeleteConnection' {[Text]
connectionNameList :: [Text]
$sel:connectionNameList:BatchDeleteConnection' :: BatchDeleteConnection -> [Text]
connectionNameList} -> [Text]
connectionNameList) (\s :: BatchDeleteConnection
s@BatchDeleteConnection' {} [Text]
a -> BatchDeleteConnection
s {$sel:connectionNameList:BatchDeleteConnection' :: [Text]
connectionNameList = [Text]
a} :: BatchDeleteConnection) 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

instance Core.AWSRequest BatchDeleteConnection where
  type
    AWSResponse BatchDeleteConnection =
      BatchDeleteConnectionResponse
  request :: (Service -> Service)
-> BatchDeleteConnection -> Request BatchDeleteConnection
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 BatchDeleteConnection
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchDeleteConnection)))
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 (HashMap Text ErrorDetail)
-> Maybe [Text] -> Int -> BatchDeleteConnectionResponse
BatchDeleteConnectionResponse'
            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
"Errors" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Succeeded" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            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 BatchDeleteConnection where
  hashWithSalt :: Int -> BatchDeleteConnection -> Int
hashWithSalt Int
_salt BatchDeleteConnection' {[Text]
Maybe Text
connectionNameList :: [Text]
catalogId :: Maybe Text
$sel:connectionNameList:BatchDeleteConnection' :: BatchDeleteConnection -> [Text]
$sel:catalogId:BatchDeleteConnection' :: BatchDeleteConnection -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
catalogId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
connectionNameList

instance Prelude.NFData BatchDeleteConnection where
  rnf :: BatchDeleteConnection -> ()
rnf BatchDeleteConnection' {[Text]
Maybe Text
connectionNameList :: [Text]
catalogId :: Maybe Text
$sel:connectionNameList:BatchDeleteConnection' :: BatchDeleteConnection -> [Text]
$sel:catalogId:BatchDeleteConnection' :: BatchDeleteConnection -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
catalogId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
connectionNameList

instance Data.ToHeaders BatchDeleteConnection where
  toHeaders :: BatchDeleteConnection -> ResponseHeaders
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 -> ResponseHeaders
Data.=# ( ByteString
"AWSGlue.BatchDeleteConnection" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON BatchDeleteConnection where
  toJSON :: BatchDeleteConnection -> Value
toJSON BatchDeleteConnection' {[Text]
Maybe Text
connectionNameList :: [Text]
catalogId :: Maybe Text
$sel:connectionNameList:BatchDeleteConnection' :: BatchDeleteConnection -> [Text]
$sel:catalogId:BatchDeleteConnection' :: BatchDeleteConnection -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CatalogId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
catalogId,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ConnectionNameList" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
connectionNameList)
          ]
      )

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

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

-- | /See:/ 'newBatchDeleteConnectionResponse' smart constructor.
data BatchDeleteConnectionResponse = BatchDeleteConnectionResponse'
  { -- | A map of the names of connections that were not successfully deleted to
    -- error details.
    BatchDeleteConnectionResponse -> Maybe (HashMap Text ErrorDetail)
errors :: Prelude.Maybe (Prelude.HashMap Prelude.Text ErrorDetail),
    -- | A list of names of the connection definitions that were successfully
    -- deleted.
    BatchDeleteConnectionResponse -> Maybe [Text]
succeeded :: Prelude.Maybe [Prelude.Text],
    -- | The response's http status code.
    BatchDeleteConnectionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (BatchDeleteConnectionResponse
-> BatchDeleteConnectionResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchDeleteConnectionResponse
-> BatchDeleteConnectionResponse -> Bool
$c/= :: BatchDeleteConnectionResponse
-> BatchDeleteConnectionResponse -> Bool
== :: BatchDeleteConnectionResponse
-> BatchDeleteConnectionResponse -> Bool
$c== :: BatchDeleteConnectionResponse
-> BatchDeleteConnectionResponse -> Bool
Prelude.Eq, ReadPrec [BatchDeleteConnectionResponse]
ReadPrec BatchDeleteConnectionResponse
Int -> ReadS BatchDeleteConnectionResponse
ReadS [BatchDeleteConnectionResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchDeleteConnectionResponse]
$creadListPrec :: ReadPrec [BatchDeleteConnectionResponse]
readPrec :: ReadPrec BatchDeleteConnectionResponse
$creadPrec :: ReadPrec BatchDeleteConnectionResponse
readList :: ReadS [BatchDeleteConnectionResponse]
$creadList :: ReadS [BatchDeleteConnectionResponse]
readsPrec :: Int -> ReadS BatchDeleteConnectionResponse
$creadsPrec :: Int -> ReadS BatchDeleteConnectionResponse
Prelude.Read, Int -> BatchDeleteConnectionResponse -> ShowS
[BatchDeleteConnectionResponse] -> ShowS
BatchDeleteConnectionResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchDeleteConnectionResponse] -> ShowS
$cshowList :: [BatchDeleteConnectionResponse] -> ShowS
show :: BatchDeleteConnectionResponse -> String
$cshow :: BatchDeleteConnectionResponse -> String
showsPrec :: Int -> BatchDeleteConnectionResponse -> ShowS
$cshowsPrec :: Int -> BatchDeleteConnectionResponse -> ShowS
Prelude.Show, forall x.
Rep BatchDeleteConnectionResponse x
-> BatchDeleteConnectionResponse
forall x.
BatchDeleteConnectionResponse
-> Rep BatchDeleteConnectionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchDeleteConnectionResponse x
-> BatchDeleteConnectionResponse
$cfrom :: forall x.
BatchDeleteConnectionResponse
-> Rep BatchDeleteConnectionResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchDeleteConnectionResponse' 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:
--
-- 'errors', 'batchDeleteConnectionResponse_errors' - A map of the names of connections that were not successfully deleted to
-- error details.
--
-- 'succeeded', 'batchDeleteConnectionResponse_succeeded' - A list of names of the connection definitions that were successfully
-- deleted.
--
-- 'httpStatus', 'batchDeleteConnectionResponse_httpStatus' - The response's http status code.
newBatchDeleteConnectionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchDeleteConnectionResponse
newBatchDeleteConnectionResponse :: Int -> BatchDeleteConnectionResponse
newBatchDeleteConnectionResponse Int
pHttpStatus_ =
  BatchDeleteConnectionResponse'
    { $sel:errors:BatchDeleteConnectionResponse' :: Maybe (HashMap Text ErrorDetail)
errors =
        forall a. Maybe a
Prelude.Nothing,
      $sel:succeeded:BatchDeleteConnectionResponse' :: Maybe [Text]
succeeded = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchDeleteConnectionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A map of the names of connections that were not successfully deleted to
-- error details.
batchDeleteConnectionResponse_errors :: Lens.Lens' BatchDeleteConnectionResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text ErrorDetail))
batchDeleteConnectionResponse_errors :: Lens'
  BatchDeleteConnectionResponse (Maybe (HashMap Text ErrorDetail))
batchDeleteConnectionResponse_errors = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDeleteConnectionResponse' {Maybe (HashMap Text ErrorDetail)
errors :: Maybe (HashMap Text ErrorDetail)
$sel:errors:BatchDeleteConnectionResponse' :: BatchDeleteConnectionResponse -> Maybe (HashMap Text ErrorDetail)
errors} -> Maybe (HashMap Text ErrorDetail)
errors) (\s :: BatchDeleteConnectionResponse
s@BatchDeleteConnectionResponse' {} Maybe (HashMap Text ErrorDetail)
a -> BatchDeleteConnectionResponse
s {$sel:errors:BatchDeleteConnectionResponse' :: Maybe (HashMap Text ErrorDetail)
errors = Maybe (HashMap Text ErrorDetail)
a} :: BatchDeleteConnectionResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A list of names of the connection definitions that were successfully
-- deleted.
batchDeleteConnectionResponse_succeeded :: Lens.Lens' BatchDeleteConnectionResponse (Prelude.Maybe [Prelude.Text])
batchDeleteConnectionResponse_succeeded :: Lens' BatchDeleteConnectionResponse (Maybe [Text])
batchDeleteConnectionResponse_succeeded = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDeleteConnectionResponse' {Maybe [Text]
succeeded :: Maybe [Text]
$sel:succeeded:BatchDeleteConnectionResponse' :: BatchDeleteConnectionResponse -> Maybe [Text]
succeeded} -> Maybe [Text]
succeeded) (\s :: BatchDeleteConnectionResponse
s@BatchDeleteConnectionResponse' {} Maybe [Text]
a -> BatchDeleteConnectionResponse
s {$sel:succeeded:BatchDeleteConnectionResponse' :: Maybe [Text]
succeeded = Maybe [Text]
a} :: BatchDeleteConnectionResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData BatchDeleteConnectionResponse where
  rnf :: BatchDeleteConnectionResponse -> ()
rnf BatchDeleteConnectionResponse' {Int
Maybe [Text]
Maybe (HashMap Text ErrorDetail)
httpStatus :: Int
succeeded :: Maybe [Text]
errors :: Maybe (HashMap Text ErrorDetail)
$sel:httpStatus:BatchDeleteConnectionResponse' :: BatchDeleteConnectionResponse -> Int
$sel:succeeded:BatchDeleteConnectionResponse' :: BatchDeleteConnectionResponse -> Maybe [Text]
$sel:errors:BatchDeleteConnectionResponse' :: BatchDeleteConnectionResponse -> Maybe (HashMap Text ErrorDetail)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text ErrorDetail)
errors
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
succeeded
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus