nebula-client 0.1.0__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.
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.2
2
+ Name: nebula-client
3
+ Version: 0.1.0
4
+ Summary: Python client for the Nebula file system API
5
+ Home-page: https://github.com/nebula/nebula-client-python
6
+ Author: Nebula Team
7
+ Author-email: support@nebula-app.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.6
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: requests>=2.25.0
14
+ Dynamic: author
15
+ Dynamic: author-email
16
+ Dynamic: classifier
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: home-page
20
+ Dynamic: requires-dist
21
+ Dynamic: requires-python
22
+ Dynamic: summary
23
+
24
+ # Nebula Python Client
25
+
26
+ A Python client library for interacting with the Nebula file system API.
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ pip install nebula-client
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ ```python
37
+ from nebula_client import NebulaClient
38
+
39
+ # Initialize the client with your API key
40
+ client = NebulaClient(api_key="your_api_key")
41
+
42
+ # List files in a cluster
43
+ files = client.list_files(cluster_id="your_cluster_id")
44
+
45
+ # Upload a file
46
+ result = client.upload_file(
47
+ cluster_id="your_cluster_id",
48
+ file_path="path/to/your/file.txt"
49
+ )
50
+
51
+ # Download a file
52
+ client.download_file(
53
+ cluster_id="your_cluster_id",
54
+ file_id="file_id",
55
+ output_path="path/to/save"
56
+ )
57
+
58
+ # Create a folder
59
+ folder = client.create_folder(
60
+ cluster_id="your_cluster_id",
61
+ folder_name="New Folder"
62
+ )
63
+
64
+ # Delete files or folders
65
+ client.delete_files(
66
+ cluster_id="your_cluster_id",
67
+ file_ids=["file_id_1", "file_id_2"]
68
+ )
69
+
70
+ # Move files to a different folder
71
+ client.move_files(
72
+ cluster_id="your_cluster_id",
73
+ file_ids=["file_id_1", "file_id_2"],
74
+ target_folder_id="target_folder_id"
75
+ )
76
+
77
+ # Rename a file or folder
78
+ client.rename_file(
79
+ cluster_id="your_cluster_id",
80
+ file_id="file_id",
81
+ new_name="New Name"
82
+ )
83
+ ```
84
+
85
+ ## API Reference
86
+
87
+ ### NebulaClient
88
+
89
+ The main client class for interacting with the Nebula API.
90
+
91
+ #### `__init__(api_key, base_url=None)`
92
+
93
+ Initialize a new client instance.
94
+
95
+ - `api_key` (str): Your Nebula API key
96
+ - `base_url` (str, optional): Custom API base URL. Defaults to production API.
97
+
98
+ #### File Operations
99
+
100
+ - `list_files(cluster_id, folder_id="ROOT")`: List files and folders
101
+ - `get_upload_url(cluster_id, file_name, folder_id="ROOT", content_type=None)`: Get a pre-signed upload URL
102
+ - `upload_file(cluster_id, file_path, folder_id="ROOT", content_type=None)`: Upload a file
103
+ - `get_download_url(cluster_id, file_id)`: Get a pre-signed download URL
104
+ - `download_file(cluster_id, file_id, output_path)`: Download a file
105
+ - `create_folder(cluster_id, folder_name, parent_folder_id="ROOT")`: Create a folder
106
+ - `delete_files(cluster_id, file_ids)`: Delete files/folders
107
+ - `move_files(cluster_id, file_ids, target_folder_id)`: Move files to another folder
108
+ - `rename_file(cluster_id, file_id, new_name)`: Rename a file/folder
109
+
110
+ ## License
111
+
112
+ MIT
@@ -0,0 +1,89 @@
1
+ # Nebula Python Client
2
+
3
+ A Python client library for interacting with the Nebula file system API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install nebula-client
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```python
14
+ from nebula_client import NebulaClient
15
+
16
+ # Initialize the client with your API key
17
+ client = NebulaClient(api_key="your_api_key")
18
+
19
+ # List files in a cluster
20
+ files = client.list_files(cluster_id="your_cluster_id")
21
+
22
+ # Upload a file
23
+ result = client.upload_file(
24
+ cluster_id="your_cluster_id",
25
+ file_path="path/to/your/file.txt"
26
+ )
27
+
28
+ # Download a file
29
+ client.download_file(
30
+ cluster_id="your_cluster_id",
31
+ file_id="file_id",
32
+ output_path="path/to/save"
33
+ )
34
+
35
+ # Create a folder
36
+ folder = client.create_folder(
37
+ cluster_id="your_cluster_id",
38
+ folder_name="New Folder"
39
+ )
40
+
41
+ # Delete files or folders
42
+ client.delete_files(
43
+ cluster_id="your_cluster_id",
44
+ file_ids=["file_id_1", "file_id_2"]
45
+ )
46
+
47
+ # Move files to a different folder
48
+ client.move_files(
49
+ cluster_id="your_cluster_id",
50
+ file_ids=["file_id_1", "file_id_2"],
51
+ target_folder_id="target_folder_id"
52
+ )
53
+
54
+ # Rename a file or folder
55
+ client.rename_file(
56
+ cluster_id="your_cluster_id",
57
+ file_id="file_id",
58
+ new_name="New Name"
59
+ )
60
+ ```
61
+
62
+ ## API Reference
63
+
64
+ ### NebulaClient
65
+
66
+ The main client class for interacting with the Nebula API.
67
+
68
+ #### `__init__(api_key, base_url=None)`
69
+
70
+ Initialize a new client instance.
71
+
72
+ - `api_key` (str): Your Nebula API key
73
+ - `base_url` (str, optional): Custom API base URL. Defaults to production API.
74
+
75
+ #### File Operations
76
+
77
+ - `list_files(cluster_id, folder_id="ROOT")`: List files and folders
78
+ - `get_upload_url(cluster_id, file_name, folder_id="ROOT", content_type=None)`: Get a pre-signed upload URL
79
+ - `upload_file(cluster_id, file_path, folder_id="ROOT", content_type=None)`: Upload a file
80
+ - `get_download_url(cluster_id, file_id)`: Get a pre-signed download URL
81
+ - `download_file(cluster_id, file_id, output_path)`: Download a file
82
+ - `create_folder(cluster_id, folder_name, parent_folder_id="ROOT")`: Create a folder
83
+ - `delete_files(cluster_id, file_ids)`: Delete files/folders
84
+ - `move_files(cluster_id, file_ids, target_folder_id)`: Move files to another folder
85
+ - `rename_file(cluster_id, file_id, new_name)`: Rename a file/folder
86
+
87
+ ## License
88
+
89
+ MIT
@@ -0,0 +1,3 @@
1
+ from .client import NebulaClient
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,236 @@
1
+ import requests
2
+ import os
3
+ from typing import Dict, List, Optional, Union, BinaryIO
4
+ import json
5
+
6
+
7
+ class NebulaClient:
8
+ """Client for interacting with the Nebula file system API."""
9
+
10
+ def __init__(self, api_key: str, base_url: Optional[str] = None):
11
+ """
12
+ Initialize a Nebula client.
13
+
14
+ Args:
15
+ api_key: The API key for authentication
16
+ base_url: Optional custom API base URL. If not provided, uses the production URL.
17
+ """
18
+ self.api_key = api_key
19
+ self.base_url = base_url or "https://api.nebula-app.com"
20
+ self.headers = {
21
+ "Authorization": f"ApiKey {self.api_key}",
22
+ "Content-Type": "application/json"
23
+ }
24
+
25
+ def list_files(self, cluster_id: str, folder_id: str = "ROOT") -> Dict:
26
+ """
27
+ List files and folders in a cluster.
28
+
29
+ Args:
30
+ cluster_id: The ID of the cluster
31
+ folder_id: Optional folder ID to list contents of. Defaults to root folder.
32
+
33
+ Returns:
34
+ Response containing files and folders
35
+ """
36
+ url = f"{self.base_url}/clusters/{cluster_id}/files/list"
37
+ payload = {"parentFolderId": folder_id}
38
+
39
+ response = requests.post(url, headers=self.headers, json=payload)
40
+ response.raise_for_status()
41
+ return response.json()
42
+
43
+ def get_upload_url(self, cluster_id: str, file_name: str, folder_id: str = "ROOT", content_type: Optional[str] = None) -> Dict:
44
+ """
45
+ Get a pre-signed URL for uploading a file.
46
+
47
+ Args:
48
+ cluster_id: The ID of the cluster
49
+ file_name: Name of the file to upload
50
+ folder_id: Optional folder ID to upload to. Defaults to root folder.
51
+ content_type: Optional content type of the file
52
+
53
+ Returns:
54
+ Response containing the upload URL and file ID
55
+ """
56
+ url = f"{self.base_url}/clusters/{cluster_id}/files/upload-url"
57
+ payload = {
58
+ "fileName": file_name,
59
+ "folderId": folder_id
60
+ }
61
+
62
+ if content_type:
63
+ payload["contentType"] = content_type
64
+
65
+ response = requests.post(url, headers=self.headers, json=payload)
66
+ response.raise_for_status()
67
+ return response.json()
68
+
69
+ def upload_file(self, cluster_id: str, file_path: str, folder_id: str = "ROOT", content_type: Optional[str] = None) -> Dict:
70
+ """
71
+ Upload a file to a cluster. Handles getting the presigned URL and uploading the file.
72
+
73
+ Args:
74
+ cluster_id: The ID of the cluster
75
+ file_path: Path to the file to upload
76
+ folder_id: Optional folder ID to upload to. Defaults to root folder.
77
+ content_type: Optional content type of the file
78
+
79
+ Returns:
80
+ Response containing the file information
81
+ """
82
+ file_name = os.path.basename(file_path)
83
+
84
+ # Get upload URL
85
+ upload_response = self.get_upload_url(cluster_id, file_name, folder_id, content_type)
86
+
87
+ # Upload file to presigned URL
88
+ with open(file_path, 'rb') as file:
89
+ upload_url = upload_response['signedUrl']
90
+ file_id = upload_response['fileId']
91
+
92
+ # Use standard requests lib for the upload (different headers for S3)
93
+ upload_headers = {}
94
+ if content_type:
95
+ upload_headers["Content-Type"] = content_type
96
+
97
+ response = requests.put(upload_url, data=file, headers=upload_headers)
98
+ response.raise_for_status()
99
+
100
+ return {
101
+ "fileId": file_id,
102
+ "fileName": upload_response.get('fileName', file_name),
103
+ "status": "completed"
104
+ }
105
+
106
+ def get_download_url(self, cluster_id: str, file_id: str) -> Dict:
107
+ """
108
+ Get a pre-signed URL for downloading a file.
109
+
110
+ Args:
111
+ cluster_id: The ID of the cluster
112
+ file_id: ID of the file to download
113
+
114
+ Returns:
115
+ Response containing the download URL
116
+ """
117
+ url = f"{self.base_url}/clusters/{cluster_id}/files/download-url"
118
+ payload = {"fileId": file_id}
119
+
120
+ response = requests.get(url, headers=self.headers, params=payload)
121
+ response.raise_for_status()
122
+ return response.json()
123
+
124
+ def download_file(self, cluster_id: str, file_id: str, output_path: str) -> str:
125
+ """
126
+ Download a file from a cluster. Handles getting the presigned URL and downloading the file.
127
+
128
+ Args:
129
+ cluster_id: The ID of the cluster
130
+ file_id: ID of the file to download
131
+ output_path: Path where the downloaded file should be saved
132
+
133
+ Returns:
134
+ Path to the downloaded file
135
+ """
136
+ # Get download URL
137
+ download_response = self.get_download_url(cluster_id, file_id)
138
+ download_url = download_response['signedUrl']
139
+
140
+ # Download file
141
+ response = requests.get(download_url, stream=True)
142
+ response.raise_for_status()
143
+
144
+ # If output_path is a directory, use the original filename
145
+ if os.path.isdir(output_path):
146
+ output_path = os.path.join(output_path, download_response.get('fileName', f'file_{file_id}'))
147
+
148
+ with open(output_path, 'wb') as f:
149
+ for chunk in response.iter_content(chunk_size=8192):
150
+ f.write(chunk)
151
+
152
+ return output_path
153
+
154
+ def create_folder(self, cluster_id: str, folder_name: str, parent_folder_id: str = "ROOT") -> Dict:
155
+ """
156
+ Create a new folder in a cluster.
157
+
158
+ Args:
159
+ cluster_id: The ID of the cluster
160
+ folder_name: Name of the folder to create
161
+ parent_folder_id: Optional parent folder ID. Defaults to root folder.
162
+
163
+ Returns:
164
+ Response containing the created folder information
165
+ """
166
+ url = f"{self.base_url}/clusters/{cluster_id}/files/create-folder"
167
+ payload = {
168
+ "folderName": folder_name,
169
+ "parentFolderId": parent_folder_id
170
+ }
171
+
172
+ response = requests.post(url, headers=self.headers, json=payload)
173
+ response.raise_for_status()
174
+ return response.json()
175
+
176
+ def delete_files(self, cluster_id: str, file_ids: List[str]) -> Dict:
177
+ """
178
+ Delete files or folders from a cluster.
179
+
180
+ Args:
181
+ cluster_id: The ID of the cluster
182
+ file_ids: List of file/folder IDs to delete
183
+
184
+ Returns:
185
+ Response containing the deletion results
186
+ """
187
+ url = f"{self.base_url}/clusters/{cluster_id}/files/delete"
188
+ payload = {"fileIds": file_ids}
189
+
190
+ response = requests.post(url, headers=self.headers, json=payload)
191
+ response.raise_for_status()
192
+ return response.json()
193
+
194
+ def move_files(self, cluster_id: str, file_ids: List[str], target_folder_id: str) -> Dict:
195
+ """
196
+ Move files or folders to a different folder.
197
+
198
+ Args:
199
+ cluster_id: The ID of the cluster
200
+ file_ids: List of file/folder IDs to move
201
+ target_folder_id: ID of the destination folder
202
+
203
+ Returns:
204
+ Response containing the move results
205
+ """
206
+ url = f"{self.base_url}/clusters/{cluster_id}/files/move"
207
+ payload = {
208
+ "fileIds": file_ids,
209
+ "targetFolderId": target_folder_id
210
+ }
211
+
212
+ response = requests.post(url, headers=self.headers, json=payload)
213
+ response.raise_for_status()
214
+ return response.json()
215
+
216
+ def rename_file(self, cluster_id: str, file_id: str, new_name: str) -> Dict:
217
+ """
218
+ Rename a file or folder.
219
+
220
+ Args:
221
+ cluster_id: The ID of the cluster
222
+ file_id: ID of the file/folder to rename
223
+ new_name: New name for the file/folder
224
+
225
+ Returns:
226
+ Response containing the rename results
227
+ """
228
+ url = f"{self.base_url}/clusters/{cluster_id}/files/rename"
229
+ payload = {
230
+ "fileId": file_id,
231
+ "newName": new_name
232
+ }
233
+
234
+ response = requests.post(url, headers=self.headers, json=payload)
235
+ response.raise_for_status()
236
+ return response.json()
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.2
2
+ Name: nebula-client
3
+ Version: 0.1.0
4
+ Summary: Python client for the Nebula file system API
5
+ Home-page: https://github.com/nebula/nebula-client-python
6
+ Author: Nebula Team
7
+ Author-email: support@nebula-app.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.6
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: requests>=2.25.0
14
+ Dynamic: author
15
+ Dynamic: author-email
16
+ Dynamic: classifier
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: home-page
20
+ Dynamic: requires-dist
21
+ Dynamic: requires-python
22
+ Dynamic: summary
23
+
24
+ # Nebula Python Client
25
+
26
+ A Python client library for interacting with the Nebula file system API.
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ pip install nebula-client
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ ```python
37
+ from nebula_client import NebulaClient
38
+
39
+ # Initialize the client with your API key
40
+ client = NebulaClient(api_key="your_api_key")
41
+
42
+ # List files in a cluster
43
+ files = client.list_files(cluster_id="your_cluster_id")
44
+
45
+ # Upload a file
46
+ result = client.upload_file(
47
+ cluster_id="your_cluster_id",
48
+ file_path="path/to/your/file.txt"
49
+ )
50
+
51
+ # Download a file
52
+ client.download_file(
53
+ cluster_id="your_cluster_id",
54
+ file_id="file_id",
55
+ output_path="path/to/save"
56
+ )
57
+
58
+ # Create a folder
59
+ folder = client.create_folder(
60
+ cluster_id="your_cluster_id",
61
+ folder_name="New Folder"
62
+ )
63
+
64
+ # Delete files or folders
65
+ client.delete_files(
66
+ cluster_id="your_cluster_id",
67
+ file_ids=["file_id_1", "file_id_2"]
68
+ )
69
+
70
+ # Move files to a different folder
71
+ client.move_files(
72
+ cluster_id="your_cluster_id",
73
+ file_ids=["file_id_1", "file_id_2"],
74
+ target_folder_id="target_folder_id"
75
+ )
76
+
77
+ # Rename a file or folder
78
+ client.rename_file(
79
+ cluster_id="your_cluster_id",
80
+ file_id="file_id",
81
+ new_name="New Name"
82
+ )
83
+ ```
84
+
85
+ ## API Reference
86
+
87
+ ### NebulaClient
88
+
89
+ The main client class for interacting with the Nebula API.
90
+
91
+ #### `__init__(api_key, base_url=None)`
92
+
93
+ Initialize a new client instance.
94
+
95
+ - `api_key` (str): Your Nebula API key
96
+ - `base_url` (str, optional): Custom API base URL. Defaults to production API.
97
+
98
+ #### File Operations
99
+
100
+ - `list_files(cluster_id, folder_id="ROOT")`: List files and folders
101
+ - `get_upload_url(cluster_id, file_name, folder_id="ROOT", content_type=None)`: Get a pre-signed upload URL
102
+ - `upload_file(cluster_id, file_path, folder_id="ROOT", content_type=None)`: Upload a file
103
+ - `get_download_url(cluster_id, file_id)`: Get a pre-signed download URL
104
+ - `download_file(cluster_id, file_id, output_path)`: Download a file
105
+ - `create_folder(cluster_id, folder_name, parent_folder_id="ROOT")`: Create a folder
106
+ - `delete_files(cluster_id, file_ids)`: Delete files/folders
107
+ - `move_files(cluster_id, file_ids, target_folder_id)`: Move files to another folder
108
+ - `rename_file(cluster_id, file_id, new_name)`: Rename a file/folder
109
+
110
+ ## License
111
+
112
+ MIT
@@ -0,0 +1,9 @@
1
+ README.md
2
+ setup.py
3
+ nebula_client/__init__.py
4
+ nebula_client/client.py
5
+ nebula_client.egg-info/PKG-INFO
6
+ nebula_client.egg-info/SOURCES.txt
7
+ nebula_client.egg-info/dependency_links.txt
8
+ nebula_client.egg-info/requires.txt
9
+ nebula_client.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ requests>=2.25.0
@@ -0,0 +1 @@
1
+ nebula_client
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,22 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="nebula-client",
5
+ version="0.1.0",
6
+ packages=find_packages(),
7
+ install_requires=[
8
+ "requests>=2.25.0",
9
+ ],
10
+ author="Nebula Team",
11
+ author_email="support@nebula-app.com",
12
+ description="Python client for the Nebula file system API",
13
+ long_description=open("README.md").read(),
14
+ long_description_content_type="text/markdown",
15
+ url="https://github.com/nebula/nebula-client-python",
16
+ classifiers=[
17
+ "Programming Language :: Python :: 3",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: OS Independent",
20
+ ],
21
+ python_requires=">=3.6",
22
+ )