openrelik-api-client 0.2.0__tar.gz → 0.2.1__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: openrelik-api-client
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: API client that automatically handles token refresh
5
5
  Author: Johan Berggren
6
6
  Author-email: jberggren@gmail.com
@@ -0,0 +1,11 @@
1
+ from folders import FoldersAPI
2
+
3
+
4
+ def main():
5
+ c = FoldersAPI("http://172.19.0.6:8710", api_key="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJmZThmMjkyYWViZDM0MjA3YjkyODYxOGQ5MmRmZThkMSIsImlhdCI6MTczNDQ0NzcyOSwibmJmIjoxNzM0NDQ3NzI5LCJleHAiOjE3MzUwNTI1MjksImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6ODcxMCIsImF1ZCI6ImFwaS1jbGllbnQiLCJqdGkiOiI2ZWZhNzBiYWU0ZDE0MjJlOGM4ODY5OGY1NDhmOTBjYiIsInRva2VuX3R5cGUiOiJyZWZyZXNoIn0.MJA48D570agD49oE4HXfTWCQRpyh5JCy7YCIsHN5YJs")
6
+ # r = c.create_root_folder("myfolder")
7
+ # r = c.create_subfolder(33, 'myfolder_sub')
8
+ print(c.folder_exists(1))
9
+
10
+
11
+ main()
@@ -21,6 +21,7 @@ class WorkflowsAPI:
21
21
  def __init__(self, api_client: APIClient):
22
22
  super().__init__()
23
23
  self.api_client = api_client
24
+ self.folders_url = f"{self.api_client.base_url}/folders"
24
25
 
25
26
  def create_workflow(
26
27
  self, folder_id: int, file_ids: list, template_id: int = None) -> int | None:
@@ -38,7 +39,7 @@ class WorkflowsAPI:
38
39
  HTTPError: If the API request failed.
39
40
  """
40
41
  workflow_id = None
41
- endpoint = f"{self.api_client.base_url}/folders/{folder_id}/workflows/"
42
+ endpoint = f"{self.folders_url}/{folder_id}/workflows/"
42
43
  data = {"folder_id": folder_id,
43
44
  "file_ids": file_ids, "template_id": template_id}
44
45
  response = self.api_client.session.post(endpoint, json=data)
@@ -60,8 +61,7 @@ class WorkflowsAPI:
60
61
  Raises:
61
62
  HTTPError: If the API request failed.
62
63
  """
63
- endpoint = f"{
64
- self.api_client.base_url}/folders/{folder_id}/workflows/{workflow_id}"
64
+ endpoint = f"{self.folders_url}/{folder_id}/workflows/{workflow_id}"
65
65
  response = self.api_client.session.get(endpoint)
66
66
  response.raise_for_status()
67
67
  if response.status_code == 200:
@@ -82,8 +82,7 @@ class WorkflowsAPI:
82
82
  HTTPError: If the API request failed.
83
83
  """
84
84
  workflow = None
85
- endpoint = f"{
86
- self.api_client.base_url}/folders/{folder_id}/workflows/{workflow_id}"
85
+ endpoint = f"{self.folders_url}/{folder_id}/workflows/{workflow_id}"
87
86
  response = self.api_client.session.patch(endpoint, json=workflow_data)
88
87
  response.raise_for_status()
89
88
  if response.status_code == 200:
@@ -103,8 +102,7 @@ class WorkflowsAPI:
103
102
  Raises:
104
103
  HTTPError: If the API request failed.
105
104
  """
106
- endpoint = f"{
107
- self.api_client.base_url}/folders/{folder_id}/workflows/{workflow_id}"
105
+ endpoint = f"{self.folders_url}/{folder_id}/workflows/{workflow_id}"
108
106
  response = self.api_client.session.delete(endpoint)
109
107
  response.raise_for_status()
110
108
  return response.status_code == 204
@@ -124,8 +122,8 @@ class WorkflowsAPI:
124
122
  HTTPError: If the API request failed.
125
123
  """
126
124
  workflow = None
127
- endpoint = f"{
128
- self.api_client.base_url}/folders/{folder_id}/workflows/{workflow_id}/run/"
125
+ endpoint = (
126
+ f"{self.folders_url}/{folder_id}/workflows/{workflow_id}/run/")
129
127
  workflow = self.get_workflow(folder_id, workflow_id)
130
128
  spec = json.loads(workflow.get('spec_json'))
131
129
  data = {'workflow_spec': spec}
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "openrelik-api-client"
3
- version = "0.2.0"
3
+ version = "0.2.1"
4
4
  description = "API client that automatically handles token refresh"
5
5
  authors = ["Johan Berggren <jberggren@gmail.com>"]
6
6
  readme = "README.md"