Skip to content

Commit 401fa8f

Browse files
bjarneschroederBjarne SchröderGokceGK
authored
feat(dremio): Adding wait handlers for new v1betaapi (copied from v1alpha) (#9972)
* feat(dremio): Adding wait handlers to v1betaapi Copying over the wait handlers from v1alphaapi to make waiting for provisioning of dremio resources possible. --------- Co-authored-by: Bjarne Schröder <bjarne.schroeder@stackit.cloud> Co-authored-by: Gökce Gök Klingel <161626272+GokceGK@users.noreply.github.com>
1 parent 8ae2e7e commit 401fa8f

6 files changed

Lines changed: 639 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
- `v1api`:
6767
- **Breaking Change:** `Value` field of `Label`/`CreateLabelPayload` changed from `string` to `*string` and is no longer required. `NewLabel`/`NewCreateLabelPayload` drop the `value` param
6868
- `dremio`:
69+
- [v0.6.0](services/dremio/CHANGELOG.md#v060)
70+
- `v1betaapi`:
71+
- **Feature:** Added wait handlers
6972
- [v0.5.1](services/dremio/CHANGELOG.md#v051)
7073
- `v1alphaapi`:
7174
- **Fix:** Response decoding now supports `*io.Reader` and `*[]byte` target types (previously only `string`, `*os.File`, and JSON were supported)

examples/dremio/dremio.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77

88
"github.com/stackitcloud/stackit-sdk-go/core/config"
99
"github.com/stackitcloud/stackit-sdk-go/core/utils"
10-
dremio "github.com/stackitcloud/stackit-sdk-go/services/dremio/v1alphaapi"
11-
"github.com/stackitcloud/stackit-sdk-go/services/dremio/v1alphaapi/wait"
10+
dremio "github.com/stackitcloud/stackit-sdk-go/services/dremio/v1betaapi"
11+
"github.com/stackitcloud/stackit-sdk-go/services/dremio/v1betaapi/wait"
1212
)
1313

1414
func main() {

services/dremio/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v0.6.0
2+
-`v1betaapi`:
3+
- **Feature**: Added wait handlers
4+
15
## v0.5.1
26
- `v1alphaapi`:
37
- **Fix:** Response decoding now supports `*io.Reader` and `*[]byte` target types (previously only `string`, `*os.File`, and JSON were supported)
@@ -20,4 +24,4 @@
2024

2125
- Manage your STACKIT Dremio resources: `DremioInstance`, `DremioUser`
2226
- Waiters for async operations: `CreateDremioInstanceWaitHandler`, `UpdateDremioInstanceWaitHandler`, `DeleteDremioInstanceWaitHandler`, `CreateDremioUserWaitHandler`, `UpdateDremioUserWaitHandler`, `DeleteDremioUserWaitHandler`
23-
- [Usage example](https://github.com/stackitcloud/stackit-sdk-go/tree/main/examples/dremio)
27+
- [Usage example](https://github.com/stackitcloud/stackit-sdk-go/tree/main/examples/dremio)

services/dremio/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.5.1
1+
v0.6.0
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
package wait
2+
3+
import (
4+
"context"
5+
"errors"
6+
"net/http"
7+
"time"
8+
9+
"github.com/stackitcloud/stackit-sdk-go/core/wait"
10+
dremio "github.com/stackitcloud/stackit-sdk-go/services/dremio/v1betaapi"
11+
)
12+
13+
const (
14+
// Deprecated: symbol is not used anymore, use the packages enum instead, will be removed 2026-12, use `go fix` for automatic fixing
15+
//go:fix inline
16+
DREMIOSTATE_ACTIVE = dremio.DREMIORESPONSESTATE_ACTIVE
17+
// Deprecated: symbol is not used anymore, use the packages enum instead, will be removed 2026-12, use `go fix` for automatic fixing
18+
//go:fix inline
19+
DREMIOSTATE_ERROR = dremio.DREMIORESPONSESTATE_ERROR
20+
21+
// Deprecated: symbol is not used anymore, use the packages enum instead, will be removed 2026-12, use `go fix` for automatic fixing
22+
//go:fix inline
23+
DREMIOUSERSTATE_ACTIVE = dremio.DREMIOUSERRESPONSESTATE_ACTIVE
24+
// Deprecated: symbol is not used anymore, use the packages enum instead, will be removed 2026-12, use `go fix` for automatic fixing
25+
//go:fix inline
26+
DREMIOUSERSTATE_ERROR = dremio.DREMIOUSERRESPONSESTATE_ERROR
27+
)
28+
29+
// CreateDremioWaitHandler will wait for the creation of a Dremio instance
30+
func CreateDremioWaitHandler(ctx context.Context, a dremio.DefaultAPI, projectId, regionId, dremioId string) *wait.AsyncActionHandler[dremio.DremioResponse] {
31+
waitConfig := wait.WaiterHelper[dremio.DremioResponse, dremio.DremioResponseState]{
32+
FetchInstance: a.GetDremioInstance(ctx, projectId, regionId, dremioId).Execute,
33+
GetState: func(dremioResp *dremio.DremioResponse) (dremio.DremioResponseState, error) {
34+
if dremioResp == nil {
35+
return "", errors.New("empty response")
36+
}
37+
return dremioResp.State, nil
38+
},
39+
ActiveState: []dremio.DremioResponseState{dremio.DREMIORESPONSESTATE_ACTIVE},
40+
ErrorState: []dremio.DremioResponseState{dremio.DREMIORESPONSESTATE_ERROR},
41+
}
42+
43+
handler := wait.New(waitConfig.Wait())
44+
handler.SetTimeout(30 * time.Minute)
45+
return handler
46+
}
47+
48+
// UpdateDremioWaitHandler will wait an update of a Dremio instance
49+
func UpdateDremioWaitHandler(ctx context.Context, a dremio.DefaultAPI, projectId, regionId, dremioId string) *wait.AsyncActionHandler[dremio.DremioResponse] {
50+
waitConfig := wait.WaiterHelper[dremio.DremioResponse, dremio.DremioResponseState]{
51+
FetchInstance: a.GetDremioInstance(ctx, projectId, regionId, dremioId).Execute,
52+
GetState: func(dremioResp *dremio.DremioResponse) (dremio.DremioResponseState, error) {
53+
if dremioResp == nil {
54+
return "", errors.New("empty response")
55+
}
56+
return dremioResp.State, nil
57+
},
58+
ActiveState: []dremio.DremioResponseState{dremio.DREMIORESPONSESTATE_ACTIVE},
59+
ErrorState: []dremio.DremioResponseState{dremio.DREMIORESPONSESTATE_ERROR},
60+
}
61+
62+
handler := wait.New(waitConfig.Wait())
63+
handler.SetTimeout(30 * time.Minute)
64+
return handler
65+
}
66+
67+
// DeleteDremioWaitHandler will wait for the deletion of a Dremio instance
68+
func DeleteDremioWaitHandler(ctx context.Context, a dremio.DefaultAPI, projectId, regionId, dremioId string) *wait.AsyncActionHandler[dremio.DremioResponse] {
69+
waitConfig := wait.WaiterHelper[dremio.DremioResponse, dremio.DremioResponseState]{
70+
FetchInstance: a.GetDremioInstance(ctx, projectId, regionId, dremioId).Execute,
71+
GetState: func(dremioResp *dremio.DremioResponse) (dremio.DremioResponseState, error) {
72+
if dremioResp == nil {
73+
return "", errors.New("empty response")
74+
}
75+
return dremioResp.State, nil
76+
},
77+
ErrorState: []dremio.DremioResponseState{dremio.DREMIORESPONSESTATE_ERROR},
78+
DeleteHttpErrorStatusCodes: []int{http.StatusNotFound},
79+
}
80+
81+
handler := wait.New(waitConfig.Wait())
82+
handler.SetTimeout(30 * time.Minute)
83+
return handler
84+
}
85+
86+
// CreateDremioUserWaitHandler will wait for the creation of a Dremio user
87+
func CreateDremioUserWaitHandler(ctx context.Context, a dremio.DefaultAPI, projectId, regionId, dremioId, dremioUserId string) *wait.AsyncActionHandler[dremio.DremioUserResponse] {
88+
waitConfig := wait.WaiterHelper[dremio.DremioUserResponse, dremio.DremioUserResponseState]{
89+
FetchInstance: a.GetDremioUser(ctx, projectId, regionId, dremioId, dremioUserId).Execute,
90+
GetState: func(user *dremio.DremioUserResponse) (dremio.DremioUserResponseState, error) {
91+
if user == nil {
92+
return "", errors.New("empty response")
93+
}
94+
return user.State, nil
95+
},
96+
ActiveState: []dremio.DremioUserResponseState{dremio.DREMIOUSERRESPONSESTATE_ACTIVE},
97+
ErrorState: []dremio.DremioUserResponseState{dremio.DREMIOUSERRESPONSESTATE_ERROR},
98+
}
99+
100+
handler := wait.New(waitConfig.Wait())
101+
handler.SetTimeout(10 * time.Minute)
102+
return handler
103+
}
104+
105+
// UpdateDremioUserWaitHandler will wait for an update to a Dremio user
106+
func UpdateDremioUserWaitHandler(ctx context.Context, a dremio.DefaultAPI, projectId, regionId, dremioId, dremioUserId string) *wait.AsyncActionHandler[dremio.DremioUserResponse] {
107+
waitConfig := wait.WaiterHelper[dremio.DremioUserResponse, dremio.DremioUserResponseState]{
108+
FetchInstance: a.GetDremioUser(ctx, projectId, regionId, dremioId, dremioUserId).Execute,
109+
GetState: func(user *dremio.DremioUserResponse) (dremio.DremioUserResponseState, error) {
110+
if user == nil {
111+
return "", errors.New("empty response")
112+
}
113+
return user.State, nil
114+
},
115+
ActiveState: []dremio.DremioUserResponseState{dremio.DREMIOUSERRESPONSESTATE_ACTIVE},
116+
ErrorState: []dremio.DremioUserResponseState{dremio.DREMIOUSERRESPONSESTATE_ERROR},
117+
}
118+
119+
handler := wait.New(waitConfig.Wait())
120+
handler.SetTimeout(10 * time.Minute)
121+
return handler
122+
}
123+
124+
// DeleteDremioUserWaitHandler will wait for a deletion of a Dremio user
125+
func DeleteDremioUserWaitHandler(ctx context.Context, a dremio.DefaultAPI, projectId, regionId, dremioId, dremioUserId string) *wait.AsyncActionHandler[dremio.DremioUserResponse] {
126+
waitConfig := wait.WaiterHelper[dremio.DremioUserResponse, dremio.DremioUserResponseState]{
127+
FetchInstance: a.GetDremioUser(ctx, projectId, regionId, dremioId, dremioUserId).Execute,
128+
GetState: func(user *dremio.DremioUserResponse) (dremio.DremioUserResponseState, error) {
129+
if user == nil {
130+
return "", errors.New("empty response")
131+
}
132+
return user.State, nil
133+
},
134+
ErrorState: []dremio.DremioUserResponseState{dremio.DREMIOUSERRESPONSESTATE_ERROR},
135+
DeleteHttpErrorStatusCodes: []int{http.StatusNotFound},
136+
}
137+
138+
handler := wait.New(waitConfig.Wait())
139+
handler.SetTimeout(10 * time.Minute)
140+
return handler
141+
}

0 commit comments

Comments
 (0)