{-# 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.CodeArtifact.ListPackages
-- 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)
--
-- Returns a list of
-- <https://docs.aws.amazon.com/codeartifact/latest/APIReference/API_PackageSummary.html PackageSummary>
-- objects for packages in a repository that match the request parameters.
--
-- This operation returns paginated results.
module Amazonka.CodeArtifact.ListPackages
  ( -- * Creating a Request
    ListPackages (..),
    newListPackages,

    -- * Request Lenses
    listPackages_format,
    listPackages_namespace,
    listPackages_domainOwner,
    listPackages_nextToken,
    listPackages_packagePrefix,
    listPackages_maxResults,
    listPackages_domain,
    listPackages_repository,

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

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

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

-- | /See:/ 'newListPackages' smart constructor.
data ListPackages = ListPackages'
  { -- | The format of the packages. The valid package types are:
    --
    -- -   @npm@: A Node Package Manager (npm) package.
    --
    -- -   @pypi@: A Python Package Index (PyPI) package.
    --
    -- -   @maven@: A Maven package that contains compiled code in a
    --     distributable format, such as a JAR file.
    ListPackages -> Maybe PackageFormat
format :: Prelude.Maybe PackageFormat,
    -- | The namespace of the package. The package component that specifies its
    -- namespace depends on its type. For example:
    --
    -- -   The namespace of a Maven package is its @groupId@.
    --
    -- -   The namespace of an npm package is its @scope@.
    --
    -- -   A Python package does not contain a corresponding component, so
    --     Python packages do not have a namespace.
    ListPackages -> Maybe Text
namespace :: Prelude.Maybe Prelude.Text,
    -- | The 12-digit account number of the AWS account that owns the domain. It
    -- does not include dashes or spaces.
    ListPackages -> Maybe Text
domainOwner :: Prelude.Maybe Prelude.Text,
    -- | The token for the next set of results. Use the value returned in the
    -- previous response in the next request to retrieve the next set of
    -- results.
    ListPackages -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A prefix used to filter returned packages. Only packages with names that
    -- start with @packagePrefix@ are returned.
    ListPackages -> Maybe Text
packagePrefix :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return per page.
    ListPackages -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The name of the domain that contains the repository that contains the
    -- requested list of packages.
    ListPackages -> Text
domain :: Prelude.Text,
    -- | The name of the repository from which packages are to be listed.
    ListPackages -> Text
repository :: Prelude.Text
  }
  deriving (ListPackages -> ListPackages -> Bool
(ListPackages -> ListPackages -> Bool)
-> (ListPackages -> ListPackages -> Bool) -> Eq ListPackages
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]
(Int -> ReadS ListPackages)
-> ReadS [ListPackages]
-> ReadPrec ListPackages
-> ReadPrec [ListPackages]
-> Read 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
(Int -> ListPackages -> ShowS)
-> (ListPackages -> String)
-> ([ListPackages] -> ShowS)
-> Show ListPackages
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. ListPackages -> Rep ListPackages x)
-> (forall x. Rep ListPackages x -> ListPackages)
-> Generic ListPackages
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:
--
-- 'format', 'listPackages_format' - The format of the packages. The valid package types are:
--
-- -   @npm@: A Node Package Manager (npm) package.
--
-- -   @pypi@: A Python Package Index (PyPI) package.
--
-- -   @maven@: A Maven package that contains compiled code in a
--     distributable format, such as a JAR file.
--
-- 'namespace', 'listPackages_namespace' - The namespace of the package. The package component that specifies its
-- namespace depends on its type. For example:
--
-- -   The namespace of a Maven package is its @groupId@.
--
-- -   The namespace of an npm package is its @scope@.
--
-- -   A Python package does not contain a corresponding component, so
--     Python packages do not have a namespace.
--
-- 'domainOwner', 'listPackages_domainOwner' - The 12-digit account number of the AWS account that owns the domain. It
-- does not include dashes or spaces.
--
-- 'nextToken', 'listPackages_nextToken' - The token for the next set of results. Use the value returned in the
-- previous response in the next request to retrieve the next set of
-- results.
--
-- 'packagePrefix', 'listPackages_packagePrefix' - A prefix used to filter returned packages. Only packages with names that
-- start with @packagePrefix@ are returned.
--
-- 'maxResults', 'listPackages_maxResults' - The maximum number of results to return per page.
--
-- 'domain', 'listPackages_domain' - The name of the domain that contains the repository that contains the
-- requested list of packages.
--
-- 'repository', 'listPackages_repository' - The name of the repository from which packages are to be listed.
newListPackages ::
  -- | 'domain'
  Prelude.Text ->
  -- | 'repository'
  Prelude.Text ->
  ListPackages
newListPackages :: Text -> Text -> ListPackages
newListPackages Text
pDomain_ Text
pRepository_ =
  ListPackages' :: Maybe PackageFormat
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> Text
-> Text
-> ListPackages
ListPackages'
    { $sel:format:ListPackages' :: Maybe PackageFormat
format = Maybe PackageFormat
forall a. Maybe a
Prelude.Nothing,
      $sel:namespace:ListPackages' :: Maybe Text
namespace = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:domainOwner:ListPackages' :: Maybe Text
domainOwner = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListPackages' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:packagePrefix:ListPackages' :: Maybe Text
packagePrefix = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListPackages' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:domain:ListPackages' :: Text
domain = Text
pDomain_,
      $sel:repository:ListPackages' :: Text
repository = Text
pRepository_
    }

-- | The format of the packages. The valid package types are:
--
-- -   @npm@: A Node Package Manager (npm) package.
--
-- -   @pypi@: A Python Package Index (PyPI) package.
--
-- -   @maven@: A Maven package that contains compiled code in a
--     distributable format, such as a JAR file.
listPackages_format :: Lens.Lens' ListPackages (Prelude.Maybe PackageFormat)
listPackages_format :: (Maybe PackageFormat -> f (Maybe PackageFormat))
-> ListPackages -> f ListPackages
listPackages_format = (ListPackages -> Maybe PackageFormat)
-> (ListPackages -> Maybe PackageFormat -> ListPackages)
-> Lens
     ListPackages
     ListPackages
     (Maybe PackageFormat)
     (Maybe PackageFormat)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPackages' {Maybe PackageFormat
format :: Maybe PackageFormat
$sel:format:ListPackages' :: ListPackages -> Maybe PackageFormat
format} -> Maybe PackageFormat
format) (\s :: ListPackages
s@ListPackages' {} Maybe PackageFormat
a -> ListPackages
s {$sel:format:ListPackages' :: Maybe PackageFormat
format = Maybe PackageFormat
a} :: ListPackages)

-- | The namespace of the package. The package component that specifies its
-- namespace depends on its type. For example:
--
-- -   The namespace of a Maven package is its @groupId@.
--
-- -   The namespace of an npm package is its @scope@.
--
-- -   A Python package does not contain a corresponding component, so
--     Python packages do not have a namespace.
listPackages_namespace :: Lens.Lens' ListPackages (Prelude.Maybe Prelude.Text)
listPackages_namespace :: (Maybe Text -> f (Maybe Text)) -> ListPackages -> f ListPackages
listPackages_namespace = (ListPackages -> Maybe Text)
-> (ListPackages -> Maybe Text -> ListPackages)
-> Lens ListPackages ListPackages (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPackages' {Maybe Text
namespace :: Maybe Text
$sel:namespace:ListPackages' :: ListPackages -> Maybe Text
namespace} -> Maybe Text
namespace) (\s :: ListPackages
s@ListPackages' {} Maybe Text
a -> ListPackages
s {$sel:namespace:ListPackages' :: Maybe Text
namespace = Maybe Text
a} :: ListPackages)

-- | The 12-digit account number of the AWS account that owns the domain. It
-- does not include dashes or spaces.
listPackages_domainOwner :: Lens.Lens' ListPackages (Prelude.Maybe Prelude.Text)
listPackages_domainOwner :: (Maybe Text -> f (Maybe Text)) -> ListPackages -> f ListPackages
listPackages_domainOwner = (ListPackages -> Maybe Text)
-> (ListPackages -> Maybe Text -> ListPackages)
-> Lens ListPackages ListPackages (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPackages' {Maybe Text
domainOwner :: Maybe Text
$sel:domainOwner:ListPackages' :: ListPackages -> Maybe Text
domainOwner} -> Maybe Text
domainOwner) (\s :: ListPackages
s@ListPackages' {} Maybe Text
a -> ListPackages
s {$sel:domainOwner:ListPackages' :: Maybe Text
domainOwner = Maybe Text
a} :: ListPackages)

-- | The token for the next set of results. Use the value returned in the
-- previous response in the next request to retrieve the next set of
-- results.
listPackages_nextToken :: Lens.Lens' ListPackages (Prelude.Maybe Prelude.Text)
listPackages_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListPackages -> f ListPackages
listPackages_nextToken = (ListPackages -> Maybe Text)
-> (ListPackages -> Maybe Text -> ListPackages)
-> Lens ListPackages ListPackages (Maybe Text) (Maybe Text)
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)

-- | A prefix used to filter returned packages. Only packages with names that
-- start with @packagePrefix@ are returned.
listPackages_packagePrefix :: Lens.Lens' ListPackages (Prelude.Maybe Prelude.Text)
listPackages_packagePrefix :: (Maybe Text -> f (Maybe Text)) -> ListPackages -> f ListPackages
listPackages_packagePrefix = (ListPackages -> Maybe Text)
-> (ListPackages -> Maybe Text -> ListPackages)
-> Lens ListPackages ListPackages (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPackages' {Maybe Text
packagePrefix :: Maybe Text
$sel:packagePrefix:ListPackages' :: ListPackages -> Maybe Text
packagePrefix} -> Maybe Text
packagePrefix) (\s :: ListPackages
s@ListPackages' {} Maybe Text
a -> ListPackages
s {$sel:packagePrefix:ListPackages' :: Maybe Text
packagePrefix = Maybe Text
a} :: ListPackages)

-- | The maximum number of results to return per page.
listPackages_maxResults :: Lens.Lens' ListPackages (Prelude.Maybe Prelude.Natural)
listPackages_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListPackages -> f ListPackages
listPackages_maxResults = (ListPackages -> Maybe Natural)
-> (ListPackages -> Maybe Natural -> ListPackages)
-> Lens ListPackages ListPackages (Maybe Natural) (Maybe Natural)
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)

-- | The name of the domain that contains the repository that contains the
-- requested list of packages.
listPackages_domain :: Lens.Lens' ListPackages Prelude.Text
listPackages_domain :: (Text -> f Text) -> ListPackages -> f ListPackages
listPackages_domain = (ListPackages -> Text)
-> (ListPackages -> Text -> ListPackages)
-> Lens ListPackages ListPackages Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPackages' {Text
domain :: Text
$sel:domain:ListPackages' :: ListPackages -> Text
domain} -> Text
domain) (\s :: ListPackages
s@ListPackages' {} Text
a -> ListPackages
s {$sel:domain:ListPackages' :: Text
domain = Text
a} :: ListPackages)

-- | The name of the repository from which packages are to be listed.
listPackages_repository :: Lens.Lens' ListPackages Prelude.Text
listPackages_repository :: (Text -> f Text) -> ListPackages -> f ListPackages
listPackages_repository = (ListPackages -> Text)
-> (ListPackages -> Text -> ListPackages)
-> Lens ListPackages ListPackages Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPackages' {Text
repository :: Text
$sel:repository:ListPackages' :: ListPackages -> Text
repository} -> Text
repository) (\s :: ListPackages
s@ListPackages' {} Text
a -> ListPackages
s {$sel:repository:ListPackages' :: Text
repository = Text
a} :: ListPackages)

instance Core.AWSPager ListPackages where
  page :: ListPackages -> AWSResponse ListPackages -> Maybe ListPackages
page ListPackages
rq AWSResponse ListPackages
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListPackages
ListPackagesResponse
rs
            ListPackagesResponse
-> Getting (First Text) ListPackagesResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListPackagesResponse -> Const (First Text) ListPackagesResponse
Lens' ListPackagesResponse (Maybe Text)
listPackagesResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListPackagesResponse -> Const (First Text) ListPackagesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListPackagesResponse 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 ListPackages
forall a. Maybe a
Prelude.Nothing
    | Maybe [PackageSummary] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListPackages
ListPackagesResponse
rs
            ListPackagesResponse
-> Getting
     (First [PackageSummary]) ListPackagesResponse [PackageSummary]
-> Maybe [PackageSummary]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [PackageSummary]
 -> Const (First [PackageSummary]) (Maybe [PackageSummary]))
-> ListPackagesResponse
-> Const (First [PackageSummary]) ListPackagesResponse
Lens' ListPackagesResponse (Maybe [PackageSummary])
listPackagesResponse_packages ((Maybe [PackageSummary]
  -> Const (First [PackageSummary]) (Maybe [PackageSummary]))
 -> ListPackagesResponse
 -> Const (First [PackageSummary]) ListPackagesResponse)
-> (([PackageSummary]
     -> Const (First [PackageSummary]) [PackageSummary])
    -> Maybe [PackageSummary]
    -> Const (First [PackageSummary]) (Maybe [PackageSummary]))
-> Getting
     (First [PackageSummary]) ListPackagesResponse [PackageSummary]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([PackageSummary]
 -> Const (First [PackageSummary]) [PackageSummary])
-> Maybe [PackageSummary]
-> Const (First [PackageSummary]) (Maybe [PackageSummary])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListPackages
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListPackages -> Maybe ListPackages
forall a. a -> Maybe a
Prelude.Just (ListPackages -> Maybe ListPackages)
-> ListPackages -> Maybe ListPackages
forall a b. (a -> b) -> a -> b
Prelude.$
        ListPackages
rq
          ListPackages -> (ListPackages -> ListPackages) -> ListPackages
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListPackages -> Identity ListPackages
Lens ListPackages ListPackages (Maybe Text) (Maybe Text)
listPackages_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListPackages -> Identity ListPackages)
-> Maybe Text -> ListPackages -> ListPackages
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListPackages
ListPackagesResponse
rs
          ListPackagesResponse
-> Getting (First Text) ListPackagesResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListPackagesResponse -> Const (First Text) ListPackagesResponse
Lens' ListPackagesResponse (Maybe Text)
listPackagesResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListPackagesResponse -> Const (First Text) ListPackagesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListPackagesResponse 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 ListPackages where
  type AWSResponse ListPackages = ListPackagesResponse
  request :: ListPackages -> Request ListPackages
request = Service -> ListPackages -> Request ListPackages
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListPackages
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListPackages)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListPackages))
-> Logger
-> Service
-> Proxy ListPackages
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListPackages)))
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 [PackageSummary] -> Maybe Text -> Int -> ListPackagesResponse
ListPackagesResponse'
            (Maybe [PackageSummary]
 -> Maybe Text -> Int -> ListPackagesResponse)
-> Either String (Maybe [PackageSummary])
-> Either String (Maybe Text -> Int -> ListPackagesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [PackageSummary]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"packages" Either String (Maybe (Maybe [PackageSummary]))
-> Maybe [PackageSummary] -> Either String (Maybe [PackageSummary])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [PackageSummary]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Maybe Text -> Int -> ListPackagesResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListPackagesResponse)
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 -> ListPackagesResponse)
-> Either String Int -> Either String ListPackagesResponse
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 ListPackages

instance Prelude.NFData ListPackages

instance Core.ToHeaders ListPackages where
  toHeaders :: ListPackages -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListPackages -> 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.ToJSON ListPackages where
  toJSON :: ListPackages -> Value
toJSON = Value -> ListPackages -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

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

instance Core.ToQuery ListPackages where
  toQuery :: ListPackages -> QueryString
toQuery ListPackages' {Maybe Natural
Maybe Text
Maybe PackageFormat
Text
repository :: Text
domain :: Text
maxResults :: Maybe Natural
packagePrefix :: Maybe Text
nextToken :: Maybe Text
domainOwner :: Maybe Text
namespace :: Maybe Text
format :: Maybe PackageFormat
$sel:repository:ListPackages' :: ListPackages -> Text
$sel:domain:ListPackages' :: ListPackages -> Text
$sel:maxResults:ListPackages' :: ListPackages -> Maybe Natural
$sel:packagePrefix:ListPackages' :: ListPackages -> Maybe Text
$sel:nextToken:ListPackages' :: ListPackages -> Maybe Text
$sel:domainOwner:ListPackages' :: ListPackages -> Maybe Text
$sel:namespace:ListPackages' :: ListPackages -> Maybe Text
$sel:format:ListPackages' :: ListPackages -> Maybe PackageFormat
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"format" ByteString -> Maybe PackageFormat -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe PackageFormat
format,
        ByteString
"namespace" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
namespace,
        ByteString
"domain-owner" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
domainOwner,
        ByteString
"next-token" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
        ByteString
"package-prefix" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
packagePrefix,
        ByteString
"max-results" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
maxResults,
        ByteString
"domain" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
domain,
        ByteString
"repository" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
repository
      ]

-- | /See:/ 'newListPackagesResponse' smart constructor.
data ListPackagesResponse = ListPackagesResponse'
  { -- | The list of returned
    -- <https://docs.aws.amazon.com/codeartifact/latest/APIReference/API_PackageSummary.html PackageSummary>
    -- objects.
    ListPackagesResponse -> Maybe [PackageSummary]
packages :: Prelude.Maybe [PackageSummary],
    -- | If there are additional results, this is the token for the next set of
    -- results.
    ListPackagesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListPackagesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListPackagesResponse -> ListPackagesResponse -> Bool
(ListPackagesResponse -> ListPackagesResponse -> Bool)
-> (ListPackagesResponse -> ListPackagesResponse -> Bool)
-> Eq ListPackagesResponse
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]
(Int -> ReadS ListPackagesResponse)
-> ReadS [ListPackagesResponse]
-> ReadPrec ListPackagesResponse
-> ReadPrec [ListPackagesResponse]
-> Read 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
(Int -> ListPackagesResponse -> ShowS)
-> (ListPackagesResponse -> String)
-> ([ListPackagesResponse] -> ShowS)
-> Show ListPackagesResponse
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. ListPackagesResponse -> Rep ListPackagesResponse x)
-> (forall x. Rep ListPackagesResponse x -> ListPackagesResponse)
-> Generic ListPackagesResponse
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:
--
-- 'packages', 'listPackagesResponse_packages' - The list of returned
-- <https://docs.aws.amazon.com/codeartifact/latest/APIReference/API_PackageSummary.html PackageSummary>
-- objects.
--
-- 'nextToken', 'listPackagesResponse_nextToken' - If there are additional results, this is the token for the next set of
-- results.
--
-- 'httpStatus', 'listPackagesResponse_httpStatus' - The response's http status code.
newListPackagesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListPackagesResponse
newListPackagesResponse :: Int -> ListPackagesResponse
newListPackagesResponse Int
pHttpStatus_ =
  ListPackagesResponse' :: Maybe [PackageSummary] -> Maybe Text -> Int -> ListPackagesResponse
ListPackagesResponse'
    { $sel:packages:ListPackagesResponse' :: Maybe [PackageSummary]
packages = Maybe [PackageSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListPackagesResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListPackagesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The list of returned
-- <https://docs.aws.amazon.com/codeartifact/latest/APIReference/API_PackageSummary.html PackageSummary>
-- objects.
listPackagesResponse_packages :: Lens.Lens' ListPackagesResponse (Prelude.Maybe [PackageSummary])
listPackagesResponse_packages :: (Maybe [PackageSummary] -> f (Maybe [PackageSummary]))
-> ListPackagesResponse -> f ListPackagesResponse
listPackagesResponse_packages = (ListPackagesResponse -> Maybe [PackageSummary])
-> (ListPackagesResponse
    -> Maybe [PackageSummary] -> ListPackagesResponse)
-> Lens' ListPackagesResponse (Maybe [PackageSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPackagesResponse' {Maybe [PackageSummary]
packages :: Maybe [PackageSummary]
$sel:packages:ListPackagesResponse' :: ListPackagesResponse -> Maybe [PackageSummary]
packages} -> Maybe [PackageSummary]
packages) (\s :: ListPackagesResponse
s@ListPackagesResponse' {} Maybe [PackageSummary]
a -> ListPackagesResponse
s {$sel:packages:ListPackagesResponse' :: Maybe [PackageSummary]
packages = Maybe [PackageSummary]
a} :: ListPackagesResponse) ((Maybe [PackageSummary] -> f (Maybe [PackageSummary]))
 -> ListPackagesResponse -> f ListPackagesResponse)
-> ((Maybe [PackageSummary] -> f (Maybe [PackageSummary]))
    -> Maybe [PackageSummary] -> f (Maybe [PackageSummary]))
-> (Maybe [PackageSummary] -> f (Maybe [PackageSummary]))
-> ListPackagesResponse
-> f ListPackagesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PackageSummary] [PackageSummary] [PackageSummary] [PackageSummary]
-> Iso
     (Maybe [PackageSummary])
     (Maybe [PackageSummary])
     (Maybe [PackageSummary])
     (Maybe [PackageSummary])
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
  [PackageSummary] [PackageSummary] [PackageSummary] [PackageSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | If there are additional results, this is the token for the next set of
-- results.
listPackagesResponse_nextToken :: Lens.Lens' ListPackagesResponse (Prelude.Maybe Prelude.Text)
listPackagesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListPackagesResponse -> f ListPackagesResponse
listPackagesResponse_nextToken = (ListPackagesResponse -> Maybe Text)
-> (ListPackagesResponse -> Maybe Text -> ListPackagesResponse)
-> Lens' ListPackagesResponse (Maybe Text)
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)

-- | The response's http status code.
listPackagesResponse_httpStatus :: Lens.Lens' ListPackagesResponse Prelude.Int
listPackagesResponse_httpStatus :: (Int -> f Int) -> ListPackagesResponse -> f ListPackagesResponse
listPackagesResponse_httpStatus = (ListPackagesResponse -> Int)
-> (ListPackagesResponse -> Int -> ListPackagesResponse)
-> Lens ListPackagesResponse ListPackagesResponse Int Int
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