{-# 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.UpdateConnection
-- 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)
--
-- Updates a connection definition in the Data Catalog.
module Amazonka.Glue.UpdateConnection
  ( -- * Creating a Request
    UpdateConnection (..),
    newUpdateConnection,

    -- * Request Lenses
    updateConnection_catalogId,
    updateConnection_name,
    updateConnection_connectionInput,

    -- * Destructuring the Response
    UpdateConnectionResponse (..),
    newUpdateConnectionResponse,

    -- * Response Lenses
    updateConnectionResponse_httpStatus,
  )
where

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

-- | /See:/ 'newUpdateConnection' smart constructor.
data UpdateConnection = UpdateConnection'
  { -- | The ID of the Data Catalog in which the connection resides. If none is
    -- provided, the Amazon Web Services account ID is used by default.
    UpdateConnection -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
    -- | The name of the connection definition to update.
    UpdateConnection -> Text
name :: Prelude.Text,
    -- | A @ConnectionInput@ object that redefines the connection in question.
    UpdateConnection -> ConnectionInput
connectionInput :: ConnectionInput
  }
  deriving (UpdateConnection -> UpdateConnection -> Bool
(UpdateConnection -> UpdateConnection -> Bool)
-> (UpdateConnection -> UpdateConnection -> Bool)
-> Eq UpdateConnection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateConnection -> UpdateConnection -> Bool
$c/= :: UpdateConnection -> UpdateConnection -> Bool
== :: UpdateConnection -> UpdateConnection -> Bool
$c== :: UpdateConnection -> UpdateConnection -> Bool
Prelude.Eq, ReadPrec [UpdateConnection]
ReadPrec UpdateConnection
Int -> ReadS UpdateConnection
ReadS [UpdateConnection]
(Int -> ReadS UpdateConnection)
-> ReadS [UpdateConnection]
-> ReadPrec UpdateConnection
-> ReadPrec [UpdateConnection]
-> Read UpdateConnection
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateConnection]
$creadListPrec :: ReadPrec [UpdateConnection]
readPrec :: ReadPrec UpdateConnection
$creadPrec :: ReadPrec UpdateConnection
readList :: ReadS [UpdateConnection]
$creadList :: ReadS [UpdateConnection]
readsPrec :: Int -> ReadS UpdateConnection
$creadsPrec :: Int -> ReadS UpdateConnection
Prelude.Read, Int -> UpdateConnection -> ShowS
[UpdateConnection] -> ShowS
UpdateConnection -> String
(Int -> UpdateConnection -> ShowS)
-> (UpdateConnection -> String)
-> ([UpdateConnection] -> ShowS)
-> Show UpdateConnection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateConnection] -> ShowS
$cshowList :: [UpdateConnection] -> ShowS
show :: UpdateConnection -> String
$cshow :: UpdateConnection -> String
showsPrec :: Int -> UpdateConnection -> ShowS
$cshowsPrec :: Int -> UpdateConnection -> ShowS
Prelude.Show, (forall x. UpdateConnection -> Rep UpdateConnection x)
-> (forall x. Rep UpdateConnection x -> UpdateConnection)
-> Generic UpdateConnection
forall x. Rep UpdateConnection x -> UpdateConnection
forall x. UpdateConnection -> Rep UpdateConnection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateConnection x -> UpdateConnection
$cfrom :: forall x. UpdateConnection -> Rep UpdateConnection x
Prelude.Generic)

-- |
-- Create a value of 'UpdateConnection' 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', 'updateConnection_catalogId' - The ID of the Data Catalog in which the connection resides. If none is
-- provided, the Amazon Web Services account ID is used by default.
--
-- 'name', 'updateConnection_name' - The name of the connection definition to update.
--
-- 'connectionInput', 'updateConnection_connectionInput' - A @ConnectionInput@ object that redefines the connection in question.
newUpdateConnection ::
  -- | 'name'
  Prelude.Text ->
  -- | 'connectionInput'
  ConnectionInput ->
  UpdateConnection
newUpdateConnection :: Text -> ConnectionInput -> UpdateConnection
newUpdateConnection Text
pName_ ConnectionInput
pConnectionInput_ =
  UpdateConnection' :: Maybe Text -> Text -> ConnectionInput -> UpdateConnection
UpdateConnection'
    { $sel:catalogId:UpdateConnection' :: Maybe Text
catalogId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:UpdateConnection' :: Text
name = Text
pName_,
      $sel:connectionInput:UpdateConnection' :: ConnectionInput
connectionInput = ConnectionInput
pConnectionInput_
    }

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

-- | The name of the connection definition to update.
updateConnection_name :: Lens.Lens' UpdateConnection Prelude.Text
updateConnection_name :: (Text -> f Text) -> UpdateConnection -> f UpdateConnection
updateConnection_name = (UpdateConnection -> Text)
-> (UpdateConnection -> Text -> UpdateConnection)
-> Lens UpdateConnection UpdateConnection Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConnection' {Text
name :: Text
$sel:name:UpdateConnection' :: UpdateConnection -> Text
name} -> Text
name) (\s :: UpdateConnection
s@UpdateConnection' {} Text
a -> UpdateConnection
s {$sel:name:UpdateConnection' :: Text
name = Text
a} :: UpdateConnection)

-- | A @ConnectionInput@ object that redefines the connection in question.
updateConnection_connectionInput :: Lens.Lens' UpdateConnection ConnectionInput
updateConnection_connectionInput :: (ConnectionInput -> f ConnectionInput)
-> UpdateConnection -> f UpdateConnection
updateConnection_connectionInput = (UpdateConnection -> ConnectionInput)
-> (UpdateConnection -> ConnectionInput -> UpdateConnection)
-> Lens
     UpdateConnection UpdateConnection ConnectionInput ConnectionInput
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConnection' {ConnectionInput
connectionInput :: ConnectionInput
$sel:connectionInput:UpdateConnection' :: UpdateConnection -> ConnectionInput
connectionInput} -> ConnectionInput
connectionInput) (\s :: UpdateConnection
s@UpdateConnection' {} ConnectionInput
a -> UpdateConnection
s {$sel:connectionInput:UpdateConnection' :: ConnectionInput
connectionInput = ConnectionInput
a} :: UpdateConnection)

instance Core.AWSRequest UpdateConnection where
  type
    AWSResponse UpdateConnection =
      UpdateConnectionResponse
  request :: UpdateConnection -> Request UpdateConnection
request = Service -> UpdateConnection -> Request UpdateConnection
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateConnection
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateConnection)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateConnection))
-> Logger
-> Service
-> Proxy UpdateConnection
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateConnection)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateConnectionResponse
UpdateConnectionResponse'
            (Int -> UpdateConnectionResponse)
-> Either String Int -> Either String UpdateConnectionResponse
forall (f :: * -> *) a b. Functor 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 UpdateConnection

instance Prelude.NFData UpdateConnection

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

instance Core.ToJSON UpdateConnection where
  toJSON :: UpdateConnection -> Value
toJSON UpdateConnection' {Maybe Text
Text
ConnectionInput
connectionInput :: ConnectionInput
name :: Text
catalogId :: Maybe Text
$sel:connectionInput:UpdateConnection' :: UpdateConnection -> ConnectionInput
$sel:name:UpdateConnection' :: UpdateConnection -> Text
$sel:catalogId:UpdateConnection' :: UpdateConnection -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CatalogId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
catalogId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ConnectionInput" Text -> ConnectionInput -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ConnectionInput
connectionInput)
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdateConnectionResponse' 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:
--
-- 'httpStatus', 'updateConnectionResponse_httpStatus' - The response's http status code.
newUpdateConnectionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateConnectionResponse
newUpdateConnectionResponse :: Int -> UpdateConnectionResponse
newUpdateConnectionResponse Int
pHttpStatus_ =
  UpdateConnectionResponse' :: Int -> UpdateConnectionResponse
UpdateConnectionResponse'
    { $sel:httpStatus:UpdateConnectionResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData UpdateConnectionResponse