Skip to content

Instantly share code, notes, and snippets.

@velp
Last active April 5, 2020 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save velp/c75c1924afdb5035eeee869a320bd64e to your computer and use it in GitHub Desktop.
Save velp/c75c1924afdb5035eeee869a320bd64e to your computer and use it in GitHub Desktop.
How to use Jexia SDK for consumption API

Install jexia-sdk

pip install jexia-sdk

Example:

from jexia_sdk.http import HTTPClient

JEXIA_PROJECT_ID = '<PROJECT_HERE>'
JEXIA_API_KEY = '<API_KEY_HERE>'
JEXIA_API_SECRET = '<API_SECRET_HER>'


if __name__ == '__main__':
    client = HTTPClient()
    client.auth_consumption(
        project=JEXIA_PROJECT_ID,
        method='apk',
        key=JEXIA_API_KEY,
        secret=JEXIA_API_SECRET,
    )
    # Get all applications
    res = client.request(method='GET', url='/ds/applications')
    print('ALL APPLICATIONS: %s' % res)
    # Get applicagtion by ID
    app_id = '379f825b-df5e-48f7-a0f2-bae83794f1da'
    res = client.request(
        method='GET',
        url='/ds/applications',
        cond='[{"field":"id"},"=","%s"]' % app_id,
    )
    print('GET APPLICATION: %s' % res)
    # Update application by ID
    res = client.request(
        method='PATCH',
        data={
            'number_of_builds': 1,
        },
        url='/ds/applications',
        cond='[{"field":"id"},"=","%s"]' % app_id,
    )
    print('UPDATED APPLICATION: %s' % res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment