Skip to content

publish_package_version

publish_package_version(
    domain: DomainName,
    repository: RepositoryName,
    format: PackageFormat,
    package: PackageName,
    package_version: PackageVersion,
    asset_content: Body[Iterator[bytes]] | Iterator[bytes] | bytes,
    asset_name: AssetName,
    asset_sha256: SHA256,
    *,
    config_overrides: Optional[codeartifactClientConfig] = None,
    domain_owner: Optional[AccountId] = None,
    namespace: Optional[PackageNamespace] = None,
    unfinished: Optional[BooleanOptional] = None,
) -> PublishPackageVersionResult

Creates a new package version containing one or more assets (or files).

The unfinished flag can be used to keep the package version in the Unfinished state until all of its assets have been uploaded (see Package version status in the CodeArtifact user guide). To set the package version’s status to Published, omit the unfinished flag when uploading the final asset, or set the status using UpdatePackageVersionStatus. Once a package version’s status is set to Published, it cannot change back to Unfinished.

Only generic packages can be published using this API. For more information, see Using generic packages in the CodeArtifact User Guide.

Parameters:

  • domain (DomainName) –

    The name of the domain that contains the repository that contains the package version to publish.

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

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

  • repository (RepositoryName) –

    The name of the repository that the package version will be published to.

  • format (PackageFormat) –

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

    The only supported value is generic.

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

    The namespace of the package version to publish.

  • package (PackageName) –

    The name of the package version to publish.

  • package_version (PackageVersion) –

    The package version to publish (for example, 3.5.2).

  • asset_content (Body[Iterator[bytes]] | Iterator[bytes] | bytes) –

    The content of the asset to publish.

  • asset_name (AssetName) –

    The name of the asset to publish. Asset names can include Unicode letters and numbers, and the following special characters: ~ ! @ ^ & ( ) - ` _ + [ ] { } ; , . `

  • asset_sha256 (SHA256) –

    The SHA256 hash of the assetContent to publish. This value must be calculated by the caller and provided with the request (see Publishing a generic package in the CodeArtifact User Guide).

    This value is used as an integrity check to verify that the assetContent has not changed after it was originally sent.

  • unfinished (Optional[BooleanOptional], default: None ) –

    Specifies whether the package version should remain in the unfinished state. If omitted, the package version status will be set to Published (see Package version status in the CodeArtifact User Guide).

    Valid values: unfinished

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.

  • ServiceQuotaExceededException –

    The operation did not succeed because it would have exceeded a service limit for your account.

  • 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/codeartifact.py
def publish_package_version(
    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_content: Body[Iterator[bytes]] | Iterator[bytes] | bytes,
    asset_name: "capo_codeartifact.types.asset_name.AssetName",
    asset_sha256: "capo_codeartifact.types.sha256.SHA256",
    *,
    config_overrides: Optional[codeartifactClientConfig] = None,
    domain_owner: Optional["capo_codeartifact.types.account_id.AccountId"] = None,
    namespace: Optional[
        "capo_codeartifact.types.package_namespace.PackageNamespace"
    ] = None,
    unfinished: Optional[
        "capo_codeartifact.types.boolean_optional.BooleanOptional"
    ] = None,
) -> "capo_codeartifact.types.publish_package_version_result.PublishPackageVersionResult":
    """<p>Creates a new package version containing one or more assets (or files).</p> <p>The <code>unfinished</code> flag can be used to keep the package version in the <code>Unfinished</code> state until all of its assets have been uploaded (see <a href="https://docs.aws.amazon.com/codeartifact/latest/ug/packages-overview.html#package-version-status.html#package-version-status">Package version status</a> in the <i>CodeArtifact user guide</i>). To set the package version’s status to <code>Published</code>, omit the <code>unfinished</code> flag when uploading the final asset, or set the status using <a href="https://docs.aws.amazon.com/codeartifact/latest/APIReference/API_UpdatePackageVersionsStatus.html">UpdatePackageVersionStatus</a>. Once a package version’s status is set to <code>Published</code>, it cannot change back to <code>Unfinished</code>.</p> <note> <p>Only generic packages can be published using this API. For more information, see <a href="https://docs.aws.amazon.com/codeartifact/latest/ug/using-generic.html">Using generic packages</a> in the <i>CodeArtifact User Guide</i>.</p> </note>

    Args:
        domain: <p>The name of the domain that contains the repository that contains the package version to publish.</p>
        domain_owner: <p>The 12-digit account number of the AWS account that owns the domain. It does not include dashes or spaces.</p>
        repository: <p>The name of the repository that the package version will be published to.</p>
        format: <p>A format that specifies the type of the package version with the requested asset file.</p> <p>The only supported value is <code>generic</code>.</p>
        namespace: <p>The namespace of the package version to publish.</p>
        package: <p>The name of the package version to publish.</p>
        package_version: <p>The package version to publish (for example, <code>3.5.2</code>).</p>
        asset_content: <p>The content of the asset to publish.</p>
        asset_name: <p>The name of the asset to publish. Asset names can include Unicode letters and numbers, and the following special characters: <code>~ ! @ ^ & ( ) - ` _ + [ ] { } ; , . `</code> </p>
        asset_sha256: <p>The SHA256 hash of the <code>assetContent</code> to publish. This value must be calculated by the caller and provided with the request (see <a href="https://docs.aws.amazon.com/codeartifact/latest/ug/using-generic.html#publishing-generic-packages">Publishing a generic package</a> in the <i>CodeArtifact User Guide</i>).</p> <p>This value is used as an integrity check to verify that the <code>assetContent</code> has not changed after it was originally sent.</p>
        unfinished: <p>Specifies whether the package version should remain in the <code>unfinished</code> state. If omitted, the package version status will be set to <code>Published</code> (see <a href="https://docs.aws.amazon.com/codeartifact/latest/ug/packages-overview.html#package-version-status">Package version status</a> in the <i>CodeArtifact User Guide</i>).</p> <p>Valid values: <code>unfinished</code> </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.service_quota_exceeded_exception.ServiceQuotaExceededException: <p> The operation did not succeed because it would have exceeded a service limit for your account. </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.
    """

    def _handler(
        req: "OperationRequest[capo_codeartifact.types.publish_package_version_request.PublishPackageVersionRequest]",
    ) -> OperationResponse[
        "capo_codeartifact.types.publish_package_version_result.PublishPackageVersionResult"
    ]:
        import capo_codeartifact._operations.code_artifact_control_plane_service.publish_package_version

        output, http_response = (
            capo_codeartifact._operations.code_artifact_control_plane_service.publish_package_version.publish_package_version(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_codeartifact.types.publish_package_version_request.PublishPackageVersionRequest",
    ) -> dict[str, Any]:
        import capo_codeartifact.types.publish_package_version_request

        return capo_codeartifact.types.publish_package_version_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("PublishPackageVersion", redact_input=_redact_input),
    )
    input_: capo_codeartifact.types.publish_package_version_request.PublishPackageVersionRequest = {
        "domain": domain,
        "repository": repository,
        "format": format,
        "package": package,
        "package_version": package_version,
        "asset_content": ensure_sync_iterator(asset_content),
        "asset_name": asset_name,
        "asset_sha256": asset_sha256,
    }
    if domain_owner is not None:
        input_["domain_owner"] = domain_owner
    if namespace is not None:
        input_["namespace"] = namespace
    if unfinished is not None:
        input_["unfinished"] = unfinished

    with closing_bodies(input_):
        response = execute_pipeline(
            OperationRequest(input=input_, options=options_),
            handler=_handler,
            interceptors=list(interceptors_),
        )
        response.response.close()
        return response.output