id: admin-api-packages title: Manage packages sidebar_label: Packages

Package management enables version management and simplifies the upgrade and rollback processes for Functions, Sinks, and Sources. When you use the same function, sink and source in different namespaces, you can upload them to a common package management system.

Package name

A package is identified by five parts: type, tenant, namespace, package name, and version.

PartDescription
typeThe type of the package. The following types are supported: function, sink and source.
nameThe fully qualified name of the package: <tenant>/<namespace>/<package name>.
versionThe version of the package.

The following is a code sample.

class PackageName {
   private final PackageType type;
   private final String namespace;
   private final String tenant;
   private final String name;
   private final String version;
}

enum PackageType {
   FUNCTION("function"), SINK("sink"), SOURCE("source");
}

Package URL

A package is located using a URL. The package URL is written in the following format:

<type>://<tenant>/<namespace>/<package name>@<version>

The following are package URL examples:

sink://public/default/mysql-sink@1.0
function://my-tenant/my-ns/my-function@0.1
source://my-tenant/my-ns/mysql-cdc-source@2.3

The package management system stores the data, versions and metadata of each package. The metadata is shown in the following table.

metadataDescription
descriptionThe description of the package.
contactThe contact information of a package. For example, team email.
create_timeThe time when the package is created.
modification_timeThe time when the package is modified.
propertiesA key/value map that stores your own information.

Permissions

The packages are organized by the tenant and namespace, so you can apply the tenant and namespace permissions to packages directly.

Package resources

You can use the package management with command line tools, REST API and Java client.

Upload a package

You can upload a package to the package management service in the following ways.

bin/pulsar-admin packages upload functions://public/default/example@v0.1 --path package-file --description package-description

{@inject: endpoint| POST |admin/v3/packages/:type/:tenant/:namespace/:packageName/:version/?version=[[pulsar:version_number]]}

Upload a package to the package management service synchronously.

   void upload(PackageMetadata metadata, String packageName, String path) throws PulsarAdminException;

Upload a package to the package management service asynchronously.

   CompletableFuture<Void> uploadAsync(PackageMetadata metadata, String packageName, String path);

Download a package

You can download a package to the package management service in the following ways.

bin/pulsar-admin packages download functions://public/default/example@v0.1 --path package-file

{@inject: endpoint| GET |admin/v3/packages/:type/:tenant/:namespace/:packageName/:version/?version=[[pulsar:version_number]]}

Download a package to the package management service synchronously.

   void download(String packageName, String path) throws PulsarAdminException;

Download a package to the package management service asynchronously.

   CompletableFuture<Void> downloadAsync(String packageName, String path);

List all versions of a package

You can get a list of all versions of a package in the following ways.

bin/pulsar-admin packages list --type function public/default

{@inject: endpoint| GET |admin/v3/packages/:type/:tenant/:namespace/:packageName/?version=[[pulsar:version_number]]}

List all versions of a package synchronously.

   List<String> listPackageVersions(String packageName) throws PulsarAdminException;

List all versions of a package asynchronously.

   CompletableFuture<List<String>> listPackageVersionsAsync(String packageName);

List all the specified type packages under a namespace

You can get a list of all the packages with the given type in a namespace in the following ways.

bin/pulsar-admin packages list --type function public/default

{@inject: endpoint|PUT|/admin/v3/packages/:type/:tenant/:namespace/?version=[[pulsar:version_number]]}

List all the packages with the given type in a namespace synchronously.

   List<String> listPackages(String type, String namespace) throws PulsarAdminException;

List all the packages with the given type in a namespace asynchronously.

   CompletableFuture<List<String>> listPackagesAsync(String type, String namespace);

Get the metadata of a package

You can get the metadata of a package in the following ways.

bin/pulsar-admin packages get-metadata function://public/default/test@v1

{@inject: endpoint| GET |admin/v3/packages/:type/:tenant/:namespace/:packageName/:version/metadata/?version=[[pulsar:version_number]]}

Get the metadata of a package synchronously.

   PackageMetadata getMetadata(String packageName) throws PulsarAdminException;

Get the metadata of a package asynchronously.

   CompletableFuture<PackageMetadata> getMetadataAsync(String packageName);

Update the metadata of a package

You can update the metadata of a package in the following ways.

bin/pulsar-admin packages update-metadata function://public/default/example@v0.1 --description update-description

{@inject: endpoint| PUT |admin/v3/packages/:type/:tenant/:namespace/:packageName/:version/metadata/?version=[[pulsar:version_number]]}

Update a package metadata information synchronously.

   void updateMetadata(String packageName, PackageMetadata metadata) throws PulsarAdminException;

Update a package metadata information asynchronously.

   CompletableFuture<Void> updateMetadataAsync(String packageName, PackageMetadata metadata);

Delete a specified package

You can delete a specified package with its package name in the following ways.

The following command example deletes a package of version 0.1.

bin/pulsar-admin packages delete functions://public/default/example@v0.1

{@inject: endpoint| DELETE |admin/v3/packages/:type/:tenant/:namespace/:packageName/:version/?version=[[pulsar:version_number]]}

Delete a specified package synchronously.

   void delete(String packageName) throws PulsarAdminException;

Delete a specified package asynchronously.

   CompletableFuture<Void> deleteAsync(String packageName);