1

feat: fill out apis
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Mya 2023-12-31 13:41:06 -06:00
parent 5c53a95d3b
commit f068352bf7
Signed by: mya
GPG Key ID: 4DFBA0F91AC3544A
7 changed files with 661 additions and 236 deletions

@ -14,31 +14,44 @@ package contributors.v1;
import "google/api/annotations.proto"; import "google/api/annotations.proto";
enum Role {
ROLE_UNSPECIFIED = 0;
ROLE_OWNER = 1;
}
message Contributor {
string id = 1;
string product_id = 2;
string email = 3;
Role role = 4;
}
message ListRequest { message ListRequest {
string product_id = 1; string product_id = 5;
} }
message ListResponse {} message ListResponse {
repeated Contributor contributors = 5;
message CreateRequest {
string product_id = 1;
} }
message CreateResponse {} message InviteRequest {
Contributor contributor = 1;
}
message InviteResponse {}
message UpdateRequest { message UpdateRequest {
string product_id = 1; Contributor contributor = 1;
string contributor_id = 2;
} }
message UpdateResponse {} message UpdateResponse {}
message DeleteRequest { message RevokeRequest {
string product_id = 1; string product_id = 1;
string contributor_id = 2; string contributor_id = 2;
} }
message DeleteResponse {} message RevokeResponse {}
service ContributorService { service ContributorService {
rpc List(ListRequest) returns (ListResponse) { rpc List(ListRequest) returns (ListResponse) {
@ -47,21 +60,21 @@ service ContributorService {
}; };
}; };
rpc Create(CreateRequest) returns (CreateResponse) { rpc Invite(InviteRequest) returns (InviteResponse) {
option (google.api.http) = { option (google.api.http) = {
post: "/v1/products/{product_id}/contributors" post: "/v1/products/{contributor.product_id}/contributors"
body: "*" body: "*"
}; };
}; };
rpc Update(UpdateRequest) returns (UpdateResponse) { rpc Update(UpdateRequest) returns (UpdateResponse) {
option (google.api.http) = { option (google.api.http) = {
post: "/v1/products/{product_id}/contributors/{contributor_id}" post: "/v1/products/{contributor.product_id}/contributors/{contributor.id}"
body: "*" body: "*"
}; };
}; };
rpc Delete(DeleteRequest) returns (DeleteResponse) { rpc Revoke(RevokeRequest) returns (RevokeResponse) {
option (google.api.http) = { option (google.api.http) = {
delete: "/v1/products/{product_id}/contributors/{contributor_id}" delete: "/v1/products/{product_id}/contributors/{contributor_id}"
}; };

@ -14,11 +14,21 @@ package licenses.v1;
import "google/api/annotations.proto"; import "google/api/annotations.proto";
message License {
string id = 1;
string product_id = 2;
string package_name = 3;
}
message ListRequest {} message ListRequest {}
message ListResponse {} message ListResponse {
repeated License licenses = 1;
}
message PurchaseRequest {} message PurchaseRequest {
License license = 1;
}
message PurchaseResponse {} message PurchaseResponse {}

@ -14,14 +14,22 @@ package packages.v1;
import "google/api/annotations.proto"; import "google/api/annotations.proto";
message ListRequest { message Package {
string product_id = 1; string id = 1;
string product_id = 2;
string name = 3;
} }
message ListResponse {} message ListRequest {
string product_id = 5;
}
message ListResponse {
repeated Package packages = 5;
}
message CreateRequest { message CreateRequest {
string product_id = 1; Package package = 1;
} }
message CreateResponse {} message CreateResponse {}
@ -31,11 +39,12 @@ message ReadRequest {
string package_name = 2; string package_name = 2;
} }
message ReadResponse {} message ReadResponse {
Package package = 1;
}
message UpdateRequest { message UpdateRequest {
string product_id = 1; Package package = 1;
string package_name = 2;
} }
message UpdateResponse {} message UpdateResponse {}
@ -56,7 +65,7 @@ service PackageService {
rpc Create(CreateRequest) returns (CreateResponse) { rpc Create(CreateRequest) returns (CreateResponse) {
option (google.api.http) = { option (google.api.http) = {
post: "/v1/products/{product_id}/packages" post: "/v1/products/{package.product_id}/packages"
body: "*" body: "*"
}; };
}; };
@ -69,7 +78,7 @@ service PackageService {
rpc Update(UpdateRequest) returns (UpdateResponse) { rpc Update(UpdateRequest) returns (UpdateResponse) {
option (google.api.http) = { option (google.api.http) = {
post: "/v1/products/{product_id}/packages/{package_name}" post: "/v1/products/{package.product_id}/packages/{package.name}"
body: "*" body: "*"
}; };
}; };

@ -14,11 +14,21 @@ package products.v1;
import "google/api/annotations.proto"; import "google/api/annotations.proto";
message Product {
string id = 1;
string name = 2;
string description = 3;
}
message ListRequest {} message ListRequest {}
message ListResponse {} message ListResponse {
repeated Product products = 5;
}
message CreateRequest {} message CreateRequest {
Product product = 1;
}
message CreateResponse {} message CreateResponse {}
@ -26,10 +36,12 @@ message ReadRequest {
string product_id = 1; string product_id = 1;
} }
message ReadResponse {} message ReadResponse {
Product product = 1;
}
message UpdateRequest { message UpdateRequest {
string product_id = 1; Product product = 1;
} }
message UpdateResponse {} message UpdateResponse {}
@ -62,7 +74,7 @@ service ProductService {
rpc Update(UpdateRequest) returns (UpdateResponse) { rpc Update(UpdateRequest) returns (UpdateResponse) {
option (google.api.http) = { option (google.api.http) = {
post: "/v1/products/{product_id}" post: "/v1/products/{product.id}"
body: "*" body: "*"
}; };
}; };

@ -3,19 +3,31 @@
"application/json" "application/json"
], ],
"definitions": { "definitions": {
"contributorsv1CreateResponse": {
"type": "object"
},
"contributorsv1DeleteResponse": {
"type": "object"
},
"contributorsv1ListResponse": { "contributorsv1ListResponse": {
"properties": {
"contributors": {
"items": {
"$ref": "#/definitions/v1Contributor",
"type": "object"
},
"type": "array"
}
},
"type": "object" "type": "object"
}, },
"contributorsv1UpdateResponse": { "contributorsv1UpdateResponse": {
"type": "object" "type": "object"
}, },
"licensesv1ListResponse": { "licensesv1ListResponse": {
"properties": {
"licenses": {
"items": {
"$ref": "#/definitions/v1License",
"type": "object"
},
"type": "array"
}
},
"type": "object" "type": "object"
}, },
"packagesv1CreateResponse": { "packagesv1CreateResponse": {
@ -25,15 +37,34 @@
"type": "object" "type": "object"
}, },
"packagesv1ListResponse": { "packagesv1ListResponse": {
"properties": {
"packages": {
"items": {
"$ref": "#/definitions/v1Package",
"type": "object"
},
"type": "array"
}
},
"type": "object" "type": "object"
}, },
"packagesv1ReadResponse": { "packagesv1ReadResponse": {
"properties": {
"package": {
"$ref": "#/definitions/v1Package"
}
},
"type": "object" "type": "object"
}, },
"packagesv1UpdateResponse": { "packagesv1UpdateResponse": {
"type": "object" "type": "object"
}, },
"productsv1CreateRequest": { "productsv1CreateRequest": {
"properties": {
"product": {
"$ref": "#/definitions/v1Product"
}
},
"type": "object" "type": "object"
}, },
"productsv1CreateResponse": { "productsv1CreateResponse": {
@ -43,9 +74,23 @@
"type": "object" "type": "object"
}, },
"productsv1ListResponse": { "productsv1ListResponse": {
"properties": {
"products": {
"items": {
"$ref": "#/definitions/v1Product",
"type": "object"
},
"type": "array"
}
},
"type": "object" "type": "object"
}, },
"productsv1ReadResponse": { "productsv1ReadResponse": {
"properties": {
"product": {
"$ref": "#/definitions/v1Product"
}
},
"type": "object" "type": "object"
}, },
"productsv1UpdateResponse": { "productsv1UpdateResponse": {
@ -80,40 +125,240 @@
"type": "object" "type": "object"
}, },
"tokensv1CreateRequest": { "tokensv1CreateRequest": {
"properties": {
"token": {
"$ref": "#/definitions/v1Token"
}
},
"type": "object" "type": "object"
}, },
"tokensv1CreateResponse": { "tokensv1CreateResponse": {
"properties": {
"token": {
"type": "string"
}
},
"type": "object" "type": "object"
}, },
"tokensv1DeleteResponse": { "tokensv1DeleteResponse": {
"type": "object" "type": "object"
}, },
"tokensv1ListResponse": { "tokensv1ListResponse": {
"properties": {
"tokens": {
"items": {
"$ref": "#/definitions/v1Token",
"type": "object"
},
"type": "array"
}
},
"type": "object" "type": "object"
}, },
"v1AuthenticateRequest": { "v1AuthenticateRequest": {
"properties": {
"clientId": {
"title": "required for a handful of workflows\ncan also come from the basic auth header",
"type": "string"
},
"clientSecret": {
"type": "string"
},
"code": {
"title": "grant_type=authorization_code",
"type": "string"
},
"codeVerifier": {
"type": "string"
},
"grantType": {
"title": "grant_type = client_credentials, refresh_token, password, authorization_code, license",
"type": "string"
},
"license": {
"title": "grant_type=license",
"type": "string"
},
"password": {
"type": "string"
},
"redirectUri": {
"type": "string"
},
"refreshToken": {
"title": "grant_type=refresh_token",
"type": "string"
},
"scope": {
"type": "string"
},
"username": {
"title": "grant_type=password",
"type": "string"
}
},
"type": "object" "type": "object"
}, },
"v1AuthenticateResponse": { "v1AuthenticateResponse": {
"properties": {
"accessToken": {
"type": "string"
},
"error": {
"type": "string"
},
"errorDescription": {
"type": "string"
},
"errorUri": {
"type": "string"
},
"expiresIn": {
"format": "int32",
"type": "integer"
},
"refreshToken": {
"type": "string"
},
"scope": {
"type": "string"
},
"tokenType": {
"type": "string"
}
},
"type": "object" "type": "object"
}, },
"v1CancelResponse": { "v1CancelResponse": {
"type": "object" "type": "object"
}, },
"v1Contributor": {
"properties": {
"email": {
"type": "string"
},
"id": {
"type": "string"
},
"productId": {
"type": "string"
},
"role": {
"$ref": "#/definitions/v1Role"
}
},
"type": "object"
},
"v1CurrentResponse": { "v1CurrentResponse": {
"type": "object" "type": "object"
}, },
"v1InviteResponse": {
"type": "object"
},
"v1License": {
"properties": {
"id": {
"type": "string"
},
"packageName": {
"type": "string"
},
"productId": {
"type": "string"
}
},
"type": "object"
},
"v1Package": {
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"productId": {
"type": "string"
}
},
"type": "object"
},
"v1Product": {
"properties": {
"description": {
"type": "string"
},
"id": {
"type": "string"
},
"name": {
"type": "string"
}
},
"type": "object"
},
"v1PurchaseRequest": { "v1PurchaseRequest": {
"properties": {
"license": {
"$ref": "#/definitions/v1License"
}
},
"type": "object" "type": "object"
}, },
"v1PurchaseResponse": { "v1PurchaseResponse": {
"type": "object" "type": "object"
}, },
"v1RevokeResponse": {
"type": "object"
},
"v1Role": {
"default": "ROLE_UNSPECIFIED",
"enum": [
"ROLE_UNSPECIFIED",
"ROLE_OWNER"
],
"type": "string"
},
"v1SignupRequest": { "v1SignupRequest": {
"properties": {
"email": {
"type": "string"
},
"password": {
"type": "string"
}
},
"type": "object" "type": "object"
}, },
"v1SignupResponse": { "v1SignupResponse": {
"type": "object" "type": "object"
},
"v1Token": {
"properties": {
"expiresAt": {
"type": "string"
},
"expiresIn": {
"type": "string"
},
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"noExpiry": {
"title": "one of",
"type": "boolean"
},
"scopes": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
} }
}, },
"info": { "info": {
@ -255,6 +500,273 @@
] ]
} }
}, },
"/v1/products/{contributor.productId}/contributors": {
"post": {
"operationId": "ContributorService_Invite",
"parameters": [
{
"in": "path",
"name": "contributor.productId",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "body",
"required": true,
"schema": {
"properties": {
"contributor": {
"properties": {
"email": {
"type": "string"
},
"id": {
"type": "string"
},
"role": {
"$ref": "#/definitions/v1Role"
}
},
"type": "object"
}
},
"type": "object"
}
}
],
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1InviteResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"tags": [
"ContributorService"
]
}
},
"/v1/products/{contributor.productId}/contributors/{contributor.id}": {
"post": {
"operationId": "ContributorService_Update",
"parameters": [
{
"in": "path",
"name": "contributor.productId",
"required": true,
"type": "string"
},
{
"in": "path",
"name": "contributor.id",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "body",
"required": true,
"schema": {
"properties": {
"contributor": {
"properties": {
"email": {
"type": "string"
},
"role": {
"$ref": "#/definitions/v1Role"
}
},
"type": "object"
}
},
"type": "object"
}
}
],
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/contributorsv1UpdateResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"tags": [
"ContributorService"
]
}
},
"/v1/products/{package.productId}/packages": {
"post": {
"operationId": "PackageService_Create",
"parameters": [
{
"in": "path",
"name": "package.productId",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "body",
"required": true,
"schema": {
"properties": {
"package": {
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
}
}
],
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/packagesv1CreateResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"tags": [
"PackageService"
]
}
},
"/v1/products/{package.productId}/packages/{package.name}": {
"post": {
"operationId": "PackageService_Update",
"parameters": [
{
"in": "path",
"name": "package.productId",
"required": true,
"type": "string"
},
{
"in": "path",
"name": "package.name",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "body",
"required": true,
"schema": {
"properties": {
"package": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
}
}
],
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/packagesv1UpdateResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"tags": [
"PackageService"
]
}
},
"/v1/products/{product.id}": {
"post": {
"operationId": "ProductService_Update",
"parameters": [
{
"in": "path",
"name": "product.id",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "body",
"required": true,
"schema": {
"properties": {
"product": {
"properties": {
"description": {
"type": "string"
},
"name": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
}
}
],
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/productsv1UpdateResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"tags": [
"ProductService"
]
}
},
"/v1/products/{productId}": { "/v1/products/{productId}": {
"delete": { "delete": {
"operationId": "ProductService_Delete", "operationId": "ProductService_Delete",
@ -311,42 +823,6 @@
"tags": [ "tags": [
"ProductService" "ProductService"
] ]
},
"post": {
"operationId": "ProductService_Update",
"parameters": [
{
"in": "path",
"name": "productId",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "body",
"required": true,
"schema": {
"type": "object"
}
}
],
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/productsv1UpdateResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"tags": [
"ProductService"
]
} }
}, },
"/v1/products/{productId}/contributors": { "/v1/products/{productId}/contributors": {
@ -377,47 +853,11 @@
"tags": [ "tags": [
"ContributorService" "ContributorService"
] ]
},
"post": {
"operationId": "ContributorService_Create",
"parameters": [
{
"in": "path",
"name": "productId",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "body",
"required": true,
"schema": {
"type": "object"
}
}
],
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/contributorsv1CreateResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"tags": [
"ContributorService"
]
} }
}, },
"/v1/products/{productId}/contributors/{contributorId}": { "/v1/products/{productId}/contributors/{contributorId}": {
"delete": { "delete": {
"operationId": "ContributorService_Delete", "operationId": "ContributorService_Revoke",
"parameters": [ "parameters": [
{ {
"in": "path", "in": "path",
@ -436,49 +876,7 @@
"200": { "200": {
"description": "A successful response.", "description": "A successful response.",
"schema": { "schema": {
"$ref": "#/definitions/contributorsv1DeleteResponse" "$ref": "#/definitions/v1RevokeResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"tags": [
"ContributorService"
]
},
"post": {
"operationId": "ContributorService_Update",
"parameters": [
{
"in": "path",
"name": "productId",
"required": true,
"type": "string"
},
{
"in": "path",
"name": "contributorId",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "body",
"required": true,
"schema": {
"type": "object"
}
}
],
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/contributorsv1UpdateResponse"
} }
}, },
"default": { "default": {
@ -521,42 +919,6 @@
"tags": [ "tags": [
"PackageService" "PackageService"
] ]
},
"post": {
"operationId": "PackageService_Create",
"parameters": [
{
"in": "path",
"name": "productId",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "body",
"required": true,
"schema": {
"type": "object"
}
}
],
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/packagesv1CreateResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"tags": [
"PackageService"
]
} }
}, },
"/v1/products/{productId}/packages/{packageName}": { "/v1/products/{productId}/packages/{packageName}": {
@ -627,48 +989,6 @@
"tags": [ "tags": [
"PackageService" "PackageService"
] ]
},
"post": {
"operationId": "PackageService_Update",
"parameters": [
{
"in": "path",
"name": "productId",
"required": true,
"type": "string"
},
{
"in": "path",
"name": "packageName",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "body",
"required": true,
"schema": {
"type": "object"
}
}
],
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/packagesv1UpdateResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"tags": [
"PackageService"
]
} }
}, },
"/v1/token": { "/v1/token": {

@ -14,17 +14,73 @@ package tokens.v1;
import "google/api/annotations.proto"; import "google/api/annotations.proto";
message AuthenticateRequest {} message AuthenticateRequest {
// grant_type = client_credentials, refresh_token, password, authorization_code, license
string grant_type = 1;
message AuthenticateResponse {} // required for a handful of workflows
// can also come from the basic auth header
string client_id = 2;
string client_secret = 3;
// grant_type=refresh_token
string refresh_token = 4;
// grant_type=password
string username = 5;
string password = 6;
// grant_type=authorization_code
string code = 7;
string redirect_uri = 8;
string code_verifier = 9;
// grant_type=license
string license = 10;
// allow for room to add additional grant_type's
string scope = 20;
}
message AuthenticateResponse {
string access_token = 1;
string token_type = 2;
int32 expires_in = 3;
string refresh_token = 4;
string scope = 5;
// error = invalid_request, invalid_client, invalid_grant, invalid_scope, unauthorized_client, unsupported_grant_type
string error = 10;
string error_description = 11;
string error_uri = 12;
}
message Token {
string id = 1;
string name = 2;
repeated string scopes = 3;
// one of
bool no_expiry = 4;
string expires_at = 5;
string expires_in = 6;
}
message ListRequest {} message ListRequest {}
message ListResponse {} message ListResponse {
repeated Token tokens = 5;
}
message CreateRequest {} message CreateRequest {
Token token = 1;
}
message CreateResponse {} message CreateResponse {
string token = 1;
}
message DeleteRequest { message DeleteRequest {
string token_id = 1; string token_id = 1;

@ -14,10 +14,15 @@ package users.v1;
import "google/api/annotations.proto"; import "google/api/annotations.proto";
message SignupRequest {} message SignupRequest {
string email = 1;
string password = 2;
}
message SignupResponse {} message SignupResponse {}
message CurrentRequest {} message CurrentRequest {}
message CurrentResponse {} message CurrentResponse {}
service UserService { service UserService {