# generated by datamodel-codegen:
#   filename:  syft-schema-7.0.1.json
#   timestamp: 2023-03-15T11:18:16+00:00

from __future__ import annotations

from datetime import datetime
from typing import Any, Dict, List, Optional, Union

from pydantic import BaseModel, Field, constr


class Descriptor(BaseModel):
    name: str
    version: str
    configuration: Optional[Any] = None


class Relationship(BaseModel):
    parent: str
    child: str
    type: str
    metadata: Optional[Any] = None


class Schema(BaseModel):
    version: str
    url: str


class Source(BaseModel):
    id: str
    type: str
    target: Any


class CargoPackageMetadata(BaseModel):
    name: str
    version: str
    source: str
    checksum: str
    dependencies: List[str]


class CocoapodsMetadata(BaseModel):
    checksum: str


class ConanLockMetadata(BaseModel):
    ref: str
    package_id: Optional[str] = None
    prev: Optional[str] = None
    requires: Optional[str] = None
    build_requires: Optional[str] = None
    py_requires: Optional[str] = None
    options: Optional[Dict[constr(regex=r".*"), str]] = None
    path: Optional[str] = None
    context: Optional[str] = None


class ConanMetadata(BaseModel):
    ref: str


class Coordinates(BaseModel):
    path: str
    layerID: Optional[str] = None


class DartPubMetadata(BaseModel):
    name: str
    version: str
    hosted_url: Optional[str] = None
    vcs_url: Optional[str] = None


class Digest(BaseModel):
    algorithm: str
    value: str


class DotnetDepsMetadata(BaseModel):
    name: str
    version: str
    path: str
    sha512: str
    hashPath: str


class FileMetadataEntry(BaseModel):
    mode: int
    type: str
    linkDestination: Optional[str] = None
    userID: int
    groupID: int
    mimeType: str


class GemMetadata(BaseModel):
    name: str
    version: str
    files: Optional[List[str]] = None
    authors: Optional[List[str]] = None
    licenses: Optional[List[str]] = None
    homepage: Optional[str] = None


class GolangBinMetadata(BaseModel):
    goBuildSettings: Optional[Dict[constr(regex=r".*"), str]] = None
    goCompiledVersion: str
    architecture: str
    h1Digest: Optional[str] = None
    mainModule: Optional[str] = None


class GolangModMetadata(BaseModel):
    h1Digest: Optional[str] = None


class HackageMetadata(BaseModel):
    name: str
    version: str
    pkgHash: Optional[str] = None
    snapshotURL: Optional[str] = None


class IDLikes(BaseModel):
    __root__: List[str]


class KbPackageMetadata(BaseModel):
    product_id: str
    kb: str


class MixLockMetadata(BaseModel):
    name: str
    version: str
    pkgHash: str
    pkgHashExt: str


class NpmPackageJSONMetadata(BaseModel):
    name: str
    version: str
    files: Optional[List[str]] = None
    author: str
    licenses: List[str]
    homepage: str
    description: str
    url: str
    private: bool


class NpmPackageLockJSONMetadata(BaseModel):
    resolved: str
    integrity: str


class PythonPipfileLockMetadata(BaseModel):
    hashes: List[str]
    index: str


class RebarLockMetadata(BaseModel):
    name: str
    version: str
    pkgHash: str
    pkgHashExt: str


class SearchResult(BaseModel):
    classification: str
    lineNumber: int
    lineOffset: int
    seekPosition: int
    length: int
    value: Optional[str] = None


class AlpmFileRecord(BaseModel):
    path: Optional[str] = None
    type: Optional[str] = None
    uid: Optional[str] = None
    gid: Optional[str] = None
    time: Optional[datetime] = None
    size: Optional[str] = None
    link: Optional[str] = None
    digest: Optional[List[Digest]] = None


class ApkFileRecord(BaseModel):
    path: str
    ownerUid: Optional[str] = None
    ownerGid: Optional[str] = None
    permissions: Optional[str] = None
    digest: Optional[Digest] = None


class DpkgFileRecord(BaseModel):
    path: str
    digest: Optional[Digest] = None
    isConfigFile: bool


class JavaManifest(BaseModel):
    main: Optional[Dict[constr(regex=r".*"), str]] = None
    namedSections: Optional[
        Dict[constr(regex=r".*"), Dict[constr(regex=r".*"), str]]
    ] = None


class PhpComposerAuthors(BaseModel):
    name: str
    email: Optional[str] = None
    homepage: Optional[str] = None


class PhpComposerExternalReference(BaseModel):
    type: str
    url: str
    reference: str
    shasum: Optional[str] = None


class PomProperties(BaseModel):
    path: str
    name: str
    groupId: str
    artifactId: str
    version: str
    extraFields: Optional[Dict[constr(regex=r".*"), str]] = None


class PortageFileRecord(BaseModel):
    path: str
    digest: Optional[Digest] = None


class PythonDirectURLOriginInfo(BaseModel):
    url: str
    commitId: Optional[str] = None
    vcs: Optional[str] = None


class RpmdbFileRecord(BaseModel):
    path: str
    mode: int
    size: int
    digest: Digest
    userName: str
    groupName: str
    flags: str


class Location(BaseModel):
    path: str
    layerID: Optional[str] = None
    virtualPath: Optional[str] = None


class PomParent(BaseModel):
    groupId: str
    artifactId: str
    version: str


class PythonFileDigest(BaseModel):
    algorithm: str
    value: str


class File(BaseModel):
    id: str
    location: Coordinates
    metadata: Optional[FileMetadataEntry] = None
    contents: Optional[str] = None
    digests: Optional[List[Digest]] = None


class LinuxRelease(BaseModel):
    prettyName: Optional[str] = None
    name: Optional[str] = None
    id: Optional[str] = None
    idLike: Optional[IDLikes] = None
    version: Optional[str] = None
    versionID: Optional[str] = None
    versionCodename: Optional[str] = None
    buildID: Optional[str] = None
    imageID: Optional[str] = None
    imageVersion: Optional[str] = None
    variant: Optional[str] = None
    variantID: Optional[str] = None
    homeURL: Optional[str] = None
    supportURL: Optional[str] = None
    bugReportURL: Optional[str] = None
    privacyPolicyURL: Optional[str] = None
    cpeName: Optional[str] = None
    supportEnd: Optional[str] = None


class Secrets(BaseModel):
    location: Coordinates
    secrets: List[SearchResult]


class AlpmMetadata(BaseModel):
    basepackage: str
    package: str
    version: str
    description: str
    architecture: str
    size: int
    packager: str
    license: str
    url: str
    validation: str
    reason: int
    files: List[AlpmFileRecord]
    backup: List[AlpmFileRecord]


class ApkMetadata(BaseModel):
    package: str
    originPackage: str
    maintainer: str
    version: str
    license: str
    architecture: str
    url: str
    description: str
    size: int
    installedSize: int
    pullDependencies: List[str]
    provides: List[str]
    pullChecksum: str
    gitCommitOfApkPort: str
    files: List[ApkFileRecord]


class DpkgMetadata(BaseModel):
    package: str
    source: str
    version: str
    sourceVersion: str
    architecture: str
    maintainer: str
    installedSize: int
    files: List[DpkgFileRecord]


class PhpComposerJSONMetadata(BaseModel):
    name: str
    version: str
    source: PhpComposerExternalReference
    dist: PhpComposerExternalReference
    require: Optional[Dict[constr(regex=r".*"), str]] = None
    provide: Optional[Dict[constr(regex=r".*"), str]] = None
    require_dev: Optional[Dict[constr(regex=r".*"), str]] = Field(
        None, alias="require-dev"
    )
    suggest: Optional[Dict[constr(regex=r".*"), str]] = None
    type: Optional[str] = None
    notification_url: Optional[str] = Field(None, alias="notification-url")
    bin: Optional[List[str]] = None
    license: Optional[List[str]] = None
    authors: Optional[List[PhpComposerAuthors]] = None
    description: Optional[str] = None
    homepage: Optional[str] = None
    keywords: Optional[List[str]] = None
    time: Optional[str] = None


class PortageMetadata(BaseModel):
    installedSize: int
    files: List[PortageFileRecord]


class RpmMetadata(BaseModel):
    name: str
    version: str
    epoch: Optional[int]
    architecture: str
    release: str
    sourceRpm: str
    size: int
    license: str
    vendor: str
    modularityLabel: str
    files: List[RpmdbFileRecord]


class ClassifierMatch(BaseModel):
    classifier: str
    location: Location


class PomProject(BaseModel):
    path: str
    parent: Optional[PomParent] = None
    groupId: str
    artifactId: str
    version: str
    name: str
    description: Optional[str] = None
    url: Optional[str] = None


class PythonFileRecord(BaseModel):
    path: str
    digest: Optional[PythonFileDigest] = None
    size: Optional[str] = None


class BinaryMetadata(BaseModel):
    matches: List[ClassifierMatch]


class JavaMetadata(BaseModel):
    virtualPath: str
    manifest: Optional[JavaManifest] = None
    pomProperties: Optional[PomProperties] = None
    pomProject: Optional[PomProject] = None
    digest: Optional[List[Digest]] = None


class PythonPackageMetadata(BaseModel):
    name: str
    version: str
    license: str
    author: str
    authorEmail: str
    platform: str
    files: Optional[List[PythonFileRecord]] = None
    sitePackagesRootPath: str
    topLevelPackages: Optional[List[str]] = None
    directUrlOrigin: Optional[PythonDirectURLOriginInfo] = None


class Package(BaseModel):
    id: str
    name: str
    version: str
    type: str
    foundBy: str
    locations: List[Coordinates]
    licenses: List[str]
    language: str
    cpes: List[str]
    purl: str
    metadataType: Optional[str] = None
    metadata: Optional[
        Union[
            AlpmMetadata,
            ApkMetadata,
            BinaryMetadata,
            CargoPackageMetadata,
            CocoapodsMetadata,
            ConanLockMetadata,
            ConanMetadata,
            DartPubMetadata,
            DotnetDepsMetadata,
            DpkgMetadata,
            GemMetadata,
            GolangBinMetadata,
            GolangModMetadata,
            HackageMetadata,
            JavaMetadata,
            KbPackageMetadata,
            MixLockMetadata,
            NpmPackageJSONMetadata,
            NpmPackageLockJSONMetadata,
            PhpComposerJSONMetadata,
            PortageMetadata,
            PythonPackageMetadata,
            PythonPipfileLockMetadata,
            RebarLockMetadata,
            RpmMetadata,
        ]
    ] = None


class Document(BaseModel):
    artifacts: List[Package]
    artifactRelationships: List[Relationship]
    files: Optional[List[File]] = None
    secrets: Optional[List[Secrets]] = None
    source: Source
    distro: LinuxRelease
    descriptor: Descriptor
    schema_: Schema = Field(..., alias="schema")


class Model(BaseModel):
    __root__: Document


class SyftModel(Model):
    pass
