From 074f43a2f9760e478a4f96cdef265cadc891f359 Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Wed, 4 Sep 2024 14:38:09 +0200 Subject: [PATCH] revert broken example autogeneration --- service/provisioning/workspaces_usage_test.go | 95 ++++++++++++++++++- 1 file changed, 90 insertions(+), 5 deletions(-) diff --git a/service/provisioning/workspaces_usage_test.go b/service/provisioning/workspaces_usage_test.go index f26ecbcc8..e50e4c98c 100755 --- a/service/provisioning/workspaces_usage_test.go +++ b/service/provisioning/workspaces_usage_test.go @@ -45,7 +45,7 @@ func ExampleWorkspacesAPI_Create_workspaces() { } logger.Infof(ctx, "found %v", role) - waiter, err := a.Workspaces.Create(ctx, provisioning.CreateWorkspaceRequest{ + created, err := a.Workspaces.CreateAndWait(ctx, provisioning.CreateWorkspaceRequest{ WorkspaceName: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), AwsRegion: os.Getenv("AWS_REGION"), CredentialsId: role.CredentialsId, @@ -54,7 +54,7 @@ func ExampleWorkspacesAPI_Create_workspaces() { if err != nil { panic(err) } - logger.Infof(ctx, "found %v", waiter) + logger.Infof(ctx, "found %v", created) // cleanup @@ -66,7 +66,7 @@ func ExampleWorkspacesAPI_Create_workspaces() { if err != nil { panic(err) } - err = a.Workspaces.DeleteByWorkspaceId(ctx, waiter.WorkspaceId) + err = a.Workspaces.DeleteByWorkspaceId(ctx, created.WorkspaceId) if err != nil { panic(err) } @@ -80,7 +80,36 @@ func ExampleWorkspacesAPI_Get_workspaces() { panic(err) } - created, err := a.Waiter.Get(ctx) + storage, err := a.Storage.Create(ctx, provisioning.CreateStorageConfigurationRequest{ + StorageConfigurationName: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), + RootBucketInfo: provisioning.RootBucketInfo{ + BucketName: os.Getenv("TEST_ROOT_BUCKET"), + }, + }) + if err != nil { + panic(err) + } + logger.Infof(ctx, "found %v", storage) + + role, err := a.Credentials.Create(ctx, provisioning.CreateCredentialRequest{ + CredentialsName: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), + AwsCredentials: provisioning.CreateCredentialAwsCredentials{ + StsRole: &provisioning.CreateCredentialStsRole{ + RoleArn: os.Getenv("TEST_CROSSACCOUNT_ARN"), + }, + }, + }) + if err != nil { + panic(err) + } + logger.Infof(ctx, "found %v", role) + + created, err := a.Workspaces.CreateAndWait(ctx, provisioning.CreateWorkspaceRequest{ + WorkspaceName: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), + AwsRegion: os.Getenv("AWS_REGION"), + CredentialsId: role.CredentialsId, + StorageConfigurationId: storage.StorageConfigurationId, + }) if err != nil { panic(err) } @@ -92,6 +121,21 @@ func ExampleWorkspacesAPI_Get_workspaces() { } logger.Infof(ctx, "found %v", byId) + // cleanup + + err = a.Storage.DeleteByStorageConfigurationId(ctx, storage.StorageConfigurationId) + if err != nil { + panic(err) + } + err = a.Credentials.DeleteByCredentialsId(ctx, role.CredentialsId) + if err != nil { + panic(err) + } + err = a.Workspaces.DeleteByWorkspaceId(ctx, created.WorkspaceId) + if err != nil { + panic(err) + } + } func ExampleWorkspacesAPI_ListAll_workspaces() { @@ -116,6 +160,30 @@ func ExampleWorkspacesAPI_Update_workspaces() { panic(err) } + storage, err := a.Storage.Create(ctx, provisioning.CreateStorageConfigurationRequest{ + StorageConfigurationName: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), + RootBucketInfo: provisioning.RootBucketInfo{ + BucketName: os.Getenv("TEST_ROOT_BUCKET"), + }, + }) + if err != nil { + panic(err) + } + logger.Infof(ctx, "found %v", storage) + + role, err := a.Credentials.Create(ctx, provisioning.CreateCredentialRequest{ + CredentialsName: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), + AwsCredentials: provisioning.CreateCredentialAwsCredentials{ + StsRole: &provisioning.CreateCredentialStsRole{ + RoleArn: os.Getenv("TEST_CROSSACCOUNT_ARN"), + }, + }, + }) + if err != nil { + panic(err) + } + logger.Infof(ctx, "found %v", role) + updateRole, err := a.Credentials.Create(ctx, provisioning.CreateCredentialRequest{ CredentialsName: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), AwsCredentials: provisioning.CreateCredentialAwsCredentials{ @@ -129,7 +197,12 @@ func ExampleWorkspacesAPI_Update_workspaces() { } logger.Infof(ctx, "found %v", updateRole) - created, err := a.Waiter.Get(ctx) + created, err := a.Workspaces.CreateAndWait(ctx, provisioning.CreateWorkspaceRequest{ + WorkspaceName: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), + AwsRegion: os.Getenv("AWS_REGION"), + CredentialsId: role.CredentialsId, + StorageConfigurationId: storage.StorageConfigurationId, + }) if err != nil { panic(err) } @@ -145,9 +218,21 @@ func ExampleWorkspacesAPI_Update_workspaces() { // cleanup + err = a.Storage.DeleteByStorageConfigurationId(ctx, storage.StorageConfigurationId) + if err != nil { + panic(err) + } + err = a.Credentials.DeleteByCredentialsId(ctx, role.CredentialsId) + if err != nil { + panic(err) + } err = a.Credentials.DeleteByCredentialsId(ctx, updateRole.CredentialsId) if err != nil { panic(err) } + err = a.Workspaces.DeleteByWorkspaceId(ctx, created.WorkspaceId) + if err != nil { + panic(err) + } }