Skip to content

Commit

Permalink
finished all crud ops
Browse files Browse the repository at this point in the history
  • Loading branch information
rizesql committed May 26, 2024
1 parent c918c14 commit 08cb592
Show file tree
Hide file tree
Showing 21 changed files with 955 additions and 25 deletions.
14 changes: 14 additions & 0 deletions proto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,33 @@ cmake_path(SET issues_proto ${CMAKE_CURRENT_SOURCE_DIR}/reasy/api/v1/issues.prot
cmake_path(SET issues_header ${CMAKE_CURRENT_BINARY_DIR}/reasy/api/v1/issues.pb.h)
cmake_path(SET issues_source ${CMAKE_CURRENT_BINARY_DIR}/reasy/api/v1/issues.pb.cc)

cmake_path(SET projects_proto ${CMAKE_CURRENT_SOURCE_DIR}/reasy/api/v1/projects.proto)
cmake_path(SET projects_header ${CMAKE_CURRENT_BINARY_DIR}/reasy/api/v1/projects.pb.h)
cmake_path(SET projects_source ${CMAKE_CURRENT_BINARY_DIR}/reasy/api/v1/projects.pb.cc)

cmake_path(SET workspaces_proto ${CMAKE_CURRENT_SOURCE_DIR}/reasy/api/v1/workspaces.proto)
cmake_path(SET workspaces_header ${CMAKE_CURRENT_BINARY_DIR}/reasy/api/v1/workspaces.pb.h)
cmake_path(SET workspaces_source ${CMAKE_CURRENT_BINARY_DIR}/reasy/api/v1/workspaces.pb.cc)

set(protos
${users_proto}
${issues_proto}
${projects_proto}
${workspaces_proto}
)

set(headers
${users_header}
${issues_header}
${projects_header}
${workspaces_header}
)

set(sources
${users_source}
${issues_source}
${projects_source}
${workspaces_source}
)

add_custom_command(
Expand Down
6 changes: 5 additions & 1 deletion proto/reasy/api/v1/issues.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ service issues {
rpc Get(IssuesGetRequest) returns (IssuesGetResponse) {}
rpc Create(IssuesCreateRequest) returns (reasy.core.Empty) {}
rpc Assign(IssuesAssignRequest) returns (reasy.core.Empty) {}
rpc RemoveAssignee(reasy.core.Empty) returns (reasy.core.Empty) {}
rpc RemoveAssignee(IssuesRemoveAssigneeRequest) returns (reasy.core.Empty) {}
rpc AddToProject(IssuesAddToProjectRequest) returns (reasy.core.Empty) {}
rpc ChangePriority(IssuesChangePriorityRequest) returns (reasy.core.Empty) {}
rpc ChangeStatus(IssuesChangeStatusRequest) returns (reasy.core.Empty) {}
Expand Down Expand Up @@ -71,6 +71,10 @@ message IssuesAssignRequest {
string assignee_id = 2;
}

message IssuesRemoveAssigneeRequest {
string issue_id = 1;
}

message IssuesAddToProjectRequest {
string issue_id = 1;
string project_id = 2;
Expand Down
42 changes: 42 additions & 0 deletions proto/reasy/api/v1/projects.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
syntax = "proto3";

package reasy.api.v1;

import "google/protobuf/struct.proto";
import "reasy/core.proto";

service projects {
rpc GetAll(reasy.core.Empty) returns (ProjectsGetAllResponse) {}
rpc Get(ProjectsGetRequest) returns (Project) {}
rpc Create(ProjectsCreateRequest) returns (Project) {}
rpc ChangeName(ProjectsChangeNameRequest) returns (reasy.core.Empty) {}
rpc Delete(ProjectsDeleteRequest) returns (reasy.core.Empty) {}
}

message Project {
string id = 1;
string workspace_id = 2;
string name = 3;
}

message ProjectsGetRequest {
string id = 1;
}

message ProjectsCreateRequest {
string workspace_id = 1;
string name = 2;
}

message ProjectsChangeNameRequest {
string id = 1;
string name = 2;
}

message ProjectsDeleteRequest {
string id = 1;
}

message ProjectsGetAllResponse {
repeated Project projects = 1;
}
34 changes: 28 additions & 6 deletions proto/reasy/api/v1/users.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ package reasy.api.v1;
import "google/protobuf/struct.proto";

service users {
rpc GetAll(UsersGetAllRequest) returns (UsersGetAllResponse) {}
rpc Get(Empty) returns (User) {}
rpc GetAll(Empty) returns (UsersGetAllResponse) {}
rpc Get(UsersGetRequest) returns (User) {}
rpc Create(UsersCreateRequest) returns (User) {}
rpc ChangeName(UsersChangeNameRequest) returns (Empty) {}
rpc ChangeUsername(UsersChangeUsernameRequest) returns (Empty) {}
rpc Delete(UsersDeleteRequest) returns (Empty) {}
}

message Empty {}
Expand All @@ -18,13 +22,31 @@ message User {
string email = 4;
}

message UsersGetAllRequest {
optional string segment = 1;
message UsersGetRequest {
string id = 1;
}

message UsersCreateRequest {
string name = 1;
string username = 2;
string email = 3;
}

message UsersChangeNameRequest {
string id = 1;
string new_name = 2;
}

message UsersChangeUsernameRequest {
string id = 1;
string new_username = 2;
}

message UsersDeleteRequest {
string id = 1;
}

message UsersGetAllResponse {
repeated User users = 1;

optional string cursor = 2;
}

48 changes: 48 additions & 0 deletions proto/reasy/api/v1/workspaces.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
syntax = "proto3";

package reasy.api.v1;

import "google/protobuf/struct.proto";
import "reasy/core.proto";

service workspaces {
rpc GetAll(reasy.core.Empty) returns (WorkspacesGetAllResponse) {}
rpc Get(WorkspacesGetRequest) returns (Workspace) {}
rpc Create(WorkspacesCreateRequest) returns(Workspace) {}
rpc ChangeAdmin(WorkspacesChangeAdminRequest) returns (reasy.core.Empty) {}
rpc ChangeName(WorkspacesChangeNameRequest) returns (reasy.core.Empty) {}
rpc Delete(WorkspacesDeleteRequest) returns (reasy.core.Empty) {}
}

message Workspace {
string id = 1;
string admin_id = 2;
string name = 3;
}

message WorkspacesGetRequest {
string id = 1;
}

message WorkspacesCreateRequest {
string admin_id = 1;
string name = 2;
}

message WorkspacesChangeAdminRequest {
string id = 1;
string new_admin_id = 2;
}

message WorkspacesChangeNameRequest {
string id = 1;
string new_name = 2;
}

message WorkspacesDeleteRequest {
string id = 1;
}

message WorkspacesGetAllResponse {
repeated Workspace workspaces = 1;
}
28 changes: 28 additions & 0 deletions requests/issues.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

###
GRPC localhost:8080/reasy.api.v1.issues/Get

{
"issue_id": "cp9k0kjjuspjbfubl0s0"
}

###
GRPC localhost:8080/reasy.api.v1.issues/Create

{
"project_id": "cc0a2mn6i1e6brmdbip0",
"creator_id": "cc0aar76i1e6jr6no620",
"name": "Issue #2",
"description": "hello world plz",
"status": 1,
"priority": 2,
"assignee_id": "cc0a2mn6i1e6brmdbip0"
}

###
GRPC localhost:8080/reasy.api.v1.issues/ChangePriority

{
"issue_id": "cp9k0kjjuspjbfubl0s0",
"new_priority": 3
}
35 changes: 35 additions & 0 deletions requests/projects.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@url = localhost:8080/reasy.api.v1.projects
@id = "cp9nk6bjuspm2rts0la0"

###
GRPC {{url}}/GetAll

###
GRPC {{url}}/Get

{
"id": {{id}}
}

###
GRPC {{url}}/Create

{
"workspace_id": "workspace1",
"name": "hello world"
}

###
GRPC {{url}}/ChangeName

{
"id": {{id}},
"name": "workspace2 edit"
}

###
GRPC {{url}}/Delete

{
"id": {{id}}
}
45 changes: 45 additions & 0 deletions requests/users.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
@url = localhost:8080/reasy.api.v1.users
@id = "cp9m3jjjuspkirgm5ds0"

###
GRPC {{url}}/GetAll

###
GRPC {{url}}/Get

{
"id": {{id}}
}

###
GRPC {{url}}/Create

{
"name": "Reezy 2",
"username": "@rizesql2_",
"email": "mail2+new@mail.com"
}

###
GRPC {{url}}/ChangeName

{
"id": {{id}},
"new_name": "new Reezy"
}

###
GRPC {{url}}/ChangeUsername

{
"id": {{id}},
"new_username": "new @rizesql_"
}

###
GRPC {{url}}/Delete

{
"id": {{id}}
}

43 changes: 43 additions & 0 deletions requests/workspaces.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
@url = localhost:8080/reasy.api.v1.workspaces
@id = ""

###
GRPC {{url}}/GetAll

###
GRPC {{url}}/Get

{
"id": {{id}}
}

###
GRPC {{url}}/Create

{
"admin_id": "",
"name": ""
}

###
GRPC {{url}}/ChangeAdmin

{
"id": "",
"new_admin_id": ""
}

###
GRPC {{url}}/ChangeName

{
"id": "",
"new_name": ""
}

###
GRPC {{url}}/Delete

{
"id": {{id}}
}
5 changes: 4 additions & 1 deletion src/api/v1.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
#include "wrapper.h"
#include "users_service.h"
#include "issues_service.h"
#include "projects_service.h"

namespace api::v1 {
using issues = Wrapper<api::issues::Rpc>;
using projects = Wrapper<api::projects::Rpc>;
using users = Wrapper<api::users::Rpc>;
}
using workspaces = Wrapper<api::projects::Rpc>;
}
2 changes: 1 addition & 1 deletion src/issues/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ target_sources(issues
target_link_libraries(issues
PRIVATE ${PROJECT_NAME}::core
PRIVATE ${PROJECT_NAME}::libproto
)
)
Loading

0 comments on commit 08cb592

Please sign in to comment.