1 year ago
#386383

defiant
Converting the response from dataproc api list_jobs gcp python sdk response to dict/json
I am trying to find a way to convert the dataproc.list_jobs response to a python dict or json without any luck. There have been some ways to convert these grpc messages which comes as the responses to a dict but none of these worked with this one.
here is the sdk function link: DataProc List Jobs
here is the code:
for job_response in client.list_jobs(project_id=self.project_id, region=region.get(constants.NAME_KEY)):
job = MessageToDict(job_response) # throws an error saying descriptor not found
job = job_response._properties # Which is available in some other related responses, but not this one
job = job_response.to_api_repr() # Which is available in some other related response objects, but not this one. So doesn't work here.
job = job_response.__class__.to_json(job_response) # Which is available in some other related response objects, but not this one. So doesn't work here.
I am at a loss here. I can manually get the fields and create a dictionary myself. But that's not something I want.
python
google-cloud-platform
google-cloud-dataproc
0 Answers
Your Answer