{-# 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.ListEulas
-- 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 EULAs.
--
-- This operation returns paginated results.
module Amazonka.Nimble.ListEulas
  ( -- * Creating a Request
    ListEulas (..),
    newListEulas,

    -- * Request Lenses
    listEulas_eulaIds,
    listEulas_nextToken,

    -- * Destructuring the Response
    ListEulasResponse (..),
    newListEulasResponse,

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

-- |
-- Create a value of 'ListEulas' 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:
--
-- 'eulaIds', 'listEulas_eulaIds' - The list of EULA IDs that should be returned
--
-- 'nextToken', 'listEulas_nextToken' - The token for the next set of results, or null if there are no more
-- results.
newListEulas ::
  ListEulas
newListEulas :: ListEulas
newListEulas =
  ListEulas'
    { $sel:eulaIds:ListEulas' :: Maybe [Text]
eulaIds = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListEulas' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The list of EULA IDs that should be returned
listEulas_eulaIds :: Lens.Lens' ListEulas (Prelude.Maybe [Prelude.Text])
listEulas_eulaIds :: Lens' ListEulas (Maybe [Text])
listEulas_eulaIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListEulas' {Maybe [Text]
eulaIds :: Maybe [Text]
$sel:eulaIds:ListEulas' :: ListEulas -> Maybe [Text]
eulaIds} -> Maybe [Text]
eulaIds) (\s :: ListEulas
s@ListEulas' {} Maybe [Text]
a -> ListEulas
s {$sel:eulaIds:ListEulas' :: Maybe [Text]
eulaIds = Maybe [Text]
a} :: ListEulas) 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 token for the next set of results, or null if there are no more
-- results.
listEulas_nextToken :: Lens.Lens' ListEulas (Prelude.Maybe Prelude.Text)
listEulas_nextToken :: Lens' ListEulas (Maybe Text)
listEulas_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListEulas' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListEulas' :: ListEulas -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListEulas
s@ListEulas' {} Maybe Text
a -> ListEulas
s {$sel:nextToken:ListEulas' :: Maybe Text
nextToken = Maybe Text
a} :: ListEulas)

instance Core.AWSPager ListEulas where
  page :: ListEulas -> AWSResponse ListEulas -> Maybe ListEulas
page ListEulas
rq AWSResponse ListEulas
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListEulas
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListEulasResponse (Maybe Text)
listEulasResponse_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 ListEulas
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListEulasResponse (Maybe [Eula])
listEulasResponse_eulas
            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
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListEulas
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListEulas (Maybe Text)
listEulas_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListEulas
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListEulasResponse (Maybe Text)
listEulasResponse_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 ListEulas where
  type AWSResponse ListEulas = ListEulasResponse
  request :: (Service -> Service) -> ListEulas -> Request ListEulas
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 ListEulas
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListEulas)))
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 [Eula] -> Maybe Text -> Int -> ListEulasResponse
ListEulasResponse'
            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
"eulas" 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.<*> (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))
      )

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

instance Prelude.NFData ListEulas where
  rnf :: ListEulas -> ()
rnf ListEulas' {Maybe [Text]
Maybe Text
nextToken :: Maybe Text
eulaIds :: Maybe [Text]
$sel:nextToken:ListEulas' :: ListEulas -> Maybe Text
$sel:eulaIds:ListEulas' :: ListEulas -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
eulaIds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

instance Data.ToHeaders ListEulas where
  toHeaders :: ListEulas -> 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 ListEulas where
  toPath :: ListEulas -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/2020-08-01/eulas"

instance Data.ToQuery ListEulas where
  toQuery :: ListEulas -> QueryString
toQuery ListEulas' {Maybe [Text]
Maybe Text
nextToken :: Maybe Text
eulaIds :: Maybe [Text]
$sel:nextToken:ListEulas' :: ListEulas -> Maybe Text
$sel:eulaIds:ListEulas' :: ListEulas -> Maybe [Text]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"eulaIds"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            (forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
eulaIds),
        ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | /See:/ 'newListEulasResponse' smart constructor.
data ListEulasResponse = ListEulasResponse'
  { -- | A collection of EULA resources.
    ListEulasResponse -> Maybe [Eula]
eulas :: Prelude.Maybe [Eula],
    -- | The token for the next set of results, or null if there are no more
    -- results.
    ListEulasResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListEulasResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListEulasResponse -> ListEulasResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListEulasResponse -> ListEulasResponse -> Bool
$c/= :: ListEulasResponse -> ListEulasResponse -> Bool
== :: ListEulasResponse -> ListEulasResponse -> Bool
$c== :: ListEulasResponse -> ListEulasResponse -> Bool
Prelude.Eq, ReadPrec [ListEulasResponse]
ReadPrec ListEulasResponse
Int -> ReadS ListEulasResponse
ReadS [ListEulasResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListEulasResponse]
$creadListPrec :: ReadPrec [ListEulasResponse]
readPrec :: ReadPrec ListEulasResponse
$creadPrec :: ReadPrec ListEulasResponse
readList :: ReadS [ListEulasResponse]
$creadList :: ReadS [ListEulasResponse]
readsPrec :: Int -> ReadS ListEulasResponse
$creadsPrec :: Int -> ReadS ListEulasResponse
Prelude.Read, Int -> ListEulasResponse -> ShowS
[ListEulasResponse] -> ShowS
ListEulasResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListEulasResponse] -> ShowS
$cshowList :: [ListEulasResponse] -> ShowS
show :: ListEulasResponse -> String
$cshow :: ListEulasResponse -> String
showsPrec :: Int -> ListEulasResponse -> ShowS
$cshowsPrec :: Int -> ListEulasResponse -> ShowS
Prelude.Show, forall x. Rep ListEulasResponse x -> ListEulasResponse
forall x. ListEulasResponse -> Rep ListEulasResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListEulasResponse x -> ListEulasResponse
$cfrom :: forall x. ListEulasResponse -> Rep ListEulasResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListEulasResponse' 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:
--
-- 'eulas', 'listEulasResponse_eulas' - A collection of EULA resources.
--
-- 'nextToken', 'listEulasResponse_nextToken' - The token for the next set of results, or null if there are no more
-- results.
--
-- 'httpStatus', 'listEulasResponse_httpStatus' - The response's http status code.
newListEulasResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListEulasResponse
newListEulasResponse :: Int -> ListEulasResponse
newListEulasResponse Int
pHttpStatus_ =
  ListEulasResponse'
    { $sel:eulas:ListEulasResponse' :: Maybe [Eula]
eulas = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListEulasResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListEulasResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A collection of EULA resources.
listEulasResponse_eulas :: Lens.Lens' ListEulasResponse (Prelude.Maybe [Eula])
listEulasResponse_eulas :: Lens' ListEulasResponse (Maybe [Eula])
listEulasResponse_eulas = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListEulasResponse' {Maybe [Eula]
eulas :: Maybe [Eula]
$sel:eulas:ListEulasResponse' :: ListEulasResponse -> Maybe [Eula]
eulas} -> Maybe [Eula]
eulas) (\s :: ListEulasResponse
s@ListEulasResponse' {} Maybe [Eula]
a -> ListEulasResponse
s {$sel:eulas:ListEulasResponse' :: Maybe [Eula]
eulas = Maybe [Eula]
a} :: ListEulasResponse) 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 token for the next set of results, or null if there are no more
-- results.
listEulasResponse_nextToken :: Lens.Lens' ListEulasResponse (Prelude.Maybe Prelude.Text)
listEulasResponse_nextToken :: Lens' ListEulasResponse (Maybe Text)
listEulasResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListEulasResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListEulasResponse' :: ListEulasResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListEulasResponse
s@ListEulasResponse' {} Maybe Text
a -> ListEulasResponse
s {$sel:nextToken:ListEulasResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListEulasResponse)

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

instance Prelude.NFData ListEulasResponse where
  rnf :: ListEulasResponse -> ()
rnf ListEulasResponse' {Int
Maybe [Eula]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
eulas :: Maybe [Eula]
$sel:httpStatus:ListEulasResponse' :: ListEulasResponse -> Int
$sel:nextToken:ListEulasResponse' :: ListEulasResponse -> Maybe Text
$sel:eulas:ListEulasResponse' :: ListEulasResponse -> Maybe [Eula]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Eula]
eulas
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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