pachadotdev / analogsea

Digital Ocean R client
https://pacha.dev/analogsea/
Apache License 2.0
154 stars 24 forks source link

Cleanly separate low level and high level API #36

Closed hadley closed 9 years ago

hadley commented 10 years ago

It feels like analogsea is currently fighting to be two things: both a low-level and a high-level wrapper. I'd recommend making this distinction more clear - for example, I'd rewrite droplet_power_cycle as:

do_power_cycle <- function(id, config) {
  stopifnot(as.numeric(id), length(id) == 1)
  do_POST(what, 
    path = sprintf('droplets/%s/actions', id), 
    args = list(type = 'power_cycle'), 
    config = config
  )
}

as_power_cyle <- function(x, ...) {
  x <- as.droplet(x)

  res <- do_power_cycle(x$id, ...)
  x
}

I'd be happy to make these changes if they seemed ok to you.

sckott commented 10 years ago

@hadley I like the proposed distinction between low and high level.

hadley commented 10 years ago

@sckott Agreed that an_ is better, but maybe it's better still to stick with the existing convention and use droplet_, image_ etc.

Would you mind adding me as a admin? I'm happy to make changes in a branch and submit pull requests if you want.

sckott commented 10 years ago

Added as collab.

No strong feeling on the prefixes

hadley commented 9 years ago

This is basically done now.