diff --git a/CHANGELOG.md b/CHANGELOG.md index 9374a58e62..bb88caa289 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,11 @@ Changes are grouped as follows - `Fixed` for any bug fixes. - `Security` in case of vulnerabilities. +## [7.63.1] - 2024-10-10 +### Fixed +- [Feature Preview - alpha] Dumping `HostedExtractor` `Job` and `Source` data classes creates valid JSON/YAML + even when unknown fields are present. + ## [7.63.0] - 2024-10-10 ### Removed - Removed support for Python 3.8 and 3.9. diff --git a/cognite/client/_version.py b/cognite/client/_version.py index d423bee540..9ba876c24b 100644 --- a/cognite/client/_version.py +++ b/cognite/client/_version.py @@ -1,4 +1,4 @@ from __future__ import annotations -__version__ = "7.63.0" +__version__ = "7.63.1" __api_subversion__ = "20230101" diff --git a/cognite/client/data_classes/hosted_extractors/jobs.py b/cognite/client/data_classes/hosted_extractors/jobs.py index 3471468c9f..52ef6db302 100644 --- a/cognite/client/data_classes/hosted_extractors/jobs.py +++ b/cognite/client/data_classes/hosted_extractors/jobs.py @@ -310,7 +310,7 @@ def __init__( def dump(self, camel_case: bool = True) -> dict[str, Any]: output = super().dump(camel_case) output["format"] = self.format.dump(camel_case) - if isinstance(self.config, JobConfig): + if self.config is not None: output["config"] = self.config.dump(camel_case) return output diff --git a/cognite/client/data_classes/hosted_extractors/sources.py b/cognite/client/data_classes/hosted_extractors/sources.py index 6c9495b10c..e788a985b0 100644 --- a/cognite/client/data_classes/hosted_extractors/sources.py +++ b/cognite/client/data_classes/hosted_extractors/sources.py @@ -488,11 +488,11 @@ def as_write(self) -> NoReturn: def dump(self, camel_case: bool = True) -> dict[str, Any]: output = super().dump(camel_case) - if isinstance(self.authentication, MQTTAuthentication): + if self.authentication is not None: output["authentication"] = self.authentication.dump(camel_case) - if isinstance(self.ca_certificate, CACertificate): + if self.ca_certificate is not None: output["caCertificate" if camel_case else "ca_certificate"] = self.ca_certificate.dump(camel_case) - if isinstance(self.auth_certificate, AuthCertificate): + if self.auth_certificate is not None: output["authCertificate" if camel_case else "auth_certificate"] = self.auth_certificate.dump(camel_case) return output @@ -722,11 +722,11 @@ def dump(self, camel_case: bool = True) -> dict[str, Any]: output["bootstrapBrokers" if camel_case else "bootstrap_brokers"] = [ broker.dump(camel_case) for broker in self.bootstrap_brokers ] - if isinstance(self.authentication, MQTTAuthentication): + if self.authentication is not None: output["authentication"] = self.authentication.dump(camel_case) - if isinstance(self.ca_certificate, CACertificate): + if self.ca_certificate is not None: output["caCertificate" if camel_case else "ca_certificate"] = self.ca_certificate.dump(camel_case) - if isinstance(self.auth_certificate, AuthCertificate): + if self.auth_certificate is not None: output["authCertificate" if camel_case else "auth_certificate"] = self.auth_certificate.dump(camel_case) return output @@ -901,9 +901,9 @@ def as_write(self) -> RestSourceWrite: def dump(self, camel_case: bool = True) -> dict[str, Any]: output = super().dump(camel_case) - if isinstance(self.ca_certificate, CACertificate): + if self.ca_certificate is not None: output["caCertificate" if camel_case else "ca_certificate"] = self.ca_certificate.dump(camel_case) - if isinstance(self.auth_certificate, AuthCertificate): + if self.auth_certificate is not None: output["authCertificate" if camel_case else "auth_certificate"] = self.auth_certificate.dump(camel_case) return output diff --git a/pyproject.toml b/pyproject.toml index 8d065f95f2..45808d508b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] name = "cognite-sdk" -version = "7.63.0" +version = "7.63.1" description = "Cognite Python SDK" readme = "README.md" documentation = "https://cognite-sdk-python.readthedocs-hosted.com" diff --git a/tests/tests_unit/test_data_classes/test_hosted_extractors/__init__.py b/tests/tests_unit/test_data_classes/test_hosted_extractors/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/tests_unit/test_data_classes/test_hosted_extractors/test_jobs.py b/tests/tests_unit/test_data_classes/test_hosted_extractors/test_jobs.py new file mode 100644 index 0000000000..864023bf3f --- /dev/null +++ b/tests/tests_unit/test_data_classes/test_hosted_extractors/test_jobs.py @@ -0,0 +1,23 @@ +import yaml + +from cognite.client.data_classes.hosted_extractors.jobs import Job + + +class TestJob: + def test_load_yaml_dump_unknown_config(self) -> None: + raw_yaml = """externalId: myJob +sourceId: my_eventhub +destinationId: EventHubTarget +targetStatus: running +status: running +createdTime: 123 +lastUpdatedTime: 1234 +format: + type: value + encoding: utf16 + compression: gzip +config: + some: new_config + that: has not been seen before""" + + assert Job.load(raw_yaml).dump() == yaml.safe_load(raw_yaml)