-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce VPC Peering resource (#318)
* Introduce VPC Peering resource VPC Peerings is a closed beta feature and not available for public use. * Fix linter * Fix vpc peering return codes * Return vpc peering when deleting * Remove PUT /vpc_peerings * Adapt rubocop * Update .rubocop_todo.yml
- Loading branch information
1 parent
50fab3b
commit f71bddd
Showing
12 changed files
with
274 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
module DropletKit | ||
class VPCPeeringMapping | ||
include Kartograph::DSL | ||
|
||
kartograph do | ||
mapping VPCPeering | ||
root_key plural: 'vpc_peerings', singular: 'vpc_peering', scopes: [:read] | ||
|
||
scoped :read do | ||
property :id | ||
property :name | ||
property :vpc_ids | ||
property :created_at | ||
property :status | ||
end | ||
|
||
scoped :update, :patch do | ||
property :name | ||
end | ||
|
||
scoped :create do | ||
property :name | ||
property :vpc_ids | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
module DropletKit | ||
class VPCPeering < BaseModel | ||
attribute :id | ||
attribute :name | ||
attribute :vpc_ids | ||
attribute :created_at | ||
attribute :status | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# frozen_string_literal: true | ||
|
||
module DropletKit | ||
class VPCPeeringResource < ResourceKit::Resource | ||
include ErrorHandlingResourcable | ||
|
||
resources do | ||
action :find, 'GET /v2/vpc_peerings/:id' do | ||
handler(200) do |response| | ||
VPCPeeringMapping.extract_single(response.body, :read) | ||
end | ||
end | ||
|
||
action :all, 'GET /v2/vpc_peerings' do | ||
query_keys :per_page, :page | ||
|
||
handler(200) do |response| | ||
VPCPeeringMapping.extract_collection(response.body, :read) | ||
end | ||
end | ||
|
||
action :create, 'POST /v2/vpc_peerings' do | ||
body { |vpc_peering| VPCPeeringMapping.representation_for(:create, vpc_peering) } | ||
handler(202) { |response| VPCPeeringMapping.extract_single(response.body, :read) } | ||
handler(422) { |response| ErrorMapping.fail_with(FailedCreate, response.body) } | ||
end | ||
|
||
action :patch, 'PATCH /v2/vpc_peerings/:id' do | ||
body { |vpc_peering| VPCPeeringMapping.representation_for(:patch, vpc_peering) } | ||
handler(200) { |response| VPCPeeringMapping.extract_single(response.body, :read) } | ||
handler(422) { |response| ErrorMapping.fail_with(FailedUpdate, response.body) } | ||
end | ||
|
||
action :delete, 'DELETE /v2/vpc_peerings/:id' do | ||
handler(202) { |response| VPCPeeringMapping.extract_single(response.body, :read) } | ||
end | ||
end | ||
|
||
def all(*args) | ||
PaginatedResource.new(action(:all), self, *args) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"vpc_peerings": [ | ||
{ | ||
"id":"6e9bff8e-2d65-4301-9a48-f80a25ad89fa", | ||
"name":"my-new-vpc-peering-1", | ||
"vpc_ids":["880b7f98-f062-404d-b33c-458d545696f6","be76c5b4-c6c4-4fbb-a710-edbfe76c1982"], | ||
"created_at":"2024-04-03T21:48:41.995304079Z", | ||
"status":"ACTIVE" | ||
}, | ||
{ | ||
"id":"cea63fe9-d95a-4bf9-b1ad-a599c67dec73", | ||
"name":"my-new-vpc-peering-1", | ||
"vpc_ids":["4598983b-e0f4-4039-ac6e-07e487e2712b","d4b88c23-528b-462d-8433-8740398a46cf"], | ||
"created_at":"2024-04-03T21:48:45.995304079Z", | ||
"status":"ACTIVE" | ||
} | ||
], | ||
"links": { | ||
"pages": { | ||
"first": "https://api.digitalocean.com/v2/vpc_peerings?page=1&per_page=2", | ||
"last": "https://api.digitalocean.com/v2/vpc_peerings?page=4&per_page=2", | ||
"next": "https://api.digitalocean.com/v2/vpc_peerings?page=3&per_page=2", | ||
"prev": "https://api.digitalocean.com/v2/vpc_peerings?page=1&per_page=2" | ||
} | ||
}, | ||
"meta": { | ||
"total": 10 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"vpc_peering": | ||
{ | ||
"id":"6e9bff8e-2d65-4301-9a48-f80a25ad89fa", | ||
"name":"my-new-vpc-peering-1", | ||
"vpc_ids":["880b7f98-f062-404d-b33c-458d545696f6","be76c5b4-c6c4-4fbb-a710-edbfe76c1982"], | ||
"created_at":"2024-04-03T21:48:41.995304079Z", | ||
"status":"ACTIVE" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.