{-# 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-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)
--
-- List studios in your Amazon Web Services account 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_studios,
    listStudiosResponse_nextToken,
    listStudiosResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ListStudios -> ListStudios -> Bool)
-> (ListStudios -> ListStudios -> Bool) -> Eq ListStudios
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]
(Int -> ReadS ListStudios)
-> ReadS [ListStudios]
-> ReadPrec ListStudios
-> ReadPrec [ListStudios]
-> Read 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
(Int -> ListStudios -> ShowS)
-> (ListStudios -> String)
-> ([ListStudios] -> ShowS)
-> Show ListStudios
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. ListStudios -> Rep ListStudios x)
-> (forall x. Rep ListStudios x -> ListStudios)
-> Generic ListStudios
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' :: Maybe Text -> ListStudios
ListStudios' {$sel:nextToken:ListStudios' :: Maybe Text
nextToken = Maybe Text
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 :: (Maybe Text -> f (Maybe Text)) -> ListStudios -> f ListStudios
listStudios_nextToken = (ListStudios -> Maybe Text)
-> (ListStudios -> Maybe Text -> ListStudios)
-> Lens ListStudios ListStudios (Maybe Text) (Maybe Text)
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
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListStudios
ListStudiosResponse
rs
            ListStudiosResponse
-> Getting (First Text) ListStudiosResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListStudiosResponse -> Const (First Text) ListStudiosResponse
Lens' ListStudiosResponse (Maybe Text)
listStudiosResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListStudiosResponse -> Const (First Text) ListStudiosResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListStudiosResponse 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 ListStudios
forall a. Maybe a
Prelude.Nothing
    | Maybe [Studio] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListStudios
ListStudiosResponse
rs
            ListStudiosResponse
-> Getting (First [Studio]) ListStudiosResponse [Studio]
-> Maybe [Studio]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Studio] -> Const (First [Studio]) (Maybe [Studio]))
-> ListStudiosResponse
-> Const (First [Studio]) ListStudiosResponse
Lens' ListStudiosResponse (Maybe [Studio])
listStudiosResponse_studios ((Maybe [Studio] -> Const (First [Studio]) (Maybe [Studio]))
 -> ListStudiosResponse
 -> Const (First [Studio]) ListStudiosResponse)
-> (([Studio] -> Const (First [Studio]) [Studio])
    -> Maybe [Studio] -> Const (First [Studio]) (Maybe [Studio]))
-> Getting (First [Studio]) ListStudiosResponse [Studio]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Studio] -> Const (First [Studio]) [Studio])
-> Maybe [Studio] -> Const (First [Studio]) (Maybe [Studio])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListStudios
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListStudios -> Maybe ListStudios
forall a. a -> Maybe a
Prelude.Just (ListStudios -> Maybe ListStudios)
-> ListStudios -> Maybe ListStudios
forall a b. (a -> b) -> a -> b
Prelude.$
        ListStudios
rq
          ListStudios -> (ListStudios -> ListStudios) -> ListStudios
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListStudios -> Identity ListStudios
Lens ListStudios ListStudios (Maybe Text) (Maybe Text)
listStudios_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListStudios -> Identity ListStudios)
-> Maybe Text -> ListStudios -> ListStudios
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListStudios
ListStudiosResponse
rs
          ListStudiosResponse
-> Getting (First Text) ListStudiosResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListStudiosResponse -> Const (First Text) ListStudiosResponse
Lens' ListStudiosResponse (Maybe Text)
listStudiosResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListStudiosResponse -> Const (First Text) ListStudiosResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListStudiosResponse 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 ListStudios where
  type AWSResponse ListStudios = ListStudiosResponse
  request :: ListStudios -> Request ListStudios
request = Service -> ListStudios -> Request ListStudios
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListStudios
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListStudios)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListStudios))
-> Logger
-> Service
-> Proxy ListStudios
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListStudios)))
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 [Studio] -> Maybe Text -> Int -> ListStudiosResponse
ListStudiosResponse'
            (Maybe [Studio] -> Maybe Text -> Int -> ListStudiosResponse)
-> Either String (Maybe [Studio])
-> Either String (Maybe Text -> Int -> ListStudiosResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Studio]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"studios" Either String (Maybe (Maybe [Studio]))
-> Maybe [Studio] -> Either String (Maybe [Studio])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Studio]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Maybe Text -> Int -> ListStudiosResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListStudiosResponse)
forall (f :: * -> *) a b. Applicative f => 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 (Int -> ListStudiosResponse)
-> Either String Int -> Either String ListStudiosResponse
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 ListStudios

instance Prelude.NFData ListStudios

instance Core.ToHeaders ListStudios where
  toHeaders :: ListStudios -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListStudios -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath ListStudios where
  toPath :: ListStudios -> ByteString
toPath = ByteString -> ListStudios -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/2020-08-01/studios"

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

-- | /See:/ 'newListStudiosResponse' smart constructor.
data ListStudiosResponse = ListStudiosResponse'
  { -- | A collection of studios.
    ListStudiosResponse -> Maybe [Studio]
studios :: Prelude.Maybe [Studio],
    -- | 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
  }
  deriving (ListStudiosResponse -> ListStudiosResponse -> Bool
(ListStudiosResponse -> ListStudiosResponse -> Bool)
-> (ListStudiosResponse -> ListStudiosResponse -> Bool)
-> Eq ListStudiosResponse
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, ReadPrec [ListStudiosResponse]
ReadPrec ListStudiosResponse
Int -> ReadS ListStudiosResponse
ReadS [ListStudiosResponse]
(Int -> ReadS ListStudiosResponse)
-> ReadS [ListStudiosResponse]
-> ReadPrec ListStudiosResponse
-> ReadPrec [ListStudiosResponse]
-> Read ListStudiosResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListStudiosResponse]
$creadListPrec :: ReadPrec [ListStudiosResponse]
readPrec :: ReadPrec ListStudiosResponse
$creadPrec :: ReadPrec ListStudiosResponse
readList :: ReadS [ListStudiosResponse]
$creadList :: ReadS [ListStudiosResponse]
readsPrec :: Int -> ReadS ListStudiosResponse
$creadsPrec :: Int -> ReadS ListStudiosResponse
Prelude.Read, Int -> ListStudiosResponse -> ShowS
[ListStudiosResponse] -> ShowS
ListStudiosResponse -> String
(Int -> ListStudiosResponse -> ShowS)
-> (ListStudiosResponse -> String)
-> ([ListStudiosResponse] -> ShowS)
-> Show ListStudiosResponse
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. ListStudiosResponse -> Rep ListStudiosResponse x)
-> (forall x. Rep ListStudiosResponse x -> ListStudiosResponse)
-> Generic ListStudiosResponse
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:
--
-- 'studios', 'listStudiosResponse_studios' - A collection of studios.
--
-- '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.
newListStudiosResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListStudiosResponse
newListStudiosResponse :: Int -> ListStudiosResponse
newListStudiosResponse Int
pHttpStatus_ =
  ListStudiosResponse' :: Maybe [Studio] -> Maybe Text -> Int -> ListStudiosResponse
ListStudiosResponse'
    { $sel:studios:ListStudiosResponse' :: Maybe [Studio]
studios = Maybe [Studio]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListStudiosResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListStudiosResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A collection of studios.
listStudiosResponse_studios :: Lens.Lens' ListStudiosResponse (Prelude.Maybe [Studio])
listStudiosResponse_studios :: (Maybe [Studio] -> f (Maybe [Studio]))
-> ListStudiosResponse -> f ListStudiosResponse
listStudiosResponse_studios = (ListStudiosResponse -> Maybe [Studio])
-> (ListStudiosResponse -> Maybe [Studio] -> ListStudiosResponse)
-> Lens' ListStudiosResponse (Maybe [Studio])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStudiosResponse' {Maybe [Studio]
studios :: Maybe [Studio]
$sel:studios:ListStudiosResponse' :: ListStudiosResponse -> Maybe [Studio]
studios} -> Maybe [Studio]
studios) (\s :: ListStudiosResponse
s@ListStudiosResponse' {} Maybe [Studio]
a -> ListStudiosResponse
s {$sel:studios:ListStudiosResponse' :: Maybe [Studio]
studios = Maybe [Studio]
a} :: ListStudiosResponse) ((Maybe [Studio] -> f (Maybe [Studio]))
 -> ListStudiosResponse -> f ListStudiosResponse)
-> ((Maybe [Studio] -> f (Maybe [Studio]))
    -> Maybe [Studio] -> f (Maybe [Studio]))
-> (Maybe [Studio] -> f (Maybe [Studio]))
-> ListStudiosResponse
-> f ListStudiosResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Studio] [Studio] [Studio] [Studio]
-> Iso
     (Maybe [Studio]) (Maybe [Studio]) (Maybe [Studio]) (Maybe [Studio])
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 [Studio] [Studio] [Studio] [Studio]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> ListStudiosResponse -> f ListStudiosResponse
listStudiosResponse_nextToken = (ListStudiosResponse -> Maybe Text)
-> (ListStudiosResponse -> Maybe Text -> ListStudiosResponse)
-> Lens' ListStudiosResponse (Maybe Text)
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 :: (Int -> f Int) -> ListStudiosResponse -> f ListStudiosResponse
listStudiosResponse_httpStatus = (ListStudiosResponse -> Int)
-> (ListStudiosResponse -> Int -> ListStudiosResponse)
-> Lens ListStudiosResponse ListStudiosResponse Int Int
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)

instance Prelude.NFData ListStudiosResponse