syntax = "proto3";

import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/field_mask.proto";
import "intranet/d/backend/service/proto/features.proto";
import "intranet/d/backend/service/proto/aggregation.proto";
import "intranet/d/backend/service/proto/provider_ui_settings.proto";
import "intranet/d/backend/service/proto/provider_external_account_url_template.proto";

package intranet.d.backend.service.recipe_proto;

option java_multiple_files = true;
option java_package = "ru.yandex.intranet.d.backend.service.recipe_proto";
option java_outer_classname = "RecipeProto";
option go_package = "a.yandex-team.ru/intranet/d/backend/service/recipe_proto;resource_model_recipe_proto";

service RecipeService {
    rpc CreateService(CreateServiceRequest) returns (google.protobuf.Empty) {};
    rpc CreateUser(CreateUserRequest) returns (google.protobuf.Empty) {};
    rpc CreateDefaultFolders(google.protobuf.Empty) returns (google.protobuf.Empty) {};
    rpc GetAccounts(google.protobuf.Empty) returns (GetAccountsResponse) {};
    rpc GetAccountsQuotas(google.protobuf.Empty) returns (GetAccountsQuotasResponse) {};
    rpc CreateProvider(CreateProviderRequest) returns (Provider) {};
    rpc PutProvider(PutProviderRequest) returns (Provider) {};
    rpc CreateUnitsEnsemble(CreateUnitsEnsembleRequest) returns (UnitsEnsemble) {};
}

message CreateServiceRequest {
    int64 id = 1;
    string name_en = 2;
    string name_ru = 3;
    string slug = 4;
    ServiceParent parent = 5;
}

message ServiceParent {
    int64 parent_id = 1;
}

message CreateUserRequest {
    string first_name_en = 1;
    string first_name_ru = 2;
    string last_name_en = 3;
    string last_name_ru = 4;
    string login = 5;
    int64 uid = 6;
    string work_email = 7;
    string gender = 8;
    string lang_ui = 9;
    string time_zone = 10;
    bool admin = 11;
    repeated ServiceRoles service_roles = 12;
}

message ServiceRoles {
    int64 service_id = 1;
    repeated int64 role_ids = 2;
}

message GetAccountsResponse {
    repeated Account accounts = 1;
}

message Account {
    string id = 1;
    string provider_id = 2;
    string external_id = 3;
    AccountKey external_key = 4;
    string folder_id = 5;
    AccountName display_name = 6;
    bool deleted = 7;
    LastUpdate last_account_update = 8;
    Version last_received_version = 9;
    OperationId latest_successful_account_operation_id = 10;
    AccountsSpaceId accounts_space_id = 11;
    bool free_tier = 12;
}

message AccountKey {
    string key = 1;
}

message AccountName {
    string name = 1;
}

message LastUpdate {
    google.protobuf.Timestamp timestamp = 1;
}

message Version {
    int64 version = 1;
}

message OperationId {
    string operation_id = 1;
}

message AccountsSpaceId {
    string id = 1;
}

message GetAccountsQuotasResponse {
    repeated AccountQuota accounts_quotas = 1;
}

message AccountQuota {
    string account_id = 1;
    string resource_id = 2;
    Amount provided = 3;
    Amount allocated = 4;
    string folder_id = 5;
    string provider_id = 6;
    LastUpdate last_provision_update = 7;
    Version last_received_provision_version = 8;
    OperationId latest_successful_provision_operation_id = 9;
    string external_account_id = 10;
    AccountsSpaceId accounts_space_id = 11;
}

message Amount {
    int64 value = 1;
    string unit_key = 2;
}

message CreateProviderRequest {
    string name_en = 1;
    string name_ru = 2;
    string description_en = 3;
    string description_ru = 4;
    ApiUri rest_api_uri = 5;
    ApiUri grpc_api_uri = 6;
    int64 source_tvm_id = 7;
    int64 destination_tvm_id = 8;
    int64 abc_service_id = 9;
    bool read_only = 10;
    bool multiple_accounts_per_folder = 11;
    bool account_transfer_with_quota = 12;
    bool managed = 13;
    string key = 14;
    bool accounts_display_name_supported = 15;
    bool accounts_key_supported = 16;
    bool accounts_delete_supported = 17;
    bool accounts_soft_delete_supported = 18;
    bool accounts_move_supported = 19;
    bool accounts_rename_supported = 20;
    bool import_allowed = 21;
    bool accounts_spaces_supported = 22;
    bool per_account_version_supported = 23;
    bool per_provision_version_supported = 24;
    bool per_account_last_update_supported = 25;
    bool per_provision_last_update_supported = 26;
    bool operation_id_deduplication_supported = 27;
    bool sync_cool_down_disabled = 28;
    bool retry_cool_down_disabled = 29;
    bool sync_enabled = 30;
    bool grpc_tls_on = 31;
    MeteringKey metering_key = 32;
    int64 tracker_component_id = 33;
    int64 accountsSyncPageSize = 34;
    bool moveProvisionSupported = 35;
    intranet.d.backend.service.proto.FeatureState allocated_supported = 36;
    intranet.d.backend.service.proto.AggregationSettings aggregation_settings = 37;
    AggregationAlgorithm aggregation_algorithm = 38;
    intranet.d.backend.service.proto.ProviderUISettings ui_settings = 39;
    repeated intranet.d.backend.service.proto.ProviderExternalAccountUrlTemplate external_account_url_template = 40;
    intranet.d.backend.service.proto.FeatureState multiple_reserves_allowed = 41;
}

message PutProviderRequest {
    string id = 1;
    int64 version = 2;
    string name_en = 3;
    string name_ru = 4;
    string description_en = 5;
    string description_ru = 6;
    ApiUri rest_api_uri = 7;
    ApiUri grpc_api_uri = 8;
    int64 source_tvm_id = 9;
    int64 destination_tvm_id = 10;
    int64 abc_service_id = 11;
    bool read_only = 12;
    bool multiple_accounts_per_folder = 13;
    bool account_transfer_with_quota = 14;
    bool managed = 15;
    bool accounts_display_name_supported = 16;
    bool accounts_key_supported = 17;
    bool accounts_delete_supported = 18;
    bool accounts_soft_delete_supported = 19;
    bool accounts_move_supported = 20;
    bool accounts_rename_supported = 21;
    bool import_allowed = 22;
    bool accounts_spaces_supported = 23;
    bool per_account_version_supported = 24;
    bool per_provision_version_supported = 25;
    bool per_account_last_update_supported = 26;
    bool per_provision_last_update_supported = 27;
    bool operation_id_deduplication_supported = 28;
    bool sync_cool_down_disabled = 29;
    bool retry_cool_down_disabled = 30;
    bool sync_enabled = 31;
    bool grpc_tls_on = 32;
    MeteringKey metering_key = 33;
    int64 tracker_component_id = 34;
    int64 accountsSyncPageSize = 35;
    bool moveProvisionSupported = 36;
    intranet.d.backend.service.proto.FeatureState allocated_supported = 37;
    intranet.d.backend.service.proto.AggregationSettings aggregation_settings = 38;
    AggregationAlgorithm aggregation_algorithm = 39;
    intranet.d.backend.service.proto.ProviderUISettings ui_settings = 40;
    repeated intranet.d.backend.service.proto.ProviderExternalAccountUrlTemplate external_account_url_template = 41;
    intranet.d.backend.service.proto.FeatureState multiple_reserves_allowed = 42;
}

message ApiUri {
    string uri = 1;
}

message MeteringKey {
    string key = 1;
}

message Provider {
    string id = 1;
    int64 version = 2;
    string name_en = 3;
    string name_ru = 4;
    string description_en = 5;
    string description_ru = 6;
    ApiUri rest_api_uri = 7;
    ApiUri grpc_api_uri = 8;
    int64 source_tvm_id = 9;
    int64 destination_tvm_id = 10;
    int64 abc_service_id = 11;
    bool read_only = 12;
    bool multiple_accounts_per_folder = 13;
    bool account_transfer_with_quota = 14;
    bool managed = 15;
    string key = 16;
    bool accounts_display_name_supported = 17;
    bool accounts_key_supported = 18;
    bool accounts_delete_supported = 19;
    bool accounts_soft_delete_supported = 20;
    bool accounts_move_supported = 21;
    bool accounts_rename_supported = 22;
    bool import_allowed = 23;
    bool accounts_spaces_supported = 24;
    bool per_account_version_supported = 25;
    bool per_provision_version_supported = 26;
    bool per_account_last_update_supported = 27;
    bool per_provision_last_update_supported = 28;
    bool operation_id_deduplication_supported = 29;
    bool sync_cool_down_disabled = 30;
    bool retry_cool_down_disabled = 31;
    bool sync_enabled = 32;
    bool grpc_tls_on = 33;
    MeteringKey metering_key = 34;
    int64 tracker_component_id = 35;
    string reserve_folder_id = 36;
    bool has_default_quotas = 37;
    int64 accountsSyncPageSize = 38;
    bool moveProvisionSupported = 39;
    intranet.d.backend.service.proto.FeatureState allocated_supported = 40;
    intranet.d.backend.service.proto.AggregationSettings aggregation_settings = 41;
    AggregationAlgorithm aggregation_algorithm = 42;
    intranet.d.backend.service.proto.ProviderUISettings ui_settings = 43;
    repeated intranet.d.backend.service.proto.ProviderExternalAccountUrlTemplate external_account_url_template = 44;
    intranet.d.backend.service.proto.FeatureState multiple_reserves_allowed = 45;
}

enum AggregationQuotaQueryType {
    PAGINATE = 0;
    SCAN_SNAPSHOT = 1;
}

message AggregationAlgorithm {
    bool disabled = 1;
    int64 upsert_page_size = 2;
    AggregationQuotaQueryType quota_query_type = 3;
    bool concurrent_aggregates_upsert = 4;
    bool concurrent_aggregation = 5;
    int64 resources_page_size = 6;
    bool paginate_resources = 7;
    bool concurrent_cleanup = 8;
}

message CreateUnitsEnsembleRequest {
    string name_en = 1;
    string name_ru = 2;
    string description_en = 3;
    string description_ru = 4;
    bool fractions_allowed = 5;
    string key = 6;
    repeated CreateUnitRequest units = 7;
}

message CreateUnitRequest {
    string key = 1;
    string short_name_singular_ru_nominative = 2;
    string short_name_singular_ru_genitive = 3;
    string short_name_singular_ru_dative = 4;
    string short_name_singular_ru_accusative = 5;
    string short_name_singular_ru_instrumental = 6;
    string short_name_singular_ru_prepositional = 7;
    string short_name_plural_ru_nominative = 8;
    string short_name_plural_ru_genitive = 9;
    string short_name_plural_ru_dative = 10;
    string short_name_plural_ru_accusative = 11;
    string short_name_plural_ru_instrumental = 12;
    string short_name_plural_ru_prepositional = 13;
    string short_name_singular_en = 14;
    string short_name_plural_en = 15;
    string long_name_singular_ru_nominative = 16;
    string long_name_singular_ru_genitive = 17;
    string long_name_singular_ru_dative = 18;
    string long_name_singular_ru_accusative = 19;
    string long_name_singular_ru_instrumental = 20;
    string long_name_singular_ru_prepositional = 21;
    string long_name_plural_ru_nominative = 22;
    string long_name_plural_ru_genitive = 23;
    string long_name_plural_ru_dative = 24;
    string long_name_plural_ru_accusative = 25;
    string long_name_plural_ru_instrumental = 26;
    string long_name_plural_ru_prepositional = 27;
    string long_name_singular_en = 28;
    string long_name_plural_en = 29;
    int64 base = 30;
    int64 power = 31;
}

message UnitsEnsemble {
    string id = 1;
    int64 version = 2;
    string name_en = 3;
    string name_ru = 4;
    string description_en = 5;
    string description_ru = 6;
    bool fractions_allowed = 7;
    string key = 8;
    repeated Unit units = 9;
}

message Unit {
    string id = 1;
    string key = 2;
    string short_name_singular_ru_nominative = 3;
    string short_name_singular_ru_genitive = 4;
    string short_name_singular_ru_dative = 5;
    string short_name_singular_ru_accusative = 6;
    string short_name_singular_ru_instrumental = 7;
    string short_name_singular_ru_prepositional = 8;
    string short_name_plural_ru_nominative = 9;
    string short_name_plural_ru_genitive = 10;
    string short_name_plural_ru_dative = 11;
    string short_name_plural_ru_accusative = 12;
    string short_name_plural_ru_instrumental = 13;
    string short_name_plural_ru_prepositional = 14;
    string short_name_singular_en = 15;
    string short_name_plural_en = 16;
    string long_name_singular_ru_nominative = 17;
    string long_name_singular_ru_genitive = 18;
    string long_name_singular_ru_dative = 19;
    string long_name_singular_ru_accusative = 20;
    string long_name_singular_ru_instrumental = 21;
    string long_name_singular_ru_prepositional = 22;
    string long_name_plural_ru_nominative = 23;
    string long_name_plural_ru_genitive = 24;
    string long_name_plural_ru_dative = 25;
    string long_name_plural_ru_accusative = 26;
    string long_name_plural_ru_instrumental = 27;
    string long_name_plural_ru_prepositional = 28;
    string long_name_singular_en = 29;
    string long_name_plural_en = 30;
    int64 base = 31;
    int64 power = 32;
}
