{-# 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-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)
--
-- 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.Lens as Lens
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
(BatchDisassociateUserStack -> BatchDisassociateUserStack -> Bool)
-> (BatchDisassociateUserStack
    -> BatchDisassociateUserStack -> Bool)
-> Eq BatchDisassociateUserStack
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
(Int -> BatchDisassociateUserStack -> ShowS)
-> (BatchDisassociateUserStack -> String)
-> ([BatchDisassociateUserStack] -> ShowS)
-> Show BatchDisassociateUserStack
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.
 BatchDisassociateUserStack -> Rep BatchDisassociateUserStack x)
-> (forall x.
    Rep BatchDisassociateUserStack x -> BatchDisassociateUserStack)
-> Generic BatchDisassociateUserStack
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' :: NonEmpty UserStackAssociation -> BatchDisassociateUserStack
BatchDisassociateUserStack'
    { $sel:userStackAssociations:BatchDisassociateUserStack' :: NonEmpty UserStackAssociation
userStackAssociations =
        Tagged
  (NonEmpty UserStackAssociation)
  (Identity (NonEmpty UserStackAssociation))
-> Tagged
     (NonEmpty UserStackAssociation)
     (Identity (NonEmpty UserStackAssociation))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
   (NonEmpty UserStackAssociation)
   (Identity (NonEmpty UserStackAssociation))
 -> Tagged
      (NonEmpty UserStackAssociation)
      (Identity (NonEmpty UserStackAssociation)))
-> NonEmpty UserStackAssociation -> NonEmpty UserStackAssociation
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 :: (NonEmpty UserStackAssociation
 -> f (NonEmpty UserStackAssociation))
-> BatchDisassociateUserStack -> f BatchDisassociateUserStack
batchDisassociateUserStack_userStackAssociations = (BatchDisassociateUserStack -> NonEmpty UserStackAssociation)
-> (BatchDisassociateUserStack
    -> NonEmpty UserStackAssociation -> BatchDisassociateUserStack)
-> Lens
     BatchDisassociateUserStack
     BatchDisassociateUserStack
     (NonEmpty UserStackAssociation)
     (NonEmpty UserStackAssociation)
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) ((NonEmpty UserStackAssociation
  -> f (NonEmpty UserStackAssociation))
 -> BatchDisassociateUserStack -> f BatchDisassociateUserStack)
-> ((NonEmpty UserStackAssociation
     -> f (NonEmpty UserStackAssociation))
    -> NonEmpty UserStackAssociation
    -> f (NonEmpty UserStackAssociation))
-> (NonEmpty UserStackAssociation
    -> f (NonEmpty UserStackAssociation))
-> BatchDisassociateUserStack
-> f BatchDisassociateUserStack
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty UserStackAssociation
 -> f (NonEmpty UserStackAssociation))
-> NonEmpty UserStackAssociation
-> f (NonEmpty UserStackAssociation)
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 :: BatchDisassociateUserStack -> Request BatchDisassociateUserStack
request = Service
-> BatchDisassociateUserStack -> Request BatchDisassociateUserStack
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy BatchDisassociateUserStack
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchDisassociateUserStack)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse BatchDisassociateUserStack))
-> Logger
-> Service
-> Proxy BatchDisassociateUserStack
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchDisassociateUserStack)))
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 [UserStackAssociationError]
-> Int -> BatchDisassociateUserStackResponse
BatchDisassociateUserStackResponse'
            (Maybe [UserStackAssociationError]
 -> Int -> BatchDisassociateUserStackResponse)
-> Either String (Maybe [UserStackAssociationError])
-> Either String (Int -> BatchDisassociateUserStackResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Key -> Either String (Maybe (Maybe [UserStackAssociationError]))
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"errors" Either String (Maybe (Maybe [UserStackAssociationError]))
-> Maybe [UserStackAssociationError]
-> Either String (Maybe [UserStackAssociationError])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [UserStackAssociationError]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> BatchDisassociateUserStackResponse)
-> Either String Int
-> Either String BatchDisassociateUserStackResponse
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 BatchDisassociateUserStack

instance Prelude.NFData BatchDisassociateUserStack

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

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

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

instance Core.ToQuery BatchDisassociateUserStack where
  toQuery :: BatchDisassociateUserStack -> QueryString
toQuery = QueryString -> BatchDisassociateUserStack -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(BatchDisassociateUserStackResponse
 -> BatchDisassociateUserStackResponse -> Bool)
-> (BatchDisassociateUserStackResponse
    -> BatchDisassociateUserStackResponse -> Bool)
-> Eq BatchDisassociateUserStackResponse
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
(Int -> BatchDisassociateUserStackResponse -> ShowS)
-> (BatchDisassociateUserStackResponse -> String)
-> ([BatchDisassociateUserStackResponse] -> ShowS)
-> Show BatchDisassociateUserStackResponse
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.
 BatchDisassociateUserStackResponse
 -> Rep BatchDisassociateUserStackResponse x)
-> (forall x.
    Rep BatchDisassociateUserStackResponse x
    -> BatchDisassociateUserStackResponse)
-> Generic BatchDisassociateUserStackResponse
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' :: Maybe [UserStackAssociationError]
-> Int -> BatchDisassociateUserStackResponse
BatchDisassociateUserStackResponse'
    { $sel:errors:BatchDisassociateUserStackResponse' :: Maybe [UserStackAssociationError]
errors =
        Maybe [UserStackAssociationError]
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 :: (Maybe [UserStackAssociationError]
 -> f (Maybe [UserStackAssociationError]))
-> BatchDisassociateUserStackResponse
-> f BatchDisassociateUserStackResponse
batchDisassociateUserStackResponse_errors = (BatchDisassociateUserStackResponse
 -> Maybe [UserStackAssociationError])
-> (BatchDisassociateUserStackResponse
    -> Maybe [UserStackAssociationError]
    -> BatchDisassociateUserStackResponse)
-> Lens
     BatchDisassociateUserStackResponse
     BatchDisassociateUserStackResponse
     (Maybe [UserStackAssociationError])
     (Maybe [UserStackAssociationError])
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) ((Maybe [UserStackAssociationError]
  -> f (Maybe [UserStackAssociationError]))
 -> BatchDisassociateUserStackResponse
 -> f BatchDisassociateUserStackResponse)
-> ((Maybe [UserStackAssociationError]
     -> f (Maybe [UserStackAssociationError]))
    -> Maybe [UserStackAssociationError]
    -> f (Maybe [UserStackAssociationError]))
-> (Maybe [UserStackAssociationError]
    -> f (Maybe [UserStackAssociationError]))
-> BatchDisassociateUserStackResponse
-> f BatchDisassociateUserStackResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [UserStackAssociationError]
  [UserStackAssociationError]
  [UserStackAssociationError]
  [UserStackAssociationError]
-> Iso
     (Maybe [UserStackAssociationError])
     (Maybe [UserStackAssociationError])
     (Maybe [UserStackAssociationError])
     (Maybe [UserStackAssociationError])
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
  [UserStackAssociationError]
  [UserStackAssociationError]
  [UserStackAssociationError]
  [UserStackAssociationError]
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 :: (Int -> f Int)
-> BatchDisassociateUserStackResponse
-> f BatchDisassociateUserStackResponse
batchDisassociateUserStackResponse_httpStatus = (BatchDisassociateUserStackResponse -> Int)
-> (BatchDisassociateUserStackResponse
    -> Int -> BatchDisassociateUserStackResponse)
-> Lens
     BatchDisassociateUserStackResponse
     BatchDisassociateUserStackResponse
     Int
     Int
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