DigitalOceanPHP / Client

DigitalOcean API v2 client for PHP
MIT License
710 stars 205 forks source link

Add support for monitoring API #294

Closed sdwru closed 2 years ago

sdwru commented 2 years ago

I think this is a recent addition.

https://docs.digitalocean.com/reference/api/api-reference/#tag/Monitoring

sdwru commented 2 years ago

Just wondering if I should do this myself or wait? I need this for a project I am working on but it might be awhile before I have time to submit a pull request for it.

webignition commented 2 years ago

I'd say it'd be best to implement this yourself. By both implementing and using the change you can be sure it works.

sdwru commented 2 years ago

They did this api a little differently than usual so I can't just go by other examples in this sdk. They have sub and sub sub urls on this one

monitoring/alerts , get all, create, destoy
monitoring/metrics/droplets, get -- bandwidth, cpu, filesystem free, filesystem size, load 1, load 5, load 15, free mem, cached mem, total mem, avail mem.

https://docs.digitalocean.com/reference/api/api-reference/#tag/Monitoring

If someone can give an example what file structure this should have it would be helpful so that I can eventually merge this here.

Right now I am doing the basic structure this way:

Api/Monitoring.php
Entity/MonitoringAlert.php
Entity/MonitoringMetric.php

Monitoring.php has the following methods

// Alerts sub url
getAlerts()
getAlert(someAlertId)

// Droplet metrics sub sub url
getDropletCpu()
getDropletBandwidth()
getDropletLoad1()
...
...

Am I on the right track so far or does it need to be broken up further or differently?

GrahamCampbell commented 2 years ago

Added in v4.4.0. :)