Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2023-09-23 21:16:26 +03:00
parent eb4daf33f1
commit cfb7cb0f26
61 changed files with 130034 additions and 1053 deletions

View File

@@ -5,7 +5,7 @@ info:
title: Pkgdash API
version: 0.0.1
paths:
/v1/comments/{id}/comments:
/v1/comments/{id}:
get:
tags:
- Pkgdash
@@ -17,7 +17,7 @@ paths:
schema:
type: integer
format: uint64
- name: package_id
- name: package
in: query
schema:
type: integer
@@ -40,6 +40,12 @@ paths:
tags:
- Pkgdash
operationId: ModuleList
parameters:
- name: package
in: query
schema:
type: integer
format: uint64
responses:
default:
description: Default
@@ -213,10 +219,6 @@ paths:
- name: package
in: path
required: true
schema:
type: string
- name: package_id
in: query
schema:
type: integer
format: uint64
@@ -262,6 +264,31 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/CommentCreateRsp'
/v1/packages/{package}/handlers:
get:
tags:
- Pkgdash
operationId: HandlerList
parameters:
- name: package
in: path
required: true
schema:
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/HandlerListRsp'
/v1/packages/{package}/modules:
get:
tags:
@@ -345,6 +372,27 @@ components:
type: string
details:
type: string
Handler:
type: object
properties:
id:
type: integer
format: uint64
package:
type: integer
format: uint64
name:
type: string
coverage:
type: number
format: double
HandlerListRsp:
type: object
properties:
handlers:
type: array
items:
$ref: '#/components/schemas/Handler'
Module:
type: object
properties:
@@ -386,6 +434,9 @@ components:
comments:
type: integer
format: uint64
handlers:
type: integer
format: uint64
created:
type: string
format: RFC3339
@@ -395,6 +446,11 @@ components:
last_check:
type: string
format: RFC3339
type:
type: string
coverage:
type: number
format: double
PackageCreateReq:
type: object
properties:
@@ -402,11 +458,8 @@ components:
type: string
url:
type: string
modules:
type: array
items:
type: integer
format: uint64
description:
type: string
PackageCreateRsp:
type: object
properties:
@@ -454,6 +507,9 @@ components:
items:
type: integer
format: uint64
coverprofile:
type: string
format: bytes
PackageUpdateRsp:
type: object
properties:

File diff suppressed because it is too large Load Diff

View File

@@ -35,6 +35,240 @@ var (
_ = sort.Sort
)
// Validate checks the field values on HandlerListReq with the rules defined in
// the proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *HandlerListReq) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on HandlerListReq with the rules defined
// in the proto definition for this message. If any rules are violated, the
// result is a list of violation errors wrapped in HandlerListReqMultiError,
// or nil if none found.
func (m *HandlerListReq) ValidateAll() error {
return m.validate(true)
}
func (m *HandlerListReq) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for Package
if len(errors) > 0 {
return HandlerListReqMultiError(errors)
}
return nil
}
// HandlerListReqMultiError is an error wrapping multiple validation errors
// returned by HandlerListReq.ValidateAll() if the designated constraints
// aren't met.
type HandlerListReqMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m HandlerListReqMultiError) Error() string {
var msgs []string
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m HandlerListReqMultiError) AllErrors() []error { return m }
// HandlerListReqValidationError is the validation error returned by
// HandlerListReq.Validate if the designated constraints aren't met.
type HandlerListReqValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e HandlerListReqValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e HandlerListReqValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e HandlerListReqValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e HandlerListReqValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e HandlerListReqValidationError) ErrorName() string { return "HandlerListReqValidationError" }
// Error satisfies the builtin error interface
func (e HandlerListReqValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sHandlerListReq.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = HandlerListReqValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = HandlerListReqValidationError{}
// Validate checks the field values on HandlerListRsp with the rules defined in
// the proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *HandlerListRsp) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on HandlerListRsp with the rules defined
// in the proto definition for this message. If any rules are violated, the
// result is a list of violation errors wrapped in HandlerListRspMultiError,
// or nil if none found.
func (m *HandlerListRsp) ValidateAll() error {
return m.validate(true)
}
func (m *HandlerListRsp) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
for idx, item := range m.GetHandlers() {
_, _ = idx, item
if all {
switch v := interface{}(item).(type) {
case interface{ ValidateAll() error }:
if err := v.ValidateAll(); err != nil {
errors = append(errors, HandlerListRspValidationError{
field: fmt.Sprintf("Handlers[%v]", idx),
reason: "embedded message failed validation",
cause: err,
})
}
case interface{ Validate() error }:
if err := v.Validate(); err != nil {
errors = append(errors, HandlerListRspValidationError{
field: fmt.Sprintf("Handlers[%v]", idx),
reason: "embedded message failed validation",
cause: err,
})
}
}
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return HandlerListRspValidationError{
field: fmt.Sprintf("Handlers[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
if len(errors) > 0 {
return HandlerListRspMultiError(errors)
}
return nil
}
// HandlerListRspMultiError is an error wrapping multiple validation errors
// returned by HandlerListRsp.ValidateAll() if the designated constraints
// aren't met.
type HandlerListRspMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m HandlerListRspMultiError) Error() string {
var msgs []string
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m HandlerListRspMultiError) AllErrors() []error { return m }
// HandlerListRspValidationError is the validation error returned by
// HandlerListRsp.Validate if the designated constraints aren't met.
type HandlerListRspValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e HandlerListRspValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e HandlerListRspValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e HandlerListRspValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e HandlerListRspValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e HandlerListRspValidationError) ErrorName() string { return "HandlerListRspValidationError" }
// Error satisfies the builtin error interface
func (e HandlerListRspValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sHandlerListRsp.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = HandlerListRspValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = HandlerListRspValidationError{}
// Validate checks the field values on PackageModulesReq with the rules defined
// in the proto definition for this message. If any rules are violated, the
// first error encountered is returned, or nil if there are no violations.
@@ -679,6 +913,8 @@ func (m *Package) validate(all bool) error {
// no validation rules for Comments
// no validation rules for Handlers
if all {
switch v := interface{}(m.GetCreated()).(type) {
case interface{ ValidateAll() error }:
@@ -766,6 +1002,10 @@ func (m *Package) validate(all bool) error {
}
}
// no validation rules for Type
// no validation rules for Coverage
if len(errors) > 0 {
return PackageMultiError(errors)
}
@@ -842,6 +1082,138 @@ var _ interface {
ErrorName() string
} = PackageValidationError{}
// Validate checks the field values on Handler with the rules defined in the
// proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *Handler) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on Handler with the rules defined in the
// proto definition for this message. If any rules are violated, the result is
// a list of violation errors wrapped in HandlerMultiError, or nil if none found.
func (m *Handler) ValidateAll() error {
return m.validate(true)
}
func (m *Handler) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
if m.GetId() <= 0 {
err := HandlerValidationError{
field: "Id",
reason: "value must be greater than 0",
}
if !all {
return err
}
errors = append(errors, err)
}
if m.GetPackage() <= 0 {
err := HandlerValidationError{
field: "Package",
reason: "value must be greater than 0",
}
if !all {
return err
}
errors = append(errors, err)
}
if utf8.RuneCountInString(m.GetName()) < 1 {
err := HandlerValidationError{
field: "Name",
reason: "value length must be at least 1 runes",
}
if !all {
return err
}
errors = append(errors, err)
}
// no validation rules for Coverage
if len(errors) > 0 {
return HandlerMultiError(errors)
}
return nil
}
// HandlerMultiError is an error wrapping multiple validation errors returned
// by Handler.ValidateAll() if the designated constraints aren't met.
type HandlerMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m HandlerMultiError) Error() string {
var msgs []string
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m HandlerMultiError) AllErrors() []error { return m }
// HandlerValidationError is the validation error returned by Handler.Validate
// if the designated constraints aren't met.
type HandlerValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e HandlerValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e HandlerValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e HandlerValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e HandlerValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e HandlerValidationError) ErrorName() string { return "HandlerValidationError" }
// Error satisfies the builtin error interface
func (e HandlerValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sHandler.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = HandlerValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = HandlerValidationError{}
// Validate checks the field values on Module with the rules defined in the
// proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
@@ -2068,6 +2440,8 @@ func (m *PackageUpdateReq) validate(all bool) error {
errors = append(errors, err)
}
// no validation rules for Coverprofile
if len(errors) > 0 {
return PackageUpdateReqMultiError(errors)
}
@@ -2557,6 +2931,8 @@ func (m *PackageCreateReq) validate(all bool) error {
errors = append(errors, err)
}
// no validation rules for Description
if len(errors) > 0 {
return PackageCreateReqMultiError(errors)
}
@@ -2784,6 +3160,8 @@ func (m *ModuleListReq) validate(all bool) error {
var errors []error
// no validation rules for Package
if len(errors) > 0 {
return ModuleListReqMultiError(errors)
}
@@ -3016,7 +3394,7 @@ func (m *CommentListReq) validate(all bool) error {
var errors []error
// no validation rules for PackageId
// no validation rules for Package
if len(errors) > 0 {
return CommentListReqMultiError(errors)
@@ -3252,7 +3630,7 @@ func (m *CommentLookupReq) validate(all bool) error {
// no validation rules for Id
// no validation rules for PackageId
// no validation rules for Package
if len(errors) > 0 {
return CommentLookupReqMultiError(errors)

View File

@@ -19,9 +19,7 @@ service Pkgdash {
};
};
};
option (micro.api.http) = {
get: "/v1/packages/{id}";
};
option (micro.api.http) = {get: "/v1/packages/{id}"};
}
rpc PackageCreate(PackageCreateReq) returns (PackageCreateRsp) {
option (micro.openapiv3.openapiv3_operation) = {
@@ -59,6 +57,17 @@ service Pkgdash {
};
option (micro.api.http) = {get: "/v1/packages"};
}
rpc HandlerList(HandlerListReq) returns (HandlerListRsp) {
option (micro.openapiv3.openapiv3_operation) = {
operation_id: "HandlerList";
responses: {
default: {
reference: {_ref: ".pkgdash.ErrorRsp"};
};
};
};
option (micro.api.http) = {get: "/v1/packages/{package}/handlers"};
}
rpc PackageModules(PackageModulesReq) returns (PackageModulesRsp) {
option (micro.openapiv3.openapiv3_operation) = {
operation_id: "PackageModules";
@@ -108,7 +117,7 @@ service Pkgdash {
};
};
option (micro.api.http) = {
get: "/v1/comments/{id}/comments";
get: "/v1/comments/{id}";
additional_bindings {get: "/v1/comments/{package}/comments/{id}"};
};
}
@@ -150,6 +159,14 @@ service Pkgdash {
}
}
message HandlerListReq {
uint64 package = 1;
}
message HandlerListRsp {
repeated Handler handlers = 1;
}
message PackageModulesReq {
uint64 package = 1 [json_name = "package"];
}
@@ -181,9 +198,19 @@ message Package {
uint64 modules = 5;
uint64 issues = 6;
uint64 comments = 7;
google.protobuf.Timestamp created = 8;
google.protobuf.Timestamp updated = 9;
google.protobuf.Timestamp last_check = 10;
uint64 handlers = 8;
google.protobuf.Timestamp created = 9;
google.protobuf.Timestamp updated = 10;
google.protobuf.Timestamp last_check = 11;
string type = 12;
double coverage = 13;
}
message Handler {
uint64 id = 1 [(validate.rules).uint64.gt = 0];
uint64 package = 2 [(validate.rules).uint64.gt = 0];
string name = 3 [(validate.rules).string.min_len = 1];
double coverage = 4;
}
message Module {
@@ -236,6 +263,7 @@ message PackageUpdateReq {
string url = 3 [(validate.rules).string.min_len = 1];
repeated uint64 modules = 4;
repeated uint64 issues = 5;
bytes coverprofile = 6;
}
message PackageUpdateRsp {
@@ -257,21 +285,23 @@ message CommentCreateRsp {
message PackageCreateReq {
string name = 1 [(validate.rules).string.min_len = 1];
string url = 2 [(validate.rules).string.min_len = 1];
repeated uint64 modules = 3;
string description = 3;
}
message PackageCreateRsp {
Package package = 1 [json_name="package"];
Package package = 1 [json_name = "package"];
}
message ModuleListReq {}
message ModuleListReq {
uint64 package = 1 [json_name = "package"];
}
message ModuleListRsp {
repeated Module modules = 1 [json_name="modules"];
repeated Module modules = 1 [json_name = "modules"];
}
message CommentListReq {
uint64 package_id = 1 [json_name = "package_id"];
uint64 package = 1 [json_name = "package"];
}
message CommentListRsp {
@@ -280,7 +310,7 @@ message CommentListRsp {
message CommentLookupReq {
uint64 id = 1 [json_name = "id"];
uint64 package_id = 2 [json_name = "package_id"];
uint64 package = 2 [json_name = "package"];
}
message CommentLookupRsp {

View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
// versions:
// - protoc-gen-go-micro v4.0.2
// - protoc v4.23.4
// - protoc v4.24.3
// source: pkgdash.proto
package pkgdashpb
@@ -21,6 +21,7 @@ type PkgdashServiceClient interface {
PackageCreate(ctx context.Context, req *PackageCreateReq, opts ...options.Option) (*PackageCreateRsp, error)
PackageDelete(ctx context.Context, req *PackageDeleteReq, opts ...options.Option) (*PackageDeleteRsp, error)
PackageList(ctx context.Context, req *PackageListReq, opts ...options.Option) (*PackageListRsp, error)
HandlerList(ctx context.Context, req *HandlerListReq, opts ...options.Option) (*HandlerListRsp, error)
PackageModules(ctx context.Context, req *PackageModulesReq, opts ...options.Option) (*PackageModulesRsp, error)
PackageUpdate(ctx context.Context, req *PackageUpdateReq, opts ...options.Option) (*PackageUpdateRsp, error)
CommentCreate(ctx context.Context, req *CommentCreateReq, opts ...options.Option) (*CommentCreateRsp, error)
@@ -35,6 +36,7 @@ type PkgdashServiceServer interface {
PackageCreate(ctx context.Context, req *PackageCreateReq, rsp *PackageCreateRsp) error
PackageDelete(ctx context.Context, req *PackageDeleteReq, rsp *PackageDeleteRsp) error
PackageList(ctx context.Context, req *PackageListReq, rsp *PackageListRsp) error
HandlerList(ctx context.Context, req *HandlerListReq, rsp *HandlerListRsp) error
PackageModules(ctx context.Context, req *PackageModulesReq, rsp *PackageModulesRsp) error
PackageUpdate(ctx context.Context, req *PackageUpdateReq, rsp *PackageUpdateRsp) error
CommentCreate(ctx context.Context, req *CommentCreateReq, rsp *CommentCreateRsp) error

View File

@@ -44,6 +44,13 @@ var (
Body: "",
Stream: false,
},
{
Name: "PkgdashService.HandlerList",
Path: "/v1/packages/{package}/handlers",
Method: "GET",
Body: "",
Stream: false,
},
{
Name: "PkgdashService.PackageModules",
Path: "/v1/packages/{package}/modules",
@@ -67,7 +74,7 @@ var (
},
{
Name: "PkgdashService.CommentLookup",
Path: "/v1/comments/{id}/comments",
Path: "/v1/comments/{id}",
Method: "GET",
Body: "",
Stream: false,
@@ -192,6 +199,24 @@ func (c *pkgdashServiceClient) PackageList(ctx context.Context, req *PackageList
return rsp, nil
}
func (c *pkgdashServiceClient) HandlerList(ctx context.Context, req *HandlerListReq, opts ...options.Option) (*HandlerListRsp, error) {
errmap := make(map[string]interface{}, 1)
errmap["default"] = &ErrorRsp{}
opts = append(opts,
v41.ErrorMap(errmap),
)
opts = append(opts,
v41.Method(http.MethodGet),
v41.Path("/v1/packages/{package}/handlers"),
)
rsp := &HandlerListRsp{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.HandlerList", req), rsp, opts...)
if err != nil {
return nil, err
}
return rsp, nil
}
func (c *pkgdashServiceClient) PackageModules(ctx context.Context, req *PackageModulesReq, opts ...options.Option) (*PackageModulesRsp, error) {
errmap := make(map[string]interface{}, 1)
errmap["default"] = &ErrorRsp{}
@@ -256,7 +281,7 @@ func (c *pkgdashServiceClient) CommentLookup(ctx context.Context, req *CommentLo
)
opts = append(opts,
v41.Method(http.MethodGet),
v41.Path("/v1/comments/{id}/comments"),
v41.Path("/v1/comments/{id}"),
)
rsp := &CommentLookupRsp{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.CommentLookup", req), rsp, opts...)
@@ -340,6 +365,10 @@ func (h *pkgdashServiceServer) PackageList(ctx context.Context, req *PackageList
return h.PkgdashServiceServer.PackageList(ctx, req, rsp)
}
func (h *pkgdashServiceServer) HandlerList(ctx context.Context, req *HandlerListReq, rsp *HandlerListRsp) error {
return h.PkgdashServiceServer.HandlerList(ctx, req, rsp)
}
func (h *pkgdashServiceServer) PackageModules(ctx context.Context, req *PackageModulesReq, rsp *PackageModulesRsp) error {
return h.PkgdashServiceServer.PackageModules(ctx, req, rsp)
}
@@ -374,6 +403,7 @@ func RegisterPkgdashServiceServer(s server.Server, sh PkgdashServiceServer, opts
PackageCreate(ctx context.Context, req *PackageCreateReq, rsp *PackageCreateRsp) error
PackageDelete(ctx context.Context, req *PackageDeleteReq, rsp *PackageDeleteRsp) error
PackageList(ctx context.Context, req *PackageListReq, rsp *PackageListRsp) error
HandlerList(ctx context.Context, req *HandlerListReq, rsp *HandlerListRsp) error
PackageModules(ctx context.Context, req *PackageModulesReq, rsp *PackageModulesRsp) error
PackageUpdate(ctx context.Context, req *PackageUpdateReq, rsp *PackageUpdateRsp) error
CommentCreate(ctx context.Context, req *CommentCreateReq, rsp *CommentCreateRsp) error