Skip to content

Commit b05b779

Browse files
author
Yago Carlos Fernandez Gou
committed
Include example using Intake SDK
1 parent 0c18d79 commit b05b779

File tree

4 files changed

+218
-1
lines changed

4 files changed

+218
-1
lines changed

examples/intake/go.mod

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
module github.com/stackitcloud/stackit-sdk-go/examples/intake
2+
3+
go 1.24.7
4+
5+
require (
6+
al.essio.dev/pkg/shellescape v1.5.1 // indirect
7+
github.com/danieljoos/wincred v1.2.2 // indirect
8+
github.com/fatih/color v1.18.0 // indirect
9+
github.com/fsnotify/fsnotify v1.9.0 // indirect
10+
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
11+
github.com/godbus/dbus/v5 v5.1.0 // indirect
12+
github.com/golang-jwt/jwt/v5 v5.3.0 // indirect
13+
github.com/google/uuid v1.6.0 // indirect
14+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
15+
github.com/inhies/go-bytesize v0.0.0-20220417184213-4913239db9cf // indirect
16+
github.com/lmittmann/tint v1.1.2 // indirect
17+
github.com/mattn/go-colorable v0.1.14 // indirect
18+
github.com/mattn/go-isatty v0.0.20 // indirect
19+
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
20+
github.com/sagikazarmark/locafero v0.11.0 // indirect
21+
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
22+
github.com/spf13/afero v1.15.0 // indirect
23+
github.com/spf13/cast v1.10.0 // indirect
24+
github.com/spf13/cobra v1.10.1 // indirect
25+
github.com/spf13/pflag v1.0.10 // indirect
26+
github.com/spf13/viper v1.21.0 // indirect
27+
github.com/stackitcloud/stackit-cli v0.44.1 // indirect
28+
github.com/stackitcloud/stackit-sdk-go/core v0.17.3 // indirect
29+
github.com/stackitcloud/stackit-sdk-go/services/iaas v0.31.0 // indirect
30+
github.com/stackitcloud/stackit-sdk-go/services/intake v0.2.0 // indirect
31+
github.com/subosito/gotenv v1.6.0 // indirect
32+
github.com/zalando/go-keyring v0.2.6 // indirect
33+
go.yaml.in/yaml/v3 v3.0.4 // indirect
34+
golang.org/x/oauth2 v0.32.0 // indirect
35+
golang.org/x/sys v0.37.0 // indirect
36+
golang.org/x/term v0.36.0 // indirect
37+
golang.org/x/text v0.30.0 // indirect
38+
)

examples/intake/go.sum

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
al.essio.dev/pkg/shellescape v1.5.1 h1:86HrALUujYS/h+GtqoB26SBEdkWfmMI6FubjXlsXyho=
2+
al.essio.dev/pkg/shellescape v1.5.1/go.mod h1:6sIqp7X2P6mThCQ7twERpZTuigpr6KbZWtls1U8I890=
3+
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
4+
github.com/danieljoos/wincred v1.2.2 h1:774zMFJrqaeYCK2W57BgAem/MLi6mtSE47MB6BOJ0i0=
5+
github.com/danieljoos/wincred v1.2.2/go.mod h1:w7w4Utbrz8lqeMbDAK0lkNJUv5sAOkFi7nd/ogr0Uh8=
6+
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
7+
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
8+
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
9+
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
10+
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
11+
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
12+
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
13+
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
14+
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
15+
github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
16+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
17+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
18+
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
19+
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
20+
github.com/inhies/go-bytesize v0.0.0-20220417184213-4913239db9cf h1:FtEj8sfIcaaBfAKrE1Cwb61YDtYq9JxChK1c7AKce7s=
21+
github.com/inhies/go-bytesize v0.0.0-20220417184213-4913239db9cf/go.mod h1:yrqSXGoD/4EKfF26AOGzscPOgTTJcyAwM2rpixWT+t4=
22+
github.com/lmittmann/tint v1.1.2 h1:2CQzrL6rslrsyjqLDwD11bZ5OpLBPU+g3G/r5LSfS8w=
23+
github.com/lmittmann/tint v1.1.2/go.mod h1:HIS3gSy7qNwGCj+5oRjAutErFBl4BzdQP6cJZ0NfMwE=
24+
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
25+
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
26+
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
27+
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
28+
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
29+
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
30+
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
31+
github.com/sagikazarmark/locafero v0.11.0 h1:1iurJgmM9G3PA/I+wWYIOw/5SyBtxapeHDcg+AAIFXc=
32+
github.com/sagikazarmark/locafero v0.11.0/go.mod h1:nVIGvgyzw595SUSUE6tvCp3YYTeHs15MvlmU87WwIik=
33+
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 h1:+jumHNA0Wrelhe64i8F6HNlS8pkoyMv5sreGx2Ry5Rw=
34+
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8/go.mod h1:3n1Cwaq1E1/1lhQhtRK2ts/ZwZEhjcQeJQ1RuC6Q/8U=
35+
github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I=
36+
github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg=
37+
github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY=
38+
github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
39+
github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s=
40+
github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0=
41+
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
42+
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
43+
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
44+
github.com/spf13/viper v1.21.0 h1:x5S+0EU27Lbphp4UKm1C+1oQO+rKx36vfCoaVebLFSU=
45+
github.com/spf13/viper v1.21.0/go.mod h1:P0lhsswPGWD/1lZJ9ny3fYnVqxiegrlNrEmgLjbTCAY=
46+
github.com/stackitcloud/stackit-cli v0.44.1 h1:3KiOEKt4OKMwpquB75zz52e5FjPLIvdKnmuHHvjwoVg=
47+
github.com/stackitcloud/stackit-cli v0.44.1/go.mod h1:gU4khJV8vRH51xUpknMLnvBbN7YlwiRVWv3OWUHHE9E=
48+
github.com/stackitcloud/stackit-sdk-go/core v0.17.3 h1:GsZGmRRc/3GJLmCUnsZswirr5wfLRrwavbnL/renOqg=
49+
github.com/stackitcloud/stackit-sdk-go/core v0.17.3/go.mod h1:HBCXJGPgdRulplDzhrmwC+Dak9B/x0nzNtmOpu+1Ahg=
50+
github.com/stackitcloud/stackit-sdk-go/services/iaas v0.31.0 h1:dnEjyapuv8WwRN5vE2z6+4/+ZqQTBx+bX27x2nOF7Jw=
51+
github.com/stackitcloud/stackit-sdk-go/services/iaas v0.31.0/go.mod h1:854gnLR92NvAbJAA1xZEumrtNh1DoBP1FXTMvhwYA6w=
52+
github.com/stackitcloud/stackit-sdk-go/services/intake v0.2.0 h1:p/zi4VPoCQWk7/2ubi3hxsqiaye41x/Pl3GXYbPkYOY=
53+
github.com/stackitcloud/stackit-sdk-go/services/intake v0.2.0/go.mod h1:jOArPjNRkwv4487+9ab3dRG+lM09leu5FiRohbQs9Z4=
54+
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
55+
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
56+
github.com/zalando/go-keyring v0.2.6 h1:r7Yc3+H+Ux0+M72zacZoItR3UDxeWfKTcabvkI8ua9s=
57+
github.com/zalando/go-keyring v0.2.6/go.mod h1:2TCrxYrbUNYfNS/Kgy/LSrkSQzZ5UPVH85RwfczwvcI=
58+
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
59+
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
60+
golang.org/x/oauth2 v0.32.0 h1:jsCblLleRMDrxMN29H3z/k1KliIvpLgCkE6R8FXXNgY=
61+
golang.org/x/oauth2 v0.32.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
62+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
63+
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
64+
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
65+
golang.org/x/term v0.36.0 h1:zMPR+aF8gfksFprF/Nc/rd1wRS1EI6nDBGyWAvDzx2Q=
66+
golang.org/x/term v0.36.0/go.mod h1:Qu394IJq6V6dCBRgwqshf3mPF85AqzYEzofzRdZkWss=
67+
golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k=
68+
golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM=
69+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
70+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

examples/intake/intake.go

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"os"
7+
8+
sdkConfig "github.com/stackitcloud/stackit-sdk-go/core/config"
9+
"github.com/stackitcloud/stackit-sdk-go/core/utils"
10+
"github.com/stackitcloud/stackit-sdk-go/services/intake"
11+
"github.com/stackitcloud/stackit-sdk-go/services/intake/wait"
12+
)
13+
14+
func main() {
15+
region := "REGION" // Region where the resources will be created
16+
projectId := "PROJECT_ID" // Your STACKIT project ID
17+
18+
dremioCatalogURI := "DREMIO_CATALOG_URI" // E.g., "https://my-dremio-catalog.data-platform.stackit.run/iceberg"
19+
dremioTokenEndpoint := "DREMIO_TOKEN_ENDPOINT" // E.g., "https://my-dremio.data-platform.stackit.run/oauth/token"
20+
dremioPAT := "DREMIO_PERSONAL_ACCESS_TOKEN" // Your Dremio Personal Access Token
21+
catalogWarehouse := "CATALOG_WAREHOUSE" // Catalog warehouse where the data will be ingested
22+
23+
intakeUserPassword := "s3cuRe_p@ssW0rd_f0r_1ntake!" // A secure password for the new intake user
24+
25+
ctx := context.Background()
26+
27+
intakeClient, err := intake.NewAPIClient(
28+
sdkConfig.WithRegion(region),
29+
)
30+
if err != nil {
31+
fmt.Fprintf(os.Stderr, "Creating API client: %v\n", err)
32+
os.Exit(1)
33+
}
34+
35+
// Create an Intake Runner
36+
createRunnerPayload := intake.CreateIntakeRunnerPayload{
37+
DisplayName: utils.Ptr("my-example-runner"),
38+
MaxMessageSizeKiB: utils.Ptr(int64(10)),
39+
MaxMessagesPerHour: utils.Ptr(int64(1000)),
40+
}
41+
createRunnerResp, err := intakeClient.CreateIntakeRunner(ctx, projectId, region).CreateIntakeRunnerPayload(createRunnerPayload).Execute()
42+
if err != nil {
43+
fmt.Fprintf(os.Stderr, "Error creating Intake Runner: %v\n", err)
44+
os.Exit(1)
45+
}
46+
intakeRunnerId := *createRunnerResp.Id
47+
fmt.Printf("Triggered creation of Intake Runner with ID: %s. Waiting for it to become active...\n", intakeRunnerId)
48+
49+
// Wait for the Intake Runner to become active
50+
_, err = wait.CreateOrUpdateIntakeRunnerWaitHandler(ctx, intakeClient, projectId, region, intakeRunnerId).WaitWithContext(ctx)
51+
if err != nil {
52+
fmt.Fprintf(os.Stderr, "Error waiting for Intake Runner: %v\n", err)
53+
os.Exit(1)
54+
}
55+
56+
// Create an Intake
57+
dremioAuthType := intake.CatalogAuthType("dremio") // can also be set to "none" if the catalog is not authenticated
58+
createIntakePayload := intake.CreateIntakePayload{
59+
DisplayName: utils.Ptr("my-example-intake"),
60+
IntakeRunnerId: utils.Ptr(intakeRunnerId),
61+
Catalog: &intake.IntakeCatalog{
62+
Uri: utils.Ptr(dremioCatalogURI),
63+
Warehouse: utils.Ptr(catalogWarehouse),
64+
Namespace: utils.Ptr("example_namespace"),
65+
TableName: utils.Ptr("example_table"),
66+
Auth: &intake.CatalogAuth{
67+
Type: &dremioAuthType,
68+
Dremio: &intake.DremioAuth{
69+
TokenEndpoint: utils.Ptr(dremioTokenEndpoint),
70+
PersonalAccessToken: utils.Ptr(dremioPAT),
71+
},
72+
},
73+
},
74+
}
75+
createIntakeResp, err := intakeClient.CreateIntake(ctx, projectId, region).CreateIntakePayload(createIntakePayload).Execute()
76+
if err != nil {
77+
fmt.Fprintf(os.Stderr, "Error creating Intake: %v\n", err)
78+
os.Exit(1)
79+
}
80+
intakeId := *createIntakeResp.Id
81+
fmt.Printf("Triggered creation of Intake with ID: %s. Waiting for it to become active...\n", intakeRunnerId)
82+
83+
// Wait for the Intake to become active
84+
_, err = wait.CreateOrUpdateIntakeWaitHandler(ctx, intakeClient, projectId, region, intakeId).WaitWithContext(ctx)
85+
if err != nil {
86+
fmt.Fprintf(os.Stderr, "Error waiting for Intake: %v\n", err)
87+
os.Exit(1)
88+
}
89+
90+
createIntakeUserPayload := intake.CreateIntakeUserPayload{
91+
DisplayName: utils.Ptr("my-example-user"),
92+
Password: utils.Ptr(intakeUserPassword),
93+
}
94+
createIntakeUserResp, err := intakeClient.CreateIntakeUser(ctx, projectId, region, intakeId).CreateIntakeUserPayload(createIntakeUserPayload).Execute()
95+
if err != nil {
96+
fmt.Fprintf(os.Stderr, "Error creating Intake User: %v\n", err)
97+
os.Exit(1)
98+
}
99+
intakeUserId := *createIntakeUserResp.Id
100+
fmt.Printf("Triggered creation of Intake User with ID: %s. Waiting for it to become active...\n", intakeRunnerId)
101+
102+
// Wait for the Intake User to become active
103+
_, err = wait.CreateOrUpdateIntakeUserWaitHandler(ctx, intakeClient, projectId, region, intakeId, intakeUserId).WaitWithContext(ctx)
104+
if err != nil {
105+
fmt.Fprintf(os.Stderr, "Error waiting for Intake User: %v\n", err)
106+
os.Exit(1)
107+
}
108+
}

go.work

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
go 1.21
1+
go 1.24.7
22

33
use (
44
./core
@@ -10,6 +10,7 @@ use (
1010
./examples/dns
1111
./examples/errorhandling
1212
./examples/iaas
13+
./examples/intake
1314
./examples/kms
1415
./examples/loadbalancer
1516
./examples/logme

0 commit comments

Comments
 (0)