|
| 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 | +} |
0 commit comments