{-# 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.GetPackageVersionAsset
-- 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 an asset (or file) that is in a package. For example, for a
-- Maven package version, use @GetPackageVersionAsset@ to download a @JAR@
-- file, a @POM@ file, or any other assets in the package version.
module Amazonka.CodeArtifact.GetPackageVersionAsset
  ( -- * Creating a Request
    GetPackageVersionAsset (..),
    newGetPackageVersionAsset,

    -- * Request Lenses
    getPackageVersionAsset_namespace,
    getPackageVersionAsset_domainOwner,
    getPackageVersionAsset_packageVersionRevision,
    getPackageVersionAsset_domain,
    getPackageVersionAsset_repository,
    getPackageVersionAsset_format,
    getPackageVersionAsset_package,
    getPackageVersionAsset_packageVersion,
    getPackageVersionAsset_asset,

    -- * Destructuring the Response
    GetPackageVersionAssetResponse (..),
    newGetPackageVersionAssetResponse,

    -- * Response Lenses
    getPackageVersionAssetResponse_packageVersion,
    getPackageVersionAssetResponse_assetName,
    getPackageVersionAssetResponse_packageVersionRevision,
    getPackageVersionAssetResponse_httpStatus,
    getPackageVersionAssetResponse_asset,
  )
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:/ 'newGetPackageVersionAsset' smart constructor.
data GetPackageVersionAsset = GetPackageVersionAsset'
  { -- | 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.
    GetPackageVersionAsset -> 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.
    GetPackageVersionAsset -> Maybe Text
domainOwner :: Prelude.Maybe Prelude.Text,
    -- | The name of the package version revision that contains the requested
    -- asset.
    GetPackageVersionAsset -> Maybe Text
packageVersionRevision :: Prelude.Maybe Prelude.Text,
    -- | The name of the domain that contains the repository that contains the
    -- package version with the requested asset.
    GetPackageVersionAsset -> Text
domain :: Prelude.Text,
    -- | The repository that contains the package version with the requested
    -- asset.
    GetPackageVersionAsset -> Text
repository :: Prelude.Text,
    -- | A format that specifies the type of the package version with the
    -- requested asset file. The valid values are:
    --
    -- -   @npm@
    --
    -- -   @pypi@
    --
    -- -   @maven@
    GetPackageVersionAsset -> PackageFormat
format :: PackageFormat,
    -- | The name of the package that contains the requested asset.
    GetPackageVersionAsset -> Text
package :: Prelude.Text,
    -- | A string that contains the package version (for example, @3.5.2@).
    GetPackageVersionAsset -> Text
packageVersion :: Prelude.Text,
    -- | The name of the requested asset.
    GetPackageVersionAsset -> Text
asset :: Prelude.Text
  }
  deriving (GetPackageVersionAsset -> GetPackageVersionAsset -> Bool
(GetPackageVersionAsset -> GetPackageVersionAsset -> Bool)
-> (GetPackageVersionAsset -> GetPackageVersionAsset -> Bool)
-> Eq GetPackageVersionAsset
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetPackageVersionAsset -> GetPackageVersionAsset -> Bool
$c/= :: GetPackageVersionAsset -> GetPackageVersionAsset -> Bool
== :: GetPackageVersionAsset -> GetPackageVersionAsset -> Bool
$c== :: GetPackageVersionAsset -> GetPackageVersionAsset -> Bool
Prelude.Eq, ReadPrec [GetPackageVersionAsset]
ReadPrec GetPackageVersionAsset
Int -> ReadS GetPackageVersionAsset
ReadS [GetPackageVersionAsset]
(Int -> ReadS GetPackageVersionAsset)
-> ReadS [GetPackageVersionAsset]
-> ReadPrec GetPackageVersionAsset
-> ReadPrec [GetPackageVersionAsset]
-> Read GetPackageVersionAsset
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetPackageVersionAsset]
$creadListPrec :: ReadPrec [GetPackageVersionAsset]
readPrec :: ReadPrec GetPackageVersionAsset
$creadPrec :: ReadPrec GetPackageVersionAsset
readList :: ReadS [GetPackageVersionAsset]
$creadList :: ReadS [GetPackageVersionAsset]
readsPrec :: Int -> ReadS GetPackageVersionAsset
$creadsPrec :: Int -> ReadS GetPackageVersionAsset
Prelude.Read, Int -> GetPackageVersionAsset -> ShowS
[GetPackageVersionAsset] -> ShowS
GetPackageVersionAsset -> String
(Int -> GetPackageVersionAsset -> ShowS)
-> (GetPackageVersionAsset -> String)
-> ([GetPackageVersionAsset] -> ShowS)
-> Show GetPackageVersionAsset
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetPackageVersionAsset] -> ShowS
$cshowList :: [GetPackageVersionAsset] -> ShowS
show :: GetPackageVersionAsset -> String
$cshow :: GetPackageVersionAsset -> String
showsPrec :: Int -> GetPackageVersionAsset -> ShowS
$cshowsPrec :: Int -> GetPackageVersionAsset -> ShowS
Prelude.Show, (forall x. GetPackageVersionAsset -> Rep GetPackageVersionAsset x)
-> (forall x.
    Rep GetPackageVersionAsset x -> GetPackageVersionAsset)
-> Generic GetPackageVersionAsset
forall x. Rep GetPackageVersionAsset x -> GetPackageVersionAsset
forall x. GetPackageVersionAsset -> Rep GetPackageVersionAsset x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetPackageVersionAsset x -> GetPackageVersionAsset
$cfrom :: forall x. GetPackageVersionAsset -> Rep GetPackageVersionAsset x
Prelude.Generic)

-- |
-- Create a value of 'GetPackageVersionAsset' 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:
--
-- 'namespace', 'getPackageVersionAsset_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', 'getPackageVersionAsset_domainOwner' - The 12-digit account number of the AWS account that owns the domain. It
-- does not include dashes or spaces.
--
-- 'packageVersionRevision', 'getPackageVersionAsset_packageVersionRevision' - The name of the package version revision that contains the requested
-- asset.
--
-- 'domain', 'getPackageVersionAsset_domain' - The name of the domain that contains the repository that contains the
-- package version with the requested asset.
--
-- 'repository', 'getPackageVersionAsset_repository' - The repository that contains the package version with the requested
-- asset.
--
-- 'format', 'getPackageVersionAsset_format' - A format that specifies the type of the package version with the
-- requested asset file. The valid values are:
--
-- -   @npm@
--
-- -   @pypi@
--
-- -   @maven@
--
-- 'package', 'getPackageVersionAsset_package' - The name of the package that contains the requested asset.
--
-- 'packageVersion', 'getPackageVersionAsset_packageVersion' - A string that contains the package version (for example, @3.5.2@).
--
-- 'asset', 'getPackageVersionAsset_asset' - The name of the requested asset.
newGetPackageVersionAsset ::
  -- | 'domain'
  Prelude.Text ->
  -- | 'repository'
  Prelude.Text ->
  -- | 'format'
  PackageFormat ->
  -- | 'package'
  Prelude.Text ->
  -- | 'packageVersion'
  Prelude.Text ->
  -- | 'asset'
  Prelude.Text ->
  GetPackageVersionAsset
newGetPackageVersionAsset :: Text
-> Text
-> PackageFormat
-> Text
-> Text
-> Text
-> GetPackageVersionAsset
newGetPackageVersionAsset
  Text
pDomain_
  Text
pRepository_
  PackageFormat
pFormat_
  Text
pPackage_
  Text
pPackageVersion_
  Text
pAsset_ =
    GetPackageVersionAsset' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Text
-> Text
-> PackageFormat
-> Text
-> Text
-> Text
-> GetPackageVersionAsset
GetPackageVersionAsset'
      { $sel:namespace:GetPackageVersionAsset' :: Maybe Text
namespace =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:domainOwner:GetPackageVersionAsset' :: Maybe Text
domainOwner = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:packageVersionRevision:GetPackageVersionAsset' :: Maybe Text
packageVersionRevision = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:domain:GetPackageVersionAsset' :: Text
domain = Text
pDomain_,
        $sel:repository:GetPackageVersionAsset' :: Text
repository = Text
pRepository_,
        $sel:format:GetPackageVersionAsset' :: PackageFormat
format = PackageFormat
pFormat_,
        $sel:package:GetPackageVersionAsset' :: Text
package = Text
pPackage_,
        $sel:packageVersion:GetPackageVersionAsset' :: Text
packageVersion = Text
pPackageVersion_,
        $sel:asset:GetPackageVersionAsset' :: Text
asset = Text
pAsset_
      }

-- | 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.
getPackageVersionAsset_namespace :: Lens.Lens' GetPackageVersionAsset (Prelude.Maybe Prelude.Text)
getPackageVersionAsset_namespace :: (Maybe Text -> f (Maybe Text))
-> GetPackageVersionAsset -> f GetPackageVersionAsset
getPackageVersionAsset_namespace = (GetPackageVersionAsset -> Maybe Text)
-> (GetPackageVersionAsset -> Maybe Text -> GetPackageVersionAsset)
-> Lens
     GetPackageVersionAsset
     GetPackageVersionAsset
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPackageVersionAsset' {Maybe Text
namespace :: Maybe Text
$sel:namespace:GetPackageVersionAsset' :: GetPackageVersionAsset -> Maybe Text
namespace} -> Maybe Text
namespace) (\s :: GetPackageVersionAsset
s@GetPackageVersionAsset' {} Maybe Text
a -> GetPackageVersionAsset
s {$sel:namespace:GetPackageVersionAsset' :: Maybe Text
namespace = Maybe Text
a} :: GetPackageVersionAsset)

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

-- | The name of the package version revision that contains the requested
-- asset.
getPackageVersionAsset_packageVersionRevision :: Lens.Lens' GetPackageVersionAsset (Prelude.Maybe Prelude.Text)
getPackageVersionAsset_packageVersionRevision :: (Maybe Text -> f (Maybe Text))
-> GetPackageVersionAsset -> f GetPackageVersionAsset
getPackageVersionAsset_packageVersionRevision = (GetPackageVersionAsset -> Maybe Text)
-> (GetPackageVersionAsset -> Maybe Text -> GetPackageVersionAsset)
-> Lens
     GetPackageVersionAsset
     GetPackageVersionAsset
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPackageVersionAsset' {Maybe Text
packageVersionRevision :: Maybe Text
$sel:packageVersionRevision:GetPackageVersionAsset' :: GetPackageVersionAsset -> Maybe Text
packageVersionRevision} -> Maybe Text
packageVersionRevision) (\s :: GetPackageVersionAsset
s@GetPackageVersionAsset' {} Maybe Text
a -> GetPackageVersionAsset
s {$sel:packageVersionRevision:GetPackageVersionAsset' :: Maybe Text
packageVersionRevision = Maybe Text
a} :: GetPackageVersionAsset)

-- | The name of the domain that contains the repository that contains the
-- package version with the requested asset.
getPackageVersionAsset_domain :: Lens.Lens' GetPackageVersionAsset Prelude.Text
getPackageVersionAsset_domain :: (Text -> f Text)
-> GetPackageVersionAsset -> f GetPackageVersionAsset
getPackageVersionAsset_domain = (GetPackageVersionAsset -> Text)
-> (GetPackageVersionAsset -> Text -> GetPackageVersionAsset)
-> Lens GetPackageVersionAsset GetPackageVersionAsset Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPackageVersionAsset' {Text
domain :: Text
$sel:domain:GetPackageVersionAsset' :: GetPackageVersionAsset -> Text
domain} -> Text
domain) (\s :: GetPackageVersionAsset
s@GetPackageVersionAsset' {} Text
a -> GetPackageVersionAsset
s {$sel:domain:GetPackageVersionAsset' :: Text
domain = Text
a} :: GetPackageVersionAsset)

-- | The repository that contains the package version with the requested
-- asset.
getPackageVersionAsset_repository :: Lens.Lens' GetPackageVersionAsset Prelude.Text
getPackageVersionAsset_repository :: (Text -> f Text)
-> GetPackageVersionAsset -> f GetPackageVersionAsset
getPackageVersionAsset_repository = (GetPackageVersionAsset -> Text)
-> (GetPackageVersionAsset -> Text -> GetPackageVersionAsset)
-> Lens GetPackageVersionAsset GetPackageVersionAsset Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPackageVersionAsset' {Text
repository :: Text
$sel:repository:GetPackageVersionAsset' :: GetPackageVersionAsset -> Text
repository} -> Text
repository) (\s :: GetPackageVersionAsset
s@GetPackageVersionAsset' {} Text
a -> GetPackageVersionAsset
s {$sel:repository:GetPackageVersionAsset' :: Text
repository = Text
a} :: GetPackageVersionAsset)

-- | A format that specifies the type of the package version with the
-- requested asset file. The valid values are:
--
-- -   @npm@
--
-- -   @pypi@
--
-- -   @maven@
getPackageVersionAsset_format :: Lens.Lens' GetPackageVersionAsset PackageFormat
getPackageVersionAsset_format :: (PackageFormat -> f PackageFormat)
-> GetPackageVersionAsset -> f GetPackageVersionAsset
getPackageVersionAsset_format = (GetPackageVersionAsset -> PackageFormat)
-> (GetPackageVersionAsset
    -> PackageFormat -> GetPackageVersionAsset)
-> Lens
     GetPackageVersionAsset
     GetPackageVersionAsset
     PackageFormat
     PackageFormat
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPackageVersionAsset' {PackageFormat
format :: PackageFormat
$sel:format:GetPackageVersionAsset' :: GetPackageVersionAsset -> PackageFormat
format} -> PackageFormat
format) (\s :: GetPackageVersionAsset
s@GetPackageVersionAsset' {} PackageFormat
a -> GetPackageVersionAsset
s {$sel:format:GetPackageVersionAsset' :: PackageFormat
format = PackageFormat
a} :: GetPackageVersionAsset)

-- | The name of the package that contains the requested asset.
getPackageVersionAsset_package :: Lens.Lens' GetPackageVersionAsset Prelude.Text
getPackageVersionAsset_package :: (Text -> f Text)
-> GetPackageVersionAsset -> f GetPackageVersionAsset
getPackageVersionAsset_package = (GetPackageVersionAsset -> Text)
-> (GetPackageVersionAsset -> Text -> GetPackageVersionAsset)
-> Lens GetPackageVersionAsset GetPackageVersionAsset Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPackageVersionAsset' {Text
package :: Text
$sel:package:GetPackageVersionAsset' :: GetPackageVersionAsset -> Text
package} -> Text
package) (\s :: GetPackageVersionAsset
s@GetPackageVersionAsset' {} Text
a -> GetPackageVersionAsset
s {$sel:package:GetPackageVersionAsset' :: Text
package = Text
a} :: GetPackageVersionAsset)

-- | A string that contains the package version (for example, @3.5.2@).
getPackageVersionAsset_packageVersion :: Lens.Lens' GetPackageVersionAsset Prelude.Text
getPackageVersionAsset_packageVersion :: (Text -> f Text)
-> GetPackageVersionAsset -> f GetPackageVersionAsset
getPackageVersionAsset_packageVersion = (GetPackageVersionAsset -> Text)
-> (GetPackageVersionAsset -> Text -> GetPackageVersionAsset)
-> Lens GetPackageVersionAsset GetPackageVersionAsset Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPackageVersionAsset' {Text
packageVersion :: Text
$sel:packageVersion:GetPackageVersionAsset' :: GetPackageVersionAsset -> Text
packageVersion} -> Text
packageVersion) (\s :: GetPackageVersionAsset
s@GetPackageVersionAsset' {} Text
a -> GetPackageVersionAsset
s {$sel:packageVersion:GetPackageVersionAsset' :: Text
packageVersion = Text
a} :: GetPackageVersionAsset)

-- | The name of the requested asset.
getPackageVersionAsset_asset :: Lens.Lens' GetPackageVersionAsset Prelude.Text
getPackageVersionAsset_asset :: (Text -> f Text)
-> GetPackageVersionAsset -> f GetPackageVersionAsset
getPackageVersionAsset_asset = (GetPackageVersionAsset -> Text)
-> (GetPackageVersionAsset -> Text -> GetPackageVersionAsset)
-> Lens GetPackageVersionAsset GetPackageVersionAsset Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPackageVersionAsset' {Text
asset :: Text
$sel:asset:GetPackageVersionAsset' :: GetPackageVersionAsset -> Text
asset} -> Text
asset) (\s :: GetPackageVersionAsset
s@GetPackageVersionAsset' {} Text
a -> GetPackageVersionAsset
s {$sel:asset:GetPackageVersionAsset' :: Text
asset = Text
a} :: GetPackageVersionAsset)

instance Core.AWSRequest GetPackageVersionAsset where
  type
    AWSResponse GetPackageVersionAsset =
      GetPackageVersionAssetResponse
  request :: GetPackageVersionAsset -> Request GetPackageVersionAsset
request = Service -> GetPackageVersionAsset -> Request GetPackageVersionAsset
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetPackageVersionAsset
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetPackageVersionAsset)))
response =
    (Int
 -> ResponseHeaders
 -> ResponseBody
 -> Either String (AWSResponse GetPackageVersionAsset))
-> Logger
-> Service
-> Proxy GetPackageVersionAsset
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetPackageVersionAsset)))
forall (m :: * -> *) a.
MonadResource m =>
(Int
 -> ResponseHeaders
 -> ResponseBody
 -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveBody
      ( \Int
s ResponseHeaders
h ResponseBody
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> ResponseBody
-> GetPackageVersionAssetResponse
GetPackageVersionAssetResponse'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Int
 -> ResponseBody
 -> GetPackageVersionAssetResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text
      -> Int
      -> ResponseBody
      -> GetPackageVersionAssetResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (ResponseHeaders
h ResponseHeaders -> HeaderName -> Either String (Maybe Text)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"X-PackageVersion")
            Either
  String
  (Maybe Text
   -> Maybe Text
   -> Int
   -> ResponseBody
   -> GetPackageVersionAssetResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Int -> ResponseBody -> GetPackageVersionAssetResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (ResponseHeaders
h ResponseHeaders -> HeaderName -> Either String (Maybe Text)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"X-AssetName")
            Either
  String
  (Maybe Text
   -> Int -> ResponseBody -> GetPackageVersionAssetResponse)
-> Either String (Maybe Text)
-> Either
     String (Int -> ResponseBody -> GetPackageVersionAssetResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (ResponseHeaders
h ResponseHeaders -> HeaderName -> Either String (Maybe Text)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"X-PackageVersionRevision")
            Either
  String (Int -> ResponseBody -> GetPackageVersionAssetResponse)
-> Either String Int
-> Either String (ResponseBody -> GetPackageVersionAssetResponse)
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))
            Either String (ResponseBody -> GetPackageVersionAssetResponse)
-> Either String ResponseBody
-> Either String GetPackageVersionAssetResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (ResponseBody -> Either String ResponseBody
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure ResponseBody
x)
      )

instance Prelude.Hashable GetPackageVersionAsset

instance Prelude.NFData GetPackageVersionAsset

instance Core.ToHeaders GetPackageVersionAsset where
  toHeaders :: GetPackageVersionAsset -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetPackageVersionAsset -> 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 GetPackageVersionAsset where
  toPath :: GetPackageVersionAsset -> ByteString
toPath = ByteString -> GetPackageVersionAsset -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/v1/package/version/asset"

instance Core.ToQuery GetPackageVersionAsset where
  toQuery :: GetPackageVersionAsset -> QueryString
toQuery GetPackageVersionAsset' {Maybe Text
Text
PackageFormat
asset :: Text
packageVersion :: Text
package :: Text
format :: PackageFormat
repository :: Text
domain :: Text
packageVersionRevision :: Maybe Text
domainOwner :: Maybe Text
namespace :: Maybe Text
$sel:asset:GetPackageVersionAsset' :: GetPackageVersionAsset -> Text
$sel:packageVersion:GetPackageVersionAsset' :: GetPackageVersionAsset -> Text
$sel:package:GetPackageVersionAsset' :: GetPackageVersionAsset -> Text
$sel:format:GetPackageVersionAsset' :: GetPackageVersionAsset -> PackageFormat
$sel:repository:GetPackageVersionAsset' :: GetPackageVersionAsset -> Text
$sel:domain:GetPackageVersionAsset' :: GetPackageVersionAsset -> Text
$sel:packageVersionRevision:GetPackageVersionAsset' :: GetPackageVersionAsset -> Maybe Text
$sel:domainOwner:GetPackageVersionAsset' :: GetPackageVersionAsset -> Maybe Text
$sel:namespace:GetPackageVersionAsset' :: GetPackageVersionAsset -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ 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
"revision" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
packageVersionRevision,
        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,
        ByteString
"format" ByteString -> PackageFormat -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: PackageFormat
format,
        ByteString
"package" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
package,
        ByteString
"version" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
packageVersion,
        ByteString
"asset" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
asset
      ]

-- | /See:/ 'newGetPackageVersionAssetResponse' smart constructor.
data GetPackageVersionAssetResponse = GetPackageVersionAssetResponse'
  { -- | A string that contains the package version (for example, @3.5.2@).
    GetPackageVersionAssetResponse -> Maybe Text
packageVersion :: Prelude.Maybe Prelude.Text,
    -- | The name of the asset that is downloaded.
    GetPackageVersionAssetResponse -> Maybe Text
assetName :: Prelude.Maybe Prelude.Text,
    -- | The name of the package version revision that contains the downloaded
    -- asset.
    GetPackageVersionAssetResponse -> Maybe Text
packageVersionRevision :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetPackageVersionAssetResponse -> Int
httpStatus :: Prelude.Int,
    -- | The binary file, or asset, that is downloaded.
    GetPackageVersionAssetResponse -> ResponseBody
asset :: Core.ResponseBody
  }
  deriving (Int -> GetPackageVersionAssetResponse -> ShowS
[GetPackageVersionAssetResponse] -> ShowS
GetPackageVersionAssetResponse -> String
(Int -> GetPackageVersionAssetResponse -> ShowS)
-> (GetPackageVersionAssetResponse -> String)
-> ([GetPackageVersionAssetResponse] -> ShowS)
-> Show GetPackageVersionAssetResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetPackageVersionAssetResponse] -> ShowS
$cshowList :: [GetPackageVersionAssetResponse] -> ShowS
show :: GetPackageVersionAssetResponse -> String
$cshow :: GetPackageVersionAssetResponse -> String
showsPrec :: Int -> GetPackageVersionAssetResponse -> ShowS
$cshowsPrec :: Int -> GetPackageVersionAssetResponse -> ShowS
Prelude.Show, (forall x.
 GetPackageVersionAssetResponse
 -> Rep GetPackageVersionAssetResponse x)
-> (forall x.
    Rep GetPackageVersionAssetResponse x
    -> GetPackageVersionAssetResponse)
-> Generic GetPackageVersionAssetResponse
forall x.
Rep GetPackageVersionAssetResponse x
-> GetPackageVersionAssetResponse
forall x.
GetPackageVersionAssetResponse
-> Rep GetPackageVersionAssetResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetPackageVersionAssetResponse x
-> GetPackageVersionAssetResponse
$cfrom :: forall x.
GetPackageVersionAssetResponse
-> Rep GetPackageVersionAssetResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetPackageVersionAssetResponse' 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:
--
-- 'packageVersion', 'getPackageVersionAssetResponse_packageVersion' - A string that contains the package version (for example, @3.5.2@).
--
-- 'assetName', 'getPackageVersionAssetResponse_assetName' - The name of the asset that is downloaded.
--
-- 'packageVersionRevision', 'getPackageVersionAssetResponse_packageVersionRevision' - The name of the package version revision that contains the downloaded
-- asset.
--
-- 'httpStatus', 'getPackageVersionAssetResponse_httpStatus' - The response's http status code.
--
-- 'asset', 'getPackageVersionAssetResponse_asset' - The binary file, or asset, that is downloaded.
newGetPackageVersionAssetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'asset'
  Core.ResponseBody ->
  GetPackageVersionAssetResponse
newGetPackageVersionAssetResponse :: Int -> ResponseBody -> GetPackageVersionAssetResponse
newGetPackageVersionAssetResponse
  Int
pHttpStatus_
  ResponseBody
pAsset_ =
    GetPackageVersionAssetResponse' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> ResponseBody
-> GetPackageVersionAssetResponse
GetPackageVersionAssetResponse'
      { $sel:packageVersion:GetPackageVersionAssetResponse' :: Maybe Text
packageVersion =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:assetName:GetPackageVersionAssetResponse' :: Maybe Text
assetName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:packageVersionRevision:GetPackageVersionAssetResponse' :: Maybe Text
packageVersionRevision = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:GetPackageVersionAssetResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:asset:GetPackageVersionAssetResponse' :: ResponseBody
asset = ResponseBody
pAsset_
      }

-- | A string that contains the package version (for example, @3.5.2@).
getPackageVersionAssetResponse_packageVersion :: Lens.Lens' GetPackageVersionAssetResponse (Prelude.Maybe Prelude.Text)
getPackageVersionAssetResponse_packageVersion :: (Maybe Text -> f (Maybe Text))
-> GetPackageVersionAssetResponse
-> f GetPackageVersionAssetResponse
getPackageVersionAssetResponse_packageVersion = (GetPackageVersionAssetResponse -> Maybe Text)
-> (GetPackageVersionAssetResponse
    -> Maybe Text -> GetPackageVersionAssetResponse)
-> Lens
     GetPackageVersionAssetResponse
     GetPackageVersionAssetResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPackageVersionAssetResponse' {Maybe Text
packageVersion :: Maybe Text
$sel:packageVersion:GetPackageVersionAssetResponse' :: GetPackageVersionAssetResponse -> Maybe Text
packageVersion} -> Maybe Text
packageVersion) (\s :: GetPackageVersionAssetResponse
s@GetPackageVersionAssetResponse' {} Maybe Text
a -> GetPackageVersionAssetResponse
s {$sel:packageVersion:GetPackageVersionAssetResponse' :: Maybe Text
packageVersion = Maybe Text
a} :: GetPackageVersionAssetResponse)

-- | The name of the asset that is downloaded.
getPackageVersionAssetResponse_assetName :: Lens.Lens' GetPackageVersionAssetResponse (Prelude.Maybe Prelude.Text)
getPackageVersionAssetResponse_assetName :: (Maybe Text -> f (Maybe Text))
-> GetPackageVersionAssetResponse
-> f GetPackageVersionAssetResponse
getPackageVersionAssetResponse_assetName = (GetPackageVersionAssetResponse -> Maybe Text)
-> (GetPackageVersionAssetResponse
    -> Maybe Text -> GetPackageVersionAssetResponse)
-> Lens
     GetPackageVersionAssetResponse
     GetPackageVersionAssetResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPackageVersionAssetResponse' {Maybe Text
assetName :: Maybe Text
$sel:assetName:GetPackageVersionAssetResponse' :: GetPackageVersionAssetResponse -> Maybe Text
assetName} -> Maybe Text
assetName) (\s :: GetPackageVersionAssetResponse
s@GetPackageVersionAssetResponse' {} Maybe Text
a -> GetPackageVersionAssetResponse
s {$sel:assetName:GetPackageVersionAssetResponse' :: Maybe Text
assetName = Maybe Text
a} :: GetPackageVersionAssetResponse)

-- | The name of the package version revision that contains the downloaded
-- asset.
getPackageVersionAssetResponse_packageVersionRevision :: Lens.Lens' GetPackageVersionAssetResponse (Prelude.Maybe Prelude.Text)
getPackageVersionAssetResponse_packageVersionRevision :: (Maybe Text -> f (Maybe Text))
-> GetPackageVersionAssetResponse
-> f GetPackageVersionAssetResponse
getPackageVersionAssetResponse_packageVersionRevision = (GetPackageVersionAssetResponse -> Maybe Text)
-> (GetPackageVersionAssetResponse
    -> Maybe Text -> GetPackageVersionAssetResponse)
-> Lens
     GetPackageVersionAssetResponse
     GetPackageVersionAssetResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPackageVersionAssetResponse' {Maybe Text
packageVersionRevision :: Maybe Text
$sel:packageVersionRevision:GetPackageVersionAssetResponse' :: GetPackageVersionAssetResponse -> Maybe Text
packageVersionRevision} -> Maybe Text
packageVersionRevision) (\s :: GetPackageVersionAssetResponse
s@GetPackageVersionAssetResponse' {} Maybe Text
a -> GetPackageVersionAssetResponse
s {$sel:packageVersionRevision:GetPackageVersionAssetResponse' :: Maybe Text
packageVersionRevision = Maybe Text
a} :: GetPackageVersionAssetResponse)

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

-- | The binary file, or asset, that is downloaded.
getPackageVersionAssetResponse_asset :: Lens.Lens' GetPackageVersionAssetResponse Core.ResponseBody
getPackageVersionAssetResponse_asset :: (ResponseBody -> f ResponseBody)
-> GetPackageVersionAssetResponse
-> f GetPackageVersionAssetResponse
getPackageVersionAssetResponse_asset = (GetPackageVersionAssetResponse -> ResponseBody)
-> (GetPackageVersionAssetResponse
    -> ResponseBody -> GetPackageVersionAssetResponse)
-> Lens
     GetPackageVersionAssetResponse
     GetPackageVersionAssetResponse
     ResponseBody
     ResponseBody
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPackageVersionAssetResponse' {ResponseBody
asset :: ResponseBody
$sel:asset:GetPackageVersionAssetResponse' :: GetPackageVersionAssetResponse -> ResponseBody
asset} -> ResponseBody
asset) (\s :: GetPackageVersionAssetResponse
s@GetPackageVersionAssetResponse' {} ResponseBody
a -> GetPackageVersionAssetResponse
s {$sel:asset:GetPackageVersionAssetResponse' :: ResponseBody
asset = ResponseBody
a} :: GetPackageVersionAssetResponse)