refactor: use new protoc plugin for api v2 (#5798)

* refactor: use new protoc plugin for api v2

* simplify code
This commit is contained in:
Livio Spring
2023-05-04 10:50:19 +02:00
committed by GitHub
parent e772ae55ab
commit f1534c0c4c
9 changed files with 252 additions and 17 deletions

View File

@@ -0,0 +1,29 @@
// Code generated by protoc-gen-zitadel. DO NOT EDIT.
package {{.GoPackageName}}
import (
"github.com/zitadel/zitadel/internal/api/authz"
{{if .AuthContext}}"github.com/zitadel/zitadel/pkg/grpc/object/v2alpha"{{end}}
)
var {{.ServiceName}}_AuthMethods = authz.MethodMapping {
{{ range $m := .AuthOptions}}
{{$.ServiceName}}_{{$m.Name}}_FullMethodName: authz.Option{
Permission: "{{$m.Permission}}",
CheckParam: "{{$m.CheckFieldName}}",
},
{{ end}}
}
{{ range $m := .AuthContext}}
func (r *{{ $m.Name }}) OrganisationFromRequest() *object.Organisation {
return r{{$m.OrgMethod}}
}
{{ end }}
{{ range $resp := .CustomHTTPResponses}}
func (r *{{ $resp.Name }}) CustomHTTPCode() int {
return {{$resp.Code}}
}
{{ end }}