data-syncmaster 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. data_syncmaster-0.1.1.dist-info/LICENSE.txt +203 -0
  2. data_syncmaster-0.1.1.dist-info/METADATA +115 -0
  3. data_syncmaster-0.1.1.dist-info/RECORD +110 -0
  4. data_syncmaster-0.1.1.dist-info/WHEEL +4 -0
  5. syncmaster/__init__.py +6 -0
  6. syncmaster/backend/__init__.py +2 -0
  7. syncmaster/backend/api/__init__.py +2 -0
  8. syncmaster/backend/api/deps.py +20 -0
  9. syncmaster/backend/api/monitoring.py +10 -0
  10. syncmaster/backend/api/router.py +10 -0
  11. syncmaster/backend/api/v1/__init__.py +2 -0
  12. syncmaster/backend/api/v1/auth/__init__.py +2 -0
  13. syncmaster/backend/api/v1/auth/router.py +32 -0
  14. syncmaster/backend/api/v1/auth/utils.py +26 -0
  15. syncmaster/backend/api/v1/connections.py +300 -0
  16. syncmaster/backend/api/v1/groups.py +225 -0
  17. syncmaster/backend/api/v1/queue.py +148 -0
  18. syncmaster/backend/api/v1/router.py +18 -0
  19. syncmaster/backend/api/v1/transfers/__init__.py +2 -0
  20. syncmaster/backend/api/v1/transfers/router.py +469 -0
  21. syncmaster/backend/api/v1/transfers/utils.py +17 -0
  22. syncmaster/backend/api/v1/users.py +75 -0
  23. syncmaster/backend/export_openapi_schema.py +26 -0
  24. syncmaster/backend/handler.py +203 -0
  25. syncmaster/backend/logger.py +2 -0
  26. syncmaster/backend/main.py +63 -0
  27. syncmaster/backend/pre_start.py +94 -0
  28. syncmaster/backend/services/__init__.py +4 -0
  29. syncmaster/backend/services/auth.py +58 -0
  30. syncmaster/backend/services/unit_of_work.py +44 -0
  31. syncmaster/config.py +110 -0
  32. syncmaster/db/__init__.py +2 -0
  33. syncmaster/db/alembic.ini +41 -0
  34. syncmaster/db/base.py +28 -0
  35. syncmaster/db/factory.py +37 -0
  36. syncmaster/db/migrations/README +1 -0
  37. syncmaster/db/migrations/__init__.py +2 -0
  38. syncmaster/db/migrations/env.py +87 -0
  39. syncmaster/db/migrations/script.py.mako +24 -0
  40. syncmaster/db/migrations/versions/2023-11-23_478240cdad4b_init.py +242 -0
  41. syncmaster/db/migrations/versions/__init__.py +2 -0
  42. syncmaster/db/mixins.py +33 -0
  43. syncmaster/db/models.py +194 -0
  44. syncmaster/db/repositories/__init__.py +22 -0
  45. syncmaster/db/repositories/base.py +109 -0
  46. syncmaster/db/repositories/connection.py +138 -0
  47. syncmaster/db/repositories/credentials_repository.py +87 -0
  48. syncmaster/db/repositories/group.py +264 -0
  49. syncmaster/db/repositories/queue.py +195 -0
  50. syncmaster/db/repositories/repository_with_owner.py +115 -0
  51. syncmaster/db/repositories/run.py +78 -0
  52. syncmaster/db/repositories/transfer.py +202 -0
  53. syncmaster/db/repositories/user.py +72 -0
  54. syncmaster/db/repositories/utils.py +25 -0
  55. syncmaster/db/utils.py +31 -0
  56. syncmaster/dto/__init__.py +2 -0
  57. syncmaster/dto/connections.py +60 -0
  58. syncmaster/dto/transfers.py +46 -0
  59. syncmaster/exceptions/__init__.py +13 -0
  60. syncmaster/exceptions/base.py +12 -0
  61. syncmaster/exceptions/connection.py +28 -0
  62. syncmaster/exceptions/credentials.py +8 -0
  63. syncmaster/exceptions/group.py +27 -0
  64. syncmaster/exceptions/queue.py +16 -0
  65. syncmaster/exceptions/run.py +19 -0
  66. syncmaster/exceptions/transfer.py +39 -0
  67. syncmaster/exceptions/user.py +11 -0
  68. syncmaster/schemas/__init__.py +2 -0
  69. syncmaster/schemas/v1/__init__.py +54 -0
  70. syncmaster/schemas/v1/auth.py +12 -0
  71. syncmaster/schemas/v1/connection_types.py +9 -0
  72. syncmaster/schemas/v1/connections/__init__.py +2 -0
  73. syncmaster/schemas/v1/connections/connection.py +146 -0
  74. syncmaster/schemas/v1/connections/hdfs.py +40 -0
  75. syncmaster/schemas/v1/connections/hive.py +40 -0
  76. syncmaster/schemas/v1/connections/oracle.py +58 -0
  77. syncmaster/schemas/v1/connections/postgres.py +48 -0
  78. syncmaster/schemas/v1/connections/s3.py +66 -0
  79. syncmaster/schemas/v1/file_formats.py +7 -0
  80. syncmaster/schemas/v1/groups.py +39 -0
  81. syncmaster/schemas/v1/page.py +40 -0
  82. syncmaster/schemas/v1/queue.py +32 -0
  83. syncmaster/schemas/v1/status.py +16 -0
  84. syncmaster/schemas/v1/transfer_types.py +6 -0
  85. syncmaster/schemas/v1/transfers/__init__.py +172 -0
  86. syncmaster/schemas/v1/transfers/db.py +23 -0
  87. syncmaster/schemas/v1/transfers/file/__init__.py +2 -0
  88. syncmaster/schemas/v1/transfers/file/base.py +47 -0
  89. syncmaster/schemas/v1/transfers/file/hdfs.py +27 -0
  90. syncmaster/schemas/v1/transfers/file/s3.py +27 -0
  91. syncmaster/schemas/v1/transfers/file_format.py +29 -0
  92. syncmaster/schemas/v1/transfers/run.py +37 -0
  93. syncmaster/schemas/v1/transfers/strategy.py +15 -0
  94. syncmaster/schemas/v1/types.py +5 -0
  95. syncmaster/schemas/v1/users.py +83 -0
  96. syncmaster/worker/__init__.py +2 -0
  97. syncmaster/worker/base.py +14 -0
  98. syncmaster/worker/config.py +18 -0
  99. syncmaster/worker/controller.py +127 -0
  100. syncmaster/worker/handlers/__init__.py +2 -0
  101. syncmaster/worker/handlers/base.py +49 -0
  102. syncmaster/worker/handlers/file/__init__.py +2 -0
  103. syncmaster/worker/handlers/file/base.py +56 -0
  104. syncmaster/worker/handlers/file/hdfs.py +14 -0
  105. syncmaster/worker/handlers/file/s3.py +20 -0
  106. syncmaster/worker/handlers/hive.py +41 -0
  107. syncmaster/worker/handlers/oracle.py +48 -0
  108. syncmaster/worker/handlers/postgres.py +47 -0
  109. syncmaster/worker/spark.py +93 -0
  110. syncmaster/worker/transfer.py +85 -0
@@ -0,0 +1,58 @@
1
+ # SPDX-FileCopyrightText: 2023-2024 MTS (Mobile Telesystems)
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ from pydantic import BaseModel, Field, SecretStr, model_validator
5
+
6
+ from syncmaster.schemas.v1.connection_types import ORACLE_TYPE
7
+ from syncmaster.schemas.v1.types import NameConstr
8
+
9
+
10
+ class OracleBaseSchema(BaseModel):
11
+ type: ORACLE_TYPE
12
+
13
+ class Config:
14
+ from_attributes = True
15
+
16
+
17
+ class ReadOracleConnectionSchema(OracleBaseSchema):
18
+ host: str
19
+ port: int
20
+ service_name: str | None = None
21
+ sid: str | None = None
22
+ additional_params: dict = Field(default_factory=dict)
23
+
24
+
25
+ class ReadOracleAuthSchema(OracleBaseSchema):
26
+ user: str
27
+
28
+
29
+ class UpdateOracleConnectionSchema(OracleBaseSchema):
30
+ host: str | None = None
31
+ sid: str | None = None
32
+ service_name: str | None = None
33
+ additional_params: dict | None = Field(default_factory=dict)
34
+
35
+
36
+ class UpdateOracleAuthSchema(OracleBaseSchema):
37
+ user: NameConstr | None = None # noqa: F722
38
+ password: SecretStr | None = None
39
+
40
+
41
+ class CreateOracleConnectionSchema(OracleBaseSchema):
42
+ host: str
43
+ port: int
44
+ service_name: str | None = None
45
+ sid: str | None = None
46
+ additional_params: dict = Field(default_factory=dict)
47
+
48
+ @model_validator(mode="before")
49
+ def check_owner_id(cls, values):
50
+ sid, service_name = values.get("sid"), values.get("service_name")
51
+ if sid and service_name:
52
+ raise ValueError("You must specify either sid or service_name but not both")
53
+ return values
54
+
55
+
56
+ class CreateOracleAuthSchema(OracleBaseSchema):
57
+ user: str
58
+ password: SecretStr
@@ -0,0 +1,48 @@
1
+ # SPDX-FileCopyrightText: 2023-2024 MTS (Mobile Telesystems)
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ from pydantic import BaseModel, Field, SecretStr
5
+
6
+ from syncmaster.schemas.v1.connection_types import POSTGRES_TYPE
7
+
8
+
9
+ class PostgresBaseSchema(BaseModel):
10
+ type: POSTGRES_TYPE
11
+
12
+ class Config:
13
+ from_attributes = True
14
+
15
+
16
+ class ReadPostgresConnectionSchema(PostgresBaseSchema):
17
+ host: str
18
+ port: int = Field(gt=0, le=65535)
19
+ database_name: str
20
+ additional_params: dict = Field(default_factory=dict)
21
+
22
+
23
+ class ReadPostgresAuthSchema(PostgresBaseSchema):
24
+ user: str
25
+
26
+
27
+ class UpdatePostgresConnectionSchema(PostgresBaseSchema):
28
+ host: str | None = None
29
+ port: int | None = None
30
+ database_name: str | None = None
31
+ additional_params: dict | None = Field(default_factory=dict)
32
+
33
+
34
+ class UpdatePostgresAuthSchema(PostgresBaseSchema):
35
+ user: str | None = None
36
+ password: SecretStr | None = None
37
+
38
+
39
+ class CreatePostgresConnectionSchema(PostgresBaseSchema):
40
+ host: str
41
+ port: int
42
+ database_name: str
43
+ additional_params: dict = Field(default_factory=dict)
44
+
45
+
46
+ class CreatePostgresAuthSchema(PostgresBaseSchema):
47
+ user: str
48
+ password: SecretStr
@@ -0,0 +1,66 @@
1
+ # SPDX-FileCopyrightText: 2023-2024 MTS (Mobile Telesystems)
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ from typing import Literal
4
+
5
+ from pydantic import BaseModel, SecretStr, model_validator
6
+
7
+ from syncmaster.schemas.v1.connection_types import S3_TYPE
8
+
9
+
10
+ class S3BaseSchema(BaseModel):
11
+ type: S3_TYPE
12
+
13
+ class Config:
14
+ from_attributes = True
15
+
16
+
17
+ class S3ReadConnectionSchema(S3BaseSchema):
18
+ host: str
19
+ bucket: str
20
+ port: int | None = None
21
+ region: str | None = None
22
+ protocol: Literal["http", "https"] = "https"
23
+ bucket_style: Literal["domain", "path"] = "domain"
24
+
25
+
26
+ class S3CreateConnectionSchema(S3BaseSchema):
27
+ host: str
28
+ bucket: str
29
+ port: int | None = None
30
+ region: str | None = None
31
+ protocol: Literal["http", "https"] = "https"
32
+ bucket_style: Literal["domain", "path"] = "domain"
33
+
34
+ @model_validator(mode="before")
35
+ def validate_port(cls, values: dict) -> dict:
36
+ port = values.get("port")
37
+ protocol = values.get("protocol")
38
+
39
+ if port is None:
40
+ port = 443 if protocol == "https" else 80
41
+ values["port"] = port
42
+
43
+ return values
44
+
45
+
46
+ class S3UpdateConnectionSchema(S3BaseSchema):
47
+ host: str | None = None
48
+ bucket: str | None = None
49
+ port: int | None = None
50
+ region: str | None = None
51
+ protocol: Literal["http", "https"] | None = None
52
+ bucket_style: Literal["domain", "path"] | None = None
53
+
54
+
55
+ class S3CreateAuthSchema(S3BaseSchema):
56
+ access_key: str
57
+ secret_key: SecretStr
58
+
59
+
60
+ class S3ReadAuthSchema(S3BaseSchema):
61
+ access_key: str
62
+
63
+
64
+ class S3UpdateAuthSchema(S3BaseSchema):
65
+ access_key: str | None = None
66
+ secret_key: SecretStr | None = None
@@ -0,0 +1,7 @@
1
+ # SPDX-FileCopyrightText: 2023-2024 MTS (Mobile Telesystems)
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ from typing import Literal
4
+
5
+ CSV_FORMAT = Literal["csv"]
6
+ JSONLINE_FORMAT = Literal["jsonline"]
7
+ JSON_FORMAT = Literal["json"]
@@ -0,0 +1,39 @@
1
+ # SPDX-FileCopyrightText: 2023-2024 MTS (Mobile Telesystems)
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ from pydantic import BaseModel
4
+
5
+ from syncmaster.db.models import GroupMemberRole
6
+ from syncmaster.schemas.v1.page import PageSchema
7
+ from syncmaster.schemas.v1.types import NameConstr
8
+
9
+
10
+ class UpdateGroupSchema(BaseModel):
11
+ name: NameConstr # noqa: F722
12
+ description: str
13
+ owner_id: int
14
+
15
+
16
+ class CreateGroupSchema(BaseModel):
17
+ name: NameConstr # noqa: F722
18
+ description: str
19
+
20
+
21
+ class AddUserSchema(BaseModel):
22
+ role: GroupMemberRole
23
+
24
+ class Config:
25
+ from_attributes = True
26
+
27
+
28
+ class ReadGroupSchema(BaseModel):
29
+ id: int
30
+ name: NameConstr # noqa: F722
31
+ description: str
32
+ owner_id: int
33
+
34
+ class Config:
35
+ from_attributes = True
36
+
37
+
38
+ class GroupPageSchema(PageSchema):
39
+ items: list[ReadGroupSchema]
@@ -0,0 +1,40 @@
1
+ # SPDX-FileCopyrightText: 2023-2024 MTS (Mobile Telesystems)
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ import abc
4
+ from typing import Any
5
+
6
+ from pydantic import BaseModel
7
+
8
+ from syncmaster.db.utils import Pagination
9
+
10
+
11
+ class MetaPageSchema(BaseModel):
12
+ page: int
13
+ pages: int
14
+ total: int
15
+ page_size: int
16
+ has_next: bool
17
+ has_previous: bool
18
+ next_page: int | None = None
19
+ previous_page: int | None = None
20
+
21
+
22
+ class PageSchema(BaseModel, abc.ABC):
23
+ meta: MetaPageSchema
24
+ items: list[Any]
25
+
26
+ @classmethod
27
+ def from_pagination(cls, pagination: Pagination):
28
+ return cls(
29
+ meta=MetaPageSchema(
30
+ page=pagination.page,
31
+ pages=pagination.pages,
32
+ page_size=pagination.page_size,
33
+ total=pagination.total,
34
+ has_next=pagination.has_next,
35
+ has_previous=pagination.has_previous,
36
+ next_page=pagination.next_page,
37
+ previous_page=pagination.previous_page,
38
+ ),
39
+ items=pagination.items,
40
+ )
@@ -0,0 +1,32 @@
1
+ # SPDX-FileCopyrightText: 2023-2024 MTS (Mobile Telesystems)
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ from pydantic import BaseModel, Field, constr
4
+
5
+ from syncmaster.schemas.v1.page import PageSchema
6
+
7
+
8
+ class CreateQueueSchema(BaseModel):
9
+ name: constr(max_length=128, pattern=r"^[-_a-zA-Z0-9]+$") = Field( # noqa: F722
10
+ ...,
11
+ description="Queue name",
12
+ )
13
+ group_id: int = Field(..., description="Queue owner group id")
14
+ description: str = Field(default="", description="Additional description")
15
+
16
+
17
+ class ReadQueueSchema(BaseModel):
18
+ name: str
19
+ description: str | None = None
20
+ group_id: int
21
+ id: int
22
+
23
+ class Config:
24
+ from_attributes = True
25
+
26
+
27
+ class QueuePageSchema(PageSchema):
28
+ items: list[ReadQueueSchema]
29
+
30
+
31
+ class UpdateQueueSchema(BaseModel):
32
+ description: str | None = None
@@ -0,0 +1,16 @@
1
+ # SPDX-FileCopyrightText: 2023-2024 MTS (Mobile Telesystems)
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ from pydantic import BaseModel
5
+
6
+
7
+ class StatusResponseSchema(BaseModel):
8
+ ok: bool
9
+ status_code: int
10
+ message: str
11
+
12
+
13
+ class StatusCopyTransferResponseSchema(StatusResponseSchema):
14
+ source_connection_id: int
15
+ target_connection_id: int
16
+ copied_transfer_id: int
@@ -0,0 +1,6 @@
1
+ # SPDX-FileCopyrightText: 2023-2024 MTS (Mobile Telesystems)
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ from typing import Literal
4
+
5
+ FULL_TYPE = Literal["full"]
6
+ INCREMENTAL_TYPE = Literal["incremental"]
@@ -0,0 +1,172 @@
1
+ # SPDX-FileCopyrightText: 2023-2024 MTS (Mobile Telesystems)
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ from __future__ import annotations
4
+
5
+ from pydantic import BaseModel, Field, model_validator
6
+
7
+ from syncmaster.schemas.v1.connections.connection import ReadConnectionSchema
8
+ from syncmaster.schemas.v1.page import PageSchema
9
+ from syncmaster.schemas.v1.transfers.db import (
10
+ HiveReadTransferSourceAndTarget,
11
+ OracleReadTransferSourceAndTarget,
12
+ PostgresReadTransferSourceAndTarget,
13
+ )
14
+ from syncmaster.schemas.v1.transfers.file.hdfs import (
15
+ HDFSCreateTransferSource,
16
+ HDFSCreateTransferTarget,
17
+ HDFSReadTransferSource,
18
+ HDFSReadTransferTarget,
19
+ )
20
+ from syncmaster.schemas.v1.transfers.file.s3 import (
21
+ S3CreateTransferSource,
22
+ S3CreateTransferTarget,
23
+ S3ReadTransferSource,
24
+ S3ReadTransferTarget,
25
+ )
26
+ from syncmaster.schemas.v1.transfers.strategy import FullStrategy, IncrementalStrategy
27
+ from syncmaster.schemas.v1.types import NameConstr
28
+
29
+ ReadTransferSchemaSource = (
30
+ PostgresReadTransferSourceAndTarget
31
+ | HDFSReadTransferSource
32
+ | HiveReadTransferSourceAndTarget
33
+ | OracleReadTransferSourceAndTarget
34
+ | S3ReadTransferSource
35
+ )
36
+
37
+ ReadTransferSchemaTarget = (
38
+ PostgresReadTransferSourceAndTarget
39
+ | HDFSReadTransferTarget
40
+ | HiveReadTransferSourceAndTarget
41
+ | OracleReadTransferSourceAndTarget
42
+ | S3ReadTransferTarget
43
+ )
44
+
45
+ CreateTransferSchemaSource = (
46
+ PostgresReadTransferSourceAndTarget
47
+ | HDFSCreateTransferSource
48
+ | HiveReadTransferSourceAndTarget
49
+ | OracleReadTransferSourceAndTarget
50
+ | S3CreateTransferSource
51
+ )
52
+
53
+ CreateTransferSchemaTarget = (
54
+ PostgresReadTransferSourceAndTarget
55
+ | HDFSCreateTransferTarget
56
+ | HiveReadTransferSourceAndTarget
57
+ | OracleReadTransferSourceAndTarget
58
+ | S3CreateTransferTarget
59
+ )
60
+
61
+ UpdateTransferSchemaSource = (
62
+ PostgresReadTransferSourceAndTarget
63
+ | HDFSReadTransferSource
64
+ | HiveReadTransferSourceAndTarget
65
+ | OracleReadTransferSourceAndTarget
66
+ | S3CreateTransferSource
67
+ | None
68
+ )
69
+
70
+ UpdateTransferSchemaTarget = (
71
+ PostgresReadTransferSourceAndTarget
72
+ | HDFSReadTransferSource
73
+ | HiveReadTransferSourceAndTarget
74
+ | OracleReadTransferSourceAndTarget
75
+ | S3CreateTransferTarget
76
+ | None
77
+ )
78
+
79
+
80
+ class CopyTransferSchema(BaseModel):
81
+ new_group_id: int
82
+ new_queue_id: int
83
+ new_source_connection_name: NameConstr | None = None # noqa: F722
84
+ new_target_connection_name: NameConstr | None = None # noqa: F722
85
+ new_name: NameConstr | None = None # noqa: F722
86
+ remove_source: bool = False
87
+
88
+
89
+ class ReadTransferSchema(BaseModel):
90
+ id: int
91
+ group_id: int
92
+ source_connection_id: int
93
+ target_connection_id: int
94
+ name: str
95
+ description: str
96
+ is_scheduled: bool
97
+ schedule: str
98
+ queue_id: int
99
+ source_params: ReadTransferSchemaSource = Field(
100
+ ...,
101
+ discriminator="type",
102
+ )
103
+ target_params: ReadTransferSchemaTarget = Field(
104
+ ...,
105
+ discriminator="type",
106
+ )
107
+ strategy_params: FullStrategy | IncrementalStrategy = Field(
108
+ ...,
109
+ discriminator="type",
110
+ )
111
+
112
+ class Config:
113
+ from_attributes = True
114
+
115
+
116
+ class CreateTransferSchema(BaseModel):
117
+ group_id: int = Field(..., description="Transfer owner group id")
118
+ source_connection_id: int = Field(..., description="id of the connection that will be the data source")
119
+ target_connection_id: int = Field(..., description="id of the connection that will be the data receiver")
120
+ name: NameConstr = Field(..., description="Transfer name") # noqa: F722
121
+ description: str = Field(..., description="Additional description")
122
+ is_scheduled: bool = Field(..., description="Is the transfer on schedule")
123
+ queue_id: int = Field(..., description="id of the queue in which the transfer will be performed")
124
+ schedule: str | None = Field(None, description="Execution schedule in cron format")
125
+ source_params: CreateTransferSchemaSource = Field(
126
+ ...,
127
+ discriminator="type",
128
+ description="Data source parameters",
129
+ )
130
+ target_params: CreateTransferSchemaTarget = Field(
131
+ ...,
132
+ discriminator="type",
133
+ description="Data receiver parameters",
134
+ )
135
+ strategy_params: FullStrategy | IncrementalStrategy = Field(
136
+ ...,
137
+ discriminator="type",
138
+ description="Incremental or archive download options",
139
+ )
140
+
141
+ @model_validator(mode="before")
142
+ def check_owner_id(cls, values):
143
+ is_scheduled, schedule = values.get("is_scheduled"), values.get("schedule")
144
+ if is_scheduled and schedule is None:
145
+ # TODO make checking cron string
146
+ raise ValueError("If transfer must be scheduled than set schedule param")
147
+ return values
148
+
149
+
150
+ class UpdateTransferSchema(BaseModel):
151
+ source_connection_id: int | None = None
152
+ target_connection_id: int | None = None
153
+ name: NameConstr | None = None # noqa: F722
154
+ description: str | None = None
155
+ is_scheduled: bool | None = None
156
+ schedule: str | None = None
157
+ new_queue_id: int | None = None
158
+ source_params: UpdateTransferSchemaSource = Field(discriminator="type", default=None)
159
+ target_params: UpdateTransferSchemaTarget = Field(discriminator="type", default=None)
160
+ strategy_params: FullStrategy | IncrementalStrategy | None = Field(discriminator="type", default=None)
161
+
162
+
163
+ class ReadFullTransferSchema(ReadTransferSchema):
164
+ source_connection: ReadConnectionSchema
165
+ target_connection: ReadConnectionSchema
166
+
167
+ class Config:
168
+ from_attributes = True
169
+
170
+
171
+ class TransferPageSchema(PageSchema):
172
+ items: list[ReadTransferSchema]
@@ -0,0 +1,23 @@
1
+ # SPDX-FileCopyrightText: 2023-2024 MTS (Mobile Telesystems)
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ from __future__ import annotations
4
+
5
+ from pydantic import BaseModel
6
+
7
+ from syncmaster.schemas.v1.connection_types import HIVE_TYPE, ORACLE_TYPE, POSTGRES_TYPE
8
+
9
+
10
+ class ReadDBTransfer(BaseModel):
11
+ table_name: str
12
+
13
+
14
+ class HiveReadTransferSourceAndTarget(ReadDBTransfer):
15
+ type: HIVE_TYPE
16
+
17
+
18
+ class OracleReadTransferSourceAndTarget(ReadDBTransfer):
19
+ type: ORACLE_TYPE
20
+
21
+
22
+ class PostgresReadTransferSourceAndTarget(ReadDBTransfer):
23
+ type: POSTGRES_TYPE
@@ -0,0 +1,2 @@
1
+ # SPDX-FileCopyrightText: 2023-2024 MTS (Mobile Telesystems)
2
+ # SPDX-License-Identifier: Apache-2.0
@@ -0,0 +1,47 @@
1
+ # SPDX-FileCopyrightText: 2023-2024 MTS (Mobile Telesystems)
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ from __future__ import annotations
4
+
5
+ from pathlib import PurePosixPath
6
+
7
+ from pydantic import BaseModel, Field, validator
8
+
9
+ from syncmaster.schemas.v1.transfers.file_format import CSV, JSON, JSONLine
10
+
11
+
12
+ def validate_directory_path(path: str) -> PurePosixPath:
13
+ return PurePosixPath(path)
14
+
15
+
16
+ # At the moment the ReadTransferSourceParams and ReadTransferTargetParams
17
+ # classes are identical but may change in the future
18
+ class ReadFileTransferSource(BaseModel):
19
+ directory_path: str
20
+ file_format: CSV | JSONLine | JSON = Field(..., discriminator="type")
21
+
22
+
23
+ class ReadFileTransferTarget(BaseModel):
24
+ directory_path: str
25
+ file_format: CSV | JSONLine = Field(..., discriminator="type") # JSON format is not supported for writing
26
+
27
+
28
+ # At the moment the CreateTransferSourceParams and CreateTransferTargetParams
29
+ # classes are identical but may change in the future
30
+ class CreateFileTransferSource(BaseModel):
31
+ directory_path: PurePosixPath
32
+ file_format: CSV | JSONLine | JSON = Field(..., discriminator="type")
33
+
34
+ class Config:
35
+ arbitrary_types_allowed = True
36
+
37
+ _validate_dir_path = validator("directory_path", allow_reuse=True, pre=True)(validate_directory_path)
38
+
39
+
40
+ class CreateFileTransferTarget(BaseModel):
41
+ directory_path: PurePosixPath
42
+ file_format: CSV | JSONLine = Field(..., discriminator="type") # JSON FORMAT IS NOT SUPPORTED AS A TARGET !
43
+
44
+ class Config:
45
+ arbitrary_types_allowed = True
46
+
47
+ _validate_dir_path = validator("directory_path", allow_reuse=True, pre=True)(validate_directory_path)
@@ -0,0 +1,27 @@
1
+ # SPDX-FileCopyrightText: 2023-2024 MTS (Mobile Telesystems)
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ from __future__ import annotations
4
+
5
+ from syncmaster.schemas.v1.connection_types import HDFS_TYPE
6
+ from syncmaster.schemas.v1.transfers.file.base import (
7
+ CreateFileTransferSource,
8
+ CreateFileTransferTarget,
9
+ ReadFileTransferSource,
10
+ ReadFileTransferTarget,
11
+ )
12
+
13
+
14
+ class HDFSReadTransferSource(ReadFileTransferSource):
15
+ type: HDFS_TYPE
16
+
17
+
18
+ class HDFSReadTransferTarget(ReadFileTransferTarget):
19
+ type: HDFS_TYPE
20
+
21
+
22
+ class HDFSCreateTransferSource(CreateFileTransferSource):
23
+ type: HDFS_TYPE
24
+
25
+
26
+ class HDFSCreateTransferTarget(CreateFileTransferTarget):
27
+ type: HDFS_TYPE
@@ -0,0 +1,27 @@
1
+ # SPDX-FileCopyrightText: 2023-2024 MTS (Mobile Telesystems)
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ from __future__ import annotations
4
+
5
+ from syncmaster.schemas.v1.connection_types import S3_TYPE
6
+ from syncmaster.schemas.v1.transfers.file.base import (
7
+ CreateFileTransferSource,
8
+ CreateFileTransferTarget,
9
+ ReadFileTransferSource,
10
+ ReadFileTransferTarget,
11
+ )
12
+
13
+
14
+ class S3ReadTransferSource(ReadFileTransferSource):
15
+ type: S3_TYPE
16
+
17
+
18
+ class S3ReadTransferTarget(ReadFileTransferTarget):
19
+ type: S3_TYPE
20
+
21
+
22
+ class S3CreateTransferSource(CreateFileTransferSource):
23
+ type: S3_TYPE
24
+
25
+
26
+ class S3CreateTransferTarget(CreateFileTransferTarget):
27
+ type: S3_TYPE
@@ -0,0 +1,29 @@
1
+ # SPDX-FileCopyrightText: 2023-2024 MTS (Mobile Telesystems)
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ from __future__ import annotations
4
+
5
+ from pydantic import BaseModel
6
+
7
+ from syncmaster.schemas.v1.file_formats import CSV_FORMAT, JSON_FORMAT, JSONLINE_FORMAT
8
+
9
+
10
+ class CSV(BaseModel):
11
+ type: CSV_FORMAT
12
+ delimiter: str = ","
13
+ encoding: str = "utf-8"
14
+ quote: str = '"'
15
+ escape: str = "\\"
16
+ header: bool = False
17
+ line_sep: str = "\n"
18
+
19
+
20
+ class JSONLine(BaseModel):
21
+ type: JSONLINE_FORMAT
22
+ encoding: str = "utf-8"
23
+ line_sep: str = "\n"
24
+
25
+
26
+ class JSON(BaseModel):
27
+ type: JSON_FORMAT
28
+ encoding: str = "utf-8"
29
+ line_sep: str = "\n"
@@ -0,0 +1,37 @@
1
+ # SPDX-FileCopyrightText: 2023-2024 MTS (Mobile Telesystems)
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ from __future__ import annotations
4
+
5
+ from datetime import datetime
6
+
7
+ from pydantic import BaseModel
8
+
9
+ from syncmaster.db.models import Status
10
+ from syncmaster.schemas.v1.page import PageSchema
11
+
12
+
13
+ class ShortRunSchema(BaseModel):
14
+ id: int
15
+ transfer_id: int
16
+ started_at: datetime | None = None
17
+ ended_at: datetime | None = None
18
+ status: Status
19
+ log_url: str | None = None
20
+
21
+ class Config:
22
+ from_attributes = True
23
+
24
+
25
+ class RunPageSchema(PageSchema):
26
+ items: list[ShortRunSchema]
27
+
28
+
29
+ class ReadRunSchema(ShortRunSchema):
30
+ transfer_dump: dict
31
+
32
+ class Config:
33
+ from_attributes = True
34
+
35
+
36
+ class CreateRunSchema(BaseModel):
37
+ transfer_id: int