Skip to content

Commit

Permalink
VPC Peering Updates (#924)
Browse files Browse the repository at this point in the history
* add vpc peering create and support files

* add remaining vpc peering endpoints

* remove duplicate model yaml to make linter happy

* fix operation ID linting errors

* fix alphabetical tags linter error

* make linter happy

* Update specification/resources/vpcs/responses/vpc_peering.yml

Co-authored-by: Andrew Starr-Bochicchio <[email protected]>

* add peering update endpoint through vpcs

* make happy

* update name rules and regex

* correct token scope

* Apply suggestions from code review

Co-authored-by: Andrew Starr-Bochicchio <[email protected]>

---------

Co-authored-by: Andrew Starr-Bochicchio <[email protected]>
  • Loading branch information
beardicus and andrewsomething authored Oct 10, 2024
1 parent e67d14f commit 705f149
Show file tree
Hide file tree
Showing 26 changed files with 752 additions and 0 deletions.
34 changes: 34 additions & 0 deletions specification/DigitalOcean-public.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,13 @@ tags:
To interact with Uptime, you will generally send requests to the Uptime endpoint at `/v2/uptime/`.
- name: VPC Peerings
description: |-
[VPC Peerings](https://docs.digitalocean.com/products/networking/vpc/how-to/create-peering/)
join two VPC networks with a secure, private connection. This allows
resources in those networks to connect to each other's private IP addresses
as if they were in the same network.
- name: VPCs
description: |-
[VPCs (virtual private clouds)](https://docs.digitalocean.com/products/networking/vpc/)
Expand Down Expand Up @@ -1637,6 +1644,33 @@ paths:
get:
$ref: 'resources/vpcs/vpcs_list_members.yml'

/v2/vpcs/{vpc_id}/peerings:
get:
$ref: 'resources/vpcs/vpcs_list_peerings.yml'

post:
$ref: 'resources/vpcs/vpcs_create_peerings.yml'

/v2/vpcs/{vpc_id}/peerings/{vpc_peering_id}:
patch:
$ref: 'resources/vpcs/vpcs_update_peerings.yml'

/v2/vpc_peerings:
get:
$ref: 'resources/vpc_peerings/vpc_peerings_list.yml'

post:
$ref: 'resources/vpc_peerings/vpc_peerings_create.yml'

/v2/vpc_peerings/{vpc_peering_id}:
get:
$ref: 'resources/vpc_peerings/vpc_peerings_get.yml'

patch:
$ref: 'resources/vpc_peerings/vpc_peerings_update.yml'

delete:
$ref: 'resources/vpc_peerings/vpc_peerings_delete.yml'

/v2/uptime/checks:
get:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
lang: cURL
source: |-
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
-d '{"name": "my-first-vpc-peering", "vpc_ids": [ "997615ce-132d-4bae-9270-9ee21b395e5d", "e51aed59-3bb1-4a6a-8de0-9d1329e9c997"]}' \
"https://api.digitalocean.com/v2/vpc_peerings"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
lang: cURL
source: |-
curl -X DELETE \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
"https://api.digitalocean.com/v2/vpc_peerings/6b5c619c-359c-44ca-87e2-47e98170c01d"
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/vpc_peerings/5a4981aa-9653-4bd1-bef5-d6bff52042e4"
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/vpc_peerings?region=sfo3&page=1&per_page=20"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
lang: cURL
source: |-
curl -X PATCH \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
-d '{"name":"renamed-vpc-peering"}' \
"https://api.digitalocean.com/v2/vpc_peerings/5a4981aa-9653-4bd1-bef5-d6bff52042e4"
58 changes: 58 additions & 0 deletions specification/resources/vpc_peerings/models/vpc_peering.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
vpc_peering:
type: object
allOf:
- $ref: '#/vpc_peering_base'
- $ref: '#/vpc_peering_create'
- $ref: '#/vpc_peering_updatable'

vpc_peering_base:
type: object
properties:
id:
type: string
format: uuid
readOnly: true
example: 5a4981aa-9653-4bd1-bef5-d6bff52042e4
description: A unique ID that can be used to identify and reference the VPC peering.

created_at:
type: string
format: date-time
readOnly: true
example: "2020-03-13T19:20:47.442049222Z"
description: A time value given in ISO8601 combined date and time format.

status:
type: string
enum:
- PROVISIONING
- ACTIVE
- DELETING
readOnly: true
example: "ACTIVE"
description: The current status of the VPC peering.

vpc_peering_create:
type: object
properties:
vpc_ids:
type: array
items:
type: string
format: uuid
minItems: 2
maxItems: 2
example:
- c140286f-e6ce-4131-8b7b-df4590ce8d6a
- 994a2735-dc84-11e8-80bc-3cfdfea9fba1
description: An array of the two peered VPCs IDs.

vpc_peering_updatable:
type: object
properties:
name:
type: string
pattern: '^[a-zA-Z0-9\-]+$'
example: nyc1-blr1-peering
description: The name of the VPC peering. Must be unique within the team
and may only contain alphanumeric characters and dashes.
9 changes: 9 additions & 0 deletions specification/resources/vpc_peerings/parameters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
vpc_peering_id:
in: path
name: vpc_peering_id
description: A unique identifier for a VPC peering.
required: true
schema:
type: string
format: uuid
example: 5a4981aa-9653-4bd1-bef5-d6bff52042e4
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
description: The response will be a JSON object with a key called `vpc_peering`.
The value of this will be an object that contains the standard attributes
associated with a VPC peering.

headers:
ratelimit-limit:
$ref: '../../../shared/headers.yml#/ratelimit-limit'
ratelimit-remaining:
$ref: '../../../shared/headers.yml#/ratelimit-remaining'
ratelimit-reset:
$ref: '../../../shared/headers.yml#/ratelimit-reset'

content:
application/json:
schema:
type: object
properties:
vpc_peering:
$ref: '../models/vpc_peering.yml#/vpc_peering'

example:
vpc_peering:
id: 5a4981aa-9653-4bd1-bef5-d6bff52042e4
name: example-vpc-peering
vpc_ids:
- 997615ce-132d-4bae-9270-9ee21b395e5d
- e51aed59-3bb1-4a6a-8de0-9d1329e9c997
created_at: '2024-01-09T20:44:32Z'
status: ACTIVE
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
description: >-
The response will be a JSON object with a key called `vpc_peerings`. This
will be set to an array of objects, each of which will contain the standard
attributes associated with a VPC peering.
headers:
ratelimit-limit:
$ref: '../../../shared/headers.yml#/ratelimit-limit'
ratelimit-remaining:
$ref: '../../../shared/headers.yml#/ratelimit-remaining'
ratelimit-reset:
$ref: '../../../shared/headers.yml#/ratelimit-reset'

content:
application/json:
schema:
allOf:
- type: object
properties:
vpc_peerings:
type: array
items:
$ref: '../models/vpc_peering.yml#/vpc_peering'
- $ref: '../../../shared/pages.yml#/pagination'
- $ref: '../../../shared/meta.yml'

example:
vpc_peerings:
- id: 6b5c619c-359c-44ca-87e2-47e98170c01d
name: example-vpc-peering
vpc_ids:
- 997615ce-132d-4bae-9270-9ee21b395e5d
- e51aed59-3bb1-4a6a-8de0-9d1329e9c997
created_at: '2024-01-09T20:44:32Z'
status: ACTIVE
- id: c212b274-911c-44cc-a117-23b7da4a2922
name: another-vpc-peering
vpc_ids:
- 5a100736-b085-4f69-81fd-feee325784bb
- c140286f-e6ce-4131-8b7b-df4590ce8d6a
created_at: '2024-01-10T13:29:58Z'
status: ACTIVE
links: {}
meta:
total: 2



Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
description: The response will be a JSON object with a key called `vpc_peering`.
The value of this will be an object that contains the standard attributes
associated with a VPC peering.

headers:
ratelimit-limit:
$ref: '../../../shared/headers.yml#/ratelimit-limit'
ratelimit-remaining:
$ref: '../../../shared/headers.yml#/ratelimit-remaining'
ratelimit-reset:
$ref: '../../../shared/headers.yml#/ratelimit-reset'

content:
application/json:
schema:
type: object
properties:
vpc_peering:
$ref: '../models/vpc_peering.yml#/vpc_peering'

example:
vpc_peering:
id: 5a4981aa-9653-4bd1-bef5-d6bff52042e4
name: example-vpc-peering
vpc_ids:
- 997615ce-132d-4bae-9270-9ee21b395e5d
- e51aed59-3bb1-4a6a-8de0-9d1329e9c997
created_at: '2024-01-09T20:44:32Z'
status: DELETING
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
description: The response will be a JSON object with a key called `vpc_peering`.
The value of this will be an object that contains the standard attributes
associated with a VPC peering.

headers:
ratelimit-limit:
$ref: '../../../shared/headers.yml#/ratelimit-limit'
ratelimit-remaining:
$ref: '../../../shared/headers.yml#/ratelimit-remaining'
ratelimit-reset:
$ref: '../../../shared/headers.yml#/ratelimit-reset'

content:
application/json:
schema:
type: object
properties:
vpc_peering:
$ref: '../models/vpc_peering.yml#/vpc_peering'

example:
vpc_peering:
id: 5a4981aa-9653-4bd1-bef5-d6bff52042e4
name: example-vpc-peering
vpc_ids:
- 997615ce-132d-4bae-9270-9ee21b395e5d
- e51aed59-3bb1-4a6a-8de0-9d1329e9c997
created_at: '2024-01-09T20:44:32Z'
status: PROVISIONING
51 changes: 51 additions & 0 deletions specification/resources/vpc_peerings/vpc_peerings_create.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
operationId: vpcPeerings_create

summary: Create a New VPC Peering

description: |
To create a new VPC Peering, send a POST request to `/v2/vpc_peerings`
specifying a name and a list of two VPC IDs to peer. The response code, 202
Accepted, does not indicate the success or failure of the operation, just
that the request has been accepted for processing.
tags:
- VPC Peerings

requestBody:
required: true

content:
application/json:
schema:
type: object
allOf:
- $ref: 'models/vpc_peering.yml#/vpc_peering_updatable'
- $ref: 'models/vpc_peering.yml#/vpc_peering_create'

required:
- name
- vpc_ids


responses:
'202':
$ref: 'responses/provisioning_vpc_peering.yml'

'401':
$ref: '../../shared/responses/unauthorized.yml'

'429':
$ref: '../../shared/responses/too_many_requests.yml'

'500':
$ref: '../../shared/responses/server_error.yml'

default:
$ref: '../../shared/responses/unexpected_error.yml'

x-codeSamples:
- $ref: 'examples/curl/vpc_peerings_create.yml'

security:
- bearer_auth:
- 'vpc_peering:create'
38 changes: 38 additions & 0 deletions specification/resources/vpc_peerings/vpc_peerings_delete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
operationId: vpcPeerings_delete

summary: Delete a VPC peering

description: |
To delete a VPC peering, send a DELETE request to `/v2/vpc_peerings/$VPC_PEERING_ID`.
tags:
- VPC Peerings

parameters:
- $ref: 'parameters.yml#/vpc_peering_id'

responses:
'202':
$ref: 'responses/deleting_vpc_peering.yml'

'401':
$ref: '../../shared/responses/unauthorized.yml'

'404':
$ref: '../../shared/responses/not_found.yml'

'429':
$ref: '../../shared/responses/too_many_requests.yml'

'500':
$ref: '../../shared/responses/server_error.yml'

default:
$ref: '../../shared/responses/unexpected_error.yml'

x-codeSamples:
- $ref: 'examples/curl/vpc_peerings_delete.yml'

security:
- bearer_auth:
- 'vpc_peering:delete'
Loading

0 comments on commit 705f149

Please sign in to comment.