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 12 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 @@ -441,6 +441,21 @@ tags:
setups or other configurations requiring movable addresses.

Reserved IPs are bound to a specific region.

- name: "[Beta] Reserved IPv6"
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: "[Beta] 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 @@ -1643,6 +1658,24 @@ paths:
get:
$ref: 'resources/reserved_ips/reservedIPsActions_get.yml'

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

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

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

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

/v2/reserved_ipv6/{reserved_ipv6}/actions:
post:
$ref: 'resources/reserved_ipv6/reservedIPv6Actions_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_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/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 \
-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,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()

createRequest := &godo.ReservedIPV6CreateRequest{
RegionSlug: "nyc3",
}
imaskm marked this conversation as resolved.
Show resolved Hide resolved

reservedIPV6, _, err := client.ReservedIPV6s.Create(ctx, createRequest)
}
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")
}
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(reserved_ipv6="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(reserved_ipv6="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.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_ipv6s_actions.post(reserved_ipv6="2409:40d0:f7:1017:74b4:3a96:105e:4c6e", body=req)
26 changes: 26 additions & 0 deletions specification/resources/reserved_ipv6/models/reserved_ipv6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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.

reserved_at:
type: string
format: date-time
example: "2024-11-20T11:08:30Z"
description: The date and time when the reserved IPv6 was reserved.

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'


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
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
type: object
properties:
reserved_ipv6s:
type: array
items:
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
reserved_at:
type: string
format: date-time
example: '2020-01-01T00:00:00Z'
droplet:
$ref: '../../droplets/models/droplet.yml'
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
Loading