syntax = "proto3";
package internal;

message Source {
	int64 ID                  = 1;  // ID is the unique ID of the source
	string Name               = 2;  // Name is the user-defined name for the source
	string Type               = 3;  // Type specifies which kinds of source (enterprise vs oss)
	string Username           = 4;  // Username is the username to connect to the source
	string Password           = 5;
	string URL                = 6;  // URL are the connections to the source
	bool Default              = 7;  // Flags an source as the default.
	string Telegraf           = 8;  // Telegraf is the db telegraf is written to. By default it is "telegraf"
	bool InsecureSkipVerify   = 9;  // InsecureSkipVerify accepts any certificate from the influx server
	string MetaURL            = 10; // MetaURL is the connection URL for the meta node.
	string SharedSecret       = 11; // SharedSecret signs the optional InfluxDB JWT Authorization
	string Organization       = 12; // Organization is the organization ID that resource belongs to
	string Role               = 13; // Role is the name of the miniumum role that a user must possess to access the resource
	string DefaultRP          = 14; // DefaultRP is the default retention policy used in database queries to this source
}

message Dashboard {
	int64 ID                     = 1; // ID is the unique ID of the dashboard
	string Name                  = 2; // Name is the user-defined name of the dashboard
	repeated DashboardCell cells = 3; // a representation of all visual data required for rendering the dashboard
	repeated Template templates  = 4; // Templates replace template variables within InfluxQL
	string Organization          = 5; // Organization is the organization ID that resource belongs to
}

message DashboardCell {
	int32 x                              = 1; // X-coordinate of Cell in the Dashboard
	int32 y                              = 2; // Y-coordinate of Cell in the Dashboard
	int32 w                              = 3; // Width of Cell in the Dashboard
	int32 h                              = 4; // Height of Cell in the Dashboard
	repeated Query queries               = 5; // Time-series data queries for Dashboard
	string name                          = 6; // User-facing name for this Dashboard
	string type                          = 7; // Dashboard visualization type
	string ID                            = 8; // id is the unique id of the dashboard. MIGRATED FIELD added in 1.2.0-beta6
	map<string, Axis> axes               = 9; // Axes represent the graphical viewport for a cell's visualizations
	repeated Color colors                = 10; // Colors represent encoding data values to color
	Legend legend                        = 11; // Legend is summary information for a cell
	TableOptions tableOptions            = 12; // TableOptions for visualization of cell with type 'table'
	repeated RenamableField fieldOptions = 13; // Options for each of the fields returned in a cell
	string timeFormat                    = 14; // format for time
	DecimalPlaces decimalPlaces          = 15; // Represents how precise the values of this field should be
}

message DecimalPlaces {
	bool isEnforced			= 1; // whether decimal places should be enforced
	int32 digits				= 2; // the number of digits to display after decical point
}

message TableOptions {
	reserved 1;
	bool verticalTimeAxis               = 2; // time axis should be a column not row
	RenamableField sortBy               = 3; // which column should a table be sorted by
	string 	wrapping                    = 4; // option for text wrapping
	reserved 5;
	bool fixFirstColumn                 = 6; // first column should be fixed/frozen
}

message RenamableField {
	string internalName     = 1; // name of column
	string displayName      = 2; // what column is renamed to
	bool visible						= 3; // Represents whether RenamableField is visible
}

message Color {
	string ID                   = 1; // ID is the unique id of the cell color
	string Type                 = 2; // Type is how the color is used. Accepted (min,max,threshold)
	string Hex                  = 3; // Hex is the hex number of the color
	string Name                 = 4; // Name is the user-facing name of the hex color
	string Value                = 5; // Value is the data value mapped to this color
}

message Legend {
	string Type                 = 1; // Type is how the legend is used
	string Orientation          = 2; // Orientation is the location of the legend on the cell
}

message Axis {
	repeated int64 legacyBounds = 1; // legacyBounds are an ordered 2-tuple consisting of lower and upper axis extents, respectively
	repeated string bounds      = 2; // bounds are an arbitrary list of client-defined bounds.
	string label                = 3; // label is a description of this axis
	string prefix               = 4; // specifies the prefix for axis values
	string suffix               = 5; // specifies the suffix for axis values
	string base                 = 6; // defines the base for axis values
	string scale                = 7; // represents the magnitude of the numbers on this axis
}

message Template {
	string ID                     = 1; // ID is the unique ID associated with this template
	string temp_var               = 2;
	repeated TemplateValue values = 3;
	string type                   = 4; // Type can be fieldKeys, tagKeys, tagValues, CSV, constant, query, measurements, databases
	string label                  = 5; // Label is a user-facing description of the Template
	TemplateQuery query           = 6; // Query is used to generate the choices for a template
}

message TemplateValue {
	string type             = 1; // Type can be tagKey, tagValue, fieldKey, csv, map, measurement, database, constant
	string value            = 2; // Value is the specific value used to replace a template in an InfluxQL query
	bool selected           = 3; // Selected states that this variable has been picked to use for replacement
	string key              = 4; // Key is the key for a specific Value if the Template Type is map (optional)
}

message TemplateQuery {
	string command          = 1; // Command is the query itself
	string db               = 2; // DB the database for the query (optional)
	string rp               = 3; // RP is a retention policy and optional;
	string measurement      = 4; // Measurement is the optinally selected measurement for the query
	string tag_key          = 5; // TagKey is the optionally selected tag key for the query
	string field_key        = 6; // FieldKey is the optionally selected field key for the query
}

message Server {
	int64 ID                = 1;  // ID is the unique ID of the server
	string Name             = 2;  // Name is the user-defined name for the server
	string Username         = 3;  // Username is the username to connect to the server
	string Password         = 4;
	string URL              = 5;  // URL is the path to the server
	int64 SrcID             = 6;  // SrcID is the ID of the data source
	bool Active             = 7;  // is this the currently active server for the source
	string Organization     = 8;  // Organization is the organization ID that resource belongs to
	bool InsecureSkipVerify = 9;  // InsecureSkipVerify accepts any certificate from the client
	string Type             = 10; // Type is the kind of the server (e.g. flux)
	string MetadataJSON     = 11; // JSON byte representation of the metadata
}

message Layout {
	string ID               = 1; // ID is the unique ID of the layout.
	string Application      = 2; // Application is the user facing name of this Layout.
	string Measurement      = 3; // Measurement is the descriptive name of the time series data.
	repeated Cell Cells     = 4; // Cells are the individual visualization elements.
	bool Autoflow           = 5; // Autoflow indicates whether the frontend should layout the cells automatically.
}

message Cell {
	int32 x                 = 1; // X-coordinate of Cell in the Layout
	int32 y                 = 2; // Y-coordinate of Cell in the Layout
	int32 w                 = 3; // Width of Cell in the Layout
	int32 h                 = 4; // Height of Cell in the Layout
	repeated Query queries  = 5; // Time-series data queries for Cell.
	string i                = 6; // Unique identifier for the cell
	string name             = 7; // User-facing name for this cell
	repeated int64 yranges  = 8; // Limits of the y-axes
	repeated string ylabels = 9; // Labels of the y-axes
	string type             = 10; // Cell visualization type
	map<string, Axis> axes  = 11; // Axes represent the graphical viewport for a cell's visualizations
}

message Query {
	string Command            = 1; // Command is the query itself
	string DB                 = 2; // DB the database for the query (optional)
	string RP                 = 3; // RP is a retention policy and optional;
	repeated string GroupBys  = 4; // GroupBys define the groups to combine in the query
	repeated string Wheres    = 5; // Wheres define the restrictions on the query
	string Label              = 6; // Label is the name of the Y-Axis
	Range Range               = 7; // Range is the upper and lower bound of the Y-Axis
	string Source             = 8; // Source is the optional URI to the data source
	repeated TimeShift Shifts = 9; // TimeShift represents a shift to apply to an influxql query's time range
  string Type               = 10;
}

message TimeShift {
	string Label              = 1; // Label user facing description
	string Unit               = 2; // Unit influxql time unit representation i.e. ms, s, m, h, d
	string Quantity           = 3; // Quantity number of units
}

message Range {
	int64 Upper               = 1; // Upper is the upper-bound of the range
	int64 Lower               = 2; // Lower is the lower-bound of the range
}

message AlertRule {
	string ID                 = 1; // ID is the unique ID of this alert rule
	string JSON               = 2; // JSON byte representation of the alert
	int64 SrcID               = 3; // SrcID is the id of the source this alert is associated with
	int64 KapaID              = 4; // KapaID is the id of the kapacitor this alert is associated with
}

message User {
	uint64 ID               = 1; // ID is the unique ID of this user
	string Name             = 2; // Name is the user's login name
	string Provider         = 3; // Provider is the provider that certifies and issues this user's authentication, e.g. GitHub
	string Scheme           = 4; // Scheme is the scheme used to perform this user's authentication, e.g. OAuth2 or LDAP
	repeated Role Roles     = 5; // Roles is set of roles a user has
	bool SuperAdmin         = 6; // SuperAdmin is bool that specifies whether a user is a super admin
}

message Role {
	string Organization     = 1; // Organization is the ID of the organization that this user has a role in
	string Name             = 2; // Name is the name of the role of this user in the respective organization
}

message Mapping {
	string Provider              = 1; // Provider is the provider that certifies and issues this user's authentication, e.g. GitHub
	string Scheme                = 2; // Scheme is the scheme used to perform this user's authentication, e.g. OAuth2 or LDAP
	string ProviderOrganization  = 3; // ProviderOrganization is the group or organizations that you are a part of in an auth provider
	string ID                    = 4; // ID is the unique ID for the mapping
	string Organization          = 5; // Organization is the organization ID that resource belongs to
}

message Organization {
	string ID                  = 1; // ID is the unique ID of the organization
	string Name                = 2; // Name is the organization's name
	string DefaultRole         = 3; // DefaultRole is the name of the role that is the default for any users added to the organization
}

message Config {
	AuthConfig Auth         = 1; // Auth is the configuration for options that auth related
}

message AuthConfig {
	bool SuperAdminNewUsers   = 1; // SuperAdminNewUsers configuration option that specifies which users will auto become super admin
}

message OrganizationConfig {
	string OrganizationID                   = 1; // OrganizationID is the ID of the organization this config belogs to
	LogViewerConfig LogViewer              	= 2; // LogViewer is the organization configuration for log viewer
}

message LogViewerConfig {
	repeated LogViewerColumn Columns               = 1; // Columns is the array of columns in the log viewer
}

message LogViewerColumn {
	string Name                                      = 1; // Name is the unique identifier of the log viewer column
	int32 Position                                   = 2; // Position is the position of the column in the log viewer's array of columns
	repeated ColumnEncoding Encodings                = 3; // Encodings is the array of encoded properties associated with a log viewer column
}

message ColumnEncoding {	
	string Type                        = 1; // Type is the purpose of the encoding, for example: severity color
	string Value                       = 2; // Value is what the encoding corresponds to
	string Name                        = 3; // Name is the optional encoding name
}

message BuildInfo {
	string Version          = 1; // Version is a descriptive git SHA identifier
	string Commit           = 2; // Commit is an abbreviated SHA
}

// The following is a vim modeline, it autoconfigures vim to have the
// appropriate tabbing and whitespace management to edit this file
//
// vim: ai:ts=4:noet:sts=4
