Open Sade154 opened 6 days ago
I encountered an issue with the example code below provided in the documentation for the
firewall_create
function.Code from Documentation:
library(analogsea) 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
Error received:
Error: missing name
Also, the message error is weird as the name is provided in the first argument.
this seems to be a change in the API, let me ask Digital Ocean
Hello,
same problem here.
if it's of any help, this function works using httr2:
library(httr2)
api_token = "kshjqlf"
create_firewall = function(droplet_ids, firewall_name, authorized_IPs){
body <- list( name = firewall_name, droplet_ids = droplet_ids, inbound_rules = list(
list(
protocol = "tcp",
ports = "22",
sources = list(
addresses = authorized_IPs # Add
)
),
# Allowing specific IPs to communicate over HTTP
list(
protocol = "tcp",
ports = "80",
sources = list(
addresses = authorized_IPs
)
),
# Allow ICMP for ping
list(
protocol = "icmp",
sources = list(
#addresses = list("0.0.0.0/0") # Allow from all sources or specify your source IP
addresses = authorized_IPs
)
)
)
)
URL = "https://api.digitalocean.com/v2/firewalls" resp = request(URL) %>% req_headers( "Content-Type" = "application/json", "Authorization" = paste("Bearer", api_token) ) %>% req_body_json(body) |> req_perform() resp$status_code }
I encountered an issue with the example code below provided in the documentation for the
firewall_create
function.Code from Documentation:
Error received:
Error: missing name
Also, the message error is weird as the name is provided in the first argument.