Files
ca/privpb/allocator.pb.go
2026-10-31 05:36:03 -05:00

179 lines
4.6 KiB
Go

// Code generated by protoc-gen-go-mock. DO NOT EDIT.
package privpb
import (
context "context"
"net/http"
"github.com/effective-security/porto/xhttp/httperror"
"github.com/effective-security/porto/xhttp/marshal"
pb "github.com/effective-security/trustyca/api/pb"
)
// RequestAllocator defines constructor to allocate Protobuf request
type RequestAllocator func() any
// CheckAccessFunc defines function to check access rights for the HTTP request
type CheckAccessFunc func(ctx context.Context, req any, action string) error
// MethodInfo provides info about RPC method
type MethodInfo struct {
Allocator RequestAllocator
AllowedRoles []string
Scopes []string
CliCmd string
RefreshInterval uint32
}
// UnmarshalRequest unmarshals JSON body of HTTP request to protobuf request
func UnmarshalRequest(w http.ResponseWriter, r *http.Request) (any, *MethodInfo, error) {
info := methods[r.URL.Path]
if info == nil {
err := httperror.NotFound("path not found: %s", r.URL.Path)
marshal.WriteJSON(w, r, err)
return nil, nil, err
}
req := info.Allocator()
err := marshal.DecodeBody(w, r, req)
if err != nil {
// DecodeBody writes error response and logs, if invalid request
return nil, nil, err
}
return req, info, nil
}
// GetMethodInfo returns MethodInfo
func GetMethodInfo(method string) *MethodInfo {
return methods[method]
}
// GetMethodsInfo returns map of methods
func GetMethodsInfo() map[string]*MethodInfo {
return methods
}
// GetMethodAliases returns map of method CLI commands to method names
func GetMethodAliases() map[string]string {
res := make(map[string]string, len(methods))
for fn, method := range methods {
if method.CliCmd != "" {
res[method.CliCmd] = fn
}
}
return res
}
// methods defines map for routes
var methods = map[string]*MethodInfo{
Admin_ListOrgs_FullMethodName: {
Allocator: func() any { return new(ListOrgsRequest) },
CliCmd: "org list",
},
Admin_ListProjects_FullMethodName: {
Allocator: func() any { return new(ListProjectsRequest) },
CliCmd: "project list",
},
Admin_ListIssuers_FullMethodName: {
Allocator: func() any { return new(ListAllIssuersRequest) },
CliCmd: "ca issuer list",
},
Admin_ListCertificates_FullMethodName: {
Allocator: func() any { return new(ListAllCertificatesRequest) },
CliCmd: "ca cert list",
},
Backend_RegisterIssuer_FullMethodName: {
Allocator: func() any { return new(RegisterIssuerRequest) },
},
Backend_ImportIssuer_FullMethodName: {
Allocator: func() any { return new(ImportIssuerRequest) },
},
Backend_ActivateIssuer_FullMethodName: {
Allocator: func() any { return new(ActivateIssuerRequest) },
},
Backend_UpdateIssuer_FullMethodName: {
Allocator: func() any { return new(UpdateIssuerRequest) },
},
Backend_GetIssuer_FullMethodName: {
Allocator: func() any { return new(GetIssuerRequest) },
},
Backend_ListIssuers_FullMethodName: {
Allocator: func() any { return new(ListIssuersRequest) },
},
Backend_RegisterRoot_FullMethodName: {
Allocator: func() any { return new(RegisterRootRequest) },
},
Backend_ListRoots_FullMethodName: {
Allocator: func() any { return new(ListRootsRequest) },
},
Backend_RegisterProfile_FullMethodName: {
Allocator: func() any { return new(RegisterProfileRequest) },
},
Backend_GetProfile_FullMethodName: {
Allocator: func() any { return new(GetProfileRequest) },
},
Backend_ListProfiles_FullMethodName: {
Allocator: func() any { return new(ListProfilesRequest) },
},
Backend_DeleteProfile_FullMethodName: {
Allocator: func() any { return new(DeleteProfileRequest) },
},
Backend_SignCertificate_FullMethodName: {
Allocator: func() any { return new(SignCertificateRequest) },
},
Backend_GetCertificate_FullMethodName: {
Allocator: func() any { return new(GetCertificateRequest) },
},
Backend_ListCertificates_FullMethodName: {
Allocator: func() any { return new(ListCertificatesRequest) },
},
Backend_UpdateCertificateLabel_FullMethodName: {
Allocator: func() any { return new(UpdateCertificateLabelRequest) },
},
Backend_RevokeCertificate_FullMethodName: {
Allocator: func() any { return new(RevokeCertificateRequest) },
},
Backend_ListRevokedCertificates_FullMethodName: {
Allocator: func() any { return new(ListRevokedCertificatesRequest) },
},
Backend_GetCRL_FullMethodName: {
Allocator: func() any { return new(GetCrlRequest) },
},
Backend_PublishCrls_FullMethodName: {
Allocator: func() any { return new(PublishCrlsRequest) },
},
Backend_SignOCSP_FullMethodName: {
Allocator: func() any { return new(pb.OCSPRequest) },
},
Backend_GetSummary_FullMethodName: {
Allocator: func() any { return new(GetSummaryRequest) },
},
}