I’m trying to implement a parent-child stream for ...
# singer-tap-development
m
I’m trying to implement a parent-child stream for the first time, following the instructions here. I’m implementing a tap for a healthcheck API, where there is a
GET /healthchecks
endpoint that returns all healthchecks (this is the parent stream), and a
GET /healthchecks/{id}/response-time
endpoint that returns raw response time data for the healthcheck with id
{id}
(this is the child stream). The response that’s returned from the response-time endpoint doesn’t contain the
id
of the healthcheck, and I want to add it to the records emitted by the child stream. In the parent stream, I’m overriding the
get_child_context
method to set the
id
. This makes it available to the child stream to an extent - the
path
string can interpolate it. But I need to do some reshaping of the raw response data from the response-time endpoint and I don’t see a way to do that within the
parse_response
method (that method doesn’t receive a
context
argument). The
post_process
method does receive a
context
argument so I’m hoping I can add the
id
if I override that method. Is that accurate? Override
parse_response
to reshape the response data into an iterable of dicts, and then add the
id
field in an overridden
post_process
method?
1
p
@Matt Menzenski thats how I'd do it,
post_process
will have your parent context
id
. I recently did something similar. Usually I dont need to actually override the parse_response method though if I'm using the rest stream because the
records_jsonpath
property handles extracting the list field that contains all the results
m
thanks Pat! I’ve confirmed that this works for me
👍 1