From 66a2fece5e62dd944f6e3d9b55d6e818a84c876b Mon Sep 17 00:00:00 2001 From: pederhan Date: Tue, 1 Aug 2023 10:17:40 +0200 Subject: [PATCH] Generate models from OpenAPI v3 schema --- harborapi/models/_models.py | 506 +++++++++++++++-------------------- harborapi/models/_scanner.py | 11 +- harborapi/models/models.py | 2 - justfile | 4 +- pyproject.toml | 2 +- 5 files changed, 224 insertions(+), 301 deletions(-) diff --git a/harborapi/models/_models.py b/harborapi/models/_models.py index 975dae8d..dd6f5870 100644 --- a/harborapi/models/_models.py +++ b/harborapi/models/_models.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: -# filename: https://raw.githubusercontent.com/goharbor/harbor/main/api/v2.0/swagger.yaml -# timestamp: 2023-05-30T12:46:34+00:00 +# filename: https://converter.swagger.io/api/convert?url=https://raw.githubusercontent.com/goharbor/harbor/main/api/v2.0/swagger.yaml +# timestamp: 2023-08-01T08:08:23+00:00 from __future__ import annotations @@ -8,15 +8,11 @@ from enum import Enum from typing import Any, Dict, List, Optional -from pydantic import AnyUrl, Extra, Field +from pydantic import AnyUrl, Field from .base import BaseModel -class Model(BaseModel): - __root__: Any - - class Error(BaseModel): code: Optional[str] = Field(None, description="The error code") message: Optional[str] = Field(None, description="The error message") @@ -86,24 +82,11 @@ class Tag(BaseModel): class ExtraAttrs(BaseModel): - pass - - class Config: - extra = Extra.allow + __root__: Optional[Dict[str, Dict[str, Any]]] = None class Annotations(BaseModel): - pass - - class Config: - extra = Extra.allow - - -class AdditionLinks(BaseModel): - pass - - class Config: - extra = Extra.allow + __root__: Optional[Dict[str, str]] = None class AdditionLink(BaseModel): @@ -118,12 +101,12 @@ class Platform(BaseModel): None, description="The architecture that the artifact applys to" ) os: Optional[str] = Field(None, description="The OS that the artifact applys to") - _os_version_: Optional[str] = Field( + field_os_version_: Optional[str] = Field( None, alias="'os.version'", description="The version of the OS that the artifact applys to", ) - _os_features_: Optional[List[str]] = Field( + field_os_features_: Optional[List[str]] = Field( None, alias="'os.features'", description="The features of the OS that the artifact applys to", @@ -160,13 +143,6 @@ class Scanner(BaseModel): ) -class ScanOverview(BaseModel): - pass - - class Config: - extra = Extra.allow - - class VulnerabilitySummary(BaseModel): total: Optional[int] = Field( None, description="The total number of the found vulnerabilities", example=500 @@ -499,10 +475,7 @@ class FilterStyle(BaseModel): class ResourceList(BaseModel): - pass - - class Config: - extra = Extra.allow + __root__: Optional[Dict[str, int]] = None class ReplicationExecution(BaseModel): @@ -735,29 +708,18 @@ class RetentionExecutionTask(BaseModel): class QuotaUpdateReq(BaseModel): - hard: Optional[ResourceList] = Field( - None, description="The new hard limits for the quota" - ) + hard: Optional[ResourceList] = None class QuotaRefObject(BaseModel): - pass - - class Config: - extra = Extra.allow + __root__: Optional[Dict[str, Dict[str, Any]]] = None class Quota(BaseModel): id: Optional[int] = Field(None, description="ID of the quota") - ref: Optional[QuotaRefObject] = Field( - None, description="The reference object of the quota" - ) - hard: Optional[ResourceList] = Field( - None, description="The hard limits of the quota" - ) - used: Optional[ResourceList] = Field( - None, description="The used status of the quota" - ) + ref: Optional[QuotaRefObject] = None + hard: Optional[ResourceList] = None + used: Optional[ResourceList] = None creation_time: Optional[datetime] = Field( None, description="the creation time of the quota" ) @@ -778,7 +740,7 @@ class ScannerRegistration(BaseModel): description="An optional description of this registration.", example="A free-to-use tool that scans container images for package vulnerabilities.\n", ) - url: Optional[str] = Field( + url: Optional[AnyUrl] = Field( None, description="A base URL of the scanner adapter", example="http://harbor-scanner-trivy:8080", @@ -1022,10 +984,7 @@ class WebhookTargetObject(BaseModel): skip_cert_verify: Optional[bool] = Field( None, description="Whether or not to skip cert verify." ) - payload_format: Optional[PayloadFormatType] = Field( - None, - description="The payload format of webhook, by default is Default for http type.", - ) + payload_format: Optional[PayloadFormatType] = None class WebhookPolicy(BaseModel): @@ -1084,13 +1043,6 @@ class WebhookJob(BaseModel): ) -class InternalConfigurationsResponse(BaseModel): - pass - - class Config: - extra = Extra.allow - - class InternalConfigurationValue(BaseModel): value: Optional[Dict[str, Any]] = Field( None, description="The value of current config item" @@ -1279,6 +1231,10 @@ class Configurations(BaseModel): scanner_skip_update_pulltime: Optional[bool] = Field( None, description="Whether or not to skip update pull time for scanner" ) + banner_message: Optional[str] = Field( + None, + description="The banner message for the UI.It is the stringified result of the banner message object", + ) class StringConfigItem(BaseModel): @@ -1620,10 +1576,69 @@ class SchedulerStatus(BaseModel): paused: Optional[bool] = Field(None, description="if the scheduler is paused") +class DangerousCVE(BaseModel): + cve_id: Optional[str] = Field(None, description="the cve id") + severity: Optional[str] = Field(None, description="the severity of the CVE") + cvss_score_v3: Optional[float] = Field(None, description="the cvss score v3") + desc: Optional[str] = Field(None, description="the description of the CVE") + package: Optional[str] = Field(None, description="the package of the CVE") + version: Optional[str] = Field(None, description="the version of the package") + + +class DangerousArtifact(BaseModel): + project_id: Optional[int] = Field( + None, description="the project id of the artifact" + ) + repository_name: Optional[str] = Field( + None, description="the repository name of the artifact" + ) + digest: Optional[str] = Field(None, description="the digest of the artifact") + critical_cnt: Optional[int] = Field( + None, description="the count of critical vulnerabilities" + ) + high_cnt: Optional[int] = Field( + None, description="the count of high vulnerabilities" + ) + medium_cnt: Optional[int] = Field( + None, description="the count of medium vulnerabilities" + ) + + +class VulnerabilityItem(BaseModel): + project_id: Optional[int] = Field( + None, description="the project ID of the artifact" + ) + repository_name: Optional[str] = Field( + None, description="the repository name of the artifact" + ) + digest: Optional[str] = Field(None, description="the digest of the artifact") + tags: Optional[List[str]] = Field(None, description="the tags of the artifact") + cve_id: Optional[str] = Field(None, description="the CVE id of the vulnerability.") + severity: Optional[str] = Field( + None, description="the severity of the vulnerability" + ) + cvss_v3_score: Optional[float] = Field( + None, description="the nvd cvss v3 score of the vulnerability" + ) + package: Optional[str] = Field(None, description="the package of the vulnerability") + version: Optional[str] = Field(None, description="the version of the package") + fixed_version: Optional[str] = Field( + None, description="the fixed version of the package" + ) + desc: Optional[str] = Field( + None, description="The description of the vulnerability" + ) + links: Optional[List[str]] = Field(None, description="Links of the vulnerability") + + class Errors(BaseModel): errors: Optional[List[Error]] = None +class AdditionLinks(BaseModel): + __root__: Optional[Dict[str, AdditionLink]] = None + + class Reference(BaseModel): parent_id: Optional[int] = Field(None, description="The parent ID of the reference") child_id: Optional[int] = Field(None, description="The child ID of the reference") @@ -1672,12 +1687,8 @@ class NativeReportSummary(BaseModel): class ProjectSummaryQuota(BaseModel): - hard: Optional[ResourceList] = Field( - None, description="The hard limits of the quota" - ) - used: Optional[ResourceList] = Field( - None, description="The used status of the quota" - ) + hard: Optional[ResourceList] = None + used: Optional[ResourceList] = None class CVEAllowlist(BaseModel): @@ -1737,6 +1748,11 @@ class RobotPermission(BaseModel): class GeneralInfo(BaseModel): + banner_message: Optional[str] = Field( + None, + description="The banner message for the UI. It is the stringified result of the banner message object.", + example='{"closable":true,"message":"your banner message content","type":"warning","fromDate":"06/19/2023","toDate":"06/21/2023"}', + ) current_time: Optional[datetime] = Field( None, description="The current time of the server." ) @@ -1779,10 +1795,7 @@ class GeneralInfo(BaseModel): None, description="The flag to indicate whether notification mechanism is enabled on Harbor instance.", ) - authproxy_settings: Optional[AuthproxySetting] = Field( - None, - description="The setting of auth proxy this is only available when Harbor relies on authproxy for authentication.", - ) + authproxy_settings: Optional[AuthproxySetting] = None class GCHistory(BaseModel): @@ -1873,174 +1886,64 @@ class SupportedWebhookEventTypes(BaseModel): payload_formats: Optional[List[PayloadFormat]] = None +class InternalConfigurationsResponse(BaseModel): + __root__: Optional[Dict[str, InternalConfigurationValue]] = None + + class ConfigurationsResponse(BaseModel): - auth_mode: Optional[StringConfigItem] = Field( - None, - description='The auth mode of current system, such as "db_auth", "ldap_auth", "oidc_auth"', - ) - primary_auth_mode: Optional[BoolConfigItem] = Field( - None, - description="The flag to indicate whether the current auth mode should consider as a primary one.", - ) - ldap_base_dn: Optional[StringConfigItem] = Field( - None, description="The Base DN for LDAP binding." - ) - ldap_filter: Optional[StringConfigItem] = Field( - None, description="The filter for LDAP search" - ) - ldap_group_base_dn: Optional[StringConfigItem] = Field( - None, description="The base DN to search LDAP group." - ) - ldap_group_admin_dn: Optional[StringConfigItem] = Field( - None, - description="Specify the ldap group which have the same privilege with Harbor admin", - ) - ldap_group_attribute_name: Optional[StringConfigItem] = Field( - None, - description="The attribute which is used as identity of the LDAP group, default is cn.'", - ) - ldap_group_search_filter: Optional[StringConfigItem] = Field( - None, description="The filter to search the ldap group" - ) - ldap_group_search_scope: Optional[IntegerConfigItem] = Field( - None, - description="The scope to search ldap group. ''0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE''", - ) - ldap_scope: Optional[IntegerConfigItem] = Field( - None, - description="The scope to search ldap users,'0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE'", - ) - ldap_search_dn: Optional[StringConfigItem] = Field( - None, description="The DN of the user to do the search." - ) - ldap_timeout: Optional[IntegerConfigItem] = Field( - None, description="Timeout in seconds for connection to LDAP server" - ) - ldap_uid: Optional[StringConfigItem] = Field( - None, - description='The attribute which is used as identity for the LDAP binding, such as "CN" or "SAMAccountname"', - ) - ldap_url: Optional[StringConfigItem] = Field( - None, description="The URL of LDAP server" - ) - ldap_verify_cert: Optional[BoolConfigItem] = Field( - None, - description="Whether verify your OIDC server certificate, disable it if your OIDC server is hosted via self-hosted certificate.", - ) - ldap_group_membership_attribute: Optional[StringConfigItem] = Field( - None, description="The user attribute to identify the group membership" - ) - project_creation_restriction: Optional[StringConfigItem] = Field( - None, - description="Indicate who can create projects, it could be ''adminonly'' or ''everyone''.", - ) - read_only: Optional[BoolConfigItem] = Field( - None, description="The flag to indicate whether Harbor is in readonly mode." - ) - self_registration: Optional[BoolConfigItem] = Field( - None, - description="Whether the Harbor instance supports self-registration. If it''s set to false, admin need to add user to the instance.", - ) - token_expiration: Optional[IntegerConfigItem] = Field( - None, - description="The expiration time of the token for internal Registry, in minutes.", - ) - uaa_client_id: Optional[StringConfigItem] = Field( - None, description="The client id of UAA" - ) - uaa_client_secret: Optional[StringConfigItem] = Field( - None, description="The client secret of the UAA" - ) - uaa_endpoint: Optional[StringConfigItem] = Field( - None, description="The endpoint of the UAA" - ) - uaa_verify_cert: Optional[BoolConfigItem] = Field( - None, description="Verify the certificate in UAA server" - ) - http_authproxy_endpoint: Optional[StringConfigItem] = Field( - None, description="The endpoint of the HTTP auth" - ) - http_authproxy_tokenreview_endpoint: Optional[StringConfigItem] = Field( - None, description="The token review endpoint" - ) - http_authproxy_admin_groups: Optional[StringConfigItem] = Field( - None, description="The group which has the harbor admin privileges" - ) - http_authproxy_admin_usernames: Optional[StringConfigItem] = Field( - None, description="The usernames which has the harbor admin privileges" - ) - http_authproxy_verify_cert: Optional[BoolConfigItem] = Field( - None, description="Verify the HTTP auth provider's certificate" - ) - http_authproxy_skip_search: Optional[BoolConfigItem] = Field( - None, description="Search user before onboard" - ) - http_authproxy_server_certificate: Optional[StringConfigItem] = Field( - None, description="The certificate of the HTTP auth provider" - ) - oidc_name: Optional[StringConfigItem] = Field( - None, description="The OIDC provider name" - ) - oidc_endpoint: Optional[StringConfigItem] = Field( - None, description="The endpoint of the OIDC provider" - ) - oidc_client_id: Optional[StringConfigItem] = Field( - None, description="The client ID of the OIDC provider" - ) - oidc_groups_claim: Optional[StringConfigItem] = Field( - None, description="The attribute claims the group name" - ) - oidc_admin_group: Optional[StringConfigItem] = Field( - None, description="The OIDC group which has the harbor admin privileges" - ) - oidc_group_filter: Optional[StringConfigItem] = Field( - None, - description="The OIDC group filter which filters out the group doesn't match the regular expression", - ) - oidc_scope: Optional[StringConfigItem] = Field( - None, description="The scope of the OIDC provider" - ) - oidc_user_claim: Optional[StringConfigItem] = Field( - None, description="The attribute claims the username" - ) - oidc_verify_cert: Optional[BoolConfigItem] = Field( - None, description="Verify the OIDC provider's certificate'" - ) - oidc_auto_onboard: Optional[BoolConfigItem] = Field( - None, description="Auto onboard the OIDC user" - ) - oidc_extra_redirect_parms: Optional[StringConfigItem] = Field( - None, - description="Extra parameters to add when redirect request to OIDC provider", - ) - robot_token_duration: Optional[IntegerConfigItem] = Field( - None, description="The robot account token duration in days" - ) - robot_name_prefix: Optional[StringConfigItem] = Field( - None, description="The rebot account name prefix" - ) - notification_enable: Optional[BoolConfigItem] = Field( - None, description="Enable notification" - ) - quota_per_project_enable: Optional[BoolConfigItem] = Field( - None, description="Enable quota per project" - ) - storage_per_project: Optional[IntegerConfigItem] = Field( - None, description="The storage quota per project" - ) - audit_log_forward_endpoint: Optional[StringConfigItem] = Field( - None, description="The endpoint of the audit log forwarder" - ) - skip_audit_log_database: Optional[BoolConfigItem] = Field( - None, description="Whether skip the audit log in database" - ) - scanner_skip_update_pulltime: Optional[BoolConfigItem] = Field( - None, description="Whether or not to skip update the pull time for scanner" - ) + auth_mode: Optional[StringConfigItem] = None + primary_auth_mode: Optional[BoolConfigItem] = None + ldap_base_dn: Optional[StringConfigItem] = None + ldap_filter: Optional[StringConfigItem] = None + ldap_group_base_dn: Optional[StringConfigItem] = None + ldap_group_admin_dn: Optional[StringConfigItem] = None + ldap_group_attribute_name: Optional[StringConfigItem] = None + ldap_group_search_filter: Optional[StringConfigItem] = None + ldap_group_search_scope: Optional[IntegerConfigItem] = None + ldap_scope: Optional[IntegerConfigItem] = None + ldap_search_dn: Optional[StringConfigItem] = None + ldap_timeout: Optional[IntegerConfigItem] = None + ldap_uid: Optional[StringConfigItem] = None + ldap_url: Optional[StringConfigItem] = None + ldap_verify_cert: Optional[BoolConfigItem] = None + ldap_group_membership_attribute: Optional[StringConfigItem] = None + project_creation_restriction: Optional[StringConfigItem] = None + read_only: Optional[BoolConfigItem] = None + self_registration: Optional[BoolConfigItem] = None + token_expiration: Optional[IntegerConfigItem] = None + uaa_client_id: Optional[StringConfigItem] = None + uaa_client_secret: Optional[StringConfigItem] = None + uaa_endpoint: Optional[StringConfigItem] = None + uaa_verify_cert: Optional[BoolConfigItem] = None + http_authproxy_endpoint: Optional[StringConfigItem] = None + http_authproxy_tokenreview_endpoint: Optional[StringConfigItem] = None + http_authproxy_admin_groups: Optional[StringConfigItem] = None + http_authproxy_admin_usernames: Optional[StringConfigItem] = None + http_authproxy_verify_cert: Optional[BoolConfigItem] = None + http_authproxy_skip_search: Optional[BoolConfigItem] = None + http_authproxy_server_certificate: Optional[StringConfigItem] = None + oidc_name: Optional[StringConfigItem] = None + oidc_endpoint: Optional[StringConfigItem] = None + oidc_client_id: Optional[StringConfigItem] = None + oidc_groups_claim: Optional[StringConfigItem] = None + oidc_admin_group: Optional[StringConfigItem] = None + oidc_group_filter: Optional[StringConfigItem] = None + oidc_scope: Optional[StringConfigItem] = None + oidc_user_claim: Optional[StringConfigItem] = None + oidc_verify_cert: Optional[BoolConfigItem] = None + oidc_auto_onboard: Optional[BoolConfigItem] = None + oidc_extra_redirect_parms: Optional[StringConfigItem] = None + robot_token_duration: Optional[IntegerConfigItem] = None + robot_name_prefix: Optional[StringConfigItem] = None + notification_enable: Optional[BoolConfigItem] = None + quota_per_project_enable: Optional[BoolConfigItem] = None + storage_per_project: Optional[IntegerConfigItem] = None + audit_log_forward_endpoint: Optional[StringConfigItem] = None + skip_audit_log_database: Optional[BoolConfigItem] = None + scanner_skip_update_pulltime: Optional[BoolConfigItem] = None scan_all_policy: Optional[ScanAllPolicy] = None - session_timeout: Optional[IntegerConfigItem] = Field( - None, description="The session timeout in minutes" - ) + session_timeout: Optional[IntegerConfigItem] = None + banner_message: Optional[StringConfigItem] = None class ProjectMember(BaseModel): @@ -2060,42 +1963,45 @@ class OverallHealthStatus(BaseModel): components: Optional[List[ComponentHealthStatus]] = None -class Artifact(BaseModel): - id: Optional[int] = Field(None, description="The ID of the artifact") - type: Optional[str] = Field( - None, description="The type of the artifact, e.g. image, chart, etc" +class SecuritySummary(BaseModel): + critical_cnt: Optional[int] = Field( + None, description="the count of critical vulnerabilities" ) - media_type: Optional[str] = Field( - None, description="The media type of the artifact" + high_cnt: Optional[int] = Field( + None, description="the count of high vulnerabilities" ) - manifest_media_type: Optional[str] = Field( - None, description="The manifest media type of the artifact" + medium_cnt: Optional[int] = Field( + None, description="the count of medium vulnerabilities" ) - project_id: Optional[int] = Field( - None, description="The ID of the project that the artifact belongs to" + low_cnt: Optional[int] = Field(None, description="the count of low vulnerabilities") + none_cnt: Optional[int] = Field( + None, description="the count of none vulnerabilities" ) - repository_id: Optional[int] = Field( - None, description="The ID of the repository that the artifact belongs to" + unknown_cnt: Optional[int] = Field( + None, description="the count of unknown vulnerabilities" ) - digest: Optional[str] = Field(None, description="The digest of the artifact") - size: Optional[int] = Field(None, description="The size of the artifact") - icon: Optional[str] = Field(None, description="The digest of the icon") - push_time: Optional[datetime] = Field( - None, description="The push time of the artifact" + total_vuls: Optional[int] = Field( + None, description="the count of total vulnerabilities" ) - pull_time: Optional[datetime] = Field( - None, description="The latest pull time of the artifact" + scanned_cnt: Optional[int] = Field( + None, description="the count of scanned artifacts" ) - extra_attrs: Optional[ExtraAttrs] = None - annotations: Optional[Annotations] = None - references: Optional[List[Reference]] = None - tags: Optional[List[Tag]] = None - addition_links: Optional[AdditionLinks] = None - labels: Optional[List[Label]] = None - scan_overview: Optional[ScanOverview] = Field( - None, description="The overview of the scan result." + total_artifact: Optional[int] = Field( + None, description="the total count of artifacts" ) - accessories: Optional[List[Accessory]] = None + fixable_cnt: Optional[int] = Field( + None, description="the count of fixable vulnerabilities" + ) + dangerous_cves: Optional[List[DangerousCVE]] = Field( + None, description="the list of dangerous CVEs" + ) + dangerous_artifacts: Optional[List[DangerousArtifact]] = Field( + None, description="the list of dangerous artifacts" + ) + + +class ScanOverview(BaseModel): + __root__: Optional[Dict[str, NativeReportSummary]] = None class ProjectReq(BaseModel): @@ -2105,12 +2011,8 @@ class ProjectReq(BaseModel): public: Optional[bool] = Field( None, description="deprecated, reserved for project creation in replication" ) - metadata: Optional[ProjectMetadata] = Field( - None, description="The metadata of the project." - ) - cve_allowlist: Optional[CVEAllowlist] = Field( - None, description="The CVE allowlist of the project." - ) + metadata: Optional[ProjectMetadata] = None + cve_allowlist: Optional[CVEAllowlist] = None storage_limit: Optional[int] = Field( None, description="The storage quota of the project." ) @@ -2156,12 +2058,8 @@ class Project(BaseModel): repo_count: Optional[int] = Field( None, description="The number of the repositories under this project." ) - metadata: Optional[ProjectMetadata] = Field( - None, description="The metadata of the project." - ) - cve_allowlist: Optional[CVEAllowlist] = Field( - None, description="The CVE allowlist of this project." - ) + metadata: Optional[ProjectMetadata] = None + cve_allowlist: Optional[CVEAllowlist] = None class ProjectSummary(BaseModel): @@ -2193,10 +2091,8 @@ class ReplicationPolicy(BaseModel): description: Optional[str] = Field( None, description="The description of the policy." ) - src_registry: Optional[Registry] = Field(None, description="The source registry.") - dest_registry: Optional[Registry] = Field( - None, description="The destination registry." - ) + src_registry: Optional[Registry] = None + dest_registry: Optional[Registry] = None dest_namespace: Optional[str] = Field( None, description="The destination namespace." ) @@ -2235,12 +2131,8 @@ class ReplicationPolicy(BaseModel): class RegistryProviderInfo(BaseModel): - endpoint_pattern: Optional[RegistryProviderEndpointPattern] = Field( - None, description="The endpoint pattern" - ) - credential_pattern: Optional[RegistryProviderCredentialPattern] = Field( - None, description="The credential pattern" - ) + endpoint_pattern: Optional[RegistryProviderEndpointPattern] = None + credential_pattern: Optional[RegistryProviderCredentialPattern] = None class Robot(BaseModel): @@ -2313,3 +2205,39 @@ class Search(BaseModel): None, description="Search results of the repositories that matched the filter keywords.", ) + + +class Artifact(BaseModel): + id: Optional[int] = Field(None, description="The ID of the artifact") + type: Optional[str] = Field( + None, description="The type of the artifact, e.g. image, chart, etc" + ) + media_type: Optional[str] = Field( + None, description="The media type of the artifact" + ) + manifest_media_type: Optional[str] = Field( + None, description="The manifest media type of the artifact" + ) + project_id: Optional[int] = Field( + None, description="The ID of the project that the artifact belongs to" + ) + repository_id: Optional[int] = Field( + None, description="The ID of the repository that the artifact belongs to" + ) + digest: Optional[str] = Field(None, description="The digest of the artifact") + size: Optional[int] = Field(None, description="The size of the artifact") + icon: Optional[str] = Field(None, description="The digest of the icon") + push_time: Optional[datetime] = Field( + None, description="The push time of the artifact" + ) + pull_time: Optional[datetime] = Field( + None, description="The latest pull time of the artifact" + ) + extra_attrs: Optional[ExtraAttrs] = None + annotations: Optional[Annotations] = None + references: Optional[List[Reference]] = None + tags: Optional[List[Tag]] = None + addition_links: Optional[AdditionLinks] = None + labels: Optional[List[Label]] = None + scan_overview: Optional[ScanOverview] = None + accessories: Optional[List[Accessory]] = None diff --git a/harborapi/models/_scanner.py b/harborapi/models/_scanner.py index b587493a..d6b58916 100644 --- a/harborapi/models/_scanner.py +++ b/harborapi/models/_scanner.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: -# filename: https://raw.githubusercontent.com/goharbor/pluggable-scanner-spec/master/api/spec/scanner-adapter-openapi-v1.1.yaml -# timestamp: 2023-06-07T13:51:29+00:00 +# filename: https://converter.swagger.io/api/convert?url=https://raw.githubusercontent.com/goharbor/pluggable-scanner-spec/master/api/spec/scanner-adapter-openapi-v1.1.yaml +# timestamp: 2023-08-01T08:14:53+00:00 from __future__ import annotations @@ -8,7 +8,7 @@ from enum import Enum from typing import Any, Dict, List, Optional -from pydantic import AnyUrl, Extra, Field +from pydantic import AnyUrl, Field from .base import BaseModel @@ -26,10 +26,7 @@ class Scanner(BaseModel): class ScannerProperties(BaseModel): - pass - - class Config: - extra = Extra.allow + __root__: Optional[Dict[str, str]] = None class ScannerCapability(BaseModel): diff --git a/harborapi/models/models.py b/harborapi/models/models.py index 740ce56f..dc49f8fd 100644 --- a/harborapi/models/models.py +++ b/harborapi/models/models.py @@ -82,7 +82,6 @@ LdapUser, Metadata, Metrics, - Model, ) from ._models import NativeReportSummary as _NativeReportSummary from ._models import ( @@ -201,7 +200,6 @@ # Explicit re-export of all models __all__ = [ - "Model", "Error", "SearchRepository", "Repository", diff --git a/justfile b/justfile index b64cd2fa..2b0b1b41 100644 --- a/justfile +++ b/justfile @@ -22,7 +22,7 @@ pcrun: # Generate new Harbor API models genapi: datamodel-codegen \ - --url https://raw.githubusercontent.com/goharbor/harbor/main/api/v2.0/swagger.yaml \ + --url https://converter.swagger.io/api/convert?url=https://raw.githubusercontent.com/goharbor/harbor/main/api/v2.0/swagger.yaml \ --output ./harborapi/models/_models.py black ./harborapi/models/_models.py # Finished fetching new definitions and generating models for the Harbor API @@ -30,7 +30,7 @@ genapi: # Generate new Scanner API models genscanner: datamodel-codegen \ - --url https://raw.githubusercontent.com/goharbor/pluggable-scanner-spec/master/api/spec/scanner-adapter-openapi-v1.1.yaml \ + --url https://converter.swagger.io/api/convert?url=https://raw.githubusercontent.com/goharbor/pluggable-scanner-spec/master/api/spec/scanner-adapter-openapi-v1.1.yaml \ --output ./harborapi/models/_scanner.py \ --input-file-type openapi black ./harborapi/models/_scanner.py diff --git a/pyproject.toml b/pyproject.toml index c9881de0..0b0d6a7e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,7 +60,7 @@ dependencies = [ "hypothesis>=6.62.1", "rich>=12.6.0", "typer>=0.7.0", - "datamodel-code-generator==0.13.0", + "datamodel-code-generator>=0.21.2", ] [tool.hatch.envs.default.scripts]