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

    -- * Request Lenses
    updateAppInstance_metadata,
    updateAppInstance_appInstanceArn,
    updateAppInstance_name,

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

    -- * Response Lenses
    updateAppInstanceResponse_appInstanceArn,
    updateAppInstanceResponse_httpStatus,
  )
where

import Amazonka.Chime.Types
import qualified Amazonka.Core as Core
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:/ 'newUpdateAppInstance' smart constructor.
data UpdateAppInstance = UpdateAppInstance'
  { -- | The metadata that you want to change.
    UpdateAppInstance -> Maybe (Sensitive Text)
metadata :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The ARN of the @AppInstance@.
    UpdateAppInstance -> Text
appInstanceArn :: Prelude.Text,
    -- | The name that you want to change.
    UpdateAppInstance -> Sensitive Text
name :: Core.Sensitive Prelude.Text
  }
  deriving (UpdateAppInstance -> UpdateAppInstance -> Bool
(UpdateAppInstance -> UpdateAppInstance -> Bool)
-> (UpdateAppInstance -> UpdateAppInstance -> Bool)
-> Eq UpdateAppInstance
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
(Int -> UpdateAppInstance -> ShowS)
-> (UpdateAppInstance -> String)
-> ([UpdateAppInstance] -> ShowS)
-> Show UpdateAppInstance
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. UpdateAppInstance -> Rep UpdateAppInstance x)
-> (forall x. Rep UpdateAppInstance x -> UpdateAppInstance)
-> Generic UpdateAppInstance
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:
--
-- 'metadata', 'updateAppInstance_metadata' - The metadata that you want to change.
--
-- 'appInstanceArn', 'updateAppInstance_appInstanceArn' - The ARN of the @AppInstance@.
--
-- 'name', 'updateAppInstance_name' - The name that you want to change.
newUpdateAppInstance ::
  -- | 'appInstanceArn'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  UpdateAppInstance
newUpdateAppInstance :: Text -> Text -> UpdateAppInstance
newUpdateAppInstance Text
pAppInstanceArn_ Text
pName_ =
  UpdateAppInstance' :: Maybe (Sensitive Text)
-> Text -> Sensitive Text -> UpdateAppInstance
UpdateAppInstance'
    { $sel:metadata:UpdateAppInstance' :: Maybe (Sensitive Text)
metadata = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:appInstanceArn:UpdateAppInstance' :: Text
appInstanceArn = Text
pAppInstanceArn_,
      $sel:name:UpdateAppInstance' :: Sensitive Text
name = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pName_
    }

-- | The metadata that you want to change.
updateAppInstance_metadata :: Lens.Lens' UpdateAppInstance (Prelude.Maybe Prelude.Text)
updateAppInstance_metadata :: (Maybe Text -> f (Maybe Text))
-> UpdateAppInstance -> f UpdateAppInstance
updateAppInstance_metadata = (UpdateAppInstance -> Maybe (Sensitive Text))
-> (UpdateAppInstance
    -> Maybe (Sensitive Text) -> UpdateAppInstance)
-> Lens
     UpdateAppInstance
     UpdateAppInstance
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAppInstance' {Maybe (Sensitive Text)
metadata :: Maybe (Sensitive Text)
$sel:metadata:UpdateAppInstance' :: UpdateAppInstance -> Maybe (Sensitive Text)
metadata} -> Maybe (Sensitive Text)
metadata) (\s :: UpdateAppInstance
s@UpdateAppInstance' {} Maybe (Sensitive Text)
a -> UpdateAppInstance
s {$sel:metadata:UpdateAppInstance' :: Maybe (Sensitive Text)
metadata = Maybe (Sensitive Text)
a} :: UpdateAppInstance) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> UpdateAppInstance -> f UpdateAppInstance)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> UpdateAppInstance
-> f UpdateAppInstance
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The ARN of the @AppInstance@.
updateAppInstance_appInstanceArn :: Lens.Lens' UpdateAppInstance Prelude.Text
updateAppInstance_appInstanceArn :: (Text -> f Text) -> UpdateAppInstance -> f UpdateAppInstance
updateAppInstance_appInstanceArn = (UpdateAppInstance -> Text)
-> (UpdateAppInstance -> Text -> UpdateAppInstance)
-> Lens UpdateAppInstance UpdateAppInstance Text Text
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 :: (Text -> f Text) -> UpdateAppInstance -> f UpdateAppInstance
updateAppInstance_name = (UpdateAppInstance -> Sensitive Text)
-> (UpdateAppInstance -> Sensitive Text -> UpdateAppInstance)
-> Lens
     UpdateAppInstance
     UpdateAppInstance
     (Sensitive Text)
     (Sensitive Text)
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) ((Sensitive Text -> f (Sensitive Text))
 -> UpdateAppInstance -> f UpdateAppInstance)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> UpdateAppInstance
-> f UpdateAppInstance
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

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

instance Prelude.NFData UpdateAppInstance

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

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

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

instance Core.ToQuery UpdateAppInstance where
  toQuery :: UpdateAppInstance -> QueryString
toQuery = QueryString -> UpdateAppInstance -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(UpdateAppInstanceResponse -> UpdateAppInstanceResponse -> Bool)
-> (UpdateAppInstanceResponse -> UpdateAppInstanceResponse -> Bool)
-> Eq UpdateAppInstanceResponse
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]
(Int -> ReadS UpdateAppInstanceResponse)
-> ReadS [UpdateAppInstanceResponse]
-> ReadPrec UpdateAppInstanceResponse
-> ReadPrec [UpdateAppInstanceResponse]
-> Read 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
(Int -> UpdateAppInstanceResponse -> ShowS)
-> (UpdateAppInstanceResponse -> String)
-> ([UpdateAppInstanceResponse] -> ShowS)
-> Show UpdateAppInstanceResponse
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.
 UpdateAppInstanceResponse -> Rep UpdateAppInstanceResponse x)
-> (forall x.
    Rep UpdateAppInstanceResponse x -> UpdateAppInstanceResponse)
-> Generic UpdateAppInstanceResponse
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' :: Maybe Text -> Int -> UpdateAppInstanceResponse
UpdateAppInstanceResponse'
    { $sel:appInstanceArn:UpdateAppInstanceResponse' :: Maybe Text
appInstanceArn =
        Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> UpdateAppInstanceResponse -> f UpdateAppInstanceResponse
updateAppInstanceResponse_appInstanceArn = (UpdateAppInstanceResponse -> Maybe Text)
-> (UpdateAppInstanceResponse
    -> Maybe Text -> UpdateAppInstanceResponse)
-> Lens
     UpdateAppInstanceResponse
     UpdateAppInstanceResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Int -> f Int)
-> UpdateAppInstanceResponse -> f UpdateAppInstanceResponse
updateAppInstanceResponse_httpStatus = (UpdateAppInstanceResponse -> Int)
-> (UpdateAppInstanceResponse -> Int -> UpdateAppInstanceResponse)
-> Lens UpdateAppInstanceResponse UpdateAppInstanceResponse Int Int
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