Skip to main content
POST
/
virtual_networks
/
assignments
Go (SDK)
package main

import(
	"context"
	"os"
	latitudeshgosdk "github.com/latitudesh/latitudesh-go-sdk"
	"github.com/latitudesh/latitudesh-go-sdk/models/operations"
	"log"
)

func main() {
    ctx := context.Background()

    s := latitudeshgosdk.New(
        latitudeshgosdk.WithSecurity(os.Getenv("LATITUDESH_BEARER")),
    )

    res, err := s.PrivateNetworks.Assign(ctx, operations.AssignServerVirtualNetworkPrivateNetworksRequestBody{
        Data: &operations.AssignServerVirtualNetworkPrivateNetworksData{
            Type: operations.AssignServerVirtualNetworkPrivateNetworksTypeVirtualNetworkAssignment,
            Attributes: &operations.AssignServerVirtualNetworkPrivateNetworksAttributes{
                ServerID: "sv_pbV0DgQGd4AWz",
                VirtualNetworkID: "vlan_3YjJOLBjqvZ87",
            },
        },
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.VirtualNetworkAssignment != nil {
        // handle response
    }
}
{
  "data": {
    "id": "vnasg_W6Q2D9jEOKLpr",
    "type": "virtual_network_assignment",
    "attributes": {
      "virtual_network_id": "vlan_3YjJOLBjqvZ87",
      "vid": 1,
      "server_id": "sv_pbV0DgQGd4AWz",
      "description": "my vlan",
      "status": "connecting"
    }
  },
  "meta": {}
}

Authorizations

Authorization
string
header
required

Body

data
object

Response

201 - application/vnd.api+json

Created

data
object
meta
object