datagrok-api 0.0.8__tar.gz → 0.0.9__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.8 → datagrok_api-0.0.9}/PKG-INFO +1 -1
- {datagrok_api-0.0.8 → datagrok_api-0.0.9}/datagrok_api/datagrok_client.py +2 -0
- {datagrok_api-0.0.8 → datagrok_api-0.0.9}/datagrok_api/models/data_connection.py +15 -15
- {datagrok_api-0.0.8 → datagrok_api-0.0.9}/datagrok_api/models/func.py +17 -34
- {datagrok_api-0.0.8 → datagrok_api-0.0.9}/datagrok_api/models/group.py +1 -1
- {datagrok_api-0.0.8 → datagrok_api-0.0.9}/datagrok_api/models/model.py +2 -2
- {datagrok_api-0.0.8 → datagrok_api-0.0.9}/datagrok_api/models/query.py +16 -28
- {datagrok_api-0.0.8 → datagrok_api-0.0.9}/datagrok_api/models/script.py +19 -33
- {datagrok_api-0.0.8 → datagrok_api-0.0.9}/datagrok_api/models/share_response.py +13 -15
- {datagrok_api-0.0.8 → datagrok_api-0.0.9}/datagrok_api/resources/connections.py +1 -1
- {datagrok_api-0.0.8 → datagrok_api-0.0.9}/datagrok_api/resources/files.py +2 -2
- {datagrok_api-0.0.8 → datagrok_api-0.0.9}/datagrok_api/resources/functions.py +48 -0
- {datagrok_api-0.0.8 → datagrok_api-0.0.9}/datagrok_api/resources/shares.py +1 -1
- {datagrok_api-0.0.8 → datagrok_api-0.0.9}/datagrok_api/resources/users.py +16 -2
- {datagrok_api-0.0.8 → datagrok_api-0.0.9}/pyproject.toml +1 -1
- {datagrok_api-0.0.8 → datagrok_api-0.0.9}/.gitignore +0 -0
- {datagrok_api-0.0.8 → datagrok_api-0.0.9}/README.md +0 -0
- {datagrok_api-0.0.8 → datagrok_api-0.0.9}/datagrok_api/__init__.py +0 -0
- {datagrok_api-0.0.8 → datagrok_api-0.0.9}/datagrok_api/http_client.py +0 -0
- {datagrok_api-0.0.8 → datagrok_api-0.0.9}/datagrok_api/models/__init__.py +0 -0
- {datagrok_api-0.0.8 → datagrok_api-0.0.9}/datagrok_api/models/user.py +0 -0
- {datagrok_api-0.0.8 → datagrok_api-0.0.9}/datagrok_api/resources/__init__.py +0 -0
- {datagrok_api-0.0.8 → datagrok_api-0.0.9}/datagrok_api/resources/groups.py +0 -0
- {datagrok_api-0.0.8 → datagrok_api-0.0.9}/datagrok_api/resources/tables.py +0 -0
|
@@ -93,7 +93,7 @@ class Credentials(Model):
|
|
|
93
93
|
Allows dynamic setting and getting of credential fields like login, password,
|
|
94
94
|
access keys, or tokens depending on the data source.
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
Attributes
|
|
97
97
|
----------
|
|
98
98
|
**kwargs : dict
|
|
99
99
|
Arbitrary credential fields passed as key-value pairs.
|
|
@@ -156,7 +156,7 @@ class DataConnection(NamedModel):
|
|
|
156
156
|
"""
|
|
157
157
|
Represents a data connection in Datagrok.
|
|
158
158
|
|
|
159
|
-
|
|
159
|
+
Attributes
|
|
160
160
|
----------
|
|
161
161
|
name : Optional[str]
|
|
162
162
|
Internal name of the model, used as an identifier.
|
|
@@ -186,25 +186,25 @@ class DataConnection(NamedModel):
|
|
|
186
186
|
Create a connection to a Postgres database with login parameters
|
|
187
187
|
|
|
188
188
|
>>> conn_pg = DataConnection(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
)
|
|
189
|
+
... name="my_postgres_conn",
|
|
190
|
+
... data_source=DataSourceType.Postgres,
|
|
191
|
+
... server="localhost",
|
|
192
|
+
... port=5432,
|
|
193
|
+
... db="mydb",
|
|
194
|
+
... new Credentials(login="postgres", password="postgres")
|
|
195
|
+
... )
|
|
196
196
|
>>> print(conn_pg.host) # Access arbitrary parameter
|
|
197
197
|
>>> conn_pg.password = "new_password" # Update arbitrary parameter
|
|
198
198
|
|
|
199
199
|
Create a connection to an S3 bucket with different parameters
|
|
200
200
|
|
|
201
201
|
>>> conn_s3 = DataConnection(
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
)
|
|
202
|
+
... name="my_s3_conn",
|
|
203
|
+
... data_source=DataSourceType.S3,
|
|
204
|
+
... bucket="my-bucket",
|
|
205
|
+
... region="us-west-2",
|
|
206
|
+
... new Credentials(accessKey="AKIA...", secretKey="...")
|
|
207
|
+
... )
|
|
208
208
|
>>> print(conn_s3.bucket) # Access bucket name
|
|
209
209
|
>>> conn_s3.region = "us-east-1" # Update region dynamically
|
|
210
210
|
"""
|
|
@@ -45,28 +45,28 @@ class Func(NamedModel):
|
|
|
45
45
|
define, discover, secure, and execute platform capabilities.
|
|
46
46
|
|
|
47
47
|
Examples of functions in Grok include:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
* Querying an external PostgreSQL database
|
|
49
|
+
* Executing JavaScript code in the browser that uses Grok APIs
|
|
50
|
+
* Performing mathematical calculations (e.g., `Sin(PI)`)
|
|
51
|
+
* Modifying datasets (e.g., deleting a column)
|
|
52
|
+
* Sending an email
|
|
53
|
+
* Applying a predictive model to a dataset
|
|
54
|
+
* Calculating molecular properties via a Python script
|
|
55
|
+
* Displaying interactive dialogs
|
|
56
56
|
|
|
57
57
|
Despite their differences (server-side vs client-side execution,
|
|
58
58
|
computational vs UI-based tasks), all functions share a common
|
|
59
59
|
set of capabilities:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
* **Scriptable**: Callable from the console or scripts.
|
|
61
|
+
* **Findable**: Searchable through the "Help | Functions" interface.
|
|
62
|
+
* **Introspectable**: Metadata about parameters is programmatically accessible.
|
|
63
|
+
* **Secure**: Access can be restricted via privileges or user groups.
|
|
64
|
+
* **Auditable**: Execution history and parameters are tracked.
|
|
65
|
+
* **Runnable**: The platform can dynamically generate UI for parameters.
|
|
66
|
+
* **Linkable**: Functions can be linked in dashboards, conversations, etc.
|
|
67
|
+
* **Composable**: Usable in workflow designers and query transformations.
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
Attributes
|
|
70
70
|
----------
|
|
71
71
|
source : Optional[str], default='function'
|
|
72
72
|
Identifies the origin or type of function (e.g., `"function"`, `"sql-query"`, `"js-script"`).
|
|
@@ -81,9 +81,6 @@ class Func(NamedModel):
|
|
|
81
81
|
**kwargs
|
|
82
82
|
Additional arguments passed to the parent `NamedModel` initializer,
|
|
83
83
|
such as `id`, `name`, `friendly_name`, `created_on`, `updated_on`, and `namespace`.
|
|
84
|
-
|
|
85
|
-
Attributes
|
|
86
|
-
----------
|
|
87
84
|
params : list of FuncParam
|
|
88
85
|
Parameter definitions (both input and output).
|
|
89
86
|
source : str
|
|
@@ -94,24 +91,10 @@ class Func(NamedModel):
|
|
|
94
91
|
Human-readable description.
|
|
95
92
|
options : dict
|
|
96
93
|
Function-specific settings.
|
|
97
|
-
|
|
98
|
-
Properties
|
|
99
|
-
----------
|
|
100
94
|
input_params : list of FuncParam
|
|
101
95
|
Parameters marked as inputs to the function.
|
|
102
96
|
output_params : list of FuncParam
|
|
103
97
|
Parameters marked as outputs from the function.
|
|
104
|
-
|
|
105
|
-
Methods
|
|
106
|
-
-------
|
|
107
|
-
to_dict() -> dict
|
|
108
|
-
Serializes the function to a dictionary for API usage.
|
|
109
|
-
register_subclass(source: str) -> Callable
|
|
110
|
-
Class decorator for registering a `Func` subclass for a specific `source`.
|
|
111
|
-
from_dict(data: dict) -> Func
|
|
112
|
-
Creates a `Func` (or registered subclass) instance from a dictionary.
|
|
113
|
-
_from_dict(data: dict) -> Func
|
|
114
|
-
Internal constructor used by `from_dict`.
|
|
115
98
|
"""
|
|
116
99
|
SOURCE = "function"
|
|
117
100
|
_registry: Dict[str, Type["Func"]] = {}
|
|
@@ -10,7 +10,7 @@ class Model(ABC):
|
|
|
10
10
|
It handles unique identification of model instances and ensures each instance
|
|
11
11
|
has a valid ID.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Attributes
|
|
14
14
|
----------
|
|
15
15
|
id : str
|
|
16
16
|
Unique identifier for the model instance. Can be None for new instances
|
|
@@ -39,7 +39,7 @@ class Model(ABC):
|
|
|
39
39
|
class NamedModel(Model, ABC):
|
|
40
40
|
"""NamedModel class that contains some common fields of Datagrok entities.
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
Attributes
|
|
43
43
|
----------
|
|
44
44
|
name : Optional[str]
|
|
45
45
|
Internal name of the model, used as an identifier.
|
|
@@ -12,7 +12,7 @@ class DataQuery(Func):
|
|
|
12
12
|
a provided connection. This class combines the platform's general
|
|
13
13
|
function capabilities with specific query execution details.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Attributes
|
|
16
16
|
----------
|
|
17
17
|
query : str
|
|
18
18
|
The query text to be executed. Typically SQL, but may vary
|
|
@@ -33,23 +33,11 @@ class DataQuery(Func):
|
|
|
33
33
|
- namespace : Optional[str]
|
|
34
34
|
- tags : Optional[List[str]]
|
|
35
35
|
- options : Optional[Dict[str, Any]]
|
|
36
|
-
|
|
37
|
-
Attributes
|
|
38
|
-
----------
|
|
39
36
|
query : str
|
|
40
37
|
The raw query text.
|
|
41
38
|
connection : DataConnection
|
|
42
39
|
Connection settings for the target data source.
|
|
43
40
|
|
|
44
|
-
Methods
|
|
45
|
-
-------
|
|
46
|
-
to_dict() -> dict
|
|
47
|
-
Serializes the data query to a dictionary, including both
|
|
48
|
-
function-level metadata and query-specific fields.
|
|
49
|
-
_from_dict(data: dict) -> DataQuery
|
|
50
|
-
Creates a `DataQuery` instance from a dictionary, reconstructing
|
|
51
|
-
both base function fields and query-specific details.
|
|
52
|
-
|
|
53
41
|
Examples
|
|
54
42
|
--------
|
|
55
43
|
Creating and serializing a `DataQuery`:
|
|
@@ -57,21 +45,21 @@ class DataQuery(Func):
|
|
|
57
45
|
>>> conn = DataConnection(name="Postgres", server="db.example.com", port=5432)
|
|
58
46
|
>>> dq = DataQuery(query="SELECT * FROM customers", connection=conn, name="Customer Query")
|
|
59
47
|
>>> dq.to_dict()
|
|
60
|
-
{
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
48
|
+
... {
|
|
49
|
+
... "id": None,
|
|
50
|
+
... "name": "Customer Query",
|
|
51
|
+
... "friendlyName": None,
|
|
52
|
+
... "createdOn": None,
|
|
53
|
+
... "updatedOn": None,
|
|
54
|
+
... "source": "data-query",
|
|
55
|
+
... "description": None,
|
|
56
|
+
... "params": [],
|
|
57
|
+
... "namespace": None,
|
|
58
|
+
... "tags": [],
|
|
59
|
+
... "options": {},
|
|
60
|
+
... "query": "SELECT * FROM customers",
|
|
61
|
+
... "connection": {...}
|
|
62
|
+
... }
|
|
75
63
|
"""
|
|
76
64
|
SOURCE = "data-query"
|
|
77
65
|
|
|
@@ -15,7 +15,7 @@ class ScriptLanguage(str, Enum):
|
|
|
15
15
|
supported by the platform. This enum defines the set of valid language
|
|
16
16
|
identifiers used for both serialization and execution.
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
Attributes
|
|
19
19
|
-------
|
|
20
20
|
Grok : str
|
|
21
21
|
Grok's native scripting language.
|
|
@@ -30,17 +30,12 @@ class ScriptLanguage(str, Enum):
|
|
|
30
30
|
Octave : str
|
|
31
31
|
GNU Octave, primarily for numerical computations.
|
|
32
32
|
|
|
33
|
-
Notes
|
|
34
|
-
-----
|
|
35
|
-
The string values (e.g., `"python"`, `"r"`) are used for
|
|
36
|
-
serialization and platform API communication.
|
|
37
|
-
|
|
38
33
|
Examples
|
|
39
34
|
--------
|
|
40
35
|
>>> ScriptLanguage.Python.value
|
|
41
|
-
'python'
|
|
36
|
+
... 'python'
|
|
42
37
|
>>> ScriptLanguage['Julia']
|
|
43
|
-
<ScriptLanguage.Julia: 'julia'>
|
|
38
|
+
... <ScriptLanguage.Julia: 'julia'>
|
|
44
39
|
"""
|
|
45
40
|
Grok = 'grok'
|
|
46
41
|
Julia = 'julia'
|
|
@@ -59,7 +54,7 @@ class Script(Func):
|
|
|
59
54
|
Scripts can be run in various environments (server-side or client-side)
|
|
60
55
|
depending on the language and platform configuration.
|
|
61
56
|
|
|
62
|
-
|
|
57
|
+
Attributes
|
|
63
58
|
----------
|
|
64
59
|
script : str
|
|
65
60
|
The source code of the script. Can contain special annotations that will
|
|
@@ -78,20 +73,11 @@ class Script(Func):
|
|
|
78
73
|
- namespace : Optional[str]
|
|
79
74
|
- tags : Optional[List[str]]
|
|
80
75
|
- options : Optional[Dict[str, Any]]
|
|
81
|
-
|
|
82
|
-
Attributes
|
|
83
|
-
----------
|
|
84
76
|
script : str
|
|
85
77
|
The script source code.
|
|
86
78
|
language : ScriptLanguage
|
|
87
79
|
The programming language used for the script.
|
|
88
80
|
|
|
89
|
-
Methods
|
|
90
|
-
-------
|
|
91
|
-
to_dict() -> dict
|
|
92
|
-
Serializes the script function into a dictionary including
|
|
93
|
-
both base function metadata and script-specific fields.
|
|
94
|
-
|
|
95
81
|
Examples
|
|
96
82
|
--------
|
|
97
83
|
Creating and serializing a Python script function:
|
|
@@ -99,21 +85,21 @@ class Script(Func):
|
|
|
99
85
|
>>> script_code = "print('Hello from Datagrok!')"
|
|
100
86
|
>>> s = Script(script=script_code, language=ScriptLanguage.Python, name="Hello Script")
|
|
101
87
|
>>> s.to_dict()
|
|
102
|
-
{
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
88
|
+
... {
|
|
89
|
+
... "id": None,
|
|
90
|
+
... "name": "Hello Script",
|
|
91
|
+
... "friendlyName": None,
|
|
92
|
+
... "createdOn": None,
|
|
93
|
+
... "updatedOn": None,
|
|
94
|
+
... "source": "script",
|
|
95
|
+
... "description": None,
|
|
96
|
+
... "params": [],
|
|
97
|
+
... "namespace": None,
|
|
98
|
+
... "tags": [],
|
|
99
|
+
... "options": {},
|
|
100
|
+
... "script": "print('Hello from Datagrok!')",
|
|
101
|
+
... "language": "python"
|
|
102
|
+
... }
|
|
117
103
|
"""
|
|
118
104
|
SOURCE = "script"
|
|
119
105
|
|
|
@@ -5,7 +5,7 @@ class ShareResponse:
|
|
|
5
5
|
This class encapsulates the status of a share request, including
|
|
6
6
|
successful shares, already shared items, and failures.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Attributes
|
|
9
9
|
----------
|
|
10
10
|
data : dict
|
|
11
11
|
Dictionary containing share response data from the Datagrok API.
|
|
@@ -17,9 +17,6 @@ class ShareResponse:
|
|
|
17
17
|
- 'shared' (list): Items that were successfully shared.
|
|
18
18
|
- 'alreadyShared' (list): Items that were already shared before the request.
|
|
19
19
|
- 'failed' (list): Items that failed to be shared.
|
|
20
|
-
|
|
21
|
-
Attributes
|
|
22
|
-
----------
|
|
23
20
|
status : str
|
|
24
21
|
The overall status of the share operation.
|
|
25
22
|
shared : list
|
|
@@ -28,17 +25,6 @@ class ShareResponse:
|
|
|
28
25
|
Items already shared before the request.
|
|
29
26
|
failed : list
|
|
30
27
|
Items that failed to be shared.
|
|
31
|
-
|
|
32
|
-
Methods
|
|
33
|
-
-------
|
|
34
|
-
is_success() -> bool
|
|
35
|
-
Returns True if all items were successfully shared.
|
|
36
|
-
is_partial() -> bool
|
|
37
|
-
Returns True if the operation had both successes and failures.
|
|
38
|
-
is_failed() -> bool
|
|
39
|
-
Returns True if the operation failed entirely.
|
|
40
|
-
raise_for_failure() -> None
|
|
41
|
-
Raises a RuntimeError if the operation failed.
|
|
42
28
|
"""
|
|
43
29
|
def __init__(self, data: dict):
|
|
44
30
|
self.status = data.get('status')
|
|
@@ -47,15 +33,27 @@ class ShareResponse:
|
|
|
47
33
|
self.failed = data.get('failed', [])
|
|
48
34
|
|
|
49
35
|
def is_success(self):
|
|
36
|
+
"""
|
|
37
|
+
Returns True if all items were successfully shared.
|
|
38
|
+
"""
|
|
50
39
|
return self.status == 'success'
|
|
51
40
|
|
|
52
41
|
def is_partial(self):
|
|
42
|
+
"""
|
|
43
|
+
Returns True if the operation had both successes and failures.
|
|
44
|
+
"""
|
|
53
45
|
return self.status == 'partial_success'
|
|
54
46
|
|
|
55
47
|
def is_failed(self):
|
|
48
|
+
"""
|
|
49
|
+
Returns True if the operation failed entirely
|
|
50
|
+
"""
|
|
56
51
|
return self.status == 'failed'
|
|
57
52
|
|
|
58
53
|
def raise_for_failure(self):
|
|
54
|
+
"""
|
|
55
|
+
Raises a RuntimeError if the operation failed.
|
|
56
|
+
"""
|
|
59
57
|
if self.is_failed():
|
|
60
58
|
raise RuntimeError(f"Sharing failed: {self.failed}")
|
|
61
59
|
|
|
@@ -34,7 +34,7 @@ class ConnectionsClient:
|
|
|
34
34
|
Create, save and test DataConnection
|
|
35
35
|
|
|
36
36
|
>>> shop_connection = DataConnection(name="TestConn", data_source=DatabaseDataSourceType.Postgres, description="Test conn", server="localhost",
|
|
37
|
-
|
|
37
|
+
... port=5432, db="shopdb", credentials=Credentials(login="***", password="***"))
|
|
38
38
|
>>> shop_connection_saved = grok.connections.save(shop_connection, save_credentials=True)
|
|
39
39
|
>>> grok.connections.test(shop_connection_saved)
|
|
40
40
|
|
|
@@ -120,8 +120,8 @@ class FilesClient:
|
|
|
120
120
|
params = {'recursive': str(recursive).lower()}
|
|
121
121
|
if ext:
|
|
122
122
|
params['ext'] = ext
|
|
123
|
-
|
|
124
|
-
response = self.
|
|
123
|
+
|
|
124
|
+
response = self.client.post(endpoint, params=params, json=sync_meta_dict)
|
|
125
125
|
|
|
126
126
|
def update_sync_meta(content: dict):
|
|
127
127
|
with open (sync_meta_file_path, "w") as f:
|
|
@@ -109,15 +109,63 @@ class FunctionsClient:
|
|
|
109
109
|
return [Func.from_dict(data) for data in response.json()]
|
|
110
110
|
|
|
111
111
|
def list_queries(self) -> List[DataQuery]:
|
|
112
|
+
"""
|
|
113
|
+
List all queries available in Datagrok.
|
|
114
|
+
|
|
115
|
+
Returns
|
|
116
|
+
-------
|
|
117
|
+
List[DataQuery]
|
|
118
|
+
List of `DataQuery` instances.
|
|
119
|
+
"""
|
|
112
120
|
return self.list(smart_filter=f"source=\"{DataQuery.SOURCE}\"")
|
|
113
121
|
|
|
114
122
|
def list_scripts(self) -> List[Script]:
|
|
123
|
+
"""
|
|
124
|
+
List all scripts available in Datagrok.
|
|
125
|
+
|
|
126
|
+
Returns
|
|
127
|
+
-------
|
|
128
|
+
List[Script]
|
|
129
|
+
List of `DataQuery` instances.
|
|
130
|
+
"""
|
|
115
131
|
return self.list(smart_filter=f"source=\"{Script.SOURCE}\"")
|
|
116
132
|
|
|
117
133
|
def create_query(self, connection: DataConnection, query: str, name: Optional[str]=None) -> DataQuery:
|
|
134
|
+
"""
|
|
135
|
+
Create and save a new data query in Datagrok.
|
|
136
|
+
|
|
137
|
+
Parameters
|
|
138
|
+
----------
|
|
139
|
+
connection : DataConnection
|
|
140
|
+
The data connection to execute the query on.
|
|
141
|
+
query : str
|
|
142
|
+
The SQL or query string to execute.
|
|
143
|
+
name : str, optional
|
|
144
|
+
Optional name for the query.
|
|
145
|
+
|
|
146
|
+
Returns
|
|
147
|
+
-------
|
|
148
|
+
DataQuery
|
|
149
|
+
The created `DataQuery` instance.
|
|
150
|
+
"""
|
|
118
151
|
return self._save(DataQuery(query=query, connection=connection, name=name))
|
|
119
152
|
|
|
120
153
|
def create_script(self, script: str, name: Optional[str]=None) -> Script:
|
|
154
|
+
"""
|
|
155
|
+
Create and save a new script in Datagrok.
|
|
156
|
+
|
|
157
|
+
Parameters
|
|
158
|
+
----------
|
|
159
|
+
script : str
|
|
160
|
+
The script source code.
|
|
161
|
+
name : str, optional
|
|
162
|
+
Optional name for the script.
|
|
163
|
+
|
|
164
|
+
Returns
|
|
165
|
+
-------
|
|
166
|
+
Script
|
|
167
|
+
The created `Script` instance.
|
|
168
|
+
"""
|
|
121
169
|
return self._save(Script(script=script, name=name))
|
|
122
170
|
|
|
123
171
|
def _save(self, func: Func) -> Func:
|
|
@@ -15,7 +15,7 @@ class UsersClient:
|
|
|
15
15
|
client : HttpClient
|
|
16
16
|
An instance of the HTTP client used to communicate with the Datagrok API.
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
Examples
|
|
19
19
|
--------
|
|
20
20
|
Get user by login
|
|
21
21
|
|
|
@@ -24,7 +24,7 @@ class UsersClient:
|
|
|
24
24
|
>>> grok = DatagrokClient(base_url="https://public.datagrok.ai/api", api_key="Bearer <your-token>")
|
|
25
25
|
>>> john_doe = grok.users.get("johndoe")
|
|
26
26
|
>>> print(john_doe.first_name)
|
|
27
|
-
John
|
|
27
|
+
... John
|
|
28
28
|
|
|
29
29
|
Get current authenticated user
|
|
30
30
|
>>> me = grok.users.current()
|
|
@@ -112,10 +112,24 @@ class UsersClient:
|
|
|
112
112
|
return [User.from_dict(data) for data in response.json()]
|
|
113
113
|
|
|
114
114
|
def block(self, user: User):
|
|
115
|
+
"""Block a user from accessing the Datagrok platform.
|
|
116
|
+
|
|
117
|
+
Parameters
|
|
118
|
+
----------
|
|
119
|
+
user : User
|
|
120
|
+
The user to block.
|
|
121
|
+
"""
|
|
115
122
|
endpoint = "/public/v1/users/block"
|
|
116
123
|
self.client.post(endpoint, json=user.to_dict())
|
|
117
124
|
|
|
118
125
|
def unblock(self, user: User):
|
|
126
|
+
"""Unblock a previously blocked user.
|
|
127
|
+
|
|
128
|
+
Parameters
|
|
129
|
+
----------
|
|
130
|
+
user : User
|
|
131
|
+
The user to unblock.
|
|
132
|
+
"""
|
|
119
133
|
endpoint = "/public/v1/users/unblock"
|
|
120
134
|
self.client.post(endpoint, json=user.to_dict())
|
|
121
135
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|