Giter VIP home page Giter VIP logo

pds-restclient-py-jo's Introduction

Portworx Data Services Rest API Client for Python

Get a token from PDS. Then add it as a shell env var so you can use the python pds_rest_client. Token can by found by clicking the user profile in the PDS ui, it is in the bottom left corner and is a "user person" icon. Create a new bearer token and copy it to your machine. More info here: https://prod.pds.portworx.com/swagger/index.html

export BEARER_TOKEN=""

Example

Example this code Gets your ID information and your project, deletes any unhealthy k8s clusters and all the deployments on them. This helps cleanup the demo.

import pds_rest
import json
# Get PDS accounts
all_accounts = json.dumps(pds_rest.get_accounts())
x = json.loads(all_accounts)

#For first account find all of the users in that account
account_id = json.dumps(x["data"][0]["id"], indent=4)
account_id = account_id.replace('"', '')
users = pds_rest.get_users(account_id)


#get deployment targets - k8s clusters
ten_id = pds_rest.get_tenants(account_id)
ten_id = json.dumps(ten_id["data"][0]["id"])
ten_id = ten_id.replace('"', '')
targets = pds_rest.get_deploymenttargets(ten_id)
targetjson = json.dumps(targets["data"])

#Finds unhealthy clusters, deletes all deployments on them then deletes the cluster
pds_rest.clean_unhealthy_clusters(targetjson, ten_id)

or download the file and run:

export BEARER_TOKEN="yourpdstoken"
python3 clean_up_demo.py

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.