{-# 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.ChimeSDKIdentity.UpdateAppInstance
-- 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 @AppInstance@ metadata.
module Amazonka.ChimeSDKIdentity.UpdateAppInstance
  ( -- * Creating a Request
    UpdateAppInstance (..),
    newUpdateAppInstance,

    -- * Request Lenses
    updateAppInstance_appInstanceArn,
    updateAppInstance_name,
    updateAppInstance_metadata,

    -- * Destructuring the Response
    UpdateAppInstanceResponse (..),
    newUpdateAppInstanceResponse,

    -- * Response Lenses
    updateAppInstanceResponse_appInstanceArn,
    updateAppInstanceResponse_httpStatus,
  )
where

import Amazonka.ChimeSDKIdentity.Types
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

-- | /See:/ 'newUpdateAppInstance' smart constructor.
data UpdateAppInstance = UpdateAppInstance'
  { -- | The ARN of the @AppInstance@.
    UpdateAppInstance -> Text
appInstanceArn :: Prelude.Text,
    -- | The name that you want to change.
    UpdateAppInstance -> Sensitive Text
name :: Data.Sensitive Prelude.Text,
    -- | The metadata that you want to change.
    UpdateAppInstance -> Sensitive Text
metadata :: Data.Sensitive Prelude.Text
  }
  deriving (UpdateAppInstance -> UpdateAppInstance -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateAppInstance -> UpdateAppInstance -> Bool
$c/= :: UpdateAppInstance -> UpdateAppInstance -> Bool
== :: UpdateAppInstance -> UpdateAppInstance -> Bool
$c== :: UpdateAppInstance -> UpdateAppInstance -> Bool
Prelude.Eq, Int -> UpdateAppInstance -> ShowS
[UpdateAppInstance] -> ShowS
UpdateAppInstance -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateAppInstance] -> ShowS
$cshowList :: [UpdateAppInstance] -> ShowS
show :: UpdateAppInstance -> String
$cshow :: UpdateAppInstance -> String
showsPrec :: Int -> UpdateAppInstance -> ShowS
$cshowsPrec :: Int -> UpdateAppInstance -> ShowS
Prelude.Show, forall x. Rep UpdateAppInstance x -> UpdateAppInstance
forall x. UpdateAppInstance -> Rep UpdateAppInstance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateAppInstance x -> UpdateAppInstance
$cfrom :: forall x. UpdateAppInstance -> Rep UpdateAppInstance x
Prelude.Generic)

-- |
-- Create a value of 'UpdateAppInstance' 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:
--
-- 'appInstanceArn', 'updateAppInstance_appInstanceArn' - The ARN of the @AppInstance@.
--
-- 'name', 'updateAppInstance_name' - The name that you want to change.
--
-- 'metadata', 'updateAppInstance_metadata' - The metadata that you want to change.
newUpdateAppInstance ::
  -- | 'appInstanceArn'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  -- | 'metadata'
  Prelude.Text ->
  UpdateAppInstance
newUpdateAppInstance :: Text -> Text -> Text -> UpdateAppInstance
newUpdateAppInstance
  Text
pAppInstanceArn_
  Text
pName_
  Text
pMetadata_ =
    UpdateAppInstance'
      { $sel:appInstanceArn:UpdateAppInstance' :: Text
appInstanceArn =
          Text
pAppInstanceArn_,
        $sel:name:UpdateAppInstance' :: Sensitive Text
name = forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pName_,
        $sel:metadata:UpdateAppInstance' :: Sensitive Text
metadata = forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pMetadata_
      }

-- | The ARN of the @AppInstance@.
updateAppInstance_appInstanceArn :: Lens.Lens' UpdateAppInstance Prelude.Text
updateAppInstance_appInstanceArn :: Lens' UpdateAppInstance Text
updateAppInstance_appInstanceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAppInstance' {Text
appInstanceArn :: Text
$sel:appInstanceArn:UpdateAppInstance' :: UpdateAppInstance -> Text
appInstanceArn} -> Text
appInstanceArn) (\s :: UpdateAppInstance
s@UpdateAppInstance' {} Text
a -> UpdateAppInstance
s {$sel:appInstanceArn:UpdateAppInstance' :: Text
appInstanceArn = Text
a} :: UpdateAppInstance)

-- | The name that you want to change.
updateAppInstance_name :: Lens.Lens' UpdateAppInstance Prelude.Text
updateAppInstance_name :: Lens' UpdateAppInstance Text
updateAppInstance_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAppInstance' {Sensitive Text
name :: Sensitive Text
$sel:name:UpdateAppInstance' :: UpdateAppInstance -> Sensitive Text
name} -> Sensitive Text
name) (\s :: UpdateAppInstance
s@UpdateAppInstance' {} Sensitive Text
a -> UpdateAppInstance
s {$sel:name:UpdateAppInstance' :: Sensitive Text
name = Sensitive Text
a} :: UpdateAppInstance) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | The metadata that you want to change.
updateAppInstance_metadata :: Lens.Lens' UpdateAppInstance Prelude.Text
updateAppInstance_metadata :: Lens' UpdateAppInstance Text
updateAppInstance_metadata = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAppInstance' {Sensitive Text
metadata :: Sensitive Text
$sel:metadata:UpdateAppInstance' :: UpdateAppInstance -> Sensitive Text
metadata} -> Sensitive Text
metadata) (\s :: UpdateAppInstance
s@UpdateAppInstance' {} Sensitive Text
a -> UpdateAppInstance
s {$sel:metadata:UpdateAppInstance' :: Sensitive Text
metadata = Sensitive Text
a} :: UpdateAppInstance) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

instance Core.AWSRequest UpdateAppInstance where
  type
    AWSResponse UpdateAppInstance =
      UpdateAppInstanceResponse
  request :: (Service -> Service)
-> UpdateAppInstance -> Request UpdateAppInstance
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 UpdateAppInstance
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateAppInstance)))
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 -> Int -> UpdateAppInstanceResponse
UpdateAppInstanceResponse'
            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
"AppInstanceArn")
            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 UpdateAppInstance where
  hashWithSalt :: Int -> UpdateAppInstance -> Int
hashWithSalt Int
_salt UpdateAppInstance' {Text
Sensitive Text
metadata :: Sensitive Text
name :: Sensitive Text
appInstanceArn :: Text
$sel:metadata:UpdateAppInstance' :: UpdateAppInstance -> Sensitive Text
$sel:name:UpdateAppInstance' :: UpdateAppInstance -> Sensitive Text
$sel:appInstanceArn:UpdateAppInstance' :: UpdateAppInstance -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
appInstanceArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
metadata

instance Prelude.NFData UpdateAppInstance where
  rnf :: UpdateAppInstance -> ()
rnf UpdateAppInstance' {Text
Sensitive Text
metadata :: Sensitive Text
name :: Sensitive Text
appInstanceArn :: Text
$sel:metadata:UpdateAppInstance' :: UpdateAppInstance -> Sensitive Text
$sel:name:UpdateAppInstance' :: UpdateAppInstance -> Sensitive Text
$sel:appInstanceArn:UpdateAppInstance' :: UpdateAppInstance -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
appInstanceArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
metadata

instance Data.ToHeaders UpdateAppInstance where
  toHeaders :: UpdateAppInstance -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToJSON UpdateAppInstance where
  toJSON :: UpdateAppInstance -> Value
toJSON UpdateAppInstance' {Text
Sensitive Text
metadata :: Sensitive Text
name :: Sensitive Text
appInstanceArn :: Text
$sel:metadata:UpdateAppInstance' :: UpdateAppInstance -> Sensitive Text
$sel:name:UpdateAppInstance' :: UpdateAppInstance -> Sensitive Text
$sel:appInstanceArn:UpdateAppInstance' :: UpdateAppInstance -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Metadata" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive Text
metadata)
          ]
      )

instance Data.ToPath UpdateAppInstance where
  toPath :: UpdateAppInstance -> ByteString
toPath UpdateAppInstance' {Text
Sensitive Text
metadata :: Sensitive Text
name :: Sensitive Text
appInstanceArn :: Text
$sel:metadata:UpdateAppInstance' :: UpdateAppInstance -> Sensitive Text
$sel:name:UpdateAppInstance' :: UpdateAppInstance -> Sensitive Text
$sel:appInstanceArn:UpdateAppInstance' :: UpdateAppInstance -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/app-instances/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
appInstanceArn]

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

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

-- |
-- Create a value of 'UpdateAppInstanceResponse' 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:
--
-- 'appInstanceArn', 'updateAppInstanceResponse_appInstanceArn' - The ARN of the @AppInstance@.
--
-- 'httpStatus', 'updateAppInstanceResponse_httpStatus' - The response's http status code.
newUpdateAppInstanceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateAppInstanceResponse
newUpdateAppInstanceResponse :: Int -> UpdateAppInstanceResponse
newUpdateAppInstanceResponse Int
pHttpStatus_ =
  UpdateAppInstanceResponse'
    { $sel:appInstanceArn:UpdateAppInstanceResponse' :: Maybe Text
appInstanceArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateAppInstanceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ARN of the @AppInstance@.
updateAppInstanceResponse_appInstanceArn :: Lens.Lens' UpdateAppInstanceResponse (Prelude.Maybe Prelude.Text)
updateAppInstanceResponse_appInstanceArn :: Lens' UpdateAppInstanceResponse (Maybe Text)
updateAppInstanceResponse_appInstanceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAppInstanceResponse' {Maybe Text
appInstanceArn :: Maybe Text
$sel:appInstanceArn:UpdateAppInstanceResponse' :: UpdateAppInstanceResponse -> Maybe Text
appInstanceArn} -> Maybe Text
appInstanceArn) (\s :: UpdateAppInstanceResponse
s@UpdateAppInstanceResponse' {} Maybe Text
a -> UpdateAppInstanceResponse
s {$sel:appInstanceArn:UpdateAppInstanceResponse' :: Maybe Text
appInstanceArn = Maybe Text
a} :: UpdateAppInstanceResponse)

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

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