{-# 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.Greengrass.UpdateConnectorDefinition
-- 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 connector definition.
module Amazonka.Greengrass.UpdateConnectorDefinition
  ( -- * Creating a Request
    UpdateConnectorDefinition (..),
    newUpdateConnectorDefinition,

    -- * Request Lenses
    updateConnectorDefinition_name,
    updateConnectorDefinition_connectorDefinitionId,

    -- * Destructuring the Response
    UpdateConnectorDefinitionResponse (..),
    newUpdateConnectorDefinitionResponse,

    -- * Response Lenses
    updateConnectorDefinitionResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Greengrass.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:/ 'newUpdateConnectorDefinition' smart constructor.
data UpdateConnectorDefinition = UpdateConnectorDefinition'
  { -- | The name of the definition.
    UpdateConnectorDefinition -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The ID of the connector definition.
    UpdateConnectorDefinition -> Text
connectorDefinitionId :: Prelude.Text
  }
  deriving (UpdateConnectorDefinition -> UpdateConnectorDefinition -> Bool
(UpdateConnectorDefinition -> UpdateConnectorDefinition -> Bool)
-> (UpdateConnectorDefinition -> UpdateConnectorDefinition -> Bool)
-> Eq UpdateConnectorDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateConnectorDefinition -> UpdateConnectorDefinition -> Bool
$c/= :: UpdateConnectorDefinition -> UpdateConnectorDefinition -> Bool
== :: UpdateConnectorDefinition -> UpdateConnectorDefinition -> Bool
$c== :: UpdateConnectorDefinition -> UpdateConnectorDefinition -> Bool
Prelude.Eq, ReadPrec [UpdateConnectorDefinition]
ReadPrec UpdateConnectorDefinition
Int -> ReadS UpdateConnectorDefinition
ReadS [UpdateConnectorDefinition]
(Int -> ReadS UpdateConnectorDefinition)
-> ReadS [UpdateConnectorDefinition]
-> ReadPrec UpdateConnectorDefinition
-> ReadPrec [UpdateConnectorDefinition]
-> Read UpdateConnectorDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateConnectorDefinition]
$creadListPrec :: ReadPrec [UpdateConnectorDefinition]
readPrec :: ReadPrec UpdateConnectorDefinition
$creadPrec :: ReadPrec UpdateConnectorDefinition
readList :: ReadS [UpdateConnectorDefinition]
$creadList :: ReadS [UpdateConnectorDefinition]
readsPrec :: Int -> ReadS UpdateConnectorDefinition
$creadsPrec :: Int -> ReadS UpdateConnectorDefinition
Prelude.Read, Int -> UpdateConnectorDefinition -> ShowS
[UpdateConnectorDefinition] -> ShowS
UpdateConnectorDefinition -> String
(Int -> UpdateConnectorDefinition -> ShowS)
-> (UpdateConnectorDefinition -> String)
-> ([UpdateConnectorDefinition] -> ShowS)
-> Show UpdateConnectorDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateConnectorDefinition] -> ShowS
$cshowList :: [UpdateConnectorDefinition] -> ShowS
show :: UpdateConnectorDefinition -> String
$cshow :: UpdateConnectorDefinition -> String
showsPrec :: Int -> UpdateConnectorDefinition -> ShowS
$cshowsPrec :: Int -> UpdateConnectorDefinition -> ShowS
Prelude.Show, (forall x.
 UpdateConnectorDefinition -> Rep UpdateConnectorDefinition x)
-> (forall x.
    Rep UpdateConnectorDefinition x -> UpdateConnectorDefinition)
-> Generic UpdateConnectorDefinition
forall x.
Rep UpdateConnectorDefinition x -> UpdateConnectorDefinition
forall x.
UpdateConnectorDefinition -> Rep UpdateConnectorDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateConnectorDefinition x -> UpdateConnectorDefinition
$cfrom :: forall x.
UpdateConnectorDefinition -> Rep UpdateConnectorDefinition x
Prelude.Generic)

-- |
-- Create a value of 'UpdateConnectorDefinition' 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:
--
-- 'name', 'updateConnectorDefinition_name' - The name of the definition.
--
-- 'connectorDefinitionId', 'updateConnectorDefinition_connectorDefinitionId' - The ID of the connector definition.
newUpdateConnectorDefinition ::
  -- | 'connectorDefinitionId'
  Prelude.Text ->
  UpdateConnectorDefinition
newUpdateConnectorDefinition :: Text -> UpdateConnectorDefinition
newUpdateConnectorDefinition Text
pConnectorDefinitionId_ =
  UpdateConnectorDefinition' :: Maybe Text -> Text -> UpdateConnectorDefinition
UpdateConnectorDefinition'
    { $sel:name:UpdateConnectorDefinition' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:connectorDefinitionId:UpdateConnectorDefinition' :: Text
connectorDefinitionId = Text
pConnectorDefinitionId_
    }

-- | The name of the definition.
updateConnectorDefinition_name :: Lens.Lens' UpdateConnectorDefinition (Prelude.Maybe Prelude.Text)
updateConnectorDefinition_name :: (Maybe Text -> f (Maybe Text))
-> UpdateConnectorDefinition -> f UpdateConnectorDefinition
updateConnectorDefinition_name = (UpdateConnectorDefinition -> Maybe Text)
-> (UpdateConnectorDefinition
    -> Maybe Text -> UpdateConnectorDefinition)
-> Lens
     UpdateConnectorDefinition
     UpdateConnectorDefinition
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConnectorDefinition' {Maybe Text
name :: Maybe Text
$sel:name:UpdateConnectorDefinition' :: UpdateConnectorDefinition -> Maybe Text
name} -> Maybe Text
name) (\s :: UpdateConnectorDefinition
s@UpdateConnectorDefinition' {} Maybe Text
a -> UpdateConnectorDefinition
s {$sel:name:UpdateConnectorDefinition' :: Maybe Text
name = Maybe Text
a} :: UpdateConnectorDefinition)

-- | The ID of the connector definition.
updateConnectorDefinition_connectorDefinitionId :: Lens.Lens' UpdateConnectorDefinition Prelude.Text
updateConnectorDefinition_connectorDefinitionId :: (Text -> f Text)
-> UpdateConnectorDefinition -> f UpdateConnectorDefinition
updateConnectorDefinition_connectorDefinitionId = (UpdateConnectorDefinition -> Text)
-> (UpdateConnectorDefinition -> Text -> UpdateConnectorDefinition)
-> Lens
     UpdateConnectorDefinition UpdateConnectorDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConnectorDefinition' {Text
connectorDefinitionId :: Text
$sel:connectorDefinitionId:UpdateConnectorDefinition' :: UpdateConnectorDefinition -> Text
connectorDefinitionId} -> Text
connectorDefinitionId) (\s :: UpdateConnectorDefinition
s@UpdateConnectorDefinition' {} Text
a -> UpdateConnectorDefinition
s {$sel:connectorDefinitionId:UpdateConnectorDefinition' :: Text
connectorDefinitionId = Text
a} :: UpdateConnectorDefinition)

instance Core.AWSRequest UpdateConnectorDefinition where
  type
    AWSResponse UpdateConnectorDefinition =
      UpdateConnectorDefinitionResponse
  request :: UpdateConnectorDefinition -> Request UpdateConnectorDefinition
request = Service
-> UpdateConnectorDefinition -> Request UpdateConnectorDefinition
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateConnectorDefinition
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateConnectorDefinition)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateConnectorDefinition))
-> Logger
-> Service
-> Proxy UpdateConnectorDefinition
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateConnectorDefinition)))
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 -> UpdateConnectorDefinitionResponse
UpdateConnectorDefinitionResponse'
            (Int -> UpdateConnectorDefinitionResponse)
-> Either String Int
-> Either String UpdateConnectorDefinitionResponse
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 UpdateConnectorDefinition

instance Prelude.NFData UpdateConnectorDefinition

instance Core.ToHeaders UpdateConnectorDefinition where
  toHeaders :: UpdateConnectorDefinition -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateConnectorDefinition -> 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 UpdateConnectorDefinition where
  toJSON :: UpdateConnectorDefinition -> Value
toJSON UpdateConnectorDefinition' {Maybe Text
Text
connectorDefinitionId :: Text
name :: Maybe Text
$sel:connectorDefinitionId:UpdateConnectorDefinition' :: UpdateConnectorDefinition -> Text
$sel:name:UpdateConnectorDefinition' :: UpdateConnectorDefinition -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"Name" 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
name]
      )

instance Core.ToPath UpdateConnectorDefinition where
  toPath :: UpdateConnectorDefinition -> ByteString
toPath UpdateConnectorDefinition' {Maybe Text
Text
connectorDefinitionId :: Text
name :: Maybe Text
$sel:connectorDefinitionId:UpdateConnectorDefinition' :: UpdateConnectorDefinition -> Text
$sel:name:UpdateConnectorDefinition' :: UpdateConnectorDefinition -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/greengrass/definition/connectors/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
connectorDefinitionId
      ]

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

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

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

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

instance
  Prelude.NFData
    UpdateConnectorDefinitionResponse