url-remote 0.0.51__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,16 @@
1
+ Metadata-Version: 2.1
2
+ Name: url-remote
3
+ Version: 0.0.51
4
+ Home-page: https://github.com/circles-zone/url-remote-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: python-dotenv>=1.0.0
12
+ Requires-Dist: pytest>=7.4.1
13
+ Requires-Dist: database-without-orm-local>=0.0.79
14
+ Requires-Dist: logger-local>=0.0.59
15
+
16
+ URL Remote
@@ -0,0 +1,14 @@
1
+ # Usage:
2
+
3
+ `pip install url-remote`
4
+
5
+ ```python
6
+ from url_local.url_circlez import UrlCirclez
7
+
8
+ UrlCirclez.endpoint_url(brand_name = BrandName, environment_name = EnvironmentName,
9
+ ComponentName.GENDER_DETECTION.value, EntityName.GENDER_DETECTION.value, ANALYZE_FACIAL_IMAGE_API_VERSION[EnvironmentName],
10
+ ActionName.ANALYZE_FACIAL_IMAGE.value)
11
+ # >>> "https://353sstqmj5.execute-api.us-east-1.amazonaws.com/play1/api/v1/gender-detection/analyzeFacialImage"
12
+ ```
13
+
14
+ Includes also domain related functions<br>
@@ -0,0 +1,12 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [tool.poetry]
6
+ name = "url-remote"
7
+ version = "0.0.32"
8
+ description = "url-local 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,31 @@
1
+ import setuptools
2
+
3
+ PACKAGE_NAME = "url-remote"
4
+ package_dir = PACKAGE_NAME.replace("-", "_")
5
+
6
+ setuptools.setup(
7
+ name=PACKAGE_NAME,
8
+ version='0.0.51', # https://pypi.org/project/url-remote
9
+
10
+ author="Circles",
11
+ author_email="info@circles.life",
12
+ url=f"https://github.com/circles-zone/{PACKAGE_NAME}-python-package",
13
+ packages=[package_dir],
14
+ package_dir={package_dir: f'{package_dir}/src'},
15
+ package_data={package_dir: ['*.py']},
16
+ long_description="URL Remote",
17
+ long_description_content_type='text/markdown',
18
+ classifiers=[
19
+ "Programming Language :: Python :: 3",
20
+ "License :: Other/Proprietary License",
21
+ "Operating System :: OS Independent",
22
+ ],
23
+ install_requires=[
24
+ "python-dotenv>=1.0.0",
25
+ "pytest>=7.4.1",
26
+ "database-without-orm-local>=0.0.79",
27
+ # TODO Can we swtich to logger-remote?
28
+ "logger-local>=0.0.59" ,
29
+ # "queue-local>=0.0.13"
30
+ ]
31
+ )
File without changes
@@ -0,0 +1,51 @@
1
+ from enum import Enum
2
+
3
+ # TODO Based on https://restfulapi.net/resource-naming/ we should change all APIs to xxx-yy gradually
4
+
5
+ # Rename to HttpUrlActionName
6
+ class ActionName(Enum):
7
+ # Authentication
8
+ LOGIN = "login" # No need to authenticate before, we should add API KEY and impersonate
9
+ VALIDATE_USER_JWT = 'validate-user-jwt' # No need to authenticate before, we should add API KEY and impersonate
10
+
11
+ # Event
12
+ GET_EVENT_BY_ID = "getEventById"
13
+ CREATE_EVENT = "createEvent"
14
+ UPDATE_EVENT_BY_ID = "updateEventById"
15
+ DELETE_EVENT_BY_ID = "deleteEventById"
16
+
17
+ # Gender-detection
18
+ ANALYZE_FACIAL_IMAGE = "analyzeFacialImage"
19
+ # TODO Repace it with GENDER_DETECTION_API_VERSION_DICT[environment_name][ANALYZE_FACIAL_IMAGE]
20
+ GENDER_DETECTION_API_VERSION = 1
21
+
22
+ # Group
23
+ GET_ALL_GROUPS = "getAllGroups"
24
+ GET_GROUP_BY_NAME = "getGroupByName"
25
+ GET_GROUP_BY_ID = "getGroupById"
26
+ CREATE_GROUP = "createGroup"
27
+ UPDATE_GROUP = "updateGroup"
28
+ DELETE_GROUP = "deleteGroup"
29
+
30
+ # Logger
31
+ ADD_LOG = "add"
32
+
33
+ # Storage
34
+ PUT = "put"
35
+ DOWNLOAD = "download"
36
+
37
+ # Timeline
38
+ TIMELINE = "timeline"
39
+
40
+ # User
41
+ CREATE_USER = "createUser" # No need to authenticate before, we should add API KEY and impersonate
42
+ UPDATE_USER = "updateUser"
43
+
44
+ # Group-profile
45
+ CREATE_GROUP_PROFILE = "createGroupProfile"
46
+ DELETE_GROUP_PROFILE = "deleteGroupProfile"
47
+ GET_GROUP_PROFILE = "getGroupProfileByGroupIdProfileId"
48
+
49
+ # SmartLink
50
+ EXECUTE_SMARTLINK_BY_IDENTIFIER = "executeSmartLinkByIdentifier" # Used when not logged in user press on a SmartLink
51
+ GET_SMARTLINK_DATA_BY_IDENTIFIER = "getSmartLinkDataByIdentifier" # Who is using it?
@@ -0,0 +1,5 @@
1
+ from enum import Enum
2
+
3
+
4
+ class BrandName(Enum):
5
+ CIRCLEZ = 'Circlez'
@@ -0,0 +1,17 @@
1
+ from enum import Enum
2
+
3
+ # Order by a..z of component name
4
+ # Should in in sync with https://github.com/circles-zone/url-remote-typescript-package/blob/dev/src/component-name.enum.ts
5
+ class ComponentName(Enum):
6
+ AUTHENTICATION = "auth" # Used by User Context both for login and validateJwt
7
+ EVENT = "event"
8
+ GENDER_DETECTION = "gender-detection"
9
+ GROUP = "group"
10
+ GROUP_PROFILE = "group-profile"
11
+ LOGGER = "logger"
12
+ MARKETPLACE_GOODS = "marketplace-goods"
13
+ STORAGE = "storage"
14
+ TIMELINE = "timeline"
15
+ USER_REGISTRATION = "user-registration"
16
+ SMARTLINK = "smartlink"
17
+
@@ -0,0 +1,15 @@
1
+ from enum import Enum
2
+
3
+ # Sorted by A..Z of Entity Type
4
+ class EntityName(Enum):
5
+ AUTH_LOGIN = "auth"
6
+ EVENT = "event"
7
+ GENDER_DETECTION = "gender-detection"
8
+ GROUP = "group"
9
+ GROUP_PROFILE = "group-profile"
10
+ LOGGER = "logger"
11
+ MARKETPLACE_GOODS = "marketplace-goods"
12
+ STORAGE = "storage"
13
+ TIMELINE = "timeline"
14
+ USER_REGISTRATION = "user-registration"
15
+ SMARTLINK = "smartlink"
@@ -0,0 +1,7 @@
1
+ from enum import Enum
2
+
3
+
4
+ class EnvironmentName(Enum):
5
+ LOCAL = 'local'
6
+ PLAY1 = 'play1'
7
+ DVLP1 = 'dvlp1'
@@ -0,0 +1,180 @@
1
+ import urllib.parse
2
+
3
+ from dotenv.main import load_dotenv
4
+
5
+ from .brand_name_enum import BrandName
6
+ from .environment_name_enum import EnvironmentName
7
+
8
+ load_dotenv()
9
+
10
+
11
+ class OurUrl:
12
+ # static dict for domain mapping
13
+ domain_mapping = {
14
+ 'auth.dvlp1.circ.zone': 'i4wp5o2381.execute-api.us-east-1.amazonaws.com',
15
+ 'auth.play1.circ.zone': 'nmxjjpyrv9.execute-api.us-east-1.amazonaws.com',
16
+ 'user-registration.dvlp1.circ.zone': 'lczo7l194b.execute-api.us-east-1.amazonaws.com',
17
+ 'user-registration.play1.circ.zone': 't3tnkh0r64.execute-api.us-east-1.amazonaws.com',
18
+ 'gender-detection.dvlp1.circ.zone': '353sstqmj5.execute-api.us-east-1.amazonaws.com',
19
+ 'gender-detection.play1.circ.zone': '353sstqmj5.execute-api.us-east-1.amazonaws.com',
20
+ 'group.dvlp1.circ.zone': '2mvpuqbhh1.execute-api.us-east-1.amazonaws.com',
21
+ 'group.play1.circ.zone': 'ly0jegwkib.execute-api.us-east-1.amazonaws.com',
22
+ 'group-profile.dvlp1.circ.zone': 'dot2ynvxwl.execute-api.us-east-1.amazonaws.com',
23
+ 'group-profile.play1.circ.zone': 'y4abphdp9l.execute-api.us-east-1.amazonaws.com',
24
+ 'marketplace-goods.play1.circ.zone': 'vcev0rrt01.execute-api.us-east-1.amazonaws.com',
25
+ 'logger.dvlp1.circ.zone': 't91y4nxsye.execute-api.us-east-1.amazonaws.com',
26
+ 'logger.play1.circ.zone': 'fsujmjyfal.execute-api.us-east-1.amazonaws.com',
27
+ #'event.play1.circ.zone': 'p89mpsr5m1.execute-api.us-east-1.amazonaws.com',
28
+ #'event.play1.circ.zone': 'x8ql0j9cwf.execute-api.us-east-1.amazonaws.com',
29
+ 'event.play1.circ.zone': 'gskq98jtkf.execute-api.us-east-1.amazonaws.com',
30
+ 'event.dvlp1.circ.zone': 'wbq5liyk63.execute-api.us-east-1.amazonaws.com',
31
+ 'storage.play1.circ.zone': 'wbq5liyk63.execute-api.us-east-1.amazonaws.com', # TODO update
32
+ 'storage.dvlp1.circ.zone': 'wbq5liyk63.execute-api.us-east-1.amazonaws.com', # TODO update
33
+ 'smartlink.play1.circ.zone': 'wagdetw4hk.execute-api.us-east-1.amazonaws.com/dev'
34
+ # 'websocket.dvlp1.circ.zone': 'ws://23.22.217.199:8080',
35
+ # 'websocket.play1.circ.zone': 'ws://23.22.217.199:8080',
36
+ }
37
+
38
+ @staticmethod
39
+ def _base_domain(brand_name: str, environment_name: str) -> str:
40
+ """
41
+ Return the base domain based on the input environment.
42
+
43
+ Parameters:
44
+ brand_name (string): Actual brand name.
45
+ environment_name (string): Desired environment name
46
+
47
+ Return:
48
+ A string that represents the base domain of a given environment name.
49
+ """
50
+ if brand_name == BrandName.CIRCLEZ.value:
51
+ if environment_name == EnvironmentName.DVLP1.value:
52
+ return 'dvlp1.circ.zone'
53
+
54
+ elif environment_name == EnvironmentName.PLAY1.value:
55
+ return 'play1.circ.zone'
56
+ elif environment_name == EnvironmentName.LOCAL:
57
+ return 'localhost'
58
+ else:
59
+ message = 'Invalid ENVIRONMENT_NAME="' + \
60
+ environment_name + '" in BRAND_NAME=Circlez'
61
+ print(message)
62
+ raise ValueError(message)
63
+ else:
64
+ raise ValueError('Invalid BRAND_NAME "' + brand_name + '"')
65
+
66
+ @staticmethod
67
+ def app_url(brand_name: str, environment_name: str) -> str:
68
+ if brand_name == BrandName.CIRCLEZ.value:
69
+ if environment_name == EnvironmentName.LOCAL.value:
70
+ # TODO: Align it with TypeScript default and environment variable.
71
+ return "localhost:5173"
72
+ elif environment_name == EnvironmentName.PLAY1.value:
73
+ return "http://circles-user-reactjs-frontend.play1.circ.zone.s3-website-us-east-1.amazonaws.com/"
74
+ elif environment_name == EnvironmentName.DVLP1.value:
75
+ return "https://d2f9rjvjaf75eo.cloudfront.net/"
76
+ else:
77
+ raise ValueError('Invalid environment name')
78
+ return 'unknown'
79
+
80
+ @staticmethod
81
+ def endpoint_url(brand_name: str, environment_name: str, component_name: str, entity_name: str, version: int, action_name: str,
82
+ path_parameters=None, query_parameters=None) -> str:
83
+ """
84
+ Function that generate a URL with the format:
85
+ "https://{direct_domain}/{environment_name}/api/v{version}/{entity}/{action}/{parameters}"
86
+
87
+ Parameters:
88
+ brand_name (string): Actual brand name.
89
+ environment_name (string): Desired environment name.
90
+ component (string): Desired component.
91
+ entity (string): Desired entity.
92
+ version (integer): Version.
93
+ action (string): Desired action.
94
+ path_parameters (dictionary): A dictionary representing the path parameters with their values.
95
+ query_parameters (dictionary): A dictionary representing the query parameters with their values.
96
+
97
+ Return:
98
+ A string that represent the desired endpoint url based on input.
99
+
100
+ """
101
+ base_url = OurUrl._base_url_builder(
102
+ component_name, brand_name, environment_name, version, entity_name, action_name)
103
+
104
+ if path_parameters:
105
+ path_params_string = '/'.join([urllib.parse.quote_plus(str(val))
106
+ for val in path_parameters.values()])
107
+ url_with_path_params = f"{base_url}/{path_params_string}"
108
+ else:
109
+ url_with_path_params = base_url
110
+
111
+ if query_parameters:
112
+ query_params_string = '&'.join(
113
+ [f"{urllib.parse.quote_plus(key)}={urllib.parse.quote_plus(str(value))}" for key, value in
114
+ query_parameters.items()])
115
+ url_with_query_params = f"{url_with_path_params}?{query_params_string}"
116
+ else:
117
+ url_with_query_params = url_with_path_params
118
+
119
+ new_url = OurUrl._convert_to_direct_url(url_with_query_params)
120
+ return new_url
121
+
122
+ @staticmethod
123
+ def _base_url_builder(component_name: str, brand_name: str, environment_name: str, version: int, entity_name: str,
124
+ action_name: str) -> str:
125
+ """
126
+ Function that generate the basic direct url with the format:
127
+ "https://{direct_domain}/{environment_name}/api/v{version}/{entity}/{action}"
128
+
129
+ Parameters:
130
+ brand_name (string): Actual brand name.
131
+ environment_name (string): Desired environment name.
132
+ component (string): Desired component.
133
+ version (integer): Version.
134
+ action (string): Desired action.
135
+
136
+ Return:
137
+ A string representing direct url after mapping out the domain.
138
+ """
139
+ base_domain = f"{component_name}.{OurUrl._base_domain(brand_name, environment_name)}"
140
+
141
+ try:
142
+ direct_domain = OurUrl.domain_mapping[base_domain]
143
+ except KeyError:
144
+ # Handle the case when the base_domain is not found in the domain_mapping
145
+ raise ValueError(
146
+ f"Domain mapping not found for '{base_domain}' in brand '{brand_name}' and environment '{environment_name}'")
147
+
148
+ direct_url = f"https://{direct_domain}/{environment_name}/api/v{version}/{entity_name}/{action_name}"
149
+ return direct_url
150
+
151
+ @staticmethod
152
+ def _convert_to_direct_url(direct_url: str, path_parameters=None, query_parameters=None) -> str:
153
+ """
154
+ Function that conver the base url to direct url.
155
+
156
+ Parameters:
157
+ direct_url (string): The direct url after mapping the domain from the base domain.
158
+ path_parameters (dictionary): A dictionary representing desired path parameters.
159
+ query_parameters (dictionary): A dictionary representing desired query parameters.
160
+
161
+ Return:
162
+ A string representing the final url after adding all the parameters to the direct url.
163
+ """
164
+ if path_parameters:
165
+ for key, value in path_parameters.items():
166
+ direct_url = direct_url.replace(f"{{{key}}}", value)
167
+
168
+ path_params_string = '/'.join(
169
+ urllib.parse.quote_plus(str(value)) for value in path_parameters.values()) if path_parameters else ''
170
+ url_with_path_params = f"{direct_url}/{path_params_string}" if path_params_string else direct_url
171
+
172
+ if query_parameters:
173
+ query_params_string = '&'.join(
174
+ f"{urllib.parse.quote_plus(str(key))}={urllib.parse.quote_plus(str(value))}" for key, value in
175
+ query_parameters.items())
176
+ url_with_query_params = f"{url_with_path_params}?{query_params_string}"
177
+ else:
178
+ url_with_query_params = url_with_path_params
179
+
180
+ return url_with_query_params
@@ -0,0 +1,16 @@
1
+ Metadata-Version: 2.1
2
+ Name: url-remote
3
+ Version: 0.0.51
4
+ Home-page: https://github.com/circles-zone/url-remote-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: python-dotenv>=1.0.0
12
+ Requires-Dist: pytest>=7.4.1
13
+ Requires-Dist: database-without-orm-local>=0.0.79
14
+ Requires-Dist: logger-local>=0.0.59
15
+
16
+ URL Remote
@@ -0,0 +1,15 @@
1
+ README.md
2
+ pyproject.toml
3
+ setup.py
4
+ url_remote.egg-info/PKG-INFO
5
+ url_remote.egg-info/SOURCES.txt
6
+ url_remote.egg-info/dependency_links.txt
7
+ url_remote.egg-info/requires.txt
8
+ url_remote.egg-info/top_level.txt
9
+ url_remote/src/__init__.py
10
+ url_remote/src/action_name_enum.py
11
+ url_remote/src/brand_name_enum.py
12
+ url_remote/src/component_name_enum.py
13
+ url_remote/src/entity_name_enum.py
14
+ url_remote/src/environment_name_enum.py
15
+ url_remote/src/url_circlez.py
@@ -0,0 +1,4 @@
1
+ python-dotenv>=1.0.0
2
+ pytest>=7.4.1
3
+ database-without-orm-local>=0.0.79
4
+ logger-local>=0.0.59
@@ -0,0 +1 @@
1
+ url_remote