syntax = "proto2";

import "google/protobuf/any.proto";

import "grr_response_proto/semantic.proto";


//
// Entities.
//

message ApiGrrBinary {
  enum Type {
    PYTHON_HACK = 1;
    EXECUTABLE = 2;
    COMPONENT = 3;
  };
  optional Type type = 1 [(sem_type) = {
      description: "Binary type. Together with path it identifies the binary."
    }];
  optional string path = 2 [(sem_type) = {
      description: "Binary path. Together with binary type it identifies the "
      "binary."
    }];
  optional uint64 size = 3 [(sem_type) = {
      type: "ByteSize",
      description: "Binary size."
    }];
  optional uint64 timestamp = 4 [(sem_type) = {
      type: "RDFDatetime",
      description: "Binary upload timestamp."
    }];
}

message ApiConfigOption {
  optional string name = 1;
  optional bool is_redacted = 2;

  optional google.protobuf.Any value = 3 [(sem_type) = {
      description: "Config option value.",
      dynamic_type: "GetValueClass"
    }];
  optional string type = 4 [(sem_type) = {
      description: "The type of the value."
    }];
  optional bool is_invalid = 5 [(sem_type) = {
      description: "Whether the value could be successfully serialized "
      "to the protobuf serialization format."
    }];
}

message ApiConfigSection {
  optional string name = 1;
  repeated ApiConfigOption options = 2;
}

//
// Method arguments and results.
//

message ApiGetConfigResult {
  repeated ApiConfigSection sections = 1;
}

message ApiGetConfigOptionArgs {
  optional string name = 1 [(sem_type) = {
      description: "Name of the config option to fetch."
    }];
}

message ApiListGrrBinariesResult {
  repeated ApiGrrBinary items = 1;
}

message ApiGetGrrBinaryArgs {
  optional ApiGrrBinary.Type type = 1 [(sem_type) = {
      description: "Binary type."
    }];
  optional string path = 2 [(sem_type) = {
      description: "Binary path."
    }];
}
