{-# 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.ListStudios
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- List studios in your Amazon Web Services accounts in the requested
-- Amazon Web Services Region.
--
-- This operation returns paginated results.
module Amazonka.Nimble.ListStudios
  ( -- * Creating a Request
    ListStudios (..),
    newListStudios,

    -- * Request Lenses
    listStudios_nextToken,

    -- * Destructuring the Response
    ListStudiosResponse (..),
    newListStudiosResponse,

    -- * Response Lenses
    listStudiosResponse_nextToken,
    listStudiosResponse_httpStatus,
    listStudiosResponse_studios,
  )
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:/ 'newListStudios' smart constructor.
data ListStudios = ListStudios'
  { -- | The token for the next set of results, or null if there are no more
    -- results.
    ListStudios -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListStudios -> ListStudios -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListStudios -> ListStudios -> Bool
$c/= :: ListStudios -> ListStudios -> Bool
== :: ListStudios -> ListStudios -> Bool
$c== :: ListStudios -> ListStudios -> Bool
Prelude.Eq, ReadPrec [ListStudios]
ReadPrec ListStudios
Int -> ReadS ListStudios
ReadS [ListStudios]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListStudios]
$creadListPrec :: ReadPrec [ListStudios]
readPrec :: ReadPrec ListStudios
$creadPrec :: ReadPrec ListStudios
readList :: ReadS [ListStudios]
$creadList :: ReadS [ListStudios]
readsPrec :: Int -> ReadS ListStudios
$creadsPrec :: Int -> ReadS ListStudios
Prelude.Read, Int -> ListStudios -> ShowS
[ListStudios] -> ShowS
ListStudios -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListStudios] -> ShowS
$cshowList :: [ListStudios] -> ShowS
show :: ListStudios -> String
$cshow :: ListStudios -> String
showsPrec :: Int -> ListStudios -> ShowS
$cshowsPrec :: Int -> ListStudios -> ShowS
Prelude.Show, forall x. Rep ListStudios x -> ListStudios
forall x. ListStudios -> Rep ListStudios x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListStudios x -> ListStudios
$cfrom :: forall x. ListStudios -> Rep ListStudios x
Prelude.Generic)

-- |
-- Create a value of 'ListStudios' 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', 'listStudios_nextToken' - The token for the next set of results, or null if there are no more
-- results.
newListStudios ::
  ListStudios
newListStudios :: ListStudios
newListStudios =
  ListStudios' {$sel:nextToken:ListStudios' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing}

-- | The token for the next set of results, or null if there are no more
-- results.
listStudios_nextToken :: Lens.Lens' ListStudios (Prelude.Maybe Prelude.Text)
listStudios_nextToken :: Lens' ListStudios (Maybe Text)
listStudios_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStudios' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListStudios' :: ListStudios -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListStudios
s@ListStudios' {} Maybe Text
a -> ListStudios
s {$sel:nextToken:ListStudios' :: Maybe Text
nextToken = Maybe Text
a} :: ListStudios)

instance Core.AWSPager ListStudios where
  page :: ListStudios -> AWSResponse ListStudios -> Maybe ListStudios
page ListStudios
rq AWSResponse ListStudios
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListStudios
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListStudiosResponse (Maybe Text)
listStudiosResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop (AWSResponse ListStudios
rs forall s a. s -> Getting a s a -> a
Lens.^. Lens' ListStudiosResponse [Studio]
listStudiosResponse_studios) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListStudios
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListStudios (Maybe Text)
listStudios_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListStudios
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListStudiosResponse (Maybe Text)
listStudiosResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListStudios where
  type AWSResponse ListStudios = ListStudiosResponse
  request :: (Service -> Service) -> ListStudios -> Request ListStudios
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListStudios
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListStudios)))
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 Text -> Int -> [Studio] -> ListStudiosResponse
ListStudiosResponse'
            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
"nextToken")
            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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"studios" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ListStudios where
  hashWithSalt :: Int -> ListStudios -> Int
hashWithSalt Int
_salt ListStudios' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListStudios' :: ListStudios -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

instance Prelude.NFData ListStudios where
  rnf :: ListStudios -> ()
rnf ListStudios' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListStudios' :: ListStudios -> Maybe Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

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

instance Data.ToPath ListStudios where
  toPath :: ListStudios -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/2020-08-01/studios"

instance Data.ToQuery ListStudios where
  toQuery :: ListStudios -> QueryString
toQuery ListStudios' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListStudios' :: ListStudios -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken]

-- | /See:/ 'newListStudiosResponse' smart constructor.
data ListStudiosResponse = ListStudiosResponse'
  { -- | The token for the next set of results, or null if there are no more
    -- results.
    ListStudiosResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListStudiosResponse -> Int
httpStatus :: Prelude.Int,
    -- | A collection of studios.
    ListStudiosResponse -> [Studio]
studios :: [Studio]
  }
  deriving (ListStudiosResponse -> ListStudiosResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListStudiosResponse -> ListStudiosResponse -> Bool
$c/= :: ListStudiosResponse -> ListStudiosResponse -> Bool
== :: ListStudiosResponse -> ListStudiosResponse -> Bool
$c== :: ListStudiosResponse -> ListStudiosResponse -> Bool
Prelude.Eq, Int -> ListStudiosResponse -> ShowS
[ListStudiosResponse] -> ShowS
ListStudiosResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListStudiosResponse] -> ShowS
$cshowList :: [ListStudiosResponse] -> ShowS
show :: ListStudiosResponse -> String
$cshow :: ListStudiosResponse -> String
showsPrec :: Int -> ListStudiosResponse -> ShowS
$cshowsPrec :: Int -> ListStudiosResponse -> ShowS
Prelude.Show, forall x. Rep ListStudiosResponse x -> ListStudiosResponse
forall x. ListStudiosResponse -> Rep ListStudiosResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListStudiosResponse x -> ListStudiosResponse
$cfrom :: forall x. ListStudiosResponse -> Rep ListStudiosResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListStudiosResponse' 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', 'listStudiosResponse_nextToken' - The token for the next set of results, or null if there are no more
-- results.
--
-- 'httpStatus', 'listStudiosResponse_httpStatus' - The response's http status code.
--
-- 'studios', 'listStudiosResponse_studios' - A collection of studios.
newListStudiosResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListStudiosResponse
newListStudiosResponse :: Int -> ListStudiosResponse
newListStudiosResponse Int
pHttpStatus_ =
  ListStudiosResponse'
    { $sel:nextToken:ListStudiosResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListStudiosResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:studios:ListStudiosResponse' :: [Studio]
studios = forall a. Monoid a => a
Prelude.mempty
    }

-- | The token for the next set of results, or null if there are no more
-- results.
listStudiosResponse_nextToken :: Lens.Lens' ListStudiosResponse (Prelude.Maybe Prelude.Text)
listStudiosResponse_nextToken :: Lens' ListStudiosResponse (Maybe Text)
listStudiosResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStudiosResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListStudiosResponse' :: ListStudiosResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListStudiosResponse
s@ListStudiosResponse' {} Maybe Text
a -> ListStudiosResponse
s {$sel:nextToken:ListStudiosResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListStudiosResponse)

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

-- | A collection of studios.
listStudiosResponse_studios :: Lens.Lens' ListStudiosResponse [Studio]
listStudiosResponse_studios :: Lens' ListStudiosResponse [Studio]
listStudiosResponse_studios = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStudiosResponse' {[Studio]
studios :: [Studio]
$sel:studios:ListStudiosResponse' :: ListStudiosResponse -> [Studio]
studios} -> [Studio]
studios) (\s :: ListStudiosResponse
s@ListStudiosResponse' {} [Studio]
a -> ListStudiosResponse
s {$sel:studios:ListStudiosResponse' :: [Studio]
studios = [Studio]
a} :: ListStudiosResponse) 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 Prelude.NFData ListStudiosResponse where
  rnf :: ListStudiosResponse -> ()
rnf ListStudiosResponse' {Int
[Studio]
Maybe Text
studios :: [Studio]
httpStatus :: Int
nextToken :: Maybe Text
$sel:studios:ListStudiosResponse' :: ListStudiosResponse -> [Studio]
$sel:httpStatus:ListStudiosResponse' :: ListStudiosResponse -> Int
$sel:nextToken:ListStudiosResponse' :: ListStudiosResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Studio]
studios