Projects
get_project(project_name_or_id)
async
Fetch a project given its name or ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name_or_id |
Union[str, int]
|
The name or ID of the project String arguments are treated as project names. Integer arguments are treated as project IDs. |
required |
Returns:
Type | Description |
---|---|
Project
|
The project with the given name or ID. |
create_project(project)
async
Create a new project. Returns location of the created project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project |
ProjectReq
|
The project to create |
required |
Returns:
Type | Description |
---|---|
str
|
The location of the created project. |
update_project(project_name_or_id, project)
async
Update a project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name_or_id |
Union[str, int]
|
The name or ID of the project String arguments are treated as project names. Integer arguments are treated as project IDs. |
required |
project |
ProjectReq
|
The updated project |
required |
delete_project(project_name_or_id, missing_ok=None)
async
Delete a project given its name or ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name_or_id |
Union[str, int]
|
The name or ID of the project String arguments are treated as project names. Integer arguments are treated as project IDs. |
required |
missing_ok |
Optional[bool]
|
If true, ignore 404 error when the project is not found. |
None
|
get_projects(query=None, sort=None, name=None, public=None, owner=None, with_detail=True, page=1, page_size=10, limit=None, **kwargs)
async
Get all projects, optionally filtered by query.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query |
Optional[str]
|
Query string to query resources. Supported query patterns are:
The value of range and list can be:
All of these query patterns should be put in the query string
and separated by |
None
|
sort |
Optional[str]
|
The sort order of the projects. |
None
|
name |
Optional[str]
|
The name of the project. |
None
|
public |
Optional[bool]
|
Only fetch public projects. |
None
|
owner |
Optional[str]
|
The owner of the project. |
None
|
with_detail |
bool
|
Return detailed information about the project. |
True
|
page |
int
|
The page of results to return |
1
|
page_size |
int
|
The number of results to return per page |
10
|
limit |
Optional[int]
|
The maximum number of results to return |
None
|
Returns:
Type | Description |
---|---|
List[Project]
|
The list of projects |
get_project_logs(project_name, query=None, sort=None, page=1, page_size=10, limit=None, **kwargs)
async
Get the audit logs of the specified project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name |
str
|
The name of the project |
required |
query |
Optional[str]
|
Query string to filter the logs. Supported query patterns are:
The value of range and list can be:
All of these query patterns should be put in the query string
and separated by |
None
|
sort |
Optional[str]
|
The sort order of the artifacts. |
None
|
page |
int
|
The page of results to return |
1
|
page_size |
int
|
The number of results to return per page |
10
|
limit |
Optional[int]
|
The maximum number of results to return |
None
|
get_project_summary(project_name_or_id)
async
Get the summary of a project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name_or_id |
Union[str, int]
|
The name or ID of the project String arguments are treated as project names. Integer arguments are treated as project IDs. |
required |
Returns:
Type | Description |
---|---|
ProjectSummary
|
The summary of a project. |
project_exists(project_name)
async
Check if a project exists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name |
str
|
The name of the project |
required |
set_project_scanner(project_name_or_id, scanner_uuid)
async
Set one of the system configured scanner registration as the indepndent scanner of the specified project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name_or_id |
Union[str, int]
|
The name or ID of the project String arguments are treated as project names. Integer arguments are treated as project IDs. Strings arguments set the |
required |
scanner_uuid |
str
|
The UUID of the scanner to set as the independent scanner of the project |
required |
get_project_scanner(project_name_or_id)
async
Get the scanner registration of the specified project. If no scanner registration is configured for the specified project, the system default scanner registration will be returned.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name_or_id |
Union[str, int]
|
The name or ID of the project
Integer arguments are treated as project IDs.
String arguments are treated as project names.
Strings arguments set the |
required |
Returns:
Type | Description |
---|---|
ScannerRegistration
|
The scanner registration of the specified project |
get_project_scanner_candidates(project_name_or_id, query=None, sort=None, page=1, page_size=10, limit=None)
async
Get the scanner candidates for a project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name_or_id |
Union[str, int]
|
The name or ID of the project String arguments are treated as project names. Integer arguments are treated as project IDs. |
required |
query |
Optional[str]
|
Query string to query resources. Supported query patterns are:
The value of range and list can be:
All of these query patterns should be put in the query string
and separated by |
None
|
sort |
Optional[str]
|
The sort order of the scanners. |
None
|
page |
int
|
The page of results to return |
1
|
page_size |
int
|
The number of results to return per page |
10
|
limit |
Optional[int]
|
The maximum number of results to return |
None
|
Returns:
Type | Description |
---|---|
List[ScannerRegistration]
|
The list of scanner candidates |
get_project_deletable(project_name_or_id)
async
Get the deletable status of a project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name_or_id |
Union[str, int]
|
The name or ID of the project String arguments are treated as project names. Integer arguments are treated as project IDs. |
required |
Returns:
Type | Description |
---|---|
ProjectDeletable
|
The deletable status of a project.
If |
get_project_member(project_name_or_id, member_id)
async
Get a project member given its ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name_or_id |
Union[str, int]
|
The name or ID of the project String arguments are treated as project names. Integer arguments are treated as project IDs. |
required |
member_id |
int
|
ID of the project member to fetch. |
required |
Returns:
Type | Description |
---|---|
ProjectMemberEntity
|
The member of the project with the given ID. |
add_project_member(project_name_or_id, member)
async
Warning
Advanced users only. This method is not recommended for general use.
Only use this method if you need full control over the ProjectMember
model that is sent to the API.
It is recommended to use add_project_member_{user, group}
instead.
Description
Add a user or group as a member of a project.
One of member_group
or member_user
fields of the ProjectMember
instance must be set.
A member_user
needs to define user_id
or username
, and adds a user as a member of the project.
A member_group
needs to define id
or ldap_group_dn
, and adds a group as a member of the project.
Note
The description above is the author of this library's interpretation of the API documentation. See below for the original description.
Original Description from API
Create project member relationship, the member can be one of the user_member and group_member, The user_member need to specify user_id or username. If the user already exist in harbor DB, specify the user_id, If does not exist in harbor DB, it will SearchAndOnBoard the user. The group_member need to specify id or ldap_group_dn. If the group already exist in harbor DB. specify the user group's id, If does not exist, it will SearchAndOnBoard the group.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name_or_id |
Union[str, int]
|
The name or ID of the project String arguments are treated as project names. Integer arguments are treated as project IDs. |
required |
member |
ProjectMember
|
The user or group to add as a member of the project. |
required |
Returns:
Type | Description |
---|---|
str
|
The location of the new member. |
add_project_member_user(project_name_or_id, username_or_id, role_id)
async
Add a user as a member of a project.
Prefer user IDs for existing users.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name_or_id |
Union[str, int]
|
The name or ID of the project String arguments are treated as project names. Integer arguments are treated as project IDs. |
required |
username_or_id |
Union[str, int]
|
The name or ID of the user String arguments are treated as user names. Integer arguments are treated as user IDs. |
required |
role_id |
int
|
The role of the user.
Set |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the new project member |
add_project_member_group(project_name_or_id, ldap_group_dn_or_id, role_id)
async
Add a group as a member of a project.
Prefer group IDs for existing groups.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name_or_id |
Union[str, int]
|
The name or ID of the project String arguments are treated as project names. Integer arguments are treated as project IDs. |
required |
ldap_group_dn_or_id |
Union[str, int]
|
The LDAP group DN or ID of the group. String arguments are treated as LDAP group DNs. Integer arguments are treated as group IDs. |
required |
role_id |
int
|
The role the users in the group will have.
Set |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the new project member |
update_project_member_role(project_name_or_id, member_id, role)
async
Update the role of a project member.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name_or_id |
Union[str, int]
|
The name or ID of the project String arguments are treated as project names. Integer arguments are treated as project IDs. |
required |
member_id |
int
|
The ID of the member to update |
required |
role |
Union[RoleRequest, int]
|
The new role of the member.
Set |
required |
Examples:
remove_project_member(project_name_or_id, member_id)
async
Remove a member from a project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name_or_id |
Union[str, int]
|
The name or ID of the project String arguments are treated as project names. Integer arguments are treated as project IDs. |
required |
member_id |
int
|
The ID of the member to remove. This is a member ID, not a user or group ID. |
required |
get_project_members(project_name_or_id, entity_name=None, page=1, page_size=10, limit=None)
async
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name_or_id |
Union[str, int]
|
Name or ID of project to list members for. String arguments are treated as project names. Integer arguments are treated as project IDs. |
required |
entity_name |
Optional[str]
|
Entity name to search for. |
None
|
page |
int
|
The page number to start iterating from, by default 1 |
1
|
page_size |
int
|
Number of results to retrieve per page, by default 10 |
10
|
limit |
Optional[int]
|
The maximum number of webhook jobs to return. |
None
|
Returns:
Type | Description |
---|---|
List[ProjectMemberEntity]
|
A list of project members. |