File tree 3 files changed +20
-1
lines changed
src/main/kotlin/com/coder/gateway
3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change
1
+ package com.coder.gateway.models
2
+
3
+ import com.google.gson.annotations.SerializedName
4
+
5
+ data class SSHKeys (@SerializedName(" public_key" ) val publicKey : String , @SerializedName(" private_key" ) val privateKey : String )
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package com.coder.gateway.sdk
2
2
3
3
import com.coder.gateway.models.UriScheme
4
4
import com.coder.gateway.models.User
5
+ import com.coder.gateway.models.SSHKeys
5
6
import com.coder.gateway.models.Workspace
6
7
import com.coder.gateway.sdk.ex.AuthenticationException
7
8
import com.google.gson.Gson
@@ -66,6 +67,14 @@ class CoderClientService {
66
67
}
67
68
68
69
return workspacesResponse.body()!!
70
+ }
71
+
72
+ fun userSSHKeys (): SSHKeys {
73
+ val sshKeysResponse = retroRestClient.sshKeys(sessionToken, me.id).execute()
74
+ if (! sshKeysResponse.isSuccessful) {
75
+ throw IllegalStateException (" Could not retrieve Coder Workspaces:${sshKeysResponse.code()} , reason: ${sshKeysResponse.message()} " )
76
+ }
69
77
78
+ return sshKeysResponse.body()!!
70
79
}
71
- }
80
+ }
Original file line number Diff line number Diff line change 1
1
package com.coder.gateway.sdk
2
2
3
3
import com.coder.gateway.models.User
4
+ import com.coder.gateway.models.SSHKeys
4
5
import com.coder.gateway.models.Workspace
5
6
import retrofit2.Call
6
7
import retrofit2.http.Body
7
8
import retrofit2.http.GET
8
9
import retrofit2.http.Header
9
10
import retrofit2.http.POST
11
+ import retrofit2.http.Path
10
12
import retrofit2.http.Query
11
13
12
14
@@ -20,4 +22,7 @@ interface CoderRestService {
20
22
21
23
@GET(" api/v0/workspaces" )
22
24
fun workspaces (@Header(" Session-Token" ) sessionToken : String , @Query(" users" ) users : String ): Call <List <Workspace >>
25
+
26
+ @GET(" api/v0/users/{userId}/sshkey" )
27
+ fun sshKeys (@Header(" Session-Token" ) sessionToken : String , @Path(" userId" ) userID : String ): Call <SSHKeys >
23
28
}
You can’t perform that action at this time.
0 commit comments