Skip to content

CS4091-Capstone-II-Team-13/StrataSDK

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StrataSDK

Go HTTP client SDK for the Strata Server. Covers every endpoint and compiles to either a standalone binary (for subprocess IPC from C++) or a shared/static library (for direct cgo linking).

Files

File Purpose
client.go Core HTTP client — all API methods
main.go CLI entry point (binary mode)
cexport.go cgo C export layer (library mode)
stratasdk.h C/C++ header with full RAII wrapper
build.go Build script for all targets

Build

# All targets at once:
go run build.go all

# Or individually:
go run build.go binary   # → dist/stratasdk or dist/stratasdk.exe
go run build.go shared   # → dist/libstrata.so + dist/stratasdk.h or dist/libstrata.dll + dist/stratasdk.
go run build.go static   # → dist/libstrata.a  + dist/stratasdk.h or dist/libstrata.lib  + dist/stratasdk.h

Endpoints Covered

Auth

Method Path CLI C API
GET /health health strataHealth()
POST /api/v1/auth/register register strataRegister()
POST /api/v1/auth/login login strataLogin()
POST /api/v1/auth/refresh refresh strataRefresh()
POST /api/v1/auth/logout logout strataLogout()

Projects

Method Path CLI C API
POST /api/v1/projects/ project:create strataProjectCreate()
GET /api/v1/projects/ project:list strataProjectList()
GET /api/v1/projects/{id}/ project:get strataProjectGet()
DELETE /api/v1/projects/{id}/ project:delete strataProjectDelete()

Push

Method Path CLI C API
POST /api/v1/projects/{id}/push/check push:check strataPushCheckChunks()
POST /api/v1/projects/{id}/push/chunk push:chunk strataPushUploadChunk()
POST /api/v1/projects/{id}/push/commit push:commit strataPushCommit()

Pull

Method Path CLI C API
POST /api/v1/projects/{id}/pull/diff pull:diff strataPullDiff()
GET /api/v1/projects/{id}/pull/chunk/{hash} pull:chunk strataPullDownloadChunk()

Version / Refs

Method Path CLI C API
GET /api/v1/projects/{id}/refs refs strataListRefs()
GET /api/v1/projects/{id}/commits commits strataListCommits()
GET /api/v1/projects/{id}/commits/{cid} commit:get strataGetCommit()
GET /api/v1/projects/{id}/commits/{cid}/files commit:files strataListCommitFiles()
GET /api/v1/projects/{id}/tree tree strataGetTree()

Branches / Merge

Method Path CLI C API
POST /api/v1/projects/{id}/branches branch:create strataCreateBranch()
POST /api/v1/projects/{id}/merge/analyze merge:analyze strataMergeAnalyze()
POST /api/v1/projects/{id}/merge merge:execute strataMergeExecute()

Locks

Method Path CLI C API
GET /api/v1/projects/{id}/locks/ lock:list strataLockList()
POST /api/v1/projects/{id}/locks/ lock:acquire strataLockAcquire()
DELETE /api/v1/projects/{id}/locks/ lock:release strataLockRelease()

Usage — Binary mode (subprocess IPC from C++)

export STRATA_TOKEN="eyJ..."
export STRATA_REFRESH_TOKEN="eyJ..."

./stratasdk https://strata-api.themrdt.org health
./stratasdk https://strata-api.themrdt.org login myuser mypass
./stratasdk https://strata-api.themrdt.org project:list
./stratasdk https://strata-api.themrdt.org refs myprojectid
./stratasdk https://strata-api.themrdt.org push:check myprojectid "hash1,hash2"
./stratasdk https://strata-api.themrdt.org push:chunk myprojectid hash1 /path/to/chunk.bin
./stratasdk https://strata-api.themrdt.org push:commit myprojectid commit_body.json
./stratasdk https://strata-api.themrdt.org pull:diff myprojectid diff_request.json
./stratasdk https://strata-api.themrdt.org pull:chunk myprojectid hash1 /tmp/out.bin

All output is JSON on stdout. Errors are JSON on stderr with exit code 1.

Usage — Library mode (direct C++ linking)

#include "stratasdk.h"

// C++ RAII wrapper (throws strata::StrataError on failure):
strata::Client c("https://strata-api.themrdt.org");
std::string tokens = c.login("user", "pass");
std::string refs   = c.listRefs("my-project-id");

// Or raw C API:
strataInit("https://strata-api.themrdt.org");
char* result = strataLogin("user", "pass");
if (!result) {
    char* err = strataLastError();
    fprintf(stderr, "Error: %s\n", err);
    strataFree(err);
} else {
    printf("%s\n", result);
    strataFree(result);
}

Notes

  • strataLogin() / strataRefresh() automatically store tokens in the global client state — you don't need to call strataSetToken() after a successful login.
  • strataPullDownloadChunk() returns raw bytes (not JSON). Free the pointer with strataFree().
  • strataPushUploadChunk() takes raw bytes directly — no base64 encoding needed.
  • The HTTP client timeout is 10 minutes to accommodate large chunk transfers.
  • All functions are thread-safe on the token read/write path via sync.RWMutex.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors