Skip to content

Commit

Permalink
Add codespace support (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
razor-x authored Oct 11, 2023
1 parent 67e847b commit 1757223
Show file tree
Hide file tree
Showing 14 changed files with 144 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
ARG VARIANT="18"

FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:${VARIANT}

RUN apt-get update

# Install Python
RUN apt-get install -y python3 python3-pip python-is-python3

# Install Ruby
RUN apt-get install -y ruby ruby-dev

RUN gem install seamapi
RUN pip install seamapi --break-system-packages

USER node
WORKDIR /home/node

# Install dotnet
RUN wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh \
&& chmod +x dotnet-install.sh \
&& ./dotnet-install.sh --channel 7.0
ENV PATH="$PATH:/home/node/.dotnet"

RUN mkdir -p .config/git \
&& echo ".vscode/*" >> .config/git/ignore \
&& echo "*.code-workspace" >> .config/git/ignore \
&& echo ".history/" >> .config/git/ignore
24 changes: 24 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "API Docs",
"build": {
"dockerfile": "Dockerfile",
"args": {
"VARIANT": "18"
}
},
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"rebornix.Ruby",
"ms-dotnettools.csharp",
"ms-vsliveshare.vsliveshare",
"dbaeumer.vscode-eslint",
"EditorConfig.EditorConfig",
"esbenp.prettier-vscode"
]
}
},
"postCreateCommand": "cd /workspaces/api-docs/snippet-playground/javascript && npm i seamapi && cd /workspaces/api-docs/snippet-playground/csharp && ./init.sh",
"remoteUser": "node"
}
9 changes: 9 additions & 0 deletions snippet-playground/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
5 changes: 5 additions & 0 deletions snippet-playground/csharp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!.gitignore
!README.md
!Program.cs
!init.sh
19 changes: 19 additions & 0 deletions snippet-playground/csharp/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Seam.Client;

var r = new string(Enumerable.Range(0, 10).Select(_ => "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[new Random().Next(36)]).ToArray());


// Get a Seam Client
var seam = new SeamClient(
basePath: string.Format("https://{0}.fakeseamconnect.seam.vc", r),
apiToken: "seam_apikey1_token"
);

var devices = seam.Devices.List();

foreach (var device in devices)
{
// NOTE: in the future Console.WriteLine(device) will print
// something pretty, but currently it doesn't print pretty
Console.WriteLine(device.Properties.Name);
}
3 changes: 3 additions & 0 deletions snippet-playground/csharp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Running C#

Just run `dotnet run`, the `Program.cs` file will be run
9 changes: 9 additions & 0 deletions snippet-playground/csharp/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env sh

set -e
set -u

mv Program.cs Program.cs.bak
dotnet new console --force
dotnet add package seam
mv Program.cs.bak Program.cs
4 changes: 4 additions & 0 deletions snippet-playground/javascript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
!.gitignore
!README.md
!main.mjs
3 changes: 3 additions & 0 deletions snippet-playground/javascript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Running Javascript

Just run `node main.mjs`
12 changes: 12 additions & 0 deletions snippet-playground/javascript/main.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env node

import Seam from "seamapi"

const seam = new Seam({
endpoint: `https://r${Math.random()
.toString(16)
.slice(2)}.fakeseamconnect.seam.vc`,
apiKey: "seam_apikey1_token",
})

console.log(await seam.devices.list())
3 changes: 3 additions & 0 deletions snippet-playground/python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Running Python

Just run `python main.py`
12 changes: 12 additions & 0 deletions snippet-playground/python/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env python

import random
from seamapi import Seam
from pprint import pprint

seam = Seam(
api_url=f"https://pws{random.randint(0,1e6)}{random.randint(0,1e6)}.fakeseamconnect.seam.vc",
api_key="seam_apikey1_token"
)

pprint(seam.devices.list())
3 changes: 3 additions & 0 deletions snippet-playground/ruby/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Running Ruby

Just run `ruby main.rb`
10 changes: 10 additions & 0 deletions snippet-playground/ruby/main.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env ruby

require 'seamapi'

random_number = rand(1e6).to_i
api_url = "https://pws#{random_number}#{random_number}.fakeseamconnect.seam.vc"

client = Seam::Client.new(base_uri: api_url, api_key: 'seam_apikey1_token')

print client.devices.list

0 comments on commit 1757223

Please sign in to comment.