ul-pii-sdk 3.1.2__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,22 @@
1
+ Metadata-Version: 2.1
2
+ Name: ul-pii-sdk
3
+ Version: 3.1.2
4
+ Summary: Pii sdk
5
+ Author: Unic-lab
6
+ License: MIT
7
+ Platform: any
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python
11
+ Classifier: Programming Language :: Python :: 3.6
12
+ Classifier: Programming Language :: Python :: 3.7
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Operating System :: OS Independent
16
+ Description-Content-Type: text/markdown
17
+
18
+ # pii
19
+
20
+ Сервис учета пользователей, организаций, групп доступов для всего проекта
21
+
22
+ Отделен базой данных от всех сервисов, для выделения в отдельный защищенный кластер баз данных
@@ -0,0 +1,5 @@
1
+ # pii
2
+
3
+ Сервис учета пользователей, организаций, групп доступов для всего проекта
4
+
5
+ Отделен базой данных от всех сервисов, для выделения в отдельный защищенный кластер баз данных
@@ -0,0 +1,8 @@
1
+ from pii_sdk.pii_sdk import PiiSdk
2
+ from pii_sdk.pii_sdk_config import PiiSdkConfig
3
+
4
+
5
+ __all__ = (
6
+ "PiiSdk",
7
+ "PiiSdkConfig",
8
+ )
@@ -0,0 +1,15 @@
1
+ class PiiAbstractError(Exception):
2
+ def __init__(self, message: str, error: Exception, status_code: int) -> None:
3
+ assert isinstance(message, str), f'message must be str. "{type(message).__name__}" was given'
4
+ assert isinstance(error, Exception), f'error must be Exception. "{type(error).__name__}" was given'
5
+ super(PiiAbstractError, self).__init__(f'{message} :: {str(error)} :: {status_code})')
6
+ self.status_code = status_code
7
+ self.error = error
8
+
9
+
10
+ class PiiRequestError(PiiAbstractError):
11
+ pass
12
+
13
+
14
+ class PiiResponseError(PiiAbstractError):
15
+ pass
@@ -0,0 +1,39 @@
1
+ import json
2
+ from uuid import UUID
3
+ from typing import List
4
+
5
+ from ul_api_utils.internal_api.internal_api import InternalApi
6
+ from ul_api_utils.internal_api.internal_api_response import InternalApiResponse
7
+
8
+ from pii_sdk.pii_sdk_config import PiiSdkConfig
9
+ from pii_sdk.types.api_ogranization import ApiOrganization
10
+ from pii_sdk.utils.internal_api_error_handler import internal_api_error_handler
11
+
12
+
13
+ class PiiSdk:
14
+ def __init__(self, config: PiiSdkConfig) -> None:
15
+ self._config = config
16
+ self._api = InternalApi(self._config.api_url, default_auth_token=self._config.api_token)
17
+
18
+ @internal_api_error_handler
19
+ def get_organization_by_id(self, organization_id: UUID) -> InternalApiResponse[ApiOrganization]:
20
+ return self._api.request_get(f'/organizations/{organization_id}').typed(ApiOrganization).check()
21
+
22
+ @internal_api_error_handler
23
+ def get_organization_by_name(self, organization_name: str) -> InternalApiResponse[List[ApiOrganization]]: # type: ignore
24
+ return self._api.request_get(
25
+ '/organizations',
26
+ q={"filter": '[{"name":"organization_data","op":"has","val":{"name":"name","op": "==","val": "%s"}}]' % organization_name},
27
+ ).typed(List[ApiOrganization]).check()
28
+
29
+ @internal_api_error_handler
30
+ def get_organizations_by_id_list(self, organization_ids: List[UUID]) -> InternalApiResponse[List[ApiOrganization]]: # type: ignore
31
+ organization_ids_str = json.dumps([str(org_id) for org_id in organization_ids])
32
+ return self._api.request_get(
33
+ '/organizations',
34
+ q={"filter": '[{"name":"id","op": "in","val": %s}]' % organization_ids_str},
35
+ ).typed(List[ApiOrganization]).check()
36
+
37
+ @internal_api_error_handler
38
+ def get_organizations(self) -> InternalApiResponse[List[ApiOrganization]]: # type: ignore
39
+ return self._api.request_get('/organizations').typed(List[ApiOrganization]).check()
@@ -0,0 +1,6 @@
1
+ from typing import NamedTuple
2
+
3
+
4
+ class PiiSdkConfig(NamedTuple):
5
+ api_url: str
6
+ api_token: str
File without changes
File without changes
@@ -0,0 +1,24 @@
1
+ from enum import Enum
2
+ from typing import Any, Dict, List, Optional
3
+
4
+ from pytz import all_timezones
5
+ from ul_api_utils.api_resource.api_response_payload_alias import ApiBaseUserModelPayloadResponse
6
+ from pydantic import BaseModel
7
+
8
+
9
+ TimeZonesEnum = Enum('tz_type', {tz_name.lower().replace('/', '_'): tz_name for tz_name in all_timezones}) # type: ignore
10
+
11
+
12
+ class ApiOrganizationData(BaseModel):
13
+ admin_notes: Optional[str]
14
+ name: str
15
+ available_permissions: List[int]
16
+ timezones: List[TimeZonesEnum]
17
+
18
+
19
+ class ApiOrganization(ApiBaseUserModelPayloadResponse):
20
+ admin_notes: Optional[str]
21
+ organization_data: ApiOrganizationData
22
+ frontend_settings: Dict[str, Any]
23
+ teams_count: int
24
+ users_count: int
File without changes
@@ -0,0 +1,27 @@
1
+ from functools import wraps
2
+ from typing import Any, Callable, Dict, TypeVar, cast
3
+
4
+ from ul_api_utils.errors import Client4XXInternalApiError, Server5XXInternalApiError, \
5
+ ResponseJsonInternalApiError, NotFinishedRequestInternalApiError
6
+
7
+ from pii_sdk.errors import PiiRequestError, PiiResponseError
8
+
9
+ TKwargs = TypeVar('TKwargs', bound=Dict[str, Any])
10
+
11
+ TFn = TypeVar('TFn', bound=Callable) # type: ignore
12
+
13
+
14
+ def internal_api_error_handler(api_method_fn: TFn) -> TFn:
15
+ @wraps(api_method_fn)
16
+ def error_handler_wrapper(*args: Any, **kwargs: TKwargs) -> TFn:
17
+ try:
18
+ return api_method_fn(*args, **kwargs)
19
+ except Client4XXInternalApiError as e:
20
+ raise PiiRequestError(str(e), e, e.status_code)
21
+ except Server5XXInternalApiError as e:
22
+ raise PiiResponseError(str(e), e, e.status_code)
23
+ except ResponseJsonInternalApiError as e:
24
+ raise PiiResponseError(str(e), e, 500)
25
+ except NotFinishedRequestInternalApiError as e:
26
+ raise PiiResponseError("SERVICE TEMPORARY UNAVAIBLE", e, 503)
27
+ return cast(TFn, error_handler_wrapper)
@@ -0,0 +1,54 @@
1
+ [mypy]
2
+ mypy_path = ul_iot_account_data_reception/
3
+ python_version = 3.8
4
+ cache_dir = .tmp/mypy-cache
5
+ ignore_missing_imports = True
6
+ follow_imports = silent
7
+ follow_imports_for_stubs = True
8
+ disallow_any_generics = True
9
+ disallow_untyped_defs = True
10
+ disallow_incomplete_defs = True
11
+ check_untyped_defs = True
12
+ disallow_untyped_decorators = False
13
+ no_implicit_optional = True
14
+ strict_optional = False
15
+ warn_unused_ignores = True
16
+ warn_no_return = True
17
+ show_none_errors = True
18
+ ignore_errors = False
19
+ allow_redefinition = False
20
+ strict_equality = True
21
+ show_error_context = False
22
+ show_column_numbers = True
23
+ warn_redundant_casts = True
24
+
25
+ [flake8]
26
+ exclude =
27
+ .git
28
+ .tmp
29
+ .var
30
+ ignore =
31
+ D100
32
+ D101
33
+ D102
34
+ D103
35
+ D104
36
+ D107
37
+ D105
38
+ D106
39
+ D200
40
+ D400
41
+ D413
42
+ E501
43
+ SF01
44
+ T484
45
+ W503
46
+ E402
47
+ N815
48
+ N805
49
+ B006
50
+
51
+ [egg_info]
52
+ tag_build =
53
+ tag_date = 0
54
+
@@ -0,0 +1,45 @@
1
+ from os import path
2
+ from setuptools import setup, find_packages
3
+
4
+ HERE = path.abspath(path.dirname(__file__))
5
+
6
+ with open(path.join(HERE, 'README.md'), encoding='utf-8') as f:
7
+ long_description = f.read()
8
+
9
+
10
+ setup(
11
+ name='ul-pii-sdk',
12
+ version='3.1.2',
13
+ description='Pii sdk',
14
+ author='Unic-lab',
15
+ long_description=long_description,
16
+ long_description_content_type="text/markdown",
17
+ package_data={
18
+ "pii_sdk": [
19
+ 'py.typed',
20
+ ],
21
+ },
22
+ packages=find_packages(include=['pii_sdk*']),
23
+ include_package_data=True,
24
+ license="MIT",
25
+ classifiers=[
26
+ "Intended Audience :: Developers",
27
+ "License :: OSI Approved :: MIT License",
28
+ "Programming Language :: Python",
29
+ "Programming Language :: Python :: 3.6",
30
+ "Programming Language :: Python :: 3.7",
31
+ "Programming Language :: Python :: 3.8",
32
+ "Programming Language :: Python :: 3.9",
33
+ "Operating System :: OS Independent",
34
+ ],
35
+ platforms='any',
36
+ install_requires=[
37
+ 'ul-api-utils>=7.2.8',
38
+ # "bcrypt==3.2.0",
39
+ # "passlib==1.7.4",
40
+ # "ul-notification-sdk-iot-account==2.2.3",
41
+ # 'ul-api-utils==7.2.8',
42
+ # 'ul-py-tool==1.15.20',
43
+ # 'ul-db-utils==2.10.7',
44
+ ],
45
+ )
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.1
2
+ Name: ul-pii-sdk
3
+ Version: 3.1.2
4
+ Summary: Pii sdk
5
+ Author: Unic-lab
6
+ License: MIT
7
+ Platform: any
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python
11
+ Classifier: Programming Language :: Python :: 3.6
12
+ Classifier: Programming Language :: Python :: 3.7
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Operating System :: OS Independent
16
+ Description-Content-Type: text/markdown
17
+
18
+ # pii
19
+
20
+ Сервис учета пользователей, организаций, групп доступов для всего проекта
21
+
22
+ Отделен базой данных от всех сервисов, для выделения в отдельный защищенный кластер баз данных
@@ -0,0 +1,17 @@
1
+ README.md
2
+ setup.cfg
3
+ setup.py
4
+ pii_sdk/__init__.py
5
+ pii_sdk/errors.py
6
+ pii_sdk/pii_sdk.py
7
+ pii_sdk/pii_sdk_config.py
8
+ pii_sdk/py.typed
9
+ pii_sdk/types/__init__.py
10
+ pii_sdk/types/api_ogranization.py
11
+ pii_sdk/utils/__init__.py
12
+ pii_sdk/utils/internal_api_error_handler.py
13
+ ul_pii_sdk.egg-info/PKG-INFO
14
+ ul_pii_sdk.egg-info/SOURCES.txt
15
+ ul_pii_sdk.egg-info/dependency_links.txt
16
+ ul_pii_sdk.egg-info/requires.txt
17
+ ul_pii_sdk.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ ul-api-utils>=7.2.8
@@ -0,0 +1 @@
1
+ pii_sdk