{-# 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.Panorama.ListPackages
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns a list of packages.
module Amazonka.Panorama.ListPackages
  ( -- * Creating a Request
    ListPackages (..),
    newListPackages,

    -- * Request Lenses
    listPackages_maxResults,
    listPackages_nextToken,

    -- * Destructuring the Response
    ListPackagesResponse (..),
    newListPackagesResponse,

    -- * Response Lenses
    listPackagesResponse_nextToken,
    listPackagesResponse_packages,
    listPackagesResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Panorama.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListPackages' smart constructor.
data ListPackages = ListPackages'
  { -- | The maximum number of packages to return in one page of results.
    ListPackages -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | Specify the pagination token from a previous request to retrieve the
    -- next page of results.
    ListPackages -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListPackages -> ListPackages -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPackages -> ListPackages -> Bool
$c/= :: ListPackages -> ListPackages -> Bool
== :: ListPackages -> ListPackages -> Bool
$c== :: ListPackages -> ListPackages -> Bool
Prelude.Eq, ReadPrec [ListPackages]
ReadPrec ListPackages
Int -> ReadS ListPackages
ReadS [ListPackages]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPackages]
$creadListPrec :: ReadPrec [ListPackages]
readPrec :: ReadPrec ListPackages
$creadPrec :: ReadPrec ListPackages
readList :: ReadS [ListPackages]
$creadList :: ReadS [ListPackages]
readsPrec :: Int -> ReadS ListPackages
$creadsPrec :: Int -> ReadS ListPackages
Prelude.Read, Int -> ListPackages -> ShowS
[ListPackages] -> ShowS
ListPackages -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPackages] -> ShowS
$cshowList :: [ListPackages] -> ShowS
show :: ListPackages -> String
$cshow :: ListPackages -> String
showsPrec :: Int -> ListPackages -> ShowS
$cshowsPrec :: Int -> ListPackages -> ShowS
Prelude.Show, forall x. Rep ListPackages x -> ListPackages
forall x. ListPackages -> Rep ListPackages x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListPackages x -> ListPackages
$cfrom :: forall x. ListPackages -> Rep ListPackages x
Prelude.Generic)

-- |
-- Create a value of 'ListPackages' 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:
--
-- 'maxResults', 'listPackages_maxResults' - The maximum number of packages to return in one page of results.
--
-- 'nextToken', 'listPackages_nextToken' - Specify the pagination token from a previous request to retrieve the
-- next page of results.
newListPackages ::
  ListPackages
newListPackages :: ListPackages
newListPackages =
  ListPackages'
    { $sel:maxResults:ListPackages' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListPackages' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of packages to return in one page of results.
listPackages_maxResults :: Lens.Lens' ListPackages (Prelude.Maybe Prelude.Natural)
listPackages_maxResults :: Lens' ListPackages (Maybe Natural)
listPackages_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPackages' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListPackages' :: ListPackages -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListPackages
s@ListPackages' {} Maybe Natural
a -> ListPackages
s {$sel:maxResults:ListPackages' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListPackages)

-- | Specify the pagination token from a previous request to retrieve the
-- next page of results.
listPackages_nextToken :: Lens.Lens' ListPackages (Prelude.Maybe Prelude.Text)
listPackages_nextToken :: Lens' ListPackages (Maybe Text)
listPackages_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPackages' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListPackages' :: ListPackages -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListPackages
s@ListPackages' {} Maybe Text
a -> ListPackages
s {$sel:nextToken:ListPackages' :: Maybe Text
nextToken = Maybe Text
a} :: ListPackages)

instance Core.AWSRequest ListPackages where
  type AWSResponse ListPackages = ListPackagesResponse
  request :: (Service -> Service) -> ListPackages -> Request ListPackages
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 ListPackages
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListPackages)))
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
-> Maybe [PackageListItem] -> Int -> ListPackagesResponse
ListPackagesResponse'
            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.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Packages" 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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

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

instance Prelude.NFData ListPackages where
  rnf :: ListPackages -> ()
rnf ListPackages' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListPackages' :: ListPackages -> Maybe Text
$sel:maxResults:ListPackages' :: ListPackages -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

instance Data.ToHeaders ListPackages where
  toHeaders :: ListPackages -> 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 ListPackages where
  toPath :: ListPackages -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/packages"

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

-- | /See:/ 'newListPackagesResponse' smart constructor.
data ListPackagesResponse = ListPackagesResponse'
  { -- | A pagination token that\'s included if more results are available.
    ListPackagesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A list of packages.
    ListPackagesResponse -> Maybe [PackageListItem]
packages :: Prelude.Maybe [PackageListItem],
    -- | The response's http status code.
    ListPackagesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListPackagesResponse -> ListPackagesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPackagesResponse -> ListPackagesResponse -> Bool
$c/= :: ListPackagesResponse -> ListPackagesResponse -> Bool
== :: ListPackagesResponse -> ListPackagesResponse -> Bool
$c== :: ListPackagesResponse -> ListPackagesResponse -> Bool
Prelude.Eq, ReadPrec [ListPackagesResponse]
ReadPrec ListPackagesResponse
Int -> ReadS ListPackagesResponse
ReadS [ListPackagesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPackagesResponse]
$creadListPrec :: ReadPrec [ListPackagesResponse]
readPrec :: ReadPrec ListPackagesResponse
$creadPrec :: ReadPrec ListPackagesResponse
readList :: ReadS [ListPackagesResponse]
$creadList :: ReadS [ListPackagesResponse]
readsPrec :: Int -> ReadS ListPackagesResponse
$creadsPrec :: Int -> ReadS ListPackagesResponse
Prelude.Read, Int -> ListPackagesResponse -> ShowS
[ListPackagesResponse] -> ShowS
ListPackagesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPackagesResponse] -> ShowS
$cshowList :: [ListPackagesResponse] -> ShowS
show :: ListPackagesResponse -> String
$cshow :: ListPackagesResponse -> String
showsPrec :: Int -> ListPackagesResponse -> ShowS
$cshowsPrec :: Int -> ListPackagesResponse -> ShowS
Prelude.Show, forall x. Rep ListPackagesResponse x -> ListPackagesResponse
forall x. ListPackagesResponse -> Rep ListPackagesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListPackagesResponse x -> ListPackagesResponse
$cfrom :: forall x. ListPackagesResponse -> Rep ListPackagesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListPackagesResponse' 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', 'listPackagesResponse_nextToken' - A pagination token that\'s included if more results are available.
--
-- 'packages', 'listPackagesResponse_packages' - A list of packages.
--
-- 'httpStatus', 'listPackagesResponse_httpStatus' - The response's http status code.
newListPackagesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListPackagesResponse
newListPackagesResponse :: Int -> ListPackagesResponse
newListPackagesResponse Int
pHttpStatus_ =
  ListPackagesResponse'
    { $sel:nextToken:ListPackagesResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:packages:ListPackagesResponse' :: Maybe [PackageListItem]
packages = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListPackagesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A pagination token that\'s included if more results are available.
listPackagesResponse_nextToken :: Lens.Lens' ListPackagesResponse (Prelude.Maybe Prelude.Text)
listPackagesResponse_nextToken :: Lens' ListPackagesResponse (Maybe Text)
listPackagesResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPackagesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListPackagesResponse' :: ListPackagesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListPackagesResponse
s@ListPackagesResponse' {} Maybe Text
a -> ListPackagesResponse
s {$sel:nextToken:ListPackagesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListPackagesResponse)

-- | A list of packages.
listPackagesResponse_packages :: Lens.Lens' ListPackagesResponse (Prelude.Maybe [PackageListItem])
listPackagesResponse_packages :: Lens' ListPackagesResponse (Maybe [PackageListItem])
listPackagesResponse_packages = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPackagesResponse' {Maybe [PackageListItem]
packages :: Maybe [PackageListItem]
$sel:packages:ListPackagesResponse' :: ListPackagesResponse -> Maybe [PackageListItem]
packages} -> Maybe [PackageListItem]
packages) (\s :: ListPackagesResponse
s@ListPackagesResponse' {} Maybe [PackageListItem]
a -> ListPackagesResponse
s {$sel:packages:ListPackagesResponse' :: Maybe [PackageListItem]
packages = Maybe [PackageListItem]
a} :: ListPackagesResponse) 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 response's http status code.
listPackagesResponse_httpStatus :: Lens.Lens' ListPackagesResponse Prelude.Int
listPackagesResponse_httpStatus :: Lens' ListPackagesResponse Int
listPackagesResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPackagesResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListPackagesResponse' :: ListPackagesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListPackagesResponse
s@ListPackagesResponse' {} Int
a -> ListPackagesResponse
s {$sel:httpStatus:ListPackagesResponse' :: Int
httpStatus = Int
a} :: ListPackagesResponse)

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