{-# 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-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 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 Amazonka.KafkaConnect.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:/ '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
(UpdateConnector -> UpdateConnector -> Bool)
-> (UpdateConnector -> UpdateConnector -> Bool)
-> Eq UpdateConnector
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]
(Int -> ReadS UpdateConnector)
-> ReadS [UpdateConnector]
-> ReadPrec UpdateConnector
-> ReadPrec [UpdateConnector]
-> Read 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
(Int -> UpdateConnector -> ShowS)
-> (UpdateConnector -> String)
-> ([UpdateConnector] -> ShowS)
-> Show UpdateConnector
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. UpdateConnector -> Rep UpdateConnector x)
-> (forall x. Rep UpdateConnector x -> UpdateConnector)
-> Generic UpdateConnector
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' :: CapacityUpdate -> Text -> Text -> UpdateConnector
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 :: (CapacityUpdate -> f CapacityUpdate)
-> UpdateConnector -> f UpdateConnector
updateConnector_capacity = (UpdateConnector -> CapacityUpdate)
-> (UpdateConnector -> CapacityUpdate -> UpdateConnector)
-> Lens
     UpdateConnector UpdateConnector CapacityUpdate CapacityUpdate
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 :: (Text -> f Text) -> UpdateConnector -> f UpdateConnector
updateConnector_connectorArn = (UpdateConnector -> Text)
-> (UpdateConnector -> Text -> UpdateConnector)
-> Lens UpdateConnector UpdateConnector Text Text
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 :: (Text -> f Text) -> UpdateConnector -> f UpdateConnector
updateConnector_currentVersion = (UpdateConnector -> Text)
-> (UpdateConnector -> Text -> UpdateConnector)
-> Lens UpdateConnector UpdateConnector Text Text
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 :: UpdateConnector -> Request UpdateConnector
request = Service -> UpdateConnector -> Request UpdateConnector
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateConnector
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateConnector)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateConnector))
-> Logger
-> Service
-> Proxy UpdateConnector
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateConnector)))
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 Text
-> Maybe ConnectorState -> Int -> UpdateConnectorResponse
UpdateConnectorResponse'
            (Maybe Text
 -> Maybe ConnectorState -> Int -> UpdateConnectorResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe ConnectorState -> Int -> UpdateConnectorResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"connectorArn")
            Either
  String (Maybe ConnectorState -> Int -> UpdateConnectorResponse)
-> Either String (Maybe ConnectorState)
-> Either String (Int -> UpdateConnectorResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe ConnectorState)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"connectorState")
            Either String (Int -> UpdateConnectorResponse)
-> Either String Int -> Either String UpdateConnectorResponse
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 UpdateConnector

instance Prelude.NFData UpdateConnector

instance Core.ToHeaders UpdateConnector where
  toHeaders :: UpdateConnector -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateConnector -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"capacity" Text -> CapacityUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= CapacityUpdate
capacity)]
      )

instance Core.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
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/connectors/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
connectorArn]

instance Core.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
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"currentVersion" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: 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
(UpdateConnectorResponse -> UpdateConnectorResponse -> Bool)
-> (UpdateConnectorResponse -> UpdateConnectorResponse -> Bool)
-> Eq UpdateConnectorResponse
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]
(Int -> ReadS UpdateConnectorResponse)
-> ReadS [UpdateConnectorResponse]
-> ReadPrec UpdateConnectorResponse
-> ReadPrec [UpdateConnectorResponse]
-> Read 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
(Int -> UpdateConnectorResponse -> ShowS)
-> (UpdateConnectorResponse -> String)
-> ([UpdateConnectorResponse] -> ShowS)
-> Show UpdateConnectorResponse
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.
 UpdateConnectorResponse -> Rep UpdateConnectorResponse x)
-> (forall x.
    Rep UpdateConnectorResponse x -> UpdateConnectorResponse)
-> Generic UpdateConnectorResponse
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' :: Maybe Text
-> Maybe ConnectorState -> Int -> UpdateConnectorResponse
UpdateConnectorResponse'
    { $sel:connectorArn:UpdateConnectorResponse' :: Maybe Text
connectorArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:connectorState:UpdateConnectorResponse' :: Maybe ConnectorState
connectorState = Maybe 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 :: (Maybe Text -> f (Maybe Text))
-> UpdateConnectorResponse -> f UpdateConnectorResponse
updateConnectorResponse_connectorArn = (UpdateConnectorResponse -> Maybe Text)
-> (UpdateConnectorResponse
    -> Maybe Text -> UpdateConnectorResponse)
-> Lens
     UpdateConnectorResponse
     UpdateConnectorResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Maybe ConnectorState -> f (Maybe ConnectorState))
-> UpdateConnectorResponse -> f UpdateConnectorResponse
updateConnectorResponse_connectorState = (UpdateConnectorResponse -> Maybe ConnectorState)
-> (UpdateConnectorResponse
    -> Maybe ConnectorState -> UpdateConnectorResponse)
-> Lens
     UpdateConnectorResponse
     UpdateConnectorResponse
     (Maybe ConnectorState)
     (Maybe 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 :: (Int -> f Int)
-> UpdateConnectorResponse -> f UpdateConnectorResponse
updateConnectorResponse_httpStatus = (UpdateConnectorResponse -> Int)
-> (UpdateConnectorResponse -> Int -> UpdateConnectorResponse)
-> Lens UpdateConnectorResponse UpdateConnectorResponse Int Int
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