项目作者: anselmevignon

项目描述 :
a shell-friendly python client for using online API
高级语言: Python
项目地址: git://github.com/anselmevignon/online-api.git
创建时间: 2017-04-28T16:43:23Z
项目社区:https://github.com/anselmevignon/online-api

开源协议:

下载


online-api

A shell-friendly python client for using online API

This script implements accessing and extracting data from the online.net API (https://console.online.net/en/api/)

Install

from the cloned repository
pip install . —upgrade -r requirements.txt

Configuration:

You need to write a script configuration, located by default in /etc/online.secret:

  1. {
  2. "access_token" : "YOUR_ACCESS_TOKEN"
  3. }

The access token is available in online.net console, under the API menu.

Example Usage

Two commands are available:

  • get: get a given endpoint,
  • get_parsed: return a jsonpathed endpoint.

examples

  1. $./online_api.py get user
  2. first_name: Roger
  3. last_name: Rabbit
  4. company: ACME Inc.
  5. email: sysadmin@acme.inc
  6. login: roger.rabbit
  7. id: XXXXXX
  8. $./online_api.py get server/failover
  9. {"status": "active", "contacts": {"owner": "acme", "tech": "acme"}, "destination": "XXX.XXX.XXX.XXX", "server": {"$ref": "/api/v1/server/XXXXXX"}, "source": "XXX.XXX.XXX.XXX", "mac": null}
  10. {"status": "active", "contacts": {"owner": "acme", "tech": "acme"}, "destination": "XXX.XXX.XXX.XXX", "server": {"$ref": "/api/v1/server/XXXXXX"}, "source": "XXX.XXX.XXX.XXX", "mac": null}
  11. $./online_api.py get_parsed server/failover server.failover '$[*].contacts.owner'
  12. acme
  13. acme

for a full reference of the available endpoints, see: https://console.online.net/en/api/
for an introduction to jsonpath, see: https://github.com/json-path/JsonPath

(not so) Advanced usage

The conf path is configurable via the ONLINE_TOKEN_FILE environment variable.

requirements:

  • fire
  • slumber
  • request
  • jsonpath_rw