Клиент для взаимодействия с Загрузчиком данных в витрину
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.1.tar.gz
(17.7 kB
view hashes)
Built Distribution
Close
Hashes for uploader_client-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e3e6792b63e7292683aa719b6e2e3aa0832e7be104eaa957d2ad45908bfc432 |
|
MD5 | 179ae2531126987ccad9a2a553f75cae |
|
BLAKE2b-256 | 7ab28e159acbbcae4c34294420095a17f0f08d8ad51c6da930debc69bfde5cb3 |