syntax = "proto3";

package filter_list_manager;

option java_multiple_files = true;
option java_package = "com.adguard.flm.protobuf";
option java_outer_classname = "FlmInterfaceProto";

import "configuration.proto";
import "outer_error.proto";
import "filters.proto";
import "misc_models.proto";

// region Requests

message InstallCustomFilterListRequest {
  string download_url = 1;
  bool is_trusted = 2;
  optional string title = 3;
  optional string description = 4;
}

message InstallCustomFilterFromStringRequest {
  string download_url = 1;
  int64 last_download_time = 2;
  bool is_enabled = 3;
  bool is_trusted = 4;
  string filter_body = 5;
  optional string custom_title = 6;
  optional string custom_description = 7;
}

message EnableFilterListsRequest {
  repeated int32 ids = 1;
  bool is_enabled = 2;
}

message InstallFilterListsRequest {
  repeated int32 ids = 1;
  bool is_installed = 2;
}

message DeleteCustomFilterListsRequest {
  repeated int32 ids = 1;
}

message GetFullFilterListByIdRequest {
  int32 id = 1;
}

message GetStoredFilterMetadataByIdRequest {
  int32 id = 1;
}

message SaveCustomFilterRulesRequest {
  FilterListRules rules = 1;
}

message SaveDisabledRulesRequest {
  int32 filter_id = 1;
  repeated string disabled_rules = 2;
}

message UpdateFiltersRequest {
  bool ignore_filters_expiration = 1;
  int32 loose_timeout = 2;
  bool ignore_filters_status = 3;
}

message UpdateFiltersByIdsRequest {
  repeated int32 ids = 1;
  bool ignore_filters_expiration = 2;
  int32 loose_timeout = 3;
  bool ignore_filters_status = 4;
}

message ForceUpdateFiltersByIdsRequest {
  repeated int32 ids = 1;
  int32 loose_timeout = 2;
}

message FetchFilterListMetadataRequest {
  string url = 1;
}

message FetchFilterListMetadataWithBodyRequest {
  string url = 1;
}

message GetActiveRulesRawRequest {
  repeated int32 filter_by = 1;
}

message ChangeLocaleRequest {
  string suggested_locale = 1;
}

message UpdateCustomFilterMetadataRequest {
  int32 filter_id = 1;
  string title = 2;
  bool is_trusted = 3;
}

message GetFilterRulesAsStringsRequest {
  repeated int32 ids = 1;
}

message SaveRulesToFileBlobRequest {
  int32 filter_id = 1;
  string file_path = 2;
}

message GetDisabledRulesRequest {
  repeated int32 ids = 1;
}

message SetProxyModeRequest {
  RawRequestProxyMode mode = 1;
  string custom_proxy_addr = 2;
}

message GetRulesCountRequest {
  repeated int32 ids = 1;
}

message SignAllDataWithNewKeyRequest {
  string integrity_key = 1;
}

message EmptyRequest {}

// endregion

// region Responses

message InstallCustomFilterListResponse {
  FullFilterList filter_list = 1;
  optional AGOuterError error = 2;
}

message EnableFilterListsResponse {
  int64 count = 1;
  optional AGOuterError error = 2;
}

message InstallFilterListsResponse {
  int64 count = 1;
  optional AGOuterError error = 2;
}

message DeleteCustomFilterListsResponse {
  int64 count = 1;
  optional AGOuterError error = 2;
}

message GetStoredFiltersMetadataResponse {
  repeated StoredFilterMetadata filter_lists = 1;
  optional AGOuterError error = 2;
}

message GetStoredFilterMetadataByIdResponse {
  optional StoredFilterMetadata filter_list = 1;
  optional AGOuterError error = 2;
}

message GetFullFilterListByIdResponse {
  optional FullFilterList filter_list = 1;
  optional AGOuterError error = 2;
}

message UpdateFiltersResponse {
  optional UpdateResult result = 1;
  optional AGOuterError error = 2;
}

message UpdateFiltersByIdsResponse {
  optional UpdateResult result = 1;
  optional AGOuterError error = 2;
}

message ForceUpdateFiltersByIdsResponse {
  optional UpdateResult result = 1;
  optional AGOuterError error = 2;
}

message FetchFilterListMetadataResponse {
  FilterListMetadata metadata = 1;
  optional AGOuterError error = 2;
}

message FetchFilterListMetadataWithBodyResponse {
  FilterListMetadataWithBody metadata = 1;
  optional AGOuterError error = 2;
}

message GetAllTagsResponse {
  repeated FilterTag tags = 1;
  optional AGOuterError error = 2;
}

message GetAllGroupsResponse {
  repeated FilterGroup groups = 1;
  optional AGOuterError error = 2;
}

message ChangeLocaleResponse {
  bool success = 1;
  optional AGOuterError error = 2;
}

message UpdateCustomFilterMetadataResponse {
  bool success = 1;
  optional AGOuterError error = 2;
}

message GetDatabasePathResponse {
  string path = 1;
  optional AGOuterError error = 2;
}

message GetDatabaseVersionResponse {
  optional int32 version = 1;
  optional AGOuterError error = 2;
}

message InstallCustomFilterFromStringResponse {
  FullFilterList filter_list = 1;
  optional AGOuterError error = 2;
}

message GetActiveRulesResponse {
  repeated ActiveRulesInfo rules = 1;
  optional AGOuterError error = 2;
}

message GetActiveRulesRawResponse {
  repeated ActiveRulesInfoRaw rules = 1;
  optional AGOuterError error = 2;
}

message GetFilterRulesAsStringsResponse {
  repeated FilterListRulesRaw rules_list = 1;
  optional AGOuterError error = 2;
}

message GetDisabledRulesResponse {
  repeated DisabledRulesRaw rules_raw = 1;
  optional AGOuterError error = 2;
}

message GetRulesCountResponse {
  repeated RulesCountByFilter rules_count_by_filter = 1;
  optional AGOuterError error = 2;
}

message PullMetadataResponse {
  PullMetadataResult result = 1;
  optional AGOuterError error = 2;
}

message EmptyResponse {
  optional AGOuterError error = 1;
}

message GenerateRandomKeyResponse {
  string key = 1;
  optional AGOuterError error = 2;
}

// endregion
