job_jdbc_datasouce.py 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. from typing import List, Optional
  2. from pydantic import BaseModel
  3. class JobJdbcDatasourceBase(BaseModel):
  4. # 数据源名称
  5. datasource_name: str
  6. # 数据源
  7. datasource: str
  8. # 数据库名
  9. database_name: str
  10. # 数据库用户名
  11. jdbc_username: Optional[str]
  12. # 数据库密码
  13. jdbc_password: Optional[str]
  14. # jdbc url
  15. jdbc_url: str
  16. # 备注
  17. comments: str
  18. # 标签
  19. tag: str
  20. # kerberos 验证(0:未开启,1:开启)
  21. kerberos: Optional[int] = 0
  22. # keytab 文件
  23. keytab: Optional[str]
  24. # krb5config 文件
  25. krb5config: Optional[str]
  26. # service 名称
  27. kerberos_service_name: Optional[str]
  28. # principal
  29. principal: Optional[str]
  30. # use_ssl
  31. use_ssl: Optional[int] = 0
  32. class Config:
  33. schema_extra = {
  34. # "example": {
  35. # "datasource_name": 'test',
  36. # "datasource": "mysql",
  37. # "database_name": 'datax_web',
  38. # "jdbc_username": 'root',
  39. # "jdbc_password": 'happylay',
  40. # "jdbc_url": '192.168.199.107:10086',
  41. # "comments": 'This is a very nice Item',
  42. # "tag": '线下'
  43. # }
  44. "example": {
  45. "datasource_name": 'testhive',
  46. "datasource": "hive",
  47. "database_name": 'default',
  48. "jdbc_username": '',
  49. "jdbc_password": '',
  50. "jdbc_url": '192.168.199.107:10000',
  51. "comments": 'This is a very nice Item',
  52. "tag": '线下',
  53. "kerberos": 0,
  54. "keytab": "test/kerberos/user.keytab",
  55. "krb5config": "test/kerberos/user.conf",
  56. "kerberos_service_name": "hadoop",
  57. "principal": "ailab@EMR-5XJSY31F",
  58. "use_ssl": 0,
  59. }
  60. }
  61. class JobJdbcDatasourceCreate(JobJdbcDatasourceBase):
  62. pass
  63. class JobJdbcDatasourceUpdate(JobJdbcDatasourceBase):
  64. status: int = 1
  65. class Config:
  66. schema_extra = {
  67. # "example": {
  68. # "datasource_name": 'test',
  69. # "datasource": "mysql",
  70. # "database_name": 'datax_web',
  71. # "jdbc_username": 'root',
  72. # "jdbc_password": 'happylay',
  73. # "jdbc_url": '192.168.199.107:10086',
  74. # "comments": 'This is a very nice Item',
  75. # "tag": '线下',
  76. # "status": 1,
  77. # }
  78. "example": {
  79. "datasource_name": 'testhive',
  80. "datasource": "hive",
  81. "database_name": 'default',
  82. "jdbc_username": '',
  83. "jdbc_password": '',
  84. "jdbc_url": '192.168.199.107:10000',
  85. "comments": 'This is a very nice Item',
  86. "tag": '线下',
  87. "kerberos": 0,
  88. "keytab": "test/kerberos/user.keytab",
  89. "krb5config": "test/kerberos/user.conf",
  90. "kerberos_service_name": "hadoop",
  91. "principal": "ailab@EMR-5XJSY31F",
  92. "use_ssl": 0,
  93. "status": 1,
  94. }
  95. }
  96. class JobJdbcDatasource(JobJdbcDatasourceBase):
  97. id: int
  98. status: int
  99. create_time: int
  100. create_by: str
  101. update_time: int
  102. update_by: str
  103. jdbc_url: str
  104. jdbc_driver_class: str
  105. class Config:
  106. orm_mode = True
  107. class ImportDataLake(BaseModel):
  108. database_name: str
  109. table_name: str
  110. table_path: str
  111. class Config:
  112. schema_extra = {
  113. "example": {
  114. "database_name": 'test',
  115. "table_name": 'test',
  116. "table_path": '/users/ailaab/test_1'
  117. }
  118. }
  119. class ShareAilab(BaseModel):
  120. table_names: List[str]
  121. project_ids: List[str]
  122. class Config:
  123. schema_extra = {
  124. "example": {
  125. "table_names": ['test'],
  126. "project_ids": ['3'],
  127. }
  128. }
  129. class Column(BaseModel):
  130. column_name: str
  131. Column_type: str
  132. class CreateAilab(BaseModel):
  133. table_name: str
  134. columns: List[Column]
  135. partition_column: Optional[str]
  136. class Config:
  137. schema_extra = {
  138. "example": {
  139. "table_name": 'test',
  140. "columns": [{
  141. 'column_name': 'id',
  142. 'Column_type': 'int',
  143. },{
  144. 'column_name': 'name',
  145. 'Column_type': 'string',
  146. }],
  147. "partition_column": 'data_ct'
  148. }
  149. }