Skip to content

Commit 6ee8fc5

Browse files
committed
Merge remote-tracking branch 'origin/develop' into feature/SCALRCORE-26056
2 parents f1b8fba + 9bc6442 commit 6ee8fc5

File tree

4 files changed

+49
-18
lines changed

4 files changed

+49
-18
lines changed

environment.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,16 @@ func (o EnvironmentCreateOptions) valid() error {
109109
type EnvironmentListOptions struct {
110110
ListOptions
111111

112-
Include *string `url:"include,omitempty"`
113-
Name *string `url:"query,omitempty"`
114-
Id *string `url:"query,omitempty"`
115-
Account *string `url:"filter[account],omitempty"`
112+
Include *string `url:"include,omitempty"`
113+
Filter *EnvironmentFilter `url:"filter,omitempty"`
114+
}
115+
116+
// EnvironmentFilter represents the options for filtering environments.
117+
type EnvironmentFilter struct {
118+
Id *string `url:"environment,omitempty"`
119+
Account *string `url:"account,omitempty"`
120+
Name *string `url:"name,omitempty"`
121+
Tag *string `url:"tag,omitempty"`
116122
}
117123

118124
// List all the environmens.

environment_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func TestEnvironmentsList(t *testing.T) {
4848
})
4949

5050
filterByNameOptions := EnvironmentListOptions{
51-
Name: &envTest1.Name,
51+
Filter: &EnvironmentFilter{Name: &envTest1.Name},
5252
}
5353
t.Run("with filter by name option", func(t *testing.T) {
5454
envl, err := client.Environments.List(ctx, filterByNameOptions)
@@ -59,7 +59,7 @@ func TestEnvironmentsList(t *testing.T) {
5959
})
6060

6161
filterByIdOptions := EnvironmentListOptions{
62-
Id: &envTest1.ID,
62+
Filter: &EnvironmentFilter{Id: &envTest1.ID},
6363
}
6464
t.Run("with filter by ID option", func(t *testing.T) {
6565
envl, err := client.Environments.List(ctx, filterByIdOptions)
@@ -70,7 +70,7 @@ func TestEnvironmentsList(t *testing.T) {
7070
})
7171

7272
filterByAccountIdOptions := EnvironmentListOptions{
73-
Account: String(defaultAccountID),
73+
Filter: &EnvironmentFilter{Account: String(defaultAccountID)},
7474
}
7575
t.Run("with filter by account option", func(t *testing.T) {
7676
envl, err := client.Environments.List(ctx, filterByAccountIdOptions)

workspace.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,18 @@ type WorkspacePermissions struct {
142142
// WorkspaceListOptions represents the options for listing workspaces.
143143
type WorkspaceListOptions struct {
144144
ListOptions
145+
Include string `url:"include,omitempty"`
146+
Filter *WorkspaceFilter `url:"filter,omitempty"`
147+
}
145148

146-
Workspace *string `url:"filter[workspace],omitempty"`
147-
Environment *string `url:"filter[environment],omitempty"`
148-
AgentPool *string `url:"filter[agent-pool],omitempty"`
149-
Name *string `url:"filter[name],omitempty"`
150-
Include string `url:"include,omitempty"`
149+
// WorkspaceFilter represents the options for filtering workspaces.
150+
type WorkspaceFilter struct {
151+
Id *string `url:"workspace,omitempty"`
152+
Account *string `url:"account,omitempty"`
153+
Environment *string `url:"environment,omitempty"`
154+
Name *string `url:"name,omitempty"`
155+
Tag *string `url:"tag,omitempty"`
156+
AgentPool *string `url:"agent-pool,omitempty"`
151157
}
152158

153159
// WorkspaceRunScheduleOptions represents option for setting run schedules for workspace
@@ -295,7 +301,10 @@ func (s *workspaces) Read(ctx context.Context, environmentID, workspaceName stri
295301
return nil, errors.New("invalid value for workspace")
296302
}
297303

298-
options := WorkspaceListOptions{Environment: &environmentID, Name: &workspaceName, Include: "created-by"}
304+
options := WorkspaceListOptions{
305+
Include: "created-by",
306+
Filter: &WorkspaceFilter{Environment: &environmentID, Name: &workspaceName},
307+
}
299308

300309
req, err := s.client.newRequest("GET", "workspaces", &options)
301310
if err != nil {

workspace_test.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ func TestWorkspacesList(t *testing.T) {
2222
defer wsTest2Cleanup()
2323

2424
t.Run("without list options", func(t *testing.T) {
25-
wsl, err := client.Workspaces.List(ctx, WorkspaceListOptions{Environment: &envTest.ID})
25+
wsl, err := client.Workspaces.List(ctx,
26+
WorkspaceListOptions{
27+
Filter: &WorkspaceFilter{
28+
Environment: &envTest.ID,
29+
},
30+
},
31+
)
2632
require.NoError(t, err)
2733
wslIDs := make([]string, len(wsl.Items))
2834
for _, ws := range wsl.Items {
@@ -36,8 +42,10 @@ func TestWorkspacesList(t *testing.T) {
3642

3743
t.Run("with ID in list options", func(t *testing.T) {
3844
wsl, err := client.Workspaces.List(ctx, WorkspaceListOptions{
39-
Environment: &envTest.ID,
40-
Workspace: &wsTest1.ID,
45+
Filter: &WorkspaceFilter{
46+
Environment: &envTest.ID,
47+
Id: &wsTest1.ID,
48+
},
4149
})
4250
require.NoError(t, err)
4351
assert.Equal(t, 1, wsl.TotalCount)
@@ -53,15 +61,23 @@ func TestWorkspacesList(t *testing.T) {
5361
PageNumber: 999,
5462
PageSize: 100,
5563
},
56-
Environment: &envTest.ID,
64+
Filter: &WorkspaceFilter{
65+
Environment: &envTest.ID,
66+
},
5767
})
5868
require.NoError(t, err)
5969
assert.Empty(t, wl.Items)
6070
assert.Equal(t, 999, wl.CurrentPage)
6171
assert.Equal(t, 2, wl.TotalCount)
6272
})
6373
t.Run("without a valid environment", func(t *testing.T) {
64-
wl, err := client.Workspaces.List(ctx, WorkspaceListOptions{Environment: String(badIdentifier)})
74+
wl, err := client.Workspaces.List(ctx,
75+
WorkspaceListOptions{
76+
Filter: &WorkspaceFilter{
77+
Environment: String(badIdentifier),
78+
},
79+
},
80+
)
6581
assert.Len(t, wl.Items, 0)
6682
assert.NoError(t, err)
6783
})

0 commit comments

Comments
 (0)