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
Output:
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
Output:
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)
Output:
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: 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) }
Output:
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)
Output:
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)
Output:
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")
Output:
Directories ¶
Path | Synopsis |
---|---|
api
|
|
account/v2
Package account provides methods and message types of the account v2 API.
|
Package account provides methods and message types of the account v2 API. |
account/v2alpha1
Package account provides methods and message types of the account v2alpha1 API.
|
Package account provides methods and message types of the account v2alpha1 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. |
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. |
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. |
billing/v2alpha1
Package billing provides methods and message types of the billing v2alpha1 API.
|
Package billing provides methods and message types of the billing v2alpha1 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/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. |
cockpit/v1beta1
Package cockpit provides methods and message types of the cockpit v1beta1 API.
|
Package cockpit provides methods and message types of the cockpit v1beta1 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. |
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/v1alpha1
Package edge_services provides methods and message types of the edge_services v1alpha1 API.
|
Package edge_services provides methods and message types of the edge_services 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/v1beta1
Package inference provides methods and message types of the inference v1beta1 API.
|
Package inference provides methods and message types of the inference v1beta1 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. |
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. |
ipfs/v1alpha1
Package ipfs provides methods and message types of the ipfs v1alpha1 API.
|
Package ipfs provides methods and message types of the ipfs 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. |
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. |
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. |
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. |
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. |
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. |
secret/v1alpha1
Package secret provides methods and message types of the secret v1alpha1 API.
|
Package secret provides methods and message types of the secret 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/v1
Package vpc provides methods and message types of the vpc v1 API.
|
Package vpc provides methods and message types of the vpc 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. |
webhosting/v1alpha1
Package webhosting provides methods and message types of the webhosting v1alpha1 API.
|
Package webhosting provides methods and message types of the webhosting v1alpha1 API. |
internal
|
|
Package validation provides format validation functions.
|
Package validation provides format validation functions. |
Click to show internal directories.
Click to hide internal directories.