{-# 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.WorkSpaces.DescribeWorkspaces
-- 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)
--
-- Describes the specified WorkSpaces.
--
-- You can filter the results by using the bundle identifier, directory
-- identifier, or owner, but you can specify only one filter at a time.
--
-- This operation returns paginated results.
module Amazonka.WorkSpaces.DescribeWorkspaces
  ( -- * Creating a Request
    DescribeWorkspaces (..),
    newDescribeWorkspaces,

    -- * Request Lenses
    describeWorkspaces_directoryId,
    describeWorkspaces_workspaceIds,
    describeWorkspaces_userName,
    describeWorkspaces_bundleId,
    describeWorkspaces_nextToken,
    describeWorkspaces_limit,

    -- * Destructuring the Response
    DescribeWorkspacesResponse (..),
    newDescribeWorkspacesResponse,

    -- * Response Lenses
    describeWorkspacesResponse_nextToken,
    describeWorkspacesResponse_workspaces,
    describeWorkspacesResponse_httpStatus,
  )
where

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
import Amazonka.WorkSpaces.Types

-- | /See:/ 'newDescribeWorkspaces' smart constructor.
data DescribeWorkspaces = DescribeWorkspaces'
  { -- | The identifier of the directory. In addition, you can optionally specify
    -- a specific directory user (see @UserName@). You cannot combine this
    -- parameter with any other filter.
    DescribeWorkspaces -> Maybe Text
directoryId :: Prelude.Maybe Prelude.Text,
    -- | The identifiers of the WorkSpaces. You cannot combine this parameter
    -- with any other filter.
    --
    -- Because the CreateWorkspaces operation is asynchronous, the identifier
    -- it returns is not immediately available. If you immediately call
    -- DescribeWorkspaces with this identifier, no information is returned.
    DescribeWorkspaces -> Maybe (NonEmpty Text)
workspaceIds :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The name of the directory user. You must specify this parameter with
    -- @DirectoryId@.
    DescribeWorkspaces -> Maybe Text
userName :: Prelude.Maybe Prelude.Text,
    -- | The identifier of the bundle. All WorkSpaces that are created from this
    -- bundle are retrieved. You cannot combine this parameter with any other
    -- filter.
    DescribeWorkspaces -> Maybe Text
bundleId :: Prelude.Maybe Prelude.Text,
    -- | If you received a @NextToken@ from a previous call that was paginated,
    -- provide this token to receive the next set of results.
    DescribeWorkspaces -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of items to return.
    DescribeWorkspaces -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural
  }
  deriving (DescribeWorkspaces -> DescribeWorkspaces -> Bool
(DescribeWorkspaces -> DescribeWorkspaces -> Bool)
-> (DescribeWorkspaces -> DescribeWorkspaces -> Bool)
-> Eq DescribeWorkspaces
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeWorkspaces -> DescribeWorkspaces -> Bool
$c/= :: DescribeWorkspaces -> DescribeWorkspaces -> Bool
== :: DescribeWorkspaces -> DescribeWorkspaces -> Bool
$c== :: DescribeWorkspaces -> DescribeWorkspaces -> Bool
Prelude.Eq, ReadPrec [DescribeWorkspaces]
ReadPrec DescribeWorkspaces
Int -> ReadS DescribeWorkspaces
ReadS [DescribeWorkspaces]
(Int -> ReadS DescribeWorkspaces)
-> ReadS [DescribeWorkspaces]
-> ReadPrec DescribeWorkspaces
-> ReadPrec [DescribeWorkspaces]
-> Read DescribeWorkspaces
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeWorkspaces]
$creadListPrec :: ReadPrec [DescribeWorkspaces]
readPrec :: ReadPrec DescribeWorkspaces
$creadPrec :: ReadPrec DescribeWorkspaces
readList :: ReadS [DescribeWorkspaces]
$creadList :: ReadS [DescribeWorkspaces]
readsPrec :: Int -> ReadS DescribeWorkspaces
$creadsPrec :: Int -> ReadS DescribeWorkspaces
Prelude.Read, Int -> DescribeWorkspaces -> ShowS
[DescribeWorkspaces] -> ShowS
DescribeWorkspaces -> String
(Int -> DescribeWorkspaces -> ShowS)
-> (DescribeWorkspaces -> String)
-> ([DescribeWorkspaces] -> ShowS)
-> Show DescribeWorkspaces
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeWorkspaces] -> ShowS
$cshowList :: [DescribeWorkspaces] -> ShowS
show :: DescribeWorkspaces -> String
$cshow :: DescribeWorkspaces -> String
showsPrec :: Int -> DescribeWorkspaces -> ShowS
$cshowsPrec :: Int -> DescribeWorkspaces -> ShowS
Prelude.Show, (forall x. DescribeWorkspaces -> Rep DescribeWorkspaces x)
-> (forall x. Rep DescribeWorkspaces x -> DescribeWorkspaces)
-> Generic DescribeWorkspaces
forall x. Rep DescribeWorkspaces x -> DescribeWorkspaces
forall x. DescribeWorkspaces -> Rep DescribeWorkspaces x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeWorkspaces x -> DescribeWorkspaces
$cfrom :: forall x. DescribeWorkspaces -> Rep DescribeWorkspaces x
Prelude.Generic)

-- |
-- Create a value of 'DescribeWorkspaces' 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:
--
-- 'directoryId', 'describeWorkspaces_directoryId' - The identifier of the directory. In addition, you can optionally specify
-- a specific directory user (see @UserName@). You cannot combine this
-- parameter with any other filter.
--
-- 'workspaceIds', 'describeWorkspaces_workspaceIds' - The identifiers of the WorkSpaces. You cannot combine this parameter
-- with any other filter.
--
-- Because the CreateWorkspaces operation is asynchronous, the identifier
-- it returns is not immediately available. If you immediately call
-- DescribeWorkspaces with this identifier, no information is returned.
--
-- 'userName', 'describeWorkspaces_userName' - The name of the directory user. You must specify this parameter with
-- @DirectoryId@.
--
-- 'bundleId', 'describeWorkspaces_bundleId' - The identifier of the bundle. All WorkSpaces that are created from this
-- bundle are retrieved. You cannot combine this parameter with any other
-- filter.
--
-- 'nextToken', 'describeWorkspaces_nextToken' - If you received a @NextToken@ from a previous call that was paginated,
-- provide this token to receive the next set of results.
--
-- 'limit', 'describeWorkspaces_limit' - The maximum number of items to return.
newDescribeWorkspaces ::
  DescribeWorkspaces
newDescribeWorkspaces :: DescribeWorkspaces
newDescribeWorkspaces =
  DescribeWorkspaces' :: Maybe Text
-> Maybe (NonEmpty Text)
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> DescribeWorkspaces
DescribeWorkspaces'
    { $sel:directoryId:DescribeWorkspaces' :: Maybe Text
directoryId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:workspaceIds:DescribeWorkspaces' :: Maybe (NonEmpty Text)
workspaceIds = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:userName:DescribeWorkspaces' :: Maybe Text
userName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bundleId:DescribeWorkspaces' :: Maybe Text
bundleId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeWorkspaces' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:limit:DescribeWorkspaces' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The identifier of the directory. In addition, you can optionally specify
-- a specific directory user (see @UserName@). You cannot combine this
-- parameter with any other filter.
describeWorkspaces_directoryId :: Lens.Lens' DescribeWorkspaces (Prelude.Maybe Prelude.Text)
describeWorkspaces_directoryId :: (Maybe Text -> f (Maybe Text))
-> DescribeWorkspaces -> f DescribeWorkspaces
describeWorkspaces_directoryId = (DescribeWorkspaces -> Maybe Text)
-> (DescribeWorkspaces -> Maybe Text -> DescribeWorkspaces)
-> Lens
     DescribeWorkspaces DescribeWorkspaces (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeWorkspaces' {Maybe Text
directoryId :: Maybe Text
$sel:directoryId:DescribeWorkspaces' :: DescribeWorkspaces -> Maybe Text
directoryId} -> Maybe Text
directoryId) (\s :: DescribeWorkspaces
s@DescribeWorkspaces' {} Maybe Text
a -> DescribeWorkspaces
s {$sel:directoryId:DescribeWorkspaces' :: Maybe Text
directoryId = Maybe Text
a} :: DescribeWorkspaces)

-- | The identifiers of the WorkSpaces. You cannot combine this parameter
-- with any other filter.
--
-- Because the CreateWorkspaces operation is asynchronous, the identifier
-- it returns is not immediately available. If you immediately call
-- DescribeWorkspaces with this identifier, no information is returned.
describeWorkspaces_workspaceIds :: Lens.Lens' DescribeWorkspaces (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
describeWorkspaces_workspaceIds :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> DescribeWorkspaces -> f DescribeWorkspaces
describeWorkspaces_workspaceIds = (DescribeWorkspaces -> Maybe (NonEmpty Text))
-> (DescribeWorkspaces
    -> Maybe (NonEmpty Text) -> DescribeWorkspaces)
-> Lens
     DescribeWorkspaces
     DescribeWorkspaces
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeWorkspaces' {Maybe (NonEmpty Text)
workspaceIds :: Maybe (NonEmpty Text)
$sel:workspaceIds:DescribeWorkspaces' :: DescribeWorkspaces -> Maybe (NonEmpty Text)
workspaceIds} -> Maybe (NonEmpty Text)
workspaceIds) (\s :: DescribeWorkspaces
s@DescribeWorkspaces' {} Maybe (NonEmpty Text)
a -> DescribeWorkspaces
s {$sel:workspaceIds:DescribeWorkspaces' :: Maybe (NonEmpty Text)
workspaceIds = Maybe (NonEmpty Text)
a} :: DescribeWorkspaces) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> DescribeWorkspaces -> f DescribeWorkspaces)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> DescribeWorkspaces
-> f DescribeWorkspaces
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the directory user. You must specify this parameter with
-- @DirectoryId@.
describeWorkspaces_userName :: Lens.Lens' DescribeWorkspaces (Prelude.Maybe Prelude.Text)
describeWorkspaces_userName :: (Maybe Text -> f (Maybe Text))
-> DescribeWorkspaces -> f DescribeWorkspaces
describeWorkspaces_userName = (DescribeWorkspaces -> Maybe Text)
-> (DescribeWorkspaces -> Maybe Text -> DescribeWorkspaces)
-> Lens
     DescribeWorkspaces DescribeWorkspaces (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeWorkspaces' {Maybe Text
userName :: Maybe Text
$sel:userName:DescribeWorkspaces' :: DescribeWorkspaces -> Maybe Text
userName} -> Maybe Text
userName) (\s :: DescribeWorkspaces
s@DescribeWorkspaces' {} Maybe Text
a -> DescribeWorkspaces
s {$sel:userName:DescribeWorkspaces' :: Maybe Text
userName = Maybe Text
a} :: DescribeWorkspaces)

-- | The identifier of the bundle. All WorkSpaces that are created from this
-- bundle are retrieved. You cannot combine this parameter with any other
-- filter.
describeWorkspaces_bundleId :: Lens.Lens' DescribeWorkspaces (Prelude.Maybe Prelude.Text)
describeWorkspaces_bundleId :: (Maybe Text -> f (Maybe Text))
-> DescribeWorkspaces -> f DescribeWorkspaces
describeWorkspaces_bundleId = (DescribeWorkspaces -> Maybe Text)
-> (DescribeWorkspaces -> Maybe Text -> DescribeWorkspaces)
-> Lens
     DescribeWorkspaces DescribeWorkspaces (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeWorkspaces' {Maybe Text
bundleId :: Maybe Text
$sel:bundleId:DescribeWorkspaces' :: DescribeWorkspaces -> Maybe Text
bundleId} -> Maybe Text
bundleId) (\s :: DescribeWorkspaces
s@DescribeWorkspaces' {} Maybe Text
a -> DescribeWorkspaces
s {$sel:bundleId:DescribeWorkspaces' :: Maybe Text
bundleId = Maybe Text
a} :: DescribeWorkspaces)

-- | If you received a @NextToken@ from a previous call that was paginated,
-- provide this token to receive the next set of results.
describeWorkspaces_nextToken :: Lens.Lens' DescribeWorkspaces (Prelude.Maybe Prelude.Text)
describeWorkspaces_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeWorkspaces -> f DescribeWorkspaces
describeWorkspaces_nextToken = (DescribeWorkspaces -> Maybe Text)
-> (DescribeWorkspaces -> Maybe Text -> DescribeWorkspaces)
-> Lens
     DescribeWorkspaces DescribeWorkspaces (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeWorkspaces' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeWorkspaces' :: DescribeWorkspaces -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeWorkspaces
s@DescribeWorkspaces' {} Maybe Text
a -> DescribeWorkspaces
s {$sel:nextToken:DescribeWorkspaces' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeWorkspaces)

-- | The maximum number of items to return.
describeWorkspaces_limit :: Lens.Lens' DescribeWorkspaces (Prelude.Maybe Prelude.Natural)
describeWorkspaces_limit :: (Maybe Natural -> f (Maybe Natural))
-> DescribeWorkspaces -> f DescribeWorkspaces
describeWorkspaces_limit = (DescribeWorkspaces -> Maybe Natural)
-> (DescribeWorkspaces -> Maybe Natural -> DescribeWorkspaces)
-> Lens
     DescribeWorkspaces
     DescribeWorkspaces
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeWorkspaces' {Maybe Natural
limit :: Maybe Natural
$sel:limit:DescribeWorkspaces' :: DescribeWorkspaces -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: DescribeWorkspaces
s@DescribeWorkspaces' {} Maybe Natural
a -> DescribeWorkspaces
s {$sel:limit:DescribeWorkspaces' :: Maybe Natural
limit = Maybe Natural
a} :: DescribeWorkspaces)

instance Core.AWSPager DescribeWorkspaces where
  page :: DescribeWorkspaces
-> AWSResponse DescribeWorkspaces -> Maybe DescribeWorkspaces
page DescribeWorkspaces
rq AWSResponse DescribeWorkspaces
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeWorkspaces
DescribeWorkspacesResponse
rs
            DescribeWorkspacesResponse
-> Getting (First Text) DescribeWorkspacesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeWorkspacesResponse
-> Const (First Text) DescribeWorkspacesResponse
Lens' DescribeWorkspacesResponse (Maybe Text)
describeWorkspacesResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeWorkspacesResponse
 -> Const (First Text) DescribeWorkspacesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeWorkspacesResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeWorkspaces
forall a. Maybe a
Prelude.Nothing
    | Maybe [Workspace] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeWorkspaces
DescribeWorkspacesResponse
rs
            DescribeWorkspacesResponse
-> Getting
     (First [Workspace]) DescribeWorkspacesResponse [Workspace]
-> Maybe [Workspace]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Workspace]
 -> Const (First [Workspace]) (Maybe [Workspace]))
-> DescribeWorkspacesResponse
-> Const (First [Workspace]) DescribeWorkspacesResponse
Lens' DescribeWorkspacesResponse (Maybe [Workspace])
describeWorkspacesResponse_workspaces
              ((Maybe [Workspace]
  -> Const (First [Workspace]) (Maybe [Workspace]))
 -> DescribeWorkspacesResponse
 -> Const (First [Workspace]) DescribeWorkspacesResponse)
-> (([Workspace] -> Const (First [Workspace]) [Workspace])
    -> Maybe [Workspace]
    -> Const (First [Workspace]) (Maybe [Workspace]))
-> Getting
     (First [Workspace]) DescribeWorkspacesResponse [Workspace]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Workspace] -> Const (First [Workspace]) [Workspace])
-> Maybe [Workspace]
-> Const (First [Workspace]) (Maybe [Workspace])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeWorkspaces
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeWorkspaces -> Maybe DescribeWorkspaces
forall a. a -> Maybe a
Prelude.Just (DescribeWorkspaces -> Maybe DescribeWorkspaces)
-> DescribeWorkspaces -> Maybe DescribeWorkspaces
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeWorkspaces
rq
          DescribeWorkspaces
-> (DescribeWorkspaces -> DescribeWorkspaces) -> DescribeWorkspaces
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeWorkspaces -> Identity DescribeWorkspaces
Lens
  DescribeWorkspaces DescribeWorkspaces (Maybe Text) (Maybe Text)
describeWorkspaces_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeWorkspaces -> Identity DescribeWorkspaces)
-> Maybe Text -> DescribeWorkspaces -> DescribeWorkspaces
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeWorkspaces
DescribeWorkspacesResponse
rs
          DescribeWorkspacesResponse
-> Getting (First Text) DescribeWorkspacesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeWorkspacesResponse
-> Const (First Text) DescribeWorkspacesResponse
Lens' DescribeWorkspacesResponse (Maybe Text)
describeWorkspacesResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeWorkspacesResponse
 -> Const (First Text) DescribeWorkspacesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeWorkspacesResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest DescribeWorkspaces where
  type
    AWSResponse DescribeWorkspaces =
      DescribeWorkspacesResponse
  request :: DescribeWorkspaces -> Request DescribeWorkspaces
request = Service -> DescribeWorkspaces -> Request DescribeWorkspaces
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeWorkspaces
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeWorkspaces)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeWorkspaces))
-> Logger
-> Service
-> Proxy DescribeWorkspaces
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeWorkspaces)))
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 Text
-> Maybe [Workspace] -> Int -> DescribeWorkspacesResponse
DescribeWorkspacesResponse'
            (Maybe Text
 -> Maybe [Workspace] -> Int -> DescribeWorkspacesResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe [Workspace] -> Int -> DescribeWorkspacesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
            Either
  String (Maybe [Workspace] -> Int -> DescribeWorkspacesResponse)
-> Either String (Maybe [Workspace])
-> Either String (Int -> DescribeWorkspacesResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [Workspace]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Workspaces" Either String (Maybe (Maybe [Workspace]))
-> Maybe [Workspace] -> Either String (Maybe [Workspace])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Workspace]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> DescribeWorkspacesResponse)
-> Either String Int -> Either String DescribeWorkspacesResponse
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 DescribeWorkspaces

instance Prelude.NFData DescribeWorkspaces

instance Core.ToHeaders DescribeWorkspaces where
  toHeaders :: DescribeWorkspaces -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeWorkspaces -> 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
"WorkspacesService.DescribeWorkspaces" ::
                          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 DescribeWorkspaces where
  toJSON :: DescribeWorkspaces -> Value
toJSON DescribeWorkspaces' {Maybe Natural
Maybe (NonEmpty Text)
Maybe Text
limit :: Maybe Natural
nextToken :: Maybe Text
bundleId :: Maybe Text
userName :: Maybe Text
workspaceIds :: Maybe (NonEmpty Text)
directoryId :: Maybe Text
$sel:limit:DescribeWorkspaces' :: DescribeWorkspaces -> Maybe Natural
$sel:nextToken:DescribeWorkspaces' :: DescribeWorkspaces -> Maybe Text
$sel:bundleId:DescribeWorkspaces' :: DescribeWorkspaces -> Maybe Text
$sel:userName:DescribeWorkspaces' :: DescribeWorkspaces -> Maybe Text
$sel:workspaceIds:DescribeWorkspaces' :: DescribeWorkspaces -> Maybe (NonEmpty Text)
$sel:directoryId:DescribeWorkspaces' :: DescribeWorkspaces -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DirectoryId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
directoryId,
            (Text
"WorkspaceIds" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
workspaceIds,
            (Text
"UserName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
userName,
            (Text
"BundleId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
bundleId,
            (Text
"NextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"Limit" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
limit
          ]
      )

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

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

-- | /See:/ 'newDescribeWorkspacesResponse' smart constructor.
data DescribeWorkspacesResponse = DescribeWorkspacesResponse'
  { -- | The token to use to retrieve the next page of results. This value is
    -- null when there are no more results to return.
    DescribeWorkspacesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Information about the WorkSpaces.
    --
    -- Because CreateWorkspaces is an asynchronous operation, some of the
    -- returned information could be incomplete.
    DescribeWorkspacesResponse -> Maybe [Workspace]
workspaces :: Prelude.Maybe [Workspace],
    -- | The response's http status code.
    DescribeWorkspacesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeWorkspacesResponse -> DescribeWorkspacesResponse -> Bool
(DescribeWorkspacesResponse -> DescribeWorkspacesResponse -> Bool)
-> (DescribeWorkspacesResponse
    -> DescribeWorkspacesResponse -> Bool)
-> Eq DescribeWorkspacesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeWorkspacesResponse -> DescribeWorkspacesResponse -> Bool
$c/= :: DescribeWorkspacesResponse -> DescribeWorkspacesResponse -> Bool
== :: DescribeWorkspacesResponse -> DescribeWorkspacesResponse -> Bool
$c== :: DescribeWorkspacesResponse -> DescribeWorkspacesResponse -> Bool
Prelude.Eq, ReadPrec [DescribeWorkspacesResponse]
ReadPrec DescribeWorkspacesResponse
Int -> ReadS DescribeWorkspacesResponse
ReadS [DescribeWorkspacesResponse]
(Int -> ReadS DescribeWorkspacesResponse)
-> ReadS [DescribeWorkspacesResponse]
-> ReadPrec DescribeWorkspacesResponse
-> ReadPrec [DescribeWorkspacesResponse]
-> Read DescribeWorkspacesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeWorkspacesResponse]
$creadListPrec :: ReadPrec [DescribeWorkspacesResponse]
readPrec :: ReadPrec DescribeWorkspacesResponse
$creadPrec :: ReadPrec DescribeWorkspacesResponse
readList :: ReadS [DescribeWorkspacesResponse]
$creadList :: ReadS [DescribeWorkspacesResponse]
readsPrec :: Int -> ReadS DescribeWorkspacesResponse
$creadsPrec :: Int -> ReadS DescribeWorkspacesResponse
Prelude.Read, Int -> DescribeWorkspacesResponse -> ShowS
[DescribeWorkspacesResponse] -> ShowS
DescribeWorkspacesResponse -> String
(Int -> DescribeWorkspacesResponse -> ShowS)
-> (DescribeWorkspacesResponse -> String)
-> ([DescribeWorkspacesResponse] -> ShowS)
-> Show DescribeWorkspacesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeWorkspacesResponse] -> ShowS
$cshowList :: [DescribeWorkspacesResponse] -> ShowS
show :: DescribeWorkspacesResponse -> String
$cshow :: DescribeWorkspacesResponse -> String
showsPrec :: Int -> DescribeWorkspacesResponse -> ShowS
$cshowsPrec :: Int -> DescribeWorkspacesResponse -> ShowS
Prelude.Show, (forall x.
 DescribeWorkspacesResponse -> Rep DescribeWorkspacesResponse x)
-> (forall x.
    Rep DescribeWorkspacesResponse x -> DescribeWorkspacesResponse)
-> Generic DescribeWorkspacesResponse
forall x.
Rep DescribeWorkspacesResponse x -> DescribeWorkspacesResponse
forall x.
DescribeWorkspacesResponse -> Rep DescribeWorkspacesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeWorkspacesResponse x -> DescribeWorkspacesResponse
$cfrom :: forall x.
DescribeWorkspacesResponse -> Rep DescribeWorkspacesResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeWorkspacesResponse' 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:
--
-- 'nextToken', 'describeWorkspacesResponse_nextToken' - The token to use to retrieve the next page of results. This value is
-- null when there are no more results to return.
--
-- 'workspaces', 'describeWorkspacesResponse_workspaces' - Information about the WorkSpaces.
--
-- Because CreateWorkspaces is an asynchronous operation, some of the
-- returned information could be incomplete.
--
-- 'httpStatus', 'describeWorkspacesResponse_httpStatus' - The response's http status code.
newDescribeWorkspacesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeWorkspacesResponse
newDescribeWorkspacesResponse :: Int -> DescribeWorkspacesResponse
newDescribeWorkspacesResponse Int
pHttpStatus_ =
  DescribeWorkspacesResponse' :: Maybe Text
-> Maybe [Workspace] -> Int -> DescribeWorkspacesResponse
DescribeWorkspacesResponse'
    { $sel:nextToken:DescribeWorkspacesResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:workspaces:DescribeWorkspacesResponse' :: Maybe [Workspace]
workspaces = Maybe [Workspace]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeWorkspacesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The token to use to retrieve the next page of results. This value is
-- null when there are no more results to return.
describeWorkspacesResponse_nextToken :: Lens.Lens' DescribeWorkspacesResponse (Prelude.Maybe Prelude.Text)
describeWorkspacesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeWorkspacesResponse -> f DescribeWorkspacesResponse
describeWorkspacesResponse_nextToken = (DescribeWorkspacesResponse -> Maybe Text)
-> (DescribeWorkspacesResponse
    -> Maybe Text -> DescribeWorkspacesResponse)
-> Lens' DescribeWorkspacesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeWorkspacesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeWorkspacesResponse' :: DescribeWorkspacesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeWorkspacesResponse
s@DescribeWorkspacesResponse' {} Maybe Text
a -> DescribeWorkspacesResponse
s {$sel:nextToken:DescribeWorkspacesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeWorkspacesResponse)

-- | Information about the WorkSpaces.
--
-- Because CreateWorkspaces is an asynchronous operation, some of the
-- returned information could be incomplete.
describeWorkspacesResponse_workspaces :: Lens.Lens' DescribeWorkspacesResponse (Prelude.Maybe [Workspace])
describeWorkspacesResponse_workspaces :: (Maybe [Workspace] -> f (Maybe [Workspace]))
-> DescribeWorkspacesResponse -> f DescribeWorkspacesResponse
describeWorkspacesResponse_workspaces = (DescribeWorkspacesResponse -> Maybe [Workspace])
-> (DescribeWorkspacesResponse
    -> Maybe [Workspace] -> DescribeWorkspacesResponse)
-> Lens' DescribeWorkspacesResponse (Maybe [Workspace])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeWorkspacesResponse' {Maybe [Workspace]
workspaces :: Maybe [Workspace]
$sel:workspaces:DescribeWorkspacesResponse' :: DescribeWorkspacesResponse -> Maybe [Workspace]
workspaces} -> Maybe [Workspace]
workspaces) (\s :: DescribeWorkspacesResponse
s@DescribeWorkspacesResponse' {} Maybe [Workspace]
a -> DescribeWorkspacesResponse
s {$sel:workspaces:DescribeWorkspacesResponse' :: Maybe [Workspace]
workspaces = Maybe [Workspace]
a} :: DescribeWorkspacesResponse) ((Maybe [Workspace] -> f (Maybe [Workspace]))
 -> DescribeWorkspacesResponse -> f DescribeWorkspacesResponse)
-> ((Maybe [Workspace] -> f (Maybe [Workspace]))
    -> Maybe [Workspace] -> f (Maybe [Workspace]))
-> (Maybe [Workspace] -> f (Maybe [Workspace]))
-> DescribeWorkspacesResponse
-> f DescribeWorkspacesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Workspace] [Workspace] [Workspace] [Workspace]
-> Iso
     (Maybe [Workspace])
     (Maybe [Workspace])
     (Maybe [Workspace])
     (Maybe [Workspace])
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 [Workspace] [Workspace] [Workspace] [Workspace]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DescribeWorkspacesResponse