{-# 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.KafkaConnect.UpdateConnector
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates the specified connector.
module Amazonka.KafkaConnect.UpdateConnector
  ( -- * Creating a Request
    UpdateConnector (..),
    newUpdateConnector,

    -- * Request Lenses
    updateConnector_capacity,
    updateConnector_connectorArn,
    updateConnector_currentVersion,

    -- * Destructuring the Response
    UpdateConnectorResponse (..),
    newUpdateConnectorResponse,

    -- * Response Lenses
    updateConnectorResponse_connectorArn,
    updateConnectorResponse_connectorState,
    updateConnectorResponse_httpStatus,
  )
where

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

-- | /See:/ 'newUpdateConnector' smart constructor.
data UpdateConnector = UpdateConnector'
  { -- | The target capacity.
    UpdateConnector -> CapacityUpdate
capacity :: CapacityUpdate,
    -- | The Amazon Resource Name (ARN) of the connector that you want to update.
    UpdateConnector -> Text
connectorArn :: Prelude.Text,
    -- | The current version of the connector that you want to update.
    UpdateConnector -> Text
currentVersion :: Prelude.Text
  }
  deriving (UpdateConnector -> UpdateConnector -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateConnector -> UpdateConnector -> Bool
$c/= :: UpdateConnector -> UpdateConnector -> Bool
== :: UpdateConnector -> UpdateConnector -> Bool
$c== :: UpdateConnector -> UpdateConnector -> Bool
Prelude.Eq, ReadPrec [UpdateConnector]
ReadPrec UpdateConnector
Int -> ReadS UpdateConnector
ReadS [UpdateConnector]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateConnector]
$creadListPrec :: ReadPrec [UpdateConnector]
readPrec :: ReadPrec UpdateConnector
$creadPrec :: ReadPrec UpdateConnector
readList :: ReadS [UpdateConnector]
$creadList :: ReadS [UpdateConnector]
readsPrec :: Int -> ReadS UpdateConnector
$creadsPrec :: Int -> ReadS UpdateConnector
Prelude.Read, Int -> UpdateConnector -> ShowS
[UpdateConnector] -> ShowS
UpdateConnector -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateConnector] -> ShowS
$cshowList :: [UpdateConnector] -> ShowS
show :: UpdateConnector -> String
$cshow :: UpdateConnector -> String
showsPrec :: Int -> UpdateConnector -> ShowS
$cshowsPrec :: Int -> UpdateConnector -> ShowS
Prelude.Show, forall x. Rep UpdateConnector x -> UpdateConnector
forall x. UpdateConnector -> Rep UpdateConnector x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateConnector x -> UpdateConnector
$cfrom :: forall x. UpdateConnector -> Rep UpdateConnector x
Prelude.Generic)

-- |
-- Create a value of 'UpdateConnector' 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:
--
-- 'capacity', 'updateConnector_capacity' - The target capacity.
--
-- 'connectorArn', 'updateConnector_connectorArn' - The Amazon Resource Name (ARN) of the connector that you want to update.
--
-- 'currentVersion', 'updateConnector_currentVersion' - The current version of the connector that you want to update.
newUpdateConnector ::
  -- | 'capacity'
  CapacityUpdate ->
  -- | 'connectorArn'
  Prelude.Text ->
  -- | 'currentVersion'
  Prelude.Text ->
  UpdateConnector
newUpdateConnector :: CapacityUpdate -> Text -> Text -> UpdateConnector
newUpdateConnector
  CapacityUpdate
pCapacity_
  Text
pConnectorArn_
  Text
pCurrentVersion_ =
    UpdateConnector'
      { $sel:capacity:UpdateConnector' :: CapacityUpdate
capacity = CapacityUpdate
pCapacity_,
        $sel:connectorArn:UpdateConnector' :: Text
connectorArn = Text
pConnectorArn_,
        $sel:currentVersion:UpdateConnector' :: Text
currentVersion = Text
pCurrentVersion_
      }

-- | The target capacity.
updateConnector_capacity :: Lens.Lens' UpdateConnector CapacityUpdate
updateConnector_capacity :: Lens' UpdateConnector CapacityUpdate
updateConnector_capacity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConnector' {CapacityUpdate
capacity :: CapacityUpdate
$sel:capacity:UpdateConnector' :: UpdateConnector -> CapacityUpdate
capacity} -> CapacityUpdate
capacity) (\s :: UpdateConnector
s@UpdateConnector' {} CapacityUpdate
a -> UpdateConnector
s {$sel:capacity:UpdateConnector' :: CapacityUpdate
capacity = CapacityUpdate
a} :: UpdateConnector)

-- | The Amazon Resource Name (ARN) of the connector that you want to update.
updateConnector_connectorArn :: Lens.Lens' UpdateConnector Prelude.Text
updateConnector_connectorArn :: Lens' UpdateConnector Text
updateConnector_connectorArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConnector' {Text
connectorArn :: Text
$sel:connectorArn:UpdateConnector' :: UpdateConnector -> Text
connectorArn} -> Text
connectorArn) (\s :: UpdateConnector
s@UpdateConnector' {} Text
a -> UpdateConnector
s {$sel:connectorArn:UpdateConnector' :: Text
connectorArn = Text
a} :: UpdateConnector)

-- | The current version of the connector that you want to update.
updateConnector_currentVersion :: Lens.Lens' UpdateConnector Prelude.Text
updateConnector_currentVersion :: Lens' UpdateConnector Text
updateConnector_currentVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConnector' {Text
currentVersion :: Text
$sel:currentVersion:UpdateConnector' :: UpdateConnector -> Text
currentVersion} -> Text
currentVersion) (\s :: UpdateConnector
s@UpdateConnector' {} Text
a -> UpdateConnector
s {$sel:currentVersion:UpdateConnector' :: Text
currentVersion = Text
a} :: UpdateConnector)

instance Core.AWSRequest UpdateConnector where
  type
    AWSResponse UpdateConnector =
      UpdateConnectorResponse
  request :: (Service -> Service) -> UpdateConnector -> Request UpdateConnector
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateConnector
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateConnector)))
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 Text
-> Maybe ConnectorState -> Int -> UpdateConnectorResponse
UpdateConnectorResponse'
            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
"connectorArn")
            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
"connectorState")
            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 UpdateConnector where
  hashWithSalt :: Int -> UpdateConnector -> Int
hashWithSalt Int
_salt UpdateConnector' {Text
CapacityUpdate
currentVersion :: Text
connectorArn :: Text
capacity :: CapacityUpdate
$sel:currentVersion:UpdateConnector' :: UpdateConnector -> Text
$sel:connectorArn:UpdateConnector' :: UpdateConnector -> Text
$sel:capacity:UpdateConnector' :: UpdateConnector -> CapacityUpdate
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` CapacityUpdate
capacity
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
connectorArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
currentVersion

instance Prelude.NFData UpdateConnector where
  rnf :: UpdateConnector -> ()
rnf UpdateConnector' {Text
CapacityUpdate
currentVersion :: Text
connectorArn :: Text
capacity :: CapacityUpdate
$sel:currentVersion:UpdateConnector' :: UpdateConnector -> Text
$sel:connectorArn:UpdateConnector' :: UpdateConnector -> Text
$sel:capacity:UpdateConnector' :: UpdateConnector -> CapacityUpdate
..} =
    forall a. NFData a => a -> ()
Prelude.rnf CapacityUpdate
capacity
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
connectorArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
currentVersion

instance Data.ToHeaders UpdateConnector where
  toHeaders :: UpdateConnector -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdateConnector where
  toJSON :: UpdateConnector -> Value
toJSON UpdateConnector' {Text
CapacityUpdate
currentVersion :: Text
connectorArn :: Text
capacity :: CapacityUpdate
$sel:currentVersion:UpdateConnector' :: UpdateConnector -> Text
$sel:connectorArn:UpdateConnector' :: UpdateConnector -> Text
$sel:capacity:UpdateConnector' :: UpdateConnector -> CapacityUpdate
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"capacity" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= CapacityUpdate
capacity)]
      )

instance Data.ToPath UpdateConnector where
  toPath :: UpdateConnector -> ByteString
toPath UpdateConnector' {Text
CapacityUpdate
currentVersion :: Text
connectorArn :: Text
capacity :: CapacityUpdate
$sel:currentVersion:UpdateConnector' :: UpdateConnector -> Text
$sel:connectorArn:UpdateConnector' :: UpdateConnector -> Text
$sel:capacity:UpdateConnector' :: UpdateConnector -> CapacityUpdate
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/connectors/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
connectorArn]

instance Data.ToQuery UpdateConnector where
  toQuery :: UpdateConnector -> QueryString
toQuery UpdateConnector' {Text
CapacityUpdate
currentVersion :: Text
connectorArn :: Text
capacity :: CapacityUpdate
$sel:currentVersion:UpdateConnector' :: UpdateConnector -> Text
$sel:connectorArn:UpdateConnector' :: UpdateConnector -> Text
$sel:capacity:UpdateConnector' :: UpdateConnector -> CapacityUpdate
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"currentVersion" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
currentVersion]

-- | /See:/ 'newUpdateConnectorResponse' smart constructor.
data UpdateConnectorResponse = UpdateConnectorResponse'
  { -- | The Amazon Resource Name (ARN) of the connector.
    UpdateConnectorResponse -> Maybe Text
connectorArn :: Prelude.Maybe Prelude.Text,
    -- | The state of the connector.
    UpdateConnectorResponse -> Maybe ConnectorState
connectorState :: Prelude.Maybe ConnectorState,
    -- | The response's http status code.
    UpdateConnectorResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateConnectorResponse -> UpdateConnectorResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateConnectorResponse -> UpdateConnectorResponse -> Bool
$c/= :: UpdateConnectorResponse -> UpdateConnectorResponse -> Bool
== :: UpdateConnectorResponse -> UpdateConnectorResponse -> Bool
$c== :: UpdateConnectorResponse -> UpdateConnectorResponse -> Bool
Prelude.Eq, ReadPrec [UpdateConnectorResponse]
ReadPrec UpdateConnectorResponse
Int -> ReadS UpdateConnectorResponse
ReadS [UpdateConnectorResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateConnectorResponse]
$creadListPrec :: ReadPrec [UpdateConnectorResponse]
readPrec :: ReadPrec UpdateConnectorResponse
$creadPrec :: ReadPrec UpdateConnectorResponse
readList :: ReadS [UpdateConnectorResponse]
$creadList :: ReadS [UpdateConnectorResponse]
readsPrec :: Int -> ReadS UpdateConnectorResponse
$creadsPrec :: Int -> ReadS UpdateConnectorResponse
Prelude.Read, Int -> UpdateConnectorResponse -> ShowS
[UpdateConnectorResponse] -> ShowS
UpdateConnectorResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateConnectorResponse] -> ShowS
$cshowList :: [UpdateConnectorResponse] -> ShowS
show :: UpdateConnectorResponse -> String
$cshow :: UpdateConnectorResponse -> String
showsPrec :: Int -> UpdateConnectorResponse -> ShowS
$cshowsPrec :: Int -> UpdateConnectorResponse -> ShowS
Prelude.Show, forall x. Rep UpdateConnectorResponse x -> UpdateConnectorResponse
forall x. UpdateConnectorResponse -> Rep UpdateConnectorResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateConnectorResponse x -> UpdateConnectorResponse
$cfrom :: forall x. UpdateConnectorResponse -> Rep UpdateConnectorResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateConnectorResponse' 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:
--
-- 'connectorArn', 'updateConnectorResponse_connectorArn' - The Amazon Resource Name (ARN) of the connector.
--
-- 'connectorState', 'updateConnectorResponse_connectorState' - The state of the connector.
--
-- 'httpStatus', 'updateConnectorResponse_httpStatus' - The response's http status code.
newUpdateConnectorResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateConnectorResponse
newUpdateConnectorResponse :: Int -> UpdateConnectorResponse
newUpdateConnectorResponse Int
pHttpStatus_ =
  UpdateConnectorResponse'
    { $sel:connectorArn:UpdateConnectorResponse' :: Maybe Text
connectorArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:connectorState:UpdateConnectorResponse' :: Maybe ConnectorState
connectorState = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateConnectorResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the connector.
updateConnectorResponse_connectorArn :: Lens.Lens' UpdateConnectorResponse (Prelude.Maybe Prelude.Text)
updateConnectorResponse_connectorArn :: Lens' UpdateConnectorResponse (Maybe Text)
updateConnectorResponse_connectorArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConnectorResponse' {Maybe Text
connectorArn :: Maybe Text
$sel:connectorArn:UpdateConnectorResponse' :: UpdateConnectorResponse -> Maybe Text
connectorArn} -> Maybe Text
connectorArn) (\s :: UpdateConnectorResponse
s@UpdateConnectorResponse' {} Maybe Text
a -> UpdateConnectorResponse
s {$sel:connectorArn:UpdateConnectorResponse' :: Maybe Text
connectorArn = Maybe Text
a} :: UpdateConnectorResponse)

-- | The state of the connector.
updateConnectorResponse_connectorState :: Lens.Lens' UpdateConnectorResponse (Prelude.Maybe ConnectorState)
updateConnectorResponse_connectorState :: Lens' UpdateConnectorResponse (Maybe ConnectorState)
updateConnectorResponse_connectorState = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConnectorResponse' {Maybe ConnectorState
connectorState :: Maybe ConnectorState
$sel:connectorState:UpdateConnectorResponse' :: UpdateConnectorResponse -> Maybe ConnectorState
connectorState} -> Maybe ConnectorState
connectorState) (\s :: UpdateConnectorResponse
s@UpdateConnectorResponse' {} Maybe ConnectorState
a -> UpdateConnectorResponse
s {$sel:connectorState:UpdateConnectorResponse' :: Maybe ConnectorState
connectorState = Maybe ConnectorState
a} :: UpdateConnectorResponse)

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

instance Prelude.NFData UpdateConnectorResponse where
  rnf :: UpdateConnectorResponse -> ()
rnf UpdateConnectorResponse' {Int
Maybe Text
Maybe ConnectorState
httpStatus :: Int
connectorState :: Maybe ConnectorState
connectorArn :: Maybe Text
$sel:httpStatus:UpdateConnectorResponse' :: UpdateConnectorResponse -> Int
$sel:connectorState:UpdateConnectorResponse' :: UpdateConnectorResponse -> Maybe ConnectorState
$sel:connectorArn:UpdateConnectorResponse' :: UpdateConnectorResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
connectorArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ConnectorState
connectorState
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus