Skip to main content

Plastclient is an API wrapper for Plast.

Project description

Plastclient is an API wrapper for Plast.

Authentication

OAuth

All updates to Plast require OAuth 2 authentication. Plast is in active development, and key/secret pairs are granted individually. Please contact njb@smartm.no if you are interested in using Plast.

AccessKeys

Applications using Plast may request additional accesskeys using the AccessKey API. These keys are used to set and assert ownership to objects created in Plast, and may be devided to individual users, groups of users or however the application sees fit.

Installation

$ pip install plastclient

Usage

from plastclient import PlastClient

pc = PlastClient(’http://plast.host.com’, <oauth_key>, <oauth_secret>)

states = pc.State.search(‘relativity’)

General principles

  • All communication is REST.

  • All states & statesets have a public view.

  • All data returned as dictionaries.

  • OAuth key/secret & plast_accesskey is required for all updates.

Query

Query API.

meta

Gets metadata for a list of uuids. All types are supported.

pc.Query.meta([uuid1,uuid2])

AccessKey

Use to interact with accesskeys.

all

Get a list of all accesskeys belonging to your application.

pc.AccessKey.all()

add

Create a new accesskey for you application.

pc.AccessKey.add()

update

Update an accesskey’s linked sets.

pc.AccessKey.update(<accesskey>, statesets=[<set_uuid1>,<set_uuid2>], add=[<set_uuid3>], remove=[<set_uuid0>])

If statesets is provided add and remove are ignored.

  • statesets - replaces existing sets with provided sets

  • add - appends listed sets

  • remove - removes listed sets

State

Use to interact with states in Plast.

get

pc.State.get(<state_uuid>)

get_list

pc.State.get_list([<state_uuid1>,<state_uuid2>])

add

pc.State.add(‘state name’, <accesskey>)

update

pc.State.update(<state_uuid>, <accesskey>, name=’updated name’, desription=’updated description’)

StateSet

Use to interact with statesets.

get

pc.StateSet.get(<set_uuid>)

add

pc.StateSet.add(‘name of set’, <accesskey>)

update

pc.StateSet.update(<set_uuid>, <accesskey>, name=’updated name’, description=’updated description’, states=[<state_uuid1>,<state_uuid2>], disabled=False)

states

Get a fully detailed list of all states linked to this set.

pc.StateSet.states(<set_uuid>)

Place

Use to interact with places.

get

pc.Place.get(<place_uuid>)

add

pc.Place.add(‘name’, ‘description’, ‘latitude’, ‘longitude’, <accesskey>)

update

pc.Place.update(<place_uuid>, ‘name’, ‘description’, ‘latitude’, ‘longitude’, <accesskey>)

get_meta

pc.Place.get_meta([<uuid1>,<uuid2>])

get_places

pc.Place.get_places(<place_uuid>)

update_places

pc.Place.update_places(<place_uuid>, [<place_x_uuid>,<place_y_uuid>] , <accesskey>)

Exception handling

Controlled exceptions might occur - permissions denied, not found, etc. These exceptions are cought and re-thrown as a PlastError.

try:

pc.State.get(<non_existing_uuid>)

except PlastError, e:

print e

PlastError har 3 properties:

  • url - the failed url.

  • code - the returned http statuscode.

  • msg - a message.

Changelog

0.2.1

  • Added support for the new Query API

  • Minor bugfixes

0.2.0

  • Support for moved meta endpoint in plast

0.1.9

  • Added get_meta function to Place for getting meta from a list of place uuids

  • Minor bugfixes

0.1.8

  • Expanding Place API

  • Added AccessKey.places to get places associated with key

  • Added Place.modify_root to modify root property

  • Added support for adding root property in Place.add

0.1.7

  • Added support for Place API

  • Removed annoying print statement from State.update

0.1.6

  • Improved Stateset update protection and errorhandling.

0.1.5

  • Updated StateSet.update ignoring None values.

0.1.4dev

  • First public release of plastclient

  • Still under active development

enjoy.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plastclient-0.2.1.tar.gz (5.8 kB view details)

Uploaded Source

File details

Details for the file plastclient-0.2.1.tar.gz.

File metadata

  • Download URL: plastclient-0.2.1.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for plastclient-0.2.1.tar.gz
Algorithm Hash digest
SHA256 11ae9ce8411527786b183b19003e64bbcdce52496ce4f72f75018dd37a054089
MD5 4f663d381931c567ca331f751282956f
BLAKE2b-256 ca990f6be5550276d8fb83da3bbfd21d36336de3584647c1091cefbfe73c1677

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page