code.oscarkilo.com/klex-git/api/datasets.go

..
api.go
datasets.go
f.go
funcs.go
messages.go
pipelines.go
worker.go
package api

type NewDatasetRequest struct {
  Name string `json:"name"`  // no need to be unique
  Data []string `json:"data"`
}

type NewDatasetResponse struct {
  Name string `json:"name"`
  DateCreated string `json:"date_created"`  // RFC8601 with millis
  Size int `json:"size"`
}

type RenameDatasetRequest struct {
  OldName string `json:"old_name"`
  NewName string `json:"new_name"`
}

type DeleteDatasetRequest struct {
  Name string `json:"name"`
}

type DatasetVersion struct {
  Key string `json:"key"`
  Size int `json:"size"`
  Date string `json:"date"`
}

type Dataset struct {
  Name string `json:"name"`
  OwnerOwid string `json:"owner_owid"`
  OwnerUsername string `json:"owner_username"`
  ReaderOwid string `json:"reader_owid"`
  ReaderUsername string `json:"reader_username"`
  Versions []DatasetVersion `json:"versions"`
}

type ListDatasetsResponse struct {
  Datasets []Dataset `json:"datasets"`
}

type KV struct {
  Key string `json:"k"`
  Value string `json:"v"`
}

type GetDatasetResponse struct {
  DatasetVersion DatasetVersion `json:"dataset_version"`
  Records []KV `json:"records"`
}

// BeginNewDatasetRequest is for the new API for uploading datasets.
// It's meant to work for huge datasets as well as small ones.
// The flow goes like this:
// 1. Call /klex/datasets/begin_new and get a version key.
// 2. Repeatedly call /klex/datasets/upload_kv with chunks of data.
// 3. Call /klex/datasets/end_new to commit and name the dataset.
type BeginNewDatasetRequest struct {
  Name string `json:"name"`
}

type BeginNewDatasetResponse struct {
  VersionKey string `json:"version_key"`
}

// UploadKVRequest is for uploading some of the kv-pairs of a new dataset.
type UploadKVRequest struct {
  VersionKey string `json:"version_key"`
  Records []KV `json:"records"`
}

type EndNewDatasetRequest struct {
  Name string `json:"name"`
  VersionKey string `json:"version_key"`
  Size int `json:"size"`
}