Skip to content

Commit

Permalink
Add go client init docs and a few examples (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
javorszky authored Mar 14, 2023
1 parent a5f1f43 commit 11eb486
Showing 1 changed file with 43 additions and 26 deletions.
69 changes: 43 additions & 26 deletions website/docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,18 @@ We'll only be shown this access key once, so we'll need to store it somewhere sa

SE2 provides client libraries for Go and Node.js. Start by installing the client:

<Tabs groupId="tenant-creation">
<Tabs groupId="sdk-import">

<TabItem value="tenant-go" label="Using Go">
<TabItem value="sdk-go" label="Using Go">
In your terminal issue the following command to grab the library.

```go
Go version goes here
```sh
$ go get github.com/suborbital/se2-go@latest
```

</TabItem>

<TabItem value = "tenant-js" label = "Using JS">
<TabItem value = "sdk-js" label = "Using JS">

```js
JS version goes here
Expand All @@ -91,36 +92,35 @@ JS version goes here

Next, initialize the client with your environment access key:

<Tabs groupId="tenant-creation">
<Tabs groupId="sdk-init">

<TabItem value="tenant-go" label="Using Go">
<TabItem value="sdk-init-go" label="Using Go">

```go
Go version goes here
```
package main

</TabItem>
import (
"log"

<TabItem value = "tenant-js" label = "Using JS">
"github.com/suborbital/se2-go"
)

```js
JS version goes here
func main() {
client, err := se2.NewClient(se2.ModeStaging, token)
if err != nil {
log.Fatalf("encountered new client error: %s", err.Error())
}

// client is now ready to use
}
```

</TabItem>

<TabItem value = "tenant-curl" label = "Using cURL">

```bash
POST api/v1/tenant HTTP/2
Host: api.suborbital.network
Content-Type: application/json
Authorization: Bearer OUR_ACCESS_KEY
<TabItem value = "tenant-js" label = "Using JS">

{
"name": "org.example.tenvantx",
"description": "hello world tenant"
}
```js
JS version goes here
```

</TabItem>
Expand All @@ -138,7 +138,12 @@ To create a tenant, we'll make an `HTTP POST` call:
<TabItem value="tenant-go" label="Using Go">

```go
Go version goes here
func main() {
tenant, err := client.CreateTenant(ctx, "tenantName", "tenantDescription")
if err != nil {
log.Fatalf("create tenant failed: %s", err.Error())
}
}
```

</TabItem>
Expand Down Expand Up @@ -180,9 +185,21 @@ In addition to the `IDENTIFIER` and `ENV_TOKEN`, you’ll also need to set `NAME
<Tabs groupId='editor-token'>

<TabItem value="go" label="Using Go">
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.

```go
Go version goes here
func main() {
session, err := client.CreateSession(ctx, "tenantName", "namespace", "pluginName")
if err != nil {
log.Fatalf("creating session failed with %s", err.Error())
}

// To use the session token in a further call
draft, err := client.CreatePluginDraft(ctx, "javascript", session)
if err != nil {
log.Fatalf("creating plugin draft for javascript failed: %s", err.Error())
}
}
```

</TabItem>
Expand Down

1 comment on commit 11eb486

@vercel
Copy link

@vercel vercel bot commented on 11eb486 Mar 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.