syntax = "proto3";

package automation_tool.src;

import "google/protobuf/empty.proto";

service AuthController {
    rpc ChangePassword(ChangePasswordRequestRequest) returns (ChangePasswordResponseResponse) {}
    rpc InitiatePasswordReset(InitiatePasswordResetRequestRequest) returns (InitiatePasswordResetResponseResponse) {}
    rpc Login(LoginRequestRequest) returns (LoginResponseResponse) {}
    rpc RegisterUser(RegisterUserRequestRequest) returns (UserResponseResponse) {}
}

service CountyController {
    rpc Create(CountyCreateUpdateRequestRequest) returns (CountyResponse) {}
    rpc Delete(CountyGetRequestRequest) returns (google.protobuf.Empty) {}
    rpc List(CountyListRequest) returns (CountyPaginatedResponseResponse) {}
    rpc Update(CountyCreateUpdateRequestRequest) returns (CountyResponse) {}
}

service DataJobController {
    rpc Delete(DataJobDeleteRequest) returns (google.protobuf.Empty) {}
    rpc GetScratchData(ScratchDataRequestRequest) returns (DataJobGetScratchDataResponse) {}
    rpc List(DataJobListRequest) returns (DataJobListResponseResponse) {}
    rpc UpdateScratchData(UpdateRecordDataRequest) returns (UpdateRecordDataResponse) {}
}

service EssentialController {
    rpc GetEssential(google.protobuf.Empty) returns (EssentialResponseResponse) {}
}

service JobController {
    rpc Create(JobCreateRequest) returns (JobResponseResponse) {}
    rpc Delete(JobDeleteRequest) returns (google.protobuf.Empty) {}
    rpc Get(JobGetRequestRequest) returns (JobResponseResponse) {}
    rpc List(JobListRequest) returns (JobPaginatedResponseResponse) {}
    rpc RunJob(JobRunJobRequest) returns (google.protobuf.Empty) {}
    rpc Update(JobUpdateRequest) returns (JobResponseResponse) {}
}

service UserController {
    rpc Create(UserCreateRequest) returns (UserResponseResponse) {}
    rpc Delete(UserDeleteRequest) returns (google.protobuf.Empty) {}
    rpc List(UserListRequest) returns (UserPaginatedResponseResponse) {}
    rpc Retrieve(UserRetrieveRequest) returns (UserResponseResponse) {}
    rpc Update(UserUpdateRequest) returns (UserResponseResponse) {}
}

message ChangePasswordRequestRequest {
    string email = 1;
    string new_password = 2;
    string token = 3;
}

message ChangePasswordResponseResponse {
    string message = 1;
}

message ChoiceResponse {
    string value = 1;
    string name = 2;
}

message CountyCreateUpdateRequestRequest {
    optional string id = 1;
    string title = 2;
    string description = 3;
    int32 quantity_job = 4;
    optional string manager_id = 5;
}

message CountyGetRequestRequest {
    string id = 1;
}

message CountyListRequest {
    string search = 1;
    string order_by = 2;
    int32 page = 3;
    int32 page_size = 4;
}

message CountyPaginatedResponseResponse {
    optional int32 page = 1;
    optional int32 page_size = 2;
    optional int32 total = 3;
    repeated CountyResponse data = 4;
}

message CountyResponse {
    string id = 1;
    string title = 2;
    string description = 3;
    string created_at = 4;
    string updated_at = 5;
    int32 quantity_job = 6;
    UserResponseResponse manager = 7;
}

message DataJobDeleteRequest {
    string data_job_id = 1;
}

message DataJobGetScratchDataResponse {
    int32 page = 1;
    int32 page_size = 2;
    int64 total = 3;
    bytes data = 4;
}

message DataJobHistoryResponseResponse {
    string id = 1;
    string user_name = 2;
    string created_at = 3;
    string updated_at = 4;
}

message DataJobListRequest {
    string job_id = 1;
    int32 page = 2;
    int32 page_size = 3;
}

message DataJobListResponseResponse {
    int32 page = 1;
    int32 page_size = 2;
    int32 total = 3;
    repeated DataJobResponseResponse data = 4;
}

message DataJobResponseResponse {
    string id = 1;
    string scratch_datetime = 2;
    string status = 3;
    repeated DataJobHistoryResponseResponse data_job_histories = 4;
}

message EssentialResponseResponse {
    repeated RoleResponseResponse roles = 1;
    UserResponseResponse me = 2;
    repeated ChoiceResponse user_status_choices = 3;
}

message InitiatePasswordResetRequestRequest {
    string email = 1;
}

message InitiatePasswordResetResponseResponse {
    string message = 1;
}

message JobCreateRequest {
    string name = 1;
    string url = 3;
    string action_code = 4;
    string frequency = 5;
    optional string start_date = 6;
    optional string end_date = 7;
    string county_id = 8;
    optional int32 day_of_week = 9;
    optional int32 day_of_month = 10;
}

message JobDeleteRequest {
    string job_id = 1;
}

message JobGetRequestRequest {
    string id = 1;
}

message JobListRequest {
    string search = 1;
    string order_by = 2;
    int32 page = 3;
    int32 page_size = 4;
}

message JobPaginatedResponseResponse {
    int32 page = 1;
    int32 page_size = 2;
    int32 total = 3;
    repeated JobResponseResponse data = 4;
}

message JobResponseResponse {
    string id = 1;
    string name = 2;
    CountyResponse county = 3;
    string url = 4;
    string action_code = 5;
    string frequency = 6;
    string start_date = 7;
    optional string end_date = 8;
    string created_at = 9;
    string updated_at = 10;
    UserResponseResponse user = 11;
    optional int32 day_of_week = 12;
    optional int32 day_of_month = 13;
}

message JobRunJobRequest {
    string job_id = 1;
}

message JobUpdateRequest {
    string id = 1;
    optional string name = 2;
    optional string county = 3;
    optional string url = 4;
    optional string action_code = 5;
    optional string frequency = 6;
    optional string start_date = 7;
    optional string end_date = 8;
    optional int32 day_of_week = 9;
    optional int32 day_of_month = 10;
}

message LoginRequestRequest {
    string email = 1;
    string password = 2;
}

message LoginResponseResponse {
    string user_id = 1;
    string email = 2;
    string token = 3;
    repeated string permission = 4;
}

message RegisterUserRequestRequest {
    string first_name = 1;
    string last_name = 2;
    string email = 3;
    string password = 4;
    string role_slug = 5;
}

message RoleResponseResponse {
    string id = 1;
    string slug = 2;
    string name = 3;
}

message ScratchDataRequestRequest {
    string data_job_id = 1;
    optional int32 page = 2;
    optional int32 page_size = 3;
}

message UpdateRecordDataRequest {
    string data_job_id = 1;
    string record_data_id = 2;
    string record_data = 3;
}

message UpdateRecordDataResponse {
    string data_job_id = 1;
    string record_data_id = 2;
    string record_data = 3;
}

message UserCreateRequest {
    string email = 1;
    string password = 2;
    string first_name = 3;
    string last_name = 4;
    repeated string roles = 5;
    string user_status = 6;
}

message UserDeleteRequest {
    string id = 1;
}

message UserListRequest {
    string search = 1;
    string order_by = 2;
    int32 page = 3;
    int32 page_size = 4;
}

message UserPaginatedResponseResponse {
    int32 page = 1;
    int32 page_size = 2;
    int32 total = 3;
    repeated UserResponseResponse data = 4;
}

message UserResponseResponse {
    string id = 1;
    string first_name = 2;
    string last_name = 3;
    string email = 4;
    string user_status = 5;
    string created_at = 6;
    repeated RoleResponseResponse roles = 7;
}

message UserRetrieveRequest {
    string id = 1;
}

message UserUpdateRequest {
    string id = 1;
    optional string first_name = 2;
    optional string last_name = 3;
    repeated string roles = 4;
    optional string user_status = 5;
}

