storage-remote-graphql 0.0.11__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,15 @@
1
+ Metadata-Version: 2.1
2
+ Name: storage-remote-graphql
3
+ Version: 0.0.11
4
+ Home-page: https://github.com/circles-zone/storage-remote-graphql-python-package
5
+ Author: Circles
6
+ Author-email: info@circles.life
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: Other/Proprietary License
9
+ Classifier: Operating System :: OS Independent
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: requests>=2.31.0
12
+ Requires-Dist: python-sdk-remote>=0.0.93
13
+ Requires-Dist: url-remote>=0.0.28
14
+
15
+ This is a package for sharing common methods of storage remote used in different repositories
@@ -0,0 +1,27 @@
1
+ # RemoteCirclesStorage Class
2
+
3
+ The `RemoteCirclesStorage` class provides methods for interacting with the remote storage service.
4
+ It allows you to upload and download files from the remote storage.
5
+
6
+ ## Installation
7
+
8
+ ```bash
9
+ pip install storage-remote
10
+ ```
11
+
12
+ Usage Example:
13
+
14
+ ```python
15
+ from storage_remote.remote_circles_storage import RemoteCirclesStorage
16
+
17
+ created_user_id = entity_type_id = profile_id = 0 # TODO: Replace with your values
18
+
19
+ # Uploading a file
20
+ remote_storage = RemoteCirclesStorage()
21
+ remote_path = remote_storage.put("file.txt", "/local/path/file.txt", created_user_id, entity_type_id, profile_id)
22
+ print(f"Uploaded file to remote path: {remote_path}")
23
+
24
+ # Downloading a file
25
+ downloaded_contents = remote_storage.download("file.txt", "/local/path/file.txt", entity_type_id, profile_id)
26
+ print(f"Downloaded file contents: {downloaded_contents}")
27
+ ```
@@ -0,0 +1,12 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [tool.poetry]
6
+ name = "storage-remote"
7
+ version = "0.0.8"
8
+ description = "project-remote Python Package"
9
+ readme = "README.md"
10
+ authors = [
11
+ "Circlez.ai <info@circlez.ai>",
12
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,27 @@
1
+ import setuptools
2
+
3
+ PACKAGE_NAME = "storage-remote-graphql" # storage-remote-graphql as we might also have storage-remote-restapi
4
+ package_dir = PACKAGE_NAME.replace("-", "_")
5
+
6
+ setuptools.setup(
7
+ name=PACKAGE_NAME, # https://pypi.org/project/storage-remote
8
+ version='0.0.11',
9
+ author="Circles",
10
+ author_email="info@circles.life",
11
+ url=f"https://github.com/circles-zone/storage-remote-graphql-python-package",
12
+ packages=[package_dir],
13
+ package_dir={package_dir: f'{package_dir}/src'},
14
+ package_data={package_dir: ['*.py']},
15
+ long_description="This is a package for sharing common methods of storage remote used in different repositories",
16
+ long_description_content_type='text/markdown',
17
+ classifiers=[
18
+ "Programming Language :: Python :: 3",
19
+ "License :: Other/Proprietary License",
20
+ "Operating System :: OS Independent",
21
+ ],
22
+ install_requires=[
23
+ "requests>=2.31.0",
24
+ "python-sdk-remote>=0.0.93",
25
+ "url-remote>=0.0.28"
26
+ ]
27
+ )
@@ -0,0 +1,79 @@
1
+ import requests
2
+ from python_sdk_remote.utilities import our_get_env
3
+ from url_remote.component_name_enum import ComponentName
4
+ from url_remote.entity_name_enum import EntityName
5
+ from url_remote.url_circlez import OurUrl
6
+
7
+ # TODO Please replace all strings and Magic Numbers such as "graphql" to const enum
8
+ version = 1
9
+ action = "graphql"
10
+ BRAND_NAME = our_get_env('BRAND_NAME')
11
+ ENVIRONMENT_NAME = our_get_env('ENVIRONMENT_NAME')
12
+
13
+ # TODO: use logger
14
+ class RemoteStorage:
15
+ def __init__(self) -> None:
16
+ self.url = OurUrl.endpoint_url(
17
+ brand_name=BRAND_NAME, environment_name=ENVIRONMENT_NAME,
18
+ component_name=ComponentName.GROUP_PROFILE.value,
19
+ entity_name=EntityName.GROUP_PROFILE.value, version=version,
20
+ action_name=action)
21
+
22
+ def put(self, *, filename: str, local_path: str, created_user_id: int, entity_type_id: int, profile_id: int) -> str:
23
+ """
24
+ Uploads a file to the remote storage and returns the file's remote path.
25
+
26
+ :param filename: The name of the file.
27
+ :param local_path: The local path to the file on your system.
28
+ :param created_user_id: The ID of the user who created the file.
29
+ :param entity_type_id: The ID of the entity type associated with the file.
30
+ :param profile_id: The ID of the profile associated with the file.
31
+ :return: The remote path of the uploaded file.
32
+ """
33
+ put_query = f"""
34
+ mutation {{
35
+ put(
36
+ filename: "{filename}",
37
+ local_path: "{local_path}",
38
+ created_user_id: "{created_user_id}",
39
+ entity_type_id: "{entity_type_id}",
40
+ profile_id: "{profile_id}"
41
+ )
42
+ }}"""
43
+ response = requests.post(self.url, json={"query": put_query})
44
+
45
+ response_data = response.json().get("data", {})
46
+ if "errors" in response_data:
47
+ raise Exception(response_data["errors"][0]["message"])
48
+ elif "put" not in response_data:
49
+ raise Exception("Unknown error while uploading file", response_data)
50
+ else:
51
+ return response_data["put"]
52
+
53
+ def download(self, *, filename: str, local_path: str, entity_type_id: int, profile_id: int) -> str:
54
+ """
55
+ Downloads a file from the remote storage and returns the file's contents.
56
+
57
+ :param filename: The name of the file to download.
58
+ :param entity_type_id: The ID of the entity type associated with the file.
59
+ :param profile_id: The ID of the profile associated with the file.
60
+ :param local_path: The local path where the downloaded file should be saved.
61
+ :return: The contents of the downloaded file.
62
+ """
63
+ download_query = f"""
64
+ mutation {{
65
+ download(
66
+ filename: "{filename}",
67
+ entity_type_id: "{entity_type_id}",
68
+ profile_id: "{profile_id}",
69
+ local_path: "{local_path}"
70
+ )
71
+ }}
72
+ """
73
+ response = requests.post(self.url, json={"query": download_query})
74
+
75
+ response_data = response.json().get("data", {})
76
+ if "errors" in response_data:
77
+ raise Exception(response_data["errors"][0]["message"])
78
+
79
+ return response_data["download"]
@@ -0,0 +1,15 @@
1
+ Metadata-Version: 2.1
2
+ Name: storage-remote-graphql
3
+ Version: 0.0.11
4
+ Home-page: https://github.com/circles-zone/storage-remote-graphql-python-package
5
+ Author: Circles
6
+ Author-email: info@circles.life
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: Other/Proprietary License
9
+ Classifier: Operating System :: OS Independent
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: requests>=2.31.0
12
+ Requires-Dist: python-sdk-remote>=0.0.93
13
+ Requires-Dist: url-remote>=0.0.28
14
+
15
+ This is a package for sharing common methods of storage remote used in different repositories
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ setup.py
4
+ storage_remote_graphql.egg-info/PKG-INFO
5
+ storage_remote_graphql.egg-info/SOURCES.txt
6
+ storage_remote_graphql.egg-info/dependency_links.txt
7
+ storage_remote_graphql.egg-info/requires.txt
8
+ storage_remote_graphql.egg-info/top_level.txt
9
+ storage_remote_graphql/src/__init__.py
10
+ storage_remote_graphql/src/remote_storage.py
@@ -0,0 +1,3 @@
1
+ requests>=2.31.0
2
+ python-sdk-remote>=0.0.93
3
+ url-remote>=0.0.28
@@ -0,0 +1 @@
1
+ storage_remote_graphql