Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(clearing): add bulk clearing endpoints, refactor objects #118

Merged
merged 4 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/fossologytests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
test-latest:
name: Integration Tests (latest Fossology - 4.2.1)
name: Integration Tests (latest Fossology - 4.3.0)
runs-on: ubuntu-latest

container:
Expand All @@ -20,7 +20,7 @@ jobs:

services:
fossology:
image: fossology/fossology:4.2.1
image: fossology/fossology:4.3.0
ports:
- 8081:80
volumes:
Expand All @@ -44,10 +44,8 @@ jobs:
run: nmap fossology -p 80
- name: Run tests
run: |
export API_LATEST=true
poetry run coverage run --source=fossology -m pytest
poetry run coverage report -m
continue-on-error: true
- name: upload codecoverage results only if we are on the repository fossology/fossology-python
if: ${{ github.repository == 'fossology/fossology-python' }}
run: poetry run codecov -t ${{ secrets.CODECOV_TOKEN }}
3 changes: 2 additions & 1 deletion docs-source/sample_workflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ Needed imports and Variables
>>> from getpass import getpass
>>> import requests
>>> from fossology import Fossology, fossology_token
>>> from fossology.obj import Group, AccessLevel, TokenScope
>>> from fossology.obj import Group
>>> from fossology.enums import AccessLevel, TokenScope
>>> from fossology.exceptions import FossologyApiError
>>> FOSSOLOGY_SERVER = "http://fossology/repo"
>>> os.environ["FOSSOLOGY_USER"] = "fossy"
Expand Down
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