datagrok-api 0.0.4__tar.gz → 0.0.5__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.
- datagrok_api-0.0.5/PKG-INFO +170 -0
- datagrok_api-0.0.5/README.md +149 -0
- {datagrok_api-0.0.4 → datagrok_api-0.0.5}/datagrok_api/datagrok_client.py +148 -0
- datagrok_api-0.0.5/example.py +121 -0
- {datagrok_api-0.0.4 → datagrok_api-0.0.5}/pyproject.toml +15 -1
- datagrok_api-0.0.4/PKG-INFO +0 -76
- datagrok_api-0.0.4/README.md +0 -63
- datagrok_api-0.0.4/example.py +0 -51
- datagrok_api-0.0.4/openapi.yaml +0 -524
- datagrok_api-0.0.4/requirements.txt +0 -0
- {datagrok_api-0.0.4 → datagrok_api-0.0.5}/.gitignore +0 -0
- {datagrok_api-0.0.4 → datagrok_api-0.0.5}/datagrok_api/__init__.py +0 -0
- {datagrok_api-0.0.4 → datagrok_api-0.0.5}/datagrok_api/group.py +0 -0
- {datagrok_api-0.0.4 → datagrok_api-0.0.5}/datagrok_api/model.py +0 -0
- {datagrok_api-0.0.4 → datagrok_api-0.0.5}/tests/test_datagrok_client.py +0 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: datagrok-api
|
|
3
|
+
Version: 0.0.5
|
|
4
|
+
Summary: Client library for integration with datagrok API
|
|
5
|
+
Project-URL: Homepage, https://github.com/datagrok-ai/public
|
|
6
|
+
Project-URL: Issues, https://github.com/datagrok-ai/public/issues
|
|
7
|
+
Author-email: Andrew Skalkin <askalkin@datagrok.ai>, Amelichev Konstantin <kamelichev@datagrok.ai>
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Requires-Python: >=3.5
|
|
12
|
+
Requires-Dist: pandas
|
|
13
|
+
Requires-Dist: requests
|
|
14
|
+
Requires-Dist: requests-toolbelt
|
|
15
|
+
Provides-Extra: test
|
|
16
|
+
Requires-Dist: data-to-xml; extra == 'test'
|
|
17
|
+
Requires-Dist: pytest; extra == 'test'
|
|
18
|
+
Requires-Dist: pytest-item-dict; extra == 'test'
|
|
19
|
+
Requires-Dist: pytest-xml; extra == 'test'
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# Datagrok python client library
|
|
23
|
+
|
|
24
|
+
This library can be used for integration with datagrok. It is a python wrapper for public API, that has OpenAPI specification available [here](http://public.datagrok.ai/api/public/api.yaml).
|
|
25
|
+
|
|
26
|
+
Refer to [Help](http://datagrok.ai/help) for more information.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
To install package, use [pip](https://pypi.org/project/pip/).
|
|
31
|
+
|
|
32
|
+
```shell
|
|
33
|
+
pip install datagrok-api
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
To use API client, import DatagrokClient to your project:
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from datagrok_api import DatagrokClient
|
|
42
|
+
|
|
43
|
+
api = DatagrokClient('your token', 'datagrok url')
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## License
|
|
47
|
+
|
|
48
|
+
See [License.md](https://github.com/datagrok-ai/public/blob/master/LICENSE.md).
|
|
49
|
+
|
|
50
|
+
## Examples
|
|
51
|
+
|
|
52
|
+
The package uses Pandas for representation of tables and dataframes.
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
import pandas as pd
|
|
56
|
+
from sklearn.datasets import load_iris
|
|
57
|
+
|
|
58
|
+
# Calls a Datagrok function
|
|
59
|
+
# Dataframes, columns and primitive data types are supported
|
|
60
|
+
api.call_function('Abs', {
|
|
61
|
+
'x': -3
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
# Downloads file from a given connection
|
|
65
|
+
res = api.download_file('system.demofiles', 'demog.csv')
|
|
66
|
+
print(res.head())
|
|
67
|
+
|
|
68
|
+
# Uploads iris dataset as a table
|
|
69
|
+
iris_id = api.upload_table('iris', pd.DataFrame(load_iris()['data']))['ID']
|
|
70
|
+
|
|
71
|
+
# Iris also can be uploaded as a file
|
|
72
|
+
# api.upload_file('system.demofiles', 'iris.csv', 'iris.csv')
|
|
73
|
+
|
|
74
|
+
# Fetches freshly uploaded Iris table
|
|
75
|
+
res = api.download_table(iris_id)
|
|
76
|
+
print(res.head())
|
|
77
|
+
|
|
78
|
+
# Creates dashboard from iris table with layout uploaded from file "iris.layout"
|
|
79
|
+
dashboard_id = api.create_dashboard('python-test', iris_id, layout_filename='iris.layout')['ID']
|
|
80
|
+
|
|
81
|
+
# Shares dashboard with admin
|
|
82
|
+
api.share_dashboard(dashboard_id, 'Test')
|
|
83
|
+
|
|
84
|
+
# Group Management Examples
|
|
85
|
+
|
|
86
|
+
# List all groups (excluding personal groups)
|
|
87
|
+
groups = api.list_groups(include_personal=False)
|
|
88
|
+
print("All groups:", [group.friendly_name for group in groups])
|
|
89
|
+
|
|
90
|
+
# List groups with members and memberships
|
|
91
|
+
groups_with_details = api.list_groups(
|
|
92
|
+
include_personal=False,
|
|
93
|
+
include_members=True,
|
|
94
|
+
include_memberships=True
|
|
95
|
+
)
|
|
96
|
+
for group in groups_with_details:
|
|
97
|
+
print(f"Group: {group.friendly_name}")
|
|
98
|
+
print(f"Members: {[m.friendly_name for m in group.members]}")
|
|
99
|
+
print(f"Memberships: {[m.friendly_name for m in group.memberships]}")
|
|
100
|
+
|
|
101
|
+
# Search for specific groups
|
|
102
|
+
dev_groups = api.lookup_groups("Dev")
|
|
103
|
+
print("Development groups:", [group.friendly_name for group in dev_groups])
|
|
104
|
+
|
|
105
|
+
# Get current user's group
|
|
106
|
+
current_user_group = api.get_current_user_group()
|
|
107
|
+
print("Current user's group:", current_user_group.friendly_name)
|
|
108
|
+
|
|
109
|
+
# Create a new group
|
|
110
|
+
new_group = Group(friendly_name="Data Science Team", description="Team working on ML projects")
|
|
111
|
+
created_group = api.save_group(new_group)
|
|
112
|
+
print("Created group:", created_group.friendly_name)
|
|
113
|
+
|
|
114
|
+
# Get group members
|
|
115
|
+
group_members = api.get_group_members(created_group.id)
|
|
116
|
+
print(f"Members of {created_group.friendly_name}:", [m.friendly_name for m in group_members])
|
|
117
|
+
|
|
118
|
+
# Get group memberships
|
|
119
|
+
group_memberships = api.get_group_memberships(created_group.id)
|
|
120
|
+
print(f"Memberships of {created_group.friendly_name}:", [m.friendly_name for m in group_memberships])
|
|
121
|
+
|
|
122
|
+
# Request membership in a group
|
|
123
|
+
request = api.request_group_membership(created_group.id)
|
|
124
|
+
print("Membership request created:", request.id)
|
|
125
|
+
|
|
126
|
+
# Get membership requests (as group admin)
|
|
127
|
+
requests = api.get_group_membership_requests(created_group.id)
|
|
128
|
+
for req in requests:
|
|
129
|
+
print(f"Request from {req.from_group.friendly_name}: {'Approved' if req.is_approved else 'Pending'}")
|
|
130
|
+
|
|
131
|
+
# Approve or deny requests (as group admin)
|
|
132
|
+
if requests:
|
|
133
|
+
if requests[0].from_group.friendly_name == "John Doe" and not requests[0].is_viewed:
|
|
134
|
+
api.approve_membership_request(requests[0].id)
|
|
135
|
+
else:
|
|
136
|
+
api.deny_membership_request(requests[0].id)
|
|
137
|
+
|
|
138
|
+
# Update group information
|
|
139
|
+
created_group.description = "Updated description for Data Science Team"
|
|
140
|
+
updated_group = api.save_group(created_group, save_relations=True)
|
|
141
|
+
print("Updated group:", updated_group.friendly_name, updated_group.description)
|
|
142
|
+
|
|
143
|
+
# Add Member Examples
|
|
144
|
+
|
|
145
|
+
# Find John Doe's personal group
|
|
146
|
+
john_doe_groups = api.lookup_groups("John Doe")
|
|
147
|
+
john_doe_group = next((g for g in john_doe_groups if g.personal), None)
|
|
148
|
+
if john_doe_group:
|
|
149
|
+
print(f"Found John Doe's personal group: {john_doe_group.friendly_name}")
|
|
150
|
+
|
|
151
|
+
# Add John Doe as regular member
|
|
152
|
+
created_group.add_member(john_doe_group)
|
|
153
|
+
print(f"Added {john_doe_group.friendly_name} as regular member to {created_group.friendly_name}")
|
|
154
|
+
|
|
155
|
+
# Verify the member was added
|
|
156
|
+
updated_group = api.get_group(created_group.id)
|
|
157
|
+
print(f"Members after adding: {[m.friendly_name for m in updated_group.members]}")
|
|
158
|
+
|
|
159
|
+
# Add John Doe as admin
|
|
160
|
+
created_group.add_member(john_doe_group, is_admin=True)
|
|
161
|
+
print(f"Added {john_doe_group.friendly_name} as admin to {created_group.friendly_name}")
|
|
162
|
+
|
|
163
|
+
# Verify the admin member was added
|
|
164
|
+
updated_group = api.get_group(created_group.id)
|
|
165
|
+
print(f"Admin members: {[m.friendly_name for m in updated_group.admin_members]}")
|
|
166
|
+
print(f"All members: {[m.friendly_name for m in updated_group.members]}")
|
|
167
|
+
else:
|
|
168
|
+
print("John Doe's personal group not found")
|
|
169
|
+
|
|
170
|
+
```
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Datagrok python client library
|
|
2
|
+
|
|
3
|
+
This library can be used for integration with datagrok. It is a python wrapper for public API, that has OpenAPI specification available [here](http://public.datagrok.ai/api/public/api.yaml).
|
|
4
|
+
|
|
5
|
+
Refer to [Help](http://datagrok.ai/help) for more information.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
To install package, use [pip](https://pypi.org/project/pip/).
|
|
10
|
+
|
|
11
|
+
```shell
|
|
12
|
+
pip install datagrok-api
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
To use API client, import DatagrokClient to your project:
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from datagrok_api import DatagrokClient
|
|
21
|
+
|
|
22
|
+
api = DatagrokClient('your token', 'datagrok url')
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## License
|
|
26
|
+
|
|
27
|
+
See [License.md](https://github.com/datagrok-ai/public/blob/master/LICENSE.md).
|
|
28
|
+
|
|
29
|
+
## Examples
|
|
30
|
+
|
|
31
|
+
The package uses Pandas for representation of tables and dataframes.
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
import pandas as pd
|
|
35
|
+
from sklearn.datasets import load_iris
|
|
36
|
+
|
|
37
|
+
# Calls a Datagrok function
|
|
38
|
+
# Dataframes, columns and primitive data types are supported
|
|
39
|
+
api.call_function('Abs', {
|
|
40
|
+
'x': -3
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
# Downloads file from a given connection
|
|
44
|
+
res = api.download_file('system.demofiles', 'demog.csv')
|
|
45
|
+
print(res.head())
|
|
46
|
+
|
|
47
|
+
# Uploads iris dataset as a table
|
|
48
|
+
iris_id = api.upload_table('iris', pd.DataFrame(load_iris()['data']))['ID']
|
|
49
|
+
|
|
50
|
+
# Iris also can be uploaded as a file
|
|
51
|
+
# api.upload_file('system.demofiles', 'iris.csv', 'iris.csv')
|
|
52
|
+
|
|
53
|
+
# Fetches freshly uploaded Iris table
|
|
54
|
+
res = api.download_table(iris_id)
|
|
55
|
+
print(res.head())
|
|
56
|
+
|
|
57
|
+
# Creates dashboard from iris table with layout uploaded from file "iris.layout"
|
|
58
|
+
dashboard_id = api.create_dashboard('python-test', iris_id, layout_filename='iris.layout')['ID']
|
|
59
|
+
|
|
60
|
+
# Shares dashboard with admin
|
|
61
|
+
api.share_dashboard(dashboard_id, 'Test')
|
|
62
|
+
|
|
63
|
+
# Group Management Examples
|
|
64
|
+
|
|
65
|
+
# List all groups (excluding personal groups)
|
|
66
|
+
groups = api.list_groups(include_personal=False)
|
|
67
|
+
print("All groups:", [group.friendly_name for group in groups])
|
|
68
|
+
|
|
69
|
+
# List groups with members and memberships
|
|
70
|
+
groups_with_details = api.list_groups(
|
|
71
|
+
include_personal=False,
|
|
72
|
+
include_members=True,
|
|
73
|
+
include_memberships=True
|
|
74
|
+
)
|
|
75
|
+
for group in groups_with_details:
|
|
76
|
+
print(f"Group: {group.friendly_name}")
|
|
77
|
+
print(f"Members: {[m.friendly_name for m in group.members]}")
|
|
78
|
+
print(f"Memberships: {[m.friendly_name for m in group.memberships]}")
|
|
79
|
+
|
|
80
|
+
# Search for specific groups
|
|
81
|
+
dev_groups = api.lookup_groups("Dev")
|
|
82
|
+
print("Development groups:", [group.friendly_name for group in dev_groups])
|
|
83
|
+
|
|
84
|
+
# Get current user's group
|
|
85
|
+
current_user_group = api.get_current_user_group()
|
|
86
|
+
print("Current user's group:", current_user_group.friendly_name)
|
|
87
|
+
|
|
88
|
+
# Create a new group
|
|
89
|
+
new_group = Group(friendly_name="Data Science Team", description="Team working on ML projects")
|
|
90
|
+
created_group = api.save_group(new_group)
|
|
91
|
+
print("Created group:", created_group.friendly_name)
|
|
92
|
+
|
|
93
|
+
# Get group members
|
|
94
|
+
group_members = api.get_group_members(created_group.id)
|
|
95
|
+
print(f"Members of {created_group.friendly_name}:", [m.friendly_name for m in group_members])
|
|
96
|
+
|
|
97
|
+
# Get group memberships
|
|
98
|
+
group_memberships = api.get_group_memberships(created_group.id)
|
|
99
|
+
print(f"Memberships of {created_group.friendly_name}:", [m.friendly_name for m in group_memberships])
|
|
100
|
+
|
|
101
|
+
# Request membership in a group
|
|
102
|
+
request = api.request_group_membership(created_group.id)
|
|
103
|
+
print("Membership request created:", request.id)
|
|
104
|
+
|
|
105
|
+
# Get membership requests (as group admin)
|
|
106
|
+
requests = api.get_group_membership_requests(created_group.id)
|
|
107
|
+
for req in requests:
|
|
108
|
+
print(f"Request from {req.from_group.friendly_name}: {'Approved' if req.is_approved else 'Pending'}")
|
|
109
|
+
|
|
110
|
+
# Approve or deny requests (as group admin)
|
|
111
|
+
if requests:
|
|
112
|
+
if requests[0].from_group.friendly_name == "John Doe" and not requests[0].is_viewed:
|
|
113
|
+
api.approve_membership_request(requests[0].id)
|
|
114
|
+
else:
|
|
115
|
+
api.deny_membership_request(requests[0].id)
|
|
116
|
+
|
|
117
|
+
# Update group information
|
|
118
|
+
created_group.description = "Updated description for Data Science Team"
|
|
119
|
+
updated_group = api.save_group(created_group, save_relations=True)
|
|
120
|
+
print("Updated group:", updated_group.friendly_name, updated_group.description)
|
|
121
|
+
|
|
122
|
+
# Add Member Examples
|
|
123
|
+
|
|
124
|
+
# Find John Doe's personal group
|
|
125
|
+
john_doe_groups = api.lookup_groups("John Doe")
|
|
126
|
+
john_doe_group = next((g for g in john_doe_groups if g.personal), None)
|
|
127
|
+
if john_doe_group:
|
|
128
|
+
print(f"Found John Doe's personal group: {john_doe_group.friendly_name}")
|
|
129
|
+
|
|
130
|
+
# Add John Doe as regular member
|
|
131
|
+
created_group.add_member(john_doe_group)
|
|
132
|
+
print(f"Added {john_doe_group.friendly_name} as regular member to {created_group.friendly_name}")
|
|
133
|
+
|
|
134
|
+
# Verify the member was added
|
|
135
|
+
updated_group = api.get_group(created_group.id)
|
|
136
|
+
print(f"Members after adding: {[m.friendly_name for m in updated_group.members]}")
|
|
137
|
+
|
|
138
|
+
# Add John Doe as admin
|
|
139
|
+
created_group.add_member(john_doe_group, is_admin=True)
|
|
140
|
+
print(f"Added {john_doe_group.friendly_name} as admin to {created_group.friendly_name}")
|
|
141
|
+
|
|
142
|
+
# Verify the admin member was added
|
|
143
|
+
updated_group = api.get_group(created_group.id)
|
|
144
|
+
print(f"Admin members: {[m.friendly_name for m in updated_group.admin_members]}")
|
|
145
|
+
print(f"All members: {[m.friendly_name for m in updated_group.members]}")
|
|
146
|
+
else:
|
|
147
|
+
print("John Doe's personal group not found")
|
|
148
|
+
|
|
149
|
+
```
|
|
@@ -3,6 +3,11 @@ import requests
|
|
|
3
3
|
import pandas as pd
|
|
4
4
|
import json
|
|
5
5
|
from io import StringIO
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
import json
|
|
8
|
+
from requests_toolbelt.multipart import decoder
|
|
9
|
+
import os
|
|
10
|
+
import shutil
|
|
6
11
|
|
|
7
12
|
from .group import Group, GroupMembershipRequest
|
|
8
13
|
|
|
@@ -115,6 +120,125 @@ class DatagrokClient:
|
|
|
115
120
|
with open(file_path, 'rb') as file:
|
|
116
121
|
self._request('POST', endpoint, content_type="application/octet-stream", data=file)
|
|
117
122
|
|
|
123
|
+
def sync_dir(self, connector: str, remote_path: str, dir: str, ext: str = None, recursive: bool = True, sync_meta_file: str = ".sync_meta.json") -> None:
|
|
124
|
+
"""
|
|
125
|
+
Syncs the content of a local directory with a remote directory on a server, updating local files and metadata based on the response.
|
|
126
|
+
|
|
127
|
+
This method compares the current state of the local directory with the remote directory and updates files based on their
|
|
128
|
+
modified status or whether they have been deleted. It uses a provided connector to connect to a remote service and syncs the
|
|
129
|
+
data, storing metadata about file versions and deletions in a `.sync_meta.json` file. If a file has been deleted on the server,
|
|
130
|
+
it will also be deleted locally.
|
|
131
|
+
|
|
132
|
+
Parameters
|
|
133
|
+
----------
|
|
134
|
+
connector: str
|
|
135
|
+
Identifier of a connector: ID or Grok name.
|
|
136
|
+
|
|
137
|
+
remote_path: str
|
|
138
|
+
The path on the server connection to sync with. Should be directory
|
|
139
|
+
|
|
140
|
+
dir: str
|
|
141
|
+
The local directory to sync. If the directory doesn't exist, it will be created.
|
|
142
|
+
|
|
143
|
+
ext: str, optional
|
|
144
|
+
A file extension filter to limit the types of files to sync. If not specified, all files are synced.
|
|
145
|
+
|
|
146
|
+
recursive: bool, optional, default=True
|
|
147
|
+
Whether to sync the directory recursively, including subdirectories. If False, only files in the root of the directory are synced.
|
|
148
|
+
|
|
149
|
+
sync_meta_file: str, optional, default=".sync_meta.json"
|
|
150
|
+
The name of the metadata file that stores the eTags and sync information for the files. This file is used to track the current
|
|
151
|
+
state of the local directory and should be present for syncing to work correctly.
|
|
152
|
+
|
|
153
|
+
Raises
|
|
154
|
+
------
|
|
155
|
+
Exception
|
|
156
|
+
If the server response does not contain a multipart body when expected.
|
|
157
|
+
|
|
158
|
+
Notes
|
|
159
|
+
-----
|
|
160
|
+
- If the server returns a `204 No Content` response, it indicates the folder is empty on the remote, so the local directory
|
|
161
|
+
will be cleared and the sync metadata will be updated accordingly.
|
|
162
|
+
- If a file is marked as "deleted" on the remote server, it will be removed from the local directory.
|
|
163
|
+
- The function uses multipart responses for efficient file transfer and parsing of updates.
|
|
164
|
+
"""
|
|
165
|
+
os.makedirs(dir, exist_ok=True)
|
|
166
|
+
sync_meta_file_path = Path(dir, sync_meta_file)
|
|
167
|
+
sync_meta_dict = {}
|
|
168
|
+
if sync_meta_file_path.exists():
|
|
169
|
+
with open(sync_meta_file_path, "r", encoding="utf-8") as f:
|
|
170
|
+
content = f.read()
|
|
171
|
+
sync_meta_dict = json.loads(content)
|
|
172
|
+
|
|
173
|
+
existed = self._list_files_unix_style(dir, {sync_meta_file})
|
|
174
|
+
for key in list(sync_meta_dict.keys()):
|
|
175
|
+
if key not in existed:
|
|
176
|
+
del sync_meta_dict[key]
|
|
177
|
+
|
|
178
|
+
if remote_path.startswith('/'):
|
|
179
|
+
remote_path = remote_path[1:]
|
|
180
|
+
|
|
181
|
+
connector = connector.replace(':', '.')
|
|
182
|
+
endpoint = f"/public/v1/files/sync/{connector}/{remote_path}"
|
|
183
|
+
params = {'recursive': str(recursive).lower()}
|
|
184
|
+
if ext:
|
|
185
|
+
params['ext'] = ext
|
|
186
|
+
|
|
187
|
+
response = self._request('POST', endpoint, content_type="application/json", params=params, json=sync_meta_dict)
|
|
188
|
+
|
|
189
|
+
def update_sync_meta(content: dict):
|
|
190
|
+
with open (sync_meta_file_path, "w") as f:
|
|
191
|
+
f.write(json.dumps(content))
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
# remote_path is empty folder
|
|
195
|
+
if response.status_code == 204:
|
|
196
|
+
self._clear_directory(dir)
|
|
197
|
+
update_sync_meta({})
|
|
198
|
+
return
|
|
199
|
+
|
|
200
|
+
if not response.headers.get('Content-Type', '').startswith('multipart/'):
|
|
201
|
+
raise Exception(f'Incorrect response type. Expected multipart but received {response.headers.get('Content-Type', '')}')
|
|
202
|
+
|
|
203
|
+
multipart_data = decoder.MultipartDecoder.from_response(response)
|
|
204
|
+
|
|
205
|
+
deleted_files = set()
|
|
206
|
+
|
|
207
|
+
for i, part in enumerate(multipart_data.parts):
|
|
208
|
+
content_disposition = part.headers.get(b'Content-Disposition', b'').decode()
|
|
209
|
+
filename = f"part_{i}"
|
|
210
|
+
if "filename=" in content_disposition:
|
|
211
|
+
filename = content_disposition.split("filename=")[1].strip('"')
|
|
212
|
+
|
|
213
|
+
status_bytes = part.headers.get(b'X-File-Status')
|
|
214
|
+
status = status_bytes.decode('utf-8') if status_bytes else None
|
|
215
|
+
|
|
216
|
+
if status == "deleted":
|
|
217
|
+
deleted_files.add(filename)
|
|
218
|
+
continue
|
|
219
|
+
elif status == "not-modified":
|
|
220
|
+
continue
|
|
221
|
+
|
|
222
|
+
full_filepath = os.path.join(dir, filename.replace('/', os.sep))
|
|
223
|
+
os.makedirs(os.path.dirname(full_filepath), exist_ok=True)
|
|
224
|
+
|
|
225
|
+
with open(full_filepath, "wb") as f:
|
|
226
|
+
f.write(part.content)
|
|
227
|
+
|
|
228
|
+
e_tag = part.headers.get(b'X-File-E-Tag')
|
|
229
|
+
if e_tag:
|
|
230
|
+
sync_meta_dict[filename] = e_tag.decode('utf-8')
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
for filename in deleted_files:
|
|
234
|
+
del sync_meta_dict[filename]
|
|
235
|
+
full_filepath = Path(dir, filename.replace('/', os.sep))
|
|
236
|
+
if full_filepath.exists():
|
|
237
|
+
full_filepath.unlink()
|
|
238
|
+
|
|
239
|
+
update_sync_meta(sync_meta_dict)
|
|
240
|
+
|
|
241
|
+
|
|
118
242
|
def share_dashboard(self, id: str, groups: str, access: str = "View") -> None:
|
|
119
243
|
'''
|
|
120
244
|
Shares a dashboard.
|
|
@@ -450,3 +574,27 @@ class DatagrokClient:
|
|
|
450
574
|
else:
|
|
451
575
|
raise Exception("Something went wrong during request")
|
|
452
576
|
return response
|
|
577
|
+
|
|
578
|
+
def _list_files_unix_style(self, root_dir: str, excludes: set = None) -> list[str]:
|
|
579
|
+
root = Path(root_dir)
|
|
580
|
+
|
|
581
|
+
if excludes is None:
|
|
582
|
+
excludes = set()
|
|
583
|
+
|
|
584
|
+
files = []
|
|
585
|
+
for path in root.rglob('*'):
|
|
586
|
+
if path.is_file():
|
|
587
|
+
relative_path = path.relative_to(root).as_posix()
|
|
588
|
+
if relative_path not in excludes:
|
|
589
|
+
files.append(relative_path)
|
|
590
|
+
|
|
591
|
+
return files
|
|
592
|
+
|
|
593
|
+
def _clear_directory(self, path: str):
|
|
594
|
+
dir_path = Path(path)
|
|
595
|
+
for item in dir_path.iterdir():
|
|
596
|
+
if item.is_file() or item.is_symlink():
|
|
597
|
+
item.unlink()
|
|
598
|
+
elif item.is_dir():
|
|
599
|
+
shutil.rmtree(item)
|
|
600
|
+
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
from datagrok_api import DatagrokClient
|
|
2
|
+
from datagrok_api.group import Group
|
|
3
|
+
|
|
4
|
+
import pandas as pd
|
|
5
|
+
from sklearn.datasets import load_iris
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
api = DatagrokClient('YOUR_TOKEN', 'API_URL')
|
|
9
|
+
|
|
10
|
+
# Calls a Datagrok function
|
|
11
|
+
# Dataframes, columns and primitive data types are supported
|
|
12
|
+
api.call_function('Abs', {
|
|
13
|
+
'x': -3
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
# Downloads file from a given connection
|
|
17
|
+
res = api.download_file('system.demofiles', 'demog.csv')
|
|
18
|
+
print(res.head())
|
|
19
|
+
|
|
20
|
+
# Uploads iris dataset as a table
|
|
21
|
+
iris_id = api.upload_table('iris', pd.DataFrame(load_iris()['data']))['ID']
|
|
22
|
+
|
|
23
|
+
# Iris also can be uploaded as a file
|
|
24
|
+
# api.upload_file('system.demofiles', 'iris.csv', 'iris.csv')
|
|
25
|
+
|
|
26
|
+
# Fetches freshly uploaded Iris table
|
|
27
|
+
res = api.download_table(iris_id)
|
|
28
|
+
print(res.head())
|
|
29
|
+
|
|
30
|
+
# Creates dashboard from iris table with layout uploaded from file "iris.layout"
|
|
31
|
+
dashboard_id = api.create_dashboard('python-test', iris_id, layout_filename='iris.layout')['ID']
|
|
32
|
+
|
|
33
|
+
# Shares dashboard with admin
|
|
34
|
+
api.share_dashboard(dashboard_id, 'Test')
|
|
35
|
+
|
|
36
|
+
# Group Management Examples
|
|
37
|
+
|
|
38
|
+
# List all groups (excluding personal groups)
|
|
39
|
+
groups = api.list_groups(include_personal=False)
|
|
40
|
+
print("All groups:", [group.friendly_name for group in groups])
|
|
41
|
+
|
|
42
|
+
# List groups with members and memberships
|
|
43
|
+
groups_with_details = api.list_groups(
|
|
44
|
+
include_personal=False,
|
|
45
|
+
include_members=True,
|
|
46
|
+
include_memberships=True
|
|
47
|
+
)
|
|
48
|
+
for group in groups_with_details:
|
|
49
|
+
print(f"Group: {group.friendly_name}")
|
|
50
|
+
print(f"Members: {[m.friendly_name for m in group.members]}")
|
|
51
|
+
print(f"Memberships: {[m.friendly_name for m in group.memberships]}")
|
|
52
|
+
|
|
53
|
+
# Search for specific groups
|
|
54
|
+
dev_groups = api.lookup_groups("Dev")
|
|
55
|
+
print("Development groups:", [group.friendly_name for group in dev_groups])
|
|
56
|
+
|
|
57
|
+
# Get current user's group
|
|
58
|
+
current_user_group = api.get_current_user_group()
|
|
59
|
+
print("Current user's group:", current_user_group.friendly_name)
|
|
60
|
+
|
|
61
|
+
# Create a new group
|
|
62
|
+
new_group = Group(friendly_name="Data Science Team", description="Team working on ML projects")
|
|
63
|
+
created_group = api.save_group(new_group)
|
|
64
|
+
print("Created group:", created_group.friendly_name)
|
|
65
|
+
|
|
66
|
+
# Get group members
|
|
67
|
+
group_members = api.get_group_members(created_group.id)
|
|
68
|
+
print(f"Members of {created_group.friendly_name}:", [m.friendly_name for m in group_members])
|
|
69
|
+
|
|
70
|
+
# Get group memberships
|
|
71
|
+
group_memberships = api.get_group_memberships(created_group.id)
|
|
72
|
+
print(f"Memberships of {created_group.friendly_name}:", [m.friendly_name for m in group_memberships])
|
|
73
|
+
|
|
74
|
+
# Request membership in a group
|
|
75
|
+
request = api.request_group_membership(created_group.id)
|
|
76
|
+
print("Membership request created:", request.id)
|
|
77
|
+
|
|
78
|
+
# Get membership requests (as group admin)
|
|
79
|
+
requests = api.get_group_membership_requests(created_group.id)
|
|
80
|
+
for req in requests:
|
|
81
|
+
print(f"Request from {req.from_group.friendly_name}: {'Approved' if req.is_approved else 'Pending'}")
|
|
82
|
+
|
|
83
|
+
# Approve or deny requests (as group admin)
|
|
84
|
+
if requests:
|
|
85
|
+
if requests[0].from_group.friendly_name == "John Doe" and not requests[0].is_viewed:
|
|
86
|
+
api.approve_membership_request(requests[0].id)
|
|
87
|
+
else:
|
|
88
|
+
api.deny_membership_request(requests[0].id)
|
|
89
|
+
|
|
90
|
+
# Update group information
|
|
91
|
+
created_group.description = "Updated description for Data Science Team"
|
|
92
|
+
updated_group = api.save_group(created_group, save_relations=True)
|
|
93
|
+
print("Updated group:", updated_group.friendly_name, updated_group.description)
|
|
94
|
+
|
|
95
|
+
# Add Member Examples
|
|
96
|
+
|
|
97
|
+
# Find John Doe's personal group
|
|
98
|
+
john_doe_groups = api.lookup_groups("John Doe")
|
|
99
|
+
john_doe_group = next((g for g in john_doe_groups if g.personal), None)
|
|
100
|
+
if john_doe_group:
|
|
101
|
+
print(f"Found John Doe's personal group: {john_doe_group.friendly_name}")
|
|
102
|
+
|
|
103
|
+
# Add John Doe as regular member
|
|
104
|
+
created_group.add_member(john_doe_group)
|
|
105
|
+
print(f"Added {john_doe_group.friendly_name} as regular member to {created_group.friendly_name}")
|
|
106
|
+
|
|
107
|
+
# Verify the member was added
|
|
108
|
+
updated_group = api.get_group(created_group.id)
|
|
109
|
+
print(f"Members after adding: {[m.friendly_name for m in updated_group.members]}")
|
|
110
|
+
|
|
111
|
+
# Add John Doe as admin
|
|
112
|
+
created_group.add_member(john_doe_group, is_admin=True)
|
|
113
|
+
print(f"Added {john_doe_group.friendly_name} as admin to {created_group.friendly_name}")
|
|
114
|
+
|
|
115
|
+
# Verify the admin member was added
|
|
116
|
+
updated_group = api.get_group(created_group.id)
|
|
117
|
+
print(f"Admin members: {[m.friendly_name for m in updated_group.admin_members]}")
|
|
118
|
+
print(f"All members: {[m.friendly_name for m in updated_group.members]}")
|
|
119
|
+
else:
|
|
120
|
+
print("John Doe's personal group not found")
|
|
121
|
+
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "datagrok-api"
|
|
7
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.5"
|
|
8
8
|
authors = [
|
|
9
9
|
{ name="Andrew Skalkin", email="askalkin@datagrok.ai" },
|
|
10
10
|
{ name="Amelichev Konstantin", email="kamelichev@datagrok.ai" },
|
|
@@ -18,6 +18,20 @@ classifiers = [
|
|
|
18
18
|
"Operating System :: OS Independent",
|
|
19
19
|
]
|
|
20
20
|
|
|
21
|
+
dependencies = [
|
|
22
|
+
"pandas",
|
|
23
|
+
"requests",
|
|
24
|
+
"requests_toolbelt"
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.optional-dependencies]
|
|
28
|
+
test = [
|
|
29
|
+
"pytest",
|
|
30
|
+
"pytest-xml",
|
|
31
|
+
"pytest-item-dict",
|
|
32
|
+
"data_to_xml"
|
|
33
|
+
]
|
|
34
|
+
|
|
21
35
|
[project.urls]
|
|
22
36
|
Homepage = "https://github.com/datagrok-ai/public"
|
|
23
37
|
Issues = "https://github.com/datagrok-ai/public/issues"
|
datagrok_api-0.0.4/PKG-INFO
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: datagrok-api
|
|
3
|
-
Version: 0.0.4
|
|
4
|
-
Summary: Client library for integration with datagrok API
|
|
5
|
-
Project-URL: Homepage, https://github.com/datagrok-ai/public
|
|
6
|
-
Project-URL: Issues, https://github.com/datagrok-ai/public/issues
|
|
7
|
-
Author-email: Andrew Skalkin <askalkin@datagrok.ai>, Amelichev Konstantin <kamelichev@datagrok.ai>
|
|
8
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
-
Classifier: Operating System :: OS Independent
|
|
10
|
-
Classifier: Programming Language :: Python :: 3
|
|
11
|
-
Requires-Python: >=3.5
|
|
12
|
-
Description-Content-Type: text/markdown
|
|
13
|
-
|
|
14
|
-
# Datagrok python client library
|
|
15
|
-
|
|
16
|
-
This library can be used for integration with datagrok. It is a python wrapper for public API, that has OpenAPI specification available [here](http://public.datagrok.ai/api/public/api.yaml).
|
|
17
|
-
|
|
18
|
-
Refer to [Help](http://datagrok.ai/help) for more information.
|
|
19
|
-
|
|
20
|
-
## Installation
|
|
21
|
-
|
|
22
|
-
To install package, use [pip](https://pypi.org/project/pip/).
|
|
23
|
-
|
|
24
|
-
```shell
|
|
25
|
-
pip install datagrok-api
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Usage
|
|
29
|
-
|
|
30
|
-
To use API client, import DatagrokClient to your project:
|
|
31
|
-
|
|
32
|
-
```python
|
|
33
|
-
from datagrok_api import DatagrokClient
|
|
34
|
-
|
|
35
|
-
api = DatagrokClient('your token', 'datagrok url')
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## License
|
|
39
|
-
|
|
40
|
-
See [License.md](https://github.com/datagrok-ai/public/blob/master/LICENSE.md).
|
|
41
|
-
|
|
42
|
-
## Examples
|
|
43
|
-
|
|
44
|
-
The package uses Pandas for representation of tables and dataframes.
|
|
45
|
-
|
|
46
|
-
```python
|
|
47
|
-
import pandas as pd
|
|
48
|
-
from sklearn.datasets import load_iris
|
|
49
|
-
|
|
50
|
-
# Calls a Datagrok function
|
|
51
|
-
# Dataframes, columns and primitive data types are supported
|
|
52
|
-
api.call_function('Abs', {
|
|
53
|
-
'x': -3
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
# Downloads file from a given connection
|
|
57
|
-
res = api.download_file('system.demofiles', 'demog.csv')
|
|
58
|
-
print(res.head())
|
|
59
|
-
|
|
60
|
-
# Uploads iris dataset as a table
|
|
61
|
-
iris_id = api.upload_table('iris', pd.DataFrame(load_iris()['data']))['ID']
|
|
62
|
-
|
|
63
|
-
# Iris also can be uploaded as a file
|
|
64
|
-
# api.upload_file('system.demofiles', 'iris.csv', 'iris.csv')
|
|
65
|
-
|
|
66
|
-
# Fetches freshly uploaded Iris table
|
|
67
|
-
res = api.download_table(iris_id)
|
|
68
|
-
print(res.head())
|
|
69
|
-
|
|
70
|
-
# Creates dashboard from iris table with layout uploaded from file "iris.layout"
|
|
71
|
-
dashboard_id = api.create_dashboard('python-test', iris_id, layout_filename='iris.layout')['ID']
|
|
72
|
-
|
|
73
|
-
# Shares dashboard with admin
|
|
74
|
-
api.share_dashboard(dashboard_id, 'Test')
|
|
75
|
-
|
|
76
|
-
```
|
datagrok_api-0.0.4/README.md
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# Datagrok python client library
|
|
2
|
-
|
|
3
|
-
This library can be used for integration with datagrok. It is a python wrapper for public API, that has OpenAPI specification available [here](http://public.datagrok.ai/api/public/api.yaml).
|
|
4
|
-
|
|
5
|
-
Refer to [Help](http://datagrok.ai/help) for more information.
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
To install package, use [pip](https://pypi.org/project/pip/).
|
|
10
|
-
|
|
11
|
-
```shell
|
|
12
|
-
pip install datagrok-api
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Usage
|
|
16
|
-
|
|
17
|
-
To use API client, import DatagrokClient to your project:
|
|
18
|
-
|
|
19
|
-
```python
|
|
20
|
-
from datagrok_api import DatagrokClient
|
|
21
|
-
|
|
22
|
-
api = DatagrokClient('your token', 'datagrok url')
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## License
|
|
26
|
-
|
|
27
|
-
See [License.md](https://github.com/datagrok-ai/public/blob/master/LICENSE.md).
|
|
28
|
-
|
|
29
|
-
## Examples
|
|
30
|
-
|
|
31
|
-
The package uses Pandas for representation of tables and dataframes.
|
|
32
|
-
|
|
33
|
-
```python
|
|
34
|
-
import pandas as pd
|
|
35
|
-
from sklearn.datasets import load_iris
|
|
36
|
-
|
|
37
|
-
# Calls a Datagrok function
|
|
38
|
-
# Dataframes, columns and primitive data types are supported
|
|
39
|
-
api.call_function('Abs', {
|
|
40
|
-
'x': -3
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
# Downloads file from a given connection
|
|
44
|
-
res = api.download_file('system.demofiles', 'demog.csv')
|
|
45
|
-
print(res.head())
|
|
46
|
-
|
|
47
|
-
# Uploads iris dataset as a table
|
|
48
|
-
iris_id = api.upload_table('iris', pd.DataFrame(load_iris()['data']))['ID']
|
|
49
|
-
|
|
50
|
-
# Iris also can be uploaded as a file
|
|
51
|
-
# api.upload_file('system.demofiles', 'iris.csv', 'iris.csv')
|
|
52
|
-
|
|
53
|
-
# Fetches freshly uploaded Iris table
|
|
54
|
-
res = api.download_table(iris_id)
|
|
55
|
-
print(res.head())
|
|
56
|
-
|
|
57
|
-
# Creates dashboard from iris table with layout uploaded from file "iris.layout"
|
|
58
|
-
dashboard_id = api.create_dashboard('python-test', iris_id, layout_filename='iris.layout')['ID']
|
|
59
|
-
|
|
60
|
-
# Shares dashboard with admin
|
|
61
|
-
api.share_dashboard(dashboard_id, 'Test')
|
|
62
|
-
|
|
63
|
-
```
|
datagrok_api-0.0.4/example.py
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
from datagrok_api import DatagrokClient
|
|
2
|
-
from datagrok_api.group import Group
|
|
3
|
-
|
|
4
|
-
import pandas as pd
|
|
5
|
-
from sklearn.datasets import load_iris
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
api = DatagrokClient('YOUR_TOKEN', 'API_URL')
|
|
9
|
-
|
|
10
|
-
# Calls a Datagrok function
|
|
11
|
-
# Dataframes, columns and primitive data types are supported
|
|
12
|
-
api.call_function('Abs', {
|
|
13
|
-
'x': -3
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
# Downloads file from a given connection
|
|
17
|
-
res = api.download_file('system.demofiles', 'demog.csv')
|
|
18
|
-
print(res.head())
|
|
19
|
-
|
|
20
|
-
# Uploads iris dataset as a table
|
|
21
|
-
iris_id = api.upload_table('iris', pd.DataFrame(load_iris()['data']))['ID']
|
|
22
|
-
|
|
23
|
-
# Iris also can be uploaded as a file
|
|
24
|
-
# api.upload_file('system.demofiles', 'iris.csv', 'iris.csv')
|
|
25
|
-
|
|
26
|
-
# Fetches freshly uploaded Iris table
|
|
27
|
-
res = api.download_table(iris_id)
|
|
28
|
-
print(res.head())
|
|
29
|
-
|
|
30
|
-
# Creates dashboard from iris table with layout uploaded from file "iris.layout"
|
|
31
|
-
dashboard_id = api.create_dashboard('python-test', iris_id, layout_filename='iris.layout')['ID']
|
|
32
|
-
|
|
33
|
-
# Shares dashboard with admin
|
|
34
|
-
api.share_dashboard(dashboard_id, 'Test')
|
|
35
|
-
|
|
36
|
-
# List all groups that are not personal
|
|
37
|
-
api.list_groups(include_personal=False, include_members=True, include_memberships=True)
|
|
38
|
-
|
|
39
|
-
# Lookup for group by name
|
|
40
|
-
developers_group = api.lookup_groups("Developers")[0]
|
|
41
|
-
# Request group membership
|
|
42
|
-
request = developers_group.request_membership()
|
|
43
|
-
# Get all membership requests
|
|
44
|
-
requests = developers_group.get_membership_requests()
|
|
45
|
-
# Deny or approve requests. You should be admin of the group
|
|
46
|
-
if requests[0].from_group.friendly_name == "John Doe" and not requests[0].is_viewed:
|
|
47
|
-
requests[0].approve()
|
|
48
|
-
requests[1].deny()
|
|
49
|
-
|
|
50
|
-
created_group = api.save_group(Group(friendlyName="R&D", description="Bio research group"))
|
|
51
|
-
|
datagrok_api-0.0.4/openapi.yaml
DELETED
|
@@ -1,524 +0,0 @@
|
|
|
1
|
-
openapi: 3.0.0
|
|
2
|
-
info:
|
|
3
|
-
title: Datagrok API
|
|
4
|
-
description: API for interacting with Datagrok platform
|
|
5
|
-
version: 1.0.0
|
|
6
|
-
contact:
|
|
7
|
-
name: Datagrok Team
|
|
8
|
-
url: https://datagrok.ai
|
|
9
|
-
|
|
10
|
-
servers:
|
|
11
|
-
- url: https://public.datagrok.ai/api
|
|
12
|
-
description: Production server
|
|
13
|
-
|
|
14
|
-
components:
|
|
15
|
-
securitySchemes:
|
|
16
|
-
BearerAuth:
|
|
17
|
-
type: http
|
|
18
|
-
scheme: bearer
|
|
19
|
-
bearerFormat: JWT
|
|
20
|
-
|
|
21
|
-
schemas:
|
|
22
|
-
Table:
|
|
23
|
-
type: object
|
|
24
|
-
properties:
|
|
25
|
-
id:
|
|
26
|
-
type: string
|
|
27
|
-
description: Unique identifier of the table
|
|
28
|
-
name:
|
|
29
|
-
type: string
|
|
30
|
-
description: Name of the table
|
|
31
|
-
description:
|
|
32
|
-
type: string
|
|
33
|
-
description: Description of the table
|
|
34
|
-
|
|
35
|
-
Group:
|
|
36
|
-
type: object
|
|
37
|
-
properties:
|
|
38
|
-
id:
|
|
39
|
-
type: string
|
|
40
|
-
description: Unique identifier of the group
|
|
41
|
-
name:
|
|
42
|
-
type: string
|
|
43
|
-
description: Name of the group
|
|
44
|
-
friendlyName:
|
|
45
|
-
type: string
|
|
46
|
-
description: Friendly name of the group
|
|
47
|
-
description:
|
|
48
|
-
type: string
|
|
49
|
-
description: Description of the group
|
|
50
|
-
createdOn:
|
|
51
|
-
type: string
|
|
52
|
-
format: date-time
|
|
53
|
-
description: Creation timestamp
|
|
54
|
-
updatedOn:
|
|
55
|
-
type: string
|
|
56
|
-
format: date-time
|
|
57
|
-
description: Last update timestamp
|
|
58
|
-
personal:
|
|
59
|
-
type: boolean
|
|
60
|
-
description: Whether this is a personal group
|
|
61
|
-
hidden:
|
|
62
|
-
type: boolean
|
|
63
|
-
description: Whether this group is hidden
|
|
64
|
-
parents:
|
|
65
|
-
type: array
|
|
66
|
-
items:
|
|
67
|
-
$ref: '#/components/schemas/GroupRelation'
|
|
68
|
-
children:
|
|
69
|
-
type: array
|
|
70
|
-
items:
|
|
71
|
-
$ref: '#/components/schemas/GroupRelation'
|
|
72
|
-
|
|
73
|
-
GroupRelation:
|
|
74
|
-
type: object
|
|
75
|
-
properties:
|
|
76
|
-
id:
|
|
77
|
-
type: string
|
|
78
|
-
description: Unique identifier of the relation
|
|
79
|
-
isAdmin:
|
|
80
|
-
type: boolean
|
|
81
|
-
description: Whether the member is an admin
|
|
82
|
-
parent:
|
|
83
|
-
$ref: '#/components/schemas/Group'
|
|
84
|
-
child:
|
|
85
|
-
$ref: '#/components/schemas/Group'
|
|
86
|
-
|
|
87
|
-
GroupMembershipRequest:
|
|
88
|
-
type: object
|
|
89
|
-
properties:
|
|
90
|
-
id:
|
|
91
|
-
type: string
|
|
92
|
-
description: Unique identifier of the request
|
|
93
|
-
approved:
|
|
94
|
-
type: boolean
|
|
95
|
-
nullable: true
|
|
96
|
-
description: Whether the request was approved
|
|
97
|
-
createdOn:
|
|
98
|
-
type: string
|
|
99
|
-
format: date-time
|
|
100
|
-
description: Creation timestamp
|
|
101
|
-
updatedOn:
|
|
102
|
-
type: string
|
|
103
|
-
format: date-time
|
|
104
|
-
description: Last update timestamp
|
|
105
|
-
resolutionDate:
|
|
106
|
-
type: string
|
|
107
|
-
format: date-time
|
|
108
|
-
nullable: true
|
|
109
|
-
description: Date when the request was resolved
|
|
110
|
-
from:
|
|
111
|
-
$ref: '#/components/schemas/Group'
|
|
112
|
-
to:
|
|
113
|
-
$ref: '#/components/schemas/Group'
|
|
114
|
-
|
|
115
|
-
security:
|
|
116
|
-
- BearerAuth: []
|
|
117
|
-
|
|
118
|
-
paths:
|
|
119
|
-
/public/v1/tables/{name}:
|
|
120
|
-
get:
|
|
121
|
-
summary: Download a table
|
|
122
|
-
description: Downloads a table from Datagrok
|
|
123
|
-
parameters:
|
|
124
|
-
- name: name
|
|
125
|
-
in: path
|
|
126
|
-
required: true
|
|
127
|
-
schema:
|
|
128
|
-
type: string
|
|
129
|
-
description: Identifier of a table (UUID or Grok name)
|
|
130
|
-
responses:
|
|
131
|
-
'200':
|
|
132
|
-
description: Table data in CSV format
|
|
133
|
-
content:
|
|
134
|
-
text/plain:
|
|
135
|
-
schema:
|
|
136
|
-
type: string
|
|
137
|
-
format: binary
|
|
138
|
-
post:
|
|
139
|
-
summary: Upload a table
|
|
140
|
-
description: Uploads a table to Datagrok
|
|
141
|
-
parameters:
|
|
142
|
-
- name: name
|
|
143
|
-
in: path
|
|
144
|
-
required: true
|
|
145
|
-
schema:
|
|
146
|
-
type: string
|
|
147
|
-
description: Name for the new table
|
|
148
|
-
requestBody:
|
|
149
|
-
required: true
|
|
150
|
-
content:
|
|
151
|
-
text/csv:
|
|
152
|
-
schema:
|
|
153
|
-
type: string
|
|
154
|
-
format: binary
|
|
155
|
-
responses:
|
|
156
|
-
'200':
|
|
157
|
-
description: Table identifiers
|
|
158
|
-
content:
|
|
159
|
-
application/json:
|
|
160
|
-
schema:
|
|
161
|
-
$ref: '#/components/schemas/Table'
|
|
162
|
-
|
|
163
|
-
/public/v1/files/{connector}/{path}:
|
|
164
|
-
get:
|
|
165
|
-
summary: Download a file
|
|
166
|
-
description: Download a file from a connector
|
|
167
|
-
parameters:
|
|
168
|
-
- name: connector
|
|
169
|
-
in: path
|
|
170
|
-
required: true
|
|
171
|
-
schema:
|
|
172
|
-
type: string
|
|
173
|
-
description: Identifier of a connector
|
|
174
|
-
- name: path
|
|
175
|
-
in: path
|
|
176
|
-
required: true
|
|
177
|
-
schema:
|
|
178
|
-
type: string
|
|
179
|
-
description: Path to file in the connector
|
|
180
|
-
responses:
|
|
181
|
-
'200':
|
|
182
|
-
description: File content
|
|
183
|
-
content:
|
|
184
|
-
application/octet-stream:
|
|
185
|
-
schema:
|
|
186
|
-
type: string
|
|
187
|
-
format: binary
|
|
188
|
-
post:
|
|
189
|
-
summary: Upload a file
|
|
190
|
-
description: Uploads a file to a connector
|
|
191
|
-
parameters:
|
|
192
|
-
- name: connector
|
|
193
|
-
in: path
|
|
194
|
-
required: true
|
|
195
|
-
schema:
|
|
196
|
-
type: string
|
|
197
|
-
description: Identifier of a connector
|
|
198
|
-
- name: path
|
|
199
|
-
in: path
|
|
200
|
-
required: true
|
|
201
|
-
schema:
|
|
202
|
-
type: string
|
|
203
|
-
description: Path to file in the connector
|
|
204
|
-
requestBody:
|
|
205
|
-
required: true
|
|
206
|
-
content:
|
|
207
|
-
application/octet-stream:
|
|
208
|
-
schema:
|
|
209
|
-
type: string
|
|
210
|
-
format: binary
|
|
211
|
-
responses:
|
|
212
|
-
'200':
|
|
213
|
-
description: File uploaded successfully
|
|
214
|
-
|
|
215
|
-
/public/v1/dashboards/{id}/shares:
|
|
216
|
-
get:
|
|
217
|
-
summary: Share a dashboard
|
|
218
|
-
description: Shares a dashboard with specified groups
|
|
219
|
-
parameters:
|
|
220
|
-
- name: id
|
|
221
|
-
in: path
|
|
222
|
-
required: true
|
|
223
|
-
schema:
|
|
224
|
-
type: string
|
|
225
|
-
description: Identifier of the dashboard
|
|
226
|
-
- name: groups
|
|
227
|
-
in: query
|
|
228
|
-
required: true
|
|
229
|
-
schema:
|
|
230
|
-
type: string
|
|
231
|
-
description: Comma-separated list of group/user names
|
|
232
|
-
- name: access
|
|
233
|
-
in: query
|
|
234
|
-
required: true
|
|
235
|
-
schema:
|
|
236
|
-
type: string
|
|
237
|
-
enum: [View, Edit]
|
|
238
|
-
description: Access level for the groups
|
|
239
|
-
responses:
|
|
240
|
-
'200':
|
|
241
|
-
description: Dashboard shared successfully
|
|
242
|
-
|
|
243
|
-
/public/v1/dashboards/{name}/{table_ids}:
|
|
244
|
-
post:
|
|
245
|
-
summary: Create a dashboard
|
|
246
|
-
description: Creates a new dashboard
|
|
247
|
-
parameters:
|
|
248
|
-
- name: name
|
|
249
|
-
in: path
|
|
250
|
-
required: true
|
|
251
|
-
schema:
|
|
252
|
-
type: string
|
|
253
|
-
description: Name for the new dashboard
|
|
254
|
-
- name: table_ids
|
|
255
|
-
in: path
|
|
256
|
-
required: true
|
|
257
|
-
schema:
|
|
258
|
-
type: string
|
|
259
|
-
description: Comma-separated list of table ids
|
|
260
|
-
requestBody:
|
|
261
|
-
content:
|
|
262
|
-
application/json:
|
|
263
|
-
schema:
|
|
264
|
-
type: object
|
|
265
|
-
description: Dashboard layout configuration
|
|
266
|
-
responses:
|
|
267
|
-
'200':
|
|
268
|
-
description: Dashboard created successfully
|
|
269
|
-
content:
|
|
270
|
-
application/json:
|
|
271
|
-
schema:
|
|
272
|
-
type: object
|
|
273
|
-
properties:
|
|
274
|
-
id:
|
|
275
|
-
type: string
|
|
276
|
-
name:
|
|
277
|
-
type: string
|
|
278
|
-
|
|
279
|
-
/public/v1/{name}/call:
|
|
280
|
-
post:
|
|
281
|
-
summary: Call a function
|
|
282
|
-
description: Performs a call of a Datagrok function
|
|
283
|
-
parameters:
|
|
284
|
-
- name: name
|
|
285
|
-
in: path
|
|
286
|
-
required: true
|
|
287
|
-
schema:
|
|
288
|
-
type: string
|
|
289
|
-
description: Function name
|
|
290
|
-
requestBody:
|
|
291
|
-
required: true
|
|
292
|
-
content:
|
|
293
|
-
application/json:
|
|
294
|
-
schema:
|
|
295
|
-
type: object
|
|
296
|
-
description: Function parameters
|
|
297
|
-
responses:
|
|
298
|
-
'200':
|
|
299
|
-
description: Function call result
|
|
300
|
-
content:
|
|
301
|
-
application/json:
|
|
302
|
-
schema:
|
|
303
|
-
type: object
|
|
304
|
-
|
|
305
|
-
/public/v1/groups:
|
|
306
|
-
get:
|
|
307
|
-
summary: List groups
|
|
308
|
-
description: Lists user groups from Datagrok
|
|
309
|
-
parameters:
|
|
310
|
-
- name: text
|
|
311
|
-
in: query
|
|
312
|
-
schema:
|
|
313
|
-
type: string
|
|
314
|
-
description: Smart search filter
|
|
315
|
-
- name: include
|
|
316
|
-
in: query
|
|
317
|
-
schema:
|
|
318
|
-
type: string
|
|
319
|
-
description: Comma-separated list of relations to include
|
|
320
|
-
responses:
|
|
321
|
-
'200':
|
|
322
|
-
description: List of groups
|
|
323
|
-
content:
|
|
324
|
-
application/json:
|
|
325
|
-
schema:
|
|
326
|
-
type: array
|
|
327
|
-
items:
|
|
328
|
-
$ref: '#/components/schemas/Group'
|
|
329
|
-
post:
|
|
330
|
-
summary: Save group
|
|
331
|
-
description: Saves or updates a group
|
|
332
|
-
requestBody:
|
|
333
|
-
required: true
|
|
334
|
-
content:
|
|
335
|
-
application/json:
|
|
336
|
-
schema:
|
|
337
|
-
$ref: '#/components/schemas/Group'
|
|
338
|
-
parameters:
|
|
339
|
-
- name: saveRelations
|
|
340
|
-
in: query
|
|
341
|
-
schema:
|
|
342
|
-
type: boolean
|
|
343
|
-
description: Whether to save group relations
|
|
344
|
-
responses:
|
|
345
|
-
'200':
|
|
346
|
-
description: Saved group
|
|
347
|
-
content:
|
|
348
|
-
application/json:
|
|
349
|
-
schema:
|
|
350
|
-
$ref: '#/components/schemas/Group'
|
|
351
|
-
|
|
352
|
-
/public/v1/groups/lookup:
|
|
353
|
-
get:
|
|
354
|
-
summary: Lookup groups
|
|
355
|
-
description: Looks up groups by name
|
|
356
|
-
parameters:
|
|
357
|
-
- name: query
|
|
358
|
-
in: query
|
|
359
|
-
required: true
|
|
360
|
-
schema:
|
|
361
|
-
type: string
|
|
362
|
-
description: Query string to match groups by name
|
|
363
|
-
responses:
|
|
364
|
-
'200':
|
|
365
|
-
description: List of matching groups
|
|
366
|
-
content:
|
|
367
|
-
application/json:
|
|
368
|
-
schema:
|
|
369
|
-
type: array
|
|
370
|
-
items:
|
|
371
|
-
$ref: '#/components/schemas/Group'
|
|
372
|
-
|
|
373
|
-
/public/v1/groups/{group_id}:
|
|
374
|
-
get:
|
|
375
|
-
summary: Get group
|
|
376
|
-
description: Retrieves the details of a specific group
|
|
377
|
-
parameters:
|
|
378
|
-
- name: group_id
|
|
379
|
-
in: path
|
|
380
|
-
required: true
|
|
381
|
-
schema:
|
|
382
|
-
type: string
|
|
383
|
-
description: ID of the group
|
|
384
|
-
responses:
|
|
385
|
-
'200':
|
|
386
|
-
description: Group details
|
|
387
|
-
content:
|
|
388
|
-
application/json:
|
|
389
|
-
schema:
|
|
390
|
-
$ref: '#/components/schemas/Group'
|
|
391
|
-
|
|
392
|
-
/public/v1/groups/{group_id}/members:
|
|
393
|
-
get:
|
|
394
|
-
summary: Get group members
|
|
395
|
-
description: Retrieves the members of a specific group
|
|
396
|
-
parameters:
|
|
397
|
-
- name: group_id
|
|
398
|
-
in: path
|
|
399
|
-
required: true
|
|
400
|
-
schema:
|
|
401
|
-
type: string
|
|
402
|
-
description: ID of the group
|
|
403
|
-
- name: admin
|
|
404
|
-
in: query
|
|
405
|
-
schema:
|
|
406
|
-
type: boolean
|
|
407
|
-
description: Filter by admin status
|
|
408
|
-
responses:
|
|
409
|
-
'200':
|
|
410
|
-
description: List of group members
|
|
411
|
-
content:
|
|
412
|
-
application/json:
|
|
413
|
-
schema:
|
|
414
|
-
type: array
|
|
415
|
-
items:
|
|
416
|
-
$ref: '#/components/schemas/Group'
|
|
417
|
-
|
|
418
|
-
/public/v1/groups/{group_id}/memberships:
|
|
419
|
-
get:
|
|
420
|
-
summary: Get group memberships
|
|
421
|
-
description: Retrieves the memberships of a specific group
|
|
422
|
-
parameters:
|
|
423
|
-
- name: group_id
|
|
424
|
-
in: path
|
|
425
|
-
required: true
|
|
426
|
-
schema:
|
|
427
|
-
type: string
|
|
428
|
-
description: ID of the group
|
|
429
|
-
- name: admin
|
|
430
|
-
in: query
|
|
431
|
-
schema:
|
|
432
|
-
type: boolean
|
|
433
|
-
description: Filter by admin status
|
|
434
|
-
responses:
|
|
435
|
-
'200':
|
|
436
|
-
description: List of group memberships
|
|
437
|
-
content:
|
|
438
|
-
application/json:
|
|
439
|
-
schema:
|
|
440
|
-
type: array
|
|
441
|
-
items:
|
|
442
|
-
$ref: '#/components/schemas/Group'
|
|
443
|
-
|
|
444
|
-
/public/v1/groups/{group_id}/request:
|
|
445
|
-
post:
|
|
446
|
-
summary: Request group membership
|
|
447
|
-
description: Submits a request to join a specific group
|
|
448
|
-
parameters:
|
|
449
|
-
- name: group_id
|
|
450
|
-
in: path
|
|
451
|
-
required: true
|
|
452
|
-
schema:
|
|
453
|
-
type: string
|
|
454
|
-
description: ID of the group
|
|
455
|
-
responses:
|
|
456
|
-
'200':
|
|
457
|
-
description: Created membership request
|
|
458
|
-
content:
|
|
459
|
-
application/json:
|
|
460
|
-
schema:
|
|
461
|
-
$ref: '#/components/schemas/GroupMembershipRequest'
|
|
462
|
-
|
|
463
|
-
/public/v1/groups/{group_id}/requests:
|
|
464
|
-
get:
|
|
465
|
-
summary: Get group membership requests
|
|
466
|
-
description: Retrieves a list of membership requests for a specific group
|
|
467
|
-
parameters:
|
|
468
|
-
- name: group_id
|
|
469
|
-
in: path
|
|
470
|
-
required: true
|
|
471
|
-
schema:
|
|
472
|
-
type: string
|
|
473
|
-
description: ID of the group
|
|
474
|
-
responses:
|
|
475
|
-
'200':
|
|
476
|
-
description: List of membership requests
|
|
477
|
-
content:
|
|
478
|
-
application/json:
|
|
479
|
-
schema:
|
|
480
|
-
type: array
|
|
481
|
-
items:
|
|
482
|
-
$ref: '#/components/schemas/GroupMembershipRequest'
|
|
483
|
-
|
|
484
|
-
/public/v1/groups/requests/{request_id}/approve:
|
|
485
|
-
post:
|
|
486
|
-
summary: Approve membership request
|
|
487
|
-
description: Approves a membership request for a group
|
|
488
|
-
parameters:
|
|
489
|
-
- name: request_id
|
|
490
|
-
in: path
|
|
491
|
-
required: true
|
|
492
|
-
schema:
|
|
493
|
-
type: string
|
|
494
|
-
description: ID of the membership request
|
|
495
|
-
responses:
|
|
496
|
-
'200':
|
|
497
|
-
description: Request approved successfully
|
|
498
|
-
|
|
499
|
-
/public/v1/groups/requests/{request_id}/deny:
|
|
500
|
-
post:
|
|
501
|
-
summary: Deny membership request
|
|
502
|
-
description: Denies a membership request for a group
|
|
503
|
-
parameters:
|
|
504
|
-
- name: request_id
|
|
505
|
-
in: path
|
|
506
|
-
required: true
|
|
507
|
-
schema:
|
|
508
|
-
type: string
|
|
509
|
-
description: ID of the membership request
|
|
510
|
-
responses:
|
|
511
|
-
'200':
|
|
512
|
-
description: Request denied successfully
|
|
513
|
-
|
|
514
|
-
/public/v1/user/group:
|
|
515
|
-
get:
|
|
516
|
-
summary: Get current user group
|
|
517
|
-
description: Gets the current user's group
|
|
518
|
-
responses:
|
|
519
|
-
'200':
|
|
520
|
-
description: Current user's group
|
|
521
|
-
content:
|
|
522
|
-
application/json:
|
|
523
|
-
schema:
|
|
524
|
-
$ref: '#/components/schemas/Group'
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|