{-# 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.ServiceCatalogAppRegistry.UpdateApplication
-- 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 an existing application with new attributes.
module Amazonka.ServiceCatalogAppRegistry.UpdateApplication
  ( -- * Creating a Request
    UpdateApplication (..),
    newUpdateApplication,

    -- * Request Lenses
    updateApplication_description,
    updateApplication_name,
    updateApplication_application,

    -- * Destructuring the Response
    UpdateApplicationResponse (..),
    newUpdateApplicationResponse,

    -- * Response Lenses
    updateApplicationResponse_application,
    updateApplicationResponse_httpStatus,
  )
where

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

-- | /See:/ 'newUpdateApplication' smart constructor.
data UpdateApplication = UpdateApplication'
  { -- | The new description of the application.
    UpdateApplication -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | Deprecated: The new name of the application. The name must be unique in
    -- the region in which you are updating the application. Please do not use
    -- this field as we have stopped supporting name updates.
    UpdateApplication -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The name or ID of the application that will be updated.
    UpdateApplication -> Text
application :: Prelude.Text
  }
  deriving (UpdateApplication -> UpdateApplication -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateApplication -> UpdateApplication -> Bool
$c/= :: UpdateApplication -> UpdateApplication -> Bool
== :: UpdateApplication -> UpdateApplication -> Bool
$c== :: UpdateApplication -> UpdateApplication -> Bool
Prelude.Eq, ReadPrec [UpdateApplication]
ReadPrec UpdateApplication
Int -> ReadS UpdateApplication
ReadS [UpdateApplication]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateApplication]
$creadListPrec :: ReadPrec [UpdateApplication]
readPrec :: ReadPrec UpdateApplication
$creadPrec :: ReadPrec UpdateApplication
readList :: ReadS [UpdateApplication]
$creadList :: ReadS [UpdateApplication]
readsPrec :: Int -> ReadS UpdateApplication
$creadsPrec :: Int -> ReadS UpdateApplication
Prelude.Read, Int -> UpdateApplication -> ShowS
[UpdateApplication] -> ShowS
UpdateApplication -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateApplication] -> ShowS
$cshowList :: [UpdateApplication] -> ShowS
show :: UpdateApplication -> String
$cshow :: UpdateApplication -> String
showsPrec :: Int -> UpdateApplication -> ShowS
$cshowsPrec :: Int -> UpdateApplication -> ShowS
Prelude.Show, forall x. Rep UpdateApplication x -> UpdateApplication
forall x. UpdateApplication -> Rep UpdateApplication x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateApplication x -> UpdateApplication
$cfrom :: forall x. UpdateApplication -> Rep UpdateApplication x
Prelude.Generic)

-- |
-- Create a value of 'UpdateApplication' 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:
--
-- 'description', 'updateApplication_description' - The new description of the application.
--
-- 'name', 'updateApplication_name' - Deprecated: The new name of the application. The name must be unique in
-- the region in which you are updating the application. Please do not use
-- this field as we have stopped supporting name updates.
--
-- 'application', 'updateApplication_application' - The name or ID of the application that will be updated.
newUpdateApplication ::
  -- | 'application'
  Prelude.Text ->
  UpdateApplication
newUpdateApplication :: Text -> UpdateApplication
newUpdateApplication Text
pApplication_ =
  UpdateApplication'
    { $sel:description:UpdateApplication' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:name:UpdateApplication' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:application:UpdateApplication' :: Text
application = Text
pApplication_
    }

-- | The new description of the application.
updateApplication_description :: Lens.Lens' UpdateApplication (Prelude.Maybe Prelude.Text)
updateApplication_description :: Lens' UpdateApplication (Maybe Text)
updateApplication_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateApplication' {Maybe Text
description :: Maybe Text
$sel:description:UpdateApplication' :: UpdateApplication -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdateApplication
s@UpdateApplication' {} Maybe Text
a -> UpdateApplication
s {$sel:description:UpdateApplication' :: Maybe Text
description = Maybe Text
a} :: UpdateApplication)

-- | Deprecated: The new name of the application. The name must be unique in
-- the region in which you are updating the application. Please do not use
-- this field as we have stopped supporting name updates.
updateApplication_name :: Lens.Lens' UpdateApplication (Prelude.Maybe Prelude.Text)
updateApplication_name :: Lens' UpdateApplication (Maybe Text)
updateApplication_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateApplication' {Maybe Text
name :: Maybe Text
$sel:name:UpdateApplication' :: UpdateApplication -> Maybe Text
name} -> Maybe Text
name) (\s :: UpdateApplication
s@UpdateApplication' {} Maybe Text
a -> UpdateApplication
s {$sel:name:UpdateApplication' :: Maybe Text
name = Maybe Text
a} :: UpdateApplication)

-- | The name or ID of the application that will be updated.
updateApplication_application :: Lens.Lens' UpdateApplication Prelude.Text
updateApplication_application :: Lens' UpdateApplication Text
updateApplication_application = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateApplication' {Text
application :: Text
$sel:application:UpdateApplication' :: UpdateApplication -> Text
application} -> Text
application) (\s :: UpdateApplication
s@UpdateApplication' {} Text
a -> UpdateApplication
s {$sel:application:UpdateApplication' :: Text
application = Text
a} :: UpdateApplication)

instance Core.AWSRequest UpdateApplication where
  type
    AWSResponse UpdateApplication =
      UpdateApplicationResponse
  request :: (Service -> Service)
-> UpdateApplication -> Request UpdateApplication
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateApplication
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateApplication)))
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 Application -> Int -> UpdateApplicationResponse
UpdateApplicationResponse'
            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
"application")
            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 UpdateApplication where
  hashWithSalt :: Int -> UpdateApplication -> Int
hashWithSalt Int
_salt UpdateApplication' {Maybe Text
Text
application :: Text
name :: Maybe Text
description :: Maybe Text
$sel:application:UpdateApplication' :: UpdateApplication -> Text
$sel:name:UpdateApplication' :: UpdateApplication -> Maybe Text
$sel:description:UpdateApplication' :: UpdateApplication -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
application

instance Prelude.NFData UpdateApplication where
  rnf :: UpdateApplication -> ()
rnf UpdateApplication' {Maybe Text
Text
application :: Text
name :: Maybe Text
description :: Maybe Text
$sel:application:UpdateApplication' :: UpdateApplication -> Text
$sel:name:UpdateApplication' :: UpdateApplication -> Maybe Text
$sel:description:UpdateApplication' :: UpdateApplication -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
application

instance Data.ToHeaders UpdateApplication where
  toHeaders :: UpdateApplication -> 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 UpdateApplication where
  toJSON :: UpdateApplication -> Value
toJSON UpdateApplication' {Maybe Text
Text
application :: Text
name :: Maybe Text
description :: Maybe Text
$sel:application:UpdateApplication' :: UpdateApplication -> Text
$sel:name:UpdateApplication' :: UpdateApplication -> Maybe Text
$sel:description:UpdateApplication' :: UpdateApplication -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"description" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name
          ]
      )

instance Data.ToPath UpdateApplication where
  toPath :: UpdateApplication -> ByteString
toPath UpdateApplication' {Maybe Text
Text
application :: Text
name :: Maybe Text
description :: Maybe Text
$sel:application:UpdateApplication' :: UpdateApplication -> Text
$sel:name:UpdateApplication' :: UpdateApplication -> Maybe Text
$sel:description:UpdateApplication' :: UpdateApplication -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/applications/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
application]

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

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

-- |
-- Create a value of 'UpdateApplicationResponse' 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:
--
-- 'application', 'updateApplicationResponse_application' - The updated information of the application.
--
-- 'httpStatus', 'updateApplicationResponse_httpStatus' - The response's http status code.
newUpdateApplicationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateApplicationResponse
newUpdateApplicationResponse :: Int -> UpdateApplicationResponse
newUpdateApplicationResponse Int
pHttpStatus_ =
  UpdateApplicationResponse'
    { $sel:application:UpdateApplicationResponse' :: Maybe Application
application =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateApplicationResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The updated information of the application.
updateApplicationResponse_application :: Lens.Lens' UpdateApplicationResponse (Prelude.Maybe Application)
updateApplicationResponse_application :: Lens' UpdateApplicationResponse (Maybe Application)
updateApplicationResponse_application = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateApplicationResponse' {Maybe Application
application :: Maybe Application
$sel:application:UpdateApplicationResponse' :: UpdateApplicationResponse -> Maybe Application
application} -> Maybe Application
application) (\s :: UpdateApplicationResponse
s@UpdateApplicationResponse' {} Maybe Application
a -> UpdateApplicationResponse
s {$sel:application:UpdateApplicationResponse' :: Maybe Application
application = Maybe Application
a} :: UpdateApplicationResponse)

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

instance Prelude.NFData UpdateApplicationResponse where
  rnf :: UpdateApplicationResponse -> ()
rnf UpdateApplicationResponse' {Int
Maybe Application
httpStatus :: Int
application :: Maybe Application
$sel:httpStatus:UpdateApplicationResponse' :: UpdateApplicationResponse -> Int
$sel:application:UpdateApplicationResponse' :: UpdateApplicationResponse -> Maybe Application
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Application
application
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus