Skip to content

Commit

Permalink
feat(clearing): add bulk clearing endpoints, refactor objects
Browse files Browse the repository at this point in the history
  • Loading branch information
deveaud-m committed Nov 3, 2023
1 parent 16719d1 commit ec8155f
Show file tree
Hide file tree
Showing 18 changed files with 713 additions and 172 deletions.
3 changes: 2 additions & 1 deletion fossology/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@

import requests

from fossology.enums import TokenScope
from fossology.exceptions import AuthenticationError, FossologyApiError
from fossology.folders import Folders
from fossology.groups import Groups
from fossology.jobs import Jobs
from fossology.license import LicenseEndpoint
from fossology.obj import Agents, ApiInfo, HealthInfo, TokenScope, User
from fossology.obj import Agents, ApiInfo, HealthInfo, User
from fossology.report import Report
from fossology.search import Search
from fossology.uploads import Uploads
Expand Down
197 changes: 197 additions & 0 deletions fossology/enums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
# Copyright 2023 Siemens AG
# SPDX-License-Identifier: MIT

from enum import Enum


class AccessLevel(Enum):
"""Available access levels for uploads:
PRIVATE
PROTECTED
PUBLIC
"""

PRIVATE = "private"
PROTECTED = "protected"
PUBLIC = "public"


class ReportFormat(Enum):
"""Available report format:
DEP5
SPDX2
SPDX2TV
READMEOSS
UNIFIEDREPORT
"""

DEP5 = "dep5"
SPDX2 = "spdx2"
SPDX2TV = "spdx2tv"
READMEOSS = "readmeoss"
UNIFIEDREPORT = "unifiedreport"


class SearchTypes(Enum):
"""Type of item that can be searched:
ALLFILES
CONTAINERS
DIRECTORY
"""

ALLFILES = "allfiles"
CONTAINERS = "containers"
DIRECTORY = "directory"


class TokenScope(Enum):
"""Scope for API tokens:
READ: Read only access, limited only to "GET" calls
WRITE: Read/Write access, required for calls other than "GET"
"""

READ = "read"
WRITE = "write"


class ClearingStatus(Enum):
"""Clearing statuses:
OPEN
INPROGRESS
CLOSED
REJECTED
"""

OPEN = "Open"
INPROGRESS = "InProgress"
CLOSED = "Closed"
REJECTED = "Rejected"


class JobStatus(Enum):
"""Job statuses:
COMPLETED
FAILED
QUEUED
PROCESSING
"""

COMPLETED = "Completed"
FAILED = "Failed"
QUEUED = "Queued"
PROCESSING = "Processing"


class LicenseType(Enum):
"""License types:
CANDIDATE
MAIN
ALL
"""

CANDIDATE = "candidate"
MAIN = "main"
ALL = "all"


class ObligationClass(Enum):
"""Classification of an obligation:
GREEN
WHITE
YELLOW
RED
"""

GREEN = "green"
WHITE = "white"
YELLOW = "yellow"
RED = "red"


class MemberPerm(Enum):
"""Group member permissions:
USER
ADMIN
ADVISOR
"""

USER = 0
ADMIN = 1
ADVISOR = 2


class Permission(Enum):
"""Upload or group permissions:
NONE
READ_ONLY
READ_WRITE
CLEARING_ADMIN
ADMIN
"""

NONE = "0"
READ_ONLY = "1"
READ_WRITE = "3"
CLEARING_ADMIN = "5"
ADMIN = "10"


class ClearingScope(Enum):
"""Scope of the clearing:
LOCAL
PACKAGE
GLOBAL
"""

LOCAL = "local"
PACKAGE = "package"
GLOBAL = "global"


class ClearingType(Enum):
"""Type of the clearing:
TO_BE_DISCUSSED
IRRELEVANT
IDENTIFIED
DO_NOT_USE
NON_FUNCTIONAL
"""

TO_BE_DISCUSSED = "TO_BE_DISCUSSED"
IRRELEVANT = "IRRELEVANT"
IDENTIFIED = "IDENTIFIED"
DO_NOT_USE = "DO_NOT_USE"
NON_FUNCTIONAL = "NON_FUNCTIONAL"


class PrevNextSelection(Enum):
"""Type of file to be selected for the prev-next endpoint:
WITHLICENSES
NOCLEARING
"""

WITHLICENSES = "withLicenses"
NOCLEARING = "noClearing"
3 changes: 2 additions & 1 deletion fossology/foss_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
import click

from fossology import Fossology, fossology_token
from fossology.enums import AccessLevel, ReportFormat, TokenScope
from fossology.exceptions import FossologyApiError, FossologyUnsupported
from fossology.obj import AccessLevel, Folder, ReportFormat, Summary, TokenScope
from fossology.obj import Folder, Summary

logger = logging.getLogger(__name__)
formatter = logging.Formatter(
Expand Down
3 changes: 2 additions & 1 deletion fossology/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

import logging

from fossology.enums import MemberPerm
from fossology.exceptions import FossologyApiError
from fossology.obj import Group, MemberPerm, UserGroupMember
from fossology.obj import Group, UserGroupMember

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
Expand Down
3 changes: 2 additions & 1 deletion fossology/license.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
from typing import Tuple
from urllib.parse import quote

from fossology.enums import LicenseType
from fossology.exceptions import FossologyApiError
from fossology.obj import License, LicenseType, Obligation
from fossology.obj import License, Obligation

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
Expand Down
Loading

0 comments on commit ec8155f

Please sign in to comment.