Skip to content

get_package_version_asset async

get_package_version_asset(
    domain: DomainName,
    repository: RepositoryName,
    format: PackageFormat,
    package: PackageName,
    package_version: PackageVersion,
    asset: AssetName,
    *,
    config_overrides: Optional[AsynccodeartifactClientConfig] = None,
    domain_owner: Optional[AccountId] = None,
    namespace: Optional[PackageNamespace] = None,
    package_version_revision: Optional[PackageVersionRevision] = None,
) -> AsyncGenerator[GetPackageVersionAssetResult]

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.

Parameters:

  • domain (DomainName) –

    The name of the domain that contains the repository that contains the package version with the requested asset.

  • domain_owner (Optional[AccountId], default: None ) –

    The 12-digit account number of the Amazon Web Services account that owns the domain. It does not include dashes or spaces.

  • repository (RepositoryName) –

    The repository that contains the package version with the requested asset.

  • format (PackageFormat) –

    A format that specifies the type of the package version with the requested asset file.

  • namespace (Optional[PackageNamespace], default: None ) –

    The namespace of the package version with the requested asset file. The package component that specifies its namespace depends on its type. For example:

    The namespace is required when requesting assets from package versions of the following formats:

    • Maven

    • Swift

    • generic

    • The namespace of a Maven package version is its groupId.

    • The namespace of an npm or Swift package version is its scope.

    • The namespace of a generic package is its namespace.

    • Python, NuGet, Ruby, and Cargo package versions do not contain a corresponding component, package versions of those formats do not have a namespace.

  • package (PackageName) –

    The name of the package that contains the requested asset.

  • package_version (PackageVersion) –

    A string that contains the package version (for example, 3.5.2).

  • asset (AssetName) –

    The name of the requested asset.

  • package_version_revision (Optional[PackageVersionRevision], default: None ) –

    The name of the package version revision that contains the requested asset.

Raises:

  • AccessDeniedException –

    The operation did not succeed because of an unauthorized access attempt.

  • ConflictException –

    The operation did not succeed because prerequisites are not met.

  • InternalServerException –

    The operation did not succeed because of an error that occurred inside CodeArtifact.

  • ResourceNotFoundException –

    The operation did not succeed because the resource requested is not found in the service.

  • ThrottlingException –

    The operation did not succeed because too many requests are sent to the service.

  • ValidationException –

    The operation did not succeed because a parameter in the request was sent with an invalid value.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_codeartifact/_services/async_codeartifact.py
@asynccontextmanager
async def get_package_version_asset(
    self,
    domain: "capo_codeartifact.types.domain_name.DomainName",
    repository: "capo_codeartifact.types.repository_name.RepositoryName",
    format: "capo_codeartifact.types.package_format.PackageFormat",
    package: "capo_codeartifact.types.package_name.PackageName",
    package_version: "capo_codeartifact.types.package_version.PackageVersion",
    asset: "capo_codeartifact.types.asset_name.AssetName",
    *,
    config_overrides: Optional[AsynccodeartifactClientConfig] = None,
    domain_owner: Optional["capo_codeartifact.types.account_id.AccountId"] = None,
    namespace: Optional[
        "capo_codeartifact.types.package_namespace.PackageNamespace"
    ] = None,
    package_version_revision: Optional[
        "capo_codeartifact.types.package_version_revision.PackageVersionRevision"
    ] = None,
) -> "AsyncGenerator[capo_codeartifact.types.get_package_version_asset_result.GetPackageVersionAssetResult]":
    """<p> Returns an asset (or file) that is in a package. For example, for a Maven package version, use <code>GetPackageVersionAsset</code> to download a <code>JAR</code> file, a <code>POM</code> file, or any other assets in the package version. </p>

    Args:
        domain: <p> The name of the domain that contains the repository that contains the package version with the requested asset. </p>
        domain_owner: <p> The 12-digit account number of the Amazon Web Services account that owns the domain. It does not include dashes or spaces. </p>
        repository: <p> The repository that contains the package version with the requested asset. </p>
        format: <p> A format that specifies the type of the package version with the requested asset file. </p>
        namespace: <p>The namespace of the package version with the requested asset file. The package component that specifies its namespace depends on its type. For example:</p> <note> <p>The namespace is required when requesting assets from package versions of the following formats:</p> <ul> <li> <p>Maven</p> </li> <li> <p>Swift</p> </li> <li> <p>generic</p> </li> </ul> </note> <ul> <li> <p> The namespace of a Maven package version is its <code>groupId</code>. </p> </li> <li> <p> The namespace of an npm or Swift package version is its <code>scope</code>. </p> </li> <li> <p>The namespace of a generic package is its <code>namespace</code>.</p> </li> <li> <p> Python, NuGet, Ruby, and Cargo package versions do not contain a corresponding component, package versions of those formats do not have a namespace. </p> </li> </ul>
        package: <p> The name of the package that contains the requested asset. </p>
        package_version: <p> A string that contains the package version (for example, <code>3.5.2</code>). </p>
        asset: <p> The name of the requested asset. </p>
        package_version_revision: <p> The name of the package version revision that contains the requested asset. </p>

    Raises:
        capo_codeartifact.errors.access_denied_exception.AccessDeniedException: <p> The operation did not succeed because of an unauthorized access attempt. </p>
        capo_codeartifact.errors.conflict_exception.ConflictException: <p> The operation did not succeed because prerequisites are not met. </p>
        capo_codeartifact.errors.internal_server_exception.InternalServerException: <p> The operation did not succeed because of an error that occurred inside CodeArtifact. </p>
        capo_codeartifact.errors.resource_not_found_exception.ResourceNotFoundException: <p> The operation did not succeed because the resource requested is not found in the service. </p>
        capo_codeartifact.errors.throttling_exception.ThrottlingException: <p> The operation did not succeed because too many requests are sent to the service. </p>
        capo_codeartifact.errors.validation_exception.ValidationException: <p> The operation did not succeed because a parameter in the request was sent with an invalid value. </p>
        capo_codeartifact.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_codeartifact.types.get_package_version_asset_request.GetPackageVersionAssetRequest]",
    ) -> AsyncOperationResponse[
        "capo_codeartifact.types.get_package_version_asset_result.GetPackageVersionAssetResult"
    ]:
        import capo_codeartifact._operations.code_artifact_control_plane_service.get_package_version_asset

        (
            output,
            http_response,
        ) = await capo_codeartifact._operations.code_artifact_control_plane_service.get_package_version_asset.async_get_package_version_asset(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_codeartifact.types.get_package_version_asset_result.GetPackageVersionAssetResult",
    ) -> dict[str, Any]:
        import capo_codeartifact.types.get_package_version_asset_result

        return capo_codeartifact.types.get_package_version_asset_result.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("GetPackageVersionAsset", redact_output=_redact_output),
    )
    input_: capo_codeartifact.types.get_package_version_asset_request.GetPackageVersionAssetRequest = {
        "domain": domain,
        "repository": repository,
        "format": format,
        "package": package,
        "package_version": package_version,
        "asset": asset,
    }
    if domain_owner is not None:
        input_["domain_owner"] = domain_owner
    if namespace is not None:
        input_["namespace"] = namespace
    if package_version_revision is not None:
        input_["package_version_revision"] = package_version_revision

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    try:
        yield response.output
    finally:
        await response.response.aclose()