D93 #100DaysOfCode

D93 #100DaysOfCode. Today I worked more with Digital Oceans APIs to see what I can do. I managed to export events from my VMs

Read Time51Seconds

Today I’ve been working more on my Digital Ocean App.

The idea of this app is to allow me to easily interact with my VMs without having to log in to the console and to let me play around with the APIs.

What I’ve done today is pulled my droplets (Virtual Machines) down into a list and then ran a for loop to get all the events for each droplet, see below code.

import digitalocean
import os

API_SECRET = os.environ.get("TOKEN")
manager = digitalocean.Manager(token=API_SECRET)
my_droplets = manager.get_all_droplets()
for droplet in my_droplets:
    print(droplet)
    print(droplet.get_events(), file=open("droplet_events.txt", "a"))

So as you can see I’m grabbing the events for each droplet and exporting the events to a text file, it’s nicer than having it all blasted in the terminal and lets me store it for later use.

I’m going to keep playing around with the APIs and then start working on making a droplet with my new app.

0 0
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleppy
Sleppy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Leave a Reply

Your email address will not be published. Required fields are marked *

Close