putPackageOriginConfiguration method
Sets the package origin configuration for a package.
The package origin configuration determines how new versions of a package can be added to a repository. You can allow or block direct publishing of new package versions, or ingestion and retaining of new package versions from an external connection or upstream source. For more information about package origin controls and configuration, see Editing package origin controls in the CodeArtifact User Guide.
PutPackageOriginConfiguration can be called on a package that
doesn't yet exist in the repository. When called on a package that does
not exist, a package is created in the repository with no versions and the
requested restrictions are set on the package. This can be used to
preemptively block ingesting or retaining any versions from external
connections or upstream repositories, or to block publishing any versions
of the package into the repository before connecting any package managers
or publishers to the repository.
May throw AccessDeniedException.
May throw InternalServerException.
May throw ResourceNotFoundException.
May throw ThrottlingException.
May throw ValidationException.
Parameter domain :
The name of the domain that contains the repository that contains the
package.
Parameter format :
A format that specifies the type of the package to be updated.
Parameter package :
The name of the package to be updated.
Parameter repository :
The name of the repository that contains the package.
Parameter restrictions :
A PackageOriginRestrictions
object that contains information about the upstream and
publish package origin restrictions. The
upstream restriction determines if new package versions can
be ingested or retained from external connections or upstream
repositories. The publish restriction determines if new
package versions can be published directly to the repository.
You must include both the desired upstream and
publish restrictions.
Parameter domainOwner :
The 12-digit account number of the Amazon Web Services account that owns
the domain. It does not include dashes or spaces.
Parameter namespace :
The namespace of the package to be updated. The package component that
specifies its namespace depends on its type. For example:
-
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.
Implementation
Future<PutPackageOriginConfigurationResult> putPackageOriginConfiguration({
required String domain,
required PackageFormat format,
required String package,
required String repository,
required PackageOriginRestrictions restrictions,
String? domainOwner,
String? namespace,
}) async {
final $query = <String, List<String>>{
'domain': [domain],
'format': [format.value],
'package': [package],
'repository': [repository],
if (domainOwner != null) 'domain-owner': [domainOwner],
if (namespace != null) 'namespace': [namespace],
};
final $payload = <String, dynamic>{
'restrictions': restrictions,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/v1/package',
queryParams: $query,
exceptionFnMap: _exceptionFns,
);
return PutPackageOriginConfigurationResult.fromJson(response);
}