{-# 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.AppStream.BatchDisassociateUserStack
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Disassociates the specified users from the specified stacks.
module Amazonka.AppStream.BatchDisassociateUserStack
  ( -- * Creating a Request
    BatchDisassociateUserStack (..),
    newBatchDisassociateUserStack,

    -- * Request Lenses
    batchDisassociateUserStack_userStackAssociations,

    -- * Destructuring the Response
    BatchDisassociateUserStackResponse (..),
    newBatchDisassociateUserStackResponse,

    -- * Response Lenses
    batchDisassociateUserStackResponse_errors,
    batchDisassociateUserStackResponse_httpStatus,
  )
where

import Amazonka.AppStream.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:/ 'newBatchDisassociateUserStack' smart constructor.
data BatchDisassociateUserStack = BatchDisassociateUserStack'
  { -- | The list of UserStackAssociation objects.
    BatchDisassociateUserStack -> NonEmpty UserStackAssociation
userStackAssociations :: Prelude.NonEmpty UserStackAssociation
  }
  deriving (BatchDisassociateUserStack -> BatchDisassociateUserStack -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchDisassociateUserStack -> BatchDisassociateUserStack -> Bool
$c/= :: BatchDisassociateUserStack -> BatchDisassociateUserStack -> Bool
== :: BatchDisassociateUserStack -> BatchDisassociateUserStack -> Bool
$c== :: BatchDisassociateUserStack -> BatchDisassociateUserStack -> Bool
Prelude.Eq, Int -> BatchDisassociateUserStack -> ShowS
[BatchDisassociateUserStack] -> ShowS
BatchDisassociateUserStack -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchDisassociateUserStack] -> ShowS
$cshowList :: [BatchDisassociateUserStack] -> ShowS
show :: BatchDisassociateUserStack -> String
$cshow :: BatchDisassociateUserStack -> String
showsPrec :: Int -> BatchDisassociateUserStack -> ShowS
$cshowsPrec :: Int -> BatchDisassociateUserStack -> ShowS
Prelude.Show, forall x.
Rep BatchDisassociateUserStack x -> BatchDisassociateUserStack
forall x.
BatchDisassociateUserStack -> Rep BatchDisassociateUserStack x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchDisassociateUserStack x -> BatchDisassociateUserStack
$cfrom :: forall x.
BatchDisassociateUserStack -> Rep BatchDisassociateUserStack x
Prelude.Generic)

-- |
-- Create a value of 'BatchDisassociateUserStack' 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:
--
-- 'userStackAssociations', 'batchDisassociateUserStack_userStackAssociations' - The list of UserStackAssociation objects.
newBatchDisassociateUserStack ::
  -- | 'userStackAssociations'
  Prelude.NonEmpty UserStackAssociation ->
  BatchDisassociateUserStack
newBatchDisassociateUserStack :: NonEmpty UserStackAssociation -> BatchDisassociateUserStack
newBatchDisassociateUserStack NonEmpty UserStackAssociation
pUserStackAssociations_ =
  BatchDisassociateUserStack'
    { $sel:userStackAssociations:BatchDisassociateUserStack' :: NonEmpty UserStackAssociation
userStackAssociations =
        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 UserStackAssociation
pUserStackAssociations_
    }

-- | The list of UserStackAssociation objects.
batchDisassociateUserStack_userStackAssociations :: Lens.Lens' BatchDisassociateUserStack (Prelude.NonEmpty UserStackAssociation)
batchDisassociateUserStack_userStackAssociations :: Lens' BatchDisassociateUserStack (NonEmpty UserStackAssociation)
batchDisassociateUserStack_userStackAssociations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDisassociateUserStack' {NonEmpty UserStackAssociation
userStackAssociations :: NonEmpty UserStackAssociation
$sel:userStackAssociations:BatchDisassociateUserStack' :: BatchDisassociateUserStack -> NonEmpty UserStackAssociation
userStackAssociations} -> NonEmpty UserStackAssociation
userStackAssociations) (\s :: BatchDisassociateUserStack
s@BatchDisassociateUserStack' {} NonEmpty UserStackAssociation
a -> BatchDisassociateUserStack
s {$sel:userStackAssociations:BatchDisassociateUserStack' :: NonEmpty UserStackAssociation
userStackAssociations = NonEmpty UserStackAssociation
a} :: BatchDisassociateUserStack) 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 BatchDisassociateUserStack where
  type
    AWSResponse BatchDisassociateUserStack =
      BatchDisassociateUserStackResponse
  request :: (Service -> Service)
-> BatchDisassociateUserStack -> Request BatchDisassociateUserStack
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 BatchDisassociateUserStack
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchDisassociateUserStack)))
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 [UserStackAssociationError]
-> Int -> BatchDisassociateUserStackResponse
BatchDisassociateUserStackResponse'
            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
"errors" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            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 BatchDisassociateUserStack where
  hashWithSalt :: Int -> BatchDisassociateUserStack -> Int
hashWithSalt Int
_salt BatchDisassociateUserStack' {NonEmpty UserStackAssociation
userStackAssociations :: NonEmpty UserStackAssociation
$sel:userStackAssociations:BatchDisassociateUserStack' :: BatchDisassociateUserStack -> NonEmpty UserStackAssociation
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty UserStackAssociation
userStackAssociations

instance Prelude.NFData BatchDisassociateUserStack where
  rnf :: BatchDisassociateUserStack -> ()
rnf BatchDisassociateUserStack' {NonEmpty UserStackAssociation
userStackAssociations :: NonEmpty UserStackAssociation
$sel:userStackAssociations:BatchDisassociateUserStack' :: BatchDisassociateUserStack -> NonEmpty UserStackAssociation
..} =
    forall a. NFData a => a -> ()
Prelude.rnf NonEmpty UserStackAssociation
userStackAssociations

instance Data.ToHeaders BatchDisassociateUserStack where
  toHeaders :: BatchDisassociateUserStack -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"PhotonAdminProxyService.BatchDisassociateUserStack" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON BatchDisassociateUserStack where
  toJSON :: BatchDisassociateUserStack -> Value
toJSON BatchDisassociateUserStack' {NonEmpty UserStackAssociation
userStackAssociations :: NonEmpty UserStackAssociation
$sel:userStackAssociations:BatchDisassociateUserStack' :: BatchDisassociateUserStack -> NonEmpty UserStackAssociation
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              ( Key
"UserStackAssociations"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty UserStackAssociation
userStackAssociations
              )
          ]
      )

instance Data.ToPath BatchDisassociateUserStack where
  toPath :: BatchDisassociateUserStack -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newBatchDisassociateUserStackResponse' smart constructor.
data BatchDisassociateUserStackResponse = BatchDisassociateUserStackResponse'
  { -- | The list of UserStackAssociationError objects.
    BatchDisassociateUserStackResponse
-> Maybe [UserStackAssociationError]
errors :: Prelude.Maybe [UserStackAssociationError],
    -- | The response's http status code.
    BatchDisassociateUserStackResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (BatchDisassociateUserStackResponse
-> BatchDisassociateUserStackResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchDisassociateUserStackResponse
-> BatchDisassociateUserStackResponse -> Bool
$c/= :: BatchDisassociateUserStackResponse
-> BatchDisassociateUserStackResponse -> Bool
== :: BatchDisassociateUserStackResponse
-> BatchDisassociateUserStackResponse -> Bool
$c== :: BatchDisassociateUserStackResponse
-> BatchDisassociateUserStackResponse -> Bool
Prelude.Eq, Int -> BatchDisassociateUserStackResponse -> ShowS
[BatchDisassociateUserStackResponse] -> ShowS
BatchDisassociateUserStackResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchDisassociateUserStackResponse] -> ShowS
$cshowList :: [BatchDisassociateUserStackResponse] -> ShowS
show :: BatchDisassociateUserStackResponse -> String
$cshow :: BatchDisassociateUserStackResponse -> String
showsPrec :: Int -> BatchDisassociateUserStackResponse -> ShowS
$cshowsPrec :: Int -> BatchDisassociateUserStackResponse -> ShowS
Prelude.Show, forall x.
Rep BatchDisassociateUserStackResponse x
-> BatchDisassociateUserStackResponse
forall x.
BatchDisassociateUserStackResponse
-> Rep BatchDisassociateUserStackResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchDisassociateUserStackResponse x
-> BatchDisassociateUserStackResponse
$cfrom :: forall x.
BatchDisassociateUserStackResponse
-> Rep BatchDisassociateUserStackResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchDisassociateUserStackResponse' 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:
--
-- 'errors', 'batchDisassociateUserStackResponse_errors' - The list of UserStackAssociationError objects.
--
-- 'httpStatus', 'batchDisassociateUserStackResponse_httpStatus' - The response's http status code.
newBatchDisassociateUserStackResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchDisassociateUserStackResponse
newBatchDisassociateUserStackResponse :: Int -> BatchDisassociateUserStackResponse
newBatchDisassociateUserStackResponse Int
pHttpStatus_ =
  BatchDisassociateUserStackResponse'
    { $sel:errors:BatchDisassociateUserStackResponse' :: Maybe [UserStackAssociationError]
errors =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchDisassociateUserStackResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The list of UserStackAssociationError objects.
batchDisassociateUserStackResponse_errors :: Lens.Lens' BatchDisassociateUserStackResponse (Prelude.Maybe [UserStackAssociationError])
batchDisassociateUserStackResponse_errors :: Lens'
  BatchDisassociateUserStackResponse
  (Maybe [UserStackAssociationError])
batchDisassociateUserStackResponse_errors = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDisassociateUserStackResponse' {Maybe [UserStackAssociationError]
errors :: Maybe [UserStackAssociationError]
$sel:errors:BatchDisassociateUserStackResponse' :: BatchDisassociateUserStackResponse
-> Maybe [UserStackAssociationError]
errors} -> Maybe [UserStackAssociationError]
errors) (\s :: BatchDisassociateUserStackResponse
s@BatchDisassociateUserStackResponse' {} Maybe [UserStackAssociationError]
a -> BatchDisassociateUserStackResponse
s {$sel:errors:BatchDisassociateUserStackResponse' :: Maybe [UserStackAssociationError]
errors = Maybe [UserStackAssociationError]
a} :: BatchDisassociateUserStackResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    BatchDisassociateUserStackResponse
  where
  rnf :: BatchDisassociateUserStackResponse -> ()
rnf BatchDisassociateUserStackResponse' {Int
Maybe [UserStackAssociationError]
httpStatus :: Int
errors :: Maybe [UserStackAssociationError]
$sel:httpStatus:BatchDisassociateUserStackResponse' :: BatchDisassociateUserStackResponse -> Int
$sel:errors:BatchDisassociateUserStackResponse' :: BatchDisassociateUserStackResponse
-> Maybe [UserStackAssociationError]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [UserStackAssociationError]
errors
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus