Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add to_dict method to domain classes #270

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jooola
Copy link
Member

@jooola jooola commented Aug 3, 2023

This allows us to serialize the domain classes by first converting them to "dumb types". For example, to convert the objects to JSON.

import json

domain = BaseDomain.from_dict(domain_dict)
json.dumps(domain.to_dict())

@jooola jooola force-pushed the to_dict branch 2 times, most recently from 033c20d to 6c8e129 Compare August 4, 2023 15:51
@jooola
Copy link
Member Author

jooola commented Aug 7, 2023

I first intended to use this to help with the hetzner.hcloud ansible collection inventory caching implementation. But I choose to use another method.

This might still be useful for the users of the library, to be able to export the entire domain object to a dict.

Copy link

codecov bot commented Feb 1, 2024

Codecov Report

Attention: Patch coverage is 94.73684% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 92.86%. Comparing base (a798979) to head (5c64538).
Report is 28 commits behind head on main.

Files Patch % Lines
hcloud/core/domain.py 94.73% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #270   +/-   ##
=======================================
  Coverage   92.86%   92.86%           
=======================================
  Files          65       65           
  Lines        2872     2889   +17     
=======================================
+ Hits         2667     2683   +16     
- Misses        205      206    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented May 2, 2024

This PR has been marked as stale because it has not had recent activity. The bot will close the PR if no further action occurs.

@github-actions github-actions bot added the Stale label May 2, 2024
@jooola jooola removed Stale labels May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant