{-# 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.AssociateSigninDelegateGroupsWithAccount
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Associates the specified sign-in delegate groups with the specified
-- Amazon Chime account.
module Amazonka.Chime.AssociateSigninDelegateGroupsWithAccount
  ( -- * Creating a Request
    AssociateSigninDelegateGroupsWithAccount (..),
    newAssociateSigninDelegateGroupsWithAccount,

    -- * Request Lenses
    associateSigninDelegateGroupsWithAccount_accountId,
    associateSigninDelegateGroupsWithAccount_signinDelegateGroups,

    -- * Destructuring the Response
    AssociateSigninDelegateGroupsWithAccountResponse (..),
    newAssociateSigninDelegateGroupsWithAccountResponse,

    -- * Response Lenses
    associateSigninDelegateGroupsWithAccountResponse_httpStatus,
  )
where

import Amazonka.Chime.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:/ 'newAssociateSigninDelegateGroupsWithAccount' smart constructor.
data AssociateSigninDelegateGroupsWithAccount = AssociateSigninDelegateGroupsWithAccount'
  { -- | The Amazon Chime account ID.
    AssociateSigninDelegateGroupsWithAccount -> Text
accountId :: Prelude.Text,
    -- | The sign-in delegate groups.
    AssociateSigninDelegateGroupsWithAccount -> [SigninDelegateGroup]
signinDelegateGroups :: [SigninDelegateGroup]
  }
  deriving (AssociateSigninDelegateGroupsWithAccount
-> AssociateSigninDelegateGroupsWithAccount -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateSigninDelegateGroupsWithAccount
-> AssociateSigninDelegateGroupsWithAccount -> Bool
$c/= :: AssociateSigninDelegateGroupsWithAccount
-> AssociateSigninDelegateGroupsWithAccount -> Bool
== :: AssociateSigninDelegateGroupsWithAccount
-> AssociateSigninDelegateGroupsWithAccount -> Bool
$c== :: AssociateSigninDelegateGroupsWithAccount
-> AssociateSigninDelegateGroupsWithAccount -> Bool
Prelude.Eq, ReadPrec [AssociateSigninDelegateGroupsWithAccount]
ReadPrec AssociateSigninDelegateGroupsWithAccount
Int -> ReadS AssociateSigninDelegateGroupsWithAccount
ReadS [AssociateSigninDelegateGroupsWithAccount]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateSigninDelegateGroupsWithAccount]
$creadListPrec :: ReadPrec [AssociateSigninDelegateGroupsWithAccount]
readPrec :: ReadPrec AssociateSigninDelegateGroupsWithAccount
$creadPrec :: ReadPrec AssociateSigninDelegateGroupsWithAccount
readList :: ReadS [AssociateSigninDelegateGroupsWithAccount]
$creadList :: ReadS [AssociateSigninDelegateGroupsWithAccount]
readsPrec :: Int -> ReadS AssociateSigninDelegateGroupsWithAccount
$creadsPrec :: Int -> ReadS AssociateSigninDelegateGroupsWithAccount
Prelude.Read, Int -> AssociateSigninDelegateGroupsWithAccount -> ShowS
[AssociateSigninDelegateGroupsWithAccount] -> ShowS
AssociateSigninDelegateGroupsWithAccount -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateSigninDelegateGroupsWithAccount] -> ShowS
$cshowList :: [AssociateSigninDelegateGroupsWithAccount] -> ShowS
show :: AssociateSigninDelegateGroupsWithAccount -> String
$cshow :: AssociateSigninDelegateGroupsWithAccount -> String
showsPrec :: Int -> AssociateSigninDelegateGroupsWithAccount -> ShowS
$cshowsPrec :: Int -> AssociateSigninDelegateGroupsWithAccount -> ShowS
Prelude.Show, forall x.
Rep AssociateSigninDelegateGroupsWithAccount x
-> AssociateSigninDelegateGroupsWithAccount
forall x.
AssociateSigninDelegateGroupsWithAccount
-> Rep AssociateSigninDelegateGroupsWithAccount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssociateSigninDelegateGroupsWithAccount x
-> AssociateSigninDelegateGroupsWithAccount
$cfrom :: forall x.
AssociateSigninDelegateGroupsWithAccount
-> Rep AssociateSigninDelegateGroupsWithAccount x
Prelude.Generic)

-- |
-- Create a value of 'AssociateSigninDelegateGroupsWithAccount' 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:
--
-- 'accountId', 'associateSigninDelegateGroupsWithAccount_accountId' - The Amazon Chime account ID.
--
-- 'signinDelegateGroups', 'associateSigninDelegateGroupsWithAccount_signinDelegateGroups' - The sign-in delegate groups.
newAssociateSigninDelegateGroupsWithAccount ::
  -- | 'accountId'
  Prelude.Text ->
  AssociateSigninDelegateGroupsWithAccount
newAssociateSigninDelegateGroupsWithAccount :: Text -> AssociateSigninDelegateGroupsWithAccount
newAssociateSigninDelegateGroupsWithAccount
  Text
pAccountId_ =
    AssociateSigninDelegateGroupsWithAccount'
      { $sel:accountId:AssociateSigninDelegateGroupsWithAccount' :: Text
accountId =
          Text
pAccountId_,
        $sel:signinDelegateGroups:AssociateSigninDelegateGroupsWithAccount' :: [SigninDelegateGroup]
signinDelegateGroups =
          forall a. Monoid a => a
Prelude.mempty
      }

-- | The Amazon Chime account ID.
associateSigninDelegateGroupsWithAccount_accountId :: Lens.Lens' AssociateSigninDelegateGroupsWithAccount Prelude.Text
associateSigninDelegateGroupsWithAccount_accountId :: Lens' AssociateSigninDelegateGroupsWithAccount Text
associateSigninDelegateGroupsWithAccount_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateSigninDelegateGroupsWithAccount' {Text
accountId :: Text
$sel:accountId:AssociateSigninDelegateGroupsWithAccount' :: AssociateSigninDelegateGroupsWithAccount -> Text
accountId} -> Text
accountId) (\s :: AssociateSigninDelegateGroupsWithAccount
s@AssociateSigninDelegateGroupsWithAccount' {} Text
a -> AssociateSigninDelegateGroupsWithAccount
s {$sel:accountId:AssociateSigninDelegateGroupsWithAccount' :: Text
accountId = Text
a} :: AssociateSigninDelegateGroupsWithAccount)

-- | The sign-in delegate groups.
associateSigninDelegateGroupsWithAccount_signinDelegateGroups :: Lens.Lens' AssociateSigninDelegateGroupsWithAccount [SigninDelegateGroup]
associateSigninDelegateGroupsWithAccount_signinDelegateGroups :: Lens'
  AssociateSigninDelegateGroupsWithAccount [SigninDelegateGroup]
associateSigninDelegateGroupsWithAccount_signinDelegateGroups = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateSigninDelegateGroupsWithAccount' {[SigninDelegateGroup]
signinDelegateGroups :: [SigninDelegateGroup]
$sel:signinDelegateGroups:AssociateSigninDelegateGroupsWithAccount' :: AssociateSigninDelegateGroupsWithAccount -> [SigninDelegateGroup]
signinDelegateGroups} -> [SigninDelegateGroup]
signinDelegateGroups) (\s :: AssociateSigninDelegateGroupsWithAccount
s@AssociateSigninDelegateGroupsWithAccount' {} [SigninDelegateGroup]
a -> AssociateSigninDelegateGroupsWithAccount
s {$sel:signinDelegateGroups:AssociateSigninDelegateGroupsWithAccount' :: [SigninDelegateGroup]
signinDelegateGroups = [SigninDelegateGroup]
a} :: AssociateSigninDelegateGroupsWithAccount) 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

instance
  Core.AWSRequest
    AssociateSigninDelegateGroupsWithAccount
  where
  type
    AWSResponse
      AssociateSigninDelegateGroupsWithAccount =
      AssociateSigninDelegateGroupsWithAccountResponse
  request :: (Service -> Service)
-> AssociateSigninDelegateGroupsWithAccount
-> Request AssociateSigninDelegateGroupsWithAccount
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 AssociateSigninDelegateGroupsWithAccount
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse
           (AWSResponse AssociateSigninDelegateGroupsWithAccount)))
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 -> AssociateSigninDelegateGroupsWithAccountResponse
AssociateSigninDelegateGroupsWithAccountResponse'
            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
    AssociateSigninDelegateGroupsWithAccount
  where
  hashWithSalt :: Int -> AssociateSigninDelegateGroupsWithAccount -> Int
hashWithSalt
    Int
_salt
    AssociateSigninDelegateGroupsWithAccount' {[SigninDelegateGroup]
Text
signinDelegateGroups :: [SigninDelegateGroup]
accountId :: Text
$sel:signinDelegateGroups:AssociateSigninDelegateGroupsWithAccount' :: AssociateSigninDelegateGroupsWithAccount -> [SigninDelegateGroup]
$sel:accountId:AssociateSigninDelegateGroupsWithAccount' :: AssociateSigninDelegateGroupsWithAccount -> Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
accountId
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [SigninDelegateGroup]
signinDelegateGroups

instance
  Prelude.NFData
    AssociateSigninDelegateGroupsWithAccount
  where
  rnf :: AssociateSigninDelegateGroupsWithAccount -> ()
rnf AssociateSigninDelegateGroupsWithAccount' {[SigninDelegateGroup]
Text
signinDelegateGroups :: [SigninDelegateGroup]
accountId :: Text
$sel:signinDelegateGroups:AssociateSigninDelegateGroupsWithAccount' :: AssociateSigninDelegateGroupsWithAccount -> [SigninDelegateGroup]
$sel:accountId:AssociateSigninDelegateGroupsWithAccount' :: AssociateSigninDelegateGroupsWithAccount -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
accountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [SigninDelegateGroup]
signinDelegateGroups

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

instance
  Data.ToJSON
    AssociateSigninDelegateGroupsWithAccount
  where
  toJSON :: AssociateSigninDelegateGroupsWithAccount -> Value
toJSON AssociateSigninDelegateGroupsWithAccount' {[SigninDelegateGroup]
Text
signinDelegateGroups :: [SigninDelegateGroup]
accountId :: Text
$sel:signinDelegateGroups:AssociateSigninDelegateGroupsWithAccount' :: AssociateSigninDelegateGroupsWithAccount -> [SigninDelegateGroup]
$sel:accountId:AssociateSigninDelegateGroupsWithAccount' :: AssociateSigninDelegateGroupsWithAccount -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              ( Key
"SigninDelegateGroups"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [SigninDelegateGroup]
signinDelegateGroups
              )
          ]
      )

instance
  Data.ToPath
    AssociateSigninDelegateGroupsWithAccount
  where
  toPath :: AssociateSigninDelegateGroupsWithAccount -> ByteString
toPath AssociateSigninDelegateGroupsWithAccount' {[SigninDelegateGroup]
Text
signinDelegateGroups :: [SigninDelegateGroup]
accountId :: Text
$sel:signinDelegateGroups:AssociateSigninDelegateGroupsWithAccount' :: AssociateSigninDelegateGroupsWithAccount -> [SigninDelegateGroup]
$sel:accountId:AssociateSigninDelegateGroupsWithAccount' :: AssociateSigninDelegateGroupsWithAccount -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/accounts/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
accountId]

instance
  Data.ToQuery
    AssociateSigninDelegateGroupsWithAccount
  where
  toQuery :: AssociateSigninDelegateGroupsWithAccount -> QueryString
toQuery =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [QueryString
"operation=associate-signin-delegate-groups"]
      )

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

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

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

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