Skip to content

Commit 8ce8356

Browse files
committed
chore(Enum): Use Enum instead of plain strings
Issue: APPAI-46
1 parent a067813 commit 8ce8356

File tree

3 files changed

+50
-9
lines changed

3 files changed

+50
-9
lines changed

packages/gg_api_core/src/gg_api_core/tools/list_repo_incidents.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,34 @@
33

44
from pydantic import BaseModel, Field
55

6+
from gg_api_core.client import IncidentSeverity, IncidentStatus, IncidentValidity, TagNames
67
from gg_api_core.utils import get_client
78

89
logger = logging.getLogger(__name__)
910

10-
DEFAULT_EXCLUDED_TAGS = ["TEST_FILE", "FALSE_POSITIVE", "CHECK_RUN_SKIP_FALSE_POSITIVE", "CHECK_RUN_SKIP_LOW_RISK", "CHECK_RUN_SKIP_TEST_CRED"]
11-
DEFAULT_SEVERITIES = ["critical", "high", "medium"]
12-
DEFAULT_STATUSES = ["TRIGGERED", "ASSIGNED", "RESOLVED"] # We exclude "IGNORED" ones
13-
DEFAULT_VALIDITIES = ["valid", "failed_to_check", "no_checker", "unknown"] # We exclude "invalid" ones
11+
DEFAULT_EXCLUDED_TAGS = [
12+
TagNames.TEST_FILE,
13+
TagNames.FALSE_POSITIVE,
14+
TagNames.CHECK_RUN_SKIP_FALSE_POSITIVE,
15+
TagNames.CHECK_RUN_SKIP_LOW_RISK,
16+
TagNames.CHECK_RUN_SKIP_TEST_CRED,
17+
]
18+
DEFAULT_SEVERITIES = [
19+
IncidentSeverity.CRITICAL,
20+
IncidentSeverity.HIGH,
21+
IncidentSeverity.MEDIUM,
22+
]
23+
DEFAULT_STATUSES = [
24+
IncidentStatus.TRIGGERED,
25+
IncidentStatus.ASSIGNED,
26+
IncidentStatus.RESOLVED,
27+
] # We exclude "IGNORED" ones
28+
DEFAULT_VALIDITIES = [
29+
IncidentValidity.VALID,
30+
IncidentValidity.FAILED_TO_CHECK,
31+
IncidentValidity.NO_CHECKER,
32+
IncidentValidity.UNKNOWN,
33+
] # We exclude "INVALID" ones
1434

1535

1636
class ListRepoIncidentsParams(BaseModel):

packages/gg_api_core/src/gg_api_core/tools/list_repo_occurrences.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,36 @@
33

44
from pydantic import BaseModel, Field
55

6+
from gg_api_core.client import IncidentSeverity, IncidentStatus, IncidentValidity, TagNames
67
from gg_api_core.utils import get_client
78

89
logger = logging.getLogger(__name__)
910

1011

11-
DEFAULT_EXCLUDED_TAGS = ["TEST_FILE", "FALSE_POSITIVE", "CHECK_RUN_SKIP_FALSE_POSITIVE", "CHECK_RUN_SKIP_LOW_RISK", "CHECK_RUN_SKIP_TEST_CRED"]
12-
DEFAULT_SEVERITIES = ["critical", "high", "medium"]
13-
DEFAULT_STATUSES = ["TRIGGERED", "ASSIGNED", "RESOLVED"] # We exclude "IGNORED" ones
14-
DEFAULT_VALIDITIES = ["valid", "failed_to_check", "no_checker", "unknown"] # We exclude "invalid" ones
12+
DEFAULT_EXCLUDED_TAGS = [
13+
TagNames.TEST_FILE,
14+
TagNames.FALSE_POSITIVE,
15+
TagNames.CHECK_RUN_SKIP_FALSE_POSITIVE,
16+
TagNames.CHECK_RUN_SKIP_LOW_RISK,
17+
TagNames.CHECK_RUN_SKIP_TEST_CRED,
18+
]
19+
DEFAULT_SEVERITIES = [
20+
IncidentSeverity.CRITICAL,
21+
IncidentSeverity.HIGH,
22+
IncidentSeverity.MEDIUM,
23+
IncidentSeverity.UNKNOWN,
24+
]
25+
DEFAULT_STATUSES = [
26+
IncidentStatus.TRIGGERED,
27+
IncidentStatus.ASSIGNED,
28+
IncidentStatus.RESOLVED,
29+
] # We exclude "IGNORED" ones
30+
DEFAULT_VALIDITIES = [
31+
IncidentValidity.VALID,
32+
IncidentValidity.FAILED_TO_CHECK,
33+
IncidentValidity.NO_CHECKER,
34+
IncidentValidity.UNKNOWN,
35+
] # We exclude "INVALID" ones
1536

1637

1738
class ListRepoOccurrencesParams(BaseModel):

scripts/run_tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
async def fetch_repo_occurrences():
88
result = await list_repo_occurrences(
9-
ListRepoOccurrencesParams(source_id="9036019")
9+
ListRepoOccurrencesParams(source_id="9036019", get_all=False, status=None, severity=["critical", "high", "medium", "low", "info", "unknown"])
1010
)
1111
print(result)
1212

0 commit comments

Comments
 (0)