Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
165 lines (144 sloc) 3.77 KB
syntax = "proto3";
package pathwar.server;
import "google/api/annotations.proto";
import "entity/entity.proto";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
import "protoc-gen-swagger/options/annotations.proto";
//import "google/protobuf/timestamp.proto";
option go_package = "pathwar.pw/server";
option (gogoproto.sizer_all) = true;
option (gogoproto.marshaler_all) = true;
option (gogoproto.unmarshaler_all) = true;
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = {
host: "api.pathwar.net";
base_path: "/";
info: {
title: "Pathwar API";
version: "1.0",
contact: {
name: "Pathwar Team";
url: "https://github.com/pathwar/pathwar";
email: "staff@pathwar.net";
};
license: {
name: "Apache-2.0";
url: "https://github.com/pathwar/pathwar/blob/master/LICENSE";
};
};
external_docs: {
url: "https://github.com/pathwar/pathwar";
description: "More about Pathwar";
};
//schemes: HTTP;
schemes: HTTPS;
schemes: WSS;
consumes: "application/json";
produces: "application/json";
security_definitions: {
security: {
key: "BasicAuth";
value: {
type: TYPE_BASIC;
};
};
security: {
key: "ApiKeyAuth";
value: {
type: TYPE_API_KEY;
in: IN_HEADER;
name: "X-API-Key";
};
};
};
security: {
security_requirement: {
key: "BasicAuth";
value: {};
};
security_requirement: {
key: "ApiKeyAuth";
value: {};
};
};
responses: {
key: "403";
value: {
description: "Returned when the user does not have permission to access the resource.";
};
};
responses: {
key: "404";
value: {
description: "Returned when the resource does not exist.";
schema: {
json_schema: {
type: STRING;
};
};
};
};
};
service Server {
//
// public stuff
//
// Create a session based on credentials
rpc Authenticate(AuthenticateInput) returns (AuthenticateOutput) {
option (google.api.http) = {
post: "/api/authenticate"
body: "*"
};
};
// Verify the service is up and running
rpc Ping(Void) returns (Void) {
option (google.api.http) = {get: "/api/ping"};
};
// Get current user's session
rpc UserSession(Void) returns (pathwar.entity.UserSession) {
option (google.api.http) = {get: "/api/user-session"};
};
// List tournaments
rpc Tournaments(Void) returns (pathwar.entity.TournamentList) {
option (google.api.http) = {get: "/api/tournaments"};
// FIXME: pagination & filters
};
// List users
rpc Users(Void) returns (pathwar.entity.UserList) {
option (google.api.http) = {get: "/api/users"};
// FIXME: pagination & filters
};
// List levels
rpc Levels(Void) returns (pathwar.entity.LevelList) {
option (google.api.http) = {get: "/api/levels"};
// FIXME: pagination & filters
};
// List teams
rpc Teams(Void) returns (pathwar.entity.TeamList) {
option (google.api.http) = {get: "/api/teams"};
// FIXME: pagination & filters
};
//
// dev stuff (should be disabled in production)
//
rpc GenerateFakeData(Void) returns (Void) {
option (google.api.http) = {post: "/api/dev/generate-fake-data"};
};
rpc Dump(Void) returns (pathwar.entity.Dump) {
option (google.api.http) = {post: "/api/dev/sql-dump"};
};
}
// Void is an empty message
message Void {
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_schema) = {
example: { value: '{}' };
};
}
// AuthenticateInput contains everything (credentials) to authenticate a user and create a new session.
message AuthenticateInput {
string username = 1;
string password = 2;
}
// AuthenticateOutput contains a session token (JWT).
message AuthenticateOutput {
string token = 1;
}
You can’t perform that action at this time.