Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,10 @@
- **Improvement:** Add description that `RoutingType` can only be set at the creation
- `v1beta1api`: Align package to latest API specification
- `v1alpha1api`: Align package to latest API specification
- `workflows`:
- [v0.1.0](services/workflows/CHANGELOG.md#v010)
- **New**: API for STACKIT Workflows
- [Usage example](https://github.com/stackitcloud/stackit-sdk-go/tree/main/examples/workflows)

## Release (2026-04-07)
- `alb`: [v0.13.1](services/alb/CHANGELOG.md#v0131)
Expand Down
16 changes: 16 additions & 0 deletions examples/workflows/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module github.com/stackitcloud/stackit-sdk-go/examples/workflows

go 1.25

// This is not needed in production. This is only here to point the golangci linter to the local version instead of the last release on GitHub.
replace github.com/stackitcloud/stackit-sdk-go/services/workflows => ../../services/workflows

require (
github.com/stackitcloud/stackit-sdk-go/core v0.26.0
github.com/stackitcloud/stackit-sdk-go/services/workflows v0.0.0-00010101000000-000000000000
)

require (
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
github.com/google/uuid v1.6.0 // indirect
)
8 changes: 8 additions & 0 deletions examples/workflows/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY=
github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/stackitcloud/stackit-sdk-go/core v0.26.0 h1:jQEb9gkehfp6VCP6TcYk7BI10cz4l0KM2L6hqYBH2QA=
github.com/stackitcloud/stackit-sdk-go/core v0.26.0/go.mod h1:WU1hhxnjXw2EV7CYa1nlEvNpMiRY6CvmIOaHuL3pOaA=
Binary file added examples/workflows/workflows
Binary file not shown.
146 changes: 146 additions & 0 deletions examples/workflows/workflows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
package main

import (
"context"
"fmt"
"os"

"github.com/stackitcloud/stackit-sdk-go/core/utils"
workflows "github.com/stackitcloud/stackit-sdk-go/services/workflows/v1alphaapi"
"github.com/stackitcloud/stackit-sdk-go/services/workflows/v1alphaapi/wait"
)

func main() {
// Region is a path parameter on every workflows endpoint, not a client setting.
region := "eu01"

// Your STACKIT project ID
projectId := "PROJECT_ID"

// A version string from `GetProviderOptions` below. Airflow 3 is recommended:
// it allows describing DAG sources via the dagBundles field. Airflow 2 instances
// must supply a dagsRepository instead. See [provider options] in the API docs.
version := "workflows-3.0-airflow-3.1"

// Git DAG bundle config — at least one DAG bundle is required so the Airflow
// cluster has something to schedule. Use NoAuth instead of BasicAuth for public repos.
dagsGitUrl := "https://example.com/my-org/my-dags-repo.git"
dagsGitBranch := "main"
dagsGitUser := "git-user"
dagsGitToken := "git-personal-access-token"

// OAuth2 IdP — the STACKIT IdP variant is not yet supported by the API, so
// every Workflows instance currently needs a custom OAuth2 IdP configured.
idpName := "azure"
idpClientId := "00000000-0000-0000-0000-000000000000"
idpClientSecret := "client-secret"
idpScope := "openid email"
idpDiscoveryUrl := "https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/.well-known/openid-configuration"

ctx := context.Background()

workflowsClient, err := workflows.NewAPIClient()
if err != nil {
fmt.Fprintf(os.Stderr, "[Workflows] Creating API client: %v\n", err)
os.Exit(1)
}

// Listing available provider options (versions, machine types, ...)
optionsResp, err := workflowsClient.DefaultAPI.GetProviderOptions(ctx, region).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "[Workflows] Error when listing provider options: %v\n", err)
os.Exit(1)
}
fmt.Println("[Workflows] Available versions:")
for _, v := range optionsResp.Versions {
fmt.Printf(" %s (%s)\n", v.Version, v.State)
}

// Build the OAuth2 identity provider block
idp := workflows.NewOAuth2IdentityProvider(
idpClientId,
idpClientSecret,
idpDiscoveryUrl,
idpName,
idpScope,
workflows.OAUTH2IDENTITYPROVIDERTYPE_OAUTH2,
)

// Build a Git-backed DAG bundle with HTTP basic auth
gitAuth := workflows.NewBasicAuth()
gitAuth.Type = utils.Ptr("basic")
gitAuth.Username = utils.Ptr(dagsGitUser)
gitAuth.Password = utils.Ptr(dagsGitToken)

bundle := workflows.NewGitDagBundle(
workflows.BasicAuthAsGitAuth(gitAuth),
dagsGitBranch,
"dags",
workflows.GITDAGBUNDLETYPE_GIT,
dagsGitUrl,
)

// Creating a Workflows instance
createPayload := workflows.CreateInstancePayload{
DisplayName: "myExampleWorkflowsInstance",
Description: utils.Ptr("This is a Workflows instance."),
Version: version,
IdentityProvider: utils.Ptr(workflows.OAuth2IdentityProviderAsIdentityProvider(idp)),
DagBundles: []workflows.DagBundle{workflows.GitDagBundleAsDagBundle(bundle)},
}
createResp, err := workflowsClient.DefaultAPI.CreateInstance(ctx, projectId, region).CreateInstancePayload(createPayload).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "[Workflows] Error when creating instance: %v\n", err)
os.Exit(1)
}
instanceId := createResp.Id
fmt.Printf("[Workflows] Triggered creation of instance with ID: %s. Waiting for it to become active...\n", instanceId)

instance, err := wait.CreateInstanceWaitHandler(ctx, workflowsClient.DefaultAPI, projectId, region, instanceId).WaitWithContext(ctx)
if err != nil {
fmt.Fprintf(os.Stderr, "[Workflows] Error when waiting for creation: %v\n", err)
os.Exit(1)
}
fmt.Printf("[Workflows] Instance %s is active. Airflow UI: %s\n", instanceId, instance.Endpoints.Url)

// Listing instances in the project
listResp, err := workflowsClient.DefaultAPI.ListInstances(ctx, projectId, region).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "[Workflows] Error when listing instances: %v\n", err)
os.Exit(1)
}
fmt.Println("[Workflows] Instances:")
for _, item := range listResp.Instances {
fmt.Printf(" %s - %s (%s)\n", item.Id, item.DisplayName, item.Status)
}

// Updating the instance description
_, err = workflowsClient.DefaultAPI.UpdateInstance(ctx, projectId, region, instanceId).UpdateInstancePayload(workflows.UpdateInstancePayload{
Description: utils.Ptr("Updated description."),
}).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "[Workflows] Error when updating instance: %v\n", err)
os.Exit(1)
}
_, err = wait.UpdateInstanceWaitHandler(ctx, workflowsClient.DefaultAPI, projectId, region, instanceId).WaitWithContext(ctx)
if err != nil {
fmt.Fprintf(os.Stderr, "[Workflows] Error when waiting for update: %v\n", err)
os.Exit(1)
}
fmt.Printf("[Workflows] Instance %s updated.\n", instanceId)

// Deleting the instance
err = workflowsClient.DefaultAPI.DeleteInstance(ctx, projectId, region, instanceId).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "[Workflows] Error when deleting instance: %v\n", err)
os.Exit(1)
}
fmt.Printf("[Workflows] Triggered deletion of instance %s. Waiting...\n", instanceId)

_, err = wait.DeleteInstanceWaitHandler(ctx, workflowsClient.DefaultAPI, projectId, region, instanceId).WaitWithContext(ctx)
if err != nil {
fmt.Fprintf(os.Stderr, "[Workflows] Error when waiting for deletion: %v\n", err)
os.Exit(1)
}
fmt.Printf("[Workflows] Instance %s deleted.\n", instanceId)
}
2 changes: 2 additions & 0 deletions go.work
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use (
./examples/telemetryrouter
./examples/vpn
./examples/waiter
./examples/workflows
./services/alb
./services/albwaf
./services/archiving
Expand Down Expand Up @@ -83,4 +84,5 @@ use (
./services/telemetrylink
./services/telemetryrouter
./services/vpn
./services/workflows
)
3 changes: 3 additions & 0 deletions services/workflows/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## v0.1.0
- **New**: API for STACKIT Workflows
- [Usage example](https://github.com/stackitcloud/stackit-sdk-go/tree/main/examples/workflows)
Loading