{-# 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.CreateAppInstanceAdmin
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Promotes an @AppInstanceUser@ to an @AppInstanceAdmin@. The promoted
-- user can perform the following actions.
--
-- -   @ChannelModerator@ actions across all channels in the @AppInstance@.
--
-- -   @DeleteChannelMessage@ actions.
--
-- Only an @AppInstanceUser@ can be promoted to an @AppInstanceAdmin@ role.
module Amazonka.ChimeSDKIdentity.CreateAppInstanceAdmin
  ( -- * Creating a Request
    CreateAppInstanceAdmin (..),
    newCreateAppInstanceAdmin,

    -- * Request Lenses
    createAppInstanceAdmin_appInstanceAdminArn,
    createAppInstanceAdmin_appInstanceArn,

    -- * Destructuring the Response
    CreateAppInstanceAdminResponse (..),
    newCreateAppInstanceAdminResponse,

    -- * Response Lenses
    createAppInstanceAdminResponse_appInstanceAdmin,
    createAppInstanceAdminResponse_appInstanceArn,
    createAppInstanceAdminResponse_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:/ 'newCreateAppInstanceAdmin' smart constructor.
data CreateAppInstanceAdmin = CreateAppInstanceAdmin'
  { -- | The ARN of the administrator of the current @AppInstance@.
    CreateAppInstanceAdmin -> Text
appInstanceAdminArn :: Prelude.Text,
    -- | The ARN of the @AppInstance@.
    CreateAppInstanceAdmin -> Text
appInstanceArn :: Prelude.Text
  }
  deriving (CreateAppInstanceAdmin -> CreateAppInstanceAdmin -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateAppInstanceAdmin -> CreateAppInstanceAdmin -> Bool
$c/= :: CreateAppInstanceAdmin -> CreateAppInstanceAdmin -> Bool
== :: CreateAppInstanceAdmin -> CreateAppInstanceAdmin -> Bool
$c== :: CreateAppInstanceAdmin -> CreateAppInstanceAdmin -> Bool
Prelude.Eq, ReadPrec [CreateAppInstanceAdmin]
ReadPrec CreateAppInstanceAdmin
Int -> ReadS CreateAppInstanceAdmin
ReadS [CreateAppInstanceAdmin]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateAppInstanceAdmin]
$creadListPrec :: ReadPrec [CreateAppInstanceAdmin]
readPrec :: ReadPrec CreateAppInstanceAdmin
$creadPrec :: ReadPrec CreateAppInstanceAdmin
readList :: ReadS [CreateAppInstanceAdmin]
$creadList :: ReadS [CreateAppInstanceAdmin]
readsPrec :: Int -> ReadS CreateAppInstanceAdmin
$creadsPrec :: Int -> ReadS CreateAppInstanceAdmin
Prelude.Read, Int -> CreateAppInstanceAdmin -> ShowS
[CreateAppInstanceAdmin] -> ShowS
CreateAppInstanceAdmin -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateAppInstanceAdmin] -> ShowS
$cshowList :: [CreateAppInstanceAdmin] -> ShowS
show :: CreateAppInstanceAdmin -> String
$cshow :: CreateAppInstanceAdmin -> String
showsPrec :: Int -> CreateAppInstanceAdmin -> ShowS
$cshowsPrec :: Int -> CreateAppInstanceAdmin -> ShowS
Prelude.Show, forall x. Rep CreateAppInstanceAdmin x -> CreateAppInstanceAdmin
forall x. CreateAppInstanceAdmin -> Rep CreateAppInstanceAdmin x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateAppInstanceAdmin x -> CreateAppInstanceAdmin
$cfrom :: forall x. CreateAppInstanceAdmin -> Rep CreateAppInstanceAdmin x
Prelude.Generic)

-- |
-- Create a value of 'CreateAppInstanceAdmin' 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:
--
-- 'appInstanceAdminArn', 'createAppInstanceAdmin_appInstanceAdminArn' - The ARN of the administrator of the current @AppInstance@.
--
-- 'appInstanceArn', 'createAppInstanceAdmin_appInstanceArn' - The ARN of the @AppInstance@.
newCreateAppInstanceAdmin ::
  -- | 'appInstanceAdminArn'
  Prelude.Text ->
  -- | 'appInstanceArn'
  Prelude.Text ->
  CreateAppInstanceAdmin
newCreateAppInstanceAdmin :: Text -> Text -> CreateAppInstanceAdmin
newCreateAppInstanceAdmin
  Text
pAppInstanceAdminArn_
  Text
pAppInstanceArn_ =
    CreateAppInstanceAdmin'
      { $sel:appInstanceAdminArn:CreateAppInstanceAdmin' :: Text
appInstanceAdminArn =
          Text
pAppInstanceAdminArn_,
        $sel:appInstanceArn:CreateAppInstanceAdmin' :: Text
appInstanceArn = Text
pAppInstanceArn_
      }

-- | The ARN of the administrator of the current @AppInstance@.
createAppInstanceAdmin_appInstanceAdminArn :: Lens.Lens' CreateAppInstanceAdmin Prelude.Text
createAppInstanceAdmin_appInstanceAdminArn :: Lens' CreateAppInstanceAdmin Text
createAppInstanceAdmin_appInstanceAdminArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAppInstanceAdmin' {Text
appInstanceAdminArn :: Text
$sel:appInstanceAdminArn:CreateAppInstanceAdmin' :: CreateAppInstanceAdmin -> Text
appInstanceAdminArn} -> Text
appInstanceAdminArn) (\s :: CreateAppInstanceAdmin
s@CreateAppInstanceAdmin' {} Text
a -> CreateAppInstanceAdmin
s {$sel:appInstanceAdminArn:CreateAppInstanceAdmin' :: Text
appInstanceAdminArn = Text
a} :: CreateAppInstanceAdmin)

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

instance Core.AWSRequest CreateAppInstanceAdmin where
  type
    AWSResponse CreateAppInstanceAdmin =
      CreateAppInstanceAdminResponse
  request :: (Service -> Service)
-> CreateAppInstanceAdmin -> Request CreateAppInstanceAdmin
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateAppInstanceAdmin
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateAppInstanceAdmin)))
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 Identity
-> Maybe Text -> Int -> CreateAppInstanceAdminResponse
CreateAppInstanceAdminResponse'
            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
"AppInstanceAdmin")
            forall (f :: * -> *) a b. Applicative f => 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 CreateAppInstanceAdmin where
  hashWithSalt :: Int -> CreateAppInstanceAdmin -> Int
hashWithSalt Int
_salt CreateAppInstanceAdmin' {Text
appInstanceArn :: Text
appInstanceAdminArn :: Text
$sel:appInstanceArn:CreateAppInstanceAdmin' :: CreateAppInstanceAdmin -> Text
$sel:appInstanceAdminArn:CreateAppInstanceAdmin' :: CreateAppInstanceAdmin -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
appInstanceAdminArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
appInstanceArn

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

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

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

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

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

-- | /See:/ 'newCreateAppInstanceAdminResponse' smart constructor.
data CreateAppInstanceAdminResponse = CreateAppInstanceAdminResponse'
  { -- | The name and ARN of the admin for the @AppInstance@.
    CreateAppInstanceAdminResponse -> Maybe Identity
appInstanceAdmin :: Prelude.Maybe Identity,
    -- | The ARN of the of the admin for the @AppInstance@.
    CreateAppInstanceAdminResponse -> Maybe Text
appInstanceArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateAppInstanceAdminResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateAppInstanceAdminResponse
-> CreateAppInstanceAdminResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateAppInstanceAdminResponse
-> CreateAppInstanceAdminResponse -> Bool
$c/= :: CreateAppInstanceAdminResponse
-> CreateAppInstanceAdminResponse -> Bool
== :: CreateAppInstanceAdminResponse
-> CreateAppInstanceAdminResponse -> Bool
$c== :: CreateAppInstanceAdminResponse
-> CreateAppInstanceAdminResponse -> Bool
Prelude.Eq, Int -> CreateAppInstanceAdminResponse -> ShowS
[CreateAppInstanceAdminResponse] -> ShowS
CreateAppInstanceAdminResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateAppInstanceAdminResponse] -> ShowS
$cshowList :: [CreateAppInstanceAdminResponse] -> ShowS
show :: CreateAppInstanceAdminResponse -> String
$cshow :: CreateAppInstanceAdminResponse -> String
showsPrec :: Int -> CreateAppInstanceAdminResponse -> ShowS
$cshowsPrec :: Int -> CreateAppInstanceAdminResponse -> ShowS
Prelude.Show, forall x.
Rep CreateAppInstanceAdminResponse x
-> CreateAppInstanceAdminResponse
forall x.
CreateAppInstanceAdminResponse
-> Rep CreateAppInstanceAdminResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateAppInstanceAdminResponse x
-> CreateAppInstanceAdminResponse
$cfrom :: forall x.
CreateAppInstanceAdminResponse
-> Rep CreateAppInstanceAdminResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateAppInstanceAdminResponse' 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:
--
-- 'appInstanceAdmin', 'createAppInstanceAdminResponse_appInstanceAdmin' - The name and ARN of the admin for the @AppInstance@.
--
-- 'appInstanceArn', 'createAppInstanceAdminResponse_appInstanceArn' - The ARN of the of the admin for the @AppInstance@.
--
-- 'httpStatus', 'createAppInstanceAdminResponse_httpStatus' - The response's http status code.
newCreateAppInstanceAdminResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateAppInstanceAdminResponse
newCreateAppInstanceAdminResponse :: Int -> CreateAppInstanceAdminResponse
newCreateAppInstanceAdminResponse Int
pHttpStatus_ =
  CreateAppInstanceAdminResponse'
    { $sel:appInstanceAdmin:CreateAppInstanceAdminResponse' :: Maybe Identity
appInstanceAdmin =
        forall a. Maybe a
Prelude.Nothing,
      $sel:appInstanceArn:CreateAppInstanceAdminResponse' :: Maybe Text
appInstanceArn = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateAppInstanceAdminResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The name and ARN of the admin for the @AppInstance@.
createAppInstanceAdminResponse_appInstanceAdmin :: Lens.Lens' CreateAppInstanceAdminResponse (Prelude.Maybe Identity)
createAppInstanceAdminResponse_appInstanceAdmin :: Lens' CreateAppInstanceAdminResponse (Maybe Identity)
createAppInstanceAdminResponse_appInstanceAdmin = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAppInstanceAdminResponse' {Maybe Identity
appInstanceAdmin :: Maybe Identity
$sel:appInstanceAdmin:CreateAppInstanceAdminResponse' :: CreateAppInstanceAdminResponse -> Maybe Identity
appInstanceAdmin} -> Maybe Identity
appInstanceAdmin) (\s :: CreateAppInstanceAdminResponse
s@CreateAppInstanceAdminResponse' {} Maybe Identity
a -> CreateAppInstanceAdminResponse
s {$sel:appInstanceAdmin:CreateAppInstanceAdminResponse' :: Maybe Identity
appInstanceAdmin = Maybe Identity
a} :: CreateAppInstanceAdminResponse)

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

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

instance
  Prelude.NFData
    CreateAppInstanceAdminResponse
  where
  rnf :: CreateAppInstanceAdminResponse -> ()
rnf CreateAppInstanceAdminResponse' {Int
Maybe Text
Maybe Identity
httpStatus :: Int
appInstanceArn :: Maybe Text
appInstanceAdmin :: Maybe Identity
$sel:httpStatus:CreateAppInstanceAdminResponse' :: CreateAppInstanceAdminResponse -> Int
$sel:appInstanceArn:CreateAppInstanceAdminResponse' :: CreateAppInstanceAdminResponse -> Maybe Text
$sel:appInstanceAdmin:CreateAppInstanceAdminResponse' :: CreateAppInstanceAdminResponse -> Maybe Identity
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Identity
appInstanceAdmin
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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