55 lines
1.1 KiB
Python
55 lines
1.1 KiB
Python
|
|
import uuid
|
||
|
|
from datetime import datetime
|
||
|
|
|
||
|
|
from pydantic import BaseModel, ConfigDict
|
||
|
|
|
||
|
|
from api.models.sbom_entry import Ecosystem
|
||
|
|
|
||
|
|
|
||
|
|
class SBOMEntryCreate(BaseModel):
|
||
|
|
package_name: str
|
||
|
|
package_version: str | None = None
|
||
|
|
ecosystem: Ecosystem
|
||
|
|
license_spdx: str | None = None
|
||
|
|
is_direct: bool = True
|
||
|
|
is_dev: bool = False
|
||
|
|
|
||
|
|
|
||
|
|
class SBOMIngest(BaseModel):
|
||
|
|
repo_slug: str
|
||
|
|
entries: list[SBOMEntryCreate]
|
||
|
|
|
||
|
|
|
||
|
|
class SBOMEntryRead(BaseModel):
|
||
|
|
model_config = ConfigDict(from_attributes=True)
|
||
|
|
|
||
|
|
id: uuid.UUID
|
||
|
|
repo_id: uuid.UUID
|
||
|
|
package_name: str
|
||
|
|
package_version: str | None = None
|
||
|
|
ecosystem: Ecosystem
|
||
|
|
license_spdx: str | None = None
|
||
|
|
is_direct: bool
|
||
|
|
is_dev: bool
|
||
|
|
snapshot_at: datetime
|
||
|
|
created_at: datetime
|
||
|
|
|
||
|
|
|
||
|
|
class LicenceGroup(BaseModel):
|
||
|
|
license_spdx: str | None
|
||
|
|
count: int
|
||
|
|
repos: list[str]
|
||
|
|
is_copyleft: bool
|
||
|
|
|
||
|
|
|
||
|
|
class LicenceReport(BaseModel):
|
||
|
|
groups: list[LicenceGroup]
|
||
|
|
copyleft_direct_count: int
|
||
|
|
|
||
|
|
|
||
|
|
class SBOMRepoView(BaseModel):
|
||
|
|
repo_slug: str
|
||
|
|
last_sbom_at: datetime | None = None
|
||
|
|
entry_count: int
|
||
|
|
entries: list[SBOMEntryRead]
|