2022-09-30 00:18:15 -05:00
|
|
|
syntax = "proto3";
|
|
|
|
package object;
|
|
|
|
|
|
|
|
option go_package = "./;object";
|
|
|
|
|
2022-10-31 09:26:16 -05:00
|
|
|
message GRN {
|
|
|
|
// the tenant/org id
|
|
|
|
int64 tenant_id = 1;
|
|
|
|
|
2022-09-30 00:18:15 -05:00
|
|
|
// Identify the object kind. This kind will be used to apply a schema to the body and
|
|
|
|
// will trigger additional indexing behavior.
|
2022-10-31 09:26:16 -05:00
|
|
|
string kind = 3;
|
|
|
|
|
|
|
|
// Unique ID
|
2022-11-30 14:10:35 -06:00
|
|
|
// 40 characters or less, no slashes or other special characters
|
2022-10-31 09:26:16 -05:00
|
|
|
string UID = 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The canonical object/document data -- this represents the raw bytes and storage level metadata
|
|
|
|
message RawObject {
|
|
|
|
// Object identifier
|
|
|
|
GRN GRN = 1;
|
2022-09-30 00:18:15 -05:00
|
|
|
|
|
|
|
// Time in epoch milliseconds that the object was created
|
2022-11-08 16:42:32 -06:00
|
|
|
int64 created_at = 2;
|
2022-09-30 00:18:15 -05:00
|
|
|
|
2022-10-05 13:58:46 -05:00
|
|
|
// Time in epoch milliseconds that the object was updated
|
2022-11-08 16:42:32 -06:00
|
|
|
int64 updated_at = 3;
|
2022-09-30 00:18:15 -05:00
|
|
|
|
|
|
|
// Who created the object
|
2022-10-31 09:26:16 -05:00
|
|
|
string created_by = 4;
|
2022-09-30 00:18:15 -05:00
|
|
|
|
2022-10-05 13:58:46 -05:00
|
|
|
// Who updated the object
|
2022-10-31 09:26:16 -05:00
|
|
|
string updated_by = 5;
|
2022-09-30 00:18:15 -05:00
|
|
|
|
|
|
|
// Content Length
|
2022-10-31 09:26:16 -05:00
|
|
|
int64 size = 6;
|
2022-09-30 00:18:15 -05:00
|
|
|
|
|
|
|
// MD5 digest of the body
|
2022-10-31 09:26:16 -05:00
|
|
|
string ETag = 7;
|
2022-09-30 00:18:15 -05:00
|
|
|
|
|
|
|
// Raw bytes of the storage object. The kind will determine what is a valid payload
|
2022-10-31 09:26:16 -05:00
|
|
|
bytes body = 8;
|
2022-09-30 00:18:15 -05:00
|
|
|
|
2022-11-30 14:10:35 -06:00
|
|
|
// Folder UID
|
|
|
|
string folder = 9;
|
|
|
|
|
|
|
|
// Unique slug within folder (may be UID)
|
|
|
|
string slug = 10;
|
|
|
|
|
2022-09-30 00:18:15 -05:00
|
|
|
// The version will change when the object is saved. It is not necessarily sortable
|
|
|
|
//
|
|
|
|
// NOTE: currently managed by the dashboard+dashboard_version tables
|
2022-11-30 14:10:35 -06:00
|
|
|
string version = 11;
|
2022-09-30 00:18:15 -05:00
|
|
|
|
2022-10-06 14:48:53 -05:00
|
|
|
// External location info
|
2022-11-30 14:10:35 -06:00
|
|
|
ObjectOriginInfo origin = 12;
|
2022-10-06 14:48:53 -05:00
|
|
|
}
|
|
|
|
|
2022-11-12 13:36:18 -06:00
|
|
|
message ObjectOriginInfo {
|
2022-09-30 00:18:15 -05:00
|
|
|
// NOTE: currently managed by the dashboard_provisioning table
|
2022-10-31 09:26:16 -05:00
|
|
|
string source = 1;
|
2022-09-30 00:18:15 -05:00
|
|
|
|
2022-11-30 14:10:35 -06:00
|
|
|
// Key in the upstream system
|
|
|
|
string key = 2;
|
|
|
|
|
2022-09-30 00:18:15 -05:00
|
|
|
// Time in epoch milliseconds that the object was last synced with an external system (provisioning/git)
|
2022-11-30 14:10:35 -06:00
|
|
|
int64 time = 3;
|
2022-09-30 00:18:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Report error while working with objects
|
|
|
|
// NOTE: real systems at scale will contain errors.
|
|
|
|
message ObjectErrorInfo {
|
|
|
|
// Match an error code registry?
|
|
|
|
int64 code = 1;
|
|
|
|
|
|
|
|
// Simple error display
|
|
|
|
string message = 2;
|
|
|
|
|
|
|
|
// Details encoded in JSON
|
|
|
|
bytes details_json = 3;
|
|
|
|
}
|
|
|
|
|
2022-10-04 13:57:26 -05:00
|
|
|
// This is a subset of RawObject that does not include body or sync info
|
|
|
|
message ObjectVersionInfo {
|
|
|
|
// The version will change when the object is saved. It is not necessarily sortable
|
|
|
|
string version = 1;
|
|
|
|
|
2022-10-05 13:58:46 -05:00
|
|
|
// Time in epoch milliseconds that the object was updated
|
2022-11-08 16:42:32 -06:00
|
|
|
int64 updated_at = 2;
|
2022-10-04 13:57:26 -05:00
|
|
|
|
2022-10-05 13:58:46 -05:00
|
|
|
// Who updated the object
|
2022-10-05 20:46:17 -05:00
|
|
|
string updated_by = 3;
|
2022-10-04 13:57:26 -05:00
|
|
|
|
|
|
|
// Content Length
|
|
|
|
int64 size = 4;
|
|
|
|
|
|
|
|
// MD5 digest of the body
|
|
|
|
string ETag = 5;
|
|
|
|
|
|
|
|
// optional "save" or "commit" message
|
|
|
|
//
|
|
|
|
// NOTE: currently managed by the dashboard_version table, and will be returned from a "history" command
|
|
|
|
string comment = 6;
|
|
|
|
}
|
|
|
|
|
2022-09-30 00:18:15 -05:00
|
|
|
//-----------------------------------------------
|
|
|
|
// Get request/response
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
|
|
|
message ReadObjectRequest {
|
2022-10-31 09:26:16 -05:00
|
|
|
// Object identifier
|
|
|
|
GRN GRN = 1;
|
2022-09-30 00:18:15 -05:00
|
|
|
|
|
|
|
// Fetch an explicit version
|
2022-10-31 09:26:16 -05:00
|
|
|
string version = 2;
|
2022-09-30 00:18:15 -05:00
|
|
|
|
|
|
|
// Include the full body bytes
|
2022-10-31 09:26:16 -05:00
|
|
|
bool with_body = 3;
|
2022-09-30 00:18:15 -05:00
|
|
|
|
|
|
|
// Include derived summary metadata
|
2022-10-31 09:26:16 -05:00
|
|
|
bool with_summary = 4;
|
2022-09-30 00:18:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
message ReadObjectResponse {
|
|
|
|
// Object details with the body removed
|
|
|
|
RawObject object = 1;
|
|
|
|
|
|
|
|
// Object summary as JSON
|
|
|
|
bytes summary_json = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------
|
|
|
|
// Make many read requests at once (by Kind+ID+version)
|
|
|
|
//------------------------------------------------------
|
|
|
|
|
|
|
|
message BatchReadObjectRequest {
|
2022-10-31 09:26:16 -05:00
|
|
|
repeated ReadObjectRequest batch = 1;
|
2022-09-30 00:18:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
message BatchReadObjectResponse {
|
|
|
|
repeated ReadObjectResponse results = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
// Write request/response
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
|
|
|
message WriteObjectRequest {
|
2022-10-31 09:26:16 -05:00
|
|
|
// Object identifier
|
|
|
|
GRN GRN = 1;
|
2022-09-30 00:18:15 -05:00
|
|
|
|
2022-11-30 14:10:35 -06:00
|
|
|
// Where to save the object (empty will leave it unchanged)
|
|
|
|
string folder = 2;
|
|
|
|
|
2022-09-30 00:18:15 -05:00
|
|
|
// The raw object body
|
2022-11-30 14:10:35 -06:00
|
|
|
bytes body = 3;
|
2022-09-30 00:18:15 -05:00
|
|
|
|
|
|
|
// Message that can be seen when exploring object history
|
2022-11-30 14:10:35 -06:00
|
|
|
string comment = 4;
|
2022-09-30 00:18:15 -05:00
|
|
|
|
|
|
|
// Used for optimistic locking. If missing, the previous version will be replaced regardless
|
2022-11-30 14:10:35 -06:00
|
|
|
string previous_version = 5;
|
2022-09-30 00:18:15 -05:00
|
|
|
}
|
|
|
|
|
2022-11-12 13:36:18 -06:00
|
|
|
// This operation is useful when syncing a resource from external sources
|
|
|
|
// that have more accurate metadata information (git, or an archive).
|
|
|
|
// This process can bypass the forced checks that
|
|
|
|
message AdminWriteObjectRequest {
|
|
|
|
// Object identifier
|
|
|
|
GRN GRN = 1;
|
|
|
|
|
2022-11-30 14:10:35 -06:00
|
|
|
// Where to save the object (empty will leave it unchanged)
|
|
|
|
string folder = 2;
|
|
|
|
|
2022-11-12 13:36:18 -06:00
|
|
|
// The raw object body
|
2022-11-30 14:10:35 -06:00
|
|
|
bytes body = 3;
|
2022-11-12 13:36:18 -06:00
|
|
|
|
|
|
|
// Message that can be seen when exploring object history
|
2022-11-30 14:10:35 -06:00
|
|
|
string comment = 4;
|
2022-11-12 13:36:18 -06:00
|
|
|
|
|
|
|
// Time in epoch milliseconds that the object was created
|
|
|
|
// Optional, if 0 it will use the current time
|
2022-11-30 14:10:35 -06:00
|
|
|
int64 created_at = 5;
|
2022-11-12 13:36:18 -06:00
|
|
|
|
|
|
|
// Time in epoch milliseconds that the object was updated
|
|
|
|
// Optional, if empty it will use the current user
|
2022-11-30 14:10:35 -06:00
|
|
|
int64 updated_at = 6;
|
2022-11-12 13:36:18 -06:00
|
|
|
|
|
|
|
// Who created the object
|
|
|
|
// Optional, if 0 it will use the current time
|
2022-11-30 14:10:35 -06:00
|
|
|
string created_by = 7;
|
2022-11-12 13:36:18 -06:00
|
|
|
|
|
|
|
// Who updated the object
|
|
|
|
// Optional, if empty it will use the current user
|
2022-11-30 14:10:35 -06:00
|
|
|
string updated_by = 8;
|
2022-11-12 13:36:18 -06:00
|
|
|
|
|
|
|
// An explicit version identifier
|
|
|
|
// Optional, if set, this will overwrite/define an explicit version
|
2022-11-30 14:10:35 -06:00
|
|
|
string version = 9;
|
2022-11-12 13:36:18 -06:00
|
|
|
|
|
|
|
// Used for optimistic locking. If missing, the previous version will be replaced regardless
|
|
|
|
// This may not be used along with an explicit version in the request
|
2022-11-30 14:10:35 -06:00
|
|
|
string previous_version = 10;
|
2022-11-12 13:36:18 -06:00
|
|
|
|
|
|
|
// Request that all previous versions are removed from the history
|
|
|
|
// This will make sense for systems that manage history explicitly externallay
|
2022-11-30 14:10:35 -06:00
|
|
|
bool clear_history = 11;
|
2022-11-12 13:36:18 -06:00
|
|
|
|
|
|
|
// Optionally define where the object came from
|
2022-11-30 14:10:35 -06:00
|
|
|
ObjectOriginInfo origin = 12;
|
2022-11-12 13:36:18 -06:00
|
|
|
}
|
|
|
|
|
2022-09-30 00:18:15 -05:00
|
|
|
message WriteObjectResponse {
|
|
|
|
// Error info -- if exists, the save did not happen
|
|
|
|
ObjectErrorInfo error = 1;
|
|
|
|
|
2022-10-31 15:37:05 -05:00
|
|
|
// Object identifier
|
|
|
|
GRN GRN = 2;
|
|
|
|
|
2022-09-30 00:18:15 -05:00
|
|
|
// Object details with the body removed
|
2022-10-31 15:37:05 -05:00
|
|
|
ObjectVersionInfo object = 3;
|
2022-09-30 00:18:15 -05:00
|
|
|
|
|
|
|
// Object summary as JSON
|
2022-10-31 15:37:05 -05:00
|
|
|
bytes summary_json = 4;
|
2022-10-04 13:57:26 -05:00
|
|
|
|
|
|
|
// Status code
|
2022-10-31 15:37:05 -05:00
|
|
|
Status status = 5;
|
2022-10-04 13:57:26 -05:00
|
|
|
|
|
|
|
// Status enumeration
|
|
|
|
enum Status {
|
|
|
|
ERROR = 0;
|
|
|
|
CREATED = 1;
|
2022-10-05 13:58:46 -05:00
|
|
|
UPDATED = 2;
|
2022-10-04 13:57:26 -05:00
|
|
|
UNCHANGED = 3;
|
|
|
|
}
|
2022-09-30 00:18:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
// Delete request/response
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
|
|
|
message DeleteObjectRequest {
|
2022-10-31 09:26:16 -05:00
|
|
|
// Object identifier
|
|
|
|
GRN GRN = 1;
|
2022-09-30 00:18:15 -05:00
|
|
|
|
|
|
|
// Used for optimistic locking. If missing, the previous version will be replaced regardless
|
|
|
|
string previous_version = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
message DeleteObjectResponse {
|
|
|
|
bool OK = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
// History request/response
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
|
|
|
message ObjectHistoryRequest {
|
2022-10-31 09:26:16 -05:00
|
|
|
// Object identifier
|
|
|
|
GRN GRN = 1;
|
2022-09-30 00:18:15 -05:00
|
|
|
|
|
|
|
// Maximum number of items to return
|
|
|
|
int64 limit = 3;
|
|
|
|
|
|
|
|
// Starting from the requested page
|
|
|
|
string next_page_token = 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
message ObjectHistoryResponse {
|
2022-10-31 15:37:05 -05:00
|
|
|
// Object identifier
|
|
|
|
GRN GRN = 1;
|
|
|
|
|
2022-09-30 00:18:15 -05:00
|
|
|
// Object metadata without the raw bytes
|
2022-10-31 15:37:05 -05:00
|
|
|
repeated ObjectVersionInfo versions = 2;
|
2022-09-30 00:18:15 -05:00
|
|
|
|
|
|
|
// More results exist... pass this in the next request
|
2022-10-31 15:37:05 -05:00
|
|
|
string next_page_token = 3;
|
2022-09-30 00:18:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
// List request/response
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
|
|
|
message ObjectSearchRequest {
|
|
|
|
// Starting from the requested page (other query parameters must match!)
|
|
|
|
string next_page_token = 1;
|
|
|
|
|
|
|
|
// Maximum number of items to return
|
|
|
|
int64 limit = 2;
|
|
|
|
|
|
|
|
// Free text query string -- mileage may vary :)
|
|
|
|
string query = 3;
|
|
|
|
|
|
|
|
// limit to a specific kind (empty is all)
|
|
|
|
repeated string kind = 4;
|
|
|
|
|
|
|
|
// Limit results to items in a specific folder
|
|
|
|
string folder = 5;
|
|
|
|
|
|
|
|
// Must match all labels
|
|
|
|
map<string,string> labels = 6;
|
|
|
|
|
|
|
|
// Sorting instructions `field ASC/DESC`
|
|
|
|
repeated string sort = 7;
|
|
|
|
|
2022-10-05 20:46:17 -05:00
|
|
|
// Return the full body in each payload
|
|
|
|
bool with_body = 8;
|
2022-09-30 00:18:15 -05:00
|
|
|
|
|
|
|
// Return the full body in each payload
|
2022-10-05 20:46:17 -05:00
|
|
|
bool with_labels = 9;
|
|
|
|
|
|
|
|
// Return the full body in each payload
|
|
|
|
bool with_fields = 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Search result metadata for each object
|
|
|
|
message ObjectSearchResult {
|
2022-10-31 09:26:16 -05:00
|
|
|
// Object identifier
|
|
|
|
GRN GRN = 1;
|
2022-10-05 20:46:17 -05:00
|
|
|
|
|
|
|
// The current veresion of this object
|
2022-11-08 16:42:32 -06:00
|
|
|
string version = 2;
|
|
|
|
|
|
|
|
// Content Length
|
|
|
|
int64 size = 3;
|
2022-10-05 20:46:17 -05:00
|
|
|
|
|
|
|
// Time in epoch milliseconds that the object was updated
|
2022-11-08 16:42:32 -06:00
|
|
|
int64 updated_at = 4;
|
2022-10-05 20:46:17 -05:00
|
|
|
|
|
|
|
// Who updated the object
|
|
|
|
string updated_by = 5;
|
|
|
|
|
|
|
|
// Optionally include the full object body
|
|
|
|
bytes body = 6;
|
|
|
|
|
|
|
|
//----------------------------------------
|
|
|
|
// Derived from body in the summary
|
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
// Always included
|
|
|
|
string name = 7;
|
|
|
|
|
|
|
|
// Always included
|
|
|
|
string description = 8;
|
|
|
|
|
|
|
|
// The structured labels
|
|
|
|
map<string,string> labels = 9;
|
|
|
|
|
2022-11-30 14:10:35 -06:00
|
|
|
// Folder UID
|
|
|
|
string folder = 10;
|
|
|
|
|
|
|
|
// Slugified name
|
|
|
|
string slug = 11;
|
|
|
|
|
2022-10-05 20:46:17 -05:00
|
|
|
// Optionally include extracted JSON
|
2022-11-30 14:10:35 -06:00
|
|
|
bytes fields_json = 12;
|
2022-10-05 20:46:17 -05:00
|
|
|
|
|
|
|
// ObjectErrorInfo in json
|
2022-11-30 14:10:35 -06:00
|
|
|
bytes error_json = 13;
|
2022-09-30 00:18:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
message ObjectSearchResponse {
|
2022-10-05 20:46:17 -05:00
|
|
|
repeated ObjectSearchResult results = 1;
|
2022-09-30 00:18:15 -05:00
|
|
|
|
|
|
|
// More results exist... pass this in the next request
|
|
|
|
string next_page_token = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
// Storage interface
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
2022-11-12 13:36:18 -06:00
|
|
|
// The object store provides a basic CRUD (+watch eventually) interface for generic objects
|
2022-09-30 00:18:15 -05:00
|
|
|
service ObjectStore {
|
|
|
|
rpc Read(ReadObjectRequest) returns (ReadObjectResponse);
|
|
|
|
rpc BatchRead(BatchReadObjectRequest) returns (BatchReadObjectResponse);
|
|
|
|
rpc Write(WriteObjectRequest) returns (WriteObjectResponse);
|
|
|
|
rpc Delete(DeleteObjectRequest) returns (DeleteObjectResponse);
|
|
|
|
rpc History(ObjectHistoryRequest) returns (ObjectHistoryResponse);
|
|
|
|
rpc Search(ObjectSearchRequest) returns (ObjectSearchResponse);
|
|
|
|
|
|
|
|
// Ideally an additional search endpoint with more flexibility to limit what you actually care about
|
|
|
|
// https://github.com/grafana/grafana-plugin-sdk-go/blob/main/proto/backend.proto#L129
|
|
|
|
// rpc SearchEX(ObjectSearchRequest) returns (DataResponse);
|
2022-11-12 13:36:18 -06:00
|
|
|
|
|
|
|
// TEMPORARY... while we split this into a new service (see below)
|
|
|
|
rpc AdminWrite(AdminWriteObjectRequest) returns (WriteObjectResponse);
|
|
|
|
}
|
|
|
|
|
|
|
|
// The admin service extends the basic object store interface, but provides
|
|
|
|
// more explicit control that can support bulk operations like efficient git sync
|
|
|
|
service ObjectStoreAdmin {
|
|
|
|
rpc AdminWrite(AdminWriteObjectRequest) returns (WriteObjectResponse);
|
2022-09-30 00:18:15 -05:00
|
|
|
}
|