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.Servers.RunAction(ctx, "sv_LA73qkJwdaJ2o", operations.CreateServerActionServersRequestBody{
Data: operations.CreateServerActionServersData{
Type: operations.CreateServerActionServersTypeActions,
Attributes: &operations.CreateServerActionServersAttributes{
Action: operations.CreateServerActionActionReboot,
},
},
})
if err != nil {
log.Fatal(err)
}
if res.ServerAction != nil {
// handle response
}
}{
"data": {
"id": "act_V0DgYxxN9Ed4A",
"type": "actions",
"attributes": {
"status": "Rebooting device"
}
},
"meta": {}
}Performs an action on a given server:
power_onpower_offrebootpackage 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.Servers.RunAction(ctx, "sv_LA73qkJwdaJ2o", operations.CreateServerActionServersRequestBody{
Data: operations.CreateServerActionServersData{
Type: operations.CreateServerActionServersTypeActions,
Attributes: &operations.CreateServerActionServersAttributes{
Action: operations.CreateServerActionActionReboot,
},
},
})
if err != nil {
log.Fatal(err)
}
if res.ServerAction != nil {
// handle response
}
}{
"data": {
"id": "act_V0DgYxxN9Ed4A",
"type": "actions",
"attributes": {
"status": "Rebooting device"
}
},
"meta": {}
}Show child attributes
Was this page helpful?