To use the SDK, you must first create a
project token. You can also use a PAT (personal
access token), however this is not recommended as it has access to all of your
projects.
GO
Copy
Ask AI
import ( "context" "fmt" hop "go.hop.io/sdk" // types is a package that contains all of the types used by the Hop API // and other utility helper functions t "go.hop.io/sdk/types")const HopToken = "ptk_xxx"func main() { c, err := hop.NewClient(HopToken) if err != nil { // Handle your error here! panic(err) } // Example: Creating a deployment deployment, err := c.Ignite.Deployments.Create(context.Background(), &t.DeploymentConfig{ Name: "postgres", DeploymentConfigPartial: t.DeploymentConfigPartial{ Type: t.RuntimeTypePersistent, RestartPolicy: t.RestartPolicyAlways, ContainerStrategy: t.ContainerStrategyManual, Image: t.Image{ Name: "postgres", }, Resources: t.Resources{ VCPU: 0.5, // Use the t.Megabytes helper function to convert // megabytes to a string RAM: t.Megabytes(128), }, Env: map[string]string{ "POSTGRES_PASSWORD": "mysecretpassword", "POSTGRES_USER": "postgres", "POSTGRES_DB": "postgres", }, }, }) if err != nil { panic(err) } fmt.Println(deployment)}