Package: pydrop
pydrop: Minimal Python Client for Digital Ocean DropletsThis is a minimal tool designed to interact with the Digital Ocean API. This does not translate all functionalities of the API but is a template I created for some of the most common operations I could perform. New tools will be added in the future as I familiarize myself further with the API structure and use as a student. For now this tool allows you to summarize all your droplets running, including and necessarily a price summary to keep tabs on your droplets monthly and hourly rates. The tool also allows you to seach by tags, delete a drop or perfrom actions such as start, stop or shutdown a droplet.Table of contentsInstallationGetting startedDigital Ocean Python CLI ToolsDigital Ocean KeyAccount InfoDroplets InfoVolume InfoSnapshot Infossh readssh postssh deleteDroplets DeleteDroplets ResetDroplets ActionInstallationThis assumes that you have native python & pip installed in your system, you can test this by going to the terminal (or windows command prompt) and tryingpythonand thenpip listIf you get no errors and you have python 2.7.14 or higher you should be good to go. Please note that I have tested this only on python 2.7.15 but can be easily modified for python 3.To installPython CLI for Digital Oceanyou can install using two methodspip install pydropor you can also trygit clone https://github.com/samapriya/pydrop.git
cd pydrop
python setup.py installFor linux use sudo.Installation is an optional step; the application can be also run directly by executing pydrop.py script. The advantage of having it installed is being able to execute ppipe as any command line tool. I recommend installation within virtual environment. If you don't want to install, browse into the pydrop folder and trypython pydrop.pyto get to the same result.Getting startedAs usual, to print help:usage: pydrop [-h]
              {dokey,accinfo,dropinfo,volinfo,snapinfo,sshread,sshpost,sshdelete,dropaction,dropdelete,dropreset}
              ...

Digital Ocean API Python CLI

positional arguments:
  {dokey,accinfo,dropinfo,volinfo,snapinfo,sshread,sshpost,sshdelete,dropaction,dropdelete,dropreset}
    dokey               Enter your Digital Ocean API Key
    accinfo             Prints your account info
    dropinfo            Prints information about all your droplets
    volinfo             Prints information about all your volumes
    snapinfo            Prints information about all your snapshots
    sshread             Prints information about your ssh keys
    sshpost             Adds new ssh keys to account
    sshdelete           Deletes a ssh keys from account
    dropaction          Performs an action on your droplets
    dropdelete          Permanently deletes the droplet
    dropreset           Resets password for the droplet

optional arguments:
  -h, --help            show this help message and exitTo obtain help for a specific functionality, simply call it withhelpswitch, e.g.:pydrop dropinfo -h. If you didn't install pydrop, then you can run it just by going topydropdirectory and runningpython pydrop.py [arguments go here]Digital Ocean Python CLI ToolsThe Digital Ocean Python CLI and tools setup contains minimal CLI in python to perform basic actions on droplets along with query and analyze your DO enviroment quickly.Digital Ocean KeyThis tool basically asks you to input your Digital Ocean API Key using a password prompt this is then used for all subsequent tools. This tool now includes an option for a quiet authentication using the API key incase it is unable to invoke an interactive environment such as in Google colaboratory.usage: pydrop dokey [-h] [--key KEY]

optional arguments:
  -h, --help  show this help message and exit

Optional named arguments:
  --key KEY   Your Digital Ocean API KeyIf using on a private machine the Key is saved as a csv file for all future runs of the tool.Droplets InfoThis tool prints account info about your account including, droplet and volume limit, your email, and so on. The setup would bepydrop accinfoDroplets InfoThe droplets info tool prints summary info about all your droplets. You can choose to narrow it down further using a droplet tag so only those droplets with speific tags will be printed. Since I wanted the ability of including price summaries, I have included prices summaries.usage: pydrop dropinfo [-h] [--tag TAG]

optional arguments:
  -h, --help  show this help message and exit

Optional named arguments:
  --tag TAG   Use a tag to refine your searchVolume InfoAs the name suggest incase you have any volumes attched, this will print information about the volumes attached. If no volumes exists, it will print that and exit out. The setup would bepydrop volinfoSnapshot InfoThis will print information about any existing snapshot that you might have. Setup again ispydrop snapinfossh readThis setup will simply read all your ssh keys and print them including the key, the id , name and so on. Setup would bepydrop sshreadssh postThis will allow you to add a new ssh key to your existing ssh keys. The required inputs are name and the keyusage: pydrop sshpost [-h] --name NAME --keyfile KEYFILE

optional arguments:
  -h, --help         show this help message and exit

Required named arguments.:
  --name NAME        name for ssh key
  --keyfile KEYFILE  file with ssh keyssh deleteThis will delete an ssh key, if no key id is provided, the tool first prints out all the ssh keys and their ids to choose from. Setup with a keyid would be simplypydrop sshdeleteThe above command will essentially call a sshread function to get you the key ids. If you know the key id the command then takes that as an inputusage: pydrop sshdelete [-h] [--keyid KEYID]

optional arguments:
  -h, --help     show this help message and exit

Optional named arguments:
  --keyid KEYID  ssh key idDroplets DeleteThis deletes a droplet and you can specify either the droplet name or id. Incase you don't remember the name or id, just run the tool without any arguments and it will list out all droplet id(s) and names.usage: pydrop dropdelete [-h] [--id ID] [--name NAME]

optional arguments:
  -h, --help   show this help message and exit

Optional named arguments:
  --id ID      Use an image ID to delete droplet
  --name NAME  Use an image name to delete dropletDroplets ResetThis resets the password of a droplet and you can specify either the droplet name or id. Incase you don't remember the name or id, just run the tool without any arguments and it will list out all droplet id(s) and names.usage: pydrop dropreset [-h] [--id ID] [--name NAME]

optional arguments:
  -h, --help   show this help message and exit

Optional named arguments:
  --id ID      Use an image ID to delete droplet
  --name NAME  Use an image name to delete dropletDroplets ActionThe droplet action tool was designed to achieve and have more control over individual droplet actions and I included actions such as shutdown, power off, power on and rename. Just like the droplet delete tool, this tool will print the name and id of all droplets if no arguments are passed and you can then choose the one on which to perform the action.usage: pydrop dropaction [-h] [--id ID] [--name NAME] [--action ACTION]
                       [--rename RENAME]

optional arguments:
  -h, --help       show this help message and exit

Optional named arguments:
  --id ID          Use an image ID to perform action
  --name NAME      Use an image name to perform action
  --action ACTION  Action type |shutdown="graceful shutdown"|power_off="hard
                   shutdown"|power_on="power on"|rename="rename
  --rename RENAME  Incase you are renaming droplet you can provide new nameChangelogv0.0.6Fixed action tool for idAdded reboot and snapshot actions.v0.0.5Added additional tools like sshfunctions, volume and snapshot readsGeneral improvements to overall toolv0.0.4Now calculates total cost till date based on active dropletsv0.0.3Now checks for keys and auto initializes if missingIncludes password reset tool