Documentation ¶
Overview ¶
Package crossregionsubnets provides the ability to retrieve and manage cross-region subnets through the Resell v2 API.
Example of getting a single cross-region subnet referenced by its id
crossRegionSubnet, _, err := crossregionsubnets.Get(context, resellClient, crossRegionSubnetID) if err != nil { log.Fatal(err) } fmt.Println(crossRegionSubnet)
Example of getting all cross-region subnets
allCrossRegionSubnets, _, err := crossregionsubnets.List(ctx, resellClient, crossregionsubnets.ListOpts{}) if err != nil { log.Fatal(err) } for _, crossRegionSubnet := range allCrossRegionSubnets { fmt.Println(crossRegionSubnet) }
Example of creating cross-region subnets
createOpts := crossregionsubnets.CrossRegionSubnetOpts{ CrossRegionSubnets: []crossregionsubnets.CrossRegionSubnetOpt{ { Quantity: 1, Regions: []crossregionsubnets.CrossRegionOpt{ { Region: "ru-1", }, { Region: "ru-3", }, }, CIDR: "192.168.200.0/24", }, }, } newCrossRegionSubnets, _, err := crossregionsubnets.Create(ctx, resellClient, projectID, createOpts) if err != nil { log.Fatal(err) } for _, newCrossRegionSubnet := range newCrossRegionSubnets { fmt.Printf("%v\n", newCrossRegionSubnet) }
Example of deleting a single cross-region subnet
_, err = crossregionsubnets.Delete(ctx, resellClient, crossRegionSubnetID) if err != nil { log.Fatal(err) }
Index ¶
- func Delete(ctx context.Context, client *selvpcclient.ServiceClient, id string) (*selvpcclient.ResponseResult, error)
- type CrossRegionOpt
- type CrossRegionSubnet
- func Create(ctx context.Context, client *selvpcclient.ServiceClient, projectID string, ...) ([]*CrossRegionSubnet, *selvpcclient.ResponseResult, error)
- func Get(ctx context.Context, client *selvpcclient.ServiceClient, id string) (*CrossRegionSubnet, *selvpcclient.ResponseResult, error)
- func List(ctx context.Context, client *selvpcclient.ServiceClient, opts ListOpts) ([]*CrossRegionSubnet, *selvpcclient.ResponseResult, error)
- type CrossRegionSubnetOpt
- type CrossRegionSubnetOpts
- type ListOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
func Delete(ctx context.Context, client *selvpcclient.ServiceClient, id string) (*selvpcclient.ResponseResult, error)
Delete deletes a single cross-region subnet by its id.
Types ¶
type CrossRegionOpt ¶
type CrossRegionOpt struct { // Region represents region that cross-region subnet is associated to. Region string `json:"region"` }
CrossRegionOpt represents region options for the cross-region subnet.
type CrossRegionSubnet ¶
type CrossRegionSubnet struct { // ID is a unique id of a cross-region subnet. ID int `json:"id"` // CIDR is a cross-region subnet prefix in CIDR notation. CIDR string `json:"cidr"` // VLANID represents id of the associated VLAN in the Networking service. VLANID int `json:"vlan_id"` // Status shows if cross-region subnet is used. Status string `json:"status"` // ProjectID represents an associated Identity service project. ProjectID string `json:"project_id"` // Servers contains info about servers to which cross-region subnet is associated to. Servers []servers.Server `json:"servers"` // Subnets contains standard subnets in every region that cross-region subnet is attached to. Subnets []subnets.Subnet `json:"subnets"` }
CrossRegionSubnet represents a single Resell cross-region subnet.
func Create ¶
func Create(ctx context.Context, client *selvpcclient.ServiceClient, projectID string, createOpts CrossRegionSubnetOpts) ([]*CrossRegionSubnet, *selvpcclient.ResponseResult, error)
Create requests a creation of the cross-region subnets in the specified project.
func Get ¶
func Get(ctx context.Context, client *selvpcclient.ServiceClient, id string) (*CrossRegionSubnet, *selvpcclient.ResponseResult, error)
Get returns a single cross-region subnet by its id.
func List ¶
func List(ctx context.Context, client *selvpcclient.ServiceClient, opts ListOpts) ([]*CrossRegionSubnet, *selvpcclient.ResponseResult, error)
List gets a list of cross-region subnets in the current domain.
type CrossRegionSubnetOpt ¶
type CrossRegionSubnetOpt struct { // Quantity represents how many subnets do we need to create. Quantity int `json:"quantity"` // Regions represents region options for the cross-region subnet. Regions []CrossRegionOpt `json:"regions"` // CIDR represents a subnet prefix in CIDR notation for the cross-region subnet. CIDR string `json:"cidr"` }
CrossRegionSubnetOpt represents options for the single cross-region subnet.
type CrossRegionSubnetOpts ¶
type CrossRegionSubnetOpts struct { // CrossRegionSubnets represents options for all cross-region subnets. CrossRegionSubnets []CrossRegionSubnetOpt `json:"cross_region_subnets"` }
CrossRegionSubnetOpts represents options for the cross-region subnets Create request.