grafana/pkg/services/store/object/object.proto

322 lines
8.4 KiB
Protocol Buffer
Raw Normal View History

syntax = "proto3";
package object;
option go_package = "./;object";
// The canonical object/document data -- this represents the raw bytes and storage level metadata
message RawObject {
// Unique ID
string UID = 1;
// Identify the object kind. This kind will be used to apply a schema to the body and
// will trigger additional indexing behavior.
string kind = 2;
// Time in epoch milliseconds that the object was created
int64 created = 3;
// Time in epoch milliseconds that the object was updated
int64 updated = 4;
// Who created the object
string created_by = 5;
// Who updated the object
string updated_by = 6;
// Content Length
int64 size = 7;
// MD5 digest of the body
string ETag = 8;
// Raw bytes of the storage object. The kind will determine what is a valid payload
bytes body = 9;
// The version will change when the object is saved. It is not necessarily sortable
//
// NOTE: currently managed by the dashboard+dashboard_version tables
string version = 10;
// External location info
RawObjectSyncInfo sync = 11;
}
message RawObjectSyncInfo {
// NOTE: currently managed by the dashboard_provisioning table
string source = 11;
// Time in epoch milliseconds that the object was last synced with an external system (provisioning/git)
int64 time = 12;
}
// 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;
}
// 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;
// Time in epoch milliseconds that the object was updated
int64 updated = 2;
// Who updated the object
string updated_by = 3;
// 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;
}
//-----------------------------------------------
// Get request/response
//-----------------------------------------------
message ReadObjectRequest {
// Unique ID (Kind is also required) NOTE: UID+kind will likely be replaced with GRN that encodes both
string UID = 1;
// Object kind (UID is also required) NOTE: UID+kind will likely be replaced with GRN that encodes both
string kind = 2;
// Fetch an explicit version
string version = 3;
// Include the full body bytes
bool with_body = 4;
// Include derived summary metadata
bool with_summary = 5;
}
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 {
repeated ReadObjectRequest batch = 3;
}
message BatchReadObjectResponse {
repeated ReadObjectResponse results = 1;
}
//-----------------------------------------------
// Write request/response
//-----------------------------------------------
message WriteObjectRequest {
// Unique ID (Kind is also required) NOTE: UID+kind will likely be replaced with GRN that encodes both
string UID = 1;
// Object kind (UID is also required) NOTE: UID+kind will likely be replaced with GRN that encodes both
string kind = 2;
// The raw object body
bytes body = 3;
// Message that can be seen when exploring object history
string comment = 4;
// Used for optimistic locking. If missing, the previous version will be replaced regardless
string previous_version = 6;
}
message WriteObjectResponse {
// Error info -- if exists, the save did not happen
ObjectErrorInfo error = 1;
// Object details with the body removed
ObjectVersionInfo object = 2;
// Object summary as JSON
bytes summary_json = 3;
// Status code
Status status = 4;
// Status enumeration
enum Status {
ERROR = 0;
CREATED = 1;
UPDATED = 2;
UNCHANGED = 3;
}
}
//-----------------------------------------------
// Delete request/response
//-----------------------------------------------
message DeleteObjectRequest {
// Unique ID (Kind is also required) NOTE: UID+kind will likely be replaced with GRN that encodes both
string UID = 1;
// Object kind (UID is also required) NOTE: UID+kind will likely be replaced with GRN that encodes both
string kind = 2;
// 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 {
// Unique ID (Kind is also required) NOTE: UID+kind will likely be replaced with GRN that encodes both
string UID = 1;
// Object kind (UID is also required) NOTE: UID+kind will likely be replaced with GRN that encodes both
string kind = 2;
// Maximum number of items to return
int64 limit = 3;
// Starting from the requested page
string next_page_token = 5;
}
message ObjectHistoryResponse {
// Object metadata without the raw bytes
repeated ObjectVersionInfo versions = 1;
// More results exist... pass this in the next request
string next_page_token = 2;
}
//-----------------------------------------------
// 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;
// Return the full body in each payload
bool with_body = 8;
// Return the full body in each payload
bool with_labels = 9;
// Return the full body in each payload
bool with_fields = 10;
}
// Search result metadata for each object
message ObjectSearchResult {
// Unique ID
string UID = 1;
// Identify the object kind. This kind will be used to apply a schema to the body and
// will trigger additional indexing behavior.
string kind = 2;
// The current veresion of this object
string version = 3;
// Time in epoch milliseconds that the object was updated
int64 updated = 4;
// 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;
// Optionally include extracted JSON
bytes fields_json = 10;
// ObjectErrorInfo in json
bytes error_json = 11;
}
message ObjectSearchResponse {
repeated ObjectSearchResult results = 1;
// More results exist... pass this in the next request
string next_page_token = 2;
}
//-----------------------------------------------
// Storage interface
//-----------------------------------------------
// This assumes a future grpc interface where the user info is passed in context, not in each message body
// for now it will only work with an admin API key
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);
}