Skip to content

Commit ab08a07

Browse files
author
Oleksandr Bazarnov
committed
add request_body_* > request_body migration + unit test
1 parent c6b31cc commit ab08a07

File tree

3 files changed

+586
-1
lines changed

3 files changed

+586
-1
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from airbyte_cdk.manifest_migrations.manifest_migration import (
2+
TYPE_TAG,
3+
ManifestMigration,
4+
ManifestType,
5+
)
6+
7+
8+
class V_6_45_2_HttpRequesterRequestBodyJsonDataToRequestBody(ManifestMigration):
9+
"""
10+
This migration is responsible for migrating the `url_base` key to `url` in the HttpRequester component.
11+
The `url_base` key is expected to be a base URL, and the `url` key is expected to be a full URL.
12+
The migration will copy the value of `url_base` to `url`.
13+
"""
14+
15+
component_type = "HttpRequester"
16+
original_keys = ["request_body_json", "request_body_data"]
17+
replacement_key = "request_body"
18+
19+
def should_migrate(self, manifest: ManifestType) -> bool:
20+
return manifest[TYPE_TAG] == self.component_type and any(
21+
key in list(manifest.keys()) for key in self.original_keys
22+
)
23+
24+
def migrate(self, manifest: ManifestType) -> None:
25+
for key in self.original_keys:
26+
if key in manifest:
27+
manifest[self.replacement_key] = manifest[key]
28+
manifest.pop(key, None)

0 commit comments

Comments
 (0)