Skip to content

Commit

Permalink
Merge pull request #161 from ans-group/ecloud-vpn-gw-support
Browse files Browse the repository at this point in the history
Add support for VPN Gateways on VPC
  • Loading branch information
Xiol authored Nov 11, 2024
2 parents b8bfaf0 + 3fb273b commit b73951d
Show file tree
Hide file tree
Showing 11 changed files with 1,594 additions and 477 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: go
go:
- "1.15"
- "1.22"

script:
- go test -v ./...
35 changes: 18 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
module github.com/ans-group/sdk-go

go 1.19
go 1.22.0

toolchain go1.22.9

require (
github.com/ans-group/go-durationstring v1.2.0
github.com/golang/mock v1.6.0
github.com/mitchellh/go-homedir v1.1.0
github.com/spf13/afero v1.10.0
github.com/spf13/viper v1.17.0
github.com/stretchr/testify v1.8.4
gopkg.in/go-playground/validator.v9 v9.27.0
github.com/spf13/afero v1.11.0
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.9.0
gopkg.in/go-playground/validator.v9 v9.31.0
)

require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-playground/locales v0.12.1 // indirect
github.com/go-playground/universal-translator v0.16.0 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/leodido/go-urn v1.1.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/sagikazarmark/locafero v0.3.0 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/text v0.13.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
491 changes: 38 additions & 453 deletions go.sum

Large diffs are not rendered by default.

93 changes: 93 additions & 0 deletions pkg/service/ecloud/model.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ecloud

import (
"fmt"

"github.com/ans-group/sdk-go/pkg/connection"
)

Expand Down Expand Up @@ -1028,3 +1030,94 @@ type IOPSTier struct {
CreatedAt connection.DateTime `json:"created_at"`
UpdatedAt connection.DateTime `json:"updated_at"`
}

// VPNGateway represents a VPN gateway
type VPNGateway struct {
ID string `json:"id"`
Name string `json:"name"`
RouterID string `json:"router_id"`
SpecificationID string `json:"specification_id"`
Sync ResourceSync `json:"sync"`
Task ResourceTask `json:"task"`
CreatedAt connection.DateTime `json:"created_at"`
UpdatedAt connection.DateTime `json:"updated_at"`
}

// CreateVPNGatewayRequest represents a request to create a VPN gateway
type CreateVPNGatewayRequest struct {
Name string `json:"name,omitempty"`
RouterID string `json:"router_id"`
SpecificationID string `json:"specification_id"`
}

// PatchVPNGatewayRequest represents a request to patch a VPN gateway
type PatchVPNGatewayRequest struct {
Name string `json:"name,omitempty"`
}

// VPNGatewaySpecification represents a VPN gateway specification
type VPNGatewaySpecification struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
CreatedAt connection.DateTime `json:"created_at"`
UpdatedAt connection.DateTime `json:"updated_at"`
}

// VPNGatewayUser represents a VPN gateway user
type VPNGatewayUser struct {
ID string `json:"id"`
Name string `json:"name"`
VPNGatewayID string `json:"vpn_gateway_id"`
Username string `json:"username,omitempty"`
Sync ResourceSync `json:"sync"`
Task ResourceTask `json:"task"`
CreatedAt connection.DateTime `json:"created_at"`
UpdatedAt connection.DateTime `json:"updated_at"`
}

// CreateVPNGatewayUserRequest represents a request to create a VPN gateway user
type CreateVPNGatewayUserRequest struct {
Name string `json:"name,omitempty"`
VPNGatewayID string `json:"vpn_gateway_id"`
Username string `json:"username"`
Password string `json:"password"`
}

// PatchVPNGatewayUserRequest represents a request to patch a VPN gateway user
type PatchVPNGatewayUserRequest struct {
Name string `json:"name,omitempty"`
Password string `json:"password,omitempty"`
}

// PatchVPNGatewayUserCredentialRequest represents a request to update VPN gateway user credentials
type PatchVPNGatewayUserCredentialRequest struct {
Password string `json:"password"`
}

// VPNGatewayNotFoundError represents a VPN gateway not found error
type VPNGatewayNotFoundError struct {
ID string
}

func (e *VPNGatewayNotFoundError) Error() string {
return fmt.Sprintf("VPN gateway not found with ID [%s]", e.ID)
}

// VPNGatewaySpecificationNotFoundError represents a VPN gateway specification not found error
type VPNGatewaySpecificationNotFoundError struct {
ID string
}

func (e *VPNGatewaySpecificationNotFoundError) Error() string {
return fmt.Sprintf("VPN gateway specification not found with ID [%s]", e.ID)
}

// VPNGatewayUserNotFoundError represents a VPN gateway user not found error
type VPNGatewayUserNotFoundError struct {
ID string
}

func (e *VPNGatewayUserNotFoundError) Error() string {
return fmt.Sprintf("VPN gateway user not found with ID [%s]", e.ID)
}
37 changes: 31 additions & 6 deletions pkg/service/ecloud/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ type ECloudService interface {
PatchNetworkRulePort(ruleID string, req PatchNetworkRulePortRequest) (TaskReference, error)
DeleteNetworkRulePort(ruleID string) (string, error)

//Volume Groups
// Volume Groups
GetVolumeGroups(parameters connection.APIRequestParameters) ([]VolumeGroup, error)
GetVolumeGroupsPaginated(parameters connection.APIRequestParameters) (*connection.Paginated[VolumeGroup], error)
GetVolumeGroup(groupID string) (VolumeGroup, error)
Expand Down Expand Up @@ -399,6 +399,31 @@ type ECloudService interface {
GetVPNProfileGroupsPaginated(parameters connection.APIRequestParameters) (*connection.Paginated[VPNProfileGroup], error)
GetVPNProfileGroup(groupID string) (VPNProfileGroup, error)

// VPN Gateways
GetVPNGateways(parameters connection.APIRequestParameters) ([]VPNGateway, error)
GetVPNGatewaysPaginated(parameters connection.APIRequestParameters) (*connection.Paginated[VPNGateway], error)
GetVPNGateway(gatewayID string) (VPNGateway, error)
CreateVPNGateway(req CreateVPNGatewayRequest) (TaskReference, error)
PatchVPNGateway(gatewayID string, req PatchVPNGatewayRequest) (TaskReference, error)
DeleteVPNGateway(gatewayID string) (string, error)
GetVPNGatewayTasks(gatewayID string, parameters connection.APIRequestParameters) ([]Task, error)
GetVPNGatewayTasksPaginated(gatewayID string, parameters connection.APIRequestParameters) (*connection.Paginated[Task], error)

// VPN Gateway Users
GetVPNGatewayUsers(parameters connection.APIRequestParameters) ([]VPNGatewayUser, error)
GetVPNGatewayUsersPaginated(parameters connection.APIRequestParameters) (*connection.Paginated[VPNGatewayUser], error)
GetVPNGatewayUser(userID string) (VPNGatewayUser, error)
CreateVPNGatewayUser(req CreateVPNGatewayUserRequest) (TaskReference, error)
PatchVPNGatewayUser(userID string, req PatchVPNGatewayUserRequest) (TaskReference, error)
DeleteVPNGatewayUser(userID string) (string, error)

// VPN Gateway Specifications
GetVPNGatewaySpecifications(parameters connection.APIRequestParameters) ([]VPNGatewaySpecification, error)
GetVPNGatewaySpecificationsPaginated(parameters connection.APIRequestParameters) (*connection.Paginated[VPNGatewaySpecification], error)
GetVPNGatewaySpecification(specificationID string) (VPNGatewaySpecification, error)
GetVPNGatewaySpecificationAvailabilityZones(specificationID string, parameters connection.APIRequestParameters) ([]AvailabilityZone, error)
GetVPNGatewaySpecificationAvailabilityZonesPaginated(specificationID string, parameters connection.APIRequestParameters) (*connection.Paginated[AvailabilityZone], error)

// Load Balancer
GetLoadBalancers(parameters connection.APIRequestParameters) ([]LoadBalancer, error)
GetLoadBalancersPaginated(parameters connection.APIRequestParameters) (*connection.Paginated[LoadBalancer], error)
Expand All @@ -420,30 +445,30 @@ type ECloudService interface {
PatchVIP(vipID string, patch PatchVIPRequest) (TaskReference, error)
DeleteVIP(vipID string) (string, error)

//IP Addresses
// IP Addresses
GetIPAddresses(parameters connection.APIRequestParameters) ([]IPAddress, error)
GetIPAddressesPaginated(parameters connection.APIRequestParameters) (*connection.Paginated[IPAddress], error)
GetIPAddress(ipID string) (IPAddress, error)
CreateIPAddress(req CreateIPAddressRequest) (TaskReference, error)
PatchIPAddress(ipID string, patch PatchIPAddressRequest) (TaskReference, error)
DeleteIPAddress(ipID string) (string, error)

//Affinity Rules
// Affinity Rules
GetAffinityRules(parameters connection.APIRequestParameters) ([]AffinityRule, error)
GetAffinityRulesPaginated(parameters connection.APIRequestParameters) (*connection.Paginated[AffinityRule], error)
GetAffinityRule(ruleID string) (AffinityRule, error)
CreateAffinityRule(req CreateAffinityRuleRequest) (TaskReference, error)
PatchAffinityRule(ruleID string, patch PatchAffinityRuleRequest) (TaskReference, error)
DeleteAffinityRule(ruleID string) (string, error)

//Affinity Rule Members
// Affinity Rule Members
GetAffinityRuleMembers(ruleID string, parameters connection.APIRequestParameters) ([]AffinityRuleMember, error)
GetAffinityRuleMembersPaginated(ruleID string, parameters connection.APIRequestParameters) (*connection.Paginated[AffinityRuleMember], error)
GetAffinityRuleMember(memberID string) (AffinityRuleMember, error)
CreateAffinityRuleMember(req CreateAffinityRuleMemberRequest) (TaskReference, error)
DeleteAffinityRuleMember(memberID string) (string, error)

//Resource Tiers
// Resource Tiers
GetResourceTiers(parameters connection.APIRequestParameters) ([]ResourceTier, error)
GetResourceTiersPaginated(parameters connection.APIRequestParameters) (*connection.Paginated[ResourceTier], error)
GetResourceTier(tierID string) (ResourceTier, error)
Expand All @@ -456,7 +481,7 @@ type ECloudService interface {
PatchNATOverloadRule(ruleID string, req PatchNATOverloadRuleRequest) (TaskReference, error)
DeleteNATOverloadRule(ruleID string) (string, error)

//IOPS Tiers
// IOPS Tiers
GetIOPSTiers(parameters connection.APIRequestParameters) ([]IOPSTier, error)
GetIOPSTiersPaginated(parameters connection.APIRequestParameters) (*connection.Paginated[IOPSTier], error)
GetIOPSTier(iopsID string) (IOPSTier, error)
Expand Down
Loading

0 comments on commit b73951d

Please sign in to comment.