Help us shape the future of Go! Take the 2026 Go Developer Survey

scalewaysdkgo

package module
v1.39.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

README

PkgGoDev GitHub Actions GoReportCard

Scaleway GO SDK

⚠ This is an early release, keep in mind that the API can break

Scaleway is a single way to create, deploy and scale your infrastructure in the cloud. We help thousands of businesses to run their infrastructures easily.

Documentation

Installation

go get github.com/scaleway/scaleway-sdk-go

Getting Started

package main

import (
	"fmt"

	"github.com/scaleway/scaleway-sdk-go/api/instance/v1"
	"github.com/scaleway/scaleway-sdk-go/scw"
	"github.com/scaleway/scaleway-sdk-go/utils"
)

func main() {

	// Create a Scaleway client
	client, err := scw.NewClient(
		// Get your organization ID at https://console.scaleway.com/organization/settings
		scw.WithDefaultOrganizationID("SCW_DEFAULT_ORGANIZATION_ID"),
		// Get your credentials at https://console.scaleway.com/iam/api-keys
		scw.WithAuth("SCW_ACCESS_KEY", "SCW_SECRET_KEY"),
		// Get more about our availability zones at https://www.scaleway.com/en/docs/console/my-account/reference-content/products-availability/
		scw.WithDefaultRegion("SCW_REGION"),
	)
	if err != nil {
		panic(err)
	}

	// Create SDK objects for Scaleway Instance product
	instanceApi := instance.NewAPI(client)

	// Call the ListServers method on the Instance SDK
	response, err := instanceApi.ListServers(&instance.ListServersRequest{
		Zone: scw.ZoneFrPar1,
	})
	if err != nil {
		panic(err)
	}

	// Do something with the response...
	for _, server := range response.Servers {
		fmt.Println("Server", server.ID, server.Name)
	}

}

Examples

You can find additional examples in the GoDoc.

Development

This repository is at its early stage and is still in active development. If you are looking for a way to contribute please read CONTRIBUTING.md.

Reach us

We love feedback. Feel free to reach us on Scaleway Slack community, we are waiting for you on #opensource.

Documentation

Overview

Package scalewaysdkgo is the Scaleway API SDK for Go.

In order to use the available APIs, create a `Client`. Once created, it can be used to instantiate an API. To use the `instance` API, for example, instantiate it (with the client object) `instance.NewApi(client)`. On this instance API, all the available API functions can be called.

Example (ApiClient)
// Create a Scaleway client
client, err := scw.NewClient(
	scw.WithAuth("ACCESS_KEY", "SECRET_KEY"), // Get your credentials at https://console.scaleway.com/project/credentials
)
if err != nil {
	// handle error
	log.Fatal(err)
}

// Create SDK objects for specific Scaleway Products
instanceAPI := instance.NewAPI(client)
lbAPI := lb.NewZonedAPI(client)

// Start using the SDKs
_, _ = instanceAPI, lbAPI
Example (ApiClientWithConfig)
// Get Scaleway Config
config, err := scw.LoadConfig()
if err != nil {
	// handle error
	log.Fatal(err)
}

// Use active profile
profile, err := config.GetActiveProfile()
if err != nil {
	// handle error
	log.Fatal(err)
}

// Create a Scaleway client
client, err := scw.NewClient(
	scw.WithProfile(profile),
	scw.WithEnv(), // env variable may overwrite profile values
)
if err != nil {
	// handle error
	log.Fatal(err)
}

// Create SDK objects for specific Scaleway Products
instanceAPI := instance.NewAPI(client)
lbAPI := lb.NewZonedAPI(client)

// Start using the SDKs
_, _ = instanceAPI, lbAPI
Example (CreateLoadBalancer)
// Create a Scaleway client
client, err := scw.NewClient(
	scw.WithAuth("ACCESS_KEY", "SECRET_KEY"), // Get your credentials at https://console.scaleway.com/project/credentials
)
if err != nil {
	// handle error
	log.Fatal(err)
}

// Create SDK objects for Scaleway LoadConfig Balancer product
lbAPI := lb.NewZonedAPI(client)

// Call the CreateLb method on the LB SDK to create a new load balancer.
newLB, err := lbAPI.CreateLB(&lb.ZonedAPICreateLBRequest{
	Name:        "My new load balancer",
	Description: "This is a example of a load balancer",
})
if err != nil {
	// handle error
	log.Fatal(err)
}

// Do something with the newly created LB...
fmt.Println(newLB)
Example (CreateServer)
// Create a Scaleway client
client, err := scw.NewClient(
	scw.WithAuth("ACCESS_KEY", "SECRET_KEY"), // Get your credentials at https://console.scaleway.com/project/credentials
	scw.WithDefaultOrganizationID("ORGANIZATION_ID"),
	scw.WithDefaultZone(scw.ZoneFrPar1),
)
if err != nil {
	panic(err)
}

// Create SDK objects for Scaleway Instance and marketplace
instanceAPI := instance.NewAPI(client)

serverType := "DEV1-S"
image := "ubuntu_focal"

// Create a new DEV1-S server
createRes, err := instanceAPI.CreateServer(&instance.CreateServerRequest{
	Name:              "my-server-01",
	CommercialType:    serverType,
	Image:             scw.StringPtr(image),
	DynamicIPRequired: scw.BoolPtr(true),
})
if err != nil {
	panic(err)
}

// Start the server and wait until it's ready.
timeout := 5 * time.Minute
err = instanceAPI.ServerActionAndWait(&instance.ServerActionAndWaitRequest{
	ServerID: createRes.Server.ID,
	Action:   instance.ServerActionPoweron,
	Timeout:  &timeout,
})
if err != nil {
	panic(err)
}
Example (ListServers)
// Create a Scaleway client
client, err := scw.NewClient(
	scw.WithAuth("ACCESS_KEY", "SECRET_KEY"), // Get your credentials at https://console.scaleway.com/project/credentials
)
if err != nil {
	// handle error
	log.Fatal(err)
}

// Create SDK objects for Scaleway Instance product
instanceAPI := instance.NewAPI(client)

// Call the ListServers method on the Instance SDK
response, err := instanceAPI.ListServers(&instance.ListServersRequest{
	Zone: scw.ZoneFrPar1,
})
if err != nil {
	// handle error
	log.Fatal(err)
}

// Do something with the response...
fmt.Println(response)
Example (ListServersWithZones)
// Create a Scaleway client
client, err := scw.NewClient(
	scw.WithAuth("ACCESS_KEY", "SECRET_KEY"), // Get your credentials at https://console.scaleway.com/project/credentials
)
if err != nil {
	// handle error
	log.Fatal(err)
}

// Create SDK objects for Scaleway Instance product
instanceAPI := instance.NewAPI(client)

// Call the ListServers method on the Instance SDK
response, err := instanceAPI.ListServers(&instance.ListServersRequest{},
	// Add WithZones option to list servers from multiple zones
	scw.WithZones(scw.ZoneFrPar1, scw.ZoneNlAms1, scw.ZonePlWaw1))
if err != nil {
	// handle error
	log.Fatal(err)
}

// Do something with the response...
fmt.Println(response)
Example (RebootAllServers)
// Create a Scaleway client
client, err := scw.NewClient(
	scw.WithAuth("ACCESS_KEY", "SECRET_KEY"), // Get your credentials at https://console.scaleway.com/project/credentials
	scw.WithDefaultZone(scw.ZoneFrPar1),
)
if err != nil {
	panic(err)
}

// Create SDK objects for Scaleway Instance product
instanceAPI := instance.NewAPI(client)

// Call the ListServers method of the Instance SDK
response, err := instanceAPI.ListServers(&instance.ListServersRequest{})
if err != nil {
	panic(err)
}

// For each server if they are running we reboot them using ServerActionAndWait
timeout := 5 * time.Minute
for _, server := range response.Servers {
	if server.State == instance.ServerStateRunning {
		fmt.Println("Rebooting server with ID", server.ID)
		err = instanceAPI.ServerActionAndWait(&instance.ServerActionAndWaitRequest{
			ServerID: server.ID,
			Action:   instance.ServerActionReboot,
			Timeout:  &timeout,
		})
		if err != nil {
			panic(err)
		}
	}
}
fmt.Println("All servers were successfully rebooted")

Directories

Path Synopsis
api
account/v3
Package account provides methods and message types of the account v3 API.
Package account provides methods and message types of the account v3 API.
annotations/v1
Package annotations provides methods and message types of the annotations v1 API.
Package annotations provides methods and message types of the annotations v1 API.
applesilicon/v1alpha1
Package applesilicon provides methods and message types of the applesilicon v1alpha1 API.
Package applesilicon provides methods and message types of the applesilicon v1alpha1 API.
audit_trail/v1alpha1
Package audit_trail provides methods and message types of the audit_trail v1alpha1 API.
Package audit_trail provides methods and message types of the audit_trail v1alpha1 API.
autoscaling/v1alpha1
Package autoscaling provides methods and message types of the autoscaling v1alpha1 API.
Package autoscaling provides methods and message types of the autoscaling v1alpha1 API.
autoscaling/v1alpha2
Package autoscaling provides methods and message types of the autoscaling v1alpha2 API.
Package autoscaling provides methods and message types of the autoscaling v1alpha2 API.
baremetal/v1
Package baremetal provides methods and message types of the baremetal v1 API.
Package baremetal provides methods and message types of the baremetal v1 API.
baremetal/v3
Package baremetal provides methods and message types of the baremetal v3 API.
Package baremetal provides methods and message types of the baremetal v3 API.
billing/v2
Package billing provides methods and message types of the billing v2 API.
Package billing provides methods and message types of the billing v2 API.
billing/v2beta1
Package billing provides methods and message types of the billing v2beta1 API.
Package billing provides methods and message types of the billing v2beta1 API.
block/v1
Package block provides methods and message types of the block v1 API.
Package block provides methods and message types of the block v1 API.
block/v1alpha1
Package block provides methods and message types of the block v1alpha1 API.
Package block provides methods and message types of the block v1alpha1 API.
cockpit/v1
Package cockpit provides methods and message types of the cockpit v1 API.
Package cockpit provides methods and message types of the cockpit v1 API.
container/v1
Package container provides methods and message types of the container v1 API.
Package container provides methods and message types of the container v1 API.
container/v1beta1
Package container provides methods and message types of the container v1beta1 API.
Package container provides methods and message types of the container v1beta1 API.
datalab/v1beta1
Package datalab provides methods and message types of the datalab v1beta1 API.
Package datalab provides methods and message types of the datalab v1beta1 API.
datawarehouse/v1beta1
Package datawarehouse provides methods and message types of the datawarehouse v1beta1 API.
Package datawarehouse provides methods and message types of the datawarehouse v1beta1 API.
dedibox/v1
Package dedibox provides methods and message types of the dedibox v1 API.
Package dedibox provides methods and message types of the dedibox v1 API.
documentdb/v1beta1
Package documentdb provides methods and message types of the documentdb v1beta1 API.
Package documentdb provides methods and message types of the documentdb v1beta1 API.
domain/v2beta1
Package domain provides methods and message types of the domain v2beta1 API.
Package domain provides methods and message types of the domain v2beta1 API.
edge_services/v1beta1
Package edge_services provides methods and message types of the edge_services v1beta1 API.
Package edge_services provides methods and message types of the edge_services v1beta1 API.
environmental_footprint/v1alpha1
Package environmental_footprint provides methods and message types of the environmental_footprint v1alpha1 API.
Package environmental_footprint provides methods and message types of the environmental_footprint v1alpha1 API.
file/v1alpha1
Package file provides methods and message types of the file v1alpha1 API.
Package file provides methods and message types of the file v1alpha1 API.
flexibleip/v1alpha1
Package flexibleip provides methods and message types of the flexibleip v1alpha1 API.
Package flexibleip provides methods and message types of the flexibleip v1alpha1 API.
function/v1beta1
Package function provides methods and message types of the function v1beta1 API.
Package function provides methods and message types of the function v1beta1 API.
iam/v1alpha1
Package iam provides methods and message types of the iam v1alpha1 API.
Package iam provides methods and message types of the iam v1alpha1 API.
inference/v1
Package inference provides methods and message types of the inference v1 API.
Package inference provides methods and message types of the inference v1 API.
instance/v1
Package instance provides methods and message types of the instance v1 API.
Package instance provides methods and message types of the instance v1 API.
instance/v2alpha1
Package instance provides methods and message types of the instance v2alpha1 API.
Package instance provides methods and message types of the instance v2alpha1 API.
interlink/v1beta1
Package interlink provides methods and message types of the interlink v1beta1 API.
Package interlink provides methods and message types of the interlink v1beta1 API.
iot/v1
Package iot provides methods and message types of the iot v1 API.
Package iot provides methods and message types of the iot v1 API.
ipam/v1
Package ipam provides methods and message types of the ipam v1 API.
Package ipam provides methods and message types of the ipam v1 API.
ipam/v1alpha1
Package ipam provides methods and message types of the ipam v1alpha1 API.
Package ipam provides methods and message types of the ipam v1alpha1 API.
jobs/v1alpha1
Package jobs provides methods and message types of the jobs v1alpha1 API.
Package jobs provides methods and message types of the jobs v1alpha1 API.
jobs/v1alpha2
Package jobs provides methods and message types of the jobs v1alpha2 API.
Package jobs provides methods and message types of the jobs v1alpha2 API.
k8s/v1
Package k8s provides methods and message types of the k8s v1 API.
Package k8s provides methods and message types of the k8s v1 API.
kafka/v1alpha1
Package kafka provides methods and message types of the kafka v1alpha1 API.
Package kafka provides methods and message types of the kafka v1alpha1 API.
key_manager/v1alpha1
Package key_manager provides methods and message types of the key_manager v1alpha1 API.
Package key_manager provides methods and message types of the key_manager v1alpha1 API.
lb/v1
Package lb provides methods and message types of the lb v1 API.
Package lb provides methods and message types of the lb v1 API.
mailbox/v1alpha1
Package mailbox provides methods and message types of the mailbox v1alpha1 API.
Package mailbox provides methods and message types of the mailbox v1alpha1 API.
marketplace/v2
Package marketplace provides methods and message types of the marketplace v2 API.
Package marketplace provides methods and message types of the marketplace v2 API.
messageq/v1alpha1
Package messageq provides methods and message types of the messageq v1alpha1 API.
Package messageq provides methods and message types of the messageq v1alpha1 API.
mnq/v1beta1
Package mnq provides methods and message types of the mnq v1beta1 API.
Package mnq provides methods and message types of the mnq v1beta1 API.
mongodb/v1
Package mongodb provides methods and message types of the mongodb v1 API.
Package mongodb provides methods and message types of the mongodb v1 API.
mongodb/v1alpha1
Package mongodb provides methods and message types of the mongodb v1alpha1 API.
Package mongodb provides methods and message types of the mongodb v1alpha1 API.
partner/v1
Package partner provides methods and message types of the partner v1 API.
Package partner provides methods and message types of the partner v1 API.
product_catalog/v2alpha1
Package product_catalog provides methods and message types of the product_catalog v2alpha1 API.
Package product_catalog provides methods and message types of the product_catalog v2alpha1 API.
qaas/v1alpha1
Package qaas provides methods and message types of the qaas v1alpha1 API.
Package qaas provides methods and message types of the qaas v1alpha1 API.
rdb/v1
Package rdb provides methods and message types of the rdb v1 API.
Package rdb provides methods and message types of the rdb v1 API.
redis/v1
Package redis provides methods and message types of the redis v1 API.
Package redis provides methods and message types of the redis v1 API.
registry/v1
Package registry provides methods and message types of the registry v1 API.
Package registry provides methods and message types of the registry v1 API.
s2s_vpn/v1alpha1
Package s2s_vpn provides methods and message types of the s2s_vpn v1alpha1 API.
Package s2s_vpn provides methods and message types of the s2s_vpn v1alpha1 API.
search/v1alpha1
Package search provides methods and message types of the search v1alpha1 API.
Package search provides methods and message types of the search v1alpha1 API.
searchdb/v1alpha1
Package searchdb provides methods and message types of the searchdb v1alpha1 API.
Package searchdb provides methods and message types of the searchdb v1alpha1 API.
secret/v1beta1
Package secret provides methods and message types of the secret v1beta1 API.
Package secret provides methods and message types of the secret v1beta1 API.
serverless_sqldb/v1alpha1
Package serverless_sqldb provides methods and message types of the serverless_sqldb v1alpha1 API.
Package serverless_sqldb provides methods and message types of the serverless_sqldb v1alpha1 API.
std
Package std provides methods and message types of the std API.
Package std provides methods and message types of the std API.
tem/v1alpha1
Package tem provides methods and message types of the tem v1alpha1 API.
Package tem provides methods and message types of the tem v1alpha1 API.
test/v1
Package test provides methods and message types of the test v1 API.
Package test provides methods and message types of the test v1 API.
vpc/v2
Package vpc provides methods and message types of the vpc v2 API.
Package vpc provides methods and message types of the vpc v2 API.
vpcgw/v1
Package vpcgw provides methods and message types of the vpcgw v1 API.
Package vpcgw provides methods and message types of the vpcgw v1 API.
vpcgw/v2
Package vpcgw provides methods and message types of the vpcgw v2 API.
Package vpcgw provides methods and message types of the vpcgw v2 API.
webhosting/v1
Package webhosting provides methods and message types of the webhosting v1 API.
Package webhosting provides methods and message types of the webhosting v1 API.
cmd
sdk-sweeper command
internal
Package validation provides format validation functions.
Package validation provides format validation functions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL