Skip to main content

Клиент для взаимодействия со СМЭВ3 посредством Адаптера

Подключение

settings:

INSTALLED_APPS = [
    'adapter_client'
]

services:

from adapter_client.adapters.smev.adapter import adapter
from adapter_client.adapters.smev.services.base import AbstractService
from adapter_client.core.domain.model import Message


class ROGDINFService(AbstractService):
    """
    Сервис обрабатывающий сообщения со сведениями о рождении.
    """
    message_type = 'urn://x-artefacts-zags-rogdinf/root/112-51/4.0.1'

    def process_message(self, message: Message):
		# сообщение на которое получен ответ
		reply_to = message.reply.to
        ...

class ApplicationRequestService(AbstractService):
    """
    Сервис обрабатывающий запросы на зачисление (в качестве поставщика).
    """
    message_type = (
        'http://epgu.gosuslugi.ru/concentrator/kindergarten/3.2.1'
    )
    def process_message(self, message: Message):
        # обрабатываем сообщение-запрос
        ...

        # отправляем ответ на запрос
        adapter.send(
            Message(
                # необходимо указать что сообщение является ответом
                reply_to=message,
                # остальные поля сообщения
                ...
            )
        )

apps:

from django.apps.config import AppConfig as AppConfigBase

class AppConfig(AppConfigBase):

    name = __package__

    def ready(self):
        self._init_adapter_client()
        self._register_services()

    def _init_adapter_client(self):
        from adapter_client.config import ProductConfig, set_config
        from tasks import BaseTask

        set_config(ProductConfig(async_task_base=BaseTask))
    
    def _register_services(self):
    from adapter_client.adapters.smev.adapter import adapter
    from .services import ApplicationRequestService, ROGDINFService
    
    adapter.register_service(ApplicationRequestService(), ROGDINFService())

API

Передача сообщения

from adapter_client.adapters.smev.adapter import adapter
from adapter_client.core.domain.model import Message

message = Message(
    message_type='Foo',
    body='<foo>bar</foo>',
    attachments=['http://domain.com/attach1', 'http://domain.com/attach2'],
    test=True
)

adapter.send(message)

Дальнейшая обработка сообщений производится Celery в фоновом режиме.

Получение ответа на сообщение

Ответы на отправленные сообщения собираются периодической задачей и передаются зарегистрированным сервисам.

Работа над пакетом

Подготовка среды разработки

Необходимый набор инструментов:

  • tox — оркестрация окружений и запуск команд
  • tox-uv — для управления окружениями в tox
  • tox-docker — для запуска инфраструктурных сервисов, необходимых в тестах.

Быстрый старт

  1. Установите необходимые инструменты:
uv tool install tox --with tox-uv --with tox-docker
  1. Клонируйте репозиторий и перейдите в директорию проекта:
git clone ssh://git@stash.bars-open.ru:7999/edusmev/adapter-client.git
cd adapter-client
  1. Запустите тесты и проверки:
tox

Проверка качества и форматирование кода

tox -e lint

Metadata

Release files for adapter-client 3.4.0

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

Source distribution (sdist)

Source distribution for adapter-client 3.4.0
File Size Uploaded Provenance Actions
adapter_client-3.4.0.tar.gz 35.2 kB Without provenance Details for adapter_client-3.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for adapter-client 3.4.0
File Interpreter ABI Platform Actions
adapter_client-3.4.0-py3-none-any.whl Python 3 none any Details for adapter_client-3.4.0-py3-none-any.whl

Total release size: 81.3 kB

Release files / adapter_client-3.4.0.tar.gz

Download URL adapter_client-3.4.0.tar.gz
Size 35.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8f0f88bbf3f4a14f05932f8aae080d30dba67b8be3992f54523afdd262c8699b
BLAKE2b-256 checksum
How to use checksums
0fd616b6cc85fb53f09c0e3bd965f59ae7b892509a84c27de937314fea3d293a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.23

Release files / adapter_client-3.4.0-py3-none-any.whl

Download URL adapter_client-3.4.0-py3-none-any.whl
Size 46.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
837d659efedbe04435ccaf7e90f0df233931b290958528a64d4124e6f71b799e
BLAKE2b-256 checksum
How to use checksums
9c0af57c3300e4d3c1fdc087b6e649df1c83f7a63da768ceca1a2f809a3e40a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.23

Security for adapter-client 3.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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