Skip to content

Commit

Permalink
chore(app): set up app in protobuf repo (#447)
Browse files Browse the repository at this point in the history
Because

we are going to develop app backend.

This commit

sets up need initial file and change for app backend

---------

Co-authored-by: droplet-bot <[email protected]>
  • Loading branch information
Yougigun and droplet-bot authored Sep 4, 2024
1 parent 165fed7 commit 49b9539
Show file tree
Hide file tree
Showing 7 changed files with 1,269 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/buf-gen-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ jobs:
uses: readmeio/rdme@v8
with:
rdme: openapi:validate openapiv2/artifact/service.swagger.yaml
- name: Lint generated App OpenAPI definitions
uses: readmeio/rdme@v8
with:
rdme: openapi:validate openapiv2/app/service.swagger.yaml
- name: Commit and push
run: |
if [[ `git status --porcelain` ]]; then
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/sync-api-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- main
paths:
- 'openapiv2/artifact/**'
- 'openapiv2/app/**'
- 'openapiv2/common/**'
- 'openapiv2/core/**'
- 'openapiv2/model/**'
Expand Down Expand Up @@ -48,6 +49,11 @@ jobs:
uses: readmeio/rdme@v8
with:
rdme: openapi openapiv2/artifact/service.swagger.yaml --title "💾 Artifact (PR ${{ github.ref_name }})" --key=${{ secrets.README_API_KEY }} --id=669fb9c72dd8c500184c6531

# - name: Sync App 💾
# uses: readmeio/rdme@v8
# with:
# rdme: openapi openapiv2/app/service.swagger.yaml --title "📱 App (PR ${{ github.ref_name }})" --key=${{ secrets.README_API_KEY }} --id=669fb9c72dd8c500184c6531

- name: Check new release 🔍
id: check-new-release
Expand Down Expand Up @@ -102,6 +108,11 @@ jobs:
with:
rdme: openapi openapiv2/artifact/service.swagger.yaml --key=${{ secrets.README_API_KEY }} --id=669fb97f2071e2004a8f9183

# - name: Sync App 💾
# uses: readmeio/rdme@v8
# with:
# rdme: openapi openapiv2/app/service.swagger.yaml --key=${{ secrets.README_API_KEY }} --id=669fb97f2071e2004a8f9183

- name: Check new release 🔍
id: check-new-release
run: |
Expand Down
122 changes: 122 additions & 0 deletions app/app/v1alpha/app.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
syntax = "proto3";

package app.app.v1alpha;

import "common/healthcheck/v1beta/healthcheck.proto";
// Google API
import "google/api/field_behavior.proto";
// Protocol Buffers Well-Known Types
import "google/protobuf/timestamp.proto";

// LivenessRequest represents a request to check a service liveness status
message LivenessRequest {
// HealthCheckRequest message
optional common.healthcheck.v1beta.HealthCheckRequest health_check_request = 1 [(google.api.field_behavior) = OPTIONAL];
}

// LivenessResponse represents a response for a service liveness status
message LivenessResponse {
// HealthCheckResponse message
common.healthcheck.v1beta.HealthCheckResponse health_check_response = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// ReadinessRequest represents a request to check a service readiness status
message ReadinessRequest {
// HealthCheckRequest message
optional common.healthcheck.v1beta.HealthCheckRequest health_check_request = 1 [(google.api.field_behavior) = OPTIONAL];
}

// ReadinessResponse represents a response for a service readiness status
message ReadinessResponse {
// HealthCheckResponse message
common.healthcheck.v1beta.HealthCheckResponse health_check_response = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
}

/*
This API is under development and, therefore, some of its entities and
endpoints are not implemented yet. This section aims to give context about the
current interface and how it fits in the App vision.
# App
The App domain is responsible of ready-to-use AI applications.
*/

// App represents a app.
message App {
// The app id.
string app_id = 1 [(google.api.field_behavior) = REQUIRED];
// The app name.
string name = 2 [(google.api.field_behavior) = REQUIRED];
// The app description.
string description = 3 [(google.api.field_behavior) = OPTIONAL];
// The creation time of the app.
google.protobuf.Timestamp create_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
// The last update time of the app.
google.protobuf.Timestamp update_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
// The owner/namespace of the app.
string owner_name = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
// The app tags.
repeated string tags = 8 [(google.api.field_behavior) = OPTIONAL];
}

// CreateAppRequest represents a request to create a app.
message CreateAppRequest {
// The app's owner(namespaces).
string namespace_id = 1 [(google.api.field_behavior) = REQUIRED];
// The app name.
string name = 2 [(google.api.field_behavior) = REQUIRED];
// The app description.
string description = 3 [(google.api.field_behavior) = OPTIONAL];
// The app tags.
repeated string tags = 4 [(google.api.field_behavior) = OPTIONAL];
}

// CreateAppResponse represents a response for creating a app.
message CreateAppResponse {
// The created app.
App app = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Request message for ListApps
message ListAppsRequest {
// User ID for which to list the apps
string namespace_id = 1 [(google.api.field_behavior) = REQUIRED];
}

// GetAppsResponse represents a response for getting all apps from users.
message ListAppsResponse {
// The apps container.
repeated App apps = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// UpdateAppRequest represents a request to update a app.
message UpdateAppRequest {
// The app id.
string app_id = 1 [(google.api.field_behavior) = REQUIRED];
// The app description.
string description = 2 [(google.api.field_behavior) = OPTIONAL];
// The app tags.
repeated string tags = 3 [(google.api.field_behavior) = OPTIONAL];
// The app owner(namespace).
string namespace_id = 4 [(google.api.field_behavior) = REQUIRED];
}

// UpdateAppResponse represents a response for updating a app.
message UpdateAppResponse {
// The updated app.
App app = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// DeleteAppRequest represents a request to delete a app.
message DeleteAppRequest {
// The owner's id. i.e. namespace.
string namespace_id = 1 [(google.api.field_behavior) = REQUIRED];
// The app id.
string app_id = 2 [(google.api.field_behavior) = REQUIRED];
}

// DeleteAppResponse represents a response for deleting a app.
message DeleteAppResponse {}
125 changes: 125 additions & 0 deletions app/app/v1alpha/app_public_service.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
syntax = "proto3";

package app.app.v1alpha;

// App definitions
import "app/app/v1alpha/app.proto";
import "app/app/v1alpha/conversation.proto";
// Google API
import "google/api/annotations.proto";
import "google/api/visibility.proto";
// OpenAPI definition
import "protoc-gen-openapiv2/options/annotations.proto";

// AppPublicService exposes the public endpoints that allow clients to
// manage apps.
service AppPublicService {
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_tag) = {description: "Public App endpoints"};

// Check if the app server is alive
//
// See https://github.com/grpc/grpc/blob/master/doc/health-checking.md.
rpc Liveness(LivenessRequest) returns (LivenessResponse) {
option (google.api.http) = {
get: "/v1alpha/__liveness"
additional_bindings: [
{get: "/v1alpha/health/app"}]
};
option (google.api.method_visibility).restriction = "INTERNAL";
}

// Check if the app server is ready
//
// See https://github.com/grpc/grpc/blob/master/doc/health-checking.md
rpc Readiness(ReadinessRequest) returns (ReadinessResponse) {
option (google.api.http) = {
get: "/v1alpha/__readiness"
additional_bindings: [
{get: "/v1alpha/ready/app"}]
};
option (google.api.method_visibility).restriction = "INTERNAL";
}

// Create a App
rpc CreateApp(CreateAppRequest) returns (CreateAppResponse) {
option (google.api.http) = {
post: "/v1alpha/namespaces/{namespace_id}/apps"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "App"};
}

// Get all apps info
rpc ListApps(ListAppsRequest) returns (ListAppsResponse) {
option (google.api.http) = {get: "/v1alpha/namespaces/{namespace_id}/apps"};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "App"};
}

// Update a app info
rpc UpdateApp(UpdateAppRequest) returns (UpdateAppResponse) {
option (google.api.http) = {
put: "/v1alpha/namespaces/{namespace_id}/apps/{app_id}"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "App"};
}

// Delete a app
rpc DeleteApp(DeleteAppRequest) returns (DeleteAppResponse) {
option (google.api.http) = {delete: "/v1alpha/namespaces/{namespace_id}/apps/{app_id}"};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "App"};
}

// Create a Conversation
rpc CreateConversation(CreateConversationRequest) returns (CreateConversationResponse) {
option (google.api.http) = {
post: "/v1alpha/namespaces/{namespace_id}/apps/{app_id}/conversations"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "app"};
}
// List conversations
rpc ListConversations(ListConversationsRequest) returns (ListConversationsResponse) {
option (google.api.http) = {get: "/v1alpha/namespaces/{namespace_id}/apps/{app_id}/conversations"};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "app"};
}
// Update a conversation
rpc UpdateConversation(UpdateConversationRequest) returns (UpdateConversationResponse) {
option (google.api.http) = {
put: "/v1alpha/namespaces/{namespace_id}/apps/{app_id}/conversations/{conversation_id}"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "app"};
}
// Delete a conversation
rpc DeleteConversation(DeleteConversationRequest) returns (DeleteConversationResponse) {
option (google.api.http) = {delete: "/v1alpha/namespaces/{namespace_id}/apps/{app_id}/conversations/{conversation_id}"};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "app"};
}
// Create a message
rpc CreateMessage(CreateMessageRequest) returns (CreateMessageResponse) {
option (google.api.http) = {
post: "/v1alpha/namespaces/{namespace_id}/apps/{app_id}/conversations/{conversation_id}/messages"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "app"};
}
// List messages
rpc ListMessages(ListMessagesRequest) returns (ListMessagesResponse) {
option (google.api.http) = {get: "/v1alpha/namespaces/{namespace_id}/apps/{app_id}/conversations/{conversation_id}/messages"};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "app"};
}
// Update a message
rpc UpdateMessage(UpdateMessageRequest) returns (UpdateMessageResponse) {
option (google.api.http) = {
put: "/v1alpha/namespaces/{namespace_id}/apps/{app_id}/conversations/{conversation_id}/messages/{message_uid}"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "app"};
}
// Delete a message
rpc DeleteMessage(DeleteMessageRequest) returns (DeleteMessageResponse) {
option (google.api.http) = {delete: "/v1alpha/namespaces/{namespace_id}/apps/{app_id}/conversations/{conversation_id}/messages/{message_uid}"};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "app"};
}
}
Loading

0 comments on commit 49b9539

Please sign in to comment.