Skip to content

Commit

Permalink
Merge pull request #11 from joshdk/develop
Browse files Browse the repository at this point in the history
Add support for enterprise CircleCI instances
  • Loading branch information
qba73 committed Jun 17, 2016
2 parents 2f3ad7c + 67016db commit 8aa7d57
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
15 changes: 15 additions & 0 deletions README.rst
Expand Up @@ -256,3 +256,18 @@ Clear build cache
# Clear build cache
client.cache.clear(username='<username>', project='<project_name>')
Use a custom CircleCI endpoint
------------------------------

.. code:: python
import os
from circleclient import circleclient
token = os.environ['API_TOKEN']
client = circleclient.CircleClient(api_token=token, endpoint='https://cci.example.com/api/v1')
# Use client as normal
client.user.info()
6 changes: 3 additions & 3 deletions circleclient/circleclient.py
Expand Up @@ -13,8 +13,9 @@ class CircleClient(object):
Attributes:
api_token: CircleCI API token for the client.
"""
def __init__(self, api_token=None):
def __init__(self, api_token=None, endpoint=None):
self.api_token = api_token
self.endpoint = 'https://circleci.com/api/v1' if endpoint is None else endpoint
self.headers = self.make_headers()
self.user = User(self)
self.projects = Projects(self)
Expand All @@ -31,8 +32,7 @@ def make_headers(self):
'Accept': 'application/json'}

def make_url(self, path):
endpoint = 'https://circleci.com/api/v1'
return endpoint + path
return self.endpoint + path

def client_get(self, url, **kwargs):
"""Send GET request with given url."""
Expand Down
15 changes: 15 additions & 0 deletions docs/usage.rst
Expand Up @@ -177,3 +177,18 @@ Clear build cache
# Clear build cache
client.cache.clear(username='<username>', project='<project_name>')
Use a custom CircleCI endpoint
------------------------------

.. code:: python
import os
from circleclient import circleclient
token = os.environ['API_TOKEN']
client = circleclient.CircleClient(api_token=token, endpoint='https://cci.example.com/api/v1')
# Use client as normal
client.user.info()

0 comments on commit 8aa7d57

Please sign in to comment.