- name
- telnyx-networking-go
- description
- Configure private networks, WireGuard VPN gateways, internet gateways, and virtual cross connects. This skill provides Go SDK examples.
- metadata
- {"author":"telnyx","product":"networking","language":"go","generated_by":"telnyx-ext-skills-generator"}
<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
# Telnyx Networking - Go
## Installation
```bash
go get github.com/team-telnyx/telnyx-go
```
## Setup
```go
import (
"context"
"fmt"
"os"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
client := telnyx.NewClient(
option.WithAPIKey(os.Getenv("TELNYX_API_KEY")),
)
```
All examples below assume `client` is already initialized as shown above.
## List all Regions
List all regions and the interfaces that region supports
`GET /regions`
```go
regions, err := client.Regions.List(context.TODO())
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", regions.Data)
```
## List all Networks
List all Networks.
`GET /networks`
```go
page, err := client.Networks.List(context.TODO(), telnyx.NetworkListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
```
## Create a Network
Create a new Network.
`POST /networks`
```go
network, err := client.Networks.New(context.TODO(), telnyx.NetworkNewParams{
NetworkCreate: telnyx.NetworkCreateParam{
RecordParam: telnyx.RecordParam{},
Name: "test network",
},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", network.Data)
```
## Retrieve a Network
Retrieve a Network.
`GET /networks/{id}`
```go
network, err := client.Networks.Get(context.TODO(), "6a09cdc3-8948-47f0-aa62-74ac943d6c58")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", network.Data)
```
## Update a Network
Update a Network.
`PATCH /networks/{id}`
```go
network, err := client.Networks.Update(
context.TODO(),
"6a09cdc3-8948-47f0-aa62-74ac943d6c58",
telnyx.NetworkUpdateParams{
NetworkCreate: telnyx.NetworkCreateParam{
RecordParam: telnyx.RecordParam{},
Name: "test network",
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", network.Data)
```
## Delete a Network
Delete a Network.
`DELETE /networks/{id}`
```go
network, err := client.Networks.Delete(context.TODO(), "6a09cdc3-8948-47f0-aa62-74ac943d6c58")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", network.Data)
```
## Get Default Gateway status.
`GET /networks/{id}/default_gateway`
```go
defaultGateway, err := client.Networks.DefaultGateway.Get(context.TODO(), "6a09cdc3-8948-47f0-aa62-74ac943d6c58")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", defaultGateway.Data)
```
## Create Default Gateway.
`POST /networks/{id}/default_gateway`
```go
defaultGateway, err := client.Networks.DefaultGateway.New(
context.TODO(),
"6a09cdc3-8948-47f0-aa62-74ac943d6c58",
telnyx.NetworkDefaultGatewayNewParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", defaultGateway.Data)
```
## Delete Default Gateway.
`DELETE /networks/{id}/default_gateway`
```go
defaultGateway, err := client.Networks.DefaultGateway.Delete(context.TODO(), "6a09cdc3-8948-47f0-aa62-74ac943d6c58")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", defaultGateway.Data)
```
## List all Interfaces for a Network.
`GET /networks/{id}/network_interfaces`
```go
page, err := client.Networks.ListInterfaces(
context.TODO(),
"6a09cdc3-8948-47f0-aa62-74ac943d6c58",
telnyx.NetworkListInterfacesParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
```
## List all WireGuard Interfaces
List all WireGuard Interfaces.
`GET /wireguard_interfaces`
```go
page, err := client.WireguardInterfaces.List(context.TODO(), telnyx.WireguardInterfaceListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
```
## Create a WireGuard Interface
Create a new WireGuard Interface.
`POST /wireguard_interfaces`
```go
wireguardInterface, err := client.WireguardInterfaces.New(context.TODO(), telnyx.WireguardInterfaceNewParams{
RegionCode: "ashburn-va",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", wireguardInterface.Data)
```
## Retrieve a WireGuard Interfaces
Retrieve a WireGuard Interfaces.
`GET /wireguard_interfaces/{id}`
```go
wireguardInterface, err := client.WireguardInterfaces.Get(context.TODO(), "6a09cdc3-8948-47f0-aa62-74ac943d6c58")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", wireguardInterface.Data)
```
## Delete a WireGuard Interface
Delete a WireGuard Interface.
`DELETE /wireguard_interfaces/{id}`
```go
wireguardInterface, err := client.WireguardInterfaces.Delete(context.TODO(), "6a09cdc3-8948-47f0-aa62-74ac943d6c58")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", wireguardInterface.Data)
```
## List all WireGuard Peers
List all WireGuard peers.
`GET /wireguard_peers`
```go
page, err := client.WireguardPeers.List(context.TODO(), telnyx.WireguardPeerListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
```
## Create a WireGuard Peer
Create a new WireGuard Peer.
`POST /wireguard_peers`
```go
wireguardPeer, err := client.WireguardPeers.New(context.TODO(), telnyx.WireguardPeerNewParams{
WireguardInterfaceID: "6a09cdc3-8948-47f0-aa62-74ac943d6c58",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", wireguardPeer.Data)
```
## Retrieve the WireGuard Peer
Retrieve the WireGuard peer.
`GET /wireguard_peers/{id}`
```go
wireguardPeer, err := client.WireguardPeers.Get(context.TODO(), "6a09cdc3-8948-47f0-aa62-74ac943d6c58")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", wireguardPeer.Data)
```
## Update the WireGuard Peer
Update the WireGuard peer.
`PATCH /wireguard_peers/{id}`
```go
wireguardPeer, err := client.WireguardPeers.Update(
context.TODO(),
"6a09cdc3-8948-47f0-aa62-74ac943d6c58",
telnyx.WireguardPeerUpdateParams{
WireguardPeerPatch: telnyx.WireguardPeerPatchParam{},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", wireguardPeer.Data)
```
## Delete the WireGuard Peer
Delete the WireGuard peer.
`DELETE /wireguard_peers/{id}`
```go
wireguardPeer, err := client.WireguardPeers.Delete(context.TODO(), "6a09cdc3-8948-47f0-aa62-74ac943d6c58")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", wireguardPeer.Data)
```
## Retrieve Wireguard config template for Peer
`GET /wireguard_peers/{id}/config`
```go
response, err := client.WireguardPeers.GetConfig(context.TODO(), "6a09cdc3-8948-47f0-aa62-74ac943d6c58")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response)
```
## Get all Private Wireless Gateways
Get all Private Wireless Gateways belonging to the user.
`GET /private_wireless_gateways`
```go
page, err := client.PrivateWirelessGateways.List(context.TODO(), telnyx.PrivateWirelessGatewayListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
```
## Create a Private Wireless Gateway
Asynchronously create a Private Wireless Gateway for SIM cards for a previously created network.
`POST /private_wireless_gateways` — Required: `network_id`, `name`
```go
privateWirelessGateway, err := client.PrivateWirelessGateways.New(context.TODO(), telnyx.PrivateWirelessGatewayNewParams{
Name: "My private wireless gateway",
NetworkID: "6a09cdc3-8948-47f0-aa62-74ac943d6c58",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", privateWirelessGateway.Data)
```
## Get a Private Wireless Gateway
Retrieve information about a Private Wireless Gateway.
`GET /private_wireless_gateways/{id}`
```go
privateWirelessGateway, err := client.PrivateWirelessGateways.Get(context.TODO(), "6a09cdc3-8948-47f0-aa62-74ac943d6c58")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", privateWirelessGateway.Data)
```
## Delete a Private Wireless Gateway
Deletes the Private Wireless Gateway.
`DELETE /private_wireless_gateways/{id}`
```go
privateWirelessGateway, err := client.PrivateWirelessGateways.Delete(context.TODO(), "6a09cdc3-8948-47f0-aa62-74ac943d6c58")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", privateWirelessGateway.Data)
```
## List all Public Internet Gateways
List all Public Internet Gateways.
`GET /public_internet_gateways`
```go
page, err := client.PublicInternetGateways.List(context.TODO(), telnyx.PublicInternetGatewayListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
```
## Create a Public Internet Gateway
Create a new Public Internet Gateway.
`POST /public_internet_gateways`
```go
publicInternetGateway, err := client.PublicInternetGateways.New(context.TODO(), telnyx.PublicInternetGatewayNewParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", publicInternetGateway.Data)
```
## Retrieve a Public Internet Gateway
Retrieve a Public Internet Gateway.
`GET /public_internet_gateways/{id}`
```go
publicInternetGateway, err := client.PublicInternetGateways.Get(context.TODO(), "6a09cdc3-8948-47f0-aa62-74ac943d6c58")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", publicInternetGateway.Data)
```
## Delete a Public Internet Gateway
Delete a Public Internet Gateway.
`DELETE /public_internet_gateways/{id}`
```go
publicInternetGateway, err := client.PublicInternetGateways.Delete(context.TODO(), "6a09cdc3-8948-47f0-aa62-74ac943d6c58")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", publicInternetGateway.Data)
```
## List all Virtual Cross Connects
List all Virtual Cross Connects.
GitHubで見る