How to ask boto internals to parse responses from AWS?

586 views
Skip to first unread message

Kirill Kazakov

unread,
Jan 31, 2014, 12:41:27 PM1/31/14
to boto-...@googlegroups.com
Hello everyone!

I'd like to use boto internals to parse responses from AWS API.

I have a lot of such responses in CloudTrail logs and I don't want to parse them manually. They are in JSON, though I could convert JSON to XML to feed them to boto. And is it possible to ask some internals from boto to parse those responses? So that I would get high-level objects like boto.ec2.group.Group and so on.

-- 
Thank you,
Kirill Kazakov
Information Security Officer
Ecwid

J Light

unread,
Feb 3, 2014, 5:28:21 PM2/3/14
to boto-...@googlegroups.com
I'd be interested to hear if this is possible as well?


--
You received this message because you are subscribed to the Google Groups "boto-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to boto-users+...@googlegroups.com.
To post to this group, send email to boto-...@googlegroups.com.
Visit this group at http://groups.google.com/group/boto-users.
For more options, visit https://groups.google.com/groups/opt_out.

Andrew Gross

unread,
Feb 28, 2014, 11:10:03 AM2/28/14
to boto-...@googlegroups.com
Hey,

I don't think this will be super easy, but it should be possible with some tinkering.  Boto uses the xml.sax parser to read XML.  The main entry for this is "boto/handler.py".  This is the code that walks the XML tree and for each top level tag, figures out which object to use for further parsing.  This is where "startElement" and "endElement" come in.  These are where the meat of the parsing is done, specify what when a specific tag is found.

In the boto code, the place where the handler is called is similar to:


So you should be able to write a bit of custom code to use this on your own input, instead of an HTTP response.

J Light

unread,
Feb 28, 2014, 5:33:57 PM2/28/14
to boto-...@googlegroups.com
Hrm. Interesting. Thanks for the response. Before i look too much into it, do you happen to know if boto3 is following the same paradigm?
Also, thanks for shedding some like on the startElement and endElement pattern in the boto code. I was wondering about that for a while.


--

Andrew Gross

unread,
Mar 3, 2014, 11:05:21 AM3/3/14
to boto-...@googlegroups.com
No problem, hope it helps.  I am not very familiar with how boto3 works, so unsure what patterns they are using.
Reply all
Reply to author
Forward
0 new messages