Created
June 30, 2016 12:54
-
-
Save pmav99/3460e4b97e084b5ab6d16137758f3445 to your computer and use it in GitHub Desktop.
An example of using circle CI with hammock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# module: circle_ci_example.py | |
# author: Panagiotis Mavrogiorgos (pmav99) | |
""" | |
An example of using Circle-CI's REST API using hammock. | |
For more info on how to use hammock check the documentation: | |
https://github.com/kadirpekel/hammock | |
""" | |
import pprint | |
import hammock | |
CIRCLE_TOKEN = "Replace this with your own" | |
circle = hammock.Hammock( | |
name="https://circleci.com/api/v1", # the API endpoint | |
params={"circle-token": CIRCLE_TOKEN}, # append 'circle-token' to every request | |
headers={"Accept": "application/json"}, # receive compact JSON | |
) | |
print("Check the circle object") | |
print(circle) | |
print(type(circle)) | |
print() | |
print("Construct a URL") | |
print(circle.me) | |
print(type(circle.me)) | |
print() | |
print("make an actual request") | |
response = circle.me.GET() | |
print(type(response)) | |
print(response.url) | |
print() | |
print("check the response") | |
pprint.pprint(response.json()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment