Title: | Interface to 'DigitalOcean' |
---|---|
Description: | Provides a set of functions for interacting with the 'DigitalOcean' API <https://www.digitalocean.com/>, including creating images, destroying them, rebooting, getting details on regions, and available images. |
Authors: | Scott Chamberlain [aut] , Hadley Wickham [aut], Winston Chang [aut], Bob Rudis [ctb], Bryce Mecum [ctb] , Mauricio Vargas [aut, cre] , RStudio [cph], DigitalOcean [cph] |
Maintainer: | Mauricio Vargas <[email protected]> |
License: | Apache License (>= 2) |
Version: | 1.0.8 |
Built: | 2024-11-22 03:05:32 UTC |
Source: | https://github.com/pachadotdev/analogsea |
This package is an R client for Digital Ocean's RESTful API, and a set of scripts that allow you to install R, RStudio server, RStudio Shiny server, or OpenCPU server, in addition to common packages used. The goal here is to spin up a cloud R environment without leaving R, and requiring no knowledge other than R. Of course if you are more experienced you can log in on the command line and modify anything you want, but for those that just want a quick cloud R environment, this should be one of the easiest options.
You need to authenticate to use this package. Get your auth token at
https://cloud.digitalocean.com/settings/api/tokens - See
do_oauth
for more on authentication.
analogsea allows you to interact with your droplet(s) from R via SSH. To do this you need to setup SSH keys with Digital Ocean. Make sure you provide Digitial Ocean your public key at https://cloud.digitalocean.com/ssh_keys - GitHub has some good advice on creating a new public key if you don't already have one: https://help.github.com/articles/generating-ssh-keys
Note that when using ssh, you'll likely get warnings like "The authenticity of host can't be established ...". This is normal, don't be worried about this.
Note that if you want to connect over SSH to a droplet you have to
create the droplet with an SSH key with the ssh_keys
parameter.
If you don't you can still interact with the droplet via the Digital
Ocean API, but you can't access the droplet over SSH.
Scott Chamberlain
Hadley Wickham
Winston Chang
Bob Rudis
Bryce Mecum
Get account information
account(...)
account(...)
... |
Options passed down to |
## Not run: account() ## End(Not run)
## Not run: account() ## End(Not run)
Retrieve an existing action by action id
action(actionid, ...)
action(actionid, ...)
actionid |
(integer) Optional. An action id. |
... |
Additional arguments passed down to low-level API function
( |
## Not run: d <- droplet_create() droplet_actions(d)[[1]]$id %>% action() ## End(Not run)
## Not run: d <- droplet_create() droplet_actions(d)[[1]]$id %>% action() ## End(Not run)
"Actions are records of events that have occurred on the resources in your account. These can be things like rebooting a Droplet, or transferring an image to a new region."
actions(..., page = 1, per_page = 25) action_wait(x)
actions(..., page = 1, per_page = 25) action_wait(x)
... |
Additional arguments passed down to low-level API function
( |
page |
Page to return. Default: 1. |
per_page |
Number of results per page. Default: 25. |
x |
Input object |
"An action object is created every time one of these actions is initiated. The action object contains information about the current status of the action, start and complete timestamps, and the associated resource type and ID."
"Every action that creates an action object is available through this endpoint. Completed actions are not removed from this list and are always available for querying."
## Not run: actions() ## End(Not run)
## Not run: actions() ## End(Not run)
Adjectives to use for seeding random word selection when name not given for a droplet
A vector of 999 adjectives. From the GitHub repo https://github.com/dariusk/corpora - the data is licensed CC0.
These functions are gone, no longer available.
tag_rename()
: DigitalOcean removed this functionality from their API.
See
https://developers.digitalocean.com/documentation/changelog/api-v2/deprecating-update-tag/
for details.
Debian functions, prefer the Ubuntu equivalents.
debian_add_swap()
debian_install_r()
debian_install_rstudio()
debian_install_shiny()
debian_install_opencpu()
debian_apt_get_update()
debian_apt_get_install()
Get list of certificate and their metadata, or a single certificate
as.certificate(x) certificates(page = 1, per_page = 25, ...) certificate(id, ...) certificate_create( name, type, private_key = NULL, leaf_certificate = NULL, certificate_chain = NULL, dns_names = NULL, ... )
as.certificate(x) certificates(page = 1, per_page = 25, ...) certificate(id, ...) certificate_create( name, type, private_key = NULL, leaf_certificate = NULL, certificate_chain = NULL, dns_names = NULL, ... )
x |
Object to coerce to an certificate |
page |
Page to return. Default: 1. |
per_page |
Number of results per page. Default: 25. |
... |
Additional arguments passed down to low-level API function
( |
id |
(numeric) certificate id |
name |
(character) a certificate name |
type |
(character) a string representing the type of certificate. The value should be "custom" for a user-uploaded certificate or "lets_encrypt" for one automatically generated with Let's Encrypt. If not provided, "custom" will be assumed by default. |
private_key |
(character) the contents of a PEM-formatted private-key corresponding to the SSL certificate |
leaf_certificate |
(character) the contents of a PEM-formatted public SSL certificate |
certificate_chain |
(character) the full PEM-formatted trust chain between the certificate authority's certificate and your domain's SSL certificate |
dns_names |
(character) a vector of fully qualified domain names (FQDNs) for which the certificate will be issued. The domains must be managed using DigitalOcean's DNS |
## Not run: # list certificates certificates() # create a certificate (create a fake domain first) d <- domain_create('tablesandchairsbunnies.stuff', '107.170.220.59') certificate_create("mycert", "lets_encrypt", dns_names = list('tablesandchairsbunnies.stuff')) ## End(Not run)
## Not run: # list certificates certificates() # create a certificate (create a fake domain first) d <- domain_create('tablesandchairsbunnies.stuff', '107.170.220.59') certificate_create("mycert", "lets_encrypt", dns_names = list('tablesandchairsbunnies.stuff')) ## End(Not run)
List, create, update, and delete domain records.
as.domain_record(x, domain) ## S3 method for class 'list' as.domain_record(x, domain) ## S3 method for class 'domain_record' as.domain_record(x, domain) ## S3 method for class 'domain_record' as.url(x, ...) domain_records(domain, ...) domain_record(domain, domain_record_id, ...) domain_record_create( domain, type, name = NULL, data = NULL, priority = NULL, port = NULL, ttl = NULL, weight = NULL, flags = NULL, tag = NULL, ... ) domain_record_update( domain_record, type = NULL, name = NULL, data = NULL, priority = NULL, port = NULL, ttl = NULL, weight = NULL, flags = NULL, tag = NULL, ... ) domain_record_delete(domain_record, ...)
as.domain_record(x, domain) ## S3 method for class 'list' as.domain_record(x, domain) ## S3 method for class 'domain_record' as.domain_record(x, domain) ## S3 method for class 'domain_record' as.url(x, ...) domain_records(domain, ...) domain_record(domain, domain_record_id, ...) domain_record_create( domain, type, name = NULL, data = NULL, priority = NULL, port = NULL, ttl = NULL, weight = NULL, flags = NULL, tag = NULL, ... ) domain_record_update( domain_record, type = NULL, name = NULL, data = NULL, priority = NULL, port = NULL, ttl = NULL, weight = NULL, flags = NULL, tag = NULL, ... ) domain_record_delete(domain_record, ...)
x |
Domain record. |
domain |
(domain) Required. Domain Name (e.g. domain.com), specifies the domain for which to create a record. |
... |
Further args passed on the curl call to the web. |
domain_record_id |
(numeric/integer) A domain record ID |
type |
(character) Required. The type of record you would like to create. 'A', 'CNAME', 'NS', 'TXT', 'MX' or 'SRV' |
name |
(character) The host name, alias, or service being defined by the record. Required for 'A', 'CNAME', 'TXT' and 'SRV' records |
data |
(character) Variable data depending on record type. Required for 'A', 'AAAA', 'CNAME', 'MX', 'TXT', 'SRV', and 'NS' records |
priority |
(integer) Required for 'SRV' and 'MX' records |
port |
(integer) Required for 'SRV' records |
ttl |
(numeric/integer) Time to live for the record, in seconds. This defines the time frame that clients can cache queried information before a refresh should be requested. If not set, default is 1800 |
weight |
(integer) Required for 'SRV' records |
flags |
(integer) An unsigned integer between 0-255 used for CAA records |
tag |
(character) The parameter tag for CAA records. Valid values are "issue", "wildissue", or "iodef" |
domain_record |
A domain record, or anything coercible to one |
## Not run: # list domains, then get domain records (d <- domains()[[1]]) (rec <- domain_records(d)) # create a domain dom <- domain_create('tablesandchairsbunnies.info', '107.170.220.59') ## list domain records domain_records(dom) # create a domain record dr <- domain_record_create(dom, "CNAME", name = "helloworld", data = "@") domain_record(dom, dr$id) # update a domain record dru <- domain_record_update(domain_record = dr, name = "blog") # delete a domain record domain_record_delete(dr) ## End(Not run)
## Not run: # list domains, then get domain records (d <- domains()[[1]]) (rec <- domain_records(d)) # create a domain dom <- domain_create('tablesandchairsbunnies.info', '107.170.220.59') ## list domain records domain_records(dom) # create a domain record dr <- domain_record_create(dom, "CNAME", name = "helloworld", data = "@") domain_record(dom, dr$id) # update a domain record dru <- domain_record_update(domain_record = dr, name = "blog") # delete a domain record domain_record_delete(dr) ## End(Not run)
Get list of firewalls and their metadata, or a single firewall
as.firewall(x) firewalls(page = 1, per_page = 25, ...) firewall(id, ...) firewall_create( name, inbound_rules, outbound_rules, droplet_ids = NULL, tags = NULL, ... ) firewall_update( name, inbound_rules, outbound_rules, droplet_ids = NULL, tags = NULL, ... )
as.firewall(x) firewalls(page = 1, per_page = 25, ...) firewall(id, ...) firewall_create( name, inbound_rules, outbound_rules, droplet_ids = NULL, tags = NULL, ... ) firewall_update( name, inbound_rules, outbound_rules, droplet_ids = NULL, tags = NULL, ... )
x |
Object to coerce to an firewall. |
page |
Page to return. Default: 1. |
per_page |
Number of results per page. Default: 25. |
... |
Additional arguments passed down to low-level API function
( |
id |
(numeric) firewall id. |
name |
(character) a firewall name |
inbound_rules |
(list) inbound rules |
outbound_rules |
(list) outbound rules |
droplet_ids |
(numeric/integer) droplet ids |
tags |
(character) tag strings |
## Not run: # list firewalls firewalls() # create a firewall inbound <- list(list(protocol = "tcp", ports = "80", sources = list(addresses = "18.0.0.0/8"))) outbound <- list(list(protocol = "tcp", ports = "80", destinations = list(addresses = "0.0.0.0/0"))) res <- firewall_create("myfirewall", inbound, outbound) res # get a firewall firewall("d19b900b-b03e-4e5d-aa85-2ff8d2786f28") as.firewall("d19b900b-b03e-4e5d-aa85-2ff8d2786f28") ## End(Not run)
## Not run: # list firewalls firewalls() # create a firewall inbound <- list(list(protocol = "tcp", ports = "80", sources = list(addresses = "18.0.0.0/8"))) outbound <- list(list(protocol = "tcp", ports = "80", destinations = list(addresses = "0.0.0.0/0"))) res <- firewall_create("myfirewall", inbound, outbound) res # get a firewall firewall("d19b900b-b03e-4e5d-aa85-2ff8d2786f28") as.firewall("d19b900b-b03e-4e5d-aa85-2ff8d2786f28") ## End(Not run)
Get list of images and their metadata, or a single image
as.image(x) images( private = FALSE, type = NULL, page = 1, per_page = 25, public = TRUE, ... ) image(id, ...)
as.image(x) images( private = FALSE, type = NULL, page = 1, per_page = 25, public = TRUE, ... ) image(id, ...)
x |
Object to coerce to an image. |
private |
Include public images? If |
type |
(character) One of |
page |
Page to return. Default: 1. |
per_page |
Number of results per page. Default: 25. |
public |
Include public images? If |
... |
Additional arguments passed down to low-level API function
( |
id |
(numeric) Image id. |
## Not run: images() # list private images images(private = TRUE) # list by type images(type = "distribution") images(type = "application") # paging images(per_page = 3) images(per_page = 3, page = 2) ## End(Not run)
## Not run: images() # list private images images(private = TRUE) # list by type images(type = "distribution") images(type = "application") # paging images(per_page = 3) images(per_page = 3, page = 2) ## End(Not run)
Get list of projects and their metadata, or a single project
as.project(x) projects(page = NULL, per_page = NULL, ...) project(id = "default", ...)
as.project(x) projects(page = NULL, per_page = NULL, ...) project(id = "default", ...)
x |
Object to coerce to a project. |
page |
Page to return. Default: 1. |
per_page |
Number of results per page. Default: 25. |
... |
Additional arguments passed down to low-level API function
( |
id |
(character) project id, default: "default" |
## Not run: projects() project("f9597f51-6fb0-492c-866d-bc67bff6d409") ## End(Not run)
## Not run: projects() project("f9597f51-6fb0-492c-866d-bc67bff6d409") ## End(Not run)
retrieve a snapshot
list snapshots, all, droplets, or volumes
delete a snapshot
as.snapshot(x) snapshots(type = NULL, page = 1, per_page = 20, ...) snapshot(id, ...) snapshot_delete(snapshot, ...)
as.snapshot(x) snapshots(type = NULL, page = 1, per_page = 20, ...) snapshot(id, ...) snapshot_delete(snapshot, ...)
x |
Object to coerce to an snapshot |
type |
(character) |
page |
Which 'page' of paginated results to return (default 1). |
per_page |
Number of items returned per page (default 20, maximum 200) |
... |
|
id |
A snapshot id (varies depending on droplet or volume ID) |
snapshot |
A snapshot, or something that can be coerced to a snapshot by
|
## Not run: # list all snapshots (res <- snapshots()) # list droplet snapshots snapshots(type = "droplet") # list volume snapshots snapshots(type = "volume") # paging snapshots(per_page = 5) snapshots(per_page = 5, page = 2) # get a single snapshot snapshot(res[[1]]$id) # delete a snapshot ## a whole snapshot class object snapshot_delete(res[[2]]) ## by id snapshot_delete(res[[2]]$id) ## by name snapshot_delete(res[[2]]$name) # delete many snapshots lapply(snapshots(), snapshot_delete) ## End(Not run)
## Not run: # list all snapshots (res <- snapshots()) # list droplet snapshots snapshots(type = "droplet") # list volume snapshots snapshots(type = "volume") # paging snapshots(per_page = 5) snapshots(per_page = 5, page = 2) # get a single snapshot snapshot(res[[1]]$id) # delete a snapshot ## a whole snapshot class object snapshot_delete(res[[2]]) ## by id snapshot_delete(res[[2]]$id) ## by name snapshot_delete(res[[2]]$name) # delete many snapshots lapply(snapshots(), snapshot_delete) ## End(Not run)
space
Coerce an object to a space
as.space(x)
as.space(x)
x |
Object to coerce to a space |
get a single volume
list volumes
create a volume
create a snapshot of a volume
list snapshots for a volume
delete a volume
as.volume(x) volumes(...) volume(volume, ...) volume_create( name, size, description = NULL, region = "nyc1", snapshot_id = NULL, filesystem_type = NULL, filesystem_label = NULL, tags = NULL, ... ) volume_snapshot_create(volume, name, ...) volume_snapshots(volume, ...) volume_delete(volume, ...)
as.volume(x) volumes(...) volume(volume, ...) volume_create( name, size, description = NULL, region = "nyc1", snapshot_id = NULL, filesystem_type = NULL, filesystem_label = NULL, tags = NULL, ... ) volume_snapshot_create(volume, name, ...) volume_snapshots(volume, ...) volume_delete(volume, ...)
x |
Object to coerce to an volume |
... |
|
volume |
A volume, or something that can be coerced to a volume by
|
name |
(character) Name of the new volume. required. |
size |
(integer) The size of the Block Storage volume in GiB |
description |
(character) An optional free-form text field to describe a Block Storage volume. |
region |
(character) The region where the Block Storage volume will be created. When setting a region, the value should be the slug identifier for the region. When you query a Block Storage volume, the entire region object will be returned. Should not be specified with a snapshot_id. Default: nyc1 |
snapshot_id |
(integer) The unique identifier for the volume snapshot from which to create the volume. Should not be specified with a region_id. |
filesystem_type |
(character) The name of the filesystem type to be used on the volume. When provided, the volume will automatically be formatted to the specified filesystem type. Currently, the available options are "ext4" and "xfs". Pre-formatted volumes are automatically mounted when attached to Ubuntu, Debian, Fedora, Fedora Atomic, and CentOS Droplets created on or after April 26, 2018. Attaching pre-formatted volumes to other Droplets is not recommended. |
filesystem_label |
(character) The label to be applied to the filesystem. Labels for ext4 type filesystems may contain 16 characters while lables for xfs type filesystems are limited to 12 characters. May only be used in conjunction with filesystem_type. |
tags |
(character) tag names to apply to the Volume after it is created. Tag names can either be existing or new tags. |
note that if you delete a volume, and it has a snapshot, the snapshot still exists, so beware
## Not run: # list volumes volumes() # create a volume vol1 <- volume_create('testing', 5) vol2 <- volume_create('foobar', 6, tags = c('stuff', 'things')) # create snapshot of a volume xx <- volume_snapshot_create(vol2, "howdy") # list snaphots for a volume volume_snapshots(xx) # list volumes again res <- volumes() # get a single volume ## a whole volume class object volume(res$testing) ## by id volume(res[[1]]$id) ## by name volume(res[[1]]$name) # delete a volume ## a whole volume class object volume_delete(res$testing) ## by id volume_delete(res[[1]]$id) ## by name volume_delete(res[[1]]$name) # delete many volumes lapply(volumes(), volume_delete) ## End(Not run)
## Not run: # list volumes volumes() # create a volume vol1 <- volume_create('testing', 5) vol2 <- volume_create('foobar', 6, tags = c('stuff', 'things')) # create snapshot of a volume xx <- volume_snapshot_create(vol2, "howdy") # list snaphots for a volume volume_snapshots(xx) # list volumes again res <- volumes() # get a single volume ## a whole volume class object volume(res$testing) ## by id volume(res[[1]]$id) ## by name volume(res[[1]]$name) # delete a volume ## a whole volume class object volume_delete(res$testing) ## by id volume_delete(res[[1]]$id) ## by name volume_delete(res[[1]]$name) # delete many volumes lapply(volumes(), volume_delete) ## End(Not run)
Delete a certificate
certificate_delete(id, ...)
certificate_delete(id, ...)
id |
A certificate id (not the name) to delete |
... |
Options passed on to httr::DELETE |
Create a password with digits, letters and special characters
create_password(n = 8)
create_password(n = 8)
n |
Password length (8-15 characters) |
create_password(10)
create_password(10)
Get all the available databases that can be used to create a droplet.
databases(page = 1, per_page = 25, ...)
databases(page = 1, per_page = 25, ...)
page |
Page to return. Default: 1. |
per_page |
Number of results per page. Default: 25. |
... |
Named options passed on to |
A data.frame with available databases (RAM, disk, no. CPU's) and their costs
## Not run: databases() ## End(Not run)
## Not run: databases() ## End(Not run)
Helpers for managing a debian droplets.
debian_add_swap( droplet, user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) debian_install_r( droplet, user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE, rprofile = "options(repos=c('CRAN'='https://cloud.r-project.org/'))" ) debian_install_rstudio( droplet, user = "rstudio", password = "server", version = "0.99.484", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) debian_install_shiny( droplet, version = "1.4.0.756", user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE, rprofile = "options(repos=c('CRAN'='https://cloud.r-project.org/'))" ) debian_apt_get_update( droplet, user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) debian_apt_get_install( droplet, ..., user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE )
debian_add_swap( droplet, user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) debian_install_r( droplet, user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE, rprofile = "options(repos=c('CRAN'='https://cloud.r-project.org/'))" ) debian_install_rstudio( droplet, user = "rstudio", password = "server", version = "0.99.484", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) debian_install_shiny( droplet, version = "1.4.0.756", user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE, rprofile = "options(repos=c('CRAN'='https://cloud.r-project.org/'))" ) debian_apt_get_update( droplet, user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) debian_apt_get_install( droplet, ..., user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE )
droplet |
A droplet, or object that can be coerced to a droplet
by |
user |
Default username for Rstudio. |
keyfile |
Optional private key file. |
ssh_passwd |
Optional passphrase or callback function for authentication.
Refer to the |
verbose |
If TRUE, will print command before executing it. |
rprofile |
A character string that will be added to the .Rprofile |
password |
Default password for Rstudio. |
version |
Version of rstudio to install. |
... |
Arguments to apt-get install. |
## Not run: d <- droplet_create() d %>% debian_add_swap() d %>% debian_apt_get_update() d %>% debian_install_r() d %>% debian_install_rstudio() # Install libcurl, then build RCurl from source d %>% debian_apt_get_install("libcurl4-openssl-dev") d %>% install_r_package("RCurl") droplet_delete(d) ## End(Not run)
## Not run: d <- droplet_create() d %>% debian_add_swap() d %>% debian_apt_get_update() d %>% debian_install_r() d %>% debian_install_rstudio() # Install libcurl, then build RCurl from source d %>% debian_apt_get_install("libcurl4-openssl-dev") d %>% install_r_package("RCurl") droplet_delete(d) ## End(Not run)
This function is run automatically to allow analogsea to access your digital ocean account.
do_oauth(app = do_app, reauth = FALSE)
do_oauth(app = do_app, reauth = FALSE)
app |
An |
reauth |
(logical) Force re-authorization? |
There are two ways to authorise analogsea to work with your digital ocean account:
Generate a personal access token at
https://cloud.digitalocean.com/settings/api/tokens and
record in the DO_PAT
envar.
Interatively login into your DO account and authorise with OAuth.
Using DO_PAT
is recommended.
This function sets options and prints them so you know what options are set.
do_options( size = NULL, image = NULL, region = NULL, ssh_keys = NULL, private_networking = NULL, backups = NULL, ipv6 = NULL, unset = FALSE )
do_options( size = NULL, image = NULL, region = NULL, ssh_keys = NULL, private_networking = NULL, backups = NULL, ipv6 = NULL, unset = FALSE )
size |
(optional) A Digital Ocean size slug name, e.g. '1gb'. Saved in options as 'do_size' |
image |
(optional) A Digital Ocean image name, e.g., 'ubuntu-22-04-x64'. Saved in options as 'do_image' |
region |
(optional) A Digital Ocean region name, e.g., 'nyc1'. Saved in options as 'do_region' |
ssh_keys |
(optional) One or more ssh key id numbers or fingerprints. Put many in a list or vector. Saved in options as 'do_ssh_keys' |
private_networking |
(optional) A logical, whether to use private networking or not. Saved in options as 'do_private_networking' |
backups |
(optional) A logical, whether to enable backups. Automated backups can only be enabled when the Droplet is created. Saved in options as 'do_backups' |
ipv6 |
(optional) A boolean indicating whether IPv6 is enabled on the Droplet. Saved in options as 'do_ipv6' |
unset |
(optional) A boolean. If TRUE, unsets options so as to use
defaults in
|
These options are read and used by droplet_create
.
You can only set one value for each of size, image, and region, but multiple values for ssh_keys as you can use multiple ssh keys on one DO droplet.
Keep in mind that there are defaults set for size, image, and region
in droplet_create
.
## Not run: do_options() do_options(ssh_keys=89103) getOption('do_ssh_keys') do_options(size="8gb") do_options(size="1gb", image='ubuntu-22-04-x64', region='nyc1') getOption('do_size') getOption('do_image') getOption('do_region') ## End(Not run)
## Not run: do_options() do_options(ssh_keys=89103) getOption('do_ssh_keys') do_options(size="8gb") do_options(size="1gb", image='ubuntu-22-04-x64', region='nyc1') getOption('do_size') getOption('do_image') getOption('do_region') ## End(Not run)
Docklets: docker on droplets.
docklet_create( name = random_name(), size = getOption("do_size", "s-1vcpu-2gb"), region = getOption("do_region", "sfo3"), ssh_keys = getOption("do_ssh_keys", NULL), backups = getOption("do_backups", NULL), ipv6 = getOption("do_ipv6", NULL), private_networking = getOption("do_private_networking", NULL), tags = list(), wait = TRUE, image = "docker-20-04", keyfile = NULL, ... ) docklet_ps(droplet, all = TRUE, ssh_user = "root") docklet_images(droplet, all = TRUE, ssh_user = "root") docklet_pull( droplet, repo, ssh_user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) docklet_run( droplet, ..., rm = FALSE, name = NULL, ssh_user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) docklet_stop(droplet, container, ssh_user = "root") docklet_rm(droplet, container, ssh_user = "root") docklet_docker( droplet, cmd, args = NULL, docker_args = NULL, ssh_user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) docklet_rstudio( droplet, user, password, email = "[email protected]", img = "rocker/rstudio", port = "8787", volume = "", dir = "", browse = TRUE, add_users = FALSE, ssh_user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) docklet_rstudio_addusers( droplet, user, password, img = "rocker/rstudio", port = "8787", ssh_user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) docklet_shinyserver( droplet, img = "rocker/shiny", port = "3838", volume = "", dir = "", browse = TRUE, ssh_user = "root", keyfile = NULL ) docklet_shinyapp( droplet, path, img = "rocker/shiny", port = "80", dir = "", browse = TRUE, ssh_user = "root", keyfile = NULL )
docklet_create( name = random_name(), size = getOption("do_size", "s-1vcpu-2gb"), region = getOption("do_region", "sfo3"), ssh_keys = getOption("do_ssh_keys", NULL), backups = getOption("do_backups", NULL), ipv6 = getOption("do_ipv6", NULL), private_networking = getOption("do_private_networking", NULL), tags = list(), wait = TRUE, image = "docker-20-04", keyfile = NULL, ... ) docklet_ps(droplet, all = TRUE, ssh_user = "root") docklet_images(droplet, all = TRUE, ssh_user = "root") docklet_pull( droplet, repo, ssh_user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) docklet_run( droplet, ..., rm = FALSE, name = NULL, ssh_user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) docklet_stop(droplet, container, ssh_user = "root") docklet_rm(droplet, container, ssh_user = "root") docklet_docker( droplet, cmd, args = NULL, docker_args = NULL, ssh_user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) docklet_rstudio( droplet, user, password, email = "[email protected]", img = "rocker/rstudio", port = "8787", volume = "", dir = "", browse = TRUE, add_users = FALSE, ssh_user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) docklet_rstudio_addusers( droplet, user, password, img = "rocker/rstudio", port = "8787", ssh_user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) docklet_shinyserver( droplet, img = "rocker/shiny", port = "3838", volume = "", dir = "", browse = TRUE, ssh_user = "root", keyfile = NULL ) docklet_shinyapp( droplet, path, img = "rocker/shiny", port = "80", dir = "", browse = TRUE, ssh_user = "root", keyfile = NULL )
name |
(character) Name of the droplet. The human-readable string you
wish to use when displaying the Droplet name. The name, if set to a domain
name managed in the DigitalOcean DNS management system, will configure a
PTR record for the Droplet. The name set during creation will also
determine the hostname for the Droplet in its internal configuration.
Default: picks a random name from |
size |
(character) Size slug identifier. See |
region |
(character) The unique slug identifier for the region that you
wish to deploy in. See |
ssh_keys |
(character) A character vector of key names, an integer
vector of key ids, or NULL, to use all keys in your account. Accounts
with the corresponding private key will be able to log in to the droplet.
See |
backups |
(logical) Enable backups. A boolean indicating whether automated backups should be enabled for the droplet. Automated backups can only be enabled when the droplet is created, and cost extra. Default: FALSE |
ipv6 |
(logical) A boolean indicating whether IPv6 is enabled on the droplet. |
private_networking |
(logical) Use private networking. Private
networking is currently only available in certain regions.
Default: |
tags |
(character) A vector of tag names to apply to the Droplet after it is created. Tag names can either be existing or new tags. Default: list() |
wait |
If |
image |
(character/numeric) The image ID of a public or private image,
or the unique slug identifier for a public image. This image will be the
base image for your droplet. See |
keyfile |
Optional private key file. |
... |
For |
droplet |
A droplet, or something that can be coerced to a droplet by
|
all |
(logical) List all containers or images. Default: |
ssh_user |
(character) User account for ssh commands against droplet. Default: root |
repo |
(character) Docker name, can be local to the Droplet or remote,
e.g., |
ssh_passwd |
Optional passphrase or callback function for authentication.
Refer to the |
verbose |
If TRUE, will print command before executing it. |
rm |
(logical) Automatically remove the container when it exits.
Default: |
container |
(character) Container name, can be partial (though has to be unique) |
cmd |
(character) A docker command (e.g., |
args |
(character) Docker args |
docker_args |
(character) Docker args |
user |
(character) User name. required. |
password |
(character) Password. required. can not be 'rstudio' |
email |
(character) E-mail address. Default: |
img |
(character) Docker image (not a DigitalOcean image). Default:
|
port |
(character) Port. Default: |
volume |
(character) Volume. Can use to bind a volume. |
dir |
(character) Working directory inside the container. |
browse |
(logical) If |
add_users |
(logical) Add users or not when installing RStudio server. Default: FALSE |
path |
(character) Path to a directory with Shiny app files |
all functions return a droplet
If you need to figure out the URL for your RStudio or Shiny server
instance, you can construct like http://<ip address>:<port>
where
IP address can most likely be found like d$networks$v4[[1]]$ip_address
and the port is the port you set in the function call.
There's a few things to be note about managing Docker containers from analogsea:
To see running containers run docklet_ps(d)
To get get logs run droplet_ssh(d, "docker logs <container ID>")
To get a continuous feed of the logs run
droplet_ssh(d, "docker logs -f <container ID>")
Do not use docker exec -ti
as you do not want an interactive session -
it will not work from within R. If you log into your DigitalOcean droplet
you can do docker exec -ti
To install R package dependencies for a Shiny app, or similar, run
droplet_ssh(d, "docker exec <ID> R -e 'install.packages(\"pkg-name\")'")
where d
is your droplet object and <ID>
is the docker container ID
If you get a droplet object back without an IP address, the IP
address was not assigned when the payload was returned by DigitalOcean.
Simply run d <- droplet(d$id)
to update your droplet object and the IP
address will populate.
## Not run: d <- docklet_create() d <- droplet(d$id) d %>% docklet_pull("dockerpinata/sqlite") d %>% docklet_images() # sqlite d %>% docklet_run("dockerpinata/sqlite", "sqlite3 --version", rm = TRUE) d %>% docklet_ps() # cowsay d %>% docklet_pull("chuanwen/cowsay") d %>% docklet_run("chuanwen/cowsay", rm = TRUE) # docker images d %>% docklet_images() # install various R versions via Rocker d %>% docklet_pull("rocker/r-base") d %>% docklet_pull("rocker/r-devel") d %>% docklet_pull("rocker/r-ver:3.2") d %>% docklet_run("rocker/r-ver:3.2", "R --version", rm = TRUE) d %>% docklet_run("rocker/r-ver:3.2", "Rscript -e '2 + 3'", rm = TRUE) # Run a docklet containing rstudio d %>% docklet_rstudio(user = "foo", password = "bar") # Delete a droplet d %>% droplet_delete() # Add users to an Rstudio instance ## This adds 100 users to the instance, with username/passwords ## following pattern user1/user1 ... through 100 d <- docklet_create() d <- droplet(d$id) d %>% docklet_rstudio(user = "foo", password = "bar") %>% docklet_rstudio_addusers(user = "foo", password = "bar") # Spin up a Shiny server (opens in default browser) (d <- docklet_create()) d %>% docklet_shinyserver() docklet_create() %>% docklet_shinyserver() # Spin up a Shiny server with an app (opens in default browser) d <- docklet_create(); d <- droplet(d$id) path <- system.file("examples", "widgets", package = "analogsea") d %>% docklet_shinyapp(path) ## uploading more apps - use droplet_upload, then navigate in browser ### if you try to use docklet_shinyapp again on the same droplet, it will error path2 <- system.file("examples", "mpg", package = "analogsea") d %>% droplet_upload(path2, "/srv/shinyapps") # then go to browser ## End(Not run)
## Not run: d <- docklet_create() d <- droplet(d$id) d %>% docklet_pull("dockerpinata/sqlite") d %>% docklet_images() # sqlite d %>% docklet_run("dockerpinata/sqlite", "sqlite3 --version", rm = TRUE) d %>% docklet_ps() # cowsay d %>% docklet_pull("chuanwen/cowsay") d %>% docklet_run("chuanwen/cowsay", rm = TRUE) # docker images d %>% docklet_images() # install various R versions via Rocker d %>% docklet_pull("rocker/r-base") d %>% docklet_pull("rocker/r-devel") d %>% docklet_pull("rocker/r-ver:3.2") d %>% docklet_run("rocker/r-ver:3.2", "R --version", rm = TRUE) d %>% docklet_run("rocker/r-ver:3.2", "Rscript -e '2 + 3'", rm = TRUE) # Run a docklet containing rstudio d %>% docklet_rstudio(user = "foo", password = "bar") # Delete a droplet d %>% droplet_delete() # Add users to an Rstudio instance ## This adds 100 users to the instance, with username/passwords ## following pattern user1/user1 ... through 100 d <- docklet_create() d <- droplet(d$id) d %>% docklet_rstudio(user = "foo", password = "bar") %>% docklet_rstudio_addusers(user = "foo", password = "bar") # Spin up a Shiny server (opens in default browser) (d <- docklet_create()) d %>% docklet_shinyserver() docklet_create() %>% docklet_shinyserver() # Spin up a Shiny server with an app (opens in default browser) d <- docklet_create(); d <- droplet(d$id) path <- system.file("examples", "widgets", package = "analogsea") d %>% docklet_shinyapp(path) ## uploading more apps - use droplet_upload, then navigate in browser ### if you try to use docklet_shinyapp again on the same droplet, it will error path2 <- system.file("examples", "mpg", package = "analogsea") d %>% droplet_upload(path2, "/srv/shinyapps") # then go to browser ## End(Not run)
Docklets: docker on droplets - create many docklets
docklets_create( names = NULL, size = getOption("do_size", "s-1vcpu-2gb"), region = getOption("do_region", "sfo3"), ssh_keys = getOption("do_ssh_keys", NULL), backups = getOption("do_backups", NULL), ipv6 = getOption("do_ipv6", NULL), private_networking = getOption("do_private_networking", NULL), tags = list(), wait = TRUE, image = "docker-18-04", ... )
docklets_create( names = NULL, size = getOption("do_size", "s-1vcpu-2gb"), region = getOption("do_region", "sfo3"), ssh_keys = getOption("do_ssh_keys", NULL), backups = getOption("do_backups", NULL), ipv6 = getOption("do_ipv6", NULL), private_networking = getOption("do_private_networking", NULL), tags = list(), wait = TRUE, image = "docker-18-04", ... )
names |
(character) Names of the droplets. The human-readable string
you wish to use when displaying the Droplet name. The name, if set to
a domain name managed in the DigitalOcean DNS management system, will
configure a PTR record for the Droplet. The name set during creation will
also determine the hostname for the Droplet in its internal configuration.
Default: picks a random name from |
size |
(character) Size slug identifier. See |
region |
(character) The unique slug identifier for the region that you
wish to deploy in. See |
ssh_keys |
(character) A character vector of key names, an integer
vector of key ids, or NULL, to use all keys in your account. Accounts
with the corresponding private key will be able to log in to the droplet.
See |
backups |
(logical) Enable backups. A boolean indicating whether automated backups should be enabled for the droplet. Automated backups can only be enabled when the droplet is created, and cost extra. Default: FALSE |
ipv6 |
(logical) A boolean indicating whether IPv6 is enabled on the droplet. |
private_networking |
(logical) Use private networking. Private
networking is currently only available in certain regions.
Default: |
tags |
(character) A vector of tag names to apply to the Droplet after it is created. Tag names can either be existing or new tags. Default: list() |
wait |
If |
image |
(character/numeric) The image ID of a public or private image,
or the unique slug identifier for a public image. This image will be the
base image for your droplet. See |
... |
Additional options passed down to |
Two or more droplet objects
If you get a droplet object back without an IP address, the IP
address was not assigned when the payload was returned by DigitalOcean.
Simply run d <- droplet(d$id)
to update your droplet object and the IP
address will populate.
## Not run: # if no names given, creates two droplets with random names docklets_create() # give names docklets_create(names = c('drop1', 'drop2')) docklets_create(names = c('drop3', 'drop4')) ## End(Not run)
## Not run: # if no names given, creates two droplets with random names docklets_create() # give names docklets_create(names = c('drop1', 'drop2')) docklets_create(names = c('drop3', 'drop4')) ## End(Not run)
Create/delete domains.
domain_create(name, ip_address, ...) domain_delete(domain, ...)
domain_create(name, ip_address, ...) domain_delete(domain, ...)
name |
(character) Required. The domain name to add to the DigitalOcean DNS management interface. The name must be unique in DigitalOcean's DNS system. The request will fail if the name has already been taken. |
ip_address |
(character) Required. An IP address for the domain's initial A record. |
... |
Further args passed on the curl call to the web. |
domain |
A domain to modify |
## Not run: d <- domain_create('tablesandchairsbunnies.info', '107.170.220.59') domain_delete(d) ## End(Not run)
## Not run: d <- domain_create('tablesandchairsbunnies.info', '107.170.220.59') domain_delete(d) ## End(Not run)
Get information on a single domain or all your domains.
domains(...) as.domain(x) domain(x, ...)
domains(...) as.domain(x) domain(x, ...)
... |
Further args passed on the curl call to the web. |
x |
(character) Required. Domain name |
## Not run: domains() ## End(Not run)
## Not run: domains() ## End(Not run)
Retrieve a single droplet.
droplet(id, ...) as.droplet(x) ## S3 method for class 'droplet' summary(object, ...)
droplet(id, ...) as.droplet(x) ## S3 method for class 'droplet' summary(object, ...)
id |
(integer) Droplet id. |
... |
Additional arguments passed down to low-level API function
( |
x |
Object to coerce. Can be an integer (droplet id), string (droplet name), a droplet (duh), or an action (which waits until complete then returns the droplet) |
object |
Droplet object to pass to |
## Not run: droplet(1234) as.droplet("my-favourite-droplet") as.droplet(10) as.droplet(droplets()[[1]]) droplet(1234) %>% summary ## End(Not run)
## Not run: droplet(1234) as.droplet("my-favourite-droplet") as.droplet(10) as.droplet(droplets()[[1]]) droplet(1234) %>% summary ## End(Not run)
These droplet actions have no further arguments.
droplet_reboot(droplet, ...) droplet_power_cycle(droplet, ...) droplet_shutdown(droplet, ...) droplet_power_off(droplet, ...) droplet_power_on(droplet, ...) droplet_reset_password(droplet, ...) droplet_enable_ipv6(droplet, ...) droplet_enable_private_networking(droplet, ...) droplet_enable_backups(droplet, ...) droplet_disable_backups(droplet, ...) droplet_upgrade(droplet, ...)
droplet_reboot(droplet, ...) droplet_power_cycle(droplet, ...) droplet_shutdown(droplet, ...) droplet_power_off(droplet, ...) droplet_power_on(droplet, ...) droplet_reset_password(droplet, ...) droplet_enable_ipv6(droplet, ...) droplet_enable_private_networking(droplet, ...) droplet_enable_backups(droplet, ...) droplet_disable_backups(droplet, ...) droplet_upgrade(droplet, ...)
droplet |
A droplet, or something that can be coerced to a droplet by
|
... |
Additional options passed down to low-level API method. |
This method allows you to reboot a droplet. This is the preferred method to use if a server is not responding
This method allows you to power cycle a droplet. This will turn off the droplet and then turn it back on.
Shutdown a running droplet. The droplet will remain in your account and you will continue to be charged for it.
Shutdown a running droplet. The droplet will remain in your account and you will continue to be charged for it.
This method will reset the root password for a droplet. Please be aware that this will reboot the droplet to allow resetting the password.
Enable IPv6 networking on an existing droplet (within a region that has IPv6 available).
Enable private networking on an existing droplet (within a region that has private networking available)
Disables backups for a droplet.
Enables backups for a droplet.
Turn on a droplet that's turned off.
## Not run: d <- droplets() d[[1]] %>% droplet_reboot() d[[2]] %>% droplet_power_cycle() d <- droplet_create() d %>% summary d %>% droplet_enable_backups() d %>% summary ## End(Not run)
## Not run: d <- droplets() d[[1]] %>% droplet_reboot() d[[2]] %>% droplet_power_cycle() d <- droplet_create() d %>% summary d %>% droplet_enable_backups() d %>% summary ## End(Not run)
Retrieve a droplet action or list all actions associatd with a droplet.
droplet_actions(droplet, actionid = NULL, ...)
droplet_actions(droplet, actionid = NULL, ...)
droplet |
A droplet, or something that can be coerced to a droplet by
|
actionid |
(integer) Optional. An action id. |
... |
Additional options passed down to low-level API method. |
## Not run: droplet_actions(2428384) droplet_actions(2428384, actionid=31223385) ## End(Not run)
## Not run: droplet_actions(2428384) droplet_actions(2428384, actionid=31223385) ## End(Not run)
There are defaults for each of size, image, and region so that a quick one-liner with one parameter is possible: simply specify the name of the droplet and your'e up and running.
droplet_create( name = random_name(), size = getOption("do_size", "s-1vcpu-1gb"), image = getOption("do_image", "ubuntu-22-04-x64"), region = getOption("do_region", "sfo3"), ssh_keys = getOption("do_ssh_keys", NULL), backups = getOption("do_backups", NULL), ipv6 = getOption("do_ipv6", NULL), private_networking = getOption("do_private_networking", NULL), tags = list(), user_data = NULL, cloud_config = NULL, wait = TRUE, ... )
droplet_create( name = random_name(), size = getOption("do_size", "s-1vcpu-1gb"), image = getOption("do_image", "ubuntu-22-04-x64"), region = getOption("do_region", "sfo3"), ssh_keys = getOption("do_ssh_keys", NULL), backups = getOption("do_backups", NULL), ipv6 = getOption("do_ipv6", NULL), private_networking = getOption("do_private_networking", NULL), tags = list(), user_data = NULL, cloud_config = NULL, wait = TRUE, ... )
name |
(character) Name of the droplet. The human-readable string you
wish to use when displaying the Droplet name. The name, if set to a domain
name managed in the DigitalOcean DNS management system, will configure a
PTR record for the Droplet. The name set during creation will also
determine the hostname for the Droplet in its internal configuration.
Default: picks a random name from |
size |
(character) Size slug identifier. See |
image |
(character/numeric) The image ID of a public or private image,
or the unique slug identifier for a public image. This image will be the
base image for your droplet. See |
region |
(character) The unique slug identifier for the region that you
wish to deploy in. See |
ssh_keys |
(character) A character vector of key names, an integer
vector of key ids, or NULL, to use all keys in your account. Accounts
with the corresponding private key will be able to log in to the droplet.
See |
backups |
(logical) Enable backups. A boolean indicating whether automated backups should be enabled for the droplet. Automated backups can only be enabled when the droplet is created, and cost extra. Default: FALSE |
ipv6 |
(logical) A boolean indicating whether IPv6 is enabled on the droplet. |
private_networking |
(logical) Use private networking. Private
networking is currently only available in certain regions.
Default: |
tags |
(character) A vector of tag names to apply to the Droplet after it is created. Tag names can either be existing or new tags. Default: list() |
user_data |
(character) Gets passed to the droplet at boot time. Not all regions have this enabled, and is not used by all images. |
cloud_config |
(character) Specify the name of a cloud config template
to automatically generate |
wait |
If |
... |
Additional options passed down to |
Note that if you exit the R session or kill the function call after it's in waiting process (the string of ...), the droplet creation will continue.
A droplet object
If you get a droplet object back without an IP address, the IP
address was not assigned when the payload was returned by DigitalOcean.
Simply run d <- droplet(d$id)
to update your droplet object and the IP
address will populate.
## Not run: # by default we give your droplet a name droplet_create() # you can set your own droplet name droplet_create('droppinit') # set name, size, image, and region droplet_create(name="newdrop", size = '512mb', image = 'ubuntu-22-04-x64', region = 'sfo3') # use an ssh key droplet_create(ssh_keys=89103) # add tags (d <- droplet_create(tags = c('venus', 'mars'))) summary(d) ## End(Not run)
## Not run: # by default we give your droplet a name droplet_create() # you can set your own droplet name droplet_create('droppinit') # set name, size, image, and region droplet_create(name="newdrop", size = '512mb', image = 'ubuntu-22-04-x64', region = 'sfo3') # use an ssh key droplet_create(ssh_keys=89103) # add tags (d <- droplet_create(tags = c('venus', 'mars'))) summary(d) ## End(Not run)
This method deletes one of your droplets - this is irreversible.
droplet_delete(droplet = NULL, tag = NULL, ...)
droplet_delete(droplet = NULL, tag = NULL, ...)
droplet |
A droplet, or something that can be coerced to a droplet by
|
tag |
(character) Name of a tag. optional |
... |
Additional options passed down to low-level API method. |
## Not run: drops <- droplets() drops[[1]] %>% droplet_delete() drops[[2]] %>% droplet_delete() droplet_create() %>% droplet_delete() droplet_delete("lombard") droplet_delete(12345) # Delete all droplets lapply(droplets(), droplet_delete) # delete droplets by tag ## first, create a tag, then a droplet, then tag it tag_create(name = "foobar") e <- droplet_create() tag_resource(name = "foobar", resource_id = e$id) droplets(tag = "foobar") ## then delete the droplet by tag name droplet_delete(tag = "foobar") ## End(Not run)
## Not run: drops <- droplets() drops[[1]] %>% droplet_delete() drops[[2]] %>% droplet_delete() droplet_create() %>% droplet_delete() droplet_delete("lombard") droplet_delete(12345) # Delete all droplets lapply(droplets(), droplet_delete) # delete droplets by tag ## first, create a tag, then a droplet, then tag it tag_create(name = "foobar") e <- droplet_create() tag_resource(name = "foobar", resource_id = e$id) droplets(tag = "foobar") ## then delete the droplet by tag name droplet_delete(tag = "foobar") ## End(Not run)
Perform actions on one or more droplets associated with a tag
droplet_do_actions(name, type, ...)
droplet_do_actions(name, type, ...)
name |
(character) Name of the tag. Required. |
type |
(character) action type, one of 'power_cycle', 'power_on', 'power_off', 'shutdown', 'enable_private_networking', 'enable_ipv6', 'enable_backups', 'disable_backups', or 'snapshot'. Required. |
... |
Additional options passed down to |
## Not run: tag_create(name = "pluto") d <- droplet_create() tag_resource(name = "pluto", resource_id = d$id) (x <- droplet_do_actions(name = "pluto", type = "power_off")) # wait until completed, check with action(xx$actions[[1]]$id) droplet_do_actions(name = "pluto", type = "power_on") ## End(Not run)
## Not run: tag_create(name = "pluto") d <- droplet_create() tag_resource(name = "pluto", resource_id = d$id) (x <- droplet_do_actions(name = "pluto", type = "power_off")) # wait until completed, check with action(xx$actions[[1]]$id) droplet_do_actions(name = "pluto", type = "power_on") ## End(Not run)
Execute R code on a droplet.
droplet_execute(droplet, code, verbose = TRUE)
droplet_execute(droplet, code, verbose = TRUE)
droplet |
A droplet, or object that can be coerced to a droplet
by |
code |
Code to execute on a droplet. |
verbose |
(logical) Print messages. Default: |
Assumes that the droplet has R installed.
## Not run: d <- droplet_create() %>% ubuntu_add_swap() %>% droplet_ssh("apt-get update") %>% ubuntu_install_r() results <- d %>% droplet_execute({ x <- letters numbers <- runif(1000) }) results$x results$numbers droplet_delete(d) ## End(Not run)
## Not run: d <- droplet_create() %>% ubuntu_add_swap() %>% droplet_ssh("apt-get update") %>% ubuntu_install_r() results <- d %>% droplet_execute({ x <- letters numbers <- runif(1000) }) results$x results$numbers droplet_delete(d) ## End(Not run)
Freeze powers off the droplet, snapshots to create an image, and deletes the droplet. Thaw performs the inverse: it takes an image and turns it into a running droplet.
droplet_freeze(droplet, name = droplet$name, ...) droplet_thaw(image, ...)
droplet_freeze(droplet, name = droplet$name, ...) droplet_thaw(image, ...)
droplet |
A droplet, or something that can be coerced to a droplet by
|
name |
Name for the image to be created, or to be used to create a new droplet. Defaults to name of the droplet. |
... |
For freeze, further args passed on to
|
image |
Image to thaw into a droplet. |
droplet_freeze
accepts a droplet as first
argument, and returns an image; droplet_thaw
does the opposite:
it accepts an image as first argument, and returns a droplet.
## Not run: # freeze droplet_create(region = 'nyc3') %>% droplet_freeze() # thaw droplet_thaw(image='chiromantical-1412718795', region='nyc3') ## End(Not run)
## Not run: # freeze droplet_create(region = 'nyc3') %>% droplet_freeze() # thaw droplet_thaw(image='chiromantical-1412718795', region='nyc3') ## End(Not run)
There's a lot of functions for working with droplets. Here's a breakdown of what they all do.
DigitalOcean docs overview: https://developers.digitalocean.com/documentation/
DigitalOcean API docs: https://developers.digitalocean.com/documentation/v2/
The main functions for creating/deleting droplets:
droplet()
: get a droplet object from a droplet ID
droplet_create()
: create a droplet
droplets_create()
: create two or more droplets
droplet_delete()
: delete a droplet
droplets()
: get your droplets
as.droplet()
: coerce various things to droplet objects
Modify a droplet:
droplet_resize()
: resize a droplet to a different size
droplet_rebuild()
: reinstall a droplet with a different image
droplet_rename()
: rename a droplet
droplet_change_kernel()
: change droplet to a new kernel
Take and restore snapshots:
droplet_snapshot()
: make a snapshot of a droplet
droplet_snapshots_list()
: list snapshots on a droplet
droplet_backups_list()
: list droplet backups
droplet_restore()
: Restore a droplet with a previous image or snapshot
ssh interactions with droplets:
droplet_ssh()
: Remotely execute code on your droplet via ssh
droplet_upload()
: Upload files to your droplet via ssh
droplet_download()
: Download files from your droplet via ssh
Perform various actions on droplets:
droplet_actions()
: retrieve a droplet action or list all actions
associated with a droplet
droplet_disable_backups()
: Disables backups for a droplet
droplet_do_actions()
: Perform actions on one or more droplets associated with a tag
droplet_enable_backups()
: Enables backups for a droplet
droplet_enable_ipv6()
: Enable IPv6 networking on an existing droplet (within
a region that has IPv6 available)
droplet_enable_private_networking()
: Enable private networking on an existing
droplet (within a region that has private networking available)
droplet_execute()
: Execute R code on a droplet
droplet_kernels_list()
: List all available kernels for a droplet
droplet_neighbors()
: List a droplet's neighbors on the same physical server
droplet_power_cycle()
: power cycle a droplet. will turn off the droplet and
then turn it back on
droplet_power_off()
: Shutdown a running droplet. The droplet will remain in
your account and you will continue to be charged for it
droplet_power_on()
: Turn on a droplet that's turned off
droplet_reboot()
: reboot a droplet. This is the preferred method to use if
a server is not responding
droplet_reset_password()
: reset the root password for a droplet
droplet_reuse()
: Reuse a droplet or image by name, creating a new droplet
droplet_shutdown()
: Shutdown a running droplet. The droplet will remain in
your account and you will continue to be charged for it.
droplet_upgrade()
: Migrate a droplet - NOT SURE IF THIS STILL WORKS OR NOT
droplet_upgrades_list()
: List all droplets that are scheduled to be upgraded
droplet_wait()
: Wait for a droplet to be ready. mostly used internally
droplets_cost()
: Calculate cost across droplets
Freeze/thaw droplets:
droplet_freeze()
: power off a droplet, snapshots to create an image, and deletes the
droplet
droplet_thaw()
: takes an image and turns it into a running droplet
We named a DO droplet with the Docker application installed a "docklet" for convienence
The main two functions for creating docklets:
docklet_create()
: create a docklet (a droplet using the docker image)
docklets_create()
: create many docklets
Running docker commands on your docklet:
docklet_images()
: list docker images on your docklet
docklet_ps()
: list running docker containers
docklet_pull()
: pull a docker image to your docklet
docklet_rm()
: remove a docker image from your docklet
docklet_run()
: run a docker command on your docklet
docklet_stop()
: stop a running docker container
docklet_docker()
: low level fxn for running docker commands on your,
not realy intended for public use
Install RStudio things:
docklet_rstudio()
: install RStudio on your docklet using
Rocker images (https://hub.docker.com/u/rocker)
docklet_rstudio_addusers()
: add users to an RStudio docker image
docklet_shinyserver()
: install Shiny server on your docklet using
Rocker images (https://hub.docker.com/u/rocker)
docklet_shinyapp()
: install a Shiny app on your Shiny server docker
container
Get droplet's IP address
droplet_ip(droplet)
droplet_ip(droplet)
droplet |
A droplet, or something that can be coerced to a droplet by
|
## Not run: # Obtain the droplet's IP as a string my_droplet <- droplet_create("demo", region = "sfo3") droplet_ip(my_droplet) ## End(Not run)
## Not run: # Obtain the droplet's IP as a string my_droplet <- droplet_create("demo", region = "sfo3") droplet_ip(my_droplet) ## End(Not run)
List all available kernels for a droplet.
droplet_kernels_list(droplet, ...)
droplet_kernels_list(droplet, ...)
droplet |
A droplet, or something that can be coerced to a droplet by
|
... |
Additional options passed down to low-level API method. |
## Not run: droplets()[[1]] %>% droplet_kernels_list ## End(Not run)
## Not run: droplets()[[1]] %>% droplet_kernels_list ## End(Not run)
These methods allow you to modify existing droplets.
droplet_resize(droplet, size, ...) droplet_rebuild(droplet, image, ...) droplet_rename(droplet, name, ...) droplet_change_kernel(droplet, kernel, ...)
droplet_resize(droplet, size, ...) droplet_rebuild(droplet, image, ...) droplet_rename(droplet, name, ...) droplet_change_kernel(droplet, kernel, ...)
droplet |
A droplet, or something that can be coerced to a droplet by
|
size |
(character) Size slug (name) of the image size. See |
... |
Additional options passed down to low-level API method. |
image |
(optional) The image ID of the backup image that you would like to restore. |
name |
(character) The new name for the droplet |
kernel |
(numeric) The ID of the new kernel. |
Resize a specific droplet to a different size. This will affect the number of processors and memory allocated to the droplet.
Reinstall a droplet with a default image. This is useful if you want to start again but retain the same IP address for your droplet.
Change the droplet name
Change kernel ID.
Beware: droplet_resize()
does not seem to work, see
resize()
## Not run: droplets()[[1]] %>% droplet_rename(name='newname') ## End(Not run)
## Not run: droplets()[[1]] %>% droplet_rename(name='newname') ## End(Not run)
Reuse a droplet or image by name
droplet_reuse(name, ...)
droplet_reuse(name, ...)
name |
A name that could be a droplet or image name |
... |
Named options passed on to |
Internally, we call the droplets
and
images
(with private = TRUE
) to get list of your
droplets and images - and we check against those.
A droplet
## Not run: # matches droplet that exists droplet_reuse(name = 'BeguiledAmmonia') # matching image that exists droplet_reuse(name = 'hadleyverse1', size = "1gb") # no matching droplet or image droplet_reuse(name = 'tablesandchairs') ## End(Not run)
## Not run: # matches droplet that exists droplet_reuse(name = 'BeguiledAmmonia') # matching image that exists droplet_reuse(name = 'hadleyverse1', size = "1gb") # no matching droplet or image droplet_reuse(name = 'tablesandchairs') ## End(Not run)
Take a snapshot of the droplet once it has been powered off, which can later be restored or used to create a new droplet from the same image.
List available snapshots
List available snapshots
Restore a droplet with a previous image or snapshot. This will be a mirror copy of the image or snapshot to your droplet. Be sure you have backed up any necessary information prior to restore.
droplet_snapshot(droplet, name = NULL, wait = TRUE, ...) droplet_snapshots_list(droplet, ...) droplet_restore(droplet, image, ...) droplet_backups_list(droplet, ...)
droplet_snapshot(droplet, name = NULL, wait = TRUE, ...) droplet_snapshots_list(droplet, ...) droplet_restore(droplet, image, ...) droplet_backups_list(droplet, ...)
droplet |
A droplet number or the result from a call to
|
name |
(character) Optional. Name of the new snapshot you want to create. If not set, the snapshot name will default to the current date/time |
wait |
If |
... |
Additional options passed down to |
image |
(optional) The image ID of the backup image that you would like to restore. |
## Not run: d <- droplet_create() d %>% droplet_snapshots_list() d %>% droplet_backups_list() d %>% droplet_snapshot() %>% droplet_power_on() %>% droplet_snapshots_list() # To delete safely d %>% droplet_snapshot() %>% droplet_delete() %>% action_wait() ## End(Not run)
## Not run: d <- droplet_create() d %>% droplet_snapshots_list() d %>% droplet_backups_list() d %>% droplet_snapshot() %>% droplet_power_on() %>% droplet_snapshots_list() # To delete safely d %>% droplet_snapshot() %>% droplet_delete() %>% action_wait() ## End(Not run)
Assumes that you have ssh & scp installed, and password-less login set up on the droplet.
droplet_ssh( droplet, ..., user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) droplet_upload( droplet, local, remote, user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) droplet_download( droplet, remote, local, user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE, overwrite = FALSE )
droplet_ssh( droplet, ..., user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) droplet_upload( droplet, local, remote, user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) droplet_download( droplet, remote, local, user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE, overwrite = FALSE )
droplet |
A droplet, or something that can be coerced to a droplet by
|
... |
Shell commands to run. Multiple commands are combined with
|
user |
User name. Defaults to "root". |
keyfile |
Optional private key file. |
ssh_passwd |
Optional passphrase or callback function for authentication.
Refer to the |
verbose |
If TRUE, will print command before executing it. |
local , remote
|
Local and remote paths. |
overwrite |
If TRUE, then overwrite destination files if they already exist. |
Uploads and downloads are recursive, so if you specify a directory, everything inside the directory will also be downloaded.
With the chang to package ssh
, we create ssh session objects
(C pointers) internally, and cache them, then look them up in the cache
based on combination of user and IP address. That is, there's separate
sessions for each user for the same IP address.
ssh sessions are cleaned up at the end of your R session.
On success, the droplet (invisibly). On failure, throws an error.
## Not run: d <- droplet_create() %>% droplet_wait() # Upgrade system packages d %>% droplet_ssh("apt-get update") %>% droplet_ssh("sudo apt-get upgrade -y --force-yes") %>% droplet_ssh("apt-get autoremove -y") # Install R d %>% droplet_ssh("apt-get install r-base-core r-base-dev --yes --force-yes") # Upload and download files ------------------------------------------------- tmp <- tempfile() saveRDS(mtcars, tmp) d %>% droplet_upload(tmp, ".") d %>% droplet_ssh("ls") tmp2 <- tempdir() d %>% droplet_download(basename(tmp), tmp2) mtcars2 <- readRDS(file.path(tmp2, basename(tmp))) stopifnot(all.equal(mtcars, mtcars2)) ## another upload/download example tmp <- tempfile(fileext = ".txt") writeLines("foo bar", tmp) readLines(tmp) d %>% droplet_upload(tmp, ".") d %>% droplet_ssh("ls") tmp2 <- tempdir() unlink(tmp) d %>% droplet_download(basename(tmp), tmp2) readLines(file.path(tmp2, basename(tmp))) ## End(Not run)
## Not run: d <- droplet_create() %>% droplet_wait() # Upgrade system packages d %>% droplet_ssh("apt-get update") %>% droplet_ssh("sudo apt-get upgrade -y --force-yes") %>% droplet_ssh("apt-get autoremove -y") # Install R d %>% droplet_ssh("apt-get install r-base-core r-base-dev --yes --force-yes") # Upload and download files ------------------------------------------------- tmp <- tempfile() saveRDS(mtcars, tmp) d %>% droplet_upload(tmp, ".") d %>% droplet_ssh("ls") tmp2 <- tempdir() d %>% droplet_download(basename(tmp), tmp2) mtcars2 <- readRDS(file.path(tmp2, basename(tmp))) stopifnot(all.equal(mtcars, mtcars2)) ## another upload/download example tmp <- tempfile(fileext = ".txt") writeLines("foo bar", tmp) readLines(tmp) d %>% droplet_upload(tmp, ".") d %>% droplet_ssh("ls") tmp2 <- tempdir() unlink(tmp) d %>% droplet_download(basename(tmp), tmp2) readLines(file.path(tmp2, basename(tmp))) ## End(Not run)
List all droplets that are scheduled to be upgraded.
droplet_upgrades_list(...)
droplet_upgrades_list(...)
... |
Additional options passed down to low-level API method. |
## Not run: droplet_upgrades_list() ## End(Not run)
## Not run: droplet_upgrades_list() ## End(Not run)
Wait for a droplet to be ready.
droplet_wait(droplet)
droplet_wait(droplet)
droplet |
A droplet, or something that can be coerced to a droplet by
|
## Not run: droplet_create() %>% droplet_wait() ## End(Not run)
## Not run: droplet_create() %>% droplet_wait() ## End(Not run)
List all available droplets.
droplets(..., page = 1, per_page = 25, tag = NULL)
droplets(..., page = 1, per_page = 25, tag = NULL)
... |
Additional arguments passed down to low-level API function
( |
page |
Page to return. Default: 1. |
per_page |
Number of results per page. Default: 25. |
tag |
(character) Name of a tag. optional |
## Not run: droplets() droplets(per_page = 2) droplets(per_page = 2, page = 2) # list droplets by tag tag_create(name = "stuffthings") d <- droplet_create() tag_resource(name = "stuffthings", resource_id = d$id, resource_type = "droplet") droplets(tag = "stuffthings") ## End(Not run)
## Not run: droplets() droplets(per_page = 2) droplets(per_page = 2, page = 2) # list droplets by tag tag_create(name = "stuffthings") d <- droplet_create() tag_resource(name = "stuffthings", resource_id = d$id, resource_type = "droplet") droplets(tag = "stuffthings") ## End(Not run)
Calculate cost across droplets
droplets_cost(x)
droplets_cost(x)
x |
Object to coerce. Can be an integer (droplet id), string (droplet name), a droplet (duh) |
## Not run: droplets() %>% droplets_cost() droplets()[[2]] %>% droplets_cost() droplets()[2:4] %>% droplets_cost() droplets_cost("FatedSpaghetti") droplets_cost(11877599) ## End(Not run)
## Not run: droplets() %>% droplets_cost() droplets()[[2]] %>% droplets_cost() droplets()[2:4] %>% droplets_cost() droplets_cost("FatedSpaghetti") droplets_cost(11877599) ## End(Not run)
There are defaults for each of size, image, and region so that a quick one-liner with one parameter is possible: simply specify the name of the droplet and you're up and running.
droplets_create( names = NULL, size = getOption("do_size", "s-1vcpu-1gb"), image = getOption("do_image", "ubuntu-22-04-x64"), region = getOption("do_region", "sfo3"), ssh_keys = getOption("do_ssh_keys", NULL), backups = getOption("do_backups", NULL), ipv6 = getOption("do_ipv6", NULL), private_networking = getOption("do_private_networking", NULL), tags = list(), user_data = NULL, cloud_config = NULL, wait = TRUE, ... )
droplets_create( names = NULL, size = getOption("do_size", "s-1vcpu-1gb"), image = getOption("do_image", "ubuntu-22-04-x64"), region = getOption("do_region", "sfo3"), ssh_keys = getOption("do_ssh_keys", NULL), backups = getOption("do_backups", NULL), ipv6 = getOption("do_ipv6", NULL), private_networking = getOption("do_private_networking", NULL), tags = list(), user_data = NULL, cloud_config = NULL, wait = TRUE, ... )
names |
(character) Names of the droplets. The human-readable string
you wish to use when displaying the Droplet name. The name, if set to
a domain name managed in the DigitalOcean DNS management system, will
configure a PTR record for the Droplet. The name set during creation will
also determine the hostname for the Droplet in its internal configuration.
Default: picks a random name from |
size |
(character) Size slug identifier. See |
image |
(character/numeric) The image ID of a public or private image,
or the unique slug identifier for a public image. This image will be the
base image for your droplet. See |
region |
(character) The unique slug identifier for the region that you
wish to deploy in. See |
ssh_keys |
(character) A character vector of key names, an integer
vector of key ids, or NULL, to use all keys in your account. Accounts
with the corresponding private key will be able to log in to the droplet.
See |
backups |
(logical) Enable backups. A boolean indicating whether automated backups should be enabled for the droplet. Automated backups can only be enabled when the droplet is created, and cost extra. Default: FALSE |
ipv6 |
(logical) A boolean indicating whether IPv6 is enabled on the droplet. |
private_networking |
(logical) Use private networking. Private
networking is currently only available in certain regions.
Default: |
tags |
(character) A vector of tag names to apply to the Droplet after it is created. Tag names can either be existing or new tags. Default: list() |
user_data |
(character) Gets passed to the droplet at boot time. Not all regions have this enabled, and is not used by all images. |
cloud_config |
(character) Specify the name of a cloud config template
to automatically generate |
wait |
If |
... |
Additional options passed down to |
Note that if you exit the R session or kill the function call after it's in waiting process (the string of ...), the droplet creation will continue.
Two or more droplet objects
If you get a droplet object back without an IP address, the IP
address was not assigned when the payload was returned by DigitalOcean.
Simply run d <- droplet(d$id)
to update your droplet object and the IP
address will populate.
## Not run: # if no names given, creates two droplets with random names droplets_create() # give names droplets_create(names = c('drop1', 'drop2')) droplets_create(names = c('drop3', 'drop4')) # add tags (d <- droplets_create(tags = 'mystuff')) invisible(lapply(d, summary)) ## End(Not run)
## Not run: # if no names given, creates two droplets with random names droplets_create() # give names droplets_create(names = c('drop1', 'drop2')) droplets_create(names = c('drop3', 'drop4')) # add tags (d <- droplets_create(tags = 'mystuff')) invisible(lapply(d, summary)) ## End(Not run)
Add/remove droplets to a firewall
firewall_add_droplets(id, droplet_ids, ...) firewall_remove_droplets(id, droplet_ids, ...)
firewall_add_droplets(id, droplet_ids, ...) firewall_remove_droplets(id, droplet_ids, ...)
id |
(character) A firewall id (not the name) to delete |
droplet_ids |
(integer/numeric) a vector of droplet ids |
... |
Options passed on to httr::POST or httr::DELETE |
## Not run: drops <- droplets_create() drop_ids <- vapply(drops, "[[", numeric(1), "id") inbound <- list(list(protocol = "tcp", ports = "80", sources = list(addresses = "18.0.0.0/8"))) outbound <- list(list(protocol = "tcp", ports = "80", destinations = list(addresses = "0.0.0.0/0"))) res <- firewall_create("myfirewall", inbound, outbound) firewall_add_droplets(id = res$id, droplet_ids = drop_ids) firewalls()[[1]]$droplet_ids firewall_remove_droplets(id = res$id, droplet_ids = drop_ids) ## End(Not run)
## Not run: drops <- droplets_create() drop_ids <- vapply(drops, "[[", numeric(1), "id") inbound <- list(list(protocol = "tcp", ports = "80", sources = list(addresses = "18.0.0.0/8"))) outbound <- list(list(protocol = "tcp", ports = "80", destinations = list(addresses = "0.0.0.0/0"))) res <- firewall_create("myfirewall", inbound, outbound) firewall_add_droplets(id = res$id, droplet_ids = drop_ids) firewalls()[[1]]$droplet_ids firewall_remove_droplets(id = res$id, droplet_ids = drop_ids) ## End(Not run)
Add/remove tags to a firewall
firewall_add_tags(id, tags, ...) firewall_remove_tags(id, tags, ...)
firewall_add_tags(id, tags, ...) firewall_remove_tags(id, tags, ...)
id |
(character) A firewall id (not the name) to delete |
tags |
(character) tag strings |
... |
Options passed on to httr::POST or httr::DELETE |
## Not run: drops <- droplets_create() drop_ids <- vapply(drops, "[[", numeric(1), "id") inbound <- list(list(protocol = "tcp", ports = "80", sources = list(addresses = "18.0.0.0/8"))) outbound <- list(list(protocol = "tcp", ports = "80", destinations = list(addresses = "0.0.0.0/0"))) res <- firewall_create("myfirewall", inbound, outbound) tag_create(name = "foobar") tags() firewall_add_tags(id = res$id, tags = "foobar") firewalls()[[1]]$tags firewall_remove_tags(id = res$id, tags = "foobar") ## End(Not run)
## Not run: drops <- droplets_create() drop_ids <- vapply(drops, "[[", numeric(1), "id") inbound <- list(list(protocol = "tcp", ports = "80", sources = list(addresses = "18.0.0.0/8"))) outbound <- list(list(protocol = "tcp", ports = "80", destinations = list(addresses = "0.0.0.0/0"))) res <- firewall_create("myfirewall", inbound, outbound) tag_create(name = "foobar") tags() firewall_add_tags(id = res$id, tags = "foobar") firewalls()[[1]]$tags firewall_remove_tags(id = res$id, tags = "foobar") ## End(Not run)
Delete a firewall
firewall_delete(id, ...)
firewall_delete(id, ...)
id |
A firewall id (not the name) to delete |
... |
Options passed on to httr::DELETE |
## Not run: firewall_delete(id="d19b900b-b03e-4e5d-aa85-2ff8d2786f28") ## End(Not run)
## Not run: firewall_delete(id="d19b900b-b03e-4e5d-aa85-2ff8d2786f28") ## End(Not run)
Retrieve an action associated with a particular image id.
image_actions(image, action_id, ...)
image_actions(image, action_id, ...)
image |
An image to modify. |
action_id |
An action id associated with an image. |
... |
Options passed on to httr::GET. Must be named, see examples. |
## Not run: image_actions(5710271, 31221438) ## End(Not run)
## Not run: image_actions(5710271, 31221438) ## End(Not run)
Convert an backup image to a snapshot.
image_convert(image, ...)
image_convert(image, ...)
image |
An image to modify. |
... |
Options passed on to httr::GET. Must be named, see examples. |
## Not run: # get a backup image img <- images(TRUE)[[1]] # then convert to a snapshot # image_convert(img) ## End(Not run)
## Not run: # get a backup image img <- images(TRUE)[[1]] # then convert to a snapshot # image_convert(img) ## End(Not run)
There is no way to restore a deleted image so be careful and ensure your data is properly backed up before deleting it.
image_delete(image, ...) image_rename(image, name, ...)
image_delete(image, ...) image_rename(image, name, ...)
image |
An image to modify. |
... |
Options passed on to httr::GET. Must be named, see examples. |
name |
(character) New name for image. |
## Not run: image_delete(5620385) # Delete all of your snapshots ## BE CAREFUL WITH THIS ONE # lapply(images(TRUE), image_delete) ## End(Not run)
## Not run: image_delete(5620385) # Delete all of your snapshots ## BE CAREFUL WITH THIS ONE # lapply(images(TRUE), image_delete) ## End(Not run)
Transfer an image to a specified region.
image_transfer(image, region, ...)
image_transfer(image, region, ...)
image |
An image to modify. |
region |
(numeric) Required. The region slug that represents the region target. |
... |
Options passed on to httr::GET. Must be named, see examples. |
## Not run: image_transfer(image=images(TRUE)[[1]], region='nyc2') image_transfer(image=images(TRUE)[[1]], region='ams2') ## End(Not run)
## Not run: image_transfer(image=images(TRUE)[[1]], region='nyc2') image_transfer(image=images(TRUE)[[1]], region='ams2') ## End(Not run)
Create, update, and delete ssh keys.
key_create(name, public_key, ...) key_rename(key, name, ...) key_delete(key, ...)
key_create(name, public_key, ...) key_rename(key, name, ...) key_delete(key, ...)
name |
(character) The name to give the new SSH key in your account. |
public_key |
(character) A string containing the entire public key. |
... |
Other options passed on to low-level API methods. |
key |
(key) Key to modify. |
## Not run: k <- key_create("key", readLines("~/.ssh/id_rsa.pub")) k <- key_rename(k, "new_name") key_delete(k) ## End(Not run)
## Not run: k <- key_create("key", readLines("~/.ssh/id_rsa.pub")) k <- key_rename(k, "new_name") key_delete(k) ## End(Not run)
List your ssh keys, or get a single key
keys(..., page = 1, per_page = 25) key(x, ...) as.sshkey(x)
keys(..., page = 1, per_page = 25) key(x, ...) as.sshkey(x)
... |
Additional arguments passed down to low-level API function
( |
page |
Page to return. Default: 1. |
per_page |
Number of results per page. Default: 25. |
x |
For |
## Not run: keys() as.sshkey(328037) as.sshkey("hadley") ## End(Not run)
## Not run: keys() as.sshkey(328037) as.sshkey("hadley") ## End(Not run)
List neighbors
neighbors(...) droplet_neighbors(droplet, ...)
neighbors(...) droplet_neighbors(droplet, ...)
... |
Additional options passed down to low-level API method. |
droplet |
A droplet, or something that can be coerced to a droplet by
|
## Not run: # List a droplet's neighbors on the same physical server droplets()[[3]] %>% droplet_neighbors() # List all neighbors on the same physical server neighbors() ## End(Not run)
## Not run: # List a droplet's neighbors on the same physical server droplets()[[3]] %>% droplet_neighbors() # List all neighbors on the same physical server neighbors() ## End(Not run)
Nouns to use for seeding random word selection when name not given for a droplet
A vector of 1000 nouns From the GitHub repo https://github.com/dariusk/corpora - the data is licensed CC0.
Create a project
project_create(name, purpose, description = NULL, environment = NULL, ...)
project_create(name, purpose, description = NULL, environment = NULL, ...)
name |
(character) Name of the project. required |
purpose |
(character) The purpose of the project. The maximum length is 255 characters. For examples of valid purposes, see the "Purposes" section. required |
description |
(character) The description of the project. The maximum length is 255 characters. optional |
environment |
(character) The environment of the project's resources. optional |
... |
Additional options passed down to |
A project object
The purpose attribute can have one of the following values:
Just trying out DigitalOcean
Class project / Educational purposes
Website or blog
Web Application
Service or API
Mobile Application
Machine learning / AI / Data processing
IoT
Operational / Developer tooling
If specify another value for purpose, for example "your custom purpose", your purpose will be stored as Other: your custom purpose
The environment attribute must have one of the following values:
Development
Staging
Production
If another value is specified, a 400 Bad Request is returned.
## Not run: project_create(name = "venus", purpose = "Web Application") ## End(Not run)
## Not run: project_create(name = "venus", purpose = "Web Application") ## End(Not run)
Delete a project
project_delete(project, ...)
project_delete(project, ...)
project |
A project to modify. |
... |
Options passed on to httr::GET. Must be named, see examples. |
## Not run: project_delete(5620385) ## End(Not run)
## Not run: project_delete(5620385) ## End(Not run)
Update certain aspects of a project
project_patch( id, name = NULL, purpose = NULL, description = NULL, is_default = FALSE, environment = NULL, ... )
project_patch( id, name = NULL, purpose = NULL, description = NULL, is_default = FALSE, environment = NULL, ... )
id |
project id. to update the default project use "default". required |
name |
(character) Name of the project. required |
purpose |
(character) The purpose of the project. The maximum length is 255 characters. For examples of valid purposes, see the "Purposes" section. required |
description |
(character) The description of the project. The maximum length is 255 characters. optional |
is_default |
(logical) If |
environment |
(character) The environment of the project's resources. optional |
... |
Additional options passed down to |
Update all aspects of a project
project_update( id, name, purpose, description, is_default = FALSE, environment = NULL, ... )
project_update( id, name, purpose, description, is_default = FALSE, environment = NULL, ... )
id |
project id. to update the default project use "default". required |
name |
(character) Name of the project. required |
purpose |
(character) The purpose of the project. The maximum length is 255 characters. For examples of valid purposes, see the "Purposes" section. required |
description |
(character) The description of the project. The maximum length is 255 characters. optional |
is_default |
(logical) If |
environment |
(character) The environment of the project's resources. optional |
... |
Additional options passed down to |
Get list of regions and their metadata
regions(page = 1, per_page = 25, ...)
regions(page = 1, per_page = 25, ...)
page |
Page to return. Default: 1. |
per_page |
Number of results per page. Default: 25. |
... |
Named options passed on to |
## Not run: regions() ## End(Not run)
## Not run: regions() ## End(Not run)
Resize a droplet by power off, snapshot, and create new droplet
resize(droplet, delete_original = TRUE, ...)
resize(droplet, delete_original = TRUE, ...)
droplet |
A droplet, or something that can be coerced to a droplet by
|
delete_original |
(logical) Delete original droplet. Default:
|
... |
Named options passed on to |
Note that you can not resize a droplet while it is powered on.
Thus, this function powers off your droplet, makes a snapshot, then
creates a new droplet from that snapshot. We use droplet_wait
in between these steps to wait for each to finish. You can optionally delete
the original droplet.
A droplet
## Not run: d <- droplet_create() d # current size is 512mb d %>% resize(size = "2gb") ## End(Not run)
## Not run: d <- droplet_create() d # current size is 512mb d %>% resize(size = "2gb") ## End(Not run)
Get all the available sizes that can be used to create a droplet.
sizes(page = 1, per_page = 25, ...)
sizes(page = 1, per_page = 25, ...)
page |
Page to return. Default: 1. |
per_page |
Number of results per page. Default: 25. |
... |
Named options passed on to |
A data.frame with available sizes (RAM, disk, no. CPU's) and their costs
## Not run: sizes() ## End(Not run)
## Not run: sizes() ## End(Not run)
Create a new Space
space_create( name, spaces_region = NULL, spaces_key = NULL, spaces_secret = NULL, ... )
space_create( name, spaces_region = NULL, spaces_key = NULL, spaces_secret = NULL, ... )
name |
(character) The name of the new Space |
spaces_region |
(character) String containing a spaces region. If
missing, defaults to value stored in an environment variable
|
spaces_key |
(character) String containing a spaces access key. If
missing, defaults to value stored in an environment variable
|
spaces_secret |
(character) String containing the secret associated
with the spaces key. If missing, defaults to value stored in an environment
variable |
... |
Additional arguments to |
(character) The name of the created Space.
## Not run: # Create a new Space # (Names must be unique within region) space_create("new_space_name") ## End(Not run)
## Not run: # Create a new Space # (Names must be unique within region) space_create("new_space_name") ## End(Not run)
Delete an existing Space
space_delete( name, spaces_region = NULL, spaces_key = NULL, spaces_secret = NULL, ... )
space_delete( name, spaces_region = NULL, spaces_key = NULL, spaces_secret = NULL, ... )
name |
(character) The name of the existing Space |
spaces_region |
(character) String containing a spaces region. If
missing, defaults to value stored in an environment variable
|
spaces_key |
(character) String containing a spaces access key. If
missing, defaults to value stored in an environment variable
|
spaces_secret |
(character) String containing the secret associated
with the spaces key. If missing, defaults to value stored in an environment
variable |
... |
Additional arguments to |
(character) The name of the deleted Space.
## Not run: # Delete an existing Space # (Check names within region) space_delete("new_space_name") ## End(Not run)
## Not run: # Delete an existing Space # (Check names within region) space_delete("new_space_name") ## End(Not run)
Upload a directory to an existing Space
space_download( name, local = NULL, remote = NULL, spaces_region = NULL, spaces_key = NULL, spaces_secret = NULL, ... )
space_download( name, local = NULL, remote = NULL, spaces_region = NULL, spaces_key = NULL, spaces_secret = NULL, ... )
name |
(character) The name of the existing Space |
local |
(character) The name of the local directory |
remote |
(character) The name of the remote directory |
spaces_region |
(character) String containing a spaces region. If
missing, defaults to value stored in an environment variable
|
spaces_key |
(character) String containing a spaces access key. If
missing, defaults to value stored in an environment variable
|
spaces_secret |
(character) String containing the secret associated
with the spaces key. If missing, defaults to value stored in an environment
variable |
... |
Additional arguments to |
(character) Success/error message.
## Not run: # Upload to an existing Space # (Check names within region) space_download("my_space", "my_subdir", "my_subdir", "nyc3", spaces_key = Sys.getenv("SPACES_KEY"), spaces_secret = Sys.getenv("SPACES_SECRET")) ## End(Not run)
## Not run: # Upload to an existing Space # (Check names within region) space_download("my_space", "my_subdir", "my_subdir", "nyc3", spaces_key = Sys.getenv("SPACES_KEY"), spaces_secret = Sys.getenv("SPACES_SECRET")) ## End(Not run)
Upload a directory to an existing Space
space_upload( name, local = NULL, remote = NULL, spaces_region = NULL, spaces_key = NULL, spaces_secret = NULL, ... )
space_upload( name, local = NULL, remote = NULL, spaces_region = NULL, spaces_key = NULL, spaces_secret = NULL, ... )
name |
(character) The name of the existing Space |
local |
(character) The name of the local directory |
remote |
(character) The name of the remote directory |
spaces_region |
(character) String containing a spaces region. If
missing, defaults to value stored in an environment variable
|
spaces_key |
(character) String containing a spaces access key. If
missing, defaults to value stored in an environment variable
|
spaces_secret |
(character) String containing the secret associated
with the spaces key. If missing, defaults to value stored in an environment
variable |
... |
Additional arguments to |
(character) Success/error message.
## Not run: # Upload to an existing Space # (Check names within region) space_upload("my_space", "my_subdir", "my_subdir", "nyc3", spaces_key = Sys.getenv("SPACES_KEY"), spaces_secret = Sys.getenv("SPACES_SECRET")) ## End(Not run)
## Not run: # Upload to an existing Space # (Check names within region) space_upload("my_space", "my_subdir", "my_subdir", "nyc3", spaces_key = Sys.getenv("SPACES_KEY"), spaces_secret = Sys.getenv("SPACES_SECRET")) ## End(Not run)
List all Spaces.
spaces(spaces_region = NULL, spaces_key = NULL, spaces_secret = NULL, ...)
spaces(spaces_region = NULL, spaces_key = NULL, spaces_secret = NULL, ...)
spaces_region |
(character) String containing a spaces region. If
missing, defaults to value stored in an environment variable
|
spaces_key |
(character) String containing a spaces access key. If
missing, defaults to value stored in an environment variable
|
spaces_secret |
(character) String containing the secret associated
with the spaces key. If missing, defaults to value stored in an environment
variable |
... |
Additional arguments to |
(list) A list of Spaces. Can be empty.
https://developers.digitalocean.com/documentation/spaces/#get-object
## Not run: # List all of your Spaces spaces() ## End(Not run)
## Not run: # List all of your Spaces spaces() ## End(Not run)
Internal helper method to get information about a Space
spaces_GET(spaces_region = NULL, spaces_key = NULL, spaces_secret = NULL, ...)
spaces_GET(spaces_region = NULL, spaces_key = NULL, spaces_secret = NULL, ...)
spaces_region |
(character) String containing a spaces region. If
missing, defaults to value stored in an environment variable
|
spaces_key |
(character) String containing a spaces access key. If
missing, defaults to value stored in an environment variable
|
spaces_secret |
(character) String containing the secret associated
with the spaces key. If missing, defaults to value stored in an environment
variable |
... |
Additional arguments to |
The raw S3 response, or throws an error
DigitalOcean provides support for storing files (Objects) in Spaces. This is
useful for storing related files for fast access, sharing, etc. See
https://developers.digitalocean.com/documentation/spaces/
for more information. The aws.s3
package is required to use analogsea
's
Spaces functionality so be sure to install it with
install.packages("aws.s3")
prior to continuing.
space |
A Space, or the name of the Space as a string. |
object |
(character) The name of the Object |
In order to get started using the Spaces API, you'll need to generate a new
"Spaces access key" in the API section of your DigitalOcean control panel and
set the key and its secret as environmental variables via
Sys.setenv
. Set the access key to DO_SPACES_ACCESS_KEY
and its secret to DO_SPACES_SECRET_KEY
. After that, set your region to
DO_SPACES_REGION
(e.g., nyc3). Alternatively, you can pass this
information as arguments to whichever Spaces API functions you're using.
## Not run: # List Spaces spaces() # Obtain Spaces as a list of Space objects res <- spaces() # Print Space summary using a Space object summary(res[["my_space_name"]]) # Create a new space space_create("new_space_name") ## End(Not run)
## Not run: # List Spaces spaces() # Obtain Spaces as a list of Space objects res <- spaces() # Print Space summary using a Space object summary(res[["my_space_name"]]) # Create a new space space_create("new_space_name") ## End(Not run)
Standardise specification of ssh keys.
standardise_keys(ssh_keys = NULL)
standardise_keys(ssh_keys = NULL)
ssh_keys |
An integer vector of given key ids, a character vector of key ids, or NULL, to use all ssh keys in account. |
A integer vector of key ids.
## Not run: standardise_keys(123) standardise_keys(123L) standardise_keys() standardise_keys("hadley") ## End(Not run)
## Not run: standardise_keys(123) standardise_keys(123L) standardise_keys() standardise_keys("hadley") ## End(Not run)
Create a tag
tag_create(name, ...)
tag_create(name, ...)
name |
(character) Name of the tag |
... |
Additional options passed down to |
A tag object
## Not run: tag_create(name = "venus") ## End(Not run)
## Not run: tag_create(name = "venus") ## End(Not run)
Delete a tag
tag_delete(name, ...)
tag_delete(name, ...)
name |
(character) Name of the tag |
... |
Additional options passed down to |
nothing, if successful
## Not run: tag_delete(name = "helloworld") ## End(Not run)
## Not run: tag_delete(name = "helloworld") ## End(Not run)
Tag a resource
tag_resource( name, resource_id = NULL, resource_type = "droplet", resources = NULL, ... )
tag_resource( name, resource_id = NULL, resource_type = "droplet", resources = NULL, ... )
name |
(character) Name of the tag |
resource_id |
(character) a droplet id |
resource_type |
(character) only "droplet" for now. Default: "droplet" |
resources |
(list) instead of |
... |
Additional options passed down to |
logical, TRUE
if successful
## Not run: d <- droplet_create() tag_resource(name = "stuffthings", resource_id = d$id, resource_type = "droplet") tag_resource("stuffthings", resources = list(list(resource_id = d$id, resource_type = "droplet"))) ## End(Not run)
## Not run: d <- droplet_create() tag_resource(name = "stuffthings", resource_id = d$id, resource_type = "droplet") tag_resource("stuffthings", resources = list(list(resource_id = d$id, resource_type = "droplet"))) ## End(Not run)
Untag a resource
tag_resource_delete( name, resource_id = NULL, resource_type = "droplet", resources = NULL, ... )
tag_resource_delete( name, resource_id = NULL, resource_type = "droplet", resources = NULL, ... )
name |
(character) Name of the tag |
resource_id |
(integer) a droplet id |
resource_type |
(character) only "droplet" for now. Default: "droplet" |
resources |
(list) instead of |
... |
Additional options passed down to |
logical, TRUE
if successful
## Not run: d <- droplet_create() tag_resource(name = "stuffthings", resource_id = d$id, resource_type = "droplet") ## same as this because only allowed resource type right now is "droplet" # tag_resource(name = "stuffthings", resource_id = d$id) tag_resource_delete(name = "stuffthings", resource_id = d$id, resource_type = "droplet") ## End(Not run)
## Not run: d <- droplet_create() tag_resource(name = "stuffthings", resource_id = d$id, resource_type = "droplet") ## same as this because only allowed resource type right now is "droplet" # tag_resource(name = "stuffthings", resource_id = d$id) tag_resource_delete(name = "stuffthings", resource_id = d$id, resource_type = "droplet") ## End(Not run)
List tags
tags(...) tag(name, ...) as.tag(x)
tags(...) tag(name, ...) as.tag(x)
... |
Additional options passed down to |
name |
(character) Name of the tag |
x |
Object to coerce to a tag. |
tags
gets all your tag, tag
gets a tag by name
Many tag objects in a list
## Not run: # get all your tags tags() # get a tag by name tag("stuffthings") tag("helloworld") ## End(Not run) ## Not run: tag_create("pluto") as.tag('pluto') as.tag(tag_create("howdyhoneighbor")) ## End(Not run)
## Not run: # get all your tags tags() # get a tag by name tag("stuffthings") tag("helloworld") ## End(Not run) ## Not run: tag_create("pluto") as.tag('pluto') as.tag(tag_create("howdyhoneighbor")) ## End(Not run)
Helpers for managing a ubuntu droplets.
ubuntu_add_swap( droplet, user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) ubuntu_install_r( droplet, user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE, rprofile = "options(repos=c('CRAN'='https://cloud.r-project.org/'))" ) ubuntu_install_rstudio( droplet, user = "rstudio", password = "server", version = "0.99.484", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) ubuntu_install_shiny( droplet, version = "1.5.20.1002", user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE, rprofile = "options(repos=c('CRAN'='https://cloud.r-project.org/'))" ) ubuntu_apt_get_cran( droplet, user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) ubuntu_apt_get_update( droplet, user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) ubuntu_apt_get_install( droplet, ..., user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) install_r_package( droplet, package, repo = "https://cloud.r-project.org/", user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) install_github_r_package( droplet, package, repo = "https://cloud.r-project.org/", user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) ubuntu_create_user( droplet, user, password, ssh_user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE )
ubuntu_add_swap( droplet, user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) ubuntu_install_r( droplet, user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE, rprofile = "options(repos=c('CRAN'='https://cloud.r-project.org/'))" ) ubuntu_install_rstudio( droplet, user = "rstudio", password = "server", version = "0.99.484", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) ubuntu_install_shiny( droplet, version = "1.5.20.1002", user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE, rprofile = "options(repos=c('CRAN'='https://cloud.r-project.org/'))" ) ubuntu_apt_get_cran( droplet, user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) ubuntu_apt_get_update( droplet, user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) ubuntu_apt_get_install( droplet, ..., user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) install_r_package( droplet, package, repo = "https://cloud.r-project.org/", user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) install_github_r_package( droplet, package, repo = "https://cloud.r-project.org/", user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE ) ubuntu_create_user( droplet, user, password, ssh_user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE )
droplet |
A droplet, or object that can be coerced to a droplet
by |
user |
Username for non-root account. |
keyfile |
Optional private key file. |
ssh_passwd |
Optional passphrase or callback function for authentication.
Refer to the |
verbose |
If TRUE, will print command before executing it. |
rprofile |
A character string that will be added to the .Rprofile |
password |
Password for non-root account. |
version |
Version of rstudio to install. |
... |
Arguments to apt-get install. |
package |
Name of R package to install. |
repo |
CRAN mirror to use. |
ssh_user |
(character) User account for ssh commands against droplet. |
## Not run: d <- droplet_create() d %>% ubuntu_add_swap() d %>% ubuntu_apt_get_update() d %>% ubuntu_install_r() d %>% ubuntu_install_rstudio() # Install libcurl, then build RCurl from source d %>% ubuntu_apt_get_install("libcurl4-openssl-dev") d %>% install_r_package("RCurl") droplet_delete(d) ## End(Not run)
## Not run: d <- droplet_create() d %>% ubuntu_add_swap() d %>% ubuntu_apt_get_update() d %>% ubuntu_install_r() d %>% ubuntu_install_rstudio() # Install libcurl, then build RCurl from source d %>% ubuntu_apt_get_install("libcurl4-openssl-dev") d %>% install_r_package("RCurl") droplet_delete(d) ## End(Not run)
Attach a volume to a droplet
volume_attach(volume, droplet, region = "nyc1", ...) volume_detach(volume, droplet, region = "nyc1", ...) volume_resize(volume, size, region = "nyc1", ...) volume_action(volume, actionid, ...) volume_actions(volume, page = 1, per_page = 25, ...)
volume_attach(volume, droplet, region = "nyc1", ...) volume_detach(volume, droplet, region = "nyc1", ...) volume_resize(volume, size, region = "nyc1", ...) volume_action(volume, actionid, ...) volume_actions(volume, page = 1, per_page = 25, ...)
volume |
A volume, or something that can be coerced to a volume by
|
droplet |
A droplet, or something that can be coerced to a droplet by
|
region |
(character) The region where the Block Storage volume will be created. When setting a region, the value should be the slug identifier for the region. When you query a Block Storage volume, the entire region object will be returned. Should not be specified with a snapshot_id. Default: nyc1 |
... |
|
size |
(integer) The size of the Block Storage volume in GiB |
actionid |
(integer) Optional. An action id. |
page |
Page to return. Default: 1. |
per_page |
Number of results per page. Default: 25. |
Note that there is a way to attach a volume to or remove from a
droplet by name, but we only support doing this by ID. However, as
the user, all you need to do is make a volume class object via
as.volume
and pass it to volume_attach
or
volume_detach
, which is pretty darn easy.
## Not run: # resize a volume ## create a volume (vol1 <- volume_create('foobar', 5)) ## resize it volume_resize(vol1, 6) volume(vol1) # attach a volume to a droplet ## create a droplet (d <- droplet_create(region = "nyc1")) ## attach volume to droplet volume_attach(vol1, d) ## refresh droplet info, see volumes slot droplet(d$id) # detach a volume from a droplet (act <- volume_detach(vol1, d)) ## refresh droplet info, see volumes slot droplet(d$id) # list an action volume_action(vol1, 154689758) # list all volume actions volume_actions(volumes()[[1]]) ## End(Not run)
## Not run: # resize a volume ## create a volume (vol1 <- volume_create('foobar', 5)) ## resize it volume_resize(vol1, 6) volume(vol1) # attach a volume to a droplet ## create a droplet (d <- droplet_create(region = "nyc1")) ## attach volume to droplet volume_attach(vol1, d) ## refresh droplet info, see volumes slot droplet(d$id) # detach a volume from a droplet (act <- volume_detach(vol1, d)) ## refresh droplet info, see volumes slot droplet(d$id) # list an action volume_action(vol1, 154689758) # list all volume actions volume_actions(volumes()[[1]]) ## End(Not run)
1000 words to use for seeding random word selection when name not given for a droplet