Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
perxis-python
Manage
Activity
Members
Labels
Plan
Issues
3
Issue boards
Milestones
Wiki
Custom issue tracker
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
perxis
perxis-python
Commits
5a50ef8f
Commit
5a50ef8f
authored
1 year ago
by
Podosochnyy Maxim
Browse files
Options
Downloads
Patches
Plain Diff
Добавлен базовый класс для сервиса расширений и модуль для установки зависимостей расширения
parent
515465ca
No related branches found
No related tags found
1 merge request
!33
Добавлен базовый класс для сервиса расширений и модуль для установки зависимостей расширения
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+79
-0
79 additions, 0 deletions
README.md
with
79 additions
and
0 deletions
README.md
+
79
−
0
View file @
5a50ef8f
# perxis-python
## Расширения
### Пример подключения расширения к Perxis
...
### Пример написания сервиса расширений
```
python
from
perxis.extensions.extension_service
import
ExtensionService
from
perxis.roles
import
roles_pb2
from
perxis.common
import
common_pb2
from
perxis.clients
import
clients_pb2
from
perxis.collections
import
collections_pb2
def
make_collection_instances
(
schemes_mapping
:
dict
[
str
,
str
])
->
list
[
collections_pb2
.
Collection
]:
collections
=
[]
for
collection_id
,
collection_name
in
schemes_mapping
.
items
():
with
open
(
f
"
./schemes/
{
collection_id
}
.json
"
,
"
r
"
)
as
file
:
collection_schema
=
file
.
read
()
collection
=
collections_pb2
.
Collection
(
id
=
collection_id
,
name
=
collection_name
,
schema
=
collection_schema
)
collections
.
append
(
collection
)
return
collections
...
schemes_mapping
=
{
"
dealers_cities
"
:
"
Дилеры/Города
"
,
"
dealers_contacts
"
:
"
Дилеры/Контакты
"
,
"
dealers_countries
"
:
"
Дилеры/Страны
"
,
"
dealers_dealers
"
:
"
Дилеры/Дилеры
"
,
"
dealers_dealerships
"
:
"
Дилеры/Дилерские центры
"
,
"
dealers_department_types
"
:
"
Дилеры/Типы отделов
"
,
"
dealers_departments
"
:
"
Дилеры/Отделы
"
,
"
dealers_events
"
:
"
Дилеры/События
"
,
"
dealers_identifiers
"
:
"
Дилеры/Идентификаторы
"
,
"
dealers_schedules
"
:
"
Дилеры/Графики работы
"
,
"
dealers_services
"
:
"
Дилеры/Услуги
"
}
...
class
Servicer
(
ExtensionService
):
extension_id
=
"
some_id
"
collections
=
make_collection_instances
(
schemes_mapping
)
roles
=
[
roles_pb2
.
Role
(
id
=
"
my-role
"
,
description
=
"
Описание к роли
"
,
rules
=
[
common_pb2
.
Rule
(
collection_id
=
"
dealers_cities
"
,
actions
=
[
common_pb2
.
CREATE
,
common_pb2
.
UPDATE
,
common_pb2
.
DELETE
],
)
],
environments
=
[
"
*
"
],
allow_management
=
False
,
)
]
clients
=
[
clients_pb2
.
Client
(
id
=
"
my-client
"
,
name
=
"
Клиент, созданный расширением
"
,
description
=
"
Описание созданного расширением клиента
"
,
role_id
=
"
my-role
"
,
api_key
=
{
"
rotate
"
:
True
}
)
]
```
## Аутентификация
gRPC Python предоставляет способ перехвата RPC и добавления метаданных,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment