To add additional access rules to a firewall, send a POST request to
/v2/firewalls/$FIREWALL_ID/rules
. The body of the request may include an
inbound_rules and/or outbound_rules attribute containing an array of rules to
be added.
No response body will be sent back, but the response code will indicate success. Specifically, the response code will be a 204, which means that the action was successful with no returned body data.
Name | Type | Required | Description | Default Value |
---|---|---|---|---|
firewall_id |
string | True | A unique ID that can be used to identify and reference a firewall. | |
body |
JSON or IO[bytes] | False |
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
req = {
"inbound_rules": [
{
"protocol": "tcp",
"ports": "3306",
"sources": {
"droplet_ids": [
49696269
]
}
}
],
"outbound_rules": [
{
"protocol": "tcp",
"ports": "3306",
"destinations": {
"droplet_ids": [
49696269
]
}
}
]
}
resp = client.firewalls.add_rules(firewall_id="39fa4gz", body=req)
See the API spec for this endpoint to view additional detail on responses, headers, parameters, and more.