Skip to content

Impl support for multi agent workspaces #26

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

Merged
merged 12 commits into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Impl: REST call to retrieve the workspace resources
  • Loading branch information
fioan89 committed Jun 28, 2022
commit 50a5e0e822a96bc504121664ef70dab3e3c011d8
10 changes: 10 additions & 0 deletions src/main/kotlin/com/coder/gateway/sdk/CoderRestClientService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.coder.gateway.sdk.v2.CoderV2RestFacade
import com.coder.gateway.sdk.v2.models.BuildInfo
import com.coder.gateway.sdk.v2.models.User
import com.coder.gateway.sdk.v2.models.Workspace
import com.coder.gateway.sdk.v2.models.WorkspaceResource
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.intellij.openapi.components.Service
Expand Down Expand Up @@ -93,4 +94,13 @@ class CoderRestClientService {
}
return buildInfoResponse.body()!!
}

fun workspaceResources(workspace: Workspace): List<WorkspaceResource> {
val workspaceResourcesResponse = retroRestClient.workspaceResourceByBuild(workspace.latestBuild.id).execute()
if (!workspaceResourcesResponse.isSuccessful) {
throw IllegalStateException("Could not retrieve resources for ${workspace.name} workspace :${workspaceResourcesResponse.code()}, reason: ${workspaceResourcesResponse.message()}")
}

return workspaceResourcesResponse.body()!!
}
}
6 changes: 6 additions & 0 deletions src/main/kotlin/com/coder/gateway/sdk/v2/CoderV2RestFacade.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ package com.coder.gateway.sdk.v2
import com.coder.gateway.sdk.v2.models.BuildInfo
import com.coder.gateway.sdk.v2.models.User
import com.coder.gateway.sdk.v2.models.Workspace
import com.coder.gateway.sdk.v2.models.WorkspaceResource
import retrofit2.Call
import retrofit2.http.GET
import retrofit2.http.Path
import java.util.UUID

interface CoderV2RestFacade {

Expand All @@ -22,4 +25,7 @@ interface CoderV2RestFacade {

@GET("api/v2/buildinfo")
fun buildInfo(): Call<BuildInfo>

@GET("api/v2/workspacebuilds/{buildID}/resources")
fun workspaceResourceByBuild(@Path("buildID") build: UUID): Call<List<WorkspaceResource>>
}