-
Notifications
You must be signed in to change notification settings - Fork 33
feat: model experiments wait handler #7800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
paul-sffrth
wants to merge
8
commits into
stackitcloud:main
Choose a base branch
from
paul-sffrth:feature/mexp-wait-handler
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f3e992d
feat(mexp): add model experiments wait handler
557a03e
feat(mexp): add example and update changelog
adfed35
feat(mexp): fix linting
6cffbe6
feat(mexp): tidying dependencies
bc71b3a
chore: code review fixes
9871182
chore: code review fixes
90ff726
chore: fix method naming
eb24830
feat: set wait timeout to 45 min
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| module github.com/stackitcloud/stackit-sdk-go/examples/modelexperiments | ||
|
|
||
| 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/modelexperiments => ../../services/modelexperiments | ||
|
|
||
| require github.com/stackitcloud/stackit-sdk-go/services/modelexperiments v0.2.0 | ||
|
|
||
| require ( | ||
| github.com/golang-jwt/jwt/v5 v5.3.1 // indirect | ||
| github.com/google/uuid v1.6.0 // indirect | ||
| github.com/stackitcloud/stackit-sdk-go/core v0.26.0 // indirect | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "os" | ||
|
|
||
| modelexperiments "github.com/stackitcloud/stackit-sdk-go/services/modelexperiments/v1api" | ||
| "github.com/stackitcloud/stackit-sdk-go/services/modelexperiments/v1api/wait" | ||
| ) | ||
|
|
||
| func main() { | ||
| projectId := "PROJECT_ID" // the uuid of your STACKIT project | ||
| region := "eu01" | ||
| instanceName := "instance" | ||
| newInstanceName := "newInstance" | ||
| newTokenName := "newTokenName" | ||
| description := "description" | ||
| ctx := context.Background() | ||
|
|
||
| modelexperimentsClient, err := modelexperiments.NewAPIClient() | ||
| if err != nil { | ||
| fmt.Fprintf(os.Stderr, "[Model Experiments] Creating API client: %v\n", err) | ||
| os.Exit(1) | ||
| } | ||
|
|
||
| // Create an Model Experiments Instance | ||
|
GokceGK marked this conversation as resolved.
Outdated
|
||
| createInstancePayload := modelexperiments.CreateInstancePayload{ | ||
| Name: instanceName, | ||
| Description: &description, | ||
| } | ||
| createInstanceResp, err := modelexperimentsClient.DefaultAPI.CreateInstance(ctx, projectId, region).CreateInstancePayload(createInstancePayload).Execute() | ||
| if err != nil { | ||
| fmt.Fprintf(os.Stderr, "[Model Experiments] Error when calling `CreateInstance`: %v\n", err) | ||
|
GokceGK marked this conversation as resolved.
Outdated
|
||
| } else { | ||
| fmt.Printf("[Model Experiments] Created Model Experiments Instance with ID: \"%s\".\n", createInstanceResp.Instance.Id) | ||
|
GokceGK marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
|
paul-sffrth marked this conversation as resolved.
|
||
| // Wait for the Model Experiments Instance to be ready | ||
| fmt.Printf("[Model Experiments] Waiting for Model Experiments Instance to be created.\n") | ||
| _, err = wait.CreateModelExperimentsInstanceWaitHandler(ctx, modelexperimentsClient.DefaultAPI, region, projectId, createInstanceResp.Instance.Id).WaitWithContext(ctx) | ||
| if err != nil { | ||
| fmt.Fprintf(os.Stderr, "[Model Experiments] Error when waiting for creation: %v\n", err) | ||
| } | ||
| fmt.Printf("[Model Experiments] Model Experiments Instance \"%s\" has been successfully created.\n", createInstanceResp.Instance.Id) | ||
|
|
||
| // Get the created Model Experiments Instance | ||
| getInstanceResp, err := modelexperimentsClient.DefaultAPI.GetInstance(ctx, projectId, region, createInstanceResp.Instance.Id).Execute() | ||
| if err != nil { | ||
| fmt.Fprintf(os.Stderr, "[Model Experiments] Error when calling `GetInstance`: %v\n", err) | ||
| } else { | ||
| fmt.Printf("[Model Experiments] Retrieved Model Experiments Instance with ID: \"%s\" and display name: \"%s\"\n", getInstanceResp.Instance.Id, getInstanceResp.Instance.Name) | ||
| } | ||
|
|
||
| // List Model Experiments Instances | ||
|
GokceGK marked this conversation as resolved.
|
||
| listInstaceResp, err := modelexperimentsClient.DefaultAPI.ListInstances(ctx, projectId, region).Execute() | ||
|
GokceGK marked this conversation as resolved.
Outdated
|
||
| if err != nil { | ||
| fmt.Fprintf(os.Stderr, "[Model Experiments] Error when calling `ListInstances`: %v\n", err) | ||
| } else { | ||
| fmt.Printf("[Model Experiments] Retrieved %d instances\n", len(listInstaceResp.Instances)) | ||
| } | ||
|
|
||
| // Update an Model Experiments Instance | ||
|
GokceGK marked this conversation as resolved.
Outdated
GokceGK marked this conversation as resolved.
Outdated
|
||
| partialUpdateInstancePayload := modelexperiments.PartialUpdateInstancePayload{ | ||
| Name: &newInstanceName, | ||
| } | ||
| partialUpdateInstanceResp, err := modelexperimentsClient.DefaultAPI.PartialUpdateInstance(ctx, projectId, region, getInstanceResp.Instance.Id).PartialUpdateInstancePayload(partialUpdateInstancePayload).Execute() | ||
| if err != nil { | ||
| fmt.Fprintf(os.Stderr, "[Model Experiments] Error when calling `PartialUpdateInstance`: %v\n", err) | ||
| } else { | ||
| fmt.Printf("[Model Experiments] Updated Model Experiments Instance with ID: \"%s\" and display name: \"%s\"\n", partialUpdateInstanceResp.Instance.Id, partialUpdateInstanceResp.Instance.Name) | ||
| } | ||
|
|
||
| // Delete an Model Experiments Instance | ||
|
GokceGK marked this conversation as resolved.
Outdated
GokceGK marked this conversation as resolved.
Outdated
|
||
| deleteInstanceResp, err := modelexperimentsClient.DefaultAPI.DeleteInstance(ctx, projectId, region, getInstanceResp.Instance.Id).Execute() | ||
| if err != nil { | ||
| fmt.Fprintf(os.Stderr, "[Model Experiments] Error when calling `DeleteInstance`: %v\n", err) | ||
| } else { | ||
| fmt.Printf("[Model Experiments] Deleted Model Experiments Instance with ID: \"%s\" and display name: \"%s\"\n", deleteInstanceResp.Instance.Id, deleteInstanceResp.Instance.Name) | ||
|
GokceGK marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| // Wait for the Model Experiments Instance to be deleted | ||
| fmt.Printf("[Model Experiments] Waiting for Model Experiments Instance to be deleted.\n") | ||
| _, err = wait.DeleteModelExperimentsInstanceWaitHandler(ctx, modelexperimentsClient.DefaultAPI, region, projectId, getInstanceResp.Instance.Id).WaitWithContext(ctx) | ||
| if err != nil { | ||
| fmt.Fprintf(os.Stderr, "[Model Experiments] Error when waiting for deletion: %v\n", err) | ||
| } | ||
| fmt.Printf("[Model Experiments] Model Experiments Instance \"%s\" has been successfully deleted.\n", deleteInstanceResp.Instance.Id) | ||
|
|
||
| // Create an Model Experiments Instance Token | ||
|
GokceGK marked this conversation as resolved.
Outdated
|
||
| createTokenPayload := modelexperiments.CreateInstanceTokenPayload{ | ||
| Name: "token-name", | ||
| } | ||
| createTokenResp, err := modelexperimentsClient.DefaultAPI.CreateInstanceToken(ctx, projectId, region, createInstanceResp.Instance.Id).CreateInstanceTokenPayload(createTokenPayload).Execute() | ||
| if err != nil { | ||
| fmt.Fprintf(os.Stderr, "[Model Experiments] Error when calling `CreateToken`: %v\n", err) | ||
| } else { | ||
| fmt.Printf("[Model Experiments] Created Model Experiments Instance Token: %+v\n", createTokenResp.Token) | ||
|
GokceGK marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| // Wait for the Model Experiments Instance Token to be ready | ||
| fmt.Printf("[Model Experiments] Waiting for Model Experiments Instance Token to be created.\n") | ||
| _, err = wait.CreateModelExperimentsInstanceTokenWaitHandler(ctx, modelexperimentsClient.DefaultAPI, region, projectId, getInstanceResp.Instance.Id, createTokenResp.Token.Id).WaitWithContext(ctx) | ||
| if err != nil { | ||
| fmt.Fprintf(os.Stderr, "[Model Experiments] Error when waiting for creation: %v\n", err) | ||
| } | ||
| fmt.Printf("[Model Experiments] Model Experiments Instance Token \"%s\" has been successfully created.\n", createTokenResp.Token.Id) | ||
|
|
||
| // Get the created Model Experiments Instance Token | ||
| getTokenResp, err := modelexperimentsClient.DefaultAPI.GetInstanceToken(ctx, projectId, region, createTokenResp.Token.Id, getInstanceResp.Instance.Id).Execute() | ||
| if err != nil { | ||
| fmt.Fprintf(os.Stderr, "[Model Experiments] Error when calling `GetInstanceToken`: %v\n", err) | ||
| } else { | ||
| fmt.Printf("[Model Experiments] Retrieved Model Experiments Instance Token with ID: \"%s\" and display name: \"%s\"\n", getTokenResp.Token.Id, getTokenResp.Token.Name) | ||
| } | ||
|
|
||
| // List Model Experiments Instance Tokens | ||
| listTokenResp, err := modelexperimentsClient.DefaultAPI.ListInstanceTokens(ctx, projectId, region, getInstanceResp.Instance.Id).Execute() | ||
| if err != nil { | ||
| fmt.Fprintf(os.Stderr, "[Model Experiments] Error when calling `ListInstanceTokens`: %v\n", err) | ||
| } else { | ||
| fmt.Printf("[Model Experiments] Retrieved %d instance tokens\n", len(listTokenResp.Tokens)) | ||
| } | ||
|
|
||
| // Update an Model Experiments Instance Token | ||
|
GokceGK marked this conversation as resolved.
Outdated
|
||
| partialUpdateInstanceTokenPayload := modelexperiments.PartialUpdateInstanceTokenPayload{ | ||
| Name: &newTokenName, | ||
| } | ||
| partialUpdateTokenResp, err := modelexperimentsClient.DefaultAPI.PartialUpdateInstanceToken(ctx, projectId, region, getTokenResp.Token.Id, getInstanceResp.Instance.Id).PartialUpdateInstanceTokenPayload(partialUpdateInstanceTokenPayload).Execute() | ||
| if err != nil { | ||
| fmt.Fprintf(os.Stderr, "[Model Experiments] Error when calling `PartialUpdateInstanceToken`: %v\n", err) | ||
| } else { | ||
| fmt.Printf("[Model Experiments] Updated Model Experiments Instance Token with ID: \"%s\" and display name: \"%s\"\n", partialUpdateTokenResp.Token.Id, partialUpdateTokenResp.Token.Name) | ||
| } | ||
|
|
||
| // Delete an Model Experiments Instance Token | ||
|
GokceGK marked this conversation as resolved.
Outdated
|
||
| deleteTokenResp, err := modelexperimentsClient.DefaultAPI.DeleteInstanceToken(ctx, projectId, region, getTokenResp.Token.Id, getInstanceResp.Instance.Id).Execute() | ||
| if err != nil { | ||
| fmt.Fprintf(os.Stderr, "[Model Experiments] Error when calling `DeleteInstanceToken`: %v\n", err) | ||
| } else { | ||
| fmt.Printf("[Model Experiments] Deleted Model Experiments Instance Token with ID: \"%s\" and display name: \"%s\"\n", deleteTokenResp.Token.Id, deleteTokenResp.Token.Name) | ||
|
GokceGK marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| // Wait for the Model Experiments Instance Token to be deleted | ||
| fmt.Printf("[Model Experiments] Waiting for Model Experiments Instance Token to be deleted.\n") | ||
| _, err = wait.DeleteModelExperimentsInstanceTokenWaitHandler(ctx, modelexperimentsClient.DefaultAPI, region, projectId, getInstanceResp.Instance.Id, deleteTokenResp.Token.Id).WaitWithContext(ctx) | ||
| if err != nil { | ||
| fmt.Fprintf(os.Stderr, "[Model Experiments] Error when waiting for deletion: %v\n", err) | ||
| } | ||
| fmt.Printf("[Model Experiments] Model Experiments Instance Token \"%s\" has been successfully deleted.\n", deleteTokenResp.Token.Id) | ||
| } | ||
|
paul-sffrth marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,5 @@ | ||
| ## v0.2.0 | ||
| - **New**: STACKIT Model Experiments module wait handler added. | ||
|
|
||
| ## v0.1.0 | ||
| - **New**: API for STACKIT modelexperiments |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| STACKIT modelexperiments SDK for Go | ||
| STACKIT Model Experiments SDK for Go | ||
| Copyright 2026 Schwarz IT KG |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| v0.1.0 | ||
| v0.2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,92 @@ | ||||||||||||||
| package wait | ||||||||||||||
|
|
||||||||||||||
| import ( | ||||||||||||||
| "context" | ||||||||||||||
| "errors" | ||||||||||||||
| "net/http" | ||||||||||||||
| "time" | ||||||||||||||
|
|
||||||||||||||
| "github.com/stackitcloud/stackit-sdk-go/core/wait" | ||||||||||||||
| modelexperiments "github.com/stackitcloud/stackit-sdk-go/services/modelexperiments/v1api" | ||||||||||||||
| ) | ||||||||||||||
|
|
||||||||||||||
| const ( | ||||||||||||||
| INSTANCESTATE_ACTIVE = "active" | ||||||||||||||
| INSTANCESTATE_IMPAIRED = "impaired" | ||||||||||||||
|
|
||||||||||||||
| TOKENSTATE_ACTIVE = "active" | ||||||||||||||
| ) | ||||||||||||||
|
Comment on lines
+13
to
+18
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
These aren't used at all and should be removed |
||||||||||||||
|
|
||||||||||||||
| // CreateModelExperimentsInstanceWaitHandler will wait for creation of Model Experiments instance | ||||||||||||||
| func CreateModelExperimentsInstanceWaitHandler(ctx context.Context, a modelexperiments.DefaultAPI, region, projectId, instanceId string) *wait.AsyncActionHandler[modelexperiments.GetInstanceResponse] { | ||||||||||||||
|
GokceGK marked this conversation as resolved.
Outdated
|
||||||||||||||
| waitConfig := wait.WaiterHelper[modelexperiments.GetInstanceResponse, modelexperiments.InstanceState]{ | ||||||||||||||
| FetchInstance: a.GetInstance(ctx, projectId, region, instanceId).Execute, | ||||||||||||||
| GetState: func(response *modelexperiments.GetInstanceResponse) (modelexperiments.InstanceState, error) { | ||||||||||||||
| if response == nil { | ||||||||||||||
| return "", errors.New("empty response") | ||||||||||||||
| } | ||||||||||||||
| return response.Instance.State, nil | ||||||||||||||
| }, | ||||||||||||||
| ActiveState: []modelexperiments.InstanceState{modelexperiments.INSTANCESTATE_ACTIVE}, | ||||||||||||||
| ErrorState: []modelexperiments.InstanceState{modelexperiments.INSTANCESTATE_IMPAIRED}, | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| handler := wait.New(waitConfig.Wait()) | ||||||||||||||
| handler.SetTimeout(10 * time.Minute) | ||||||||||||||
| return handler | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // DeleteModelExperimentsInstanceWaitHandler will wait for deletion of Model Experiments instance | ||||||||||||||
| func DeleteModelExperimentsInstanceWaitHandler(ctx context.Context, a modelexperiments.DefaultAPI, region, projectId, instanceId string) *wait.AsyncActionHandler[modelexperiments.GetInstanceResponse] { | ||||||||||||||
| waitConfig := wait.WaiterHelper[modelexperiments.GetInstanceResponse, modelexperiments.InstanceState]{ | ||||||||||||||
| FetchInstance: a.GetInstance(ctx, projectId, region, instanceId).Execute, | ||||||||||||||
| GetState: func(response *modelexperiments.GetInstanceResponse) (modelexperiments.InstanceState, error) { | ||||||||||||||
| if response == nil { | ||||||||||||||
| return "", errors.New("empty response") | ||||||||||||||
| } | ||||||||||||||
| return response.Instance.State, nil | ||||||||||||||
| }, | ||||||||||||||
| DeleteHttpErrorStatusCodes: []int{http.StatusNotFound}, | ||||||||||||||
|
Comment on lines
+48
to
+49
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ErrorState is missing
Suggested change
|
||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| handler := wait.New(waitConfig.Wait()) | ||||||||||||||
| handler.SetTimeout(10 * time.Minute) | ||||||||||||||
| return handler | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // CreateModelExperimentsTokenWait Handler will wait for creation of Model Experiments instance token | ||||||||||||||
| func CreateModelExperimentsInstanceTokenWaitHandler(ctx context.Context, a modelexperiments.DefaultAPI, region, projectId, instanceId, tokenId string) *wait.AsyncActionHandler[modelexperiments.GetInstanceTokenResponse] { | ||||||||||||||
| waitConfig := wait.WaiterHelper[modelexperiments.GetInstanceTokenResponse, modelexperiments.TokenState]{ | ||||||||||||||
| FetchInstance: a.GetInstanceToken(ctx, projectId, region, tokenId, instanceId).Execute, | ||||||||||||||
| GetState: func(response *modelexperiments.GetInstanceTokenResponse) (modelexperiments.TokenState, error) { | ||||||||||||||
| if response == nil { | ||||||||||||||
| return "", errors.New("empty response") | ||||||||||||||
| } | ||||||||||||||
| return response.Token.State, nil | ||||||||||||||
| }, | ||||||||||||||
| ActiveState: []modelexperiments.TokenState{modelexperiments.TOKENSTATE_ACTIVE}, | ||||||||||||||
| ErrorState: []modelexperiments.TokenState{}, | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| handler := wait.New(waitConfig.Wait()) | ||||||||||||||
| handler.SetTimeout(10 * time.Minute) | ||||||||||||||
| return handler | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // DeleteModelExperimentsInstanceTokenWaitHandler will wait for deletion of Model Experiments instance token | ||||||||||||||
| func DeleteModelExperimentsInstanceTokenWaitHandler(ctx context.Context, a modelexperiments.DefaultAPI, region, projectId, instanceId, tokenId string) *wait.AsyncActionHandler[modelexperiments.GetInstanceTokenResponse] { | ||||||||||||||
| waitConfig := wait.WaiterHelper[modelexperiments.GetInstanceTokenResponse, modelexperiments.TokenState]{ | ||||||||||||||
| FetchInstance: a.GetInstanceToken(ctx, projectId, region, tokenId, instanceId).Execute, | ||||||||||||||
| GetState: func(response *modelexperiments.GetInstanceTokenResponse) (modelexperiments.TokenState, error) { | ||||||||||||||
| if response == nil { | ||||||||||||||
| return "", errors.New("empty response") | ||||||||||||||
| } | ||||||||||||||
| return response.Token.State, nil | ||||||||||||||
| }, | ||||||||||||||
| DeleteHttpErrorStatusCodes: []int{http.StatusNotFound}, | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| handler := wait.New(waitConfig.Wait()) | ||||||||||||||
| handler.SetTimeout(10 * time.Minute) | ||||||||||||||
| return handler | ||||||||||||||
| } | ||||||||||||||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.