Recently I have started to look at the Turbonomic API. Due to my current skill level in Python, I quickly hit a roadblock. The response from an API is in in XML format. Parsing the response in XML slowed things down a little. Which is the focus of the post. How to parse the XML response with Python.
After some time I put the pieces together can work with this product through the API.
PyCharm from JetBrains, is a full featured Python IDE. Which over the last 6 months has been my Python IDE of choice.
The official site is: https://www.jetbrains.com/pycharm.
I would like to share my experiences, which have mostly been positive.
Editions Before jumping into thoughts and experiences, lets preface with the two different editions of PyCharm. Community and Professional.
PyCharm Community Edition is the free version. For my usage, it can almost do everything I need.
If you’;re looking at Python to interact with API’;s, it’;s likely that you’;ll use the Requests module. Many platforms also offer SDK’;s to help. Such as, Boto3 which is the AWS Python SDK.
Requests is very well documented, both official and community documentation.
The official site for Requests is http://docs.python-requests.org/en/master/
In this post, we are going to cover the basics of performing a HTTP GET and working with the data.
Boto3 was my first real attempt to work with an API interface. At the start, I had difficulty using the API response. This was partly due to only light exposure to Python. Also, an incorrect understanding of what the response was.
When people talk about APIs, it’;s hard to go a minute without hearing “JSON format’;. I had seen JSON formatted text before. Combining this, with documentation displaying API call response in JSON formation, lead to a 2+2=5 scenario.
To describe a VPC is to retrieve the values of it attributes. A task we might perform to validate configuration.
This article will demonstrate the following:
Find VPC ID using filters Retrieve VPC configuration values Information on Boto3 can be found here.
This post assumes that you already have a working Boto3 installation. Including IAM configuration to perform the task. If you have not, click here for the install document.