2022-01-17 07:58:39 +00:00
|
|
|
import copy
|
|
|
|
|
2021-01-03 21:27:03 +00:00
|
|
|
from applications import const
|
2021-01-05 15:39:38 +00:00
|
|
|
from . import application_category, application_type
|
2021-01-03 21:27:03 +00:00
|
|
|
|
|
|
|
__all__ = [
|
2021-01-06 04:44:12 +00:00
|
|
|
'category_serializer_classes_mapping',
|
|
|
|
'type_serializer_classes_mapping',
|
2021-01-05 15:39:38 +00:00
|
|
|
'get_serializer_class_by_application_type',
|
2022-01-17 07:58:39 +00:00
|
|
|
'type_secret_serializer_classes_mapping'
|
2021-01-03 21:27:03 +00:00
|
|
|
]
|
|
|
|
|
2021-01-06 04:44:12 +00:00
|
|
|
# define `attrs` field `category serializers mapping`
|
|
|
|
# ---------------------------------------------------
|
2021-01-03 21:27:03 +00:00
|
|
|
|
2021-01-06 04:44:12 +00:00
|
|
|
category_serializer_classes_mapping = {
|
2021-07-27 08:06:00 +00:00
|
|
|
const.AppCategory.db.value: application_category.DBSerializer,
|
|
|
|
const.AppCategory.remote_app.value: application_category.RemoteAppSerializer,
|
|
|
|
const.AppCategory.cloud.value: application_category.CloudSerializer,
|
2021-01-06 04:44:12 +00:00
|
|
|
}
|
2021-01-03 21:27:03 +00:00
|
|
|
|
2021-01-06 04:44:12 +00:00
|
|
|
# define `attrs` field `type serializers mapping`
|
|
|
|
# -----------------------------------------------
|
|
|
|
|
|
|
|
type_serializer_classes_mapping = {
|
|
|
|
# db
|
2021-07-27 08:06:00 +00:00
|
|
|
const.AppType.mysql.value: application_type.MySQLSerializer,
|
2021-12-23 03:13:32 +00:00
|
|
|
const.AppType.redis.value: application_type.RedisSerializer,
|
2021-07-27 08:06:00 +00:00
|
|
|
const.AppType.mariadb.value: application_type.MariaDBSerializer,
|
|
|
|
const.AppType.oracle.value: application_type.OracleSerializer,
|
|
|
|
const.AppType.pgsql.value: application_type.PostgreSerializer,
|
2021-11-18 08:44:33 +00:00
|
|
|
const.AppType.sqlserver.value: application_type.SQLServerSerializer,
|
2022-01-17 07:58:39 +00:00
|
|
|
# cloud
|
|
|
|
const.AppType.k8s.value: application_type.K8SSerializer
|
|
|
|
}
|
|
|
|
|
|
|
|
remote_app_serializer_classes_mapping = {
|
2021-01-06 04:44:12 +00:00
|
|
|
# remote-app
|
2021-07-27 08:06:00 +00:00
|
|
|
const.AppType.chrome.value: application_type.ChromeSerializer,
|
|
|
|
const.AppType.mysql_workbench.value: application_type.MySQLWorkbenchSerializer,
|
|
|
|
const.AppType.vmware_client.value: application_type.VMwareClientSerializer,
|
2022-01-17 07:58:39 +00:00
|
|
|
const.AppType.custom.value: application_type.CustomSerializer
|
2021-01-03 21:27:03 +00:00
|
|
|
}
|
|
|
|
|
2022-01-17 07:58:39 +00:00
|
|
|
type_serializer_classes_mapping.update(remote_app_serializer_classes_mapping)
|
|
|
|
|
|
|
|
remote_app_secret_serializer_classes_mapping = {
|
|
|
|
# remote-app
|
|
|
|
const.AppType.chrome.value: application_type.ChromeSecretSerializer,
|
|
|
|
const.AppType.mysql_workbench.value: application_type.MySQLWorkbenchSecretSerializer,
|
|
|
|
const.AppType.vmware_client.value: application_type.VMwareClientSecretSerializer,
|
|
|
|
const.AppType.custom.value: application_type.CustomSecretSerializer
|
|
|
|
}
|
|
|
|
|
|
|
|
type_secret_serializer_classes_mapping = copy.deepcopy(type_serializer_classes_mapping)
|
|
|
|
|
|
|
|
type_secret_serializer_classes_mapping.update(remote_app_secret_serializer_classes_mapping)
|
|
|
|
|
2021-01-03 21:27:03 +00:00
|
|
|
|
2021-01-05 15:39:38 +00:00
|
|
|
def get_serializer_class_by_application_type(_application_type):
|
2021-01-06 04:44:12 +00:00
|
|
|
return type_serializer_classes_mapping.get(_application_type)
|