Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added reserved ipv6 API specs #951

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
33 changes: 33 additions & 0 deletions specification/DigitalOcean-public.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,21 @@ tags:
setups or other configurations requiring movable addresses.

Reserved IPs are bound to a specific region.

- name: Reserved IPv6s
description: |-
DigitalOcean Reserved IPv6s are publicly-accessible static IP addresses that can be
mapped to one of your Droplets. They can be used to create highly available
setups or other configurations requiring movable addresses.

Reserved IPv6s are bound to a specific region.
- name: Reserved IPv6 Actions
description: |-
Reserved IPv6 actions requests are made on the actions endpoint of a specific
reserved IPv6.

An action object is returned. These objects hold the current status of the
requested action.

- name: Sizes
description: |-
Expand Down Expand Up @@ -1585,6 +1600,24 @@ paths:
get:
$ref: 'resources/reserved_ips/reservedIPsActions_get.yml'

/v2/reserved_ipv6:
get:
$ref: 'resources/reserved_ipv6/reservedIPv6s_list.yml'

post:
$ref: 'resources/reserved_ipv6/reservedIPv6s_create.yml'

/v2/reserved_ipv6/{reserved_ipv6}:
get:
$ref: 'resources/reserved_ipv6/reservedIPv6s_get.yml'

delete:
$ref: 'resources/reserved_ipv6/reservedIPv6s_delete.yml'

/v2/reserved_ipv6/{reserved_ipv6}/actions:
post:
$ref: 'resources/reserved_ipv6/reservedIPv6sActions_post.yml'

/v2/sizes:
get:
$ref: 'resources/sizes/sizes_list.yml'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
lang: cURL
source: |-
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
-d '{"region_slug": "nyc3"}' \
"https://api.digitalocean.com/v2/reserved_ipv6"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
lang: cURL
source: |-
curl -X DELETE \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
"https://api.digitalocean.com/v2/reserved_ips/2409:40d0:f7:1017:74b4:3a96:105e:4c6e"
imaskm marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
lang: cURL
source: |-
curl -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
"https://api.digitalocean.com/v2/reserved_ipv6/2409:40d0:f7:1017:74b4:3a96:105e:4c6e"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
lang: cURL
source: |-
curl -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
"https://api.digitalocean.com/v2/reserved_ipv6?page=1&per_page=20"
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
lang: cURL
source: |-
# Assign a Reserved IPv6 to a Droplet
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
-d '{"type":"assign","droplet_id":8219222}' \
"https://api.digitalocean.com/v2/reserved_ipv6/2409:40d0:f7:1017:74b4:3a96:105e:4c6e/actions"

# Unassign a Reserved IPv6 from a Droplet
# curl -X POST \
imaskm marked this conversation as resolved.
Show resolved Hide resolved
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
-d '{"type":"unassign"}' \
"https://api.digitalocean.com/v2/reserved_ipv6/2409:40d0:f7:1017:74b4:3a96:105e:4c6e/actions"
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
lang: Go
source: |-
import (
"context"
"os"

"github.com/digitalocean/godo"
)

func main() {
token := os.Getenv("DIGITALOCEAN_TOKEN")

client := godo.NewFromToken(token)
ctx := context.TODO()

createRequest := &godo.ReservedIPV6CreateRequest{
RegionSlug: "nyc3",
}
imaskm marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
lang: Go
source: |-
import (
"context"
"os"

"github.com/digitalocean/godo"
)

func main() {
token := os.Getenv("DIGITALOCEAN_TOKEN")

client := godo.NewFromToken(token)
ctx := context.TODO()

_, err := client.ReservedIPV6s.Delete(ctx, "2409:40d0:f7:1017:74b4:3a96:105e:4c6e")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
lang: Go
source: |-
import (
"context"
"os"

"github.com/digitalocean/godo"
)

func main() {
token := os.Getenv("DIGITALOCEAN_TOKEN")

client := godo.NewFromToken(token)
ctx := context.TODO()

reservedIP, _, err := client.ReservedIPV6s.Get(ctx, "2409:40d0:f7:1017:74b4:3a96:105e:4c6e")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
lang: Go
source: |-
import (
"context"
"os"

"github.com/digitalocean/godo"
)

func main() {
token := os.Getenv("DIGITALOCEAN_TOKEN")

client := godo.NewFromToken(token)
ctx := context.TODO()

opt := &godo.ListOptions{
Page: 1,
PerPage: 200,
}

reservedIPs, _, err := client.ReservedIPV6s.List(ctx, opt)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
lang: Go
source: |-
import (
"context"
"os"

"github.com/digitalocean/godo"
)

func main() {
token := os.Getenv("DIGITALOCEAN_TOKEN")

client := godo.NewFromToken(token)
ctx := context.TODO()

// Assign a Reserved IPv6 to a Droplet
action, _, err := client.ReservedIPV6Actions.Assign(ctx, "2409:40d0:f7:1017:74b4:3a96:105e:4c6e", 8219222)

// Unassign a Reserved IPv6
// action, _, err := client.ReservedIPV6Actions.Unassign(ctx, "2409:40d0:f7:1017:74b4:3a96:105e:4c6e")
imaskm marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
lang: Python
source: |-
import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

req = {
"region_slug": nyc3
}

resp = client.reserved_ipv6s.create(body=req)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
lang: Python
source: |-
import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

resp = client.reserved_ipv6s.delete(ip="2409:40d0:f7:1017:74b4:3a96:105e:4c6e")
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
lang: Python
source: |-
import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

resp = client.reserved_ipv6s.get(ip="2409:40d0:f7:1017:74b4:3a96:105e:4c6e")
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
lang: Python
source: |-
import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

resp = client.reserved_ips.list()
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
lang: Python
source: |-
import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

req={
"type": "unassign"
}

resp = client.reserved_ips_actions.post(ip="2409:40d0:f7:1017:74b4:3a96:105e:4c6e", body=req)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
lang: Ruby
imaskm marked this conversation as resolved.
Show resolved Hide resolved
source: |-
require 'droplet_kit'
token = ENV['DIGITALOCEAN_TOKEN']
client = DropletKit::Client.new(access_token: token)

reserved_ip = DropletKit::ReservedIpv6.new(region_slug: nyc3)
client.reserved_ipv6s.create(reserved_ip)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
lang: Ruby
source: |-
require 'droplet_kit'
token = ENV['DIGITALOCEAN_TOKEN']
client = DropletKit::Client.new(access_token: token)

client.reserved_ipv6s.delete(ip: '2409:40d0:f7:1017:74b4:3a96:105e:4c6e')
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
lang: Ruby
source: |-
require 'droplet_kit'
token = ENV['DIGITALOCEAN_TOKEN']
client = DropletKit::Client.new(access_token: token)

client.reserved_ipv6s.find(ip: '2409:40d0:f7:1017:74b4:3a96:105e:4c6e')
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
lang: Ruby
source: |-
require 'droplet_kit'
token = ENV['DIGITALOCEAN_TOKEN']
client = DropletKit::Client.new(access_token: token)

reserved_ips = client.reserved_ipv6s.all
reserved_ips.each
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
lang: Ruby
source: |-
require 'droplet_kit'
token = ENV['DIGITALOCEAN_TOKEN']
client = DropletKit::Client.new(access_token: token)

# Assign a Reserved IPv6 to a Droplet
client.reserved_ip_actions.assign(ip: '2409:40d0:f7:1017:74b4:3a96:105e:4c6e', droplet_id: 8219222)

# Unassign a Reserved IPv6
# client.reserved_ip_actions.unassign(ip: '2409:40d0:f7:1017:74b4:3a96:105e:4c6e')
20 changes: 20 additions & 0 deletions specification/resources/reserved_ipv6/models/reserved_ipv6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
type: object

properties:
ip:
type: string
format: ipv6
example: 2409:40d0:f7:1017:74b4:3a96:105e:4c6e
description: The public IP address of the reserved IPv6. It also serves as its
identifier.

region_slug:
type: string
description: The region that the reserved IPv6 is reserved to. When you
query a reserved IPv6,the region_slug will be returned.
example: nyc3

droplet:
$ref: '../../droplets/models/droplet.yml'
imaskm marked this conversation as resolved.
Show resolved Hide resolved


Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
reserved_ipv6_action_type:
type: object
required:
- type
properties:
type:
type: string
enum:
- assign
- unassign
description: The type of action to initiate for the reserved IPv6.
discriminator:
propertyName: type
mapping:
assign: '#/reserved_ipv6_action_assign'
unassign: '#/reserved_ipv6_action_unassign'

reserved_ipv6_action_unassign:
allOf:
- $ref: '#/reserved_ipv6_action_type'
- type: object
required:
- type

reserved_ipv6_action_assign:
allOf:
- $ref: '#/reserved_ipv6_action_type'
- type: object
required:
- type
- droplet_id
properties:
droplet_id:
type: integer
example: 758604968
description: The ID of the Droplet that the reserved IPv6 will be assigned to.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title: Reserve to Region
type: object
properties:
region_slug:
imaskm marked this conversation as resolved.
Show resolved Hide resolved
type: string
example: nyc3
description: The slug identifier for the region the reserved IPv6 will be reserved to.
required:
- region_slug
10 changes: 10 additions & 0 deletions specification/resources/reserved_ipv6/parameters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
reserved_ipv6:
in: path
name: reserved_ipv6
description: A reserved IPv6 address.
required: true
schema:
type: string
format: ipv6
minimum: 1
example: 2409:40d0:f7:1017:74b4:3a96:105e:4c6e
Loading