Skip to main content

Pritunl API Client for Python

Project description

Pritunl API client for Python 3

This is a simple api client written in Python 3. View example in example.py. Python 2 is not supported. You need to refer Pritunl api doc to get the idea on how to use this.

Basically this api client use almost same command like in the doc. For example:

Quick Usage

import os

from pritunl_api import Pritunl

PRITUNL_BASE_URL = os.environ.get('PRITUNL_BASE_URL')
PRITUNL_API_TOKEN = os.environ.get('PRITUNL_API_TOKEN')
PRITUNL_API_SECRET= os.environ.get('PRITUNL_API_SECRET')

pritunl = Pritunl(
    url=PRITUNL_BASE_URL,
    token=PRITUNL_API_TOKEN,
    secret=PRITUNL_API_SECRET
    )

Example

  • Example 1

    (in source) GET /server/:server_id

    pritunl.server.get()
    
  • Example 2

    (in source) PUT /server/:server_id/organization/:organization_id

    pritunl.server.put(srv_id='', org_id='')
    
  • Example 3

    (in source) DELETE /user/:organization_id/:user_id

    pritunl.user.delete(org_id='', usr_id='')
    
  • Example 4

    (in source) POST /server**

    pritunl.server.post(data={
      'name': 'new server name'})
    

    * If there is data available, you must pass it through data parameter.

    * Command above works well because there are template available for creating a new server.

  • Example 5

    (in source) PUT /user/:organization_id/:user_id

    api.user.put(org_id='', usr_id='', data={
      'name': 'modified org name',
      'disabled': True})
    

Installation

pip install pritunl-api

Include REPL Tools

pip install pritunl-api[repl]

API Development

Docker Environment

Building a Development Container

docker buildx build . \
  --progress plain \
  --file dev.Dockerfile \
  --tag pritunl_api:development

Running a Development Container

docker run --rm -it \
  --volume $(PWD):/pritunl-api \
  --env-file EnvironmentFile \
  pritunl_api:development

This api client is not fully complete. There are some features missing, feel free to fork and pull request to add new features.

Tested working on Pritunl v1.30.3354.99.

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

pritunl-api-1.0.3.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pritunl_api-1.0.3-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file pritunl-api-1.0.3.tar.gz.

File metadata

  • Download URL: pritunl-api-1.0.3.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.7

File hashes

Hashes for pritunl-api-1.0.3.tar.gz
Algorithm Hash digest
SHA256 aeb07ea5b820f16be41fa72d373c4ea9cdd38721ec189a2db9f814879bc78cb5
MD5 7c2dc38eea8d36c24ee003981f4c1067
BLAKE2b-256 926f9cbda79f6dbf3af290d50385bbf899decff207039f9670a7d3e984f6af7f

See more details on using hashes here.

File details

Details for the file pritunl_api-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: pritunl_api-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.7

File hashes

Hashes for pritunl_api-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e933076171a6e5007d9b8cfb995e78110f8b3c161fe63f443478ccef317a0e27
MD5 347e51c83e7a09eda084c4fc5eef32bd
BLAKE2b-256 edb31bd53f469256853e6dd8a61b2d6b2959b93f4c2e0e36153d0bc0d771f8f4

See more details on using hashes here.

Supported by

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