Skip to content

copy_package_versions async

copy_package_versions(
    domain: DomainName,
    source_repository: RepositoryName,
    destination_repository: RepositoryName,
    format: PackageFormat,
    package: PackageName,
    *,
    config_overrides: Optional[AsynccodeartifactClientConfig] = None,
    domain_owner: Optional[AccountId] = None,
    namespace: Optional[PackageNamespace] = None,
    versions: Optional[PackageVersionList] = None,
    version_revisions: Optional[PackageVersionRevisionMap] = None,
    allow_overwrite: Optional[BooleanOptional] = None,
    include_from_upstream: Optional[BooleanOptional] = None,
) -> CopyPackageVersionsResult

Copies package versions from one repository to another repository in the same domain.

You must specify versions or versionRevisions. You cannot specify both.

Parameters:

  • domain (DomainName) –

    The name of the domain that contains the source and destination repositories.

  • 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.

  • source_repository (RepositoryName) –

    The name of the repository that contains the package versions to be copied.

  • destination_repository (RepositoryName) –

    The name of the repository into which package versions are copied.

  • format (PackageFormat) –

    The format of the package versions to be copied.

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

    The namespace of the package versions to be copied. The package component that specifies its namespace depends on its type. For example:

    The namespace is required when copying 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 versions to be copied.

  • versions (Optional[PackageVersionList], default: None ) –

    The versions of the package to be copied.

    You must specify versions or versionRevisions. You cannot specify both.

  • version_revisions (Optional[PackageVersionRevisionMap], default: None ) –

    A list of key-value pairs. The keys are package versions and the values are package version revisions. A CopyPackageVersion operation succeeds if the specified versions in the source repository match the specified package version revision.

    You must specify versions or versionRevisions. You cannot specify both.

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

    Set to true to overwrite a package version that already exists in the destination repository. If set to false and the package version already exists in the destination repository, the package version is returned in the failedVersions field of the response with an ALREADY_EXISTS error code.

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

    Set to true to copy packages from repositories that are upstream from the source repository to the destination repository. The default setting is false. For more information, see Working with upstream repositories.

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/async_codeartifact.py
async def copy_package_versions(
    self,
    domain: "capo_codeartifact.types.domain_name.DomainName",
    source_repository: "capo_codeartifact.types.repository_name.RepositoryName",
    destination_repository: "capo_codeartifact.types.repository_name.RepositoryName",
    format: "capo_codeartifact.types.package_format.PackageFormat",
    package: "capo_codeartifact.types.package_name.PackageName",
    *,
    config_overrides: Optional[AsynccodeartifactClientConfig] = None,
    domain_owner: Optional["capo_codeartifact.types.account_id.AccountId"] = None,
    namespace: Optional[
        "capo_codeartifact.types.package_namespace.PackageNamespace"
    ] = None,
    versions: Optional[
        "capo_codeartifact.types.package_version_list.PackageVersionList"
    ] = None,
    version_revisions: Optional[
        "capo_codeartifact.types.package_version_revision_map.PackageVersionRevisionMap"
    ] = None,
    allow_overwrite: Optional[
        "capo_codeartifact.types.boolean_optional.BooleanOptional"
    ] = None,
    include_from_upstream: Optional[
        "capo_codeartifact.types.boolean_optional.BooleanOptional"
    ] = None,
) -> (
    "capo_codeartifact.types.copy_package_versions_result.CopyPackageVersionsResult"
):
    """<p> Copies package versions from one repository to another repository in the same domain. </p> <note> <p> You must specify <code>versions</code> or <code>versionRevisions</code>. You cannot specify both. </p> </note>

    Args:
        domain: <p> The name of the domain that contains the source and destination repositories. </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>
        source_repository: <p> The name of the repository that contains the package versions to be copied. </p>
        destination_repository: <p> The name of the repository into which package versions are copied. </p>
        format: <p> The format of the package versions to be copied. </p>
        namespace: <p>The namespace of the package versions to be copied. The package component that specifies its namespace depends on its type. For example:</p> <note> <p>The namespace is required when copying 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 versions to be copied. </p>
        versions: <p> The versions of the package to be copied. </p> <note> <p> You must specify <code>versions</code> or <code>versionRevisions</code>. You cannot specify both. </p> </note>
        version_revisions: <p> A list of key-value pairs. The keys are package versions and the values are package version revisions. A <code>CopyPackageVersion</code> operation succeeds if the specified versions in the source repository match the specified package version revision. </p> <note> <p> You must specify <code>versions</code> or <code>versionRevisions</code>. You cannot specify both. </p> </note>
        allow_overwrite: <p> Set to true to overwrite a package version that already exists in the destination repository. If set to false and the package version already exists in the destination repository, the package version is returned in the <code>failedVersions</code> field of the response with an <code>ALREADY_EXISTS</code> error code. </p>
        include_from_upstream: <p> Set to true to copy packages from repositories that are upstream from the source repository to the destination repository. The default setting is false. For more information, see <a href="https://docs.aws.amazon.com/codeartifact/latest/ug/repos-upstream.html">Working with upstream repositories</a>. </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.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_codeartifact.types.copy_package_versions_request.CopyPackageVersionsRequest]",
    ) -> AsyncOperationResponse[
        "capo_codeartifact.types.copy_package_versions_result.CopyPackageVersionsResult"
    ]:
        import capo_codeartifact._operations.code_artifact_control_plane_service.copy_package_versions

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CopyPackageVersions")
    )
    input_: capo_codeartifact.types.copy_package_versions_request.CopyPackageVersionsRequest = {
        "domain": domain,
        "source_repository": source_repository,
        "destination_repository": destination_repository,
        "format": format,
        "package": package,
    }
    if domain_owner is not None:
        input_["domain_owner"] = domain_owner
    if namespace is not None:
        input_["namespace"] = namespace
    if versions is not None:
        input_["versions"] = versions
    if version_revisions is not None:
        input_["version_revisions"] = version_revisions
    if allow_overwrite is not None:
        input_["allow_overwrite"] = allow_overwrite
    if include_from_upstream is not None:
        input_["include_from_upstream"] = include_from_upstream

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