adalib.harbor
¶
The Harbor sub-package exposes the core integrations of the Harbor container image registry connected to AdaLab.
Functions¶
archive_image ¶
Archive an image in the Harbor registry. This will archive the OCI image metadata object and works as a soft delete.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metadata_id |
int
|
the metadata ID of the image |
required |
Returns:
Type | Description |
---|---|
None
|
nothing |
Source code in adalib/harbor/harbor.py
create_image_metadata ¶
create_image_metadata(source_type, source_repository, source_tag, project_name, repository_name, tag, type_id, name, description, username, cmd='', picture_id=1)
Create metadata for a specific image in the Harbor registry.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source_type |
str
|
the location where the source image is to be pulled from |
required |
source_repository |
str
|
the name of the repository of the source image |
required |
source_tag |
str
|
the tag of the source image |
required |
project_name |
str
|
the name of the target project for the image metadata |
required |
repository_name |
str
|
the name of the target repository for the image metadata |
required |
tag |
str
|
the tag for the target image metadata |
required |
type_id |
str
|
the type of the image |
required |
name |
str
|
the name for the target image metadata |
required |
description |
str
|
the description for the target image metadata |
required |
username |
str
|
the current username (tip: check "LOGNAME" environment variable) |
required |
cmd |
str
|
the startup command for the target image metadata, defaults to "" |
''
|
picture_id |
int, optional
|
the ID of the picture for the image, defaults to 1 |
1
|
Returns:
Type | Description |
---|---|
dict
|
image metadata |
Source code in adalib/harbor/harbor.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
|
edit_image_metadata ¶
edit_image_metadata(metadata_id, new_name='', new_description='', new_cmd='', new_run_id=0, new_picture_id=1)
Edit the metadata of an image in the Harbor registry.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metadata_id |
int
|
the metadata ID of the image |
required |
new_name |
str
|
the new name of the image, defaults to "" |
''
|
new_description |
str
|
the new description of the image, defaults to "" |
''
|
new_cmd |
str
|
the new startup command of the image, defaults to "" |
''
|
new_run_id |
int
|
the new run ID of the image, defaults to 0 |
0
|
new_picture_id |
int
|
the ID of the new picture of the image, defaults to 1 |
1
|
Returns:
Type | Description |
---|---|
None
|
nothing |
Source code in adalib/harbor/harbor.py
get_all_metadata ¶
Get metadata for all images in the Harbor registry.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
include_archived |
bool
|
whether to include archived images, defaults to False |
False
|
Returns:
Type | Description |
---|---|
list
|
metadata for all images |
Source code in adalib/harbor/harbor.py
get_image_digest ¶
Get the digest of an image in the Harbor registry.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metadata_id |
str
|
the metadata ID of the image |
required |
Returns:
Type | Description |
---|---|
str
|
image digest for the remote image |
Source code in adalib/harbor/harbor.py
get_image_id ¶
Get the ID of an image in the Harbor registry.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name |
str
|
the name of the project the image belongs to |
required |
repository_name |
str
|
the name of the image repository |
required |
tag |
str
|
the tag of the specific image |
required |
Returns:
Type | Description |
---|---|
int
|
image ID |
Source code in adalib/harbor/harbor.py
get_image_metadata ¶
Get metadata for a specific image in the Harbor registry based on its ID.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metadata_id |
int
|
the metadata ID of the image |
required |
Returns:
Type | Description |
---|---|
dict
|
image metadata |
Source code in adalib/harbor/harbor.py
get_image_metadata_id ¶
Get the metadata ID for a specific image in the Harbor registry.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name |
str
|
the name of the project the image belongs to |
required |
repository_name |
str
|
the name of the image repository |
required |
tag |
str
|
the tag of the specific image |
required |
Returns:
Type | Description |
---|---|
int
|
image metadata ID |
Source code in adalib/harbor/harbor.py
get_project_repositories ¶
Get all image repositories under a given project name.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name |
str
|
the name of the project to list images from |
required |
Returns:
Type | Description |
---|---|
list
|
list of existing images under a given project name |
Source code in adalib/harbor/harbor.py
get_project_stats ¶
Get statistics for a specific project in the Harbor registry.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name |
str
|
the name of the project to get stats from |
required |
Returns:
Type | Description |
---|---|
list
|
usage statistics for a given project |
Source code in adalib/harbor/harbor.py
get_projects ¶
Get a list of the projects in the Harbor registry.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
include_archived |
bool
|
whether to include archived projects |
False
|
Returns:
Type | Description |
---|---|
list
|
list of existing projects |
Source code in adalib/harbor/harbor.py
get_publish_logs ¶
Get the publish or system logs of an image publishing process.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metadata_id |
int
|
the metadata ID of the image |
required |
source |
str
|
the source of the logs, either "build" or "publish", defaults to "publish" |
'publish'
|
Returns:
Type | Description |
---|---|
list
|
build logs |
Source code in adalib/harbor/harbor.py
get_repositories_by_author ¶
Get a list of the repositories in the Harbor registry by author ID.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
author_id |
str
|
the ID of the author to list repositories from |
required |
include_archived |
bool
|
whether to include archived images, defaults to False |
False
|
Returns:
Type | Description |
---|---|
list
|
list of existing repositories from a given author |
Source code in adalib/harbor/harbor.py
get_repositories_by_type ¶
Get a list of the repositories in the Harbor registry by image type.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
type |
str
|
type of image |
required |
include_archived |
bool
|
whether to include archived images, defaults to False |
False
|
Returns:
Type | Description |
---|---|
list
|
list of existing repositories of a given type |
Source code in adalib/harbor/harbor.py
get_repository_tags ¶
Get all tags of an image in the Harbor registry.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name |
str
|
the name of the project the image belongs to |
required |
repository_name |
str
|
the name of the image repository |
required |
Returns:
Type | Description |
---|---|
list
|
list of existing image tags |
Source code in adalib/harbor/harbor.py
get_types ¶
Get a list of the image types in the Harbor registry.
Use the example Jupyter Notebook to test this function or build upon it.
Returns:
Type | Description |
---|---|
list
|
list of existing types |
Source code in adalib/harbor/harbor.py
request_harbor ¶
Function to request the registry API at the specified URL.
Raises on errors from the HTTP calls.
Note: All kwargs passed are directly sent through to the request function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
path to query the registry on (base url will be injected automatically) |
required |
method |
function, optional
|
method to use to query harbor, defaults to requests.get |
get
|
Returns:
Type | Description |
---|---|
response
|
response from harbor |
Source code in adalib/harbor/harbor.py
restore_image ¶
Restore a previously-archived image in the Harbor registry.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metadata_id |
int
|
the metadata ID of the image |
required |
Returns:
Type | Description |
---|---|
None
|
nothing |
Source code in adalib/harbor/harbor.py
update_image_state ¶
Update the "ready" state of an image based on its status in the Harbor registry.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metadata_id |
str
|
the metadata ID of the image |
required |
Returns:
Type | Description |
---|---|
str
|
the updated "ready" state of the image |