syntax = "proto3";
package carbonapi_v3_pb;

option go_package = "github.com/go-graphite/protocol/carbonapi_v3_pb";

message FilteringFunction {
    string name = 1;
    repeated string arguments = 2;
}

// Fetch Storage Capabilities
message CapabilityRequest {
}

// Storage capability information
message CapabilityResponse {
    // carbonapi_v2_pb, carbonapi_v3_pb, etc.
    repeated string supportedProtocols = 1;
    // server name
    string name = 2;
    bool highPrecisionTimestamps = 3;
    bool supportFilteringFunctions = 4;
    // true if storage will behave normally if request is splitted by maxGlobs
    bool likeSplittedRequests = 5;
    bool supportStreaming = 6;
}

// Fetch Data
message FetchRequest {
    string name = 1;
    int64 startTime = 2;
    int64 stopTime = 3;
    // Should be true if our request requires more precision than seconds.
    bool highPrecisionTimestamps = 4;
    string pathExpression = 5;
    repeated FilteringFunction filterFunctions = 6;
    int64 maxDataPoints = 7;
}

message MultiFetchRequest {
    repeated FetchRequest metrics = 1;
}

// Stop time can be computed by stepTime*len(values)
message FetchResponse {
    string name = 1;
    string pathExpression = 2;
    string consolidationFunc = 3;
    int64 startTime = 4;
    int64 stopTime = 5;
    int64 stepTime = 6;
    float xFilesFactor = 7;
    // Should be true if timestamps have better precision than seconds.
    bool highPrecisionTimestamps = 8;
    repeated double values = 9;
    repeated string appliedFunctions = 10;
    int64 requestStartTime = 11;
    int64 requestStopTime = 12;
}

message MultiFetchResponse {
    repeated FetchResponse metrics = 1;
}

// Find Metrics
message MultiGlobRequest {
    repeated string metrics = 1;
    int64 startTime = 2;
    int64 stopTime = 3;
}

message GlobMatch {
    string path = 1;
    bool isLeaf = 2;
}

// request name to metrics
message GlobResponse {
    string name = 1;
    repeated GlobMatch matches = 2;
}

message MultiGlobResponse {
    repeated GlobResponse metrics = 1;
}

// Information about metrics
message MetricsInfoRequest {
    string name = 1;
}

message MultiMetricsInfoRequest {
    repeated string names = 1;
}

message Retention {
    int64 secondsPerPoint = 1;
    int64 numberOfPoints = 2;
}

message MetricsInfoResponse {
    string name = 1;
    string consolidationFunc = 2;
    float xFilesFactor = 4;
    int64 maxRetention = 3;
    repeated Retention retentions = 5;
}

message MultiMetricsInfoResponse {
    repeated MetricsInfoResponse metrics = 1;
}

// key = server, value = metric
message ZipperInfoResponse {
    map<string, MultiMetricsInfoResponse> info = 1;
}

// List all metrics
message ListMetricsResponse {
    repeated string Metrics = 1;
}

// Get stats about metrics
message MetricDetails {
    int64 Size = 2;
    int64 ModTime = 3;
    int64 ATime = 4;
    int64 RdTime = 5;
        int64 RealSize = 6;

}

message MetricDetailsResponse {
    map<string, MetricDetails> metrics = 1;
    uint64 FreeSpace = 2;
    uint64 TotalSpace = 3;
}

message MultiDetailsResponse {
    map<string, MetricDetailsResponse> metrics = 1;
}
