Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2023-08-12 16:24:50 +03:00
parent 96c955b412
commit ad798713df
59 changed files with 15882 additions and 1887 deletions

277
proto/apidocs.swagger.yaml Normal file
View File

@@ -0,0 +1,277 @@
# Generated with protoc-gen-go-micro
openapi: 3.0.3
info:
title: PkgdashService API
version: 0.0.1
paths:
/v1/module:
get:
tags:
- PkgdashService
operationId: GetModule
parameters:
- name: id
in: query
schema:
type: array
items:
type: integer
format: uint64
responses:
default:
description: Default
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorRsp'
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/GetModuleRsp'
/v1/package:
post:
tags:
- PkgdashService
operationId: AddPackage
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/AddPackageReq'
required: true
responses:
default:
description: Default
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorRsp'
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/AddPackageRsp'
/v1/package/{id}:
post:
tags:
- PkgdashService
operationId: UpdateInfo
parameters:
- name: id
in: path
required: true
schema:
$ref: '#/components/schemas/UInt64Value'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/UpdatePackageReq'
required: true
responses:
default:
description: Default
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorRsp'
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/UpdatePackageRsp'
/v1/package/{pkg}/comment:
post:
tags:
- PkgdashService
operationId: AddComment
parameters:
- name: pkg
in: path
required: true
schema:
type: string
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/AddCommentReq'
required: true
responses:
default:
description: Default
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorRsp'
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/AddCommentRsp'
/v1/packages:
get:
tags:
- PkgdashService
operationId: ListPackage
responses:
default:
description: Default
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorRsp'
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/ListPackageRsp'
components:
schemas:
AddCommentReq:
type: object
properties:
idPackage:
$ref: '#/components/schemas/UInt64Value'
text:
type: string
AddCommentRsp:
type: object
properties:
id:
type: integer
format: uint64
AddPackageReq:
type: object
properties:
name:
$ref: '#/components/schemas/StringValue'
url:
$ref: '#/components/schemas/StringValue'
modules:
type: array
items:
type: integer
format: uint64
AddPackageRsp:
type: object
properties: {}
Error:
type: object
properties:
code:
type: string
title:
type: string
uuid:
type: string
details:
type: string
ErrorRsp:
type: object
properties:
error:
$ref: '#/components/schemas/Error'
GetModuleRsp:
type: object
properties:
modules:
type: array
items:
$ref: '#/components/schemas/Module'
ListPackageRsp:
type: object
properties:
packages:
type: array
items:
$ref: '#/components/schemas/Package'
Module:
type: object
properties:
id:
type: integer
format: uint64
name:
type: string
version:
type: string
package:
type: integer
format: uint64
last_version:
type: string
Package:
type: object
properties:
id:
type: integer
format: uint64
name:
type: string
url:
type: string
modules:
type: array
items:
type: integer
format: uint64
issues:
type: array
items:
type: integer
format: uint64
comments:
type: array
items:
type: integer
format: uint64
StringValue:
type: object
properties:
value:
type: string
description: The string value.
description: Wrapper message for `string`. The JSON representation for `StringValue` is JSON string.
UInt64Value:
type: object
properties:
value:
type: integer
description: The uint64 value.
format: uint64
description: Wrapper message for `uint64`. The JSON representation for `UInt64Value` is JSON string.
UpdatePackageReq:
type: object
properties:
id:
$ref: '#/components/schemas/UInt64Value'
name:
$ref: '#/components/schemas/StringValue'
url:
$ref: '#/components/schemas/StringValue'
modules:
type: array
items:
type: integer
format: uint64
issues:
type: array
items:
type: integer
format: uint64
UpdatePackageRsp:
type: object
properties:
id:
type: integer
format: uint64
tags:
- name: PkgdashService

View File

@@ -1,43 +0,0 @@
FROM golang:1.19-bullseye
RUN mkdir /build
WORKDIR /build
RUN apt-get update && apt-get -y install --no-install-recommends protobuf-compiler libprotobuf-dev
ENV PATH=${PATH}:${GOBIN}
ENV GEN_VALIDATE=github.com/envoyproxy/protoc-gen-validate@v1.0.2
ENV GOOGLEAPIS=github.com/google/googleapis@v0.0.0-20200324113624-36c0febd0fa7
ENV GRPC_GATEWAY=github.com/grpc-ecosystem/grpc-gateway@v1.16.0
RUN go install ${GEN_VALIDATE}
RUN go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v1.16.0 && \
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v1.16.0 && \
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
RUN go install go.unistack.org/protoc-gen-go-micro/v3@latest
RUN go mod init proto
RUN go get ${GOOGLEAPIS} && \
go get ${GRPC_GATEWAY} && \
go get google.golang.org/grpc@v1.57.0 && \
go get -u github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway && \
go get -u github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 && \
go get google.golang.org/protobuf/cmd/protoc-gen-go && \
go get go.unistack.org/micro-proto/v3@v3.3.1
CMD rm -rf go_generate && \
protoc \
--validate_out=lang=go:. \
--go-micro_out=debug=true,components="micro|http":. \
--go_out=. \
--grpc-gateway_out=. \
--proto_path=/go/pkg/mod/go.unistack.org/micro-proto/v3@v3.3.1 \
-I=./ \
-I=/usr/include \
-I=/go/pkg/mod/${GEN_VALIDATE} \
-I=/go/pkg/mod/${GOOGLEAPIS} \
-I=/go/pkg/mod/${GRPC_GATEWAY} \
./*.proto

View File

@@ -1,7 +0,0 @@
#New version of proto Makefile and Dockerfile can be found
#at https://qcm-git.mbrd.ru/service-platform/examples/makefile
.PHONY: proto
proto:
docker build -t proto:latest .
docker run --rm --name=proto -v `pwd`:/build proto:latest

View File

@@ -1,71 +0,0 @@
syntax = "proto3";
package proto;
option go_package = "./go_generate;go_generate";
import "validate/validate.proto";
message ErrorRsp {
Error error = 1 [json_name = "error"];
}
message Error {
string code = 1 [json_name = "code"];
string title = 2 [json_name = "title"];
string uuid = 3 [json_name = "uuid"];
string details = 4 [json_name = "details"];
}
message Package {
uint64 id = 1 [(validate.rules).uint64.gt = 0];
string name = 2 [(validate.rules).string.min_len = 1];
string url = 3 [(validate.rules).string.min_len = 1];
repeated Module modules = 4;
repeated Issue issues = 5;
};
message Module {
uint64 id = 1 [(validate.rules).uint64.gt = 0];
string name = 2 [(validate.rules).string.min_len = 1];
string version = 3 [(validate.rules).string.min_len = 1];
uint64 package = 4 [(validate.rules).uint64.gt = 0];
}
message Issue {
uint64 id = 1 [(validate.rules).uint64.gt = 0];
uint64 status = 2 [(validate.rules).uint64.gt = 0];
string desc = 3 [(validate.rules).string.min_len = 1];
uint64 package = 4 [(validate.rules).uint64.gt = 0];
repeated uint64 modules = 5;
}
message Comment {
uint64 id = 1 [(validate.rules).uint64.gt = 0];
uint64 package = 2 [(validate.rules).uint64.gt = 0];
string text = 3;
uint64 created = 4 [(validate.rules).uint64.gt = 0];
uint64 updated = 5 [(validate.rules).uint64.gt = 0];
}
message ListPackageReq {}
message ListPackageRsp{
repeated Package packages = 1;
}
message UpdateInfoPackageRsp {
uint64 id = 1 [(validate.rules).uint64.gt = 0];
}
message UpdateInfoPackageReq {
uint64 id = 1 [(validate.rules).uint64.gt = 0];
}
message CommentRsp {
uint64 idPackage = 1 [(validate.rules).uint64.gt = 0];
string text = 2;
}
message CommentReq {
uint64 id = 1 [(validate.rules).uint64.gt = 0];
}

View File

@@ -1,42 +0,0 @@
syntax = "proto3";
package proto;
option go_package = "./go_generate;go_generate";
import "dashboard.proto";
import "google/api/annotations.proto";
import "protoc-gen-swagger/options/annotations.proto";
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = {
info: {
title: "service-platform/product-services/mts-money/gateway-proto",
version: "0";
};
consumes: "application/json";
produces: "application/json";
};
service DashboardService {
rpc ListPackage(ListPackageReq) returns (ListPackageRsp) {
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
operation_id: "ListPackage";
responses: {
key: "default";
value: {
description: "Error response";
schema: {
json_schema: {
ref: ".go_generate.ErrorRsp";
}
}
}
}
};
option (google.api.http) = {
get: "/listPackage";
};
};
rpc UpdateInfo(UpdateInfoPackageRsp) returns (UpdateInfoPackageReq) {};
rpc AddComment(CommentRsp) returns (CommentReq) {};
};

View File

@@ -1,14 +0,0 @@
#!/bin/sh -ex
PROTO_ARGS=" \
--proto_path=$(go list -f '{{ .Dir }}' -m github.com/envoyproxy/protoc-gen-validate) \
--proto_path=$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) \
--go_out=paths=source_relative:go_generate \
--go-micro_out=module=go.unistack.org/unistack-org/pkgdash/proto/go_generate,components=micro|http,standalone=true:./micro \
--validate_out=paths=source_relative,lang=go:go_generate
"
find . -not \( -name "*.sh" -or -name "*.proto" -or -name "generate.go" -or -name "Dockerfile" -or -name "Makefile" \) -delete
mkdir -p micro go_generate && \
protoc -I. $PROTO_ARGS ./*.proto || \
find . -not \( -name "*.sh" -or -name "*.proto" -or -name "generate.go" -or -name "Dockerfile" -or -name "Makefile" \) -delete

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -2,12 +2,12 @@ syntax = "proto3";
package pkgdash;
option go_package = "go.unistack.org/unistack-org/pkgdash/proto;pkgdashpb";
import "api/annotations.proto";
import "google/protobuf/wrappers.proto";
import "openapiv3/annotations.proto";
import "validate/validate.proto";
import "google/protobuf/wrappers.proto";
option go_package = "go.unistack.org/unistack-org/pkgdash/proto;pkgdashpb";
service PkgdashService {
rpc ListPackage(ListPackageReq) returns (ListPackageRsp) {
@@ -19,10 +19,8 @@ service PkgdashService {
};
};
};
option (micro.api.http) = {
get: "/v1/packages";
};
};
option (micro.api.http) = {get: "/v1/packages"};
}
rpc UpdatePackage(UpdatePackageReq) returns (UpdatePackageRsp) {
option (micro.openapiv3.openapiv3_operation) = {
operation_id: "UpdateInfo";
@@ -36,7 +34,7 @@ service PkgdashService {
post: "/v1/package/{id}";
body: "*";
};
};
}
rpc AddComment(AddCommentReq) returns (AddCommentRsp) {
option (micro.openapiv3.openapiv3_operation) = {
operation_id: "AddComment";
@@ -50,7 +48,7 @@ service PkgdashService {
post: "/v1/package/{pkg}/comment";
body: "*";
};
};
}
rpc AddPackage(AddPackageReq) returns (AddPackageRsp) {
option (micro.openapiv3.openapiv3_operation) = {
operation_id: "AddPackage";
@@ -64,7 +62,7 @@ service PkgdashService {
post: "/v1/package";
body: "*";
};
};
}
rpc GetModule(GetModuleReq) returns (GetModuleRsp) {
option (micro.openapiv3.openapiv3_operation) = {
operation_id: "GetModule";
@@ -74,11 +72,65 @@ service PkgdashService {
};
};
};
option (micro.api.http) = {
get: "/v1/module";
};
};
};
option (micro.api.http) = {get: "/v1/module"};
}
}
message ListPackageReq {}
message ListPackageRsp {
repeated Package packages = 1;
}
message UpdatePackageReq {
google.protobuf.UInt64Value id = 1 [(validate.rules).message.required = true];
google.protobuf.StringValue name = 2 [(validate.rules).message.required = true];
google.protobuf.StringValue url = 3 [(validate.rules).message.required = true];
repeated uint64 modules = 4;
repeated uint64 issues = 5;
}
message UpdatePackageRsp {
uint64 id = 1 [(validate.rules).uint64.gt = 0];
}
message CommentReq {
uint64 pkg = 1 [(validate.rules).uint64.gt = 0];
string text = 2;
}
message AddCommentReq {
google.protobuf.UInt64Value idPackage = 1 [(validate.rules).message.required = true];
string text = 2;
}
message AddCommentRsp {
uint64 id = 1 [(validate.rules).uint64.gt = 0];
}
message AddPackageReq {
google.protobuf.StringValue name = 1 [(validate.rules).message.required = true];
google.protobuf.StringValue url = 2 [(validate.rules).message.required = true];
repeated uint64 modules = 3;
}
message AddPackageRsp {}
message GetModuleReq {
repeated uint64 id = 1;
}
message GetModuleRsp {
repeated Module modules = 1;
}
message Package {
uint64 id = 1 [(validate.rules).uint64.gt = 0];
string name = 2 [(validate.rules).string.min_len = 1];
string url = 3 [(validate.rules).string.min_len = 1];
repeated uint64 modules = 4;
repeated uint64 issues = 5;
repeated uint64 comments = 6;
}
message ErrorRsp {
Error error = 1 [json_name = "error"];
@@ -91,15 +143,6 @@ message Error {
string details = 4 [json_name = "details"];
}
message Package {
uint64 id = 1 [(validate.rules).uint64.gt = 0];
string name = 2 [(validate.rules).string.min_len = 1];
string url = 3 [(validate.rules).string.min_len = 1];
repeated uint64 modules = 4;
repeated uint64 issues = 5;
repeated uint64 comments = 6;
};
message Module {
uint64 id = 1 [(validate.rules).uint64.gt = 0];
string name = 2 [(validate.rules).string.min_len = 1];
@@ -123,48 +166,3 @@ message Comment {
uint64 created = 4 [(validate.rules).uint64.gt = 0];
uint64 updated = 5 [(validate.rules).uint64.gt = 0];
}
message ListPackageReq {}
message ListPackageRsp{
repeated Package packages = 1;
}
message UpdatePackageReq {
google.protobuf.UInt64Value id = 1 [(validate.rules).message.required = true];
google.protobuf.StringValue name = 2 [(validate.rules).message.required = true];
google.protobuf.StringValue url = 3 [(validate.rules).message.required = true];
repeated uint64 modules = 4 ;
repeated uint64 issues = 5 ;
}
message UpdatePackageRsp {
uint64 id = 1 [(validate.rules).uint64.gt = 0];
}
message CommentReq {
uint64 pkg = 1 [(validate.rules).uint64.gt = 0];
string text = 2;
}
message AddCommentReq {
google.protobuf.UInt64Value idPackage = 1 [(validate.rules).message.required = true];
string text = 2;
}
message AddCommentRsp {
uint64 id = 1 [(validate.rules).uint64.gt = 0];
}
message AddPackageReq {
google.protobuf.StringValue name = 1 [(validate.rules).message.required = true];
google.protobuf.StringValue url = 2 [(validate.rules).message.required = true];
repeated uint64 modules = 3;
}
message AddPackageRsp{}
message GetModuleReq {
repeated uint64 id = 1 ;
}
message GetModuleRsp {
repeated Module modules = 1 ;
}