{-# 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.IoTSiteWise.UpdateProject
-- 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 an IoT SiteWise Monitor project.
module Amazonka.IoTSiteWise.UpdateProject
  ( -- * Creating a Request
    UpdateProject (..),
    newUpdateProject,

    -- * Request Lenses
    updateProject_clientToken,
    updateProject_projectDescription,
    updateProject_projectId,
    updateProject_projectName,

    -- * Destructuring the Response
    UpdateProjectResponse (..),
    newUpdateProjectResponse,

    -- * Response Lenses
    updateProjectResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.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:/ 'newUpdateProject' smart constructor.
data UpdateProject = UpdateProject'
  { -- | A unique case-sensitive identifier that you can provide to ensure the
    -- idempotency of the request. Don\'t reuse this client token if a new
    -- idempotent request is required.
    UpdateProject -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | A new description for the project.
    UpdateProject -> Maybe Text
projectDescription :: Prelude.Maybe Prelude.Text,
    -- | The ID of the project to update.
    UpdateProject -> Text
projectId :: Prelude.Text,
    -- | A new friendly name for the project.
    UpdateProject -> Text
projectName :: Prelude.Text
  }
  deriving (UpdateProject -> UpdateProject -> Bool
(UpdateProject -> UpdateProject -> Bool)
-> (UpdateProject -> UpdateProject -> Bool) -> Eq UpdateProject
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateProject -> UpdateProject -> Bool
$c/= :: UpdateProject -> UpdateProject -> Bool
== :: UpdateProject -> UpdateProject -> Bool
$c== :: UpdateProject -> UpdateProject -> Bool
Prelude.Eq, ReadPrec [UpdateProject]
ReadPrec UpdateProject
Int -> ReadS UpdateProject
ReadS [UpdateProject]
(Int -> ReadS UpdateProject)
-> ReadS [UpdateProject]
-> ReadPrec UpdateProject
-> ReadPrec [UpdateProject]
-> Read UpdateProject
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateProject]
$creadListPrec :: ReadPrec [UpdateProject]
readPrec :: ReadPrec UpdateProject
$creadPrec :: ReadPrec UpdateProject
readList :: ReadS [UpdateProject]
$creadList :: ReadS [UpdateProject]
readsPrec :: Int -> ReadS UpdateProject
$creadsPrec :: Int -> ReadS UpdateProject
Prelude.Read, Int -> UpdateProject -> ShowS
[UpdateProject] -> ShowS
UpdateProject -> String
(Int -> UpdateProject -> ShowS)
-> (UpdateProject -> String)
-> ([UpdateProject] -> ShowS)
-> Show UpdateProject
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateProject] -> ShowS
$cshowList :: [UpdateProject] -> ShowS
show :: UpdateProject -> String
$cshow :: UpdateProject -> String
showsPrec :: Int -> UpdateProject -> ShowS
$cshowsPrec :: Int -> UpdateProject -> ShowS
Prelude.Show, (forall x. UpdateProject -> Rep UpdateProject x)
-> (forall x. Rep UpdateProject x -> UpdateProject)
-> Generic UpdateProject
forall x. Rep UpdateProject x -> UpdateProject
forall x. UpdateProject -> Rep UpdateProject x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateProject x -> UpdateProject
$cfrom :: forall x. UpdateProject -> Rep UpdateProject x
Prelude.Generic)

-- |
-- Create a value of 'UpdateProject' 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:
--
-- 'clientToken', 'updateProject_clientToken' - A unique case-sensitive identifier that you can provide to ensure the
-- idempotency of the request. Don\'t reuse this client token if a new
-- idempotent request is required.
--
-- 'projectDescription', 'updateProject_projectDescription' - A new description for the project.
--
-- 'projectId', 'updateProject_projectId' - The ID of the project to update.
--
-- 'projectName', 'updateProject_projectName' - A new friendly name for the project.
newUpdateProject ::
  -- | 'projectId'
  Prelude.Text ->
  -- | 'projectName'
  Prelude.Text ->
  UpdateProject
newUpdateProject :: Text -> Text -> UpdateProject
newUpdateProject Text
pProjectId_ Text
pProjectName_ =
  UpdateProject' :: Maybe Text -> Maybe Text -> Text -> Text -> UpdateProject
UpdateProject'
    { $sel:clientToken:UpdateProject' :: Maybe Text
clientToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:projectDescription:UpdateProject' :: Maybe Text
projectDescription = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:projectId:UpdateProject' :: Text
projectId = Text
pProjectId_,
      $sel:projectName:UpdateProject' :: Text
projectName = Text
pProjectName_
    }

-- | A unique case-sensitive identifier that you can provide to ensure the
-- idempotency of the request. Don\'t reuse this client token if a new
-- idempotent request is required.
updateProject_clientToken :: Lens.Lens' UpdateProject (Prelude.Maybe Prelude.Text)
updateProject_clientToken :: (Maybe Text -> f (Maybe Text)) -> UpdateProject -> f UpdateProject
updateProject_clientToken = (UpdateProject -> Maybe Text)
-> (UpdateProject -> Maybe Text -> UpdateProject)
-> Lens UpdateProject UpdateProject (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateProject' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:UpdateProject' :: UpdateProject -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: UpdateProject
s@UpdateProject' {} Maybe Text
a -> UpdateProject
s {$sel:clientToken:UpdateProject' :: Maybe Text
clientToken = Maybe Text
a} :: UpdateProject)

-- | A new description for the project.
updateProject_projectDescription :: Lens.Lens' UpdateProject (Prelude.Maybe Prelude.Text)
updateProject_projectDescription :: (Maybe Text -> f (Maybe Text)) -> UpdateProject -> f UpdateProject
updateProject_projectDescription = (UpdateProject -> Maybe Text)
-> (UpdateProject -> Maybe Text -> UpdateProject)
-> Lens UpdateProject UpdateProject (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateProject' {Maybe Text
projectDescription :: Maybe Text
$sel:projectDescription:UpdateProject' :: UpdateProject -> Maybe Text
projectDescription} -> Maybe Text
projectDescription) (\s :: UpdateProject
s@UpdateProject' {} Maybe Text
a -> UpdateProject
s {$sel:projectDescription:UpdateProject' :: Maybe Text
projectDescription = Maybe Text
a} :: UpdateProject)

-- | The ID of the project to update.
updateProject_projectId :: Lens.Lens' UpdateProject Prelude.Text
updateProject_projectId :: (Text -> f Text) -> UpdateProject -> f UpdateProject
updateProject_projectId = (UpdateProject -> Text)
-> (UpdateProject -> Text -> UpdateProject)
-> Lens UpdateProject UpdateProject Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateProject' {Text
projectId :: Text
$sel:projectId:UpdateProject' :: UpdateProject -> Text
projectId} -> Text
projectId) (\s :: UpdateProject
s@UpdateProject' {} Text
a -> UpdateProject
s {$sel:projectId:UpdateProject' :: Text
projectId = Text
a} :: UpdateProject)

-- | A new friendly name for the project.
updateProject_projectName :: Lens.Lens' UpdateProject Prelude.Text
updateProject_projectName :: (Text -> f Text) -> UpdateProject -> f UpdateProject
updateProject_projectName = (UpdateProject -> Text)
-> (UpdateProject -> Text -> UpdateProject)
-> Lens UpdateProject UpdateProject Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateProject' {Text
projectName :: Text
$sel:projectName:UpdateProject' :: UpdateProject -> Text
projectName} -> Text
projectName) (\s :: UpdateProject
s@UpdateProject' {} Text
a -> UpdateProject
s {$sel:projectName:UpdateProject' :: Text
projectName = Text
a} :: UpdateProject)

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

instance Prelude.NFData UpdateProject

instance Core.ToHeaders UpdateProject where
  toHeaders :: UpdateProject -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateProject -> 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 UpdateProject where
  toJSON :: UpdateProject -> Value
toJSON UpdateProject' {Maybe Text
Text
projectName :: Text
projectId :: Text
projectDescription :: Maybe Text
clientToken :: Maybe Text
$sel:projectName:UpdateProject' :: UpdateProject -> Text
$sel:projectId:UpdateProject' :: UpdateProject -> Text
$sel:projectDescription:UpdateProject' :: UpdateProject -> Maybe Text
$sel:clientToken:UpdateProject' :: UpdateProject -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"clientToken" 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
clientToken,
            (Text
"projectDescription" 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
projectDescription,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"projectName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
projectName)
          ]
      )

instance Core.ToPath UpdateProject where
  toPath :: UpdateProject -> ByteString
toPath UpdateProject' {Maybe Text
Text
projectName :: Text
projectId :: Text
projectDescription :: Maybe Text
clientToken :: Maybe Text
$sel:projectName:UpdateProject' :: UpdateProject -> Text
$sel:projectId:UpdateProject' :: UpdateProject -> Text
$sel:projectDescription:UpdateProject' :: UpdateProject -> Maybe Text
$sel:clientToken:UpdateProject' :: UpdateProject -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/projects/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
projectId]

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

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

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

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

instance Prelude.NFData UpdateProjectResponse