Tapi 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tapi/__init__.py +2 -0
- tapi/api/__init__.py +46 -0
- tapi/api/action/__init__.py +7 -0
- tapi/api/action/actions.py +106 -0
- tapi/api/action/events.py +33 -0
- tapi/api/action/logs.py +34 -0
- tapi/api/admin/__init__.py +12 -0
- tapi/api/admin/action_egress_control_rules.py +87 -0
- tapi/api/admin/admin.py +43 -0
- tapi/api/admin/ip_access_control.py +76 -0
- tapi/api/admin/job.py +42 -0
- tapi/api/admin/scim.py +27 -0
- tapi/api/admin/template.py +86 -0
- tapi/api/admin/user.py +104 -0
- tapi/api/audit_log/__init__.py +5 -0
- tapi/api/audit_log/audit_logs.py +24 -0
- tapi/api/case/__init__.py +20 -0
- tapi/api/case/actions.py +90 -0
- tapi/api/case/activities.py +35 -0
- tapi/api/case/assignees.py +21 -0
- tapi/api/case/blocks.py +112 -0
- tapi/api/case/cases.py +132 -0
- tapi/api/case/comments.py +102 -0
- tapi/api/case/fields.py +69 -0
- tapi/api/case/files.py +77 -0
- tapi/api/case/inputs.py +64 -0
- tapi/api/case/linked_cases.py +57 -0
- tapi/api/case/metadata.py +65 -0
- tapi/api/case/notes.py +78 -0
- tapi/api/case/records.py +54 -0
- tapi/api/case/subscribers.py +56 -0
- tapi/api/credential/__init__.py +1 -0
- tapi/api/credential/credentials.py +240 -0
- tapi/api/event/__init__.py +1 -0
- tapi/api/event/events.py +44 -0
- tapi/api/folder/__init__.py +1 -0
- tapi/api/folder/folders.py +71 -0
- tapi/api/note/__init__.py +5 -0
- tapi/api/note/notes.py +76 -0
- tapi/api/record/__init__.py +7 -0
- tapi/api/record/artifacts.py +17 -0
- tapi/api/record/records.py +85 -0
- tapi/api/record/types.py +52 -0
- tapi/api/report/__init__.py +5 -0
- tapi/api/report/reporting.py +41 -0
- tapi/api/resource/__init__.py +1 -0
- tapi/api/resource/resources.py +152 -0
- tapi/api/story/__init__.py +10 -0
- tapi/api/story/change_requests.py +64 -0
- tapi/api/story/drafts.py +45 -0
- tapi/api/story/groups.py +38 -0
- tapi/api/story/runs.py +43 -0
- tapi/api/story/stories.py +162 -0
- tapi/api/story/versions.py +65 -0
- tapi/api/team/__init__.py +4 -0
- tapi/api/team/members.py +62 -0
- tapi/api/team/teams.py +60 -0
- tapi/api/tenant.py +68 -0
- tapi/client/__init__.py +1 -0
- tapi/client/client.py +55 -0
- tapi/utils/helpers.py +9 -0
- tapi/utils/http.py +8 -0
- tapi/utils/testing_decorators.py +5 -0
- tapi/utils/types.py +300 -0
- tapi-0.1.2.dist-info/METADATA +2487 -0
- tapi-0.1.2.dist-info/RECORD +69 -0
- tapi-0.1.2.dist-info/WHEEL +5 -0
- tapi-0.1.2.dist-info/licenses/LICENSE +674 -0
- tapi-0.1.2.dist-info/top_level.txt +1 -0
tapi/__init__.py
ADDED
tapi/api/__init__.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from .case import *
|
|
2
|
+
from .team import *
|
|
3
|
+
from .note import *
|
|
4
|
+
from .story import *
|
|
5
|
+
from .event import *
|
|
6
|
+
from .admin import *
|
|
7
|
+
from .folder import *
|
|
8
|
+
from .action import *
|
|
9
|
+
from .record import *
|
|
10
|
+
from .report import *
|
|
11
|
+
from .resource import *
|
|
12
|
+
from .audit_log import *
|
|
13
|
+
from .credential import *
|
|
14
|
+
from .tenant import TenantAPI
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
"TenantAPI",
|
|
18
|
+
|
|
19
|
+
"CasesAPI", "CaseActionsAPI", "CaseActivitiesAPI", "CaseAssigneesAPI", "CaseInputsAPI", "CaseInputsFieldsAPI",
|
|
20
|
+
"CaseCommentsAPI", "CaseCommentsReactionsAPI", "CaseFieldsAPI", "CaseFilesAPI", "LinkedCasesAPI", "CaseMetadataAPI",
|
|
21
|
+
"CaseNotesAPI", "CaseRecordsAPI", "CaseSubscribersAPI", "GroupsAPI", "CaseBlocksAPI", "CaseBlockElementsAPI",
|
|
22
|
+
|
|
23
|
+
"ActionsAPI", "ActionLogsAPI", "ActionEventsAPI",
|
|
24
|
+
|
|
25
|
+
"NotesAPI",
|
|
26
|
+
|
|
27
|
+
"AuditLogsAPI",
|
|
28
|
+
|
|
29
|
+
"CredentialsAPI",
|
|
30
|
+
|
|
31
|
+
"EventsAPI",
|
|
32
|
+
|
|
33
|
+
"FoldersAPI",
|
|
34
|
+
|
|
35
|
+
"ResourcesAPI",
|
|
36
|
+
|
|
37
|
+
"RecordsAPI", "RecordTypesAPI", "RecordArtifactsAPI",
|
|
38
|
+
|
|
39
|
+
"ReportingAPI",
|
|
40
|
+
|
|
41
|
+
"AdminAPI", "ActionEgressControlRulesAPI", "IpAccessControlAPI", "JobsAPI", "SCIMUserGroupMappingAPI",
|
|
42
|
+
"TemplatesAPI", "UsersAPI", "DraftsAPI",
|
|
43
|
+
|
|
44
|
+
"StoriesAPI", "ChangeRequestAPI", "RunsAPI", "VersionsAPI",
|
|
45
|
+
"TeamsAPI", "MembersAPI"
|
|
46
|
+
]
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
from tapi.client import Client
|
|
2
|
+
from .logs import ActionLogsAPI
|
|
3
|
+
from .events import ActionEventsAPI
|
|
4
|
+
from tapi.utils.types import AgentType, StoryMode
|
|
5
|
+
from typing import List, Dict, Any, Optional, Union
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ActionsAPI(Client):
|
|
9
|
+
def __init__(self, domain: str, apiKey: str):
|
|
10
|
+
super().__init__(domain, apiKey)
|
|
11
|
+
self.base_endpoint = "actions"
|
|
12
|
+
self.logs = ActionLogsAPI(domain, apiKey)
|
|
13
|
+
self.events = ActionEventsAPI(domain, apiKey)
|
|
14
|
+
|
|
15
|
+
def create(
|
|
16
|
+
self,
|
|
17
|
+
type: Union[AgentType, str],
|
|
18
|
+
name: str,
|
|
19
|
+
options: Dict[str, Any],
|
|
20
|
+
position: Dict[str, int],
|
|
21
|
+
story_id: Optional[int] = None,
|
|
22
|
+
group_id: Optional[int] = None,
|
|
23
|
+
description: Optional[str] = None,
|
|
24
|
+
disabled: bool = False,
|
|
25
|
+
source_ids: Optional[List[int]] = None,
|
|
26
|
+
links_to_sources: Optional[List[Dict[str, Union[str, int]]]] = None,
|
|
27
|
+
receiver_ids: Optional[List[int]] = None,
|
|
28
|
+
links_to_receivers: Optional[List[Dict[str, Union[str, int]]]] = None,
|
|
29
|
+
schedule: Optional[List[Dict[str, str]]] = None,
|
|
30
|
+
monitor_failures: bool = True,
|
|
31
|
+
monitor_all_events: bool = False,
|
|
32
|
+
monitor_no_events_emitted: Optional[int] = None
|
|
33
|
+
):
|
|
34
|
+
return self._http_request(
|
|
35
|
+
"POST",
|
|
36
|
+
self.base_endpoint,
|
|
37
|
+
json = {key: value for key, value in locals().items() if value is not None and key != "self"}
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
def get(
|
|
41
|
+
self,
|
|
42
|
+
action_id: int
|
|
43
|
+
):
|
|
44
|
+
return self._http_request(
|
|
45
|
+
"GET",
|
|
46
|
+
f"{self.base_endpoint}/{action_id}"
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
def update(
|
|
50
|
+
self,
|
|
51
|
+
action_id: int,
|
|
52
|
+
name: Optional[str] = None,
|
|
53
|
+
description: Optional[str] = None,
|
|
54
|
+
options: Optional[Dict[str, Any]] = None,
|
|
55
|
+
position: Optional[Dict[str, int]] = None,
|
|
56
|
+
source_ids: Optional[List[int]] = None,
|
|
57
|
+
links_to_sources: Optional[List[Dict[str, Union[int, str]]]] = None,
|
|
58
|
+
receiver_ids: Optional[List[str]] = None,
|
|
59
|
+
links_to_receivers: Optional[List[Dict[str, Union[int, str]]]] = None,
|
|
60
|
+
schedule: Optional[Dict[str, Any]] = None,
|
|
61
|
+
disabled: Optional[bool] = None,
|
|
62
|
+
monitor_failures: Optional[bool] = None,
|
|
63
|
+
monitor_all_events: Optional[bool] = None,
|
|
64
|
+
monitor_no_events_emitted: Optional[int] = None
|
|
65
|
+
):
|
|
66
|
+
return self._http_request(
|
|
67
|
+
"PUT",
|
|
68
|
+
f"{self.base_endpoint}/{action_id}",
|
|
69
|
+
json = {key: value for key, value in locals().items()
|
|
70
|
+
if value is not None and key not in ("self", "action_id")}
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
def list(
|
|
74
|
+
self,
|
|
75
|
+
story_id: Optional[int] = None,
|
|
76
|
+
story_mode: Optional[Union[StoryMode, str]] = None,
|
|
77
|
+
team_id: Optional[int] = None,
|
|
78
|
+
group_id: Optional[int] = None,
|
|
79
|
+
draft_id: Optional[str] = None,
|
|
80
|
+
action_type: Optional[str] = None,
|
|
81
|
+
per_page: int = 10,
|
|
82
|
+
page: int = 1
|
|
83
|
+
):
|
|
84
|
+
return self._http_request(
|
|
85
|
+
"GET",
|
|
86
|
+
self.base_endpoint,
|
|
87
|
+
params = {key: value for key, value in locals().items() if value is not None and key != "self"}
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
def delete(
|
|
91
|
+
self,
|
|
92
|
+
action_id: int
|
|
93
|
+
):
|
|
94
|
+
return self._http_request(
|
|
95
|
+
"DELETE",
|
|
96
|
+
f"{self.base_endpoint}/{action_id}"
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
def clear_memory(
|
|
100
|
+
self,
|
|
101
|
+
action_id: int
|
|
102
|
+
):
|
|
103
|
+
return self._http_request(
|
|
104
|
+
"DELETE",
|
|
105
|
+
f"{self.base_endpoint}/{action_id}/clear_memory"
|
|
106
|
+
)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from tapi.client import Client
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ActionEventsAPI(Client):
|
|
6
|
+
def __init__(self, domain: str, apiKey: str):
|
|
7
|
+
super().__init__(domain, apiKey)
|
|
8
|
+
self.base_endpoint = "actions"
|
|
9
|
+
|
|
10
|
+
def list(
|
|
11
|
+
self,
|
|
12
|
+
action_id: Optional[int] = None,
|
|
13
|
+
since_id: Optional[int] = None,
|
|
14
|
+
until_id: Optional[int] = None,
|
|
15
|
+
per_page: int = 10,
|
|
16
|
+
page: int = 1
|
|
17
|
+
):
|
|
18
|
+
return self._http_request(
|
|
19
|
+
"GET",
|
|
20
|
+
f"{self.base_endpoint}/{action_id}/events",
|
|
21
|
+
params = {key: value for key, value in locals().items() if value is not None and key != "self"}
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
def delete(
|
|
25
|
+
self,
|
|
26
|
+
action_id: int,
|
|
27
|
+
async_deletion: bool = True
|
|
28
|
+
):
|
|
29
|
+
return self._http_request(
|
|
30
|
+
"DELETE",
|
|
31
|
+
f"{self.base_endpoint}/{action_id}/remove_events",
|
|
32
|
+
json = {"async_deletion": async_deletion}
|
|
33
|
+
)
|
tapi/api/action/logs.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from tapi.client import Client
|
|
2
|
+
from typing import Optional, Union
|
|
3
|
+
from tapi.utils.types import LogSeverityLevel
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ActionLogsAPI(Client):
|
|
7
|
+
def __init__(self, domain: str, apiKey: str):
|
|
8
|
+
super().__init__(domain, apiKey)
|
|
9
|
+
self.base_endpoint = "actions"
|
|
10
|
+
|
|
11
|
+
def list(
|
|
12
|
+
self,
|
|
13
|
+
action_id: int,
|
|
14
|
+
level: Optional[Union[LogSeverityLevel, str]] = None,
|
|
15
|
+
per_page: int = 10,
|
|
16
|
+
page: int = 1
|
|
17
|
+
):
|
|
18
|
+
return self._http_request(
|
|
19
|
+
"GET",
|
|
20
|
+
f"{self.base_endpoint}/{action_id}/logs",
|
|
21
|
+
params = {key: value for key, value in locals().items()
|
|
22
|
+
if value is not None and key not in ("self", "action_id")}
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
def delete(
|
|
26
|
+
self,
|
|
27
|
+
action_id: int,
|
|
28
|
+
async_deletion: bool = True
|
|
29
|
+
):
|
|
30
|
+
return self._http_request(
|
|
31
|
+
"DELETE",
|
|
32
|
+
f"{self.base_endpoint}/{action_id}/remove_logs",
|
|
33
|
+
json={"async_deletion": async_deletion}
|
|
34
|
+
)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from .job import JobsAPI
|
|
2
|
+
from .user import UsersAPI
|
|
3
|
+
from .admin import AdminAPI
|
|
4
|
+
from .template import TemplatesAPI
|
|
5
|
+
from .ip_access_control import IpAccessControlAPI
|
|
6
|
+
from .scim import SCIMUserGroupMappingAPI
|
|
7
|
+
from .action_egress_control_rules import ActionEgressControlRulesAPI
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"AdminAPI", "ActionEgressControlRulesAPI", "IpAccessControlAPI", "JobsAPI", "SCIMUserGroupMappingAPI",
|
|
11
|
+
"TemplatesAPI", "UsersAPI"
|
|
12
|
+
]
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
from tapi.client import Client
|
|
2
|
+
from tapi.utils.helpers import is_ip_valid
|
|
3
|
+
from typing import List, Optional, Literal, Union
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ActionEgressControlRulesAPI(Client):
|
|
7
|
+
def __init__(self, domain: str, apiKey: str):
|
|
8
|
+
super().__init__(domain, apiKey)
|
|
9
|
+
self.base_endpoint = "admin"
|
|
10
|
+
|
|
11
|
+
def create(
|
|
12
|
+
self,
|
|
13
|
+
ip: Optional[str] = None,
|
|
14
|
+
fqdn: Optional[str] = None,
|
|
15
|
+
description: str = "",
|
|
16
|
+
allowed_action_types: List[Literal["http-request", "send-email"]] = None
|
|
17
|
+
):
|
|
18
|
+
if ip and fqdn:
|
|
19
|
+
raise ValueError("Only IP or FQDN is allowed, not both.")
|
|
20
|
+
|
|
21
|
+
if not ip and not fqdn:
|
|
22
|
+
raise ValueError("Either IP or FQDN must be provided.")
|
|
23
|
+
|
|
24
|
+
if ip and not is_ip_valid(ip):
|
|
25
|
+
raise ValueError("Invalid IP address or CIDR range.")
|
|
26
|
+
|
|
27
|
+
return self._http_request(
|
|
28
|
+
"POST",
|
|
29
|
+
f"{self.base_endpoint}/action_egress_control_rules",
|
|
30
|
+
json = {key: value for key, value in locals().items() if value is not None and key != "self"}
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
def get(
|
|
34
|
+
self,
|
|
35
|
+
id: int
|
|
36
|
+
):
|
|
37
|
+
return self._http_request(
|
|
38
|
+
"GET",
|
|
39
|
+
f"{self.base_endpoint}/action_egress_control_rules/{id}"
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
def update(
|
|
43
|
+
self,
|
|
44
|
+
id: Union[str, int],
|
|
45
|
+
ip: Optional[str] = None,
|
|
46
|
+
fqdn: Optional[str] = None,
|
|
47
|
+
description: Optional[str] = None,
|
|
48
|
+
allowed_action_types: List[Literal["http-request", "send-email"]] = None
|
|
49
|
+
):
|
|
50
|
+
if ip and fqdn:
|
|
51
|
+
raise ValueError("Only IP or FQDN is allowed, not both.")
|
|
52
|
+
|
|
53
|
+
if not ip and not fqdn:
|
|
54
|
+
raise ValueError("Either IP or FQDN must be provided.")
|
|
55
|
+
|
|
56
|
+
if ip and not is_ip_valid(ip):
|
|
57
|
+
raise ValueError("Invalid IP address or CIDR range.")
|
|
58
|
+
|
|
59
|
+
return self._http_request(
|
|
60
|
+
"PUT",
|
|
61
|
+
f"{self.base_endpoint}/ip_access_control_rules/{id}",
|
|
62
|
+
json = {key: value for key, value in locals().items()
|
|
63
|
+
if value is not None and key not in ("self", "id")}
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
def list(
|
|
67
|
+
self,
|
|
68
|
+
per_page: int = 10,
|
|
69
|
+
page: int = 1,
|
|
70
|
+
):
|
|
71
|
+
return self._http_request(
|
|
72
|
+
"GET",
|
|
73
|
+
f"{self.base_endpoint}/action_egress_control_rules",
|
|
74
|
+
params = {
|
|
75
|
+
"per_page": per_page,
|
|
76
|
+
"page": page
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
def delete(
|
|
81
|
+
self,
|
|
82
|
+
id: Union[str, int]
|
|
83
|
+
):
|
|
84
|
+
return self._http_request(
|
|
85
|
+
"DELETE",
|
|
86
|
+
f"{self.base_endpoint}/action_egress_control_rules/{id}"
|
|
87
|
+
)
|
tapi/api/admin/admin.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from tapi.client import Client
|
|
2
|
+
from .job import JobsAPI
|
|
3
|
+
from .user import UsersAPI
|
|
4
|
+
from .template import TemplatesAPI
|
|
5
|
+
from .ip_access_control import IpAccessControlAPI
|
|
6
|
+
from .scim import SCIMUserGroupMappingAPI
|
|
7
|
+
from .action_egress_control_rules import ActionEgressControlRulesAPI
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class AdminAPI(Client):
|
|
11
|
+
def __init__(self, domain: str, apiKey: str):
|
|
12
|
+
super().__init__(domain, apiKey)
|
|
13
|
+
self.base_endpoint = "admin"
|
|
14
|
+
self.jobs = JobsAPI(domain, apiKey)
|
|
15
|
+
self.users = UsersAPI(domain, apiKey)
|
|
16
|
+
self.templates = TemplatesAPI(domain, apiKey)
|
|
17
|
+
self.ip_access_control = IpAccessControlAPI(domain, apiKey)
|
|
18
|
+
self.scim_user_group_mapping = SCIMUserGroupMappingAPI(domain, apiKey)
|
|
19
|
+
self.egress_rules = ActionEgressControlRulesAPI(domain, apiKey)
|
|
20
|
+
|
|
21
|
+
def set_custom_certificate_authority(
|
|
22
|
+
self,
|
|
23
|
+
name: str,
|
|
24
|
+
certificate: str
|
|
25
|
+
|
|
26
|
+
):
|
|
27
|
+
return self._http_request(
|
|
28
|
+
"PUT",
|
|
29
|
+
f"{self.base_endpoint}/custom_certificate_authority",
|
|
30
|
+
json = {
|
|
31
|
+
"name": name,
|
|
32
|
+
"certificate": certificate
|
|
33
|
+
}
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
def tunnel_health(
|
|
37
|
+
self,
|
|
38
|
+
tunnel_name: str
|
|
39
|
+
):
|
|
40
|
+
return self._http_request(
|
|
41
|
+
"GET",
|
|
42
|
+
f"{self.base_endpoint}/tunnel/{tunnel_name}/health"
|
|
43
|
+
)
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
from tapi.client import Client
|
|
2
|
+
from tapi.utils.helpers import is_ip_valid
|
|
3
|
+
from typing import Optional, Union
|
|
4
|
+
|
|
5
|
+
class IpAccessControlAPI(Client):
|
|
6
|
+
def __init__(self, domain: str, apiKey: str):
|
|
7
|
+
super().__init__(domain, apiKey)
|
|
8
|
+
self.base_endpoint = "admin"
|
|
9
|
+
|
|
10
|
+
def create(
|
|
11
|
+
self,
|
|
12
|
+
ip: str,
|
|
13
|
+
description: str
|
|
14
|
+
):
|
|
15
|
+
if not is_ip_valid(ip):
|
|
16
|
+
raise ValueError("Invalid IP address or CIDR range.")
|
|
17
|
+
|
|
18
|
+
return self._http_request(
|
|
19
|
+
"POST",
|
|
20
|
+
f"{self.base_endpoint}/ip_access_control_rules",
|
|
21
|
+
json = {
|
|
22
|
+
"ip": ip,
|
|
23
|
+
"description": description
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
def get(
|
|
28
|
+
self,
|
|
29
|
+
id: Union[str, int]
|
|
30
|
+
):
|
|
31
|
+
return self._http_request(
|
|
32
|
+
"GET",
|
|
33
|
+
f"{self.base_endpoint}/ip_access_control_rules/{id}"
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
def update(
|
|
37
|
+
self,
|
|
38
|
+
id: Union[str, int],
|
|
39
|
+
ip: str,
|
|
40
|
+
description: str
|
|
41
|
+
):
|
|
42
|
+
if not is_ip_valid(ip):
|
|
43
|
+
raise ValueError("Invalid IP address or CIDR range.")
|
|
44
|
+
|
|
45
|
+
return self._http_request(
|
|
46
|
+
"PUT",
|
|
47
|
+
f"{self.base_endpoint}/ip_access_control_rules/{id}",
|
|
48
|
+
json = {
|
|
49
|
+
"ip": ip,
|
|
50
|
+
"description": description
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
def list(
|
|
55
|
+
self,
|
|
56
|
+
matching_ip: Optional[str] = None,
|
|
57
|
+
per_page: int = 10,
|
|
58
|
+
page: int = 1
|
|
59
|
+
):
|
|
60
|
+
if matching_ip and not is_ip_valid(matching_ip):
|
|
61
|
+
raise ValueError("Invalid IP address or CIDR range.")
|
|
62
|
+
|
|
63
|
+
return self._http_request(
|
|
64
|
+
"GET",
|
|
65
|
+
f"{self.base_endpoint}/ip_access_control_rules",
|
|
66
|
+
params = {key: value for key, value in locals().items() if value is not None and key != "self"}
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
def delete(
|
|
70
|
+
self,
|
|
71
|
+
id: Union[str, int]
|
|
72
|
+
):
|
|
73
|
+
return self._http_request(
|
|
74
|
+
"DELETE",
|
|
75
|
+
f"{self.base_endpoint}/ip_access_control_rules/{id}"
|
|
76
|
+
)
|
tapi/api/admin/job.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from tapi.client import Client
|
|
2
|
+
from typing import Literal
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class JobsAPI(Client):
|
|
6
|
+
def __init__(self, domain: str, apiKey: str):
|
|
7
|
+
super().__init__(domain, apiKey)
|
|
8
|
+
self.base_endpoint = "admin"
|
|
9
|
+
|
|
10
|
+
def list(
|
|
11
|
+
self,
|
|
12
|
+
job_type: Literal["dead", "in_progress", "queued", "retry"],
|
|
13
|
+
per_page: int = 10,
|
|
14
|
+
page: int = 1
|
|
15
|
+
):
|
|
16
|
+
return self._http_request(
|
|
17
|
+
"GET",
|
|
18
|
+
f"{self.base_endpoint}/{job_type}_jobs",
|
|
19
|
+
params = {
|
|
20
|
+
"per_page": per_page,
|
|
21
|
+
"page": page
|
|
22
|
+
}
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
def delete(
|
|
26
|
+
self,
|
|
27
|
+
job_type: Literal["dead", "queued", "retry"]
|
|
28
|
+
):
|
|
29
|
+
return self._http_request(
|
|
30
|
+
"DELETE",
|
|
31
|
+
f"{self.base_endpoint}/delete_all_{job_type}_jobs"
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
def delete_by_action(
|
|
35
|
+
self,
|
|
36
|
+
action_id: int,
|
|
37
|
+
job_type: Literal["dead", "queued", "retry"]
|
|
38
|
+
):
|
|
39
|
+
return self._http_request(
|
|
40
|
+
"DELETE",
|
|
41
|
+
f"{self.base_endpoint}/actions/{action_id}/delete_all_{job_type}_jobs"
|
|
42
|
+
)
|
tapi/api/admin/scim.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from tapi.client import Client
|
|
2
|
+
from typing import Union, Dict
|
|
3
|
+
from tapi.utils.types import SCIMUserGroupMapping
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class SCIMUserGroupMappingAPI(Client):
|
|
7
|
+
def __init__(self, domain: str, apiKey: str):
|
|
8
|
+
super().__init__(domain, apiKey)
|
|
9
|
+
self.base_endpoint = "admin"
|
|
10
|
+
|
|
11
|
+
def list(self):
|
|
12
|
+
return self._http_request(
|
|
13
|
+
"GET",
|
|
14
|
+
f"{self.base_endpoint}/scim_user_group_mapping"
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
def update(
|
|
18
|
+
self,
|
|
19
|
+
mappings: Union[SCIMUserGroupMapping, Dict[str, str]]
|
|
20
|
+
):
|
|
21
|
+
return self._http_request(
|
|
22
|
+
"POST",
|
|
23
|
+
f"{self.base_endpoint}/scim_user_group_mapping",
|
|
24
|
+
json = {
|
|
25
|
+
"mappings": mappings
|
|
26
|
+
}
|
|
27
|
+
)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
from tapi.client import Client
|
|
2
|
+
from tapi.utils.types import AgentType
|
|
3
|
+
from typing import Union, Dict, Any
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class TemplatesAPI(Client):
|
|
7
|
+
def __init__(self, domain: str, apiKey: str):
|
|
8
|
+
super().__init__(domain, apiKey)
|
|
9
|
+
self.base_endpoint = "admin"
|
|
10
|
+
|
|
11
|
+
def create(
|
|
12
|
+
self,
|
|
13
|
+
name: str,
|
|
14
|
+
description: str,
|
|
15
|
+
vendor: str,
|
|
16
|
+
product: str,
|
|
17
|
+
agent_type: Union[AgentType, str],
|
|
18
|
+
agent_options: Dict[str, Any]
|
|
19
|
+
):
|
|
20
|
+
return self._http_request(
|
|
21
|
+
"POST",
|
|
22
|
+
f"{self.base_endpoint}/templates",
|
|
23
|
+
json = {
|
|
24
|
+
"name": name,
|
|
25
|
+
"description": description,
|
|
26
|
+
"vendor": vendor,
|
|
27
|
+
"product": product,
|
|
28
|
+
"agent_type": agent_type,
|
|
29
|
+
"agent_options": agent_options
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
def get(
|
|
34
|
+
self,
|
|
35
|
+
template_id: int
|
|
36
|
+
):
|
|
37
|
+
return self._http_request(
|
|
38
|
+
"GET",
|
|
39
|
+
f"{self.base_endpoint}/templates/{template_id}"
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
def update(
|
|
43
|
+
self,
|
|
44
|
+
template_id: int,
|
|
45
|
+
name: str,
|
|
46
|
+
description: str,
|
|
47
|
+
vendor: str,
|
|
48
|
+
product: str,
|
|
49
|
+
agent_type: Union[AgentType, str],
|
|
50
|
+
agent_options: Dict[str, Any]
|
|
51
|
+
):
|
|
52
|
+
return self._http_request(
|
|
53
|
+
"PUT",
|
|
54
|
+
f"{self.base_endpoint}/templates/{template_id}",
|
|
55
|
+
json = {
|
|
56
|
+
"name": name,
|
|
57
|
+
"description": description,
|
|
58
|
+
"vendor": vendor,
|
|
59
|
+
"product": product,
|
|
60
|
+
"agent_type": agent_type,
|
|
61
|
+
"agent_options": agent_options
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
def list(
|
|
66
|
+
self,
|
|
67
|
+
per_page: int = 10,
|
|
68
|
+
page: int = 1
|
|
69
|
+
):
|
|
70
|
+
return self._http_request(
|
|
71
|
+
"GET",
|
|
72
|
+
f"{self.base_endpoint}/templates",
|
|
73
|
+
params = {
|
|
74
|
+
"per_page": per_page,
|
|
75
|
+
"page": page
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
def delete(
|
|
80
|
+
self,
|
|
81
|
+
template_id: int
|
|
82
|
+
):
|
|
83
|
+
return self._http_request(
|
|
84
|
+
"DELETE",
|
|
85
|
+
f"{self.base_endpoint}/templates/{template_id}"
|
|
86
|
+
)
|