The Ubuntu Pro API reference guide#
The Ubuntu Pro Client has a Python-based API to be consumed by users who want to integrate the Client’s functionality with their software.
The functions and objects are available through the uaclient.api module,
and all of the available endpoints return an object with specific data for the
calls.
Besides importing the Python code directly, consumers who are not writing
Python may use the command line interface (CLI) to call the same functionality,
using the pro api command. This command will always return a JSON with a
standard structure, as can be seen below:
{
"_schema_version": "v1",
"data": {
"attributes": {
// <endpoint specific attributes>
},
"meta": {
"environment_vars": []
},
"type": "<response_type>"
},
"errors": [],
"result": "<success|failure>",
"version": "<client version>",
"warnings": []
}
Version dependencies#
The Ubuntu Pro Client is shipped as the ubuntu-pro-client package.
The documentation for each endpoint below states the first version to include that endpoint.
If you depend on these endpoints, we recommend using a standard dependency version requirement to ensure that a sufficiently up-to-date version of the Pro Client is installed before trying to use it.
Important
The ~ at the end of the version is important to ensure that dpkg
version comparison works as expected.
For example, if your software is packaged as a deb, then you can add the
following to your Depends list in your control file to ensure the
installed version is at least 27.11~:
ubuntu-pro-client (>= 27.11~)
Runtime version detection#
If you need to detect the current version at runtime, the most reliable way is
to query dpkg.
dpkg-query --showformat='${Version}' --show ubuntu-pro-client
If you need to compare versions at runtime, make sure you use the dpkg
version comparison algorithm. For example, the following will exit 0 if the
currently installed version of Pro Client is at least 27.11~:
dpkg --compare-versions "$(dpkg-query --showformat='${Version}' --show ubuntu-pro-client)" ge "27.11~"
Runtime feature detection#
As an alternative to version detection, you can use feature detection. This is
easier to do when importing the API in python than it is when using the
pro api subcommand.
In python, try to import the desired endpoint. If an ImportError is raised,
then the currently installed version of Ubuntu Pro Client doesn’t support that
endpoint.
For example:
try:
from uaclient.api.u.pro.version.v1 import version
pro_client_api_supported = True
except ImportError:
pro_client_api_supported = False
You could do something similar by catching certain errors when using the
pro api subcommand, but there are more cases that could indicate an old
version, and it generally isn’t recommended.
Errors and warnings fields#
When using the API through the CLI, we use two distinct fields to list issues to the users; errors and warnings.
Both of these fields contain a list of JSON objects explaining unexpected
behavior during the execution of a command. For example, the errors field
will be populated like this if we have a connectivity issue when running a
pro api command:
[
{
"title": "Failed to connect to authentication server",
"code": "connectivity-error",
"meta": {}
}
]
Warnings follow the exact same structure as errors. The only difference is that warnings means that the command was able to complete although unexpected scenarios happened when executing the command.
CLI arguments#
There are two ways to provide data to APIs that require arguments.
--args: Use this to individually provide arguments to the CLI endpoint.For example:
pro api u.pro.attach.magic.revoke.v1 --args magic_token=TOKEN--data: Use this to provide a JSON object containing all the data:For example:
pro api u.pro.security.fix.cve.plan.v1 --data '{"cves": ["CVE-1234-1235"]}'
Available endpoints#
The currently available endpoints are:
u.pro.version.v1#
This endpoint shows the installed Pro Client version.
Introduced in Ubuntu Pro Client Version:
27.11~Requires network access: No
Arguments:
This endpoint takes no arguments.
Calling from Python code:
from uaclient.api.u.pro.version.v1 import version
result = version()
Expected return object:
uaclient.api.u.pro.version.v1.VersionResultField Name
Type
Description
installed_versionstrThe current installed version
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).VersionError: Raised if the Client cannot determine the version.
Calling from the CLI:
pro api u.pro.version.v1
Expected attributes in JSON structure:
{
"installed_version": "32.3~24.04"
}
u.pro.attach.auto.configure_retry_service.v1#
This endpoint configures options for the retry auto-attach functionality,
and creates files that will activate the retry auto-attach functionality
if ubuntu-advantage.service runs.
Note that this does not start ubuntu-advantage.service. This makes it
useful for calling during the boot process
Before: ubuntu-advantage.service so that when
ubuntu-advantage.service starts, its ConditionPathExists check
passes and activates the retry auto-attach function.
If you call this function outside of the boot process and would like the
retry auto-attach functionality to actually start, you’ll need to call
something like systemctl start ubuntu-advantage.service.
Introduced in Ubuntu Pro Client Version:
27.12~Requires network access: No
Arguments:
Field Name |
Type |
Description |
|---|---|---|
|
|
Optional list of services to enable after auto-attaching. |
|
|
Optional list of beta services to enable after auto-attaching. |
|
|
Ignore the result of |
Note
If none of the lists are set, the services will be enabled based on the contract definitions.
Calling from Python code:
from uaclient.api.u.pro.attach.auto.configure_retry_service.v1 import configure_retry_service, ConfigureRetryServiceOptions
options = ConfigureRetryServiceOptions(enable=["<service1>", "<service2>"], enable_beta=["<beta_service3>"])
result = configure_retry_service(options)
Expected return object:
uaclient.api.u.pro.attach.auto.configure_retry_service.v1.ConfigureRetryServiceResultThis object has no fields.
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).
Calling from the CLI:
pro api u.pro.attach.auto.configure_retry_service.v1 --data {"enable": ["esm-infra", "esm-apps"]}
Expected attributes in JSON structure:
{}
u.pro.attach.auto.full_auto_attach.v1#
This endpoint runs the whole auto-attach process on the system.
Introduced in Ubuntu Pro Client Version:
27.11~Requires network access: Yes
Arguments:
Field Name |
Type |
Description |
|---|---|---|
|
|
Optional list of services to enable after auto-attaching. |
|
|
Optional list of beta services to enable after auto-attaching. |
|
|
Ignore the result of |
Note
If none of the lists are set, the services will be enabled based on the contract definitions.
Calling from Python code:
from uaclient.api.u.pro.attach.auto.full_auto_attach.v1 import full_auto_attach, FullAutoAttachOptions
options = FullAutoAttachOptions(enable=["<service1>", "<service2>"], enable_beta=["<beta_service3>"])
result = full_auto_attach(options)
Expected return object:
uaclient.api.u.pro.attach.auto.full_auto_attach.v1.FullAutoAttachResultThis object has no fields.
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).AlreadyAttachedError: Raised if running on a machine which is already attached to a Pro subscription.AutoAttachDisabledError: Raised ifdisable_auto_attach: trueinuaclient.conf.ConnectivityError: Raised if it is not possible to connect to the contracts service.ContractAPIError: Raised if there is an unexpected error in the contracts service interaction.EntitlementsNotEnabledError: Raised if the Client fails to enable any of the entitlements (whether present in any of the lists or listed in the contract).LockHeldError: Raised if another Client process is holding the lock on the machine.NonAutoAttachImageError: Raised if the cloud where the system is running does not support auto-attach.
Calling from the CLI:
pro api u.pro.attach.auto.full_auto_attach.v1 --data {"enable": ["esm-infra", "esm-apps"]}
Expected attributes in JSON structure:
{}
u.pro.attach.auto.should_auto_attach.v1#
This endpoint checks if a given system should run auto-attach on boot.
Introduced in Ubuntu Pro Client Version:
27.11~Requires network access: No
Arguments:
This endpoint takes no arguments.
Calling from Python code:
from uaclient.api.u.pro.attach.auto.should_auto_attach.v1 import should_auto_attach
result = should_auto_attach()
Expected return object:
uaclient.api.u.pro.attach.auto.should_auto_attach.v1.ShouldAutoAttachResultField Name
Type
Description
should_auto_attachboolTrue if the system should run auto-attach on boot
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).
Calling from the CLI:
pro api u.pro.attach.auto.should_auto_attach.v1
Expected attributes in JSON structure:
{
"should_auto_attach": false
}
u.pro.attach.guest.get_guest_token.v1#
This endpoint fetches a guest token from the backend.
Introduced in Ubuntu Pro Client Version:
35~Requires network access: Yes
Arguments:
This endpoint takes no arguments.
Calling from Python code:
from uaclient.api.u.pro.attach.guest_token.get_guest_token.v1 import get_guest_token
get_guest_token()
Expected return object:
uaclient.api.u.pro.attach.guest.get_guest_token.v1.GetGuestTokenResultField Name
Type
Description
guest_tokenstrThe guest token
idstrThe ID of the guest token
expiresdatetimeThe expiration time of the guest token
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).ConnectivityError: Raised if it is not possible to connect to the contracts service.ContractAPIError: Raised if there is an unexpected error in the contracts service interaction.NonRootUserError: Raised if a non-root user executes this endpoint.UnattachedError: Raised if the machine is not attachedFeatureNotSupportedOldTokenError: Raised if the machine needs to be re-attached first.
Calling from the CLI:
pro api u.pro.attach.guest_token.get_guest_token.v1
Expected attributes in JSON structure:
{
"guest_token": "...",
"id": "...",
"expires": "..."
}
u.pro.attach.magic.initiate.v1#
This endpoint initiates the Magic Attach flow, retrieving the User Code to confirm the operation and the Token used to proceed.
Introduced in Ubuntu Pro Client Version:
27.11~Requires network access: Yes
Arguments:
This endpoint takes no arguments.
Calling from Python code:
from uaclient.api.u.pro.attach.magic.initiate.v1 import initiate
result = initiate()
Expected return object:
uaclient.api.u.pro.attach.magic.initiate.v1.MagicAttachInitiateResultField Name
Type
Description
user_codestrCode the user will see in the UI when confirming the Magic Attach
tokenstrMagic Token that can be used in either u.pro.attach.magic.revoke.v1 or u.pro.attach.magic.wait.v1
expiresstrTimestamp of the Magic Attach process expiration
expires_inintSeconds before the Magic Attach process expires
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).ConnectivityError: Raised if it is not possible to connect to the contracts service.ContractAPIError: Raised if there is an unexpected error in the contracts service interaction.MagicAttachUnavailable: Raised if the Magic Attach service is busy or unavailable at the moment.
Calling from the CLI:
pro api u.pro.attach.magic.initiate.v1
Expected attributes in JSON structure:
{
"user_code":"<UI_code>",
"token":"<magic_token>",
"expires": "<yyyy-MM-dd>T<HH:mm:ss>.<TZ>",
"expires_in": 600
}
u.pro.attach.magic.revoke.v1#
This endpoint revokes a Magic Attach Token.
Introduced in Ubuntu Pro Client Version:
27.11~Requires network access: Yes
Arguments:
Field Name |
Type |
Description |
|---|---|---|
|
|
The Token provided by the initiate endpoint. |
Calling from Python code:
from uaclient.api.u.pro.attach.magic.revoke.v1 import MagicAttachRevokeOptions, revoke
options = MagicAttachWaitOptions(magic_token="<magic_token>")
result = revoke(options)
Expected return object:
uaclient.api.u.pro.attach.magic.revoke.v1.MagicAttachRevokeResultThis object has no fields.
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).ConnectivityError: Raised if it is not possible to connect to the contracts service.ContractAPIError: Raised if there is an unexpected error in the contracts service interaction.MagicAttachTokenAlreadyActivated: Raised when trying to revoke a Token which was already activated through the UI.MagicAttachTokenError: Raised when an invalid/expired Token is sent.MagicAttachUnavailable: Raised if the Magic Attach service is busy or unavailable at the moment.
Calling from the CLI:
pro api u.pro.attach.magic.revoke.v1 --args magic_token=<token>
Expected attributes in JSON structure:
{}
u.pro.attach.magic.wait.v1#
This endpoint polls the contracts service waiting for the user to confirm the Magic Attach.
Introduced in Ubuntu Pro Client Version:
27.11~Requires network access: Yes
Arguments:
Field Name |
Type |
Description |
|---|---|---|
|
|
The Token provided by the initiate endpoint. |
Calling from Python code:
from uaclient.api.u.pro.attach.magic.wait.v1 import MagicAttachWaitOptions, wait
options = MagicAttachWaitOptions(magic_token="<magic_token>")
result = wait(options)
Expected return object:
uaclient.api.u.pro.attach.magic.wait.v1.MagicAttachWaitResultField Name
Type
Description
user_codestrCode the user will see in the UI when confirming the Magic Attach
tokenstrThe same Magic Token that was sent as an argument
expiresstrTimestamp of the Magic Attach process expiration
expires_inintSeconds before the Magic Attach process expires
contract_idstrID of the contract the machine will be attached to
contract_tokenstrThe contract Token to attach the machine
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).ConnectivityError: Raised if it is not possible to connect to the contracts service.ContractAPIError: Raised if there is an unexpected error in the contracts service interaction.MagicAttachTokenError: Raised when an invalid/expired Token is sent.MagicAttachUnavailable: Raised if the Magic Attach service is busy or unavailable at the moment.
Calling from the CLI:
pro api u.pro.attach.magic.wait.v1 --args magic_token=<magic_token>
Expected attributes in JSON structure:
{
"user_code":"<UI_code>",
"token":"<magic_token>",
"expires": "<yyyy-MM-dd>T<HH:mm:ss>.<TZ>",
"expires_in": 500,
"contract_id": "<Contract-ID>",
"contract_token": "<attach_token>",
}
u.pro.attach.token.full_token_attach.v1#
This endpoint allows the user to attach to a Pro subscription using a token.
Introduced in Ubuntu Pro Client Version:
32~Requires network access: Yes
Arguments:
Field Name |
Type |
Description |
|---|---|---|
|
|
The token associated with a Pro subscription |
|
|
If false, the attach operation will not enable any service during the operation (default: true) |
Calling from Python code:
from uaclient.api.u.pro.attach.token.full_token_attach.v1 import full_token_attach, FullTokenAttachOptions
options = FullTokenAttachOptions(token="TOKEN")
result = full_token_attach(options)
Expected return object:
uaclient.api.u.pro.attach.token.full_token_attach.v1.FullTokenAttachResultField Name
Type
Description
enabledList[str]The services enabled during the attach operation
reboot_requiredboolTrue if the system requires a reboot after the attach operation
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).ConnectivityError: Raised if it is not possible to connect to the contracts service.ContractAPIError: Raised if there is an unexpected error in the contracts service interaction.LockHeldError: Raised if another Client process is holding the lock on the machine.NonRootUserError: Raised if a non-root user executes this endpoint.
Calling from the CLI:
pro api u.pro.attach.token.full_token_attach.v1 --data -
Note that it is generally not recommended to pass secrets such as the token on
the command line. The example uses the arguments --data - which causes
pro to read the input data from stdin. Then the arguments can be
written as JSON to stdin of the process.
For example, if we define a JSON file (i.e. file.json) with the same
attributes as the options for this endpoint:
{
"token": "TOKEN",
"auto_enable_services": false
}
Then we can call the API like this:
cat file.json | pro api u.pro.attach.token.full_token_attach.v1 --data -
Expected attributes in JSON structure:
{
"enabled": ["service1", "service2"],
"reboot_required": false
}
u.pro.detach.v1#
This endpoint allows the user to detach the machine from a Pro subscription.
Introduced in Ubuntu Pro Client Version:
32~Requires network access: Yes
Arguments:
This endpoint takes no arguments.
Calling from Python code:
from uaclient.api.u.pro.detach.v1 import detach
result = detach()
Expected return object:
uaclient.api.u.pro.detach.v1.DetachResultField Name
Type
Description
disabledList[str]The services disabled during the detach operation
reboot_requiredboolTrue if the system requires a reboot after the detach operation
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).NonRootUserError: Raised if a non-root user executes this endpoint.
Calling from the CLI:
pro api u.pro.detach.v1
Expected attributes in JSON structure:
{
"disabled": ["service1", "service2"],
"reboot_required": false
}
u.pro.packages.summary.v1#
This endpoint shows a summary of installed packages in the system, categorized by origin.
Introduced in Ubuntu Pro Client Version:
27.12~Requires network access: No
Arguments:
This endpoint takes no arguments.
Calling from Python code:
from uaclient.api.u.pro.packages.summary.v1 import summary
result = summary()
Expected return object:
uaclient.api.u.pro.packages.summary.v1.PackageSummaryResultField Name
Type
Description
summaryPackageSummarySummary of all installed packages
uaclient.api.u.pro.packages.summary.v1.PackageSummaryField Name
Type
Description
num_installed_packagesintTotal count of installed packages
num_esm_apps_packagesintCount of packages installed from
esm-appsnum_esm_infra_packagesintCount of packages installed from
esm-infranum_main_packagesintCount of packages installed from
mainnum_multiverse_packagesintCount of packages installed from
multiversenum_restricted_packagesintCount of packages installed from
restrictednum_third_party_packagesintCount of packages installed from third party sources
num_universe_packagesintCount of packages installed from
universenum_unknown_packagesintCount of packages installed from unknown sources
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).
Calling from the CLI:
pro api u.pro.packages.summary.v1
Expected attributes in JSON structure:
{
"summary":{
"num_installed_packages": 1,
"num_esm_apps_packages": 2,
"num_esm_infra_packages": 3,
"num_main_packages": 4,
"num_multiverse_packages": 5,
"num_restricted_packages": 6,
"num_third_party_packages": 7,
"num_universe_packages": 8,
"num_unknown_packages": 9,
},
}
u.pro.packages.updates.v1#
This endpoint shows available updates for packages in a system, categorized by where they can be obtained.
Introduced in Ubuntu Pro Client Version:
27.12~Requires network access: No
Arguments:
This endpoint takes no arguments.
Calling from Python code:
from uaclient.api.u.pro.packages.updates.v1 import updates
result = updates()
Expected return object:
uaclient.api.u.pro.packages.updates.v1.PackageUpdatesResultField Name
Type
Description
summaryUpdateSummarySummary of all available updates
updatesList[UpdateInfo]Detailed list of all available updates
uaclient.api.u.pro.packages.updates.v1.UpdateSummaryField Name
Type
Description
num_updatesintTotal count of available updates
num_esm_apps_updatesintCount of available updates from
esm-appsnum_esm_infra_updatesintCount of available updates from
esm-infranum_standard_security_updatesintCount of available updates from the
-securitypocketnum_standard_updatesintCount of available updates from the
-updatespocketuaclient.api.u.pro.packages.updates.v1.UpdateInfoField Name
Type
Description
download_sizeintDownload size for the update in bytes
originstrWhere the update is downloaded from
packagestrName of the package to be updated
provided_bystrService which provides the update
statusstrWhether this update is ready for download or not
versionstrVersion of the update
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).
Calling from the CLI:
pro api u.pro.packages.updates.v1
Expected attributes in JSON structure:
{
"summary": {
"num_updates": 1,
"num_esm_apps_updates": 2,
"num_esm_infra_updates": 3,
"num_standard_security_updates": 4,
"num_standard_updates": 5,
},
"updates": [
{
"download_size": 6,
"origin": "<some site>",
"package": "<package name>",
"provided_by": "<service name>",
"status": "<update status>",
"version": "<updated version>",
},
]
}
u.pro.security.cves.v1#
This endpoint shows the CVE vulnerabilities in the system. By default, this API will show all CVEs that affect the system.
Introduced in Ubuntu Pro Client Version:
35~Requires network access: Yes
Arguments:
Field Name |
Type |
Description |
|---|---|---|
|
|
Show only unfixable CVES. |
|
|
Show only fixable CVES. |
Calling from Python code:
from uaclient.api.u.pro.security.cves.v1 import cves, CVEsOptions
options = CVEsOptions()
result = cves(options)
Expected return object:
uaclient.api.u.pro.security.cves.v1.CVEsResultField Name
Type
Description
packagesdictA dictionary where the keys are installed package names and the values are AffectedPackage objects.
cvesdictA dictionary where the keys are CVE names and the values are CVEInfo objects.
uaclient.api.u.pro.security.cves.v1.AffectedPackageField Name
Type
Description
current_versionstrThe current version of the package
cvesList[CVEAffectedPackage]The CVE that affects the package
uaclient.api.u.pro.security.cves.v1.CVEAffectedPackageField Name
Type
Description
nameOptional[str]The CVE name
fix_versionOptional[str]The version that fixes the CVE for the package
fix_statusOptional[str]The status of the CVE fix for the package
fix_originstrThe pocket where the fix is available from
uaclient.api.u.pro.security.cves.v1.CVEInfoField Name
Type
Description
descriptionstrThe CVE description
published_atdatetimeThe CVE published date
prioritystrThe ubuntu priority for the CVE
notesOptional[List[str]]A list of notes for the CVE
cvss_scoreOptional[float]The CVE cvss score
cvss_severityOptional[str]The CVE cvss severity
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).
Calling from the CLI:
pro api u.pro.security.cves.v1
Expected attributes in JSON structure:
{
"cves": {
"CVE-2023-5678": {
"cvss_score": 8.1,
"cvss_severity": "high",
"description": "description example",
"notes": [
"note example",
],
"priority": "medium",
"published_at": ".*"
}
},
"packages": {
"accountsservice": {
"current_version": "0.6.40-2ubuntu11.6",
"cves": [
{
"fix_origin": "esm-infra",
"fix_status": "fixed",
"fix_version": "0.6.40-2ubuntu11.6+esm1",
"name": "CVE-2023-5678"
}
]
},
"libaccountsservice0": {
"current_version": "0.6.40-2ubuntu11.6",
"cves": [
{
"fix_origin": "esm-infra",
"fix_status": "fixed",
"fix_version": "0.6.40-2ubuntu11.6+esm1",
"name": "CVE-2023-5678"
}
]
}
},
}
u.pro.security.fix.cve.execute.v1#
This endpoint fixes the specified CVEs on the machine.
Introduced in Ubuntu Pro Client Version:
30~Requires network access: Yes
Arguments:
Field Name |
Type |
Description |
|---|---|---|
|
|
A list of CVE (i.e. CVE-2023-2650) titles |
Calling from Python code:
from uaclient.api.u.pro.security.fix.cve.execute.v1 import execute, CVEFixExecuteOptions
options = CVEFixExecuteOptions(cves=["CVE-1234-1234", "CVE-1234-1235"])
result = execute(options)
Expected return object:
uaclient.api.u.pro.security.fix.cve.execute.v1.CVESAPIFixExecuteResultField Name
Type
Description
cves_dataCVEAPIFixExecuteResultA list of
CVEAPIFixExecuteResultobjectsuaclient.api.u.pro.security.fix.cve.execute.v1.CVEAPIFixExecuteResultField Name
Type
Description
statusstrThe status of fixing the CVEs
cvesList[FixExecuteResult]A list of
FixExecuteResultobjectsuaclient.api.u.pro.security.fix._common.execute.v1.FixExecuteResultField Name
Type
Description
titlestrThe title of the CVE
descriptionOptional[str]The description of the CVE
statusstrThe status of fixing the CVE
upgraded_packagesOptional[List[UpgradedPackage]]A list of
UpgradedPackageobjectserrorsOptional[List[FixExecuteError]]A list of
FixExecuteErrorobjectsuaclient.api.u.pro.security.fix._common.execute.v1.UpgradedPackageField Name
Type
Description
namestrThe name of the package
versionstrThe version that the package was upgraded to
pocketstrThe pocket which contained the package upgrade
uaclient.api.u.pro.security.fix._common.execute.v1.FixExecuteErrorField Name
Type
Description
error_typestrThe type of the error
reasonstrThe reason why the error occurred
failed_upgradesOptional[List[FailedUpgrade]]A list of
FailedUpgradeobjectsuaclient.api.u.pro.security.fix._common.execute.v1.FailedUpgradeField Name
Type
Description
namestrThe name of the package
pocketOptional[str]The pocket which contained the package upgrade
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).
Calling from the CLI:
pro api u.pro.security.fix.cve.execute.v1 --data '{"cves": ["CVE-1234-1234", "CVE-1234-1235"]}'
Expected attributes in JSON structure:
{
"cves_data": {
"status": "fixed",
"cves": [
{
"title": "CVE-1234-56789",
"description": "..."
"status": "fixed",
"upgraded_packages": {
"name": "pkg1",
"version": "1.1",
"pocket": "standard-updates"
},
"errors": []
}
]
}
}
When using the CVE endpoint, the expected output is as follows:
{
"_schema_version": "v1",
"data": {
"attributes": {
"cves_data": {
"cves": [
{
"description": "description",
"errors": null,
"status": "fixed",
"title": "CVE-2021-27135",
"upgraded_packages": [
{
"name": "xterm",
"pocket": "standard-updates",
"version": "VERSION"
}
]
}
],
"status": "fixed"
}
},
"meta": {
"environment_vars": []
},
"type": "CVEFixExecute"
},
"errors": [],
"result": "success",
"version": "30",
"warnings": []
}
From this output, we can see that the cves_data object contains two attributes:
cves: A list of CVE objects detailing what happened during the fix operation.
status: The status of the fix operation considering all CVEs. This means that if one CVE cannot be fixed, this field will reflect that.
If we take a look at a CVE object, we will see the following structure:
title: The title of the CVE.
description: The CVE description.
error: Any error captured when fixing the CVE will appear here. The error object will be detailed in a following section.
status: The expected status of the CVE after the fix operation. There are three possible scenarios: fixed, still-affected and not-affected. The system is considered still-affected if there is something that prevents any required packages from being upgraded. The system is considered not-affected if the CVE doesn’t affect the system at all.
upgraded_packages: A list of UpgradedPackage objects referencing each package that was upgraded during the fix operation. The UpgradedPackage object always contain the name of the package, the version it was upgraded to and the pocket where the package upgrade came from.
What errors can be generated?
There some errors that can happen when executing this endpoint. For example, the system might require the user to attach to a Pro subscription to install the upgrades, or the user might run the command as non-root when a package upgrade is needed.
In those situations, the error JSON error object will follow this representation:
{
"error_type": "error-type",
"reason": "reason",
"failed_upgrades": [
{
"name": "pkg1",
"pocket": "esm-infra"
}
]
}
We can see that the representation has the following fields:
error_type: The error type
reason: The explanation of why the error happened
failed_upgrade: A list of objects that always contain the name of the package that was not upgraded and the pocket where the upgrade would have come from.
u.pro.security.fix.cve.plan.v1#
This endpoint shows the necessary steps required to fix CVEs in the system without executing any of those steps.
Introduced in Ubuntu Pro Client Version:
29~Requires network access: Yes
Arguments:
Field Name |
Type |
Description |
|---|---|---|
|
|
A list of CVE (i.e. CVE-2023-2650) titles |
Calling from Python code:
from uaclient.api.u.pro.security.fix.cve.plan.v1 import plan, CVEFixPlanOptions
options = CVEFixPlanOptions(cves=["CVE-1234-1234", "CVE-1234-1235"])
result = plan(options)
Expected return object:
uaclient.api.u.pro.security.fix.cve.plan.v1.CVESFixPlanResultField Name
Type
Description
cves_dataCVEFixPlanResultA list of
CVEFixPlanResultobjectsuaclient.api.u.pro.security.fix.cve.plan.v1.CVEFixPlanResultField Name
Type
Description
expected_statusstrThe expected status of fixing the CVEs
cvesList[FixPlanResult]A list of
FixPlanResultobjectsuaclient.api.u.pro.security.fix._common.plan.v1.FixPlanResultField Name
Type
Description
titlestrThe title of the issue
descriptionOptional[str]The description of the issue
current_statusOptional[str]The current status of the issue on the system
expected_statusstrThe expected status of fixing the issue
affected_packagesOptional[List[str]]A list of package names affected by the issue
planList[FixPlanStep]A list of
FixPlanStepobjectswarningsOptional[List[FixPlanWarning]]A list of
FixPlanWarningobjectserrorOptional[FixPlanError]A
FixPlanErrorobject, if an error occurred.additional_dataOptional[AdditionalData]Additional data for the issue
uaclient.api.u.pro.security.fix._common.plan.v1.FixPlanStepField Name
Type
Description
operationstrThe operation that would be performed to fix the issue. This can be either an attach, enable, apt-upgrade or a no-op type
orderintThe execution order of the operation
dataDataObjectA data object that can be either an
AptUpgradeData,AttachData,EnableData,NoOpDatauaclient.data_types.DataObjectThis object has no fields.
uaclient.api.u.pro.security.fix._common.plan.v1.FixPlanWarningField Name
Type
Description
warning_typestrThe type of warning
orderintThe execution order of the operation
dataDataObjectA data object that represents either a
PackageCannotBeInstalledDataor aSecurityIssueNotFixedDatauaclient.api.u.pro.security.fix._common.plan.v1.FixPlanErrorField Name
Type
Description
msgstrThe error message
codeOptional[str]The message code
uaclient.api.u.pro.security.fix._common.plan.v1.AdditionalDataThis object has no fields.
uaclient.api.u.pro.security.fix._common.plan.v1.AptUpgradeDataField Name
Type
Description
binary_packagesList[str]A list of binary packages that need to be upgraded
source_packagesList[str]A list of source packages that need to be upgraded
pocketstrThe pocket where the packages will be installed from
uaclient.api.u.pro.security.fix._common.plan.v1.AttachDataField Name
Type
Description
reasonstrThe reason why an attach operation is needed
required_servicestrThe required service that requires the attach operation
source_packagesList[str]The source packages that require the attach operation
uaclient.api.u.pro.security.fix._common.plan.v1.EnableDataField Name
Type
Description
servicestrThe service that needs to be enabled
source_packagesList[str]The source packages that require the service to be enabled
uaclient.api.u.pro.security.fix._common.plan.v1.NoOpDataField Name
Type
Description
statusstrThe status of the issue when no operation can be performed
uaclient.api.u.pro.security.fix._common.plan.v1.NoOpAlreadyFixedDataField Name
Type
Description
statusstrThe status of the issue when no operation can be performed
source_packagesList[str]The source packages that are already fixed
pocketstrThe pocket where the packages would have been installed from
uaclient.api.u.pro.security.fix._common.plan.v1.NoOpLivepatchFixDataField Name
Type
Description
statusstrThe status of the CVE when no operation can be performed
patch_versionstrVersion of the patch from Livepatch that fixed the CVE
uaclient.api.u.pro.security.fix._common.plan.v1.PackageCannotBeInstalledDataField Name
Type
Description
binary_packagestrThe binary package that cannot be installed
binary_package_versionstrThe version of the binary package that cannot be installed
source_packagestrThe source package associated with the binary package
related_source_packagesList[str]A list of source packages that come from the same pocket as the affected package
pocketstrThe pocket where the affected package should be installed from
uaclient.api.u.pro.security.fix._common.plan.v1.SecurityIssueNotFixedDataField Name
Type
Description
source_packagesList[str]A list of source packages that cannot be fixed at the moment
statusstrThe status of the CVE regarding those packages
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).
Calling from the CLI:
pro api u.pro.security.fix.cve.plan.v1 --data '{"cves": ["CVE-1234-56789", "CVE-1234-1235"]}'
Expected attributes in JSON structure:
{
"cves_data": {
"expected_status": "fixed",
"cves": [
{
"title": "CVE-1234-56789",
"expected_status": "fixed",
"plan": [
{
"operation": "apt-upgrade",
"order": 1,
"data": {
"binary_packages": ["pkg1"],
"source_packages": ["pkg1"],
"pocket": "standard-updates",
}
}
],
"warnings": [],
"error": null,
"additional_data": {}
}
]
}
}
u.pro.security.fix.usn.execute.v1#
This endpoint fixes the specified USNs on the machine.
Introduced in Ubuntu Pro Client Version:
30~Requires network access: Yes
Arguments:
Field Name |
Type |
Description |
|---|---|---|
|
|
A list of USNs (i.e. USN-6188-1) titles |
Calling from Python code:
from uaclient.api.u.pro.security.fix.usn.execute.v1 import execute, USNFixExecuteOptions
options = USNFixExecuteOptions(usns=["USN-1234-1", "USN-1235-1"])
result = execute(options)
Expected return object:
uaclient.api.u.pro.security.fix.usn.execute.v1.USNSAPIFixExecuteResultField Name
Type
Description
usns_dataUSNAPIFixExecuteResultA list of
USNAPIFixExecuteResultobjectsuaclient.api.u.pro.security.fix.usn.execute.v1.USNAPIFixExecuteResultField Name
Type
Description
statusstrThe status of fixing the USNs
usnsList[FixExecuteUSNResult]A list of
FixExecuteUSNResultobjectsuaclient.api.u.pro.security.fix.usn.execute.v1.FixExecuteUSNResultField Name
Type
Description
target_usnFixExecuteResultThe
FixExecuteResultfor the target USNrelated_usnsOptional[List[FixExecuteResult]]A list of
FixExecuteResultobjects for the related USNsuaclient.api.u.pro.security.fix._common.execute.v1.FixExecuteResultField Name
Type
Description
titlestrThe title of the CVE
descriptionOptional[str]The description of the CVE
statusstrThe status of fixing the CVE
upgraded_packagesOptional[List[UpgradedPackage]]A list of
UpgradedPackageobjectserrorsOptional[List[FixExecuteError]]A list of
FixExecuteErrorobjectsuaclient.api.u.pro.security.fix._common.execute.v1.UpgradedPackageField Name
Type
Description
namestrThe name of the package
versionstrThe version that the package was upgraded to
pocketstrThe pocket which contained the package upgrade
uaclient.api.u.pro.security.fix._common.execute.v1.FixExecuteErrorField Name
Type
Description
error_typestrThe type of the error
reasonstrThe reason why the error occurred
failed_upgradesOptional[List[FailedUpgrade]]A list of
FailedUpgradeobjectsuaclient.api.u.pro.security.fix._common.execute.v1.FailedUpgradeField Name
Type
Description
namestrThe name of the package
pocketOptional[str]The pocket which contained the package upgrade
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).
Calling from the CLI:
pro api u.pro.security.fix.usn.execute.v1 --data '{"usns": ["USN-1234-1", "USN-1235-1"]}'
Expected attributes in JSON structure:
{
"usns_data": {
"status": "fixed",
"usns": [
{
"target_usn": {
"title": "CVE-1234-56789",
"status": "fixed",
"upgraded_packages": {
"name": "pkg1",
"version": "1.1",
"pocket": "standard-updates"
},
"error": null
},
"related_usns": []
}
]
}
}
When using the USN endpoint, the expected output is as follows:
{
"usns_data": {
"status": "fixed",
"usns": [
{
"target_usn": {
"title": "CVE-1234-56789",
"status": "fixed",
"upgraded_packages": {
"name": "pkg1",
"version": "1.1",
"pocket": "standard-updates"
},
"error": null
},
"related_usns": []
}
]
}
}
From this output, we can see that the usns_data object contains two attributes:
usns: A list of USN objects detailing what happened during the fix operation.
status: The status of the fix operation considering all USNs. This means that if one USN cannot be fixed, this field will reflect that. Note that related USNs don’t interfere with this attribute, meaning that a related USN can fail to be fixed without modifying the status value.
Each usn object contains a reference for both target_usn and related_usns. The target is the USN requested to be fixed by the user, while related USNs are USNs that are related to the main USN and an attempt to fix them will be performed by the endpoint too. To better understand that distinction, please refer to our explanation of CVEs and USNs.
With that said both target_usn object and any object from related_usns follow this structure:
title: The title of the USN.
description: The USN description.
error: Any error captured when fixing the USN will appear here. The error object will be detailed in a following section.
status: The expected status of the USN after the fix operation. There are three possible scenarios: fixed, still-affected and not-affected. The system is considered still-affected if there is something that prevents any required packages from being upgraded. The system is considered not-affected if the USN doesn’t affect the system at all.
upgraded_packages: A list of UpgradedPackage objects referencing each package that was upgraded during the fix operation. The UpgradedPackage object always contain the name of the package, the version it was upgraded to and the pocket where the package upgrade came from.
What errors can be generated?
There some errors that can happen when executing this endpoint. For example, the system might require the user to attach to a Pro subscription to install the upgrades, or the user might run the command as non-root when a package upgrade is needed.
In those situations, the error JSON error object will follow this representation:
{
"error_type": "error-type",
"reason": "reason",
"failed_upgrades": [
{
"name": "pkg1",
"pocket": "esm-infra"
}
]
}
We can see that the representation has the following fields:
error_type: The error type
reason: The explanation of why the error happened
failed_upgrade: A list of objects that always contain the name of the package that was not upgraded and the pocket where the upgrade would have come from.
u.pro.security.fix.usn.plan.v1#
This endpoint shows the necessary steps required to fix USNs in the system without executing any of those steps.
Introduced in Ubuntu Pro Client Version:
29~Requires network access: Yes
Arguments:
Field Name |
Type |
Description |
|---|---|---|
|
|
A list of USNs (i.e. USN-6119-1) titles |
Calling from Python code:
from uaclient.api.u.pro.security.fix.usn.plan.v1 import plan, USNFixPlanOptions
options = USNFixPlanOptions(cves=["USN-1234-1", "USN-1235-1"])
result = plan(options)
Expected return object:
uaclient.api.u.pro.security.fix.usn.plan.v1.USNSFixPlanResultField Name
Type
Description
usns_dataUSNFixPlanResultA list of
USNFixPlanResultobjectsuaclient.api.u.pro.security.fix.usn.plan.v1.USNFixPlanResultField Name
Type
Description
expected_statusstrThe expected status of fixing the USNs
usnsList[FixPlanUSNResult]A list of
FixPlanUSNResultobjectsuaclient.api.u.pro.security.fix._common.plan.v1.FixPlanUSNResultField Name
Type
Description
target_usn_planFixPlanResultA
FixPlanResultobject for the target USNrelated_usns_planOptional[List[FixPlanResult]]A list of
FixPlanResultobjects for the related USNsuaclient.api.u.pro.security.fix._common.plan.v1.FixPlanResultField Name
Type
Description
titlestrThe title of the issue
descriptionOptional[str]The description of the issue
current_statusOptional[str]The current status of the issue on the system
expected_statusstrThe expected status of fixing the issue
affected_packagesOptional[List[str]]A list of package names affected by the issue
planList[FixPlanStep]A list of
FixPlanStepobjectswarningsOptional[List[FixPlanWarning]]A list of
FixPlanWarningobjectserrorOptional[FixPlanError]A
FixPlanErrorobject, if an error occurred.additional_dataOptional[AdditionalData]Additional data for the issue
uaclient.api.u.pro.security.fix._common.plan.v1.FixPlanStepField Name
Type
Description
operationstrThe operation that would be performed to fix the issue. This can be either an attach, enable, apt-upgrade or a no-op type
orderintThe execution order of the operation
dataDataObjectA data object that can be either an
AptUpgradeData,AttachData,EnableData,NoOpDatauaclient.data_types.DataObjectThis object has no fields.
uaclient.api.u.pro.security.fix._common.plan.v1.FixPlanWarningField Name
Type
Description
warning_typestrThe type of warning
orderintThe execution order of the operation
dataDataObjectA data object that represents either a
PackageCannotBeInstalledDataor aSecurityIssueNotFixedDatauaclient.api.u.pro.security.fix._common.plan.v1.FixPlanErrorField Name
Type
Description
msgstrThe error message
codeOptional[str]The message code
uaclient.api.u.pro.security.fix._common.plan.v1.AdditionalDataThis object has no fields.
uaclient.api.u.pro.security.fix._common.plan.v1.USNAdditionalDataField Name
Type
Description
associated_cvesList[str]The associated CVEs for the USN
associated_launchpad_bugsList[str]The associated Launchpad bugs for the USN
uaclient.api.u.pro.security.fix._common.plan.v1.AptUpgradeDataField Name
Type
Description
binary_packagesList[str]A list of binary packages that need to be upgraded
source_packagesList[str]A list of source packages that need to be upgraded
pocketstrThe pocket where the packages will be installed from
uaclient.api.u.pro.security.fix._common.plan.v1.AttachDataField Name
Type
Description
reasonstrThe reason why an attach operation is needed
required_servicestrThe required service that requires the attach operation
source_packagesList[str]The source packages that require the attach operation
uaclient.api.u.pro.security.fix._common.plan.v1.EnableDataField Name
Type
Description
servicestrThe service that needs to be enabled
source_packagesList[str]The source packages that require the service to be enabled
uaclient.api.u.pro.security.fix._common.plan.v1.NoOpDataField Name
Type
Description
statusstrThe status of the issue when no operation can be performed
uaclient.api.u.pro.security.fix._common.plan.v1.NoOpAlreadyFixedDataField Name
Type
Description
statusstrThe status of the issue when no operation can be performed
source_packagesList[str]The source packages that are already fixed
pocketstrThe pocket where the packages would have been installed from
uaclient.api.u.pro.security.fix._common.plan.v1.PackageCannotBeInstalledDataField Name
Type
Description
binary_packagestrThe binary package that cannot be installed
binary_package_versionstrThe version of the binary package that cannot be installed
source_packagestrThe source package associated with the binary package
related_source_packagesList[str]A list of source packages that come from the same pocket as the affected package
pocketstrThe pocket where the affected package should be installed from
uaclient.api.u.pro.security.fix._common.plan.v1.SecurityIssueNotFixedDataField Name
Type
Description
source_packagesList[str]A list of source packages that cannot be fixed at the moment
statusstrThe status of the CVE regarding those packages
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).
Calling from the CLI:
pro api u.pro.security.fix.usn.plan.v1 --data '{"usns": ["USN-1234-1", "USN-1235-1"]}'
Expected attributes in JSON structure:
{
"usns_data": {
"expected_status": "fixed",
"usns": [
{
"related_usns_plan": [],
"target_usn_plan": {
"title": "USN-1234-5",
"expected_status": "fixed",
"plan": [
{
"operation": "apt-upgrade",
"order": 1,
"data": {
"binary_packages": ["pkg1"],
"source_packages": ["pkg1"],
"pocket": "standard-updates"
}
}
],
"warnings": [],
"error": null,
"additional_data": {
"associated_cves": [
"CVE-1234-56789"
],
"associated_launchpad_bus": [
"https://launchpad.net/bugs/BUG_ID"
]
}
},
}
]
}
}
u.pro.security.status.livepatch_cves.v1#
This endpoint lists Livepatch patches for the currently-running kernel.
Introduced in Ubuntu Pro Client Version:
27.12~Requires network access: No
Arguments:
This endpoint takes no arguments.
Calling from Python code:
from uaclient.api.u.pro.security.status.livepatch_cves.v1 import livepatch_cves
result = livepatch_cves()
Expected return object:
uaclient.api.u.pro.security.status.livepatch_cves.v1.LivepatchCVEsResultField Name
Type
Description
fixed_cvesList[LivepatchCVEObject]List of Livepatch patches for the given system
uaclient.api.u.pro.security.status.livepatch_cves.v1.LivepatchCVEObjectField Name
Type
Description
namestrName (ID) of the CVE
patchedboolLivepatch has patched the CVE
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).
Calling from the CLI:
pro api u.pro.security.status.livepatch_cves.v1
Expected attributes in JSON structure:
{
"fixed_cves":[
{
"name": "<CVE Name>",
"patched": true
},
{
"name": "<Other CVE Name>",
"patched": false
},
]
}
u.pro.security.status.reboot_required.v1#
This endpoint informs if the system should be rebooted or not. Possible outputs are:
yes: The system should be rebooted.no: There is no known need to reboot the system.yes-kernel-livepatches-applied: There are Livepatch patches applied to the current kernel, but a reboot is required for an update to take place. This reboot can wait until the next maintenance window.
Introduced in Ubuntu Pro Client Version:
27.12~Requires network access: No
Arguments:
This endpoint takes no arguments.
Calling from Python code:
from uaclient.api.u.pro.security.status.reboot_required.v1 import reboot_required
result = reboot_required()
Expected return object:
uaclient.api.u.pro.security.status.reboot_required.v1.RebootRequiredResultField Name
Type
Description
reboot_requiredstrEither ‘yes’, ‘no’, or ‘yes-kernel-livepatches-applied’
reboot_required_packagesRebootRequiredPkgsThe packages that require a reboot
livepatch_enabled_and_kernel_patchedboolTrue if livepatch is enabled and working
livepatch_enabledboolTrue if livepatch is enabled
livepatch_stateOptional[str]The state of livepatch as reported by the livepatch client
livepatch_supportOptional[str]Whether livepatch covers the current kernel
uaclient.api.u.pro.security.status.reboot_required.v1.RebootRequiredPkgsField Name
Type
Description
standard_packagesOptional[List[str]]Non-kernel packages that require a reboot
kernel_packagesOptional[List[str]]Kernel packages that require a reboot
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).
Calling from the CLI:
pro api u.pro.security.status.reboot_required.v1
Expected attributes in JSON structure:
{
"reboot_required": "yes|no|yes-kernel-livepatches-applied"
}
u.pro.services.dependencies.v1#
This endpoint will return a full list of all service dependencies, regardless of the current system state. That means it will always return the same thing until new services are added, or until we add/remove dependencies between services.
Introduced in Ubuntu Pro Client Version:
32~Requires network access: No
Arguments:
This endpoint takes no arguments.
Calling from Python code:
from uaclient.api.u.pro.services.dependencies.v1 import dependencies
result = dependencies()
Expected return object:
uaclient.api.u.pro.services.dependencies.v1.DependenciesResultField Name
Type
Description
servicesList[ServiceWithDependencies]Each Pro service gets an item in this list
uaclient.api.u.pro.services.dependencies.v1.ServiceWithDependenciesField Name
Type
Description
namestrName of the Pro service this item corresponds to
incompatible_withList[ServiceWithReason]List of Pro services this service is incompatible with. That means they cannot be enabled at the same time.
depends_onList[ServiceWithReason]List of Pro services this service depends on. The services in this list must be enabled for this service to be enabled.
uaclient.api.u.pro.services.dependencies.v1.ServiceWithReasonField Name
Type
Description
namestrName of the Pro service this item corresponds to
reasonReasonReason that this service is in the list it is in
uaclient.api.u.pro.services.dependencies.v1.ReasonField Name
Type
Description
codestrShort string that represents the reason
titlestrLonger string describing the reason - possibly translated
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).
Calling from the CLI:
pro api u.pro.services.dependencies.v1
Expected attributes in JSON structure:
{
"services": [
{
"name": "one",
"depends_on": [
{
"name": "zero",
"reason": {
"code": "one-and-zero",
"title": "Service One requires service Zero."
}
},
...
],
"incompatible_with": [
{
"name": "two",
"reason": {
"code": "one-and-two",
"title": "Services One and Two are not compatible."
}
},
...
]
},
...
]
}
u.pro.services.disable.v1#
Disable a Pro service. This will automatically disable any services that depend on the target service.
Introduced in Ubuntu Pro Client Version:
32~Requires network access: Yes
Arguments:
Field Name |
Type |
Description |
|---|---|---|
|
|
Pro service to disable |
|
|
Also remove all packages that were installed from this service. Only supported by some services. (default: false) |
Calling from Python code:
from uaclient.api.u.pro.services.disable.v1 import disable, DisableOptions
result = disable(DisableOptions(service="usg"))
Expected return object:
uaclient.api.u.pro.services.disable.v1.DisableResultField Name
Type
Description
disabledList[str]List of services disabled
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).NonRootUserError: When called as non-root userUnattachedError: When called on a machine that is not attached to a Pro subscriptionEntitlementNotFoundError: When the service argument is not a valid Pro service nameLockHeldError: When another Ubuntu Pro related operation is in progressEntitlementNotDisabledError: When the service fails to disable
Calling from the CLI:
pro api u.pro.services.disable.v1 --args service=usg
Expected attributes in JSON structure:
{
"disabled": [
"usg"
]
}
u.pro.services.enable.v1#
Enable a Pro service. This will automatically disable incompatible services and enable required services that that target service depends on.
Introduced in Ubuntu Pro Client Version:
32~Requires network access: Yes
Arguments:
Field Name |
Type |
Description |
|---|---|---|
|
|
Pro service to be enabled |
|
|
Optional variant of the Pro service to be enabled. |
|
|
If true and the target service supports it, only enable access to the service (default: false) |
Calling from Python code:
from uaclient.api.u.pro.services.enable.v1 import enable, EnableOptions
result = enable(EnableOptions(service="usg"))
Expected return object:
uaclient.api.u.pro.services.enable.v1.EnableResultField Name
Type
Description
enabledList[str]List of services that were enabled.
disabledList[str]List of services that were disabled.
reboot_requiredboolTrue if one of the services that was enabled requires a reboot.
messagesList[str]List of information message strings about the service that was just enabled. Possibly translated.
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).NonRootUserError: When called as non-root userUnattachedError: When called on a machine that is not attached to a Pro subscriptionNotSupported: When called for a service that doesn’t support being enabled via API (currently only Landscape)EntitlementNotFoundError: When the service argument is not a valid Pro service name or if the variant is not a valid variant of the target serviceLockHeldError: When another Ubuntu Pro related operation is in progressEntitlementNotEnabledError: When the service fails to enable
Calling from the CLI:
pro api u.pro.services.enable.v1 --args service=usg
Expected attributes in JSON structure:
{
"disabled": [],
"enabled": [
"usg"
],
"messages": [],
"reboot_required": false
}
u.pro.status.enabled_services.v1#
This endpoint shows the Pro services that are enabled on the machine.
Introduced in Ubuntu Pro Client Version:
28~Requires network access: No
Arguments:
This endpoint takes no arguments.
Calling from Python code:
from uaclient.api.u.pro.status.enabled_services.v1 import enabled_services
result = enabled_services()
Expected return object:
uaclient.api.u.pro.status.enabled_services.v1.EnabledServicesResultField Name
Type
Description
enabled_servicesList[EnabledService]A list of
EnabledServiceobjectsuaclient.api.u.pro.status.enabled_services.v1.EnabledServiceField Name
Type
Description
namestrName of the service
variant_enabledboolIf a variant of the service is enabled
variant_nameOptional[str]Name of the variant, if a variant is enabled
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).
Calling from the CLI:
pro api u.pro.status.enabled_services.v1
Expected attributes in JSON structure:
{
"enabled_services": [
{
"name": "esm-apps",
"variant_enabled": false,
"variant_name": null
},
{
"name": "esm-infra",
"variant_enabled": false,
"variant_name": null
},
{
"name": "realtime-kernel",
"variant_enabled": true,
"variant_name": "raspi"
}
]
}
u.pro.status.is_attached.v1#
This endpoint shows if the machine is attached to a Pro subscription.
Introduced in Ubuntu Pro Client Version:
28~Requires network access: No
Arguments:
This endpoint takes no arguments.
Calling from Python code:
from uaclient.api.u.pro.status.is_attached.v1 import is_attached
result = is_attached()
Expected return object:
uaclient.api.u.pro.status.is_attached.v1.IsAttachedResultField Name
Type
Description
is_attachedboolTrue if the machine is attached to an Ubuntu Pro subscription
contract_statusOptional[str]Status of the Ubuntu Pro subscription
contract_remaining_daysintNumber of days left in the Ubuntu Pro subscription
is_attached_and_contract_validboolTrue if the machine is attached to an Ubuntu Pro subscription and that subscription is not expired
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).
Calling from the CLI:
pro api u.pro.status.is_attached.v1
Expected attributes in JSON structure:
{
"contract_remaining_days": 360,
"contract_status": "active",
"is_attached": true,
"is_attached_and_contract_valid": true
}
The contract_status field can return 4 different states, they are:
active: The contract is currently valid.
grace-period: The contract is in the grace period. This means that it is expired, but there are still some days where the contract will be valid.
active-soon-to-expire: The contract is almost expired, but still valid.
expired: The contract is expired and no longer valid.
u.apt_news.current_news.v1#
This endpoint returns the current APT News that gets displayed in apt upgrade.
Introduced in Ubuntu Pro Client Version:
29~Requires network access: No
Arguments:
This endpoint takes no arguments.
Calling from Python code:
from uaclient.api.u.apt_news.current_news.v1 import current_news
result = current_news().current_news
Expected return object:
uaclient.api.u.apt_news.current_news.v1.CurrentNewsResultField Name
Type
Description
current_newsOptional[str]The current APT News to be displayed for the system. This could be a str with up to three lines (i.e. up to two
\ncharacters). If there is no APT News to be displayed, this will beNone.
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).
Calling from the CLI:
pro api u.apt_news.current_news.v1
Expected attributes in JSON structure:
{
"current_news":"This is a news message.\nThis is the second line of the message.\nAnd this is the third line."
}
u.security.package_manifest.v1#
This endpoint returns the status of installed packages (apt and
snap), formatted as a manifest file (i.e., package_name\tversion).
Introduced in Ubuntu Pro Client Version:
27.12~Requires network access: No
Arguments:
This endpoint takes no arguments.
Calling from Python code:
from uaclient.api.u.security.package_manifest.v1 import package_manifest
result = package_manifest()
Expected return object:
uaclient.api.u.security.package_manifest.v1.PackageManifestResultField Name
Type
Description
manifest_datastrManifest of
aptandsnappackages installed on the system
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).
Calling from the CLI:
pro api u.security.package_manifest.v1
Expected attributes in JSON structure:
{
"package_manifest":"package1\t1.0\npackage2\t2.3\n"
}
u.unattended_upgrades.status.v1#
This endpoint returns the status around unattended-upgrades. The focus
of the endpoint is to verify if the application is running and how it is
configured on the machine.
Important
For this endpoint, we deliver a unique key under meta called
raw_config. This field contains all related unattended-upgrades
configurations, unparsed. This means that this field will maintain both
original name and values for those configurations.
Introduced in Ubuntu Pro Client Version:
27.14~Requires network access: No
Arguments:
This endpoint takes no arguments.
Calling from Python code:
from uaclient.api.u.unattended_upgrades.status.v1 import status
result = status()
Expected return object:
uaclient.api.u.unattended_upgrades.status.v1.UnattendedUpgradesStatusResultField Name
Type
Description
systemd_apt_timer_enabledboolIndicate if the
apt-daily.timerjobs are enabledapt_periodic_job_enabledboolIndicate if the
APT::Periodic::Enabledconfiguration is turned offpackage_lists_refresh_frequency_daysintThe value of the
APT::Periodic::Update-Package-Listsconfigurationunattended_upgrades_frequency_daysintThe value of the
APT::Periodic::Unattended-Upgradeconfigurationunattended_upgrades_allowed_originsList[str]The value of the
Unattended-Upgrade::Allowed-Originsconfigurationunattended_upgrades_runningboolIndicate if the
unattended-upgradeservice is correctly configured and runningunattended_upgrades_disabled_reasonOptional[UnattendedUpgradesDisabledReason]Object that explains why
unattended-upgradesis not running – if the application is running, the object will be nullunattended_upgrades_last_runOptional[datetime]The last time
unattended-upgradesranuaclient.api.u.unattended_upgrades.status.v1.UnattendedUpgradesDisabledReasonField Name
Type
Description
msgstrHuman readable reason
codestrReason code
Raised exceptions:
UbuntuProError:UbuntuProErroris the base class of all exceptions raised by Ubuntu Pro Client and it is best practice to handle this error on any API call. (Note: if any API call raises an exception that does not inherit fromUbuntuProError, please report a bug).UnattendedUpgradesError: Raised if we cannot run a necessary command to show the status ofunattended-upgrades
Calling from the CLI:
pro api u.unattended_upgrades.status.v1
Expected attributes in JSON structure:
{
"apt_periodic_job_enabled": true,
"package_lists_refresh_frequency_days": 1,
"systemd_apt_timer_enabled": true,
"unattended_upgrades_allowed_origins": [
"${distro_id}:${distro_codename}",
"${distro_id}:${distro_codename}-security",
"${distro_id}ESMApps:${distro_codename}-apps-security",
"${distro_id}ESM:${distro_codename}-infra-security"
],
"unattended_upgrades_disabled_reason": null,
"unattended_upgrades_frequency_days": 1,
"unattended_upgrades_last_run": null,
"unattended_upgrades_running": true
}
Possible attributes in JSON
metafield:{ "meta": { "environment_vars": [], "raw_config": { "APT::Periodic::Enable": "1", "APT::Periodic::Unattended-Upgrade": "1", "APT::Periodic::Update-Package-Lists": "1", "Unattended-Upgrade::Allowed-Origins": [ "${distro_id}:${distro_codename}", "${distro_id}:${distro_codename}-security", "${distro_id}ESMApps:${distro_codename}-apps-security", "${distro_id}ESM:${distro_codename}-infra-security" ] } } }