Tanner Wilcox
04/29/2025, 8:37 PMTanner Wilcox
04/29/2025, 8:47 PMEdgar Ramírez (Arch.dev)
04/29/2025, 9:54 PMIdeally I would be able to supply a list of hosts to reach out to based on the response from an initial api call to get a list of hostsThat sounds like the perfect use case for Parent-Child streams.
Tanner Wilcox
04/29/2025, 10:15 PMEdgar Ramírez (Arch.dev)
04/29/2025, 10:27 PMHosts
and Devices
. The Hosts
stream class makes a single request for get a list of hosts and generates a context for each one. The Devices
stream class then uses the context object that's automatically passed from the parent stream to configure the query for the corresponding device.Tanner Wilcox
05/01/2025, 6:33 PMTanner Wilcox
05/01/2025, 7:03 PMImplement one of the below methods to pass context from the parent to the child:
1. If usingyou can simply return a tuple instead of aget_records
dictionary. A tuple return value will be interpreted by the SDK asrecord
.(record: dict, child_context: dict)
2. Overrideto return a new child context object based on records and any existing context from the parent stream.get_child_context
3. If you need to sync more than one child stream per parent record, you can overrideI don't really understand whatto yield as many contexts as you need.generate_child_contexts
get_records
is. The docs say that it needs to be overridden by the child class but at the same time it can optionally return a child context? So the child that's overriding it needs to create its own context? What is it returning a context for? To potentially another child?Edgar Ramírez (Arch.dev)
05/02/2025, 11:40 PMThe docs say that it needs to be overridden by the child class but at the same time it can optionally return a child contextYeah, that's a bit of the older way of doing so I may need to update the docs. The way I'd recommend to do this is implementing generate_child_contexts in `HostStream`:
class HostStream(RESTStream):
def generate_child_contexts(self, record, context):
yield {
"hostname": ident.get("name"),
"ip": ip_address.split("/")[0]
}
class OltStream(RESTStream):
parent_stream_type = HostStream
How would you pass the host information to the request for the Olt stream?