Skip to main content

Клиент для взаимодействия с РВД посредством Адаптера

Подключение

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())

Metadata

Release files for uploader-client 0.7.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for uploader-client 0.7.2
File Size Uploaded
uploader_client-0.7.2.tar.gz 21.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for uploader-client 0.7.2
File Interpreter ABI Platform
uploader_client-0.7.2-py3-none-any.whl Python 3 none any Details

Total release size: 48.2 kB

Release files / uploader_client-0.7.2.tar.gz

Download URL uploader_client-0.7.2.tar.gz
Size 21.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1597b9d29fff75314451afff18e4423759998e444ccc5f12b9ba6d7ec400875b
BLAKE2b-256 checksum
How to use checksums
39d543d37a532950a8194df07a8ecbdacf8aae02d9001b5a3a0efc279d2cb6ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.23

Release files / uploader_client-0.7.2-py3-none-any.whl

Download URL uploader_client-0.7.2-py3-none-any.whl
Size 26.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b6808ec2e807addde333c07d443ba5b3be19e0e44199520d072d4f4c2b9b9eb
BLAKE2b-256 checksum
How to use checksums
e8a941031814e790770d9326e6fbcc1496f772c9b38592b5038e7d2c8927f57d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.23

Release history Release notifications | RSS feed

This release

0.7.2 This release

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page