Giter Club home page Giter Club logo

nebula-python-sdk's Introduction

Nebula-Python-SDK

Travis CI unit tests & auto PyPi push status: Build Status

Code coverage: codecov

An SDK for managing nebula via python.

translates all of Nebula API calls to something more pythonic.

Source code is available at github

How To Use

first get NebulaPythonSDK onto your machine

# Install from PyPi
pip install NebulaPythonSDK

now use it in your code

# Load API wrapper from library
from NebulaPythonSDK import Nebula

# Create API object.
# port defaults to 80, protocol defaults to "http" & request_timeout defaults to 60 if any of them is not set.
connection = Nebula(username="your_nebula_user", password="your_nebula_pass", host="nebula.example.com", port=80, protocol="http", request_timeout=60)

# List apps
app_list = connection.list_apps()

# List app info
app_config = connection.list_app_info("app_name")

# Create app
app_conf = {
    "containers_per_cpu": 8,
    "env_vars": {
        "test": "blabla",
        "test3t2t32": "tesg4ehgee"
    },
    "docker_ulimits": [],
    "networks": ["nebula"],
    "running": True,
    "rolling_restart": False,
    "volumes": ["/tmp:/tmp/1", "/var/tmp/:/var/tmp/1:ro"],
    "containers_per": {
        "cpu": 6
    },
    "starting_ports": [
        {
            "81": 80
        }
    ],
    "docker_image": "httpd",
    "privileged": False,
    "devices": []
}
connection.create_app("app_name", app_conf)

# create device group
device_group_config = {"apps": ["app_name"]}
connection.create_device_group("device_group_name", device_group_config)

# list device group
connection.list_device_group("device_group_name")

# list device group info
connection.list_device_group_info("device_group_name")

# ping api
connection.check_api()

# delete app
connection.delete_app("app_name")

# stop app
connection.stop_app("app_name")

# start app
connection.start_app("app_name")

# restart app
connection.restart_app("app_name")

# update app
connection.update_app("app_name", app_conf)

# update app force all params - will reset all params to default values if not declared and raise an error for params 
# that are required but not given, similar to the POST update of the API
connection.update_app("app_name", app_conf, force_all=True)

# prune images on all device groups
connection.prune_images()

# delete device_group
connection.delete_device_group("device_group_name")

# prune images on a selected device groups
connection.prune__device_group_images("device_group_name")

# update device group
connection.update_device_group("device_group_name", device_group_config)

# list paginated reports
connection.list_reports()

# create a user
user_config = {"password": "user_password", "token": "user_token"}
connection.create_user("user_name", user_config)

# list user info
connection.list_user("user_name")

# list all users
connection.list_users()

# update a user
user_config = {"password": "new_password", "token": "new_token"}
connection.update_user("user_name", user_config)

# refresh a user token
connection.refresh_user_token("user_name")

# delete a user
connection.delete_user("user_name")

# create a user group
user_group_config = {
                        "group_members": [
                            "user_name"
                            ], 
                        "pruning_allowed": True, 
                        "apps": {
                            "app_name": "rw"
                            }, 
                        "device_groups": {
                            "device_group_name": "ro"
                            }, 
                        "admin": False
                    }
connection.create_user_group("user_group_name", user_group_config)

# list user group info
connection.list_user_group("user_group_name")

# list all users group
connection.list_user_groups()

# update a user group
user_group_config = {"admin": False}
connection.update_user_group("user_group_name", user_group_config)

# delete a user group
connection.delete_user_group("user_group_name")

# list all cron jobs
connection.list_cron_jobs()

# delete a cron job
connection.delete_cron_job("cron_job_name")

# list a cron job
connection.list_cron_job_info("cron_job_name")

# create a cron job
cron_job_config = {
  "env_vars": {"test": "test123"},
  "docker_image" : "nginx",
  "running": True,
  "volumes": [],
  "networks": ["nebula", "bridge"],
  "devices": [],
  "privileged": False,
  "schedule": "0 * * * *"
}
connection.create_cron_job("cron_job_name", cron_job_config)

# update a cron job
cron_job_config = {
  "schedule": "5 * * * *"
}
connection.update_cron_job("cron_job_name", cron_job_config)

# update a cron job force all params - will reset all params to default values if not declared and raise an error for 
# params that are required but not given, similar to the POST update of the API
cron_job_config = {
  "schedule": "5 * * * *",
  "docker_image" : "nginx"
}
connection.update_cron_job("cron_job_name", cron_job_config, force_all=True)

nebula-python-sdk's People

Contributors

dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar naorlivne avatar nebula-bot avatar vineyyadav avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nebula-python-sdk's Issues

Add PyPI description

Expected/Wanted Behavior

The PyPI description should match the GitHub readme.

Actual Behavior

The PyPI description field is empty.

Auto push to PyPi

There should be a full CI\CD (TravisCI based most likely) that autopushes the SDK to the PyPi whenever an update is made to the Repo.

automatically create github branches, tags, release & a changelog whenever the version is bumped\released

Expected/Wanted Behavior

Similar to what's been done in https://github.com/naorlivne/parse_it Travis CI should be configured that whenever the version of the sdk is changed to do the following:

  1. create a new tag of the matching version
  2. create a new release of the matching version (should also create the tag)
    3, create a new branch of the matching version
  3. use naorlivne/github-changelog-generator-dockerized docker container to auto create a changelog and push it to the repo

Actual Behavior

There are no release notes\changelog & all version branches & tags are manually created.

Remove unneeded modules from requirements.txt file

Currently the requirements.txt is a mess, each repo should only include the requirements it actaully needs to function and not have grabage that was either once needed but not anymore or needed by another repo in the Nebula project but not this repo.

Update prereqs

Expected/Wanted Behavior

All prereqs at requirements.txt needs to up to date

Actual Behavior

Some packages are outdated

Port configuration improvment

While currently possible to have Port configured in the "host" param like "nebula.host.com:8888" it deserves it's own "port" param when you create the connection to a nebula server.

Auto match version to branch on deployment

Expected/Wanted Behaviour

The version of the SDK should be auto set to match the branches (and ignore the master branch as it's not the one that should be deployed from to PyPi but rather only valid numbered version branches).

the $TRAVIS_BRANCH envvar will likely be part of the solution but as this should be a change in the codebase itself (rather then just assigning the variable value a more complex solution the just os.getenv(TRAVIS_BRANCH) will be needed.

Possible solutions (need to read more about them):

Actual Behaviour

Version is manually set before deployments.

Migrate to Python 3.x

Expected/Wanted Behaviour

With Python 2.x nearing it's EOL Nebula should migrate to Python 3.x (with the current minor version target being the latest released version)

Actual Behaviour

Nebula is is currently Python 2.7.x based

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.