@@ -69,17 +69,18 @@ We'll only be shown this access key once, so we'll need to store it somewhere sa
6969
7070SE2 provides client libraries for Go and Node.js. Start by installing the client:
7171
72- <Tabs groupId =" tenant-creation " >
72+ <Tabs groupId =" sdk-import " >
7373
74- <TabItem value =" tenant-go " label =" Using Go " >
74+ <TabItem value =" sdk-go " label =" Using Go " >
75+ In your terminal issue the following command to grab the library.
7576
76- ``` go
77- Go version goes here
77+ ``` sh
78+ $ go get github.com/suborbital/se2-go@latest
7879```
7980
8081</TabItem >
8182
82- <TabItem value = " tenant -js" label = " Using JS " >
83+ <TabItem value = " sdk -js" label = " Using JS " >
8384
8485``` js
8586JS version goes here
@@ -91,36 +92,35 @@ JS version goes here
9192
9293Next, initialize the client with your environment access key:
9394
94- <Tabs groupId =" tenant-creation " >
95+ <Tabs groupId =" sdk-init " >
9596
96- <TabItem value =" tenant -go" label =" Using Go " >
97+ <TabItem value =" sdk-init -go" label =" Using Go " >
9798
9899``` go
99- Go version goes here
100- ```
100+ package main
101101
102- </TabItem >
102+ import (
103+ " log"
103104
104- <TabItem value = " tenant-js " label = " Using JS " >
105+ " github.com/suborbital/se2-go"
106+ )
105107
106- ``` js
107- JS version goes here
108+ func main () {
109+ client , err := se2.NewClient (se2.ModeStaging , token)
110+ if err != nil {
111+ log.Fatalf (" encountered new client error: %s " , err.Error ())
112+ }
113+
114+ // client is now ready to use
115+ }
108116```
109117
110118</TabItem >
111119
112- <TabItem value = " tenant-curl " label = " Using cURL " >
113-
114- ``` bash
115- POST api/v1/tenant HTTP/2
116- Host: api.suborbital.network
117- Content-Type: application/json
118- Authorization: Bearer OUR_ACCESS_KEY
120+ <TabItem value = " tenant-js " label = " Using JS " >
119121
120- {
121- " name" : " org.example.tenvantx" ,
122- " description" : " hello world tenant"
123- }
122+ ``` js
123+ JS version goes here
124124```
125125
126126</TabItem >
@@ -138,7 +138,12 @@ To create a tenant, we'll make an `HTTP POST` call:
138138<TabItem value =" tenant-go " label =" Using Go " >
139139
140140``` go
141- Go version goes here
141+ func main () {
142+ tenant , err := client.CreateTenant (ctx, " tenantName" , " tenantDescription" )
143+ if err != nil {
144+ log.Fatalf (" create tenant failed: %s " , err.Error ())
145+ }
146+ }
142147```
143148
144149</TabItem >
@@ -180,9 +185,21 @@ In addition to the `IDENTIFIER` and `ENV_TOKEN`, you’ll also need to set `NAME
180185<Tabs groupId =' editor-token ' >
181186
182187<TabItem value =" go " label =" Using Go " >
188+ Call the ` CreateSession ` method with your tenant's name, the namespace, and the plugin name of your intended plugin. The response is going to be a struct that contains the session token. All methods will use this session response struct as input.
183189
184190``` go
185- Go version goes here
191+ func main () {
192+ session , err := client.CreateSession (ctx, " tenantName" , " namespace" , " pluginName" )
193+ if err != nil {
194+ log.Fatalf (" creating session failed with %s " , err.Error ())
195+ }
196+
197+ // To use the session token in a further call
198+ draft , err := client.CreatePluginDraft (ctx, " javascript" , session)
199+ if err != nil {
200+ log.Fatalf (" creating plugin draft for javascript failed: %s " , err.Error ())
201+ }
202+ }
186203```
187204
188205</TabItem >
0 commit comments