Skip to content

Commit 7120e6c

Browse files
author
Bjarne Schröder
committed
Dremio: Adding SDK example.
1 parent c923a75 commit 7120e6c

4 files changed

Lines changed: 78 additions & 0 deletions

File tree

examples/dremio/dremio.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"os"
7+
8+
"github.com/stackitcloud/stackit-sdk-go/core/utils"
9+
dremio "github.com/stackitcloud/stackit-sdk-go/services/dremio/v1alphaapi"
10+
)
11+
12+
func main() {
13+
region := "eu01" // Region where the resources will be created
14+
projectId := "PROJECT_ID" // Your STACKIT project ID
15+
16+
ctx := context.Background()
17+
18+
dremioClient, err := dremio.NewAPIClient()
19+
if err != nil {
20+
fmt.Fprintf(os.Stderr, "[Dremio] Creating API client: %v\n", err)
21+
os.Exit(1)
22+
}
23+
24+
// Creating a Dremio instance
25+
createDremioInstancePayload := dremio.CreateDremioInstancePayload{
26+
DisplayName: "myExampleDremioInstance",
27+
Description: utils.Ptr("This is a Dremio instance."),
28+
}
29+
createDremioInstanceResponse, err := dremioClient.DefaultAPI.CreateDremioInstance(ctx, projectId, region).CreateDremioInstancePayload(createDremioInstancePayload).Execute()
30+
if err != nil {
31+
fmt.Fprintf(os.Stderr, "[Dremio] Error when creating Dremio instance: %v\n", err)
32+
os.Exit(1)
33+
}
34+
dremioId := createDremioInstanceResponse.Id
35+
fmt.Printf("[Dremio] Triggered creation of Dremio with ID: %s. Waiting for it to become active... \n", dremioId)
36+
37+
// Creating a Dremio user
38+
createDremioUserPayload := dremio.CreateDremioUserPayload{
39+
Description: utils.Ptr("This is a new user."),
40+
Email: "newuser@some.domain",
41+
FirstName: "New",
42+
LastName: "User",
43+
Name: "newUser",
44+
Password: "aV3ryS4feP4ssw0rd6",
45+
}
46+
createDremioUserResponse, err := dremioClient.DefaultAPI.CreateDremioUser(ctx, projectId, region, dremioId).CreateDremioUserPayload(createDremioUserPayload).Execute()
47+
if err != nil {
48+
fmt.Fprintf(os.Stderr, "[Dremio] Error when creating Dremio user: %v\n", err)
49+
os.Exit(1)
50+
}
51+
dremioUserId := createDremioUserResponse.Id
52+
fmt.Printf("[Dremio] Created Dremio User with ID: %s\n", dremioUserId)
53+
}

examples/dremio/go.mod

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module github.com/stackitcloud/stackit-sdk-go/examples/dremio
2+
3+
go 1.25
4+
5+
// 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.
6+
replace github.com/stackitcloud/stackit-sdk-go/services/dremio => ../../services/dremio
7+
8+
require (
9+
github.com/stackitcloud/stackit-sdk-go/core v0.26.0
10+
github.com/stackitcloud/stackit-sdk-go/services/dremio v0.0.0-00010101000000-000000000000
11+
)
12+
13+
require (
14+
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
15+
github.com/google/uuid v1.6.0 // indirect
16+
)

examples/dremio/go.sum

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY=
2+
github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
3+
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
4+
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
5+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
6+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
7+
github.com/stackitcloud/stackit-sdk-go/core v0.26.0 h1:jQEb9gkehfp6VCP6TcYk7BI10cz4l0KM2L6hqYBH2QA=
8+
github.com/stackitcloud/stackit-sdk-go/core v0.26.0/go.mod h1:WU1hhxnjXw2EV7CYa1nlEvNpMiRY6CvmIOaHuL3pOaA=

go.work

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use (
99
./examples/configuration
1010
./examples/cost
1111
./examples/dns
12+
./examples/dremio
1213
./examples/edge
1314
./examples/errorhandling
1415
./examples/iaas

0 commit comments

Comments
 (0)