Клиент для взаимодействия с Загрузчиком данных в витрину
Project description
Клиент для взаимодействия с РВД посредством Адаптера
Подключение
settings:
INSTALLED_APPS = [
'uploader_client',
]
apps:
from django.apps import AppConfig as AppConfigBase
class AppConfig(AppConfigBase):
name = __package__
def __setup_uploader_client(self):
import uploader_client
uploader_client.set_config(
uploader_client.configuration.Config(
agent_url='http://localhost:8090',
system_mnemonics='MNSV03',
timeout=1,
request_retries=1,
)
)
def ready(self):
super().ready()
self.__setup_uploader_client()
Использование Proxy API для отправки запросов в РВД
Заменить используемый интерфейс на ProxyAPIInterface и добавить необходимые параметры в конфигурации:
uploader_client.set_config(
...,
RegionalDataMartUploaderConfig(
interface='uploader_client.contrib.rdm.interfaces.rest.ProxyAPIInterface',
cache=<cache>,
url=<url>,
datamart_name=<datamart_name>,
organization_ogrn=<organization_ogrn>,
installation_name=<installation_name>,
installation_id=<installation_id>,
username=<username>,
password=<username>,
)
)
где
- cache - кеш django для хранения токена доступа (например,
caches[DEFAULT_CACHE_ALIAS]
); - url - URL до хоста Datamart Studio;
- datamart_name - мнемоника Витрины;
- organization_ogrn - ОГРН организации, в рамках которой развёрнута Витрина;
- installation_name - имя инсталляции в целевой Витрине;
- installation_id - идентификатор инсталляции;
- username - имя пользователя IAM;
- password - пароль пользователя IAM.
Эмуляция
Заменить используемый интерфейс на эмулирующий запросы:
uploader_client.set_config(
...,
uploader_client.configuration.Config(
interface=(
'uploader_client.contrib.rdm.interfaces.rest'
'.OpenAPIInterfaceEmulation'
)
)
)
Запуск тестов
$ tox
API
Передача сообщения
from uploader_client.adapters import adapter
from uploader_client.interfaces import OpenAPIRequest
class Request(OpenAPIRequest):
def get_url(self):
return 'http://localhost:8090/MNSV03/myedu/api/edu-upload/v1/multipart/csv'
def get_method(self):
return 'post'
def get_files(self) -> List[str]:
return [
Path('files/myedu_schools.csv').as_posix()
]
result = adapter.send(Request())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
uploader-client-0.2.2.tar.gz
(17.8 kB
view details)
Built Distribution
File details
Details for the file uploader-client-0.2.2.tar.gz
.
File metadata
- Download URL: uploader-client-0.2.2.tar.gz
- Upload date:
- Size: 17.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/42.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.5 tqdm/4.66.2 importlib-metadata/6.8.0 keyring/24.2.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2995fa4f2edf828874d9c2af61c3e52fbcf9fb840a3fc271789cff46711bb6d6 |
|
MD5 | 2d96e7a4c39a80309870b6193bec2386 |
|
BLAKE2b-256 | f89e2b529e4e1b8901c7d75ed9ceedc9872851d4c1c4c6883b8149af09dcef32 |
File details
Details for the file uploader_client-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: uploader_client-0.2.2-py3-none-any.whl
- Upload date:
- Size: 22.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/42.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.5 tqdm/4.66.2 importlib-metadata/6.8.0 keyring/24.2.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f57f06d23416bc2e94091950fa4414f6860bd7bc9b3c1753da583cb52adcefa |
|
MD5 | 4bc5084d0e84ed40f16837594fabf10d |
|
BLAKE2b-256 | 62d0c3e6444724389f5f28d7afa0ef8a037ae909a4e1a183117de95f305a77f1 |