hetznercloud/hcloud-python

How to convert BoundServer to json for writing to MongoDB

simonjcarr opened this issue · 1 comments

This is more a cry for help rather than a bug report, but this seems to be the only relevant place to post the help request.

Bug Report

Unable to serialise BoundServer to json

Current Behavior
using json.dumps() results in AttributeError

Input Code

response = client.servers.create(....)
print(json.dumps(response.server.__dict__))

TypeError: Object of type ServersClient is not JSON serializable

Expected behavior/code
I don't have an in depth knowledge, so I know I am probably doing something wrong. However I need to write the server results returned from client.servers.create to mongodb.

Environment

  • Python Version: v3.9.1
  • Hcloud-Python Version: 1.16.0

I have moved to the REST API as the responses are more appropriate for my use case.