Skip to content

Commit

Permalink
Added reserved ipv6 API specs (#951)
Browse files Browse the repository at this point in the history
* added reserved ipv6

* fixed lint issues

* Addressed review comments

* fixed schemas and responses

* removed ruby examples

* removed ruby example refs

* addressed review comments

* fixed python examples

* replaced beta with public-preview

* removed project_id from resp

* added 422 error

* fixed lint issue

* added null value for droplet

---------

Co-authored-by: Anna Lushnikova <[email protected]>
  • Loading branch information
imaskm and loosla authored Feb 26, 2025
1 parent 44575ea commit 31fb5b2
Show file tree
Hide file tree
Showing 32 changed files with 902 additions and 0 deletions.
33 changes: 33 additions & 0 deletions specification/DigitalOcean-public.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,21 @@ tags:
setups or other configurations requiring movable addresses.
Reserved IPs are bound to a specific region.
- name: "[Public Preview] 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: "[Public Preview] 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 @@ -1651,6 +1666,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",
}
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)
33 changes: 33 additions & 0 deletions specification/resources/reserved_ipv6/models/reserved_ipv6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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:
anyOf:
- title: 'null'
type: object
nullable: true
description: If the reserved IP is not assigned to a Droplet, the
value will be null.
- $ref: '../../droplets/models/droplet.yml'
example: null


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:
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,30 @@
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:
anyOf:
- title: 'null'
type: object
nullable: true
description: If the reserved IP is not assigned to a Droplet, the
value will be null.
- $ref: '../../droplets/models/droplet.yml'
example: null
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

0 comments on commit 31fb5b2

Please sign in to comment.