publishPackageVersion method
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.
May throw AccessDeniedException.
May throw ConflictException.
May throw InternalServerException.
May throw ResourceNotFoundException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
May throw ValidationException.
Parameter assetContent :
The content of the asset to publish.
Parameter assetName :
The name of the asset to publish. Asset names can include Unicode letters
and numbers, and the following special characters: ~ ! @ ^ & ( ) - _ + \[ \] { } ; , .
Parameter assetSHA256 :
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.
Parameter domain :
The name of the domain that contains the repository that contains the
package version to publish.
Parameter format :
A format that specifies the type of the package version with the requested
asset file.
The only supported value is generic.
Parameter package :
The name of the package version to publish.
Parameter packageVersion :
The package version to publish (for example, 3.5.2).
Parameter repository :
The name of the repository that the package version will be published to.
Parameter domainOwner :
The 12-digit account number of the AWS account that owns the domain. It
does not include dashes or spaces.
Parameter namespace :
The namespace of the package version to publish.
Parameter unfinished :
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
Implementation
Future<PublishPackageVersionResult> publishPackageVersion({
required Uint8List assetContent,
required String assetName,
required String assetSHA256,
required String domain,
required PackageFormat format,
required String package,
required String packageVersion,
required String repository,
String? domainOwner,
String? namespace,
bool? unfinished,
}) async {
final headers = <String, String>{
'x-amz-content-sha256': assetSHA256.toString(),
};
final $query = <String, List<String>>{
'asset': [assetName],
'domain': [domain],
'format': [format.value],
'package': [package],
'version': [packageVersion],
'repository': [repository],
if (domainOwner != null) 'domain-owner': [domainOwner],
if (namespace != null) 'namespace': [namespace],
if (unfinished != null) 'unfinished': [unfinished.toString()],
};
final response = await _protocol.send(
payload: assetContent,
method: 'POST',
requestUri: '/v1/package/version/publish',
queryParams: $query,
headers: headers,
exceptionFnMap: _exceptionFns,
);
return PublishPackageVersionResult.fromJson(response);
}