Skip to content

Commit 41455d0

Browse files
committed
Remove unused API references
Many of these are out of date, and it seems Moshi is more strict about parsing because when a property is missing it will error. For now, pare down the SDK to just the values we are using, but ideally we would generate this from coder/coder itself.
1 parent fc934dd commit 41455d0

17 files changed

+18
-389
lines changed

src/main/kotlin/com/coder/gateway/sdk/BaseCoderRestClient.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ open class BaseCoderRestClient(
194194
}
195195

196196
fun startWorkspace(workspace: Workspace): WorkspaceBuild {
197-
val buildRequest = CreateWorkspaceBuildRequest(null, WorkspaceTransition.START, null, null, null, null)
197+
val buildRequest = CreateWorkspaceBuildRequest(null, WorkspaceTransition.START)
198198
val buildResponse = retroRestClient.createWorkspaceBuild(workspace.id, buildRequest).execute()
199199
if (buildResponse.code() != HttpURLConnection.HTTP_CREATED) {
200200
throw WorkspaceResponseException(error("start workspace ${workspace.name}", buildResponse))
@@ -204,7 +204,7 @@ open class BaseCoderRestClient(
204204
}
205205

206206
fun stopWorkspace(workspace: Workspace): WorkspaceBuild {
207-
val buildRequest = CreateWorkspaceBuildRequest(null, WorkspaceTransition.STOP, null, null, null, null)
207+
val buildRequest = CreateWorkspaceBuildRequest(null, WorkspaceTransition.STOP)
208208
val buildResponse = retroRestClient.createWorkspaceBuild(workspace.id, buildRequest).execute()
209209
if (buildResponse.code() != HttpURLConnection.HTTP_CREATED) {
210210
throw WorkspaceResponseException(error("stop workspace ${workspace.name}", buildResponse))
@@ -226,7 +226,7 @@ open class BaseCoderRestClient(
226226
val template = template(workspace.templateID)
227227

228228
val buildRequest =
229-
CreateWorkspaceBuildRequest(template.activeVersionID, WorkspaceTransition.START, null, null, null, null)
229+
CreateWorkspaceBuildRequest(template.activeVersionID, WorkspaceTransition.START)
230230
val buildResponse = retroRestClient.createWorkspaceBuild(workspace.id, buildRequest).execute()
231231
if (buildResponse.code() != HttpURLConnection.HTTP_CREATED) {
232232
throw WorkspaceResponseException(error("update workspace ${workspace.name}", buildResponse))

src/main/kotlin/com/coder/gateway/sdk/v2/models/BuildReason.kt

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/main/kotlin/com/coder/gateway/sdk/v2/models/CreateParameterRequest.kt

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/main/kotlin/com/coder/gateway/sdk/v2/models/CreateWorkspaceBuildRequest.kt

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@ import com.squareup.moshi.Json
44
import java.util.UUID
55

66
data class CreateWorkspaceBuildRequest(
7+
// Use to update the workspace to a new template version.
78
@Json(name = "template_version_id") val templateVersionID: UUID?,
9+
// Use to start and stop the workspace.
810
@Json(name = "transition") val transition: WorkspaceTransition,
9-
@Json(name = "dry_run") val dryRun: Boolean?,
10-
@Json(name = "state") val provisionerState: Array<Byte>?,
11-
// Orphan may be set for the Destroy transition.
12-
@Json(name = "orphan") val orphan: Boolean?,
13-
@Json(name = "parameter_values") val parameterValues: Array<CreateParameterRequest>?
1411
) {
1512
override fun equals(other: Any?): Boolean {
1613
if (this === other) return true
@@ -20,27 +17,13 @@ data class CreateWorkspaceBuildRequest(
2017

2118
if (templateVersionID != other.templateVersionID) return false
2219
if (transition != other.transition) return false
23-
if (dryRun != other.dryRun) return false
24-
if (provisionerState != null) {
25-
if (other.provisionerState == null) return false
26-
if (!provisionerState.contentEquals(other.provisionerState)) return false
27-
} else if (other.provisionerState != null) return false
28-
if (orphan != other.orphan) return false
29-
if (parameterValues != null) {
30-
if (other.parameterValues == null) return false
31-
if (!parameterValues.contentEquals(other.parameterValues)) return false
32-
} else if (other.parameterValues != null) return false
3320

3421
return true
3522
}
3623

3724
override fun hashCode(): Int {
3825
var result = templateVersionID?.hashCode() ?: 0
3926
result = 31 * result + transition.hashCode()
40-
result = 31 * result + (dryRun?.hashCode() ?: 0)
41-
result = 31 * result + (provisionerState?.contentHashCode() ?: 0)
42-
result = 31 * result + (orphan?.hashCode() ?: 0)
43-
result = 31 * result + (parameterValues?.contentHashCode() ?: 0)
4427
return result
4528
}
4629
}

src/main/kotlin/com/coder/gateway/sdk/v2/models/ProvisionerJob.kt

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/main/kotlin/com/coder/gateway/sdk/v2/models/Role.kt

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,9 @@
11
package com.coder.gateway.sdk.v2.models
22

33
import com.squareup.moshi.Json
4-
import java.time.Instant
54
import java.util.UUID
65

76
data class Template(
87
@Json(name = "id") val id: UUID,
9-
@Json(name = "created_at") val createdAt: Instant,
10-
@Json(name = "updated_at") val updatedAt: Instant,
11-
@Json(name = "organization_id") val organizationIterator: UUID,
12-
@Json(name = "name") val name: String,
13-
@Json(name = "display_name") val displayName: String,
14-
@Json(name = "provisioner") val provisioner: ProvisionerType,
158
@Json(name = "active_version_id") val activeVersionID: UUID,
16-
@Json(name = "workspace_owner_count") val workspaceOwnerCount: Int,
17-
@Json(name = "active_user_count") val activeUserCount: Int,
18-
@Json(name = "build_time_stats") val buildTimeStats: Map<WorkspaceTransition, TransitionStats>,
19-
@Json(name = "description") val description: String,
20-
@Json(name = "icon") val icon: String,
21-
@Json(name = "default_ttl_ms") val defaultTTLMillis: Long,
22-
@Json(name = "created_by_id") val createdByID: UUID,
23-
@Json(name = "created_by_name") val createdByName: String,
24-
@Json(name = "allow_user_cancel_workspace_jobs") val allowUserCancelWorkspaceJobs: Boolean,
259
)
26-
27-
enum class ProvisionerType {
28-
@Json(name = "echo") ECHO,
29-
@Json(name = "terraform") TERRAFORM
30-
}
31-
32-
data class TransitionStats(val p50: Long, val p95: Long)
Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,7 @@
11
package com.coder.gateway.sdk.v2.models
22

33
import com.squareup.moshi.Json
4-
import java.time.Instant
5-
import java.util.UUID
64

75
data class User(
8-
@Json(name = "id") val id: UUID,
96
@Json(name = "username") val username: String,
10-
@Json(name = "email") val email: String,
11-
@Json(name = "created_at") val createdAt: Instant,
12-
@Json(name = "last_seen_at") val lastSeenAt: Instant,
13-
14-
@Json(name = "status") val status: UserStatus,
15-
@Json(name = "organization_ids") val organizationIDs: List<UUID>,
16-
@Json(name = "roles") val roles: List<Role>?,
17-
@Json(name = "avatar_url") val avatarURL: String,
187
)
19-
20-
enum class UserStatus {
21-
@Json(name = "active") ACTIVE,
22-
@Json(name = "suspended") SUSPENDED
23-
}

src/main/kotlin/com/coder/gateway/sdk/v2/models/Workspace.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,20 @@ package com.coder.gateway.sdk.v2.models
22

33
import com.coder.gateway.models.WorkspaceAgentListModel
44
import com.squareup.moshi.Json
5-
import java.time.Instant
65
import java.util.*
76

87
/**
98
* Represents a deployment of a template. It references a specific version and can be updated.
109
*/
1110
data class Workspace(
1211
@Json(name = "id") val id: UUID,
13-
@Json(name = "created_at") val createdAt: Instant,
14-
@Json(name = "updated_at") val updatedAt: Instant,
15-
@Json(name = "owner_id") val ownerID: UUID,
16-
@Json(name = "owner_name") val ownerName: String,
1712
@Json(name = "template_id") val templateID: UUID,
1813
@Json(name = "template_name") val templateName: String,
1914
@Json(name = "template_display_name") val templateDisplayName: String,
2015
@Json(name = "template_icon") val templateIcon: String,
21-
@Json(name = "template_allow_user_cancel_workspace_jobs") val templateAllowUserCancelWorkspaceJobs: Boolean,
2216
@Json(name = "latest_build") val latestBuild: WorkspaceBuild,
2317
@Json(name = "outdated") val outdated: Boolean,
2418
@Json(name = "name") val name: String,
25-
@Json(name = "autostart_schedule") val autostartSchedule: String?,
26-
@Json(name = "ttl_ms") val ttlMillis: Long?,
27-
@Json(name = "last_used_at") val lastUsedAt: Instant,
2819
)
2920

3021
/**

src/main/kotlin/com/coder/gateway/sdk/v2/models/WorkspaceAgent.kt

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,16 @@ package com.coder.gateway.sdk.v2.models
33
import com.coder.gateway.util.Arch
44
import com.coder.gateway.util.OS
55
import com.squareup.moshi.Json
6-
import java.time.Instant
76
import java.util.*
87

98
data class WorkspaceAgent(
109
@Json(name = "id") val id: UUID,
11-
@Json(name = "created_at") val createdAt: Instant,
12-
@Json(name = "updated_at") val updatedAt: Instant,
13-
@Json(name = "first_connected_at") val firstConnectedAt: Instant?,
14-
@Json(name = "last_connected_at") val lastConnectedAt: Instant?,
15-
@Json(name = "disconnected_at") val disconnectedAt: Instant?,
1610
@Json(name = "status") val status: WorkspaceAgentStatus,
1711
@Json(name = "name") val name: String,
18-
@Json(name = "resource_id") val resourceID: UUID,
19-
@Json(name = "instance_id") val instanceID: String?,
2012
@Json(name = "architecture") val architecture: Arch?,
21-
@Json(name = "environment_variables") val envVariables: Map<String, String>,
2213
@Json(name = "operating_system") val operatingSystem: OS?,
23-
@Json(name = "startup_script") val startupScript: String?,
2414
@Json(name = "directory") val directory: String?,
2515
@Json(name = "expanded_directory") val expandedDirectory: String?,
26-
@Json(name = "version") val version: String,
27-
@Json(name = "apps") val apps: List<WorkspaceApp>,
28-
@Json(name = "latency") val derpLatency: Map<String, DERPRegion>?,
29-
@Json(name = "connection_timeout_seconds") val connectionTimeoutSeconds: Int,
30-
@Json(name = "troubleshooting_url") val troubleshootingURL: String,
3116
@Json(name = "lifecycle_state") val lifecycleState: WorkspaceAgentLifecycleState,
3217
@Json(name = "login_before_ready") val loginBeforeReady: Boolean?,
3318
)
@@ -50,8 +35,3 @@ enum class WorkspaceAgentLifecycleState {
5035
@Json(name = "shutdown_error") SHUTDOWN_ERROR,
5136
@Json(name = "off") OFF,
5237
}
53-
54-
data class DERPRegion(
55-
@Json(name = "preferred") val preferred: Boolean,
56-
@Json(name = "latency_ms") val latencyMillis: Double,
57-
)

src/main/kotlin/com/coder/gateway/sdk/v2/models/WorkspaceApp.kt

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/main/kotlin/com/coder/gateway/sdk/v2/models/WorkspaceBuild.kt

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,16 @@
11
package com.coder.gateway.sdk.v2.models
22

33
import com.squareup.moshi.Json
4-
import java.time.Instant
54
import java.util.UUID
65

76
/**
87
* WorkspaceBuild is an at-point representation of a workspace state.
98
* BuildNumbers start at 1 and increase by 1 for each subsequent build.
109
*/
1110
data class WorkspaceBuild(
12-
@Json(name = "id") val id: UUID,
13-
@Json(name = "created_at") val createdAt: Instant,
14-
@Json(name = "updated_at") val updatedAt: Instant,
15-
@Json(name = "workspace_id") val workspaceID: UUID,
16-
@Json(name = "workspace_name") val workspaceName: String,
17-
@Json(name = "workspace_owner_id") val workspaceOwnerID: UUID,
18-
@Json(name = "workspace_owner_name") val workspaceOwnerName: String,
1911
@Json(name = "template_version_id") val templateVersionID: UUID,
20-
@Json(name = "build_number") val buildNumber: Int,
21-
@Json(name = "transition") val transition: WorkspaceTransition,
22-
@Json(name = "initiator_id") val initiatorID: UUID,
23-
@Json(name = "initiator_name") val initiatorUsername: String,
24-
@Json(name = "job") val job: ProvisionerJob,
25-
@Json(name = "reason") val reason: BuildReason,
2612
@Json(name = "resources") val resources: List<WorkspaceResource>,
27-
@Json(name = "deadline") val deadline: Instant?,
2813
@Json(name = "status") val status: WorkspaceStatus,
29-
@Json(name = "daily_cost") val dailyCost: Int,
3014
)
3115

3216
enum class WorkspaceStatus {
Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
11
package com.coder.gateway.sdk.v2.models
22

33
import com.squareup.moshi.Json
4-
import java.time.Instant
5-
import java.util.UUID
64

75
data class WorkspaceResource(
8-
@Json(name = "id") val id: UUID,
9-
@Json(name = "created_at") val createdAt: Instant,
10-
@Json(name = "job_id") val jobID: UUID,
11-
@Json(name = "workspace_transition") val workspaceTransition: WorkspaceTransition,
12-
@Json(name = "type") val type: String,
13-
@Json(name = "name") val name: String,
14-
@Json(name = "hide") val hide: Boolean,
15-
@Json(name = "icon") val icon: String,
166
@Json(name = "agents") val agents: List<WorkspaceAgent>?,
17-
@Json(name = "metadata") val metadata: List<WorkspaceResourceMetadata>?,
18-
@Json(name = "daily_cost") val dailyCost: Int
197
)

src/main/kotlin/com/coder/gateway/sdk/v2/models/WorkspaceResourceMetadata.kt

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)