{-# 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.Nimble.PutStudioMembers
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Add\/update users with given persona to studio membership.
module Amazonka.Nimble.PutStudioMembers
  ( -- * Creating a Request
    PutStudioMembers (..),
    newPutStudioMembers,

    -- * Request Lenses
    putStudioMembers_clientToken,
    putStudioMembers_identityStoreId,
    putStudioMembers_members,
    putStudioMembers_studioId,

    -- * Destructuring the Response
    PutStudioMembersResponse (..),
    newPutStudioMembersResponse,

    -- * Response Lenses
    putStudioMembersResponse_httpStatus,
  )
where

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

-- | /See:/ 'newPutStudioMembers' smart constructor.
data PutStudioMembers = PutStudioMembers'
  { -- | Unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the request. If you don’t specify a client token, the
    -- Amazon Web Services SDK automatically generates a client token and uses
    -- it for the request to ensure idempotency.
    PutStudioMembers -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The ID of the identity store.
    PutStudioMembers -> Text
identityStoreId :: Prelude.Text,
    -- | A list of members.
    PutStudioMembers -> NonEmpty NewStudioMember
members :: Prelude.NonEmpty NewStudioMember,
    -- | The studio ID.
    PutStudioMembers -> Text
studioId :: Prelude.Text
  }
  deriving (PutStudioMembers -> PutStudioMembers -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutStudioMembers -> PutStudioMembers -> Bool
$c/= :: PutStudioMembers -> PutStudioMembers -> Bool
== :: PutStudioMembers -> PutStudioMembers -> Bool
$c== :: PutStudioMembers -> PutStudioMembers -> Bool
Prelude.Eq, ReadPrec [PutStudioMembers]
ReadPrec PutStudioMembers
Int -> ReadS PutStudioMembers
ReadS [PutStudioMembers]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutStudioMembers]
$creadListPrec :: ReadPrec [PutStudioMembers]
readPrec :: ReadPrec PutStudioMembers
$creadPrec :: ReadPrec PutStudioMembers
readList :: ReadS [PutStudioMembers]
$creadList :: ReadS [PutStudioMembers]
readsPrec :: Int -> ReadS PutStudioMembers
$creadsPrec :: Int -> ReadS PutStudioMembers
Prelude.Read, Int -> PutStudioMembers -> ShowS
[PutStudioMembers] -> ShowS
PutStudioMembers -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutStudioMembers] -> ShowS
$cshowList :: [PutStudioMembers] -> ShowS
show :: PutStudioMembers -> String
$cshow :: PutStudioMembers -> String
showsPrec :: Int -> PutStudioMembers -> ShowS
$cshowsPrec :: Int -> PutStudioMembers -> ShowS
Prelude.Show, forall x. Rep PutStudioMembers x -> PutStudioMembers
forall x. PutStudioMembers -> Rep PutStudioMembers x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutStudioMembers x -> PutStudioMembers
$cfrom :: forall x. PutStudioMembers -> Rep PutStudioMembers x
Prelude.Generic)

-- |
-- Create a value of 'PutStudioMembers' 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', 'putStudioMembers_clientToken' - Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. If you don’t specify a client token, the
-- Amazon Web Services SDK automatically generates a client token and uses
-- it for the request to ensure idempotency.
--
-- 'identityStoreId', 'putStudioMembers_identityStoreId' - The ID of the identity store.
--
-- 'members', 'putStudioMembers_members' - A list of members.
--
-- 'studioId', 'putStudioMembers_studioId' - The studio ID.
newPutStudioMembers ::
  -- | 'identityStoreId'
  Prelude.Text ->
  -- | 'members'
  Prelude.NonEmpty NewStudioMember ->
  -- | 'studioId'
  Prelude.Text ->
  PutStudioMembers
newPutStudioMembers :: Text -> NonEmpty NewStudioMember -> Text -> PutStudioMembers
newPutStudioMembers
  Text
pIdentityStoreId_
  NonEmpty NewStudioMember
pMembers_
  Text
pStudioId_ =
    PutStudioMembers'
      { $sel:clientToken:PutStudioMembers' :: Maybe Text
clientToken = forall a. Maybe a
Prelude.Nothing,
        $sel:identityStoreId:PutStudioMembers' :: Text
identityStoreId = Text
pIdentityStoreId_,
        $sel:members:PutStudioMembers' :: NonEmpty NewStudioMember
members = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty NewStudioMember
pMembers_,
        $sel:studioId:PutStudioMembers' :: Text
studioId = Text
pStudioId_
      }

-- | Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. If you don’t specify a client token, the
-- Amazon Web Services SDK automatically generates a client token and uses
-- it for the request to ensure idempotency.
putStudioMembers_clientToken :: Lens.Lens' PutStudioMembers (Prelude.Maybe Prelude.Text)
putStudioMembers_clientToken :: Lens' PutStudioMembers (Maybe Text)
putStudioMembers_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutStudioMembers' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:PutStudioMembers' :: PutStudioMembers -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: PutStudioMembers
s@PutStudioMembers' {} Maybe Text
a -> PutStudioMembers
s {$sel:clientToken:PutStudioMembers' :: Maybe Text
clientToken = Maybe Text
a} :: PutStudioMembers)

-- | The ID of the identity store.
putStudioMembers_identityStoreId :: Lens.Lens' PutStudioMembers Prelude.Text
putStudioMembers_identityStoreId :: Lens' PutStudioMembers Text
putStudioMembers_identityStoreId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutStudioMembers' {Text
identityStoreId :: Text
$sel:identityStoreId:PutStudioMembers' :: PutStudioMembers -> Text
identityStoreId} -> Text
identityStoreId) (\s :: PutStudioMembers
s@PutStudioMembers' {} Text
a -> PutStudioMembers
s {$sel:identityStoreId:PutStudioMembers' :: Text
identityStoreId = Text
a} :: PutStudioMembers)

-- | A list of members.
putStudioMembers_members :: Lens.Lens' PutStudioMembers (Prelude.NonEmpty NewStudioMember)
putStudioMembers_members :: Lens' PutStudioMembers (NonEmpty NewStudioMember)
putStudioMembers_members = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutStudioMembers' {NonEmpty NewStudioMember
members :: NonEmpty NewStudioMember
$sel:members:PutStudioMembers' :: PutStudioMembers -> NonEmpty NewStudioMember
members} -> NonEmpty NewStudioMember
members) (\s :: PutStudioMembers
s@PutStudioMembers' {} NonEmpty NewStudioMember
a -> PutStudioMembers
s {$sel:members:PutStudioMembers' :: NonEmpty NewStudioMember
members = NonEmpty NewStudioMember
a} :: PutStudioMembers) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The studio ID.
putStudioMembers_studioId :: Lens.Lens' PutStudioMembers Prelude.Text
putStudioMembers_studioId :: Lens' PutStudioMembers Text
putStudioMembers_studioId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutStudioMembers' {Text
studioId :: Text
$sel:studioId:PutStudioMembers' :: PutStudioMembers -> Text
studioId} -> Text
studioId) (\s :: PutStudioMembers
s@PutStudioMembers' {} Text
a -> PutStudioMembers
s {$sel:studioId:PutStudioMembers' :: Text
studioId = Text
a} :: PutStudioMembers)

instance Core.AWSRequest PutStudioMembers where
  type
    AWSResponse PutStudioMembers =
      PutStudioMembersResponse
  request :: (Service -> Service)
-> PutStudioMembers -> Request PutStudioMembers
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 PutStudioMembers
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutStudioMembers)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> PutStudioMembersResponse
PutStudioMembersResponse'
            forall (f :: * -> *) a b. Functor 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 PutStudioMembers where
  hashWithSalt :: Int -> PutStudioMembers -> Int
hashWithSalt Int
_salt PutStudioMembers' {Maybe Text
NonEmpty NewStudioMember
Text
studioId :: Text
members :: NonEmpty NewStudioMember
identityStoreId :: Text
clientToken :: Maybe Text
$sel:studioId:PutStudioMembers' :: PutStudioMembers -> Text
$sel:members:PutStudioMembers' :: PutStudioMembers -> NonEmpty NewStudioMember
$sel:identityStoreId:PutStudioMembers' :: PutStudioMembers -> Text
$sel:clientToken:PutStudioMembers' :: PutStudioMembers -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
identityStoreId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty NewStudioMember
members
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
studioId

instance Prelude.NFData PutStudioMembers where
  rnf :: PutStudioMembers -> ()
rnf PutStudioMembers' {Maybe Text
NonEmpty NewStudioMember
Text
studioId :: Text
members :: NonEmpty NewStudioMember
identityStoreId :: Text
clientToken :: Maybe Text
$sel:studioId:PutStudioMembers' :: PutStudioMembers -> Text
$sel:members:PutStudioMembers' :: PutStudioMembers -> NonEmpty NewStudioMember
$sel:identityStoreId:PutStudioMembers' :: PutStudioMembers -> Text
$sel:clientToken:PutStudioMembers' :: PutStudioMembers -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
identityStoreId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty NewStudioMember
members
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
studioId

instance Data.ToHeaders PutStudioMembers where
  toHeaders :: PutStudioMembers -> ResponseHeaders
toHeaders PutStudioMembers' {Maybe Text
NonEmpty NewStudioMember
Text
studioId :: Text
members :: NonEmpty NewStudioMember
identityStoreId :: Text
clientToken :: Maybe Text
$sel:studioId:PutStudioMembers' :: PutStudioMembers -> Text
$sel:members:PutStudioMembers' :: PutStudioMembers -> NonEmpty NewStudioMember
$sel:identityStoreId:PutStudioMembers' :: PutStudioMembers -> Text
$sel:clientToken:PutStudioMembers' :: PutStudioMembers -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"X-Amz-Client-Token" forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# Maybe Text
clientToken,
        HeaderName
"Content-Type"
          forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"application/x-amz-json-1.1" :: Prelude.ByteString)
      ]

instance Data.ToJSON PutStudioMembers where
  toJSON :: PutStudioMembers -> Value
toJSON PutStudioMembers' {Maybe Text
NonEmpty NewStudioMember
Text
studioId :: Text
members :: NonEmpty NewStudioMember
identityStoreId :: Text
clientToken :: Maybe Text
$sel:studioId:PutStudioMembers' :: PutStudioMembers -> Text
$sel:members:PutStudioMembers' :: PutStudioMembers -> NonEmpty NewStudioMember
$sel:identityStoreId:PutStudioMembers' :: PutStudioMembers -> Text
$sel:clientToken:PutStudioMembers' :: PutStudioMembers -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"identityStoreId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
identityStoreId),
            forall a. a -> Maybe a
Prelude.Just (Key
"members" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty NewStudioMember
members)
          ]
      )

instance Data.ToPath PutStudioMembers where
  toPath :: PutStudioMembers -> ByteString
toPath PutStudioMembers' {Maybe Text
NonEmpty NewStudioMember
Text
studioId :: Text
members :: NonEmpty NewStudioMember
identityStoreId :: Text
clientToken :: Maybe Text
$sel:studioId:PutStudioMembers' :: PutStudioMembers -> Text
$sel:members:PutStudioMembers' :: PutStudioMembers -> NonEmpty NewStudioMember
$sel:identityStoreId:PutStudioMembers' :: PutStudioMembers -> Text
$sel:clientToken:PutStudioMembers' :: PutStudioMembers -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2020-08-01/studios/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
studioId,
        ByteString
"/membership"
      ]

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

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

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

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

instance Prelude.NFData PutStudioMembersResponse where
  rnf :: PutStudioMembersResponse -> ()
rnf PutStudioMembersResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutStudioMembersResponse' :: PutStudioMembersResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus