mirror of
https://github.com/absmach/magistrala.git
synced 2026-06-23 04:10:28 +00:00
NOISSUE - Replace interface{} with any (#3079)
Signed-off-by: dusan <borovcanindusan1@gmail.com>
This commit is contained in:
+1
-1
@@ -150,7 +150,7 @@ func ValidateUserName(name string) error {
|
||||
}
|
||||
|
||||
// EncodeResponse encodes successful response.
|
||||
func EncodeResponse(_ context.Context, w http.ResponseWriter, response interface{}) error {
|
||||
func EncodeResponse(_ context.Context, w http.ResponseWriter, response any) error {
|
||||
if ar, ok := response.(supermq.Response); ok {
|
||||
for k, v := range ar.Headers() {
|
||||
w.Header().Set(k, v)
|
||||
|
||||
@@ -115,7 +115,7 @@ func TestEncodeResponse(t *testing.T) {
|
||||
|
||||
cases := []struct {
|
||||
desc string
|
||||
resp interface{}
|
||||
resp any
|
||||
header http.Header
|
||||
code int
|
||||
body []byte
|
||||
|
||||
@@ -39,7 +39,7 @@ func ReadStringQuery(r *http.Request, key, def string) (string, error) {
|
||||
}
|
||||
|
||||
// ReadMetadataQuery reads the value of json http query parameters for a given key.
|
||||
func ReadMetadataQuery(r *http.Request, key string, def map[string]interface{}) (map[string]interface{}, error) {
|
||||
func ReadMetadataQuery(r *http.Request, key string, def map[string]any) (map[string]any, error) {
|
||||
vals := r.URL.Query()[key]
|
||||
if len(vals) > 1 {
|
||||
return nil, ErrInvalidQueryParams
|
||||
@@ -49,7 +49,7 @@ func ReadMetadataQuery(r *http.Request, key string, def map[string]interface{})
|
||||
return def, nil
|
||||
}
|
||||
|
||||
m := make(map[string]interface{})
|
||||
m := make(map[string]any)
|
||||
err := json.Unmarshal([]byte(vals[0]), &m)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ErrInvalidQueryParams, err)
|
||||
|
||||
@@ -67,14 +67,14 @@ func TestReadMetadataQuery(t *testing.T) {
|
||||
desc string
|
||||
url string
|
||||
key string
|
||||
ret map[string]interface{}
|
||||
ret map[string]any
|
||||
err error
|
||||
}{
|
||||
{
|
||||
desc: "valid metadata query",
|
||||
url: "http://localhost:8080/?key={\"test\":\"test\"}",
|
||||
key: "key",
|
||||
ret: map[string]interface{}{"test": "test"},
|
||||
ret: map[string]any{"test": "test"},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
@@ -177,7 +177,7 @@ func TestReadNumQuery(t *testing.T) {
|
||||
url string
|
||||
key string
|
||||
numType string
|
||||
ret interface{}
|
||||
ret any
|
||||
err error
|
||||
}{
|
||||
{
|
||||
@@ -316,7 +316,7 @@ func TestReadNumQuery(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
|
||||
r := &http.Request{URL: parsedURL}
|
||||
var ret interface{}
|
||||
var ret any
|
||||
switch c.numType {
|
||||
case "int64":
|
||||
ret, err = apiutil.ReadNumQuery[int64](r, c.key, 0)
|
||||
|
||||
@@ -78,12 +78,12 @@ func (client authGrpcClient) Authenticate(ctx context.Context, token *grpcAuthV1
|
||||
return &grpcAuthV1.AuthNRes{Id: ir.id, UserId: ir.userID, UserRole: uint32(ir.userRole)}, nil
|
||||
}
|
||||
|
||||
func encodeIdentifyRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func encodeIdentifyRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(authenticateReq)
|
||||
return &grpcAuthV1.AuthNReq{Token: req.token}, nil
|
||||
}
|
||||
|
||||
func decodeIdentifyResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func decodeIdentifyResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(*grpcAuthV1.AuthNRes)
|
||||
return authenticateRes{id: res.GetId(), userID: res.GetUserId(), userRole: auth.Role(res.UserRole)}, nil
|
||||
}
|
||||
@@ -100,7 +100,7 @@ func (client authGrpcClient) AuthenticatePAT(ctx context.Context, token *grpcAut
|
||||
return &grpcAuthV1.AuthNRes{Id: ir.id, UserId: ir.userID, UserRole: uint32(ir.userRole)}, nil
|
||||
}
|
||||
|
||||
func decodeIdentifyPATResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func decodeIdentifyPATResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(*grpcAuthV1.AuthNRes)
|
||||
return authenticateRes{id: res.GetId(), userID: res.GetUserId(), userRole: auth.Role(res.UserRole)}, nil
|
||||
}
|
||||
@@ -127,12 +127,12 @@ func (client authGrpcClient) Authorize(ctx context.Context, req *grpcAuthV1.Auth
|
||||
return &grpcAuthV1.AuthZRes{Authorized: ar.authorized, Id: ar.id}, nil
|
||||
}
|
||||
|
||||
func decodeAuthorizeResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func decodeAuthorizeResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(*grpcAuthV1.AuthZRes)
|
||||
return authorizeRes{authorized: res.Authorized, id: res.Id}, nil
|
||||
}
|
||||
|
||||
func encodeAuthorizeRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func encodeAuthorizeRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(authReq)
|
||||
return &grpcAuthV1.AuthZReq{
|
||||
Domain: req.Domain,
|
||||
@@ -166,7 +166,7 @@ func (client authGrpcClient) AuthorizePAT(ctx context.Context, req *grpcAuthV1.A
|
||||
return &grpcAuthV1.AuthZRes{Authorized: ar.authorized, Id: ar.id}, nil
|
||||
}
|
||||
|
||||
func encodeAuthorizePATRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func encodeAuthorizePATRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(authPATReq)
|
||||
return &grpcAuthV1.AuthZPatReq{
|
||||
UserId: req.userID,
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func authenticateEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(authenticateReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return authenticateRes{}, err
|
||||
@@ -28,7 +28,7 @@ func authenticateEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func authenticatePATEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(authenticateReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return authenticateRes{}, err
|
||||
@@ -44,7 +44,7 @@ func authenticatePATEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func authorizeEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(authReq)
|
||||
|
||||
if err := req.validate(); err != nil {
|
||||
@@ -68,7 +68,7 @@ func authorizeEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func authorizePATEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(authPATReq)
|
||||
|
||||
if err := req.validate(); err != nil {
|
||||
|
||||
@@ -75,22 +75,22 @@ func (s *authGrpcServer) Authorize(ctx context.Context, req *grpcAuthV1.AuthZReq
|
||||
return res.(*grpcAuthV1.AuthZRes), nil
|
||||
}
|
||||
|
||||
func decodeAuthenticateRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func decodeAuthenticateRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(*grpcAuthV1.AuthNReq)
|
||||
return authenticateReq{token: req.GetToken()}, nil
|
||||
}
|
||||
|
||||
func encodeAuthenticateResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func encodeAuthenticateResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(authenticateRes)
|
||||
return &grpcAuthV1.AuthNRes{Id: res.id, UserId: res.userID, UserRole: uint32(res.userRole)}, nil
|
||||
}
|
||||
|
||||
func encodeAuthenticatePATResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func encodeAuthenticatePATResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(authenticateRes)
|
||||
return &grpcAuthV1.AuthNRes{Id: res.id, UserId: res.userID, UserRole: uint32(res.userRole)}, nil
|
||||
}
|
||||
|
||||
func decodeAuthorizeRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func decodeAuthorizeRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(*grpcAuthV1.AuthZReq)
|
||||
return authReq{
|
||||
Domain: req.GetDomain(),
|
||||
@@ -104,12 +104,12 @@ func decodeAuthorizeRequest(_ context.Context, grpcReq interface{}) (interface{}
|
||||
}, nil
|
||||
}
|
||||
|
||||
func encodeAuthorizeResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func encodeAuthorizeResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(authorizeRes)
|
||||
return &grpcAuthV1.AuthZRes{Authorized: res.authorized, Id: res.id}, nil
|
||||
}
|
||||
|
||||
func decodeAuthorizePATRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func decodeAuthorizePATRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(*grpcAuthV1.AuthZPatReq)
|
||||
return authPATReq{
|
||||
userID: req.GetUserId(),
|
||||
|
||||
@@ -63,7 +63,7 @@ func (client tokenGrpcClient) Issue(ctx context.Context, req *grpcTokenV1.IssueR
|
||||
return res.(*grpcTokenV1.Token), nil
|
||||
}
|
||||
|
||||
func encodeIssueRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func encodeIssueRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(issueReq)
|
||||
return &grpcTokenV1.IssueReq{
|
||||
UserId: req.userID,
|
||||
@@ -72,7 +72,7 @@ func encodeIssueRequest(_ context.Context, grpcReq interface{}) (interface{}, er
|
||||
}, nil
|
||||
}
|
||||
|
||||
func decodeIssueResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func decodeIssueResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
return grpcRes, nil
|
||||
}
|
||||
|
||||
@@ -87,11 +87,11 @@ func (client tokenGrpcClient) Refresh(ctx context.Context, req *grpcTokenV1.Refr
|
||||
return res.(*grpcTokenV1.Token), nil
|
||||
}
|
||||
|
||||
func encodeRefreshRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func encodeRefreshRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(refreshReq)
|
||||
return &grpcTokenV1.RefreshReq{RefreshToken: req.refreshToken}, nil
|
||||
}
|
||||
|
||||
func decodeRefreshResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func decodeRefreshResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
return grpcRes, nil
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func issueEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(issueReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return issueRes{}, err
|
||||
@@ -36,7 +36,7 @@ func issueEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func refreshEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(refreshReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return issueRes{}, err
|
||||
|
||||
@@ -52,7 +52,7 @@ func (s *tokenGrpcServer) Refresh(ctx context.Context, req *grpcTokenV1.RefreshR
|
||||
return res.(*grpcTokenV1.Token), nil
|
||||
}
|
||||
|
||||
func decodeIssueRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func decodeIssueRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(*grpcTokenV1.IssueReq)
|
||||
return issueReq{
|
||||
userID: req.GetUserId(),
|
||||
@@ -61,12 +61,12 @@ func decodeIssueRequest(_ context.Context, grpcReq interface{}) (interface{}, er
|
||||
}, nil
|
||||
}
|
||||
|
||||
func decodeRefreshRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func decodeRefreshRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(*grpcTokenV1.RefreshReq)
|
||||
return refreshReq{refreshToken: req.GetRefreshToken()}, nil
|
||||
}
|
||||
|
||||
func encodeIssueResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func encodeIssueResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(issueRes)
|
||||
|
||||
return &grpcTokenV1.Token{
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func issueEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(issueKeyReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, err
|
||||
@@ -44,7 +44,7 @@ func issueEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func retrieveEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(keyReq)
|
||||
|
||||
if err := req.validate(); err != nil {
|
||||
@@ -71,7 +71,7 @@ func retrieveEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func revokeEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(keyReq)
|
||||
|
||||
if err := req.validate(); err != nil {
|
||||
|
||||
@@ -90,7 +90,7 @@ func newServer(svc auth.Service) *httptest.Server {
|
||||
return httptest.NewServer(mux)
|
||||
}
|
||||
|
||||
func toJSON(data interface{}) string {
|
||||
func toJSON(data any) string {
|
||||
jsonData, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return ""
|
||||
|
||||
@@ -50,7 +50,7 @@ func MakeHandler(svc auth.Service, mux *chi.Mux, logger *slog.Logger) *chi.Mux {
|
||||
return mux
|
||||
}
|
||||
|
||||
func decodeIssue(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeIssue(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), contentType) {
|
||||
return nil, apiutil.ErrUnsupportedContentType
|
||||
}
|
||||
@@ -63,7 +63,7 @@ func decodeIssue(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeKeyReq(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeKeyReq(_ context.Context, r *http.Request) (any, error) {
|
||||
req := keyReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
id: chi.URLParam(r, "id"),
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func createPATEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(createPatReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, err
|
||||
@@ -27,7 +27,7 @@ func createPATEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func retrievePATEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(retrievePatReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, err
|
||||
@@ -43,7 +43,7 @@ func retrievePATEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func updatePATNameEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(updatePatNameReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, err
|
||||
@@ -59,7 +59,7 @@ func updatePATNameEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func updatePATDescriptionEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(updatePatDescriptionReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, err
|
||||
@@ -75,7 +75,7 @@ func updatePATDescriptionEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func listPATSEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(listPatsReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, err
|
||||
@@ -98,7 +98,7 @@ func listPATSEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func deletePATEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(deletePatReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, err
|
||||
@@ -113,7 +113,7 @@ func deletePATEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func resetPATSecretEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(resetPatSecretReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, err
|
||||
@@ -129,7 +129,7 @@ func resetPATSecretEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func revokePATSecretEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(revokePatSecretReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, err
|
||||
@@ -144,7 +144,7 @@ func revokePATSecretEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func clearAllPATEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(clearAllPATReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, err
|
||||
@@ -159,7 +159,7 @@ func clearAllPATEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func addScopeEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(addScopeReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, err
|
||||
@@ -174,7 +174,7 @@ func addScopeEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func removeScopeEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(removeScopeReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, err
|
||||
@@ -189,7 +189,7 @@ func removeScopeEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func clearAllScopeEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(clearAllScopeReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, err
|
||||
@@ -204,7 +204,7 @@ func clearAllScopeEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func listScopesEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(listScopesReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -130,7 +130,7 @@ func MakeHandler(svc auth.Service, mux *chi.Mux, logger *slog.Logger) *chi.Mux {
|
||||
return mux
|
||||
}
|
||||
|
||||
func decodeCreatePATRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeCreatePATRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), contentType) {
|
||||
return nil, apiutil.ErrUnsupportedContentType
|
||||
}
|
||||
@@ -145,7 +145,7 @@ func decodeCreatePATRequest(_ context.Context, r *http.Request) (interface{}, er
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeRetrievePATRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeRetrievePATRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
token := apiutil.ExtractBearerToken(r)
|
||||
if strings.HasPrefix(token, patPrefix) {
|
||||
return nil, apiutil.ErrUnsupportedTokenType
|
||||
@@ -158,7 +158,7 @@ func decodeRetrievePATRequest(_ context.Context, r *http.Request) (interface{},
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeUpdatePATNameRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeUpdatePATNameRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), contentType) {
|
||||
return nil, apiutil.ErrUnsupportedContentType
|
||||
}
|
||||
@@ -176,7 +176,7 @@ func decodeUpdatePATNameRequest(_ context.Context, r *http.Request) (interface{}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeUpdatePATDescriptionRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeUpdatePATDescriptionRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), contentType) {
|
||||
return nil, apiutil.ErrUnsupportedContentType
|
||||
}
|
||||
@@ -195,7 +195,7 @@ func decodeUpdatePATDescriptionRequest(_ context.Context, r *http.Request) (inte
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeListPATSRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeListPATSRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
l, err := apiutil.ReadNumQuery[uint64](r, api.LimitKey, api.DefLimit)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -237,7 +237,7 @@ func decodeListPATSRequest(_ context.Context, r *http.Request) (interface{}, err
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeDeletePATRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeDeletePATRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
token := apiutil.ExtractBearerToken(r)
|
||||
if strings.HasPrefix(token, patPrefix) {
|
||||
return nil, apiutil.ErrUnsupportedTokenType
|
||||
@@ -248,7 +248,7 @@ func decodeDeletePATRequest(_ context.Context, r *http.Request) (interface{}, er
|
||||
}, nil
|
||||
}
|
||||
|
||||
func decodeResetPATSecretRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeResetPATSecretRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), contentType) {
|
||||
return nil, apiutil.ErrUnsupportedContentType
|
||||
}
|
||||
@@ -267,7 +267,7 @@ func decodeResetPATSecretRequest(_ context.Context, r *http.Request) (interface{
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeRevokePATSecretRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeRevokePATSecretRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
token := apiutil.ExtractBearerToken(r)
|
||||
if strings.HasPrefix(token, patPrefix) {
|
||||
return nil, apiutil.ErrUnsupportedTokenType
|
||||
@@ -278,7 +278,7 @@ func decodeRevokePATSecretRequest(_ context.Context, r *http.Request) (interface
|
||||
}, nil
|
||||
}
|
||||
|
||||
func decodeClearAllPATRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeClearAllPATRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
token := apiutil.ExtractBearerToken(r)
|
||||
if strings.HasPrefix(token, patPrefix) {
|
||||
return nil, apiutil.ErrUnsupportedTokenType
|
||||
@@ -289,7 +289,7 @@ func decodeClearAllPATRequest(_ context.Context, r *http.Request) (interface{},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func decodeAddScopeRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeAddScopeRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), contentType) {
|
||||
return nil, apiutil.ErrUnsupportedContentType
|
||||
}
|
||||
@@ -311,7 +311,7 @@ func decodeAddScopeRequest(_ context.Context, r *http.Request) (interface{}, err
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeListScopeRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeListScopeRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
l, err := apiutil.ReadNumQuery[uint64](r, api.LimitKey, api.DefLimit)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -333,7 +333,7 @@ func decodeListScopeRequest(_ context.Context, r *http.Request) (interface{}, er
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeRemoveScopeRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeRemoveScopeRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), contentType) {
|
||||
return nil, apiutil.ErrUnsupportedContentType
|
||||
}
|
||||
@@ -353,7 +353,7 @@ func decodeRemoveScopeRequest(_ context.Context, r *http.Request) (interface{},
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeClearAllScopeRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeClearAllScopeRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
token := apiutil.ExtractBearerToken(r)
|
||||
if strings.HasPrefix(token, patPrefix) {
|
||||
return nil, apiutil.ErrUnsupportedTokenType
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func issueCert(svc certs.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(addCertsReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -38,7 +38,7 @@ func issueCert(svc certs.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func listSerials(svc certs.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(listReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -71,7 +71,7 @@ func listSerials(svc certs.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func viewCert(svc certs.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(viewReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return certsRes{}, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -95,7 +95,7 @@ func viewCert(svc certs.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func revokeAllCerts(svc certs.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(revokeAllReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -111,7 +111,7 @@ func revokeAllCerts(svc certs.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func revokeBySerial(svc certs.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(revokeBySerialReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
|
||||
@@ -83,7 +83,7 @@ func MakeHandler(svc certs.Service, authn smqauthn.Authentication, logger *slog.
|
||||
return r
|
||||
}
|
||||
|
||||
func decodeListCerts(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeListCerts(_ context.Context, r *http.Request) (any, error) {
|
||||
l, err := apiutil.ReadNumQuery[uint64](r, limitKey, defLimit)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -108,7 +108,7 @@ func decodeListCerts(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeViewCert(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeViewCert(_ context.Context, r *http.Request) (any, error) {
|
||||
req := viewReq{
|
||||
serialID: chi.URLParam(r, "certID"),
|
||||
}
|
||||
@@ -116,7 +116,7 @@ func decodeViewCert(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeCerts(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeCerts(_ context.Context, r *http.Request) (any, error) {
|
||||
if r.Header.Get("Content-Type") != contentType {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -132,7 +132,7 @@ func decodeCerts(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeRevokeAllCerts(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeRevokeAllCerts(_ context.Context, r *http.Request) (any, error) {
|
||||
req := revokeAllReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
clientID: chi.URLParam(r, "clientID"),
|
||||
@@ -142,7 +142,7 @@ func decodeRevokeAllCerts(_ context.Context, r *http.Request) (interface{}, erro
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeRevokeBySerial(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeRevokeBySerial(_ context.Context, r *http.Request) (any, error) {
|
||||
req := revokeBySerialReq{
|
||||
serialID: chi.URLParam(r, "certID"),
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ func (va *openbaoPKIAgent) Issue(entityId, ttl string, ipAddrs []string) (certs.
|
||||
return certs.Cert{}, err
|
||||
}
|
||||
|
||||
secretValues := map[string]interface{}{
|
||||
secretValues := map[string]any{
|
||||
"common_name": entityId,
|
||||
"ttl": ttl,
|
||||
"exclude_cn_from_sans": true,
|
||||
@@ -122,7 +122,7 @@ func (va *openbaoPKIAgent) Issue(entityId, ttl string, ipAddrs []string) (certs.
|
||||
if serialNumber, ok := secret.Data["serial_number"].(string); ok {
|
||||
cert.SerialNumber = serialNumber
|
||||
}
|
||||
if caChain, ok := secret.Data["ca_chain"].([]interface{}); ok {
|
||||
if caChain, ok := secret.Data["ca_chain"].([]any); ok {
|
||||
for _, ca := range caChain {
|
||||
if caStr, ok := ca.(string); ok {
|
||||
cert.CAChain = append(cert.CAChain, caStr)
|
||||
@@ -201,7 +201,7 @@ func (va *openbaoPKIAgent) Revoke(serialNumber string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
secretValues := map[string]interface{}{
|
||||
secretValues := map[string]any{
|
||||
"serial_number": serialNumber,
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ func (va *openbaoPKIAgent) LoginAndRenew() error {
|
||||
}
|
||||
}
|
||||
|
||||
authData := map[string]interface{}{
|
||||
authData := map[string]any{
|
||||
"role_id": va.appRole,
|
||||
"secret_id": va.appSecret,
|
||||
}
|
||||
|
||||
+10
-10
@@ -100,7 +100,7 @@ func (client grpcClient) Authorize(ctx context.Context, req *grpcChannelsV1.Auth
|
||||
return &grpcChannelsV1.AuthzRes{Authorized: ar.authorized}, nil
|
||||
}
|
||||
|
||||
func encodeAuthorizeRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func encodeAuthorizeRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(authorizeReq)
|
||||
|
||||
return &grpcChannelsV1.AuthzReq{
|
||||
@@ -112,7 +112,7 @@ func encodeAuthorizeRequest(_ context.Context, grpcReq interface{}) (interface{}
|
||||
}, nil
|
||||
}
|
||||
|
||||
func decodeAuthorizeResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func decodeAuthorizeResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(*grpcChannelsV1.AuthzRes)
|
||||
|
||||
return authorizeRes{authorized: res.GetAuthorized()}, nil
|
||||
@@ -129,11 +129,11 @@ func (client grpcClient) RemoveClientConnections(ctx context.Context, req *grpcC
|
||||
return &grpcChannelsV1.RemoveClientConnectionsRes{}, nil
|
||||
}
|
||||
|
||||
func encodeRemoveClientConnectionsRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func encodeRemoveClientConnectionsRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
return grpcReq.(*grpcChannelsV1.RemoveClientConnectionsReq), nil
|
||||
}
|
||||
|
||||
func decodeRemoveClientConnectionsResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func decodeRemoveClientConnectionsResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
return grpcRes.(*grpcChannelsV1.RemoveClientConnectionsRes), nil
|
||||
}
|
||||
|
||||
@@ -148,11 +148,11 @@ func (client grpcClient) UnsetParentGroupFromChannels(ctx context.Context, req *
|
||||
return &grpcChannelsV1.UnsetParentGroupFromChannelsRes{}, nil
|
||||
}
|
||||
|
||||
func encodeUnsetParentGroupFromChannelsRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func encodeUnsetParentGroupFromChannelsRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
return grpcReq.(*grpcChannelsV1.UnsetParentGroupFromChannelsReq), nil
|
||||
}
|
||||
|
||||
func decodeUnsetParentGroupFromChannelsResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func decodeUnsetParentGroupFromChannelsResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
return grpcRes.(*grpcChannelsV1.UnsetParentGroupFromChannelsRes), nil
|
||||
}
|
||||
|
||||
@@ -168,11 +168,11 @@ func (client grpcClient) RetrieveEntity(ctx context.Context, req *grpcCommonV1.R
|
||||
return res.(*grpcCommonV1.RetrieveEntityRes), nil
|
||||
}
|
||||
|
||||
func encodeRetrieveEntityRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func encodeRetrieveEntityRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
return grpcReq.(*grpcCommonV1.RetrieveEntityReq), nil
|
||||
}
|
||||
|
||||
func decodeRetrieveEntityResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func decodeRetrieveEntityResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
return grpcRes.(*grpcCommonV1.RetrieveEntityRes), nil
|
||||
}
|
||||
|
||||
@@ -188,11 +188,11 @@ func (client grpcClient) RetrieveIDByRoute(ctx context.Context, req *grpcCommonV
|
||||
return res.(*grpcCommonV1.RetrieveEntityRes), nil
|
||||
}
|
||||
|
||||
func encodeRetrieveIDByRouteRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func encodeRetrieveIDByRouteRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
return grpcReq.(*grpcCommonV1.RetrieveIDByRouteReq), nil
|
||||
}
|
||||
|
||||
func decodeRetrieveIDByRouteResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func decodeRetrieveIDByRouteResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
return grpcRes.(*grpcCommonV1.RetrieveEntityRes), nil
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func authorizeEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(authorizeReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return authorizeRes{}, err
|
||||
@@ -33,7 +33,7 @@ func authorizeEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func removeClientConnectionsEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(removeClientConnectionsReq)
|
||||
|
||||
if err := svc.RemoveClientConnections(ctx, req.clientID); err != nil {
|
||||
@@ -45,7 +45,7 @@ func removeClientConnectionsEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func unsetParentGroupFromChannelsEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(unsetParentGroupFromChannelsReq)
|
||||
|
||||
if err := svc.UnsetParentGroupFromChannels(ctx, req.parentGroupID); err != nil {
|
||||
@@ -57,7 +57,7 @@ func unsetParentGroupFromChannelsEndpoint(svc channels.Service) endpoint.Endpoin
|
||||
}
|
||||
|
||||
func retrieveEntityEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(retrieveEntityReq)
|
||||
channel, err := svc.RetrieveByID(ctx, req.Id)
|
||||
if err != nil {
|
||||
@@ -69,7 +69,7 @@ func retrieveEntityEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func retrieveIDByRouteEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(retrieveIDByRouteReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return retrieveIDByRouteRes{}, err
|
||||
|
||||
+10
-10
@@ -69,7 +69,7 @@ func (s *grpcServer) Authorize(ctx context.Context, req *grpcChannelsV1.AuthzReq
|
||||
return res.(*grpcChannelsV1.AuthzRes), nil
|
||||
}
|
||||
|
||||
func decodeAuthorizeRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func decodeAuthorizeRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(*grpcChannelsV1.AuthzReq)
|
||||
|
||||
connType := connections.ConnType(req.GetType())
|
||||
@@ -85,7 +85,7 @@ func decodeAuthorizeRequest(_ context.Context, grpcReq interface{}) (interface{}
|
||||
}, nil
|
||||
}
|
||||
|
||||
func encodeAuthorizeResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func encodeAuthorizeResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(authorizeRes)
|
||||
return &grpcChannelsV1.AuthzRes{Authorized: res.authorized}, nil
|
||||
}
|
||||
@@ -98,7 +98,7 @@ func (s *grpcServer) RemoveClientConnections(ctx context.Context, req *grpcChann
|
||||
return res.(*grpcChannelsV1.RemoveClientConnectionsRes), nil
|
||||
}
|
||||
|
||||
func decodeRemoveClientConnectionsRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func decodeRemoveClientConnectionsRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(*grpcChannelsV1.RemoveClientConnectionsReq)
|
||||
|
||||
return removeClientConnectionsReq{
|
||||
@@ -106,7 +106,7 @@ func decodeRemoveClientConnectionsRequest(_ context.Context, grpcReq interface{}
|
||||
}, nil
|
||||
}
|
||||
|
||||
func encodeRemoveClientConnectionsResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func encodeRemoveClientConnectionsResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
_ = grpcRes.(removeClientConnectionsRes)
|
||||
return &grpcChannelsV1.RemoveClientConnectionsRes{}, nil
|
||||
}
|
||||
@@ -119,7 +119,7 @@ func (s *grpcServer) UnsetParentGroupFromChannels(ctx context.Context, req *grpc
|
||||
return res.(*grpcChannelsV1.UnsetParentGroupFromChannelsRes), nil
|
||||
}
|
||||
|
||||
func decodeUnsetParentGroupFromChannelsRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func decodeUnsetParentGroupFromChannelsRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(*grpcChannelsV1.UnsetParentGroupFromChannelsReq)
|
||||
|
||||
return unsetParentGroupFromChannelsReq{
|
||||
@@ -127,7 +127,7 @@ func decodeUnsetParentGroupFromChannelsRequest(_ context.Context, grpcReq interf
|
||||
}, nil
|
||||
}
|
||||
|
||||
func encodeUnsetParentGroupFromChannelsResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func encodeUnsetParentGroupFromChannelsResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
_ = grpcRes.(unsetParentGroupFromChannelsRes)
|
||||
return &grpcChannelsV1.UnsetParentGroupFromChannelsRes{}, nil
|
||||
}
|
||||
@@ -140,14 +140,14 @@ func (s *grpcServer) RetrieveEntity(ctx context.Context, req *grpcCommonV1.Retri
|
||||
return res.(*grpcCommonV1.RetrieveEntityRes), nil
|
||||
}
|
||||
|
||||
func decodeRetrieveEntityRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func decodeRetrieveEntityRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(*grpcCommonV1.RetrieveEntityReq)
|
||||
return retrieveEntityReq{
|
||||
Id: req.GetId(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func encodeRetrieveEntityResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func encodeRetrieveEntityResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(retrieveEntityRes)
|
||||
|
||||
return &grpcCommonV1.RetrieveEntityRes{
|
||||
@@ -160,7 +160,7 @@ func encodeRetrieveEntityResponse(_ context.Context, grpcRes interface{}) (inter
|
||||
}, nil
|
||||
}
|
||||
|
||||
func decodeRetrieveIDByRouteRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func decodeRetrieveIDByRouteRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(*grpcCommonV1.RetrieveIDByRouteReq)
|
||||
return retrieveIDByRouteReq{
|
||||
route: req.GetRoute(),
|
||||
@@ -168,7 +168,7 @@ func decodeRetrieveIDByRouteRequest(_ context.Context, grpcReq interface{}) (int
|
||||
}, nil
|
||||
}
|
||||
|
||||
func encodeRetrieveIDByRouteResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func encodeRetrieveIDByRouteResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(retrieveIDByRouteRes)
|
||||
|
||||
return &grpcCommonV1.RetrieveEntityRes{
|
||||
|
||||
+14
-14
@@ -17,7 +17,7 @@ import (
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
func decodeViewChannel(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeViewChannel(_ context.Context, r *http.Request) (any, error) {
|
||||
roles, err := apiutil.ReadBoolQuery(r, api.RolesKey, false)
|
||||
if err != nil {
|
||||
return viewChannelReq{}, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -31,7 +31,7 @@ func decodeViewChannel(_ context.Context, r *http.Request) (interface{}, error)
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeCreateChannelReq(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeCreateChannelReq(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -44,7 +44,7 @@ func decodeCreateChannelReq(_ context.Context, r *http.Request) (interface{}, er
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeCreateChannelsReq(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeCreateChannelsReq(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -57,7 +57,7 @@ func decodeCreateChannelsReq(_ context.Context, r *http.Request) (interface{}, e
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeListChannels(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeListChannels(_ context.Context, r *http.Request) (any, error) {
|
||||
name, err := apiutil.ReadStringQuery(r, api.NameKey, "")
|
||||
if err != nil {
|
||||
return listChannelsReq{}, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -174,7 +174,7 @@ func decodeListChannels(_ context.Context, r *http.Request) (interface{}, error)
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeUpdateChannel(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeUpdateChannel(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -189,7 +189,7 @@ func decodeUpdateChannel(_ context.Context, r *http.Request) (interface{}, error
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeUpdateChannelTags(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeUpdateChannelTags(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -204,7 +204,7 @@ func decodeUpdateChannelTags(_ context.Context, r *http.Request) (interface{}, e
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeSetChannelParentGroupStatus(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeSetChannelParentGroupStatus(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -218,7 +218,7 @@ func decodeSetChannelParentGroupStatus(_ context.Context, r *http.Request) (inte
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeRemoveChannelParentGroupStatus(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeRemoveChannelParentGroupStatus(_ context.Context, r *http.Request) (any, error) {
|
||||
req := removeChannelParentGroupReq{
|
||||
id: chi.URLParam(r, "channelID"),
|
||||
}
|
||||
@@ -226,7 +226,7 @@ func decodeRemoveChannelParentGroupStatus(_ context.Context, r *http.Request) (i
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeChangeChannelStatus(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeChangeChannelStatus(_ context.Context, r *http.Request) (any, error) {
|
||||
req := changeChannelStatusReq{
|
||||
id: chi.URLParam(r, "channelID"),
|
||||
}
|
||||
@@ -234,14 +234,14 @@ func decodeChangeChannelStatus(_ context.Context, r *http.Request) (interface{},
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeDeleteChannelReq(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeDeleteChannelReq(_ context.Context, r *http.Request) (any, error) {
|
||||
req := deleteChannelReq{
|
||||
id: chi.URLParam(r, "channelID"),
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeConnectChannelClientRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeConnectChannelClientRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -255,7 +255,7 @@ func decodeConnectChannelClientRequest(_ context.Context, r *http.Request) (inte
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeDisconnectChannelClientsRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeDisconnectChannelClientsRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -269,7 +269,7 @@ func decodeDisconnectChannelClientsRequest(_ context.Context, r *http.Request) (
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeConnectRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeConnectRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -282,7 +282,7 @@ func decodeConnectRequest(_ context.Context, r *http.Request) (interface{}, erro
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeDisconnectRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeDisconnectRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ func TestCreateChannelEndpoint(t *testing.T) {
|
||||
|
||||
reqChannel := channels.Channel{
|
||||
Name: valid,
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"name": "test",
|
||||
},
|
||||
Route: valid,
|
||||
@@ -145,7 +145,7 @@ func TestCreateChannelEndpoint(t *testing.T) {
|
||||
domainID: validID,
|
||||
req: channels.Channel{
|
||||
Name: strings.Repeat("a", 1025),
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"name": "test",
|
||||
},
|
||||
},
|
||||
@@ -238,7 +238,7 @@ func TestCreateChannelsEndpoint(t *testing.T) {
|
||||
reqChannels := []channels.Channel{
|
||||
{
|
||||
Name: valid,
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"name": "test",
|
||||
},
|
||||
Route: valid,
|
||||
@@ -304,7 +304,7 @@ func TestCreateChannelsEndpoint(t *testing.T) {
|
||||
req: []channels.Channel{
|
||||
{
|
||||
Name: strings.Repeat("a", 1025),
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"name": "test",
|
||||
},
|
||||
},
|
||||
@@ -824,7 +824,7 @@ func TestUpdateChannelEndpoint(t *testing.T) {
|
||||
updateChannelReq := channels.Channel{
|
||||
ID: validID,
|
||||
Name: valid,
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"name": "test",
|
||||
},
|
||||
}
|
||||
@@ -895,7 +895,7 @@ func TestUpdateChannelEndpoint(t *testing.T) {
|
||||
updateReq: channels.Channel{
|
||||
ID: validID,
|
||||
Name: strings.Repeat("a", 1025),
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"name": "test",
|
||||
},
|
||||
},
|
||||
@@ -1843,7 +1843,7 @@ func TestConnectEndpoint(t *testing.T) {
|
||||
url: fmt.Sprintf("%s/%s/channels/connect", gs.URL, tc.domainID),
|
||||
token: tc.token,
|
||||
contentType: contentType,
|
||||
body: strings.NewReader(toJSON(map[string]interface{}{
|
||||
body: strings.NewReader(toJSON(map[string]any{
|
||||
"channel_ids": tc.channelIDs,
|
||||
"client_ids": tc.clientIDs,
|
||||
"types": tc.types,
|
||||
@@ -1973,7 +1973,7 @@ func TestDisconnectEndpoint(t *testing.T) {
|
||||
url: fmt.Sprintf("%s/%s/channels/disconnect", gs.URL, tc.domainID),
|
||||
token: tc.token,
|
||||
contentType: contentType,
|
||||
body: strings.NewReader(toJSON(map[string]interface{}{
|
||||
body: strings.NewReader(toJSON(map[string]any{
|
||||
"channel_ids": tc.channelIDs,
|
||||
"client_ids": tc.clientIDs,
|
||||
"types": tc.types,
|
||||
@@ -2104,7 +2104,7 @@ func (tr testRequest) make() (*http.Response, error) {
|
||||
return tr.client.Do(req)
|
||||
}
|
||||
|
||||
func toJSON(data interface{}) string {
|
||||
func toJSON(data any) string {
|
||||
jsonData, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return ""
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
func createChannelEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(createChannelReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -40,7 +40,7 @@ func createChannelEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func createChannelsEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(createChannelsReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -71,7 +71,7 @@ func createChannelsEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func viewChannelEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(viewChannelReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -92,7 +92,7 @@ func viewChannelEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func listChannelsEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(listChannelsReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -132,7 +132,7 @@ func listChannelsEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func updateChannelEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(updateChannelReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -158,7 +158,7 @@ func updateChannelEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func updateChannelTagsEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(updateChannelTagsReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -183,7 +183,7 @@ func updateChannelTagsEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func setChannelParentGroupEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(setChannelParentGroupReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -203,7 +203,7 @@ func setChannelParentGroupEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func removeChannelParentGroupEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(removeChannelParentGroupReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -223,7 +223,7 @@ func removeChannelParentGroupEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func enableChannelEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(changeChannelStatusReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -244,7 +244,7 @@ func enableChannelEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func disableChannelEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(changeChannelStatusReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -265,7 +265,7 @@ func disableChannelEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func connectChannelClientEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(connectChannelClientsRequest)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -285,7 +285,7 @@ func connectChannelClientEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func disconnectChannelClientsEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(disconnectChannelClientsRequest)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -305,7 +305,7 @@ func disconnectChannelClientsEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func connectEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(connectRequest)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -325,7 +325,7 @@ func connectEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func disconnectEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(disconnectRequest)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -345,7 +345,7 @@ func disconnectEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func deleteChannelEndpoint(svc channels.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(deleteChannelReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
|
||||
@@ -108,9 +108,9 @@ func (req listChannelsReq) validate() error {
|
||||
|
||||
type updateChannelReq struct {
|
||||
id string
|
||||
Name string `json:"name,omitempty"`
|
||||
Metadata map[string]interface{} `json:"metadata,omitempty"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Metadata map[string]any `json:"metadata,omitempty"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
func (req updateChannelReq) validate() error {
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
// Metadata represents arbitrary JSON.
|
||||
type Metadata map[string]interface{}
|
||||
type Metadata map[string]any
|
||||
|
||||
// Channel represents a SuperMQ "communication topic". This topic
|
||||
// contains the clients that can exchange messages between each other.
|
||||
|
||||
+22
-22
@@ -48,8 +48,8 @@ type createChannelEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (cce createChannelEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (cce createChannelEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": channelCreate,
|
||||
"id": cce.ID,
|
||||
"roles_provisioned": cce.rolesProvisioned,
|
||||
@@ -83,8 +83,8 @@ type updateChannelEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (uce updateChannelEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (uce updateChannelEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": uce.operation,
|
||||
"updated_at": uce.UpdatedAt,
|
||||
"updated_by": uce.UpdatedBy,
|
||||
@@ -130,8 +130,8 @@ type changeChannelStatusEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (cse changeChannelStatusEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (cse changeChannelStatusEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": cse.operation,
|
||||
"id": cse.id,
|
||||
"status": cse.status,
|
||||
@@ -151,8 +151,8 @@ type viewChannelEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (vce viewChannelEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (vce viewChannelEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": channelView,
|
||||
"id": vce.ID,
|
||||
"domain": vce.DomainID,
|
||||
@@ -196,8 +196,8 @@ type listChannelEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (lce listChannelEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (lce listChannelEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": channelList,
|
||||
"total": lce.Total,
|
||||
"offset": lce.Offset,
|
||||
@@ -241,8 +241,8 @@ type listUserChannelsEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (luce listUserChannelsEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (luce listUserChannelsEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": channelListByUser,
|
||||
"req_user_id": luce.userID,
|
||||
"total": luce.Total,
|
||||
@@ -289,8 +289,8 @@ type removeChannelEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (dce removeChannelEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (dce removeChannelEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": channelRemove,
|
||||
"id": dce.id,
|
||||
"domain": dce.DomainID,
|
||||
@@ -309,8 +309,8 @@ type connectEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (ce connectEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (ce connectEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": channelConnect,
|
||||
"client_ids": ce.thIDs,
|
||||
"channel_ids": ce.chIDs,
|
||||
@@ -331,8 +331,8 @@ type disconnectEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (de disconnectEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (de disconnectEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": channelDisconnect,
|
||||
"client_ids": de.thIDs,
|
||||
"channel_ids": de.chIDs,
|
||||
@@ -352,8 +352,8 @@ type setParentGroupEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (spge setParentGroupEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (spge setParentGroupEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": channelSetParent,
|
||||
"id": spge.id,
|
||||
"parent_group_id": spge.parentGroupID,
|
||||
@@ -371,8 +371,8 @@ type removeParentGroupEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (rpge removeParentGroupEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (rpge removeParentGroupEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": channelRemoveParent,
|
||||
"id": rpge.id,
|
||||
"domain": rpge.DomainID,
|
||||
|
||||
@@ -644,7 +644,7 @@ func (am *authorizationMiddleware) checkSuperAdmin(ctx context.Context, userID s
|
||||
return nil
|
||||
}
|
||||
|
||||
func (am *authorizationMiddleware) callOut(ctx context.Context, session authn.Session, op string, params map[string]interface{}) error {
|
||||
func (am *authorizationMiddleware) callOut(ctx context.Context, session authn.Session, op string, params map[string]any) error {
|
||||
pl := map[string]any{
|
||||
"entity_type": policies.ChannelType,
|
||||
"subject_type": policies.UserType,
|
||||
|
||||
@@ -349,7 +349,7 @@ func (cr *channelRepository) RetrieveByIDWithRoles(ctx context.Context, id, memb
|
||||
FROM channels c2
|
||||
JOIN final_roles fr ON fr.channel_id = c2.id
|
||||
`
|
||||
parameters := map[string]interface{}{
|
||||
parameters := map[string]any{
|
||||
"id": id,
|
||||
"member_id": memberID,
|
||||
}
|
||||
@@ -894,7 +894,7 @@ final_channels AS (
|
||||
|
||||
func (cr *channelRepository) Remove(ctx context.Context, ids ...string) error {
|
||||
q := "DELETE FROM channels AS c WHERE c.id = ANY(:channel_ids) ;"
|
||||
params := map[string]interface{}{
|
||||
params := map[string]any{
|
||||
"channel_ids": ids,
|
||||
}
|
||||
result, err := cr.db.NamedExecContext(ctx, q, params)
|
||||
|
||||
@@ -31,7 +31,7 @@ var (
|
||||
Name: namegen.Generate(),
|
||||
Route: testsutil.GenerateUUID(&testing.T{}),
|
||||
Tags: []string{"tag1", "tag2"},
|
||||
Metadata: map[string]interface{}{"key": "value"},
|
||||
Metadata: map[string]any{"key": "value"},
|
||||
CreatedAt: time.Now().UTC().Truncate(time.Microsecond),
|
||||
Status: channels.EnabledStatus,
|
||||
ConnectionTypes: []connections.ConnType{},
|
||||
@@ -92,7 +92,7 @@ func TestSave(t *testing.T) {
|
||||
ID: invalidID,
|
||||
Domain: testsutil.GenerateUUID(t),
|
||||
Name: namegen.Generate(),
|
||||
Metadata: map[string]interface{}{"key": "value"},
|
||||
Metadata: map[string]any{"key": "value"},
|
||||
CreatedAt: time.Now().UTC().Truncate(time.Microsecond),
|
||||
Status: channels.EnabledStatus,
|
||||
},
|
||||
@@ -105,7 +105,7 @@ func TestSave(t *testing.T) {
|
||||
ID: testsutil.GenerateUUID(t),
|
||||
Domain: invalidID,
|
||||
Name: namegen.Generate(),
|
||||
Metadata: map[string]interface{}{"key": "value"},
|
||||
Metadata: map[string]any{"key": "value"},
|
||||
CreatedAt: time.Now().UTC().Truncate(time.Microsecond),
|
||||
Status: channels.EnabledStatus,
|
||||
},
|
||||
@@ -118,7 +118,7 @@ func TestSave(t *testing.T) {
|
||||
ID: testsutil.GenerateUUID(t),
|
||||
Domain: testsutil.GenerateUUID(t),
|
||||
Name: strings.Repeat("a", 1025),
|
||||
Metadata: map[string]interface{}{"key": "value"},
|
||||
Metadata: map[string]any{"key": "value"},
|
||||
CreatedAt: time.Now().UTC().Truncate(time.Microsecond),
|
||||
Status: channels.EnabledStatus,
|
||||
},
|
||||
@@ -131,7 +131,7 @@ func TestSave(t *testing.T) {
|
||||
ID: testsutil.GenerateUUID(t),
|
||||
Domain: testsutil.GenerateUUID(t),
|
||||
Name: namegen.Generate(),
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"key": make(chan int),
|
||||
},
|
||||
CreatedAt: time.Now().UTC().Truncate(time.Microsecond),
|
||||
@@ -146,7 +146,7 @@ func TestSave(t *testing.T) {
|
||||
ID: duplicateChannelID,
|
||||
Domain: validChannel.Domain,
|
||||
Name: validChannel.Name,
|
||||
Metadata: map[string]interface{}{"key": "different_value"},
|
||||
Metadata: map[string]any{"key": "different_value"},
|
||||
CreatedAt: validTimestamp,
|
||||
Status: channels.EnabledStatus,
|
||||
},
|
||||
@@ -155,7 +155,7 @@ func TestSave(t *testing.T) {
|
||||
ID: duplicateChannelID,
|
||||
Domain: validChannel.Domain,
|
||||
Name: validChannel.Name,
|
||||
Metadata: map[string]interface{}{"key": "different_value"},
|
||||
Metadata: map[string]any{"key": "different_value"},
|
||||
CreatedAt: validTimestamp,
|
||||
Status: channels.EnabledStatus,
|
||||
ConnectionTypes: []connections.ConnType{},
|
||||
@@ -209,7 +209,7 @@ func TestUpdate(t *testing.T) {
|
||||
ID: validChannel.ID,
|
||||
Name: namegen.Generate(),
|
||||
Route: testsutil.GenerateUUID(t),
|
||||
Metadata: map[string]interface{}{"key": "value"},
|
||||
Metadata: map[string]any{"key": "value"},
|
||||
UpdatedAt: validTimestamp,
|
||||
UpdatedBy: testsutil.GenerateUUID(t),
|
||||
},
|
||||
@@ -231,7 +231,7 @@ func TestUpdate(t *testing.T) {
|
||||
update: "metadata",
|
||||
channel: channels.Channel{
|
||||
ID: validChannel.ID,
|
||||
Metadata: map[string]interface{}{"key1": "value1"},
|
||||
Metadata: map[string]any{"key1": "value1"},
|
||||
UpdatedAt: validTimestamp,
|
||||
UpdatedBy: testsutil.GenerateUUID(t),
|
||||
},
|
||||
@@ -243,7 +243,7 @@ func TestUpdate(t *testing.T) {
|
||||
channel: channels.Channel{
|
||||
ID: testsutil.GenerateUUID(t),
|
||||
Name: namegen.Generate(),
|
||||
Metadata: map[string]interface{}{"key": "value"},
|
||||
Metadata: map[string]any{"key": "value"},
|
||||
UpdatedAt: validTimestamp,
|
||||
UpdatedBy: testsutil.GenerateUUID(t),
|
||||
},
|
||||
@@ -254,7 +254,7 @@ func TestUpdate(t *testing.T) {
|
||||
update: "all",
|
||||
channel: channels.Channel{
|
||||
Name: namegen.Generate(),
|
||||
Metadata: map[string]interface{}{"key": "value"},
|
||||
Metadata: map[string]any{"key": "value"},
|
||||
UpdatedAt: validTimestamp,
|
||||
UpdatedBy: testsutil.GenerateUUID(t),
|
||||
},
|
||||
@@ -551,7 +551,7 @@ func TestRetrieveAll(t *testing.T) {
|
||||
ParentGroup: parentID,
|
||||
Name: name,
|
||||
Route: testsutil.GenerateUUID(t),
|
||||
Metadata: map[string]interface{}{"name": name},
|
||||
Metadata: map[string]any{"name": name},
|
||||
CreatedAt: time.Now().UTC().Truncate(time.Microsecond),
|
||||
Status: channels.EnabledStatus,
|
||||
ConnectionTypes: []connections.ConnType{},
|
||||
@@ -772,7 +772,7 @@ func TestRetrieveAll(t *testing.T) {
|
||||
Page: channels.Page{
|
||||
Offset: 0,
|
||||
Limit: 10,
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"key": make(chan int),
|
||||
},
|
||||
},
|
||||
@@ -1489,7 +1489,7 @@ func TestRetrieveParentGroupChannels(t *testing.T) {
|
||||
Domain: testsutil.GenerateUUID(t),
|
||||
ParentGroup: parentID,
|
||||
Name: name,
|
||||
Metadata: map[string]interface{}{"name": name},
|
||||
Metadata: map[string]any{"name": name},
|
||||
CreatedAt: time.Now().UTC().Truncate(time.Microsecond),
|
||||
Status: channels.EnabledStatus,
|
||||
ConnectionTypes: []connections.ConnType{},
|
||||
@@ -1557,7 +1557,7 @@ func TestUnsetParentGroupFromChannels(t *testing.T) {
|
||||
Domain: testsutil.GenerateUUID(t),
|
||||
ParentGroup: parentID,
|
||||
Name: name,
|
||||
Metadata: map[string]interface{}{"name": name},
|
||||
Metadata: map[string]any{"name": name},
|
||||
CreatedAt: time.Now().UTC().Truncate(time.Microsecond),
|
||||
Status: channels.EnabledStatus,
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ var (
|
||||
ID: testsutil.GenerateUUID(&testing.T{}),
|
||||
Name: namegen.Generate(),
|
||||
Route: namegen.Generate(),
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"key": "value",
|
||||
},
|
||||
Tags: []string{"tag1", "tag2"},
|
||||
@@ -50,7 +50,7 @@ var (
|
||||
ID: testsutil.GenerateUUID(&testing.T{}),
|
||||
Name: namegen.Generate(),
|
||||
Route: namegen.Generate(),
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"key": "value",
|
||||
},
|
||||
Tags: []string{"tag1", "tag2"},
|
||||
|
||||
+2
-2
@@ -292,8 +292,8 @@ func TestUpdateClientCmd(t *testing.T) {
|
||||
},
|
||||
client: smqsdk.Client{
|
||||
Name: "clientName",
|
||||
Metadata: map[string]interface{}{
|
||||
"metadata": map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"metadata": map[string]any{
|
||||
"role": "general",
|
||||
},
|
||||
},
|
||||
|
||||
+1
-1
@@ -250,7 +250,7 @@ func setConfigValue(key, value string) error {
|
||||
}
|
||||
}
|
||||
|
||||
configKeyToField := map[string]interface{}{
|
||||
configKeyToField := map[string]any{
|
||||
"clients_url": &config.Remotes.ClientsURL,
|
||||
"users_url": &config.Remotes.UsersURL,
|
||||
"http_adapter_url": &config.Remotes.HTTPAdapterURL,
|
||||
|
||||
+3
-3
@@ -44,7 +44,7 @@ var (
|
||||
LastName string = ""
|
||||
)
|
||||
|
||||
func logJSONCmd(cmd cobra.Command, iList ...interface{}) {
|
||||
func logJSONCmd(cmd cobra.Command, iList ...any) {
|
||||
for _, i := range iList {
|
||||
m, err := json.Marshal(i)
|
||||
if err != nil {
|
||||
@@ -85,8 +85,8 @@ func logRevokedTimeCmd(cmd cobra.Command, t time.Time) {
|
||||
}
|
||||
}
|
||||
|
||||
func convertMetadata(m string) (map[string]interface{}, error) {
|
||||
var metadata map[string]interface{}
|
||||
func convertMetadata(m string) (map[string]any, error) {
|
||||
var metadata map[string]any
|
||||
if m == "" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
+14
-14
@@ -121,14 +121,14 @@ func (client grpcClient) Authenticate(ctx context.Context, req *grpcClientsV1.Au
|
||||
return &grpcClientsV1.AuthnRes{Authenticated: ar.authenticated, Id: ar.id}, nil
|
||||
}
|
||||
|
||||
func encodeAuthenticateRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func encodeAuthenticateRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(authenticateReq)
|
||||
return &grpcClientsV1.AuthnReq{
|
||||
Token: req.Token,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func decodeAuthenticateResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func decodeAuthenticateResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(*grpcClientsV1.AuthnRes)
|
||||
return authenticateRes{authenticated: res.GetAuthenticated(), id: res.GetId()}, nil
|
||||
}
|
||||
@@ -147,14 +147,14 @@ func (client grpcClient) RetrieveEntity(ctx context.Context, req *grpcCommonV1.R
|
||||
return &grpcCommonV1.RetrieveEntityRes{Entity: &grpcCommonV1.EntityBasic{Id: ebr.id, DomainId: ebr.domain, Status: uint32(ebr.status)}}, nil
|
||||
}
|
||||
|
||||
func encodeRetrieveEntityRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func encodeRetrieveEntityRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(string)
|
||||
return &grpcCommonV1.RetrieveEntityReq{
|
||||
Id: req,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func decodeRetrieveEntityResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func decodeRetrieveEntityResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(*grpcCommonV1.RetrieveEntityRes)
|
||||
|
||||
return retrieveEntityRes{
|
||||
@@ -187,14 +187,14 @@ func (client grpcClient) RetrieveEntities(ctx context.Context, req *grpcCommonV1
|
||||
return &grpcCommonV1.RetrieveEntitiesRes{Total: ep.total, Limit: ep.limit, Offset: ep.offset, Entities: entities}, nil
|
||||
}
|
||||
|
||||
func encodeRetrieveEntitiesRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func encodeRetrieveEntitiesRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.([]string)
|
||||
return &grpcCommonV1.RetrieveEntitiesReq{
|
||||
Ids: req,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func decodeRetrieveEntitiesResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func decodeRetrieveEntitiesResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(*grpcCommonV1.RetrieveEntitiesRes)
|
||||
|
||||
clis := []entity{}
|
||||
@@ -234,7 +234,7 @@ func (client grpcClient) AddConnections(ctx context.Context, req *grpcCommonV1.A
|
||||
return &grpcCommonV1.AddConnectionsRes{Ok: cr.ok}, nil
|
||||
}
|
||||
|
||||
func encodeAddConnectionsRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func encodeAddConnectionsRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.([]clients.Connection)
|
||||
|
||||
conns := []*grpcCommonV1.Connection{}
|
||||
@@ -252,7 +252,7 @@ func encodeAddConnectionsRequest(_ context.Context, grpcReq interface{}) (interf
|
||||
}, nil
|
||||
}
|
||||
|
||||
func decodeAddConnectionsResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func decodeAddConnectionsResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(*grpcCommonV1.AddConnectionsRes)
|
||||
|
||||
return connectionsRes{ok: res.GetOk()}, nil
|
||||
@@ -282,7 +282,7 @@ func (client grpcClient) RemoveConnections(ctx context.Context, req *grpcCommonV
|
||||
return &grpcCommonV1.RemoveConnectionsRes{Ok: cr.ok}, nil
|
||||
}
|
||||
|
||||
func encodeRemoveConnectionsRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func encodeRemoveConnectionsRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.([]clients.Connection)
|
||||
|
||||
conns := []*grpcCommonV1.Connection{}
|
||||
@@ -300,7 +300,7 @@ func encodeRemoveConnectionsRequest(_ context.Context, grpcReq interface{}) (int
|
||||
}, nil
|
||||
}
|
||||
|
||||
func decodeRemoveConnectionsResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func decodeRemoveConnectionsResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(*grpcCommonV1.RemoveConnectionsRes)
|
||||
|
||||
return connectionsRes{ok: res.GetOk()}, nil
|
||||
@@ -317,11 +317,11 @@ func (client grpcClient) RemoveChannelConnections(ctx context.Context, req *grpc
|
||||
return &grpcClientsV1.RemoveChannelConnectionsRes{}, nil
|
||||
}
|
||||
|
||||
func encodeRemoveChannelConnectionsRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func encodeRemoveChannelConnectionsRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
return grpcReq.(*grpcClientsV1.RemoveChannelConnectionsReq), nil
|
||||
}
|
||||
|
||||
func decodeRemoveChannelConnectionsResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func decodeRemoveChannelConnectionsResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
return grpcRes.(*grpcClientsV1.RemoveChannelConnectionsRes), nil
|
||||
}
|
||||
|
||||
@@ -336,11 +336,11 @@ func (client grpcClient) UnsetParentGroupFromClient(ctx context.Context, req *gr
|
||||
return &grpcClientsV1.UnsetParentGroupFromClientRes{}, nil
|
||||
}
|
||||
|
||||
func encodeUnsetParentGroupFromClientRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func encodeUnsetParentGroupFromClientRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
return grpcReq.(*grpcClientsV1.UnsetParentGroupFromClientReq), nil
|
||||
}
|
||||
|
||||
func decodeUnsetParentGroupFromClientResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func decodeUnsetParentGroupFromClientResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
return grpcRes.(*grpcClientsV1.UnsetParentGroupFromClientRes), nil
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func authenticateEndpoint(svc pClients.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(authenticateReq)
|
||||
id, err := svc.Authenticate(ctx, req.Token)
|
||||
if err != nil {
|
||||
@@ -26,7 +26,7 @@ func authenticateEndpoint(svc pClients.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func retrieveEntityEndpoint(svc pClients.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(retrieveEntityReq)
|
||||
client, err := svc.RetrieveById(ctx, req.Id)
|
||||
if err != nil {
|
||||
@@ -38,7 +38,7 @@ func retrieveEntityEndpoint(svc pClients.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func retrieveEntitiesEndpoint(svc pClients.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(retrieveEntitiesReq)
|
||||
tp, err := svc.RetrieveByIds(ctx, req.Ids)
|
||||
if err != nil {
|
||||
@@ -58,7 +58,7 @@ func retrieveEntitiesEndpoint(svc pClients.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func addConnectionsEndpoint(svc pClients.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(connectionsReq)
|
||||
|
||||
var conns []clients.Connection
|
||||
@@ -81,7 +81,7 @@ func addConnectionsEndpoint(svc pClients.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func removeConnectionsEndpoint(svc pClients.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(connectionsReq)
|
||||
|
||||
var conns []clients.Connection
|
||||
@@ -103,7 +103,7 @@ func removeConnectionsEndpoint(svc pClients.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func removeChannelConnectionsEndpoint(svc pClients.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(removeChannelConnectionsReq)
|
||||
|
||||
if err := svc.RemoveChannelConnections(ctx, req.channelID); err != nil {
|
||||
@@ -115,7 +115,7 @@ func removeChannelConnectionsEndpoint(svc pClients.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func UnsetParentGroupFromClientEndpoint(svc pClients.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(UnsetParentGroupFromClientReq)
|
||||
|
||||
if err := svc.UnsetParentGroupFromClient(ctx, req.parentGroupID); err != nil {
|
||||
|
||||
+14
-14
@@ -81,14 +81,14 @@ func (s *grpcServer) Authenticate(ctx context.Context, req *grpcClientsV1.AuthnR
|
||||
return res.(*grpcClientsV1.AuthnRes), nil
|
||||
}
|
||||
|
||||
func decodeAuthorizeRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func decodeAuthorizeRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(*grpcClientsV1.AuthnReq)
|
||||
return authenticateReq{
|
||||
Token: req.GetToken(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func encodeAuthorizeResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func encodeAuthorizeResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(authenticateRes)
|
||||
return &grpcClientsV1.AuthnRes{Authenticated: res.authenticated, Id: res.id}, nil
|
||||
}
|
||||
@@ -101,14 +101,14 @@ func (s *grpcServer) RetrieveEntity(ctx context.Context, req *grpcCommonV1.Retri
|
||||
return res.(*grpcCommonV1.RetrieveEntityRes), nil
|
||||
}
|
||||
|
||||
func decodeRetrieveEntityRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func decodeRetrieveEntityRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(*grpcCommonV1.RetrieveEntityReq)
|
||||
return retrieveEntityReq{
|
||||
Id: req.GetId(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func encodeRetrieveEntityResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func encodeRetrieveEntityResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(retrieveEntityRes)
|
||||
|
||||
return &grpcCommonV1.RetrieveEntityRes{
|
||||
@@ -129,14 +129,14 @@ func (s *grpcServer) RetrieveEntities(ctx context.Context, req *grpcCommonV1.Ret
|
||||
return res.(*grpcCommonV1.RetrieveEntitiesRes), nil
|
||||
}
|
||||
|
||||
func decodeRetrieveEntitiesRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func decodeRetrieveEntitiesRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(*grpcCommonV1.RetrieveEntitiesReq)
|
||||
return retrieveEntitiesReq{
|
||||
Ids: req.GetIds(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func encodeRetrieveEntitiesResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func encodeRetrieveEntitiesResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(retrieveEntitiesRes)
|
||||
|
||||
entities := []*grpcCommonV1.EntityBasic{}
|
||||
@@ -159,7 +159,7 @@ func (s *grpcServer) AddConnections(ctx context.Context, req *grpcCommonV1.AddCo
|
||||
return res.(*grpcCommonV1.AddConnectionsRes), nil
|
||||
}
|
||||
|
||||
func decodeAddConnectionsRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func decodeAddConnectionsRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(*grpcCommonV1.AddConnectionsReq)
|
||||
|
||||
conns := []connection{}
|
||||
@@ -180,7 +180,7 @@ func decodeAddConnectionsRequest(_ context.Context, grpcReq interface{}) (interf
|
||||
}, nil
|
||||
}
|
||||
|
||||
func encodeAddConnectionsResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func encodeAddConnectionsResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(connectionsRes)
|
||||
|
||||
return &grpcCommonV1.AddConnectionsRes{Ok: res.ok}, nil
|
||||
@@ -194,7 +194,7 @@ func (s *grpcServer) RemoveConnections(ctx context.Context, req *grpcCommonV1.Re
|
||||
return res.(*grpcCommonV1.RemoveConnectionsRes), nil
|
||||
}
|
||||
|
||||
func decodeRemoveConnectionsRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func decodeRemoveConnectionsRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(*grpcCommonV1.RemoveConnectionsReq)
|
||||
|
||||
conns := []connection{}
|
||||
@@ -215,7 +215,7 @@ func decodeRemoveConnectionsRequest(_ context.Context, grpcReq interface{}) (int
|
||||
}, nil
|
||||
}
|
||||
|
||||
func encodeRemoveConnectionsResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func encodeRemoveConnectionsResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(connectionsRes)
|
||||
|
||||
return &grpcCommonV1.RemoveConnectionsRes{Ok: res.ok}, nil
|
||||
@@ -229,7 +229,7 @@ func (s *grpcServer) RemoveChannelConnections(ctx context.Context, req *grpcClie
|
||||
return res.(*grpcClientsV1.RemoveChannelConnectionsRes), nil
|
||||
}
|
||||
|
||||
func decodeRemoveChannelConnectionsRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func decodeRemoveChannelConnectionsRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(*grpcClientsV1.RemoveChannelConnectionsReq)
|
||||
|
||||
return removeChannelConnectionsReq{
|
||||
@@ -237,7 +237,7 @@ func decodeRemoveChannelConnectionsRequest(_ context.Context, grpcReq interface{
|
||||
}, nil
|
||||
}
|
||||
|
||||
func encodeRemoveChannelConnectionsResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func encodeRemoveChannelConnectionsResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
_ = grpcRes.(removeChannelConnectionsRes)
|
||||
return &grpcClientsV1.RemoveChannelConnectionsRes{}, nil
|
||||
}
|
||||
@@ -250,7 +250,7 @@ func (s *grpcServer) UnsetParentGroupFromClient(ctx context.Context, req *grpcCl
|
||||
return res.(*grpcClientsV1.UnsetParentGroupFromClientRes), nil
|
||||
}
|
||||
|
||||
func decodeUnsetParentGroupFromClientRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func decodeUnsetParentGroupFromClientRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(*grpcClientsV1.UnsetParentGroupFromClientReq)
|
||||
|
||||
return UnsetParentGroupFromClientReq{
|
||||
@@ -258,7 +258,7 @@ func decodeUnsetParentGroupFromClientRequest(_ context.Context, grpcReq interfac
|
||||
}, nil
|
||||
}
|
||||
|
||||
func encodeUnsetParentGroupFromClientResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func encodeUnsetParentGroupFromClientResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
_ = grpcRes.(UnsetParentGroupFromClientRes)
|
||||
return &grpcClientsV1.UnsetParentGroupFromClientRes{}, nil
|
||||
}
|
||||
|
||||
+11
-11
@@ -18,7 +18,7 @@ import (
|
||||
|
||||
const clientID = "clientID"
|
||||
|
||||
func decodeViewClient(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeViewClient(_ context.Context, r *http.Request) (any, error) {
|
||||
roles, err := apiutil.ReadBoolQuery(r, api.RolesKey, false)
|
||||
if err != nil {
|
||||
return listClientsReq{}, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -32,7 +32,7 @@ func decodeViewClient(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeListClients(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeListClients(_ context.Context, r *http.Request) (any, error) {
|
||||
name, err := apiutil.ReadStringQuery(r, api.NameKey, "")
|
||||
if err != nil {
|
||||
return listClientsReq{}, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -161,7 +161,7 @@ func decodeListClients(_ context.Context, r *http.Request) (interface{}, error)
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeUpdateClient(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeUpdateClient(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -176,7 +176,7 @@ func decodeUpdateClient(_ context.Context, r *http.Request) (interface{}, error)
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeUpdateClientTags(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeUpdateClientTags(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -191,7 +191,7 @@ func decodeUpdateClientTags(_ context.Context, r *http.Request) (interface{}, er
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeUpdateClientCredentials(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeUpdateClientCredentials(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -206,7 +206,7 @@ func decodeUpdateClientCredentials(_ context.Context, r *http.Request) (interfac
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeCreateClientReq(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeCreateClientReq(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -222,7 +222,7 @@ func decodeCreateClientReq(_ context.Context, r *http.Request) (interface{}, err
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeCreateClientsReq(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeCreateClientsReq(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -235,7 +235,7 @@ func decodeCreateClientsReq(_ context.Context, r *http.Request) (interface{}, er
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func decodeChangeClientStatus(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeChangeClientStatus(_ context.Context, r *http.Request) (any, error) {
|
||||
req := changeClientStatusReq{
|
||||
id: chi.URLParam(r, clientID),
|
||||
}
|
||||
@@ -243,7 +243,7 @@ func decodeChangeClientStatus(_ context.Context, r *http.Request) (interface{},
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeSetClientParentGroupStatus(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeSetClientParentGroupStatus(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -257,7 +257,7 @@ func decodeSetClientParentGroupStatus(_ context.Context, r *http.Request) (inter
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeRemoveClientParentGroupStatus(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeRemoveClientParentGroupStatus(_ context.Context, r *http.Request) (any, error) {
|
||||
req := removeClientParentGroupReq{
|
||||
id: chi.URLParam(r, clientID),
|
||||
}
|
||||
@@ -265,7 +265,7 @@ func decodeRemoveClientParentGroupStatus(_ context.Context, r *http.Request) (in
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeDeleteClientReq(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeDeleteClientReq(_ context.Context, r *http.Request) (any, error) {
|
||||
req := deleteClientReq{
|
||||
id: chi.URLParam(r, clientID),
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
func createClientEndpoint(svc clients.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(createClientReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -40,7 +40,7 @@ func createClientEndpoint(svc clients.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func createClientsEndpoint(svc clients.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(createClientsReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -71,7 +71,7 @@ func createClientsEndpoint(svc clients.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func viewClientEndpoint(svc clients.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(viewClientReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -92,7 +92,7 @@ func viewClientEndpoint(svc clients.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func listClientsEndpoint(svc clients.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(listClientsReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -132,7 +132,7 @@ func listClientsEndpoint(svc clients.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func updateClientEndpoint(svc clients.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(updateClientReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -158,7 +158,7 @@ func updateClientEndpoint(svc clients.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func updateClientTagsEndpoint(svc clients.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(updateClientTagsReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -183,7 +183,7 @@ func updateClientTagsEndpoint(svc clients.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func updateClientSecretEndpoint(svc clients.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(updateClientCredentialsReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -204,7 +204,7 @@ func updateClientSecretEndpoint(svc clients.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func enableClientEndpoint(svc clients.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(changeClientStatusReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -225,7 +225,7 @@ func enableClientEndpoint(svc clients.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func disableClientEndpoint(svc clients.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(changeClientStatusReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -246,7 +246,7 @@ func disableClientEndpoint(svc clients.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func setClientParentGroupEndpoint(svc clients.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(setClientParentGroupReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -265,7 +265,7 @@ func setClientParentGroupEndpoint(svc clients.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func removeClientParentGroupEndpoint(svc clients.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(removeClientParentGroupReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -284,7 +284,7 @@ func removeClientParentGroupEndpoint(svc clients.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func deleteClientEndpoint(svc clients.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(deleteClientReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
|
||||
@@ -81,7 +81,7 @@ func (tr testRequest) make() (*http.Response, error) {
|
||||
return tr.client.Do(req)
|
||||
}
|
||||
|
||||
func toJSON(data interface{}) string {
|
||||
func toJSON(data any) string {
|
||||
jsonData, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return ""
|
||||
@@ -169,7 +169,7 @@ func TestCreateClient(t *testing.T) {
|
||||
Identity: "user@example.com",
|
||||
Secret: "12345678",
|
||||
},
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"test": make(chan int),
|
||||
},
|
||||
},
|
||||
@@ -361,7 +361,7 @@ func TestCreateClients(t *testing.T) {
|
||||
Identity: "user@example.com",
|
||||
Secret: "12345678",
|
||||
},
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"test": make(chan int),
|
||||
},
|
||||
},
|
||||
|
||||
@@ -113,9 +113,9 @@ func (req listMembersReq) validate() error {
|
||||
|
||||
type updateClientReq struct {
|
||||
id string
|
||||
Name string `json:"name,omitempty"`
|
||||
Metadata map[string]interface{} `json:"metadata,omitempty"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Metadata map[string]any `json:"metadata,omitempty"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
func (req updateClientReq) validate() error {
|
||||
|
||||
+1
-1
@@ -221,7 +221,7 @@ type Page struct {
|
||||
}
|
||||
|
||||
// Metadata represents arbitrary JSON.
|
||||
type Metadata map[string]interface{}
|
||||
type Metadata map[string]any
|
||||
|
||||
// Credentials represent client credentials: its
|
||||
// "identity" which can be a username, email, generated name;
|
||||
|
||||
+28
-28
@@ -53,8 +53,8 @@ type createClientEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (cce createClientEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (cce createClientEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": clientCreate,
|
||||
"id": cce.ID,
|
||||
"roles_provisioned": cce.rolesProvisioned,
|
||||
@@ -90,8 +90,8 @@ type updateClientEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (uce updateClientEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (uce updateClientEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": uce.operation,
|
||||
"updated_at": uce.UpdatedAt,
|
||||
"updated_by": uce.UpdatedBy,
|
||||
@@ -136,8 +136,8 @@ type changeClientStatusEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (cse changeClientStatusEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (cse changeClientStatusEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": cse.operation,
|
||||
"id": cse.id,
|
||||
"status": cse.status,
|
||||
@@ -157,8 +157,8 @@ type viewClientEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (vce viewClientEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (vce viewClientEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": clientView,
|
||||
"id": vce.ID,
|
||||
"domain": vce.DomainID,
|
||||
@@ -202,8 +202,8 @@ type viewClientPermsEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (vcpe viewClientPermsEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (vcpe viewClientPermsEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": clientViewPerms,
|
||||
"permissions": vcpe.permissions,
|
||||
"domain": vcpe.DomainID,
|
||||
@@ -221,8 +221,8 @@ type listClientEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (lce listClientEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (lce listClientEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": clientList,
|
||||
"total": lce.Total,
|
||||
"offset": lce.Offset,
|
||||
@@ -268,8 +268,8 @@ type listUserClientEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (lce listUserClientEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (lce listUserClientEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": clientList,
|
||||
"req_user_id": lce.userID,
|
||||
"total": lce.Total,
|
||||
@@ -317,8 +317,8 @@ type listClientByGroupEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (lcge listClientByGroupEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (lcge listClientByGroupEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": clientListByGroup,
|
||||
"total": lcge.Total,
|
||||
"offset": lcge.Offset,
|
||||
@@ -362,8 +362,8 @@ type identifyClientEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (ice identifyClientEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (ice identifyClientEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": clientIdentify,
|
||||
"id": ice.clientID,
|
||||
"domain": ice.DomainID,
|
||||
@@ -382,8 +382,8 @@ type authorizeClientEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (ice authorizeClientEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (ice authorizeClientEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": clientAuthorize,
|
||||
"id": ice.clientID,
|
||||
"domain": ice.DomainID,
|
||||
@@ -412,8 +412,8 @@ type shareClientEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (sce shareClientEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (sce shareClientEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": clientPrefix + sce.action,
|
||||
"id": sce.id,
|
||||
"relation": sce.relation,
|
||||
@@ -432,8 +432,8 @@ type removeClientEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (dce removeClientEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (dce removeClientEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": clientRemove,
|
||||
"id": dce.id,
|
||||
"domain": dce.DomainID,
|
||||
@@ -451,8 +451,8 @@ type setParentGroupEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (spge setParentGroupEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (spge setParentGroupEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": clientSetParent,
|
||||
"id": spge.id,
|
||||
"parent_group_id": spge.parentGroupID,
|
||||
@@ -470,8 +470,8 @@ type removeParentGroupEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (rpge removeParentGroupEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (rpge removeParentGroupEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": clientRemoveParent,
|
||||
"id": rpge.id,
|
||||
"domain": rpge.DomainID,
|
||||
|
||||
@@ -564,7 +564,7 @@ func (am *authorizationMiddleware) checkSuperAdmin(ctx context.Context, userID s
|
||||
return nil
|
||||
}
|
||||
|
||||
func (am *authorizationMiddleware) callOut(ctx context.Context, session authn.Session, op string, params map[string]interface{}) error {
|
||||
func (am *authorizationMiddleware) callOut(ctx context.Context, session authn.Session, op string, params map[string]any) error {
|
||||
pl := map[string]any{
|
||||
"entity_type": policies.ClientType,
|
||||
"subject_type": policies.UserType,
|
||||
|
||||
@@ -359,7 +359,7 @@ func (repo *clientRepo) RetrieveByIDWithRoles(ctx context.Context, id, memberID
|
||||
FROM clients c2
|
||||
JOIN final_roles fr ON fr.client_id = c2.id
|
||||
`
|
||||
parameters := map[string]interface{}{
|
||||
parameters := map[string]any{
|
||||
"id": id,
|
||||
"member_id": memberID,
|
||||
}
|
||||
@@ -1009,7 +1009,7 @@ func (repo *clientRepo) update(ctx context.Context, client clients.Client, query
|
||||
func (repo *clientRepo) Delete(ctx context.Context, clientIDs ...string) error {
|
||||
q := "DELETE FROM clients AS c WHERE c.id = ANY(:client_ids) ;"
|
||||
|
||||
params := map[string]interface{}{
|
||||
params := map[string]any{
|
||||
"client_ids": clientIDs,
|
||||
}
|
||||
result, err := repo.DB.NamedExecContext(ctx, q, params)
|
||||
|
||||
@@ -40,7 +40,7 @@ var (
|
||||
ID: testsutil.GenerateUUID(&testing.T{}),
|
||||
Domain: testsutil.GenerateUUID(&testing.T{}),
|
||||
Name: namegen.Generate(),
|
||||
Metadata: map[string]interface{}{"key": "value"},
|
||||
Metadata: map[string]any{"key": "value"},
|
||||
CreatedAt: time.Now().UTC().Truncate(time.Microsecond),
|
||||
Status: clients.EnabledStatus,
|
||||
}
|
||||
@@ -311,7 +311,7 @@ func TestClientsSave(t *testing.T) {
|
||||
Identity: fmt.Sprintf("%s@example.com", namegen.Generate()),
|
||||
Secret: testsutil.GenerateUUID(t),
|
||||
},
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"key": make(chan int),
|
||||
},
|
||||
},
|
||||
@@ -325,7 +325,7 @@ func TestClientsSave(t *testing.T) {
|
||||
ID: duplicateClientID,
|
||||
Domain: validClient.Domain,
|
||||
Name: validClient.Name,
|
||||
Metadata: map[string]interface{}{"key": "different_value"},
|
||||
Metadata: map[string]any{"key": "different_value"},
|
||||
CreatedAt: validTimestamp,
|
||||
Status: clients.EnabledStatus,
|
||||
},
|
||||
@@ -519,7 +519,7 @@ func TestUpdate(t *testing.T) {
|
||||
client: clients.Client{
|
||||
ID: validClient.ID,
|
||||
Name: namegen.Generate(),
|
||||
Metadata: map[string]interface{}{"key": "value"},
|
||||
Metadata: map[string]any{"key": "value"},
|
||||
UpdatedAt: validTimestamp,
|
||||
UpdatedBy: testsutil.GenerateUUID(t),
|
||||
},
|
||||
@@ -541,7 +541,7 @@ func TestUpdate(t *testing.T) {
|
||||
update: "metadata",
|
||||
client: clients.Client{
|
||||
ID: validClient.ID,
|
||||
Metadata: map[string]interface{}{"key1": "value1"},
|
||||
Metadata: map[string]any{"key1": "value1"},
|
||||
UpdatedAt: validTimestamp,
|
||||
UpdatedBy: testsutil.GenerateUUID(t),
|
||||
},
|
||||
@@ -553,7 +553,7 @@ func TestUpdate(t *testing.T) {
|
||||
client: clients.Client{
|
||||
ID: testsutil.GenerateUUID(t),
|
||||
Name: namegen.Generate(),
|
||||
Metadata: map[string]interface{}{"key": "value"},
|
||||
Metadata: map[string]any{"key": "value"},
|
||||
UpdatedAt: validTimestamp,
|
||||
UpdatedBy: testsutil.GenerateUUID(t),
|
||||
},
|
||||
@@ -564,7 +564,7 @@ func TestUpdate(t *testing.T) {
|
||||
update: "all",
|
||||
client: clients.Client{
|
||||
Name: namegen.Generate(),
|
||||
Metadata: map[string]interface{}{"key": "value"},
|
||||
Metadata: map[string]any{"key": "value"},
|
||||
UpdatedAt: validTimestamp,
|
||||
UpdatedBy: testsutil.GenerateUUID(t),
|
||||
},
|
||||
@@ -1734,7 +1734,7 @@ func TestRetrieveByIDs(t *testing.T) {
|
||||
Secret: testsutil.GenerateUUID(t),
|
||||
},
|
||||
Tags: namegen.GenerateMultiple(5),
|
||||
Metadata: map[string]interface{}{"name": name},
|
||||
Metadata: map[string]any{"name": name},
|
||||
CreatedAt: time.Now().UTC().Truncate(time.Microsecond),
|
||||
Status: clients.EnabledStatus,
|
||||
}
|
||||
@@ -2364,7 +2364,7 @@ func TestRetrieveParentGroupClients(t *testing.T) {
|
||||
Domain: testsutil.GenerateUUID(t),
|
||||
ParentGroup: parentID,
|
||||
Name: name,
|
||||
Metadata: map[string]interface{}{"name": name},
|
||||
Metadata: map[string]any{"name": name},
|
||||
CreatedAt: time.Now().UTC().Truncate(time.Microsecond),
|
||||
Status: clients.EnabledStatus,
|
||||
}
|
||||
@@ -2431,7 +2431,7 @@ func TestUnsetParentGroupFromClients(t *testing.T) {
|
||||
Domain: testsutil.GenerateUUID(t),
|
||||
ParentGroup: parentID,
|
||||
Name: name,
|
||||
Metadata: map[string]interface{}{"name": name},
|
||||
Metadata: map[string]any{"name": name},
|
||||
CreatedAt: time.Now().UTC().Truncate(time.Microsecond),
|
||||
Status: clients.EnabledStatus,
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import "context"
|
||||
// to broker, sending notifications, or any other asynchronous job.
|
||||
type AsyncConsumer interface {
|
||||
// ConsumeAsync method is used to asynchronously consume received messages.
|
||||
ConsumeAsync(ctx context.Context, messages interface{})
|
||||
ConsumeAsync(ctx context.Context, messages any)
|
||||
|
||||
// Errors method returns a channel for reading errors which occur during async writes.
|
||||
// Must be called before performing any writes for errors to be collected.
|
||||
@@ -26,5 +26,5 @@ type AsyncConsumer interface {
|
||||
type BlockingConsumer interface {
|
||||
// ConsumeBlocking method is used to consume received messages synchronously.
|
||||
// A non-nil error is returned to indicate operation failure.
|
||||
ConsumeBlocking(ctx context.Context, messages interface{}) error
|
||||
ConsumeBlocking(ctx context.Context, messages any) error
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ var (
|
||||
// Start method starts consuming messages received from Message broker.
|
||||
// This method transforms messages to SenML format before
|
||||
// using MessageRepository to store them.
|
||||
func Start(ctx context.Context, id string, sub messaging.Subscriber, consumer interface{}, configPath string, logger *slog.Logger) error {
|
||||
func Start(ctx context.Context, id string, sub messaging.Subscriber, consumer any, configPath string, logger *slog.Logger) error {
|
||||
cfg, err := loadConfig(configPath)
|
||||
if err != nil {
|
||||
logger.Warn(fmt.Sprintf("Failed to load consumer config: %s", err))
|
||||
@@ -67,7 +67,7 @@ func Start(ctx context.Context, id string, sub messaging.Subscriber, consumer in
|
||||
|
||||
func handleSync(ctx context.Context, t transformers.Transformer, sc BlockingConsumer) handleFunc {
|
||||
return func(msg *messaging.Message) error {
|
||||
m := interface{}(msg)
|
||||
m := any(msg)
|
||||
var err error
|
||||
if t != nil {
|
||||
m, err = t.Transform(msg)
|
||||
@@ -81,7 +81,7 @@ func handleSync(ctx context.Context, t transformers.Transformer, sc BlockingCons
|
||||
|
||||
func handleAsync(ctx context.Context, t transformers.Transformer, ac AsyncConsumer) handleFunc {
|
||||
return func(msg *messaging.Message) error {
|
||||
m := interface{}(msg)
|
||||
m := any(msg)
|
||||
var err error
|
||||
if t != nil {
|
||||
m, err = t.Transform(msg)
|
||||
|
||||
@@ -72,12 +72,12 @@ func (client domainsGrpcClient) DeleteUserFromDomains(ctx context.Context, in *g
|
||||
return &grpcDomainsV1.DeleteUserRes{Deleted: dpr.deleted}, nil
|
||||
}
|
||||
|
||||
func decodeDeleteUserResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func decodeDeleteUserResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(*grpcDomainsV1.DeleteUserRes)
|
||||
return deleteUserRes{deleted: res.GetDeleted()}, nil
|
||||
}
|
||||
|
||||
func encodeDeleteUserRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func encodeDeleteUserRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(deleteUserPoliciesReq)
|
||||
return &grpcDomainsV1.DeleteUserReq{
|
||||
Id: req.ID,
|
||||
@@ -103,12 +103,12 @@ func (client domainsGrpcClient) RetrieveStatus(ctx context.Context, in *grpcComm
|
||||
}, nil
|
||||
}
|
||||
|
||||
func decodeRetrieveStatusResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func decodeRetrieveStatusResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(*grpcCommonV1.RetrieveEntityRes)
|
||||
return retrieveStatusRes{status: uint8(res.Entity.GetStatus())}, nil
|
||||
}
|
||||
|
||||
func encodeRetrieveStatusRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func encodeRetrieveStatusRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(retrieveStatusReq)
|
||||
return &grpcCommonV1.RetrieveEntityReq{
|
||||
Id: req.ID,
|
||||
@@ -134,12 +134,12 @@ func (client domainsGrpcClient) RetrieveIDByRoute(ctx context.Context, in *grpcC
|
||||
}, nil
|
||||
}
|
||||
|
||||
func decodeRetrieveIDByRouteResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func decodeRetrieveIDByRouteResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(*grpcCommonV1.RetrieveEntityRes)
|
||||
return retrieveIDByRouteRes{id: res.Entity.GetId()}, nil
|
||||
}
|
||||
|
||||
func encodeRetrieveIDByRouteRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func encodeRetrieveIDByRouteRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(retrieveIDByRouteReq)
|
||||
return &grpcCommonV1.RetrieveIDByRouteReq{
|
||||
Route: req.Route,
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func deleteUserFromDomainsEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(deleteUserPoliciesReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return deleteUserRes{}, err
|
||||
@@ -26,7 +26,7 @@ func deleteUserFromDomainsEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func retrieveStatusEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(retrieveStatusReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return retrieveStatusRes{}, err
|
||||
@@ -44,7 +44,7 @@ func retrieveStatusEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func retrieveIDByRouteEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(retrieveIDByRouteReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return retrieveIDByRouteRes{}, err
|
||||
|
||||
@@ -42,14 +42,14 @@ func NewDomainsServer(svc domains.Service) grpcDomainsV1.DomainsServiceServer {
|
||||
}
|
||||
}
|
||||
|
||||
func decodeDeleteUserRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func decodeDeleteUserRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(*grpcDomainsV1.DeleteUserReq)
|
||||
return deleteUserPoliciesReq{
|
||||
ID: req.GetId(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func encodeDeleteUserResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func encodeDeleteUserResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(deleteUserRes)
|
||||
return &grpcDomainsV1.DeleteUserRes{Deleted: res.deleted}, nil
|
||||
}
|
||||
@@ -62,7 +62,7 @@ func (s *domainsGrpcServer) DeleteUserFromDomains(ctx context.Context, req *grpc
|
||||
return res.(*grpcDomainsV1.DeleteUserRes), nil
|
||||
}
|
||||
|
||||
func decodeRetrieveStatusRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func decodeRetrieveStatusRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(*grpcCommonV1.RetrieveEntityReq)
|
||||
|
||||
return retrieveStatusReq{
|
||||
@@ -70,7 +70,7 @@ func decodeRetrieveStatusRequest(_ context.Context, grpcReq interface{}) (interf
|
||||
}, nil
|
||||
}
|
||||
|
||||
func encodeRetrieveStatusResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func encodeRetrieveStatusResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(retrieveStatusRes)
|
||||
|
||||
return &grpcCommonV1.RetrieveEntityRes{
|
||||
@@ -89,7 +89,7 @@ func (s *domainsGrpcServer) RetrieveStatus(ctx context.Context, req *grpcCommonV
|
||||
return res.(*grpcCommonV1.RetrieveEntityRes), nil
|
||||
}
|
||||
|
||||
func decodeRetrieveIDByRouteRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func decodeRetrieveIDByRouteRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(*grpcCommonV1.RetrieveIDByRouteReq)
|
||||
|
||||
return retrieveIDByRouteReq{
|
||||
@@ -97,7 +97,7 @@ func decodeRetrieveIDByRouteRequest(_ context.Context, grpcReq interface{}) (int
|
||||
}, nil
|
||||
}
|
||||
|
||||
func encodeRetrieveIDByRouteResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func encodeRetrieveIDByRouteResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(retrieveIDByRouteRes)
|
||||
|
||||
return &grpcCommonV1.RetrieveEntityRes{
|
||||
|
||||
+11
-11
@@ -25,7 +25,7 @@ const (
|
||||
stateKey = "state"
|
||||
)
|
||||
|
||||
func decodeCreateDomainRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeCreateDomainRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -37,7 +37,7 @@ func decodeCreateDomainRequest(_ context.Context, r *http.Request) (interface{},
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeRetrieveDomainRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeRetrieveDomainRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
roles, err := apiutil.ReadBoolQuery(r, api.RolesKey, false)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -49,7 +49,7 @@ func decodeRetrieveDomainRequest(_ context.Context, r *http.Request) (interface{
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeUpdateDomainRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeUpdateDomainRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -65,7 +65,7 @@ func decodeUpdateDomainRequest(_ context.Context, r *http.Request) (interface{},
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeListDomainRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeListDomainRequest(ctx context.Context, r *http.Request) (any, error) {
|
||||
page, err := decodePageRequest(ctx, r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -77,21 +77,21 @@ func decodeListDomainRequest(ctx context.Context, r *http.Request) (interface{},
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeEnableDomainRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeEnableDomainRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
req := enableDomainReq{
|
||||
domainID: chi.URLParam(r, "domainID"),
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeDisableDomainRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeDisableDomainRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
req := disableDomainReq{
|
||||
domainID: chi.URLParam(r, "domainID"),
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeFreezeDomainRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeFreezeDomainRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
req := freezeDomainReq{
|
||||
domainID: chi.URLParam(r, "domainID"),
|
||||
}
|
||||
@@ -184,7 +184,7 @@ func decodePageRequest(_ context.Context, r *http.Request) (domains.Page, error)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func decodeSendInvitationReq(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeSendInvitationReq(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -197,7 +197,7 @@ func decodeSendInvitationReq(_ context.Context, r *http.Request) (interface{}, e
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeListInvitationsReq(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeListInvitationsReq(_ context.Context, r *http.Request) (any, error) {
|
||||
offset, err := apiutil.ReadNumQuery[uint64](r, api.OffsetKey, api.DefOffset)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -250,7 +250,7 @@ func decodeListInvitationsReq(_ context.Context, r *http.Request) (interface{},
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeAcceptInvitationReq(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeAcceptInvitationReq(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -263,7 +263,7 @@ func decodeAcceptInvitationReq(_ context.Context, r *http.Request) (interface{},
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeDeleteInvitationReq(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeDeleteInvitationReq(_ context.Context, r *http.Request) (any, error) {
|
||||
req := deleteInvitationReq{
|
||||
userID: chi.URLParam(r, "userID"),
|
||||
domainID: chi.URLParam(r, "domainID"),
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
const InvitationSent = "invitation sent"
|
||||
|
||||
func createDomainEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(createDomainReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, err
|
||||
@@ -47,7 +47,7 @@ func createDomainEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func retrieveDomainEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(retrieveDomainRequest)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, err
|
||||
@@ -67,7 +67,7 @@ func retrieveDomainEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func updateDomainEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(updateDomainReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, err
|
||||
@@ -97,7 +97,7 @@ func updateDomainEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func listDomainsEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(listDomainsReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -117,7 +117,7 @@ func listDomainsEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func enableDomainEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(enableDomainReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, err
|
||||
@@ -136,7 +136,7 @@ func enableDomainEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func disableDomainEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(disableDomainReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, err
|
||||
@@ -155,7 +155,7 @@ func disableDomainEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func freezeDomainEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(freezeDomainReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, err
|
||||
@@ -174,7 +174,7 @@ func freezeDomainEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func sendInvitationEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(sendInvitationReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -202,7 +202,7 @@ func sendInvitationEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func listDomainInvitationsEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(listInvitationsReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -225,7 +225,7 @@ func listDomainInvitationsEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func listUserInvitationsEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(listInvitationsReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -248,7 +248,7 @@ func listUserInvitationsEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func acceptInvitationEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(acceptInvitationReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -268,7 +268,7 @@ func acceptInvitationEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func rejectInvitationEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(acceptInvitationReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -288,7 +288,7 @@ func rejectInvitationEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func deleteInvitationEndpoint(svc domains.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(deleteInvitationReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
|
||||
@@ -84,7 +84,7 @@ func (tr testRequest) make() (*http.Response, error) {
|
||||
return tr.client.Do(req)
|
||||
}
|
||||
|
||||
func toJSON(data interface{}) string {
|
||||
func toJSON(data any) string {
|
||||
jsonData, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return ""
|
||||
@@ -200,7 +200,7 @@ func TestCreateDomain(t *testing.T) {
|
||||
desc: "register a new domain that cant be marshalled",
|
||||
domain: domains.Domain{
|
||||
Name: "test",
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"test": make(chan int),
|
||||
},
|
||||
Tags: []string{"tag1", "tag2"},
|
||||
|
||||
@@ -12,11 +12,11 @@ import (
|
||||
const maxLimitSize = 100
|
||||
|
||||
type createDomainReq struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Metadata map[string]interface{} `json:"metadata,omitempty"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
Route string `json:"route"`
|
||||
ID string `json:"id,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Metadata map[string]any `json:"metadata,omitempty"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
Route string `json:"route"`
|
||||
}
|
||||
|
||||
func (req createDomainReq) validate() error {
|
||||
@@ -51,9 +51,9 @@ func (req retrieveDomainRequest) validate() error {
|
||||
|
||||
type updateDomainReq struct {
|
||||
domainID string
|
||||
Name *string `json:"name,omitempty"`
|
||||
Metadata *map[string]interface{} `json:"metadata,omitempty"`
|
||||
Tags *[]string `json:"tags,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
Metadata *map[string]any `json:"metadata,omitempty"`
|
||||
Tags *[]string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
func (req updateDomainReq) validate() error {
|
||||
|
||||
+1
-1
@@ -94,7 +94,7 @@ func (s *Status) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
// Metadata represents arbitrary JSON.
|
||||
type Metadata map[string]interface{}
|
||||
type Metadata map[string]any
|
||||
|
||||
type DomainReq struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
|
||||
+28
-28
@@ -54,8 +54,8 @@ type createDomainEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (cde createDomainEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (cde createDomainEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": domainCreate,
|
||||
"id": cde.ID,
|
||||
"route": cde.Route,
|
||||
@@ -88,8 +88,8 @@ type retrieveDomainEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (rde retrieveDomainEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (rde retrieveDomainEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": domainRetrieve,
|
||||
"id": rde.ID,
|
||||
"route": rde.Route,
|
||||
@@ -127,8 +127,8 @@ type retrieveDomainStatusEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (rdse retrieveDomainStatusEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (rdse retrieveDomainStatusEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": domainRetrieve,
|
||||
"id": rdse.id,
|
||||
"status": rdse.status.String(),
|
||||
@@ -147,8 +147,8 @@ type updateDomainEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (ude updateDomainEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (ude updateDomainEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": domainUpdate,
|
||||
"id": ude.domain.ID,
|
||||
"route": ude.domain.Route,
|
||||
@@ -184,8 +184,8 @@ type enableDomainEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (cdse enableDomainEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (cdse enableDomainEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": domainEnable,
|
||||
"id": cdse.domainID,
|
||||
"updated_at": cdse.updatedAt,
|
||||
@@ -205,8 +205,8 @@ type disableDomainEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (cdse disableDomainEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (cdse disableDomainEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": domainDisable,
|
||||
"id": cdse.domainID,
|
||||
"updated_at": cdse.updatedAt,
|
||||
@@ -226,8 +226,8 @@ type freezeDomainEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (cdse freezeDomainEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (cdse freezeDomainEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": domainFreeze,
|
||||
"id": cdse.domainID,
|
||||
"updated_at": cdse.updatedAt,
|
||||
@@ -248,8 +248,8 @@ type listDomainsEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (lde listDomainsEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (lde listDomainsEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": domainList,
|
||||
"total": lde.total,
|
||||
"offset": lde.Offset,
|
||||
@@ -308,8 +308,8 @@ type sendInvitationEvent struct {
|
||||
session authn.Session
|
||||
}
|
||||
|
||||
func (sie sendInvitationEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (sie sendInvitationEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": invitationSend,
|
||||
"invitee_user_id": sie.invitation.InviteeUserID,
|
||||
"domain_id": sie.invitation.DomainID,
|
||||
@@ -327,8 +327,8 @@ type listInvitationsEvent struct {
|
||||
session authn.Session
|
||||
}
|
||||
|
||||
func (lie listInvitationsEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (lie listInvitationsEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": invitationList,
|
||||
"offset": lie.Offset,
|
||||
"limit": lie.Limit,
|
||||
@@ -360,8 +360,8 @@ type listDomainInvitationsEvent struct {
|
||||
session authn.Session
|
||||
}
|
||||
|
||||
func (lie listDomainInvitationsEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (lie listDomainInvitationsEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": invitationListDomain,
|
||||
"offset": lie.Offset,
|
||||
"limit": lie.Limit,
|
||||
@@ -391,8 +391,8 @@ type acceptInvitationEvent struct {
|
||||
session authn.Session
|
||||
}
|
||||
|
||||
func (aie acceptInvitationEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (aie acceptInvitationEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": invitationAccept,
|
||||
"domain_id": aie.domainID,
|
||||
"invitee_user_id": aie.session.UserID,
|
||||
@@ -408,8 +408,8 @@ type rejectInvitationEvent struct {
|
||||
session authn.Session
|
||||
}
|
||||
|
||||
func (rie rejectInvitationEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (rie rejectInvitationEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": invitationReject,
|
||||
"domain_id": rie.domainID,
|
||||
"invitee_user_id": rie.session.UserID,
|
||||
@@ -426,8 +426,8 @@ type deleteInvitationEvent struct {
|
||||
session authn.Session
|
||||
}
|
||||
|
||||
func (die deleteInvitationEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (die deleteInvitationEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": invitationDelete,
|
||||
"invitee_user_id": die.inviteeUserID,
|
||||
"domain_id": die.domainID,
|
||||
|
||||
@@ -342,7 +342,7 @@ func (am *authorizationMiddleware) extAuthorize(ctx context.Context, subj, perm,
|
||||
return nil
|
||||
}
|
||||
|
||||
func (am *authorizationMiddleware) callOut(ctx context.Context, session authn.Session, op string, params map[string]interface{}) error {
|
||||
func (am *authorizationMiddleware) callOut(ctx context.Context, session authn.Session, op string, params map[string]any) error {
|
||||
pl := map[string]any{
|
||||
"entity_type": policies.DomainType,
|
||||
"subject_type": policies.UserType,
|
||||
|
||||
@@ -45,7 +45,7 @@ func TestSaveDomain(t *testing.T) {
|
||||
Name: "test",
|
||||
Route: "test",
|
||||
Tags: []string{"test"},
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"test": "test",
|
||||
},
|
||||
CreatedAt: time.Now().UTC().Truncate(time.Millisecond),
|
||||
@@ -63,7 +63,7 @@ func TestSaveDomain(t *testing.T) {
|
||||
Name: "test",
|
||||
Route: "test",
|
||||
Tags: []string{"test"},
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"test": "test",
|
||||
},
|
||||
CreatedAt: time.Now().UTC().Truncate(time.Millisecond),
|
||||
@@ -81,7 +81,7 @@ func TestSaveDomain(t *testing.T) {
|
||||
Name: "test1",
|
||||
Route: "test1",
|
||||
Tags: []string{"test"},
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"test": "test",
|
||||
},
|
||||
CreatedAt: time.Now().UTC().Truncate(time.Millisecond),
|
||||
@@ -99,7 +99,7 @@ func TestSaveDomain(t *testing.T) {
|
||||
Name: "test1",
|
||||
Route: "",
|
||||
Tags: []string{"test"},
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"test": "test",
|
||||
},
|
||||
CreatedAt: time.Now(),
|
||||
@@ -117,7 +117,7 @@ func TestSaveDomain(t *testing.T) {
|
||||
Name: "test1",
|
||||
Route: "test1",
|
||||
Tags: []string{"test"},
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"key": make(chan int),
|
||||
},
|
||||
CreatedAt: time.Now(),
|
||||
@@ -154,7 +154,7 @@ func TestRetrieveByID(t *testing.T) {
|
||||
Name: "test",
|
||||
Route: "test",
|
||||
Tags: []string{"test"},
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"test": "test",
|
||||
},
|
||||
CreatedBy: userID,
|
||||
@@ -216,7 +216,7 @@ func TestRetrieveByRoute(t *testing.T) {
|
||||
Name: "test",
|
||||
Route: validRoute,
|
||||
Tags: []string{"test"},
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"test": "test",
|
||||
},
|
||||
CreatedBy: userID,
|
||||
@@ -279,7 +279,7 @@ func TestRetrieveAllByIDs(t *testing.T) {
|
||||
Name: fmt.Sprintf(`"test%d"`, i),
|
||||
Route: fmt.Sprintf(`"test%d"`, i),
|
||||
Tags: []string{"test"},
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"test": "test",
|
||||
},
|
||||
CreatedBy: userID,
|
||||
@@ -289,7 +289,7 @@ func TestRetrieveAllByIDs(t *testing.T) {
|
||||
if i%5 == 0 {
|
||||
domain.Status = domains.DisabledStatus
|
||||
domain.Tags = []string{"test", "admin"}
|
||||
domain.Metadata = map[string]interface{}{
|
||||
domain.Metadata = map[string]any{
|
||||
"test1": "test1",
|
||||
}
|
||||
}
|
||||
@@ -398,7 +398,7 @@ func TestRetrieveAllByIDs(t *testing.T) {
|
||||
Offset: 0,
|
||||
Limit: 10,
|
||||
IDs: []string{items[1].ID, items[2].ID},
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"test": "test",
|
||||
},
|
||||
Status: domains.EnabledStatus,
|
||||
@@ -416,7 +416,7 @@ func TestRetrieveAllByIDs(t *testing.T) {
|
||||
Offset: 0,
|
||||
Limit: 10,
|
||||
IDs: []string{items[1].ID, items[2].ID},
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"test1": "test1",
|
||||
},
|
||||
Status: domains.EnabledStatus,
|
||||
@@ -433,7 +433,7 @@ func TestRetrieveAllByIDs(t *testing.T) {
|
||||
Offset: 0,
|
||||
Limit: 10,
|
||||
IDs: []string{items[1].ID, items[2].ID},
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"key": make(chan int),
|
||||
},
|
||||
Status: domains.EnabledStatus,
|
||||
@@ -521,7 +521,7 @@ func TestUpdate(t *testing.T) {
|
||||
Name: "test",
|
||||
Route: "test",
|
||||
Tags: []string{"test"},
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"test": "test",
|
||||
},
|
||||
CreatedBy: userID,
|
||||
@@ -551,7 +551,7 @@ func TestUpdate(t *testing.T) {
|
||||
Name: "test1",
|
||||
Route: "test",
|
||||
Tags: []string{"test"},
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"test1": "test1",
|
||||
},
|
||||
CreatedBy: userID,
|
||||
@@ -575,7 +575,7 @@ func TestUpdate(t *testing.T) {
|
||||
Name: "test1",
|
||||
Route: "test",
|
||||
Tags: []string{"test1"},
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"test1": "test1",
|
||||
},
|
||||
CreatedBy: userID,
|
||||
@@ -640,7 +640,7 @@ func TestDelete(t *testing.T) {
|
||||
Name: "test",
|
||||
Route: "test",
|
||||
Tags: []string{"test"},
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"test": "test",
|
||||
},
|
||||
CreatedBy: userID,
|
||||
@@ -696,7 +696,7 @@ func TestListDomains(t *testing.T) {
|
||||
Name: fmt.Sprintf(`"test%d"`, i),
|
||||
Route: fmt.Sprintf(`"test%d"`, i),
|
||||
Tags: []string{"test"},
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"test": "test",
|
||||
},
|
||||
CreatedBy: userID,
|
||||
@@ -706,7 +706,7 @@ func TestListDomains(t *testing.T) {
|
||||
if i%5 == 0 {
|
||||
domain.Status = domains.DisabledStatus
|
||||
domain.Tags = []string{"test", "admin"}
|
||||
domain.Metadata = map[string]interface{}{
|
||||
domain.Metadata = map[string]any{
|
||||
"test1": "test1",
|
||||
}
|
||||
}
|
||||
@@ -818,7 +818,7 @@ func TestListDomains(t *testing.T) {
|
||||
pm: domains.Page{
|
||||
Offset: 0,
|
||||
Limit: 10,
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"test1": "test1",
|
||||
},
|
||||
Status: domains.AllStatus,
|
||||
@@ -836,7 +836,7 @@ func TestListDomains(t *testing.T) {
|
||||
pm: domains.Page{
|
||||
Offset: 0,
|
||||
Limit: 10,
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"key": make(chan int),
|
||||
},
|
||||
Status: domains.AllStatus,
|
||||
|
||||
@@ -825,7 +825,7 @@ func saveDomain(t *testing.T, repo domains.Repository) domains.Domain {
|
||||
Name: "test",
|
||||
Route: "test",
|
||||
Tags: []string{"test"},
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"test": "test",
|
||||
},
|
||||
CreatedBy: userID,
|
||||
|
||||
@@ -57,11 +57,11 @@ func (client grpcClient) RetrieveEntity(ctx context.Context, req *grpcCommonV1.R
|
||||
return typedRes, nil
|
||||
}
|
||||
|
||||
func encodeRetrieveEntityRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func encodeRetrieveEntityRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
return grpcReq, nil
|
||||
}
|
||||
|
||||
func decodeRetrieveEntityResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func decodeRetrieveEntityResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
return grpcRes, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func retrieveEntityEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(retrieveEntityReq)
|
||||
group, err := svc.RetrieveById(ctx, req.Id)
|
||||
if err != nil {
|
||||
|
||||
@@ -44,14 +44,14 @@ func (s *grpcServer) RetrieveEntity(ctx context.Context, req *grpcCommonV1.Retri
|
||||
return res.(*grpcCommonV1.RetrieveEntityRes), nil
|
||||
}
|
||||
|
||||
func decodeRetrieveEntityRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
func decodeRetrieveEntityRequest(_ context.Context, grpcReq any) (any, error) {
|
||||
req := grpcReq.(*grpcCommonV1.RetrieveEntityReq)
|
||||
return retrieveEntityReq{
|
||||
Id: req.GetId(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func encodeRetrieveEntityResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
func encodeRetrieveEntityResponse(_ context.Context, grpcRes any) (any, error) {
|
||||
res := grpcRes.(retrieveEntityRes)
|
||||
|
||||
return &grpcCommonV1.RetrieveEntityRes{
|
||||
|
||||
+13
-13
@@ -16,7 +16,7 @@ import (
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
func DecodeGroupCreate(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func DecodeGroupCreate(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -31,7 +31,7 @@ func DecodeGroupCreate(_ context.Context, r *http.Request) (interface{}, error)
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func DecodeListGroupsRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func DecodeListGroupsRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
pm, err := decodePageMeta(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -55,7 +55,7 @@ func DecodeListGroupsRequest(_ context.Context, r *http.Request) (interface{}, e
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func DecodeGroupUpdate(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func DecodeGroupUpdate(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -68,7 +68,7 @@ func DecodeGroupUpdate(_ context.Context, r *http.Request) (interface{}, error)
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeUpdateGroupTags(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeUpdateGroupTags(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -83,7 +83,7 @@ func decodeUpdateGroupTags(_ context.Context, r *http.Request) (interface{}, err
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func DecodeGroupRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func DecodeGroupRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
roles, err := apiutil.ReadBoolQuery(r, api.RolesKey, false)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -97,14 +97,14 @@ func DecodeGroupRequest(_ context.Context, r *http.Request) (interface{}, error)
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func DecodeChangeGroupStatusRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func DecodeChangeGroupStatusRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
req := changeGroupStatusReq{
|
||||
id: chi.URLParam(r, "groupID"),
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeRetrieveGroupHierarchy(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeRetrieveGroupHierarchy(_ context.Context, r *http.Request) (any, error) {
|
||||
hm, err := decodeHierarchyPageMeta(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -117,7 +117,7 @@ func decodeRetrieveGroupHierarchy(_ context.Context, r *http.Request) (interface
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeAddParentGroupRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeAddParentGroupRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -131,14 +131,14 @@ func decodeAddParentGroupRequest(_ context.Context, r *http.Request) (interface{
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeRemoveParentGroupRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeRemoveParentGroupRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
req := removeParentGroupReq{
|
||||
id: chi.URLParam(r, "groupID"),
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeAddChildrenGroupsRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeAddChildrenGroupsRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -151,7 +151,7 @@ func decodeAddChildrenGroupsRequest(_ context.Context, r *http.Request) (interfa
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeRemoveChildrenGroupsRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeRemoveChildrenGroupsRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), api.ContentType) {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
}
|
||||
@@ -164,14 +164,14 @@ func decodeRemoveChildrenGroupsRequest(_ context.Context, r *http.Request) (inte
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeRemoveAllChildrenGroupsRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeRemoveAllChildrenGroupsRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
req := removeAllChildrenGroupsReq{
|
||||
id: chi.URLParam(r, "groupID"),
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeListChildrenGroupsRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeListChildrenGroupsRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
pm, err := decodePageMeta(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -23,7 +23,7 @@ func TestDecodeListGroupsRequest(t *testing.T) {
|
||||
desc string
|
||||
url string
|
||||
header map[string][]string
|
||||
resp interface{}
|
||||
resp any
|
||||
err error
|
||||
}{
|
||||
{
|
||||
@@ -89,7 +89,7 @@ func TestDecodeRetrieveGroupHierarchy(t *testing.T) {
|
||||
desc string
|
||||
url string
|
||||
header map[string][]string
|
||||
resp interface{}
|
||||
resp any
|
||||
err error
|
||||
}{
|
||||
{
|
||||
@@ -157,7 +157,7 @@ func TestDecodeListChildrenRequest(t *testing.T) {
|
||||
desc string
|
||||
url string
|
||||
header map[string][]string
|
||||
resp interface{}
|
||||
resp any
|
||||
err error
|
||||
}{
|
||||
{
|
||||
@@ -311,7 +311,7 @@ func TestDecodeGroupCreate(t *testing.T) {
|
||||
desc string
|
||||
body string
|
||||
header map[string][]string
|
||||
resp interface{}
|
||||
resp any
|
||||
err error
|
||||
}{
|
||||
{
|
||||
@@ -366,7 +366,7 @@ func TestDecodeGroupUpdate(t *testing.T) {
|
||||
desc string
|
||||
body string
|
||||
header map[string][]string
|
||||
resp interface{}
|
||||
resp any
|
||||
err error
|
||||
}{
|
||||
{
|
||||
@@ -418,7 +418,7 @@ func TestDecodeGroupRequest(t *testing.T) {
|
||||
cases := []struct {
|
||||
desc string
|
||||
header map[string][]string
|
||||
resp interface{}
|
||||
resp any
|
||||
err error
|
||||
}{
|
||||
{
|
||||
@@ -450,7 +450,7 @@ func TestDecodeChangeGroupStatus(t *testing.T) {
|
||||
cases := []struct {
|
||||
desc string
|
||||
header map[string][]string
|
||||
resp interface{}
|
||||
resp any
|
||||
err error
|
||||
}{
|
||||
{
|
||||
|
||||
@@ -72,7 +72,7 @@ func TestCreateGroupEndpoint(t *testing.T) {
|
||||
reqGroup := groups.Group{
|
||||
Name: valid,
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"name": "test",
|
||||
},
|
||||
}
|
||||
@@ -144,7 +144,7 @@ func TestCreateGroupEndpoint(t *testing.T) {
|
||||
req: createGroupReq{
|
||||
Group: groups.Group{
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"name": "test",
|
||||
},
|
||||
},
|
||||
@@ -161,7 +161,7 @@ func TestCreateGroupEndpoint(t *testing.T) {
|
||||
Group: groups.Group{
|
||||
Name: strings.Repeat("a", 1025),
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"name": "test",
|
||||
},
|
||||
},
|
||||
@@ -339,7 +339,7 @@ func TestUpdateGroupEndpoint(t *testing.T) {
|
||||
ID: validID,
|
||||
Name: valid,
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"name": "test",
|
||||
},
|
||||
}
|
||||
@@ -411,7 +411,7 @@ func TestUpdateGroupEndpoint(t *testing.T) {
|
||||
ID: validID,
|
||||
Name: strings.Repeat("a", 1025),
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"name": "test",
|
||||
},
|
||||
},
|
||||
@@ -2193,7 +2193,7 @@ func (tr testRequest) make() (*http.Response, error) {
|
||||
return tr.client.Do(req)
|
||||
}
|
||||
|
||||
func toJSON(data interface{}) string {
|
||||
func toJSON(data any) string {
|
||||
jsonData, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return ""
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
func CreateGroupEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(createGroupReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return createGroupRes{created: false}, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -37,7 +37,7 @@ func CreateGroupEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func ViewGroupEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(groupReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return viewGroupRes{}, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -58,7 +58,7 @@ func ViewGroupEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func UpdateGroupEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(updateGroupReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return updateGroupRes{}, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -86,7 +86,7 @@ func UpdateGroupEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func updateGroupTagsEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(updateGroupTagsReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -111,7 +111,7 @@ func updateGroupTagsEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func EnableGroupEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(changeGroupStatusReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return changeStatusRes{}, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -131,7 +131,7 @@ func EnableGroupEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func DisableGroupEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(changeGroupStatusReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return changeStatusRes{}, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -151,7 +151,7 @@ func DisableGroupEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func ListGroupsEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(listGroupsReq)
|
||||
|
||||
if err := req.validate(); err != nil {
|
||||
@@ -192,7 +192,7 @@ func ListGroupsEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func DeleteGroupEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(groupReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return deleteGroupRes{}, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -210,7 +210,7 @@ func DeleteGroupEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func retrieveGroupHierarchyEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(retrieveGroupHierarchyReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return retrieveGroupHierarchyRes{}, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -238,7 +238,7 @@ func retrieveGroupHierarchyEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func addParentGroupEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(addParentGroupReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return addParentGroupRes{}, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -257,7 +257,7 @@ func addParentGroupEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func removeParentGroupEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(removeParentGroupReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return removeParentGroupRes{}, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -276,7 +276,7 @@ func removeParentGroupEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func addChildrenGroupsEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(addChildrenGroupsReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return addChildrenGroupsRes{}, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -295,7 +295,7 @@ func addChildrenGroupsEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func removeChildrenGroupsEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(removeChildrenGroupsReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return removeChildrenGroupsRes{}, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -314,7 +314,7 @@ func removeChildrenGroupsEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func removeAllChildrenGroupsEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(removeAllChildrenGroupsReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return removeAllChildrenGroupsRes{}, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -333,7 +333,7 @@ func removeAllChildrenGroupsEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func listChildrenGroupsEndpoint(svc groups.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(listChildrenGroupsReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return listChildrenGroupsRes{}, errors.Wrap(apiutil.ErrValidation, err)
|
||||
|
||||
@@ -26,7 +26,7 @@ type updateGroupReq struct {
|
||||
id string
|
||||
Name string `json:"name,omitempty"`
|
||||
Description nullable.Value[string] `json:"description,omitempty"`
|
||||
Metadata map[string]interface{} `json:"metadata,omitempty"`
|
||||
Metadata map[string]any `json:"metadata,omitempty"`
|
||||
}
|
||||
|
||||
func (req updateGroupReq) validate() error {
|
||||
|
||||
+30
-30
@@ -58,8 +58,8 @@ type createGroupEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (cge createGroupEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (cge createGroupEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": groupCreate,
|
||||
"id": cge.ID,
|
||||
"roles_provisioned": cge.rolesProvisioned,
|
||||
@@ -98,8 +98,8 @@ type updateGroupEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (uge updateGroupEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (uge updateGroupEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": uge.operation,
|
||||
"updated_at": uge.UpdatedAt,
|
||||
"updated_by": uge.UpdatedBy,
|
||||
@@ -146,8 +146,8 @@ type changeGroupStatusEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (rge changeGroupStatusEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (rge changeGroupStatusEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": rge.operation,
|
||||
"id": rge.id,
|
||||
"status": rge.status,
|
||||
@@ -167,8 +167,8 @@ type viewGroupEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (vge viewGroupEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (vge viewGroupEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": groupView,
|
||||
"id": vge.ID,
|
||||
"domain": vge.DomainID,
|
||||
@@ -215,8 +215,8 @@ type listGroupEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (lge listGroupEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (lge listGroupEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": groupList,
|
||||
"total": lge.Total,
|
||||
"offset": lge.Offset,
|
||||
@@ -253,8 +253,8 @@ type listUserGroupEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (luge listUserGroupEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (luge listUserGroupEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": groupListUserGroups,
|
||||
"user_id": luge.userID,
|
||||
"domain": luge.domainID,
|
||||
@@ -288,8 +288,8 @@ type deleteGroupEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (rge deleteGroupEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (rge deleteGroupEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": groupRemove,
|
||||
"id": rge.id,
|
||||
"domain": rge.DomainID,
|
||||
@@ -307,8 +307,8 @@ type retrieveGroupHierarchyEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (vcge retrieveGroupHierarchyEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (vcge retrieveGroupHierarchyEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": groupRetrieveGroupHierarchy,
|
||||
"id": vcge.id,
|
||||
"level": vcge.Level,
|
||||
@@ -330,8 +330,8 @@ type addParentGroupEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (apge addParentGroupEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (apge addParentGroupEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": groupAddParentGroup,
|
||||
"id": apge.id,
|
||||
"parent_id": apge.parentID,
|
||||
@@ -349,8 +349,8 @@ type removeParentGroupEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (rpge removeParentGroupEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (rpge removeParentGroupEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": groupRemoveParentGroup,
|
||||
"id": rpge.id,
|
||||
"domain": rpge.DomainID,
|
||||
@@ -367,8 +367,8 @@ type viewParentGroupEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (vpge viewParentGroupEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (vpge viewParentGroupEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": groupViewParentGroup,
|
||||
"id": vpge.id,
|
||||
"domain": vpge.domainID,
|
||||
@@ -383,8 +383,8 @@ type addChildrenGroupsEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (acge addChildrenGroupsEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (acge addChildrenGroupsEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": groupAddChildrenGroups,
|
||||
"id": acge.id,
|
||||
"children_ids": acge.childrenIDs,
|
||||
@@ -403,8 +403,8 @@ type removeChildrenGroupsEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (rcge removeChildrenGroupsEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (rcge removeChildrenGroupsEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": groupRemoveChildrenGroups,
|
||||
"id": rcge.id,
|
||||
"children_ids": rcge.childrenIDs,
|
||||
@@ -422,8 +422,8 @@ type removeAllChildrenGroupsEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (racge removeAllChildrenGroupsEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (racge removeAllChildrenGroupsEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": groupRemoveAllChildrenGroups,
|
||||
"id": racge.id,
|
||||
"domain": racge.DomainID,
|
||||
@@ -446,8 +446,8 @@ type listChildrenGroupsEvent struct {
|
||||
requestID string
|
||||
}
|
||||
|
||||
func (vcge listChildrenGroupsEvent) Encode() (map[string]interface{}, error) {
|
||||
val := map[string]interface{}{
|
||||
func (vcge listChildrenGroupsEvent) Encode() (map[string]any, error) {
|
||||
val := map[string]any{
|
||||
"operation": groupListChildrenGroups,
|
||||
"id": vcge.id,
|
||||
"start_level": vcge.startLevel,
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ const (
|
||||
)
|
||||
|
||||
// Metadata represents arbitrary JSON.
|
||||
type Metadata map[string]interface{}
|
||||
type Metadata map[string]any
|
||||
|
||||
// Group represents the group of Clients.
|
||||
// Indicates a level in tree hierarchy. Root node is level 1.
|
||||
|
||||
@@ -723,7 +723,7 @@ func (am *authorizationMiddleware) extAuthorize(ctx context.Context, extOp svcut
|
||||
return nil
|
||||
}
|
||||
|
||||
func (am *authorizationMiddleware) callOut(ctx context.Context, session authn.Session, op string, params map[string]interface{}) error {
|
||||
func (am *authorizationMiddleware) callOut(ctx context.Context, session authn.Session, op string, params map[string]any) error {
|
||||
pl := map[string]any{
|
||||
"entity_type": policies.GroupType,
|
||||
"subject_type": policies.UserType,
|
||||
|
||||
@@ -335,7 +335,7 @@ func (repo groupRepository) RetrieveByIDWithRoles(ctx context.Context, id, membe
|
||||
JOIN final_roles fr ON fr.group_id = g.id
|
||||
`
|
||||
|
||||
parameters := map[string]interface{}{
|
||||
parameters := map[string]any{
|
||||
"id": id,
|
||||
"member_id": memberID,
|
||||
}
|
||||
@@ -549,7 +549,7 @@ func (repo groupRepository) RetrieveHierarchy(ctx context.Context, domainID, use
|
||||
ORDER BY path;
|
||||
`, baseQuery, dirQuery)
|
||||
|
||||
parameters := map[string]interface{}{
|
||||
parameters := map[string]any{
|
||||
"id": groupID,
|
||||
"level": hm.Level,
|
||||
}
|
||||
@@ -624,7 +624,7 @@ func (repo groupRepository) AssignParentGroup(ctx context.Context, parentGroupID
|
||||
WHERE id = ANY(:children_group_ids)
|
||||
RETURNING id, path;`
|
||||
|
||||
params := map[string]interface{}{
|
||||
params := map[string]any{
|
||||
"parent_id": pGroup.ID,
|
||||
"children_group_ids": groupIDs,
|
||||
}
|
||||
@@ -705,7 +705,7 @@ func (repo groupRepository) UnassignParentGroup(ctx context.Context, parentGroup
|
||||
WHERE id = ANY(:children_group_ids) AND parent_id = :parent_id
|
||||
RETURNING id, path;`
|
||||
|
||||
parameters := map[string]interface{}{
|
||||
parameters := map[string]any{
|
||||
"parent_id": pGroup.ID,
|
||||
"children_group_ids": groupIDs,
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ var (
|
||||
Name: namegen.Generate(),
|
||||
Tags: []string{"tag1", "tag2"},
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{"key": "value"},
|
||||
Metadata: map[string]any{"key": "value"},
|
||||
CreatedAt: time.Now().UTC().Truncate(time.Microsecond),
|
||||
Status: groups.EnabledStatus,
|
||||
}
|
||||
@@ -121,7 +121,7 @@ func TestSave(t *testing.T) {
|
||||
Domain: testsutil.GenerateUUID(t),
|
||||
Name: namegen.Generate(),
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{"key": "value"},
|
||||
Metadata: map[string]any{"key": "value"},
|
||||
CreatedAt: validTimestamp,
|
||||
Status: groups.EnabledStatus,
|
||||
},
|
||||
@@ -134,7 +134,7 @@ func TestSave(t *testing.T) {
|
||||
Domain: invalidID,
|
||||
Name: namegen.Generate(),
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{"key": "value"},
|
||||
Metadata: map[string]any{"key": "value"},
|
||||
CreatedAt: validTimestamp,
|
||||
Status: groups.EnabledStatus,
|
||||
},
|
||||
@@ -147,7 +147,7 @@ func TestSave(t *testing.T) {
|
||||
Parent: testsutil.GenerateUUID(t),
|
||||
Name: namegen.Generate(),
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{"key": "value"},
|
||||
Metadata: map[string]any{"key": "value"},
|
||||
CreatedAt: validTimestamp,
|
||||
Status: groups.EnabledStatus,
|
||||
},
|
||||
@@ -160,7 +160,7 @@ func TestSave(t *testing.T) {
|
||||
Domain: testsutil.GenerateUUID(t),
|
||||
Name: strings.Repeat("a", 1025),
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{"key": "value"},
|
||||
Metadata: map[string]any{"key": "value"},
|
||||
CreatedAt: validTimestamp,
|
||||
Status: groups.EnabledStatus,
|
||||
},
|
||||
@@ -173,7 +173,7 @@ func TestSave(t *testing.T) {
|
||||
Domain: testsutil.GenerateUUID(t),
|
||||
Name: namegen.Generate(),
|
||||
Description: invalidDesc,
|
||||
Metadata: map[string]interface{}{"key": "value"},
|
||||
Metadata: map[string]any{"key": "value"},
|
||||
CreatedAt: validTimestamp,
|
||||
Status: groups.EnabledStatus,
|
||||
},
|
||||
@@ -186,7 +186,7 @@ func TestSave(t *testing.T) {
|
||||
Domain: testsutil.GenerateUUID(t),
|
||||
Name: namegen.Generate(),
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"key": make(chan int),
|
||||
},
|
||||
CreatedAt: validTimestamp,
|
||||
@@ -201,7 +201,7 @@ func TestSave(t *testing.T) {
|
||||
Name: namegen.Generate(),
|
||||
Domain: invalidID,
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{"key": "value"},
|
||||
Metadata: map[string]any{"key": "value"},
|
||||
CreatedAt: validTimestamp,
|
||||
Status: groups.EnabledStatus,
|
||||
},
|
||||
@@ -214,7 +214,7 @@ func TestSave(t *testing.T) {
|
||||
Domain: validGroup.Domain,
|
||||
Name: validGroup.Name,
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{"key": "different_value"},
|
||||
Metadata: map[string]any{"key": "different_value"},
|
||||
CreatedAt: validTimestamp,
|
||||
Status: groups.EnabledStatus,
|
||||
Path: duplicateGroupID,
|
||||
@@ -225,7 +225,7 @@ func TestSave(t *testing.T) {
|
||||
Domain: validGroup.Domain,
|
||||
Name: validGroup.Name,
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{"key": "different_value"},
|
||||
Metadata: map[string]any{"key": "different_value"},
|
||||
CreatedAt: validTimestamp,
|
||||
Status: groups.EnabledStatus,
|
||||
Path: duplicateGroupID,
|
||||
@@ -268,7 +268,7 @@ func TestUpdate(t *testing.T) {
|
||||
ID: group.ID,
|
||||
Name: namegen.Generate(),
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{"key": "value"},
|
||||
Metadata: map[string]any{"key": "value"},
|
||||
UpdatedAt: validTimestamp,
|
||||
UpdatedBy: testsutil.GenerateUUID(t),
|
||||
},
|
||||
@@ -301,7 +301,7 @@ func TestUpdate(t *testing.T) {
|
||||
update: "metadata",
|
||||
group: groups.Group{
|
||||
ID: group.ID,
|
||||
Metadata: map[string]interface{}{"key1": "value1"},
|
||||
Metadata: map[string]any{"key1": "value1"},
|
||||
UpdatedAt: validTimestamp,
|
||||
UpdatedBy: testsutil.GenerateUUID(t),
|
||||
},
|
||||
@@ -314,7 +314,7 @@ func TestUpdate(t *testing.T) {
|
||||
ID: testsutil.GenerateUUID(t),
|
||||
Name: namegen.Generate(),
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{"key": "value"},
|
||||
Metadata: map[string]any{"key": "value"},
|
||||
UpdatedAt: validTimestamp,
|
||||
UpdatedBy: testsutil.GenerateUUID(t),
|
||||
},
|
||||
@@ -326,7 +326,7 @@ func TestUpdate(t *testing.T) {
|
||||
group: groups.Group{
|
||||
Name: namegen.Generate(),
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{"key": "value"},
|
||||
Metadata: map[string]any{"key": "value"},
|
||||
UpdatedAt: validTimestamp,
|
||||
UpdatedBy: testsutil.GenerateUUID(t),
|
||||
},
|
||||
@@ -554,7 +554,7 @@ func TestRetrieveByIDAndUser(t *testing.T) {
|
||||
Domain: domainID,
|
||||
Name: name,
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{"name": name},
|
||||
Metadata: map[string]any{"name": name},
|
||||
CreatedAt: validTimestamp,
|
||||
Status: groups.EnabledStatus,
|
||||
}
|
||||
@@ -683,7 +683,7 @@ func TestRetrieveAll(t *testing.T) {
|
||||
Parent: parentID,
|
||||
Name: name,
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{"name": name},
|
||||
Metadata: map[string]any{"name": name},
|
||||
CreatedAt: time.Now().UTC().Truncate(time.Microsecond),
|
||||
Status: groups.EnabledStatus,
|
||||
}
|
||||
@@ -916,7 +916,7 @@ func TestRetrieveAll(t *testing.T) {
|
||||
PageMeta: groups.PageMeta{
|
||||
Offset: 0,
|
||||
Limit: 10,
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"key": make(chan int),
|
||||
},
|
||||
},
|
||||
@@ -1008,7 +1008,7 @@ func TestRetrieveByIDs(t *testing.T) {
|
||||
Parent: parentID,
|
||||
Name: name,
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{"name": name},
|
||||
Metadata: map[string]any{"name": name},
|
||||
CreatedAt: time.Now().UTC().Truncate(time.Microsecond),
|
||||
Status: groups.EnabledStatus,
|
||||
}
|
||||
@@ -1226,7 +1226,7 @@ func TestRetrieveByIDs(t *testing.T) {
|
||||
PageMeta: groups.PageMeta{
|
||||
Offset: 0,
|
||||
Limit: 10,
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"key": make(chan int),
|
||||
},
|
||||
},
|
||||
@@ -1319,7 +1319,7 @@ func TestAssignParentGroup(t *testing.T) {
|
||||
Domain: testsutil.GenerateUUID(t),
|
||||
Name: name,
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{"name": name},
|
||||
Metadata: map[string]any{"name": name},
|
||||
CreatedAt: validTimestamp,
|
||||
Status: groups.EnabledStatus,
|
||||
}
|
||||
@@ -1394,7 +1394,7 @@ func TestUnassignParentGroup(t *testing.T) {
|
||||
Parent: parentID,
|
||||
Name: name,
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{"name": name},
|
||||
Metadata: map[string]any{"name": name},
|
||||
CreatedAt: time.Now().UTC().Truncate(time.Microsecond),
|
||||
Status: groups.EnabledStatus,
|
||||
}
|
||||
@@ -1472,7 +1472,7 @@ func TestUnassignAllChildrenGroups(t *testing.T) {
|
||||
Parent: parentID,
|
||||
Name: name,
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{"name": name},
|
||||
Metadata: map[string]any{"name": name},
|
||||
CreatedAt: time.Now().UTC().Truncate(time.Microsecond),
|
||||
Status: groups.EnabledStatus,
|
||||
}
|
||||
@@ -1536,7 +1536,7 @@ func TestRetrieveHierarchy(t *testing.T) {
|
||||
Parent: parentID,
|
||||
Name: name,
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{"name": name},
|
||||
Metadata: map[string]any{"name": name},
|
||||
CreatedAt: time.Now().UTC().Truncate(time.Microsecond),
|
||||
Status: groups.EnabledStatus,
|
||||
}
|
||||
@@ -1703,7 +1703,7 @@ func TestRetrieveAllParentGroups(t *testing.T) {
|
||||
Name: name,
|
||||
Parent: parentID,
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{"name": name},
|
||||
Metadata: map[string]any{"name": name},
|
||||
CreatedAt: validTimestamp,
|
||||
Status: groups.EnabledStatus,
|
||||
}
|
||||
@@ -1880,7 +1880,7 @@ func TestRetrieveChildrenGroups(t *testing.T) {
|
||||
Name: name,
|
||||
Parent: parentID,
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{"name": name},
|
||||
Metadata: map[string]any{"name": name},
|
||||
CreatedAt: validTimestamp,
|
||||
Status: groups.EnabledStatus,
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ var (
|
||||
ID: testsutil.GenerateUUID(&testing.T{}),
|
||||
Name: namegen.Generate(),
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"key": "value",
|
||||
},
|
||||
Status: groups.EnabledStatus,
|
||||
@@ -50,7 +50,7 @@ var (
|
||||
ID: testsutil.GenerateUUID(&testing.T{}),
|
||||
Name: namegen.Generate(),
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"key": "value",
|
||||
},
|
||||
Status: groups.EnabledStatus,
|
||||
@@ -68,7 +68,7 @@ var (
|
||||
ID: childGroupID,
|
||||
Name: namegen.Generate(),
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"key": "value",
|
||||
},
|
||||
Status: groups.EnabledStatus,
|
||||
@@ -79,7 +79,7 @@ var (
|
||||
ID: parentGroupID,
|
||||
Name: namegen.Generate(),
|
||||
Description: desc,
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"key": "value",
|
||||
},
|
||||
Status: groups.EnabledStatus,
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func sendMessageEndpoint() endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(publishReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
|
||||
@@ -53,7 +53,7 @@ func MakeHandler(logger *slog.Logger, instanceID string) http.Handler {
|
||||
return r
|
||||
}
|
||||
|
||||
func decodeRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeRequest(_ context.Context, r *http.Request) (any, error) {
|
||||
ct := r.Header.Get("Content-Type")
|
||||
if ct != ctSenmlJSON && ct != contentType && ct != ctSenmlCBOR {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, apiutil.ErrUnsupportedContentType)
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
func retrieveJournalsEndpoint(svc journal.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(retrieveJournalsReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -39,7 +39,7 @@ func retrieveJournalsEndpoint(svc journal.Service) endpoint.Endpoint {
|
||||
}
|
||||
|
||||
func retrieveClientTelemetryEndpoint(svc journal.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
return func(ctx context.Context, request any) (any, error) {
|
||||
req := request.(retrieveClientTelemetryReq)
|
||||
if err := req.validate(); err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
|
||||
@@ -74,7 +74,7 @@ func MakeHandler(svc journal.Service, authn smqauthn.Authentication, logger *slo
|
||||
return mux
|
||||
}
|
||||
|
||||
func decodeRetrieveEntityJournalReq(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeRetrieveEntityJournalReq(_ context.Context, r *http.Request) (any, error) {
|
||||
page, err := decodePageQuery(r)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -94,7 +94,7 @@ func decodeRetrieveEntityJournalReq(_ context.Context, r *http.Request) (interfa
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeRetrieveUserJournalReq(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeRetrieveUserJournalReq(_ context.Context, r *http.Request) (any, error) {
|
||||
page, err := decodePageQuery(r)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(apiutil.ErrValidation, err)
|
||||
@@ -170,7 +170,7 @@ func decodePageQuery(r *http.Request) (journal.Page, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func decodeRetrieveClientTelemetryReq(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeRetrieveClientTelemetryReq(_ context.Context, r *http.Request) (any, error) {
|
||||
req := retrieveClientTelemetryReq{
|
||||
clientID: chi.URLParam(r, "clientID"),
|
||||
}
|
||||
|
||||
@@ -64,9 +64,9 @@ func Handle(service journal.Service) handleFunc {
|
||||
return nil
|
||||
}
|
||||
|
||||
metadata, ok := data["metadata"].(map[string]interface{})
|
||||
metadata, ok := data["metadata"].(map[string]any)
|
||||
if !ok {
|
||||
metadata = make(map[string]interface{})
|
||||
metadata = make(map[string]any)
|
||||
}
|
||||
delete(data, "metadata")
|
||||
|
||||
|
||||
@@ -24,10 +24,10 @@ import (
|
||||
|
||||
var (
|
||||
operation = "users.create"
|
||||
payload = map[string]interface{}{
|
||||
payload = map[string]any{
|
||||
"temperature": rand.Float64(),
|
||||
"humidity": float64(rand.Intn(1000)),
|
||||
"locations": []interface{}{
|
||||
"locations": []any{
|
||||
strings.Repeat("a", 100),
|
||||
strings.Repeat("a", 100),
|
||||
},
|
||||
@@ -37,15 +37,15 @@ var (
|
||||
)
|
||||
|
||||
type testEvent struct {
|
||||
data map[string]interface{}
|
||||
data map[string]any
|
||||
err error
|
||||
}
|
||||
|
||||
func (e testEvent) Encode() (map[string]interface{}, error) {
|
||||
func (e testEvent) Encode() (map[string]any, error) {
|
||||
return e.data, e.err
|
||||
}
|
||||
|
||||
func NewTestEvent(data map[string]interface{}, err error) testEvent {
|
||||
func NewTestEvent(data map[string]any, err error) testEvent {
|
||||
return testEvent{data: data, err: err}
|
||||
}
|
||||
|
||||
@@ -55,18 +55,18 @@ func TestHandle(t *testing.T) {
|
||||
|
||||
cases := []struct {
|
||||
desc string
|
||||
event map[string]interface{}
|
||||
event map[string]any
|
||||
encodeErr error
|
||||
repoErr error
|
||||
err error
|
||||
}{
|
||||
{
|
||||
desc: "success",
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"operation": operation,
|
||||
"occurred_at": float64(time.Now().UnixNano()),
|
||||
"id": testsutil.GenerateUUID(t),
|
||||
"tags": []interface{}{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"tags": []any{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"number": float64(rand.Intn(1000)),
|
||||
"metadata": payload,
|
||||
},
|
||||
@@ -74,11 +74,11 @@ func TestHandle(t *testing.T) {
|
||||
},
|
||||
{
|
||||
desc: "with encode error",
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"operation": operation,
|
||||
"occurred_at": float64(time.Now().UnixNano()),
|
||||
"id": testsutil.GenerateUUID(t),
|
||||
"tags": []interface{}{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"tags": []any{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"number": float64(rand.Intn(1000)),
|
||||
"metadata": payload,
|
||||
},
|
||||
@@ -87,10 +87,10 @@ func TestHandle(t *testing.T) {
|
||||
},
|
||||
{
|
||||
desc: "with missing operation",
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"occurred_at": float64(time.Now().UnixNano()),
|
||||
"id": testsutil.GenerateUUID(t),
|
||||
"tags": []interface{}{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"tags": []any{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"number": float64(rand.Intn(1000)),
|
||||
"metadata": payload,
|
||||
},
|
||||
@@ -98,11 +98,11 @@ func TestHandle(t *testing.T) {
|
||||
},
|
||||
{
|
||||
desc: "with empty operation",
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"operation": "",
|
||||
"occurred_at": float64(time.Now().UnixNano()),
|
||||
"id": testsutil.GenerateUUID(t),
|
||||
"tags": []interface{}{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"tags": []any{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"number": float64(rand.Intn(1000)),
|
||||
"metadata": payload,
|
||||
},
|
||||
@@ -110,11 +110,11 @@ func TestHandle(t *testing.T) {
|
||||
},
|
||||
{
|
||||
desc: "with invalid operation",
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"operation": 1,
|
||||
"occurred_at": float64(time.Now().UnixNano()),
|
||||
"id": testsutil.GenerateUUID(t),
|
||||
"tags": []interface{}{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"tags": []any{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"number": float64(rand.Intn(1000)),
|
||||
"metadata": payload,
|
||||
},
|
||||
@@ -122,10 +122,10 @@ func TestHandle(t *testing.T) {
|
||||
},
|
||||
{
|
||||
desc: "with missing occurred_at",
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"operation": operation,
|
||||
"id": testsutil.GenerateUUID(t),
|
||||
"tags": []interface{}{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"tags": []any{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"number": float64(rand.Intn(1000)),
|
||||
"metadata": payload,
|
||||
},
|
||||
@@ -133,11 +133,11 @@ func TestHandle(t *testing.T) {
|
||||
},
|
||||
{
|
||||
desc: "with empty occurred_at",
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"operation": operation,
|
||||
"occurred_at": float64(0),
|
||||
"id": testsutil.GenerateUUID(t),
|
||||
"tags": []interface{}{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"tags": []any{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"number": float64(rand.Intn(1000)),
|
||||
"metadata": payload,
|
||||
},
|
||||
@@ -145,11 +145,11 @@ func TestHandle(t *testing.T) {
|
||||
},
|
||||
{
|
||||
desc: "with invalid occurred_at",
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"operation": operation,
|
||||
"occurred_at": "invalid",
|
||||
"id": testsutil.GenerateUUID(t),
|
||||
"tags": []interface{}{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"tags": []any{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"number": float64(rand.Intn(1000)),
|
||||
"metadata": payload,
|
||||
},
|
||||
@@ -157,34 +157,34 @@ func TestHandle(t *testing.T) {
|
||||
},
|
||||
{
|
||||
desc: "with missing metadata",
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"operation": operation,
|
||||
"occurred_at": float64(time.Now().UnixNano()),
|
||||
"id": testsutil.GenerateUUID(t),
|
||||
"tags": []interface{}{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"tags": []any{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"number": float64(rand.Intn(1000)),
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
desc: "with empty metadata",
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"operation": operation,
|
||||
"occurred_at": float64(time.Now().UnixNano()),
|
||||
"id": testsutil.GenerateUUID(t),
|
||||
"tags": []interface{}{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"tags": []any{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"number": float64(rand.Intn(1000)),
|
||||
"metadata": map[string]interface{}{},
|
||||
"metadata": map[string]any{},
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
desc: "with invalid metadata",
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"operation": operation,
|
||||
"occurred_at": float64(time.Now().UnixNano()),
|
||||
"id": testsutil.GenerateUUID(t),
|
||||
"tags": []interface{}{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"tags": []any{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"number": float64(rand.Intn(1000)),
|
||||
"metadata": 1,
|
||||
},
|
||||
@@ -192,7 +192,7 @@ func TestHandle(t *testing.T) {
|
||||
},
|
||||
{
|
||||
desc: "with missing attributes",
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"operation": operation,
|
||||
"occurred_at": float64(time.Now().UnixNano()),
|
||||
"metadata": payload,
|
||||
@@ -201,11 +201,11 @@ func TestHandle(t *testing.T) {
|
||||
},
|
||||
{
|
||||
desc: "with empty attributes",
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"operation": operation,
|
||||
"occurred_at": float64(time.Now().UnixNano()),
|
||||
"id": "",
|
||||
"tags": []interface{}{},
|
||||
"tags": []any{},
|
||||
"number": float64(0),
|
||||
"metadata": payload,
|
||||
},
|
||||
@@ -213,20 +213,20 @@ func TestHandle(t *testing.T) {
|
||||
},
|
||||
{
|
||||
desc: "with invalid attributes",
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"operation": operation,
|
||||
"occurred_at": float64(time.Now().UnixNano()),
|
||||
"nested": map[string]interface{}{
|
||||
"nested": map[string]any{
|
||||
"key": float64(rand.Intn(1000)),
|
||||
"nested": map[string]interface{}{
|
||||
"nested": map[string]any{
|
||||
"key": float64(rand.Intn(1000)),
|
||||
"nested": map[string]interface{}{
|
||||
"nested": map[string]any{
|
||||
"key": float64(rand.Intn(1000)),
|
||||
"nested": map[string]interface{}{
|
||||
"nested": map[string]any{
|
||||
"key": float64(rand.Intn(1000)),
|
||||
"nested": map[string]interface{}{
|
||||
"nested": map[string]any{
|
||||
"key": float64(rand.Intn(1000)),
|
||||
"nested": map[string]interface{}{
|
||||
"nested": map[string]any{
|
||||
"key": float64(rand.Intn(1000)),
|
||||
},
|
||||
},
|
||||
@@ -240,11 +240,11 @@ func TestHandle(t *testing.T) {
|
||||
},
|
||||
{
|
||||
desc: "success",
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"operation": operation,
|
||||
"occurred_at": float64(time.Now().UnixNano()),
|
||||
"id": testsutil.GenerateUUID(t),
|
||||
"tags": []interface{}{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"tags": []any{testsutil.GenerateUUID(t), testsutil.GenerateUUID(t)},
|
||||
"number": float64(rand.Intn(1000)),
|
||||
"metadata": payload,
|
||||
},
|
||||
@@ -258,7 +258,7 @@ func TestHandle(t *testing.T) {
|
||||
data, err := json.Marshal(tc.event)
|
||||
assert.NoError(t, err)
|
||||
|
||||
event := map[string]interface{}{}
|
||||
event := map[string]any{}
|
||||
err = json.Unmarshal(data, &event)
|
||||
assert.NoError(t, err)
|
||||
|
||||
|
||||
+6
-6
@@ -79,12 +79,12 @@ func (e EntityType) Query() string {
|
||||
|
||||
// Journal represents an event journal that occurred in the system.
|
||||
type Journal struct {
|
||||
ID string `json:"id,omitempty" db:"id"`
|
||||
Domain string `json:"domain,omitempty" db:"domain"`
|
||||
Operation string `json:"operation,omitempty" db:"operation,omitempty"`
|
||||
OccurredAt time.Time `json:"occurred_at,omitempty" db:"occurred_at,omitempty"`
|
||||
Attributes map[string]interface{} `json:"attributes,omitempty" db:"attributes,omitempty"` // This is extra information about the journal for example client_id, user_id, group_id etc.
|
||||
Metadata map[string]interface{} `json:"metadata,omitempty" db:"metadata,omitempty"` // This is decoded metadata from the journal.
|
||||
ID string `json:"id,omitempty" db:"id"`
|
||||
Domain string `json:"domain,omitempty" db:"domain"`
|
||||
Operation string `json:"operation,omitempty" db:"operation,omitempty"`
|
||||
OccurredAt time.Time `json:"occurred_at,omitempty" db:"occurred_at,omitempty"`
|
||||
Attributes map[string]any `json:"attributes,omitempty" db:"attributes,omitempty"` // This is extra information about the journal for example client_id, user_id, group_id etc.
|
||||
Metadata map[string]any `json:"metadata,omitempty" db:"metadata,omitempty"` // This is decoded metadata from the journal.
|
||||
}
|
||||
|
||||
// JournalsPage represents a page of journals.
|
||||
|
||||
@@ -38,8 +38,8 @@ func TestJournalsPage_MarshalJSON(t *testing.T) {
|
||||
{
|
||||
Operation: "123",
|
||||
OccurredAt: occurredAt,
|
||||
Attributes: map[string]interface{}{"123": "123"},
|
||||
Metadata: map[string]interface{}{"123": "123"},
|
||||
Attributes: map[string]any{"123": "123"},
|
||||
Metadata: map[string]any{"123": "123"},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -168,14 +168,14 @@ func toDBJournal(j journal.Journal) (dbJournal, error) {
|
||||
}
|
||||
|
||||
func toJournal(dbj dbJournal) (journal.Journal, error) {
|
||||
var attributes map[string]interface{}
|
||||
var attributes map[string]any
|
||||
if dbj.Attributes != nil {
|
||||
if err := json.Unmarshal(dbj.Attributes, &attributes); err != nil {
|
||||
return journal.Journal{}, errors.Wrap(repoerr.ErrMalformedEntity, err)
|
||||
}
|
||||
}
|
||||
|
||||
var metadata map[string]interface{}
|
||||
var metadata map[string]any
|
||||
if dbj.Metadata != nil {
|
||||
if err := json.Unmarshal(dbj.Metadata, &metadata); err != nil {
|
||||
return journal.Journal{}, errors.Wrap(repoerr.ErrMalformedEntity, err)
|
||||
|
||||
@@ -23,18 +23,18 @@ import (
|
||||
|
||||
var (
|
||||
operation = "user.create"
|
||||
payload = map[string]interface{}{
|
||||
payload = map[string]any{
|
||||
"temperature": rand.Float64(),
|
||||
"humidity": float64(rand.Intn(1000)),
|
||||
"locations": []interface{}{
|
||||
"locations": []any{
|
||||
strings.Repeat("a", 100),
|
||||
strings.Repeat("a", 100),
|
||||
},
|
||||
"status": "active",
|
||||
"nested": map[string]interface{}{
|
||||
"nested": map[string]interface{}{
|
||||
"nested": map[string]interface{}{
|
||||
"nested": map[string]interface{}{
|
||||
"nested": map[string]any{
|
||||
"nested": map[string]any{
|
||||
"nested": map[string]any{
|
||||
"nested": map[string]any{
|
||||
"key": "value",
|
||||
},
|
||||
},
|
||||
@@ -47,41 +47,41 @@ var (
|
||||
clientOperation = "client.create"
|
||||
channelOperation = "channel.create"
|
||||
groupOperation = "group.create"
|
||||
clientAttributesV1 = map[string]interface{}{
|
||||
clientAttributesV1 = map[string]any{
|
||||
"id": entityID,
|
||||
"status": "enabled",
|
||||
"created_at": time.Now().Add(-time.Hour),
|
||||
"name": "client",
|
||||
"tags": []interface{}{"tag1", "tag2"},
|
||||
"tags": []any{"tag1", "tag2"},
|
||||
"domain": domain,
|
||||
"metadata": payload,
|
||||
"identity": testsutil.GenerateUUID(&testing.T{}),
|
||||
}
|
||||
clientAttributesV2 = map[string]interface{}{
|
||||
clientAttributesV2 = map[string]any{
|
||||
"entity_id": entityID,
|
||||
"metadata": payload,
|
||||
}
|
||||
userAttributesV1 = map[string]interface{}{
|
||||
userAttributesV1 = map[string]any{
|
||||
"id": entityID,
|
||||
"status": "enabled",
|
||||
"created_at": time.Now().Add(-time.Hour),
|
||||
"name": "user",
|
||||
"tags": []interface{}{"tag1", "tag2"},
|
||||
"tags": []any{"tag1", "tag2"},
|
||||
"domain": domain,
|
||||
"metadata": payload,
|
||||
"identity": testsutil.GenerateUUID(&testing.T{}),
|
||||
}
|
||||
userAttributesV2 = map[string]interface{}{
|
||||
userAttributesV2 = map[string]any{
|
||||
"user_id": entityID,
|
||||
"metadata": payload,
|
||||
}
|
||||
channelAtttributes = map[string]interface{}{
|
||||
channelAtttributes = map[string]any{
|
||||
"id": entityID,
|
||||
"status": "enabled",
|
||||
"created_at": time.Now().Add(-time.Hour),
|
||||
"name": "channel",
|
||||
}
|
||||
groupAttributes = map[string]interface{}{
|
||||
groupAttributes = map[string]any{
|
||||
"id": entityID,
|
||||
"status": "enabled",
|
||||
"created_at": time.Now().Add(-time.Hour),
|
||||
@@ -133,12 +133,12 @@ func TestJournalSave(t *testing.T) {
|
||||
ID: testsutil.GenerateUUID(t),
|
||||
Operation: operation,
|
||||
OccurredAt: time.Now(),
|
||||
Attributes: map[string]interface{}{
|
||||
"attributes": map[string]interface{}{
|
||||
"attributes": map[string]interface{}{
|
||||
"attributes": map[string]interface{}{
|
||||
"attributes": map[string]interface{}{
|
||||
"attributes": map[string]interface{}{
|
||||
Attributes: map[string]any{
|
||||
"attributes": map[string]any{
|
||||
"attributes": map[string]any{
|
||||
"attributes": map[string]any{
|
||||
"attributes": map[string]any{
|
||||
"attributes": map[string]any{
|
||||
"data": payload,
|
||||
},
|
||||
"data": payload,
|
||||
@@ -151,12 +151,12 @@ func TestJournalSave(t *testing.T) {
|
||||
},
|
||||
"data": payload,
|
||||
},
|
||||
Metadata: map[string]interface{}{
|
||||
"metadata": map[string]interface{}{
|
||||
"metadata": map[string]interface{}{
|
||||
"metadata": map[string]interface{}{
|
||||
"metadata": map[string]interface{}{
|
||||
"metadata": map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"metadata": map[string]any{
|
||||
"metadata": map[string]any{
|
||||
"metadata": map[string]any{
|
||||
"metadata": map[string]any{
|
||||
"metadata": map[string]any{
|
||||
"data": payload,
|
||||
},
|
||||
"data": payload,
|
||||
@@ -230,7 +230,7 @@ func TestJournalSave(t *testing.T) {
|
||||
ID: testsutil.GenerateUUID(t),
|
||||
Operation: operation,
|
||||
OccurredAt: time.Now(),
|
||||
Attributes: map[string]interface{}{"invalid": make(chan struct{})},
|
||||
Attributes: map[string]any{"invalid": make(chan struct{})},
|
||||
Metadata: payload,
|
||||
},
|
||||
err: repoerr.ErrCreateEntity,
|
||||
@@ -241,7 +241,7 @@ func TestJournalSave(t *testing.T) {
|
||||
ID: testsutil.GenerateUUID(t),
|
||||
Operation: operation + ".with.empty.attributes",
|
||||
OccurredAt: time.Now(),
|
||||
Attributes: map[string]interface{}{},
|
||||
Attributes: map[string]any{},
|
||||
Metadata: payload,
|
||||
},
|
||||
err: nil,
|
||||
@@ -262,7 +262,7 @@ func TestJournalSave(t *testing.T) {
|
||||
ID: testsutil.GenerateUUID(t),
|
||||
Operation: operation,
|
||||
OccurredAt: time.Now(),
|
||||
Metadata: map[string]interface{}{"invalid": make(chan struct{})},
|
||||
Metadata: map[string]any{"invalid": make(chan struct{})},
|
||||
Attributes: payload,
|
||||
},
|
||||
err: repoerr.ErrCreateEntity,
|
||||
@@ -273,7 +273,7 @@ func TestJournalSave(t *testing.T) {
|
||||
ID: testsutil.GenerateUUID(t),
|
||||
Operation: operation + ".with.empty.metadata",
|
||||
OccurredAt: time.Now(),
|
||||
Metadata: map[string]interface{}{},
|
||||
Metadata: map[string]any{},
|
||||
Attributes: payload,
|
||||
},
|
||||
err: nil,
|
||||
@@ -740,10 +740,10 @@ func TestJournalRetrieveAll(t *testing.T) {
|
||||
assert.Equal(t, tc.response.Offset, page.Offset)
|
||||
assert.Equal(t, tc.response.Limit, page.Limit)
|
||||
for i := range tc.response.Journals {
|
||||
tc.response.Journals[i].Attributes = map[string]interface{}{}
|
||||
page.Journals[i].Attributes = map[string]interface{}{}
|
||||
tc.response.Journals[i].Metadata = map[string]interface{}{}
|
||||
page.Journals[i].Metadata = map[string]interface{}{}
|
||||
tc.response.Journals[i].Attributes = map[string]any{}
|
||||
page.Journals[i].Attributes = map[string]any{}
|
||||
tc.response.Journals[i].Metadata = map[string]any{}
|
||||
page.Journals[i].Metadata = map[string]any{}
|
||||
tc.response.Journals[i].OccurredAt = validTimeStamp
|
||||
page.Journals[i].OccurredAt = validTimeStamp
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ var (
|
||||
validJournal = journal.Journal{
|
||||
Operation: "user.create",
|
||||
OccurredAt: time.Now().Add(-time.Hour),
|
||||
Attributes: map[string]interface{}{
|
||||
Attributes: map[string]any{
|
||||
"temperature": rand.Float64(),
|
||||
"humidity": rand.Float64(),
|
||||
},
|
||||
Metadata: map[string]interface{}{
|
||||
Metadata: map[string]any{
|
||||
"sensor_id": rand.Intn(1000),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ type connectEvent struct {
|
||||
instance string
|
||||
}
|
||||
|
||||
func (ce connectEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (ce connectEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": ce.operation,
|
||||
"client_id": ce.clientID,
|
||||
"subscriber_id": ce.subscriberID,
|
||||
@@ -42,8 +42,8 @@ type subscribeEvent struct {
|
||||
subtopic string
|
||||
}
|
||||
|
||||
func (se subscribeEvent) Encode() (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
func (se subscribeEvent) Encode() (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"operation": se.operation,
|
||||
"client_id": se.clientID,
|
||||
"subscriber_id": se.subscriberID,
|
||||
|
||||
@@ -48,7 +48,7 @@ type CallOutReq struct {
|
||||
|
||||
// Callout send request to an external service.
|
||||
type Callout interface {
|
||||
Callout(ctx context.Context, perm string, pl map[string]interface{}) error
|
||||
Callout(ctx context.Context, perm string, pl map[string]any) error
|
||||
}
|
||||
|
||||
// New creates a new instance of Callout.
|
||||
@@ -161,7 +161,7 @@ func (c *callout) makeRequest(ctx context.Context, urlStr string, params map[str
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *callout) Callout(ctx context.Context, op string, pl map[string]interface{}) error {
|
||||
func (c *callout) Callout(ctx context.Context, op string, pl map[string]any) error {
|
||||
if len(c.urls) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ const (
|
||||
filePermission = 0o644
|
||||
)
|
||||
|
||||
var pl = map[string]interface{}{
|
||||
var pl = map[string]any{
|
||||
"entity_type": entityType,
|
||||
"sender": userID,
|
||||
"domain": domainID,
|
||||
@@ -339,13 +339,13 @@ func TestCallout_Operations(t *testing.T) {
|
||||
cases := []struct {
|
||||
desc string
|
||||
operations []string
|
||||
payload map[string]interface{}
|
||||
payload map[string]any
|
||||
serverCalled bool
|
||||
}{
|
||||
{
|
||||
desc: "matching operation is called",
|
||||
operations: []string{operation},
|
||||
payload: map[string]interface{}{
|
||||
payload: map[string]any{
|
||||
"entity_type": entityType,
|
||||
"sender": userID,
|
||||
"domain": domainID,
|
||||
@@ -357,7 +357,7 @@ func TestCallout_Operations(t *testing.T) {
|
||||
{
|
||||
desc: "non-matching operation is not called",
|
||||
operations: []string{"other_operation"},
|
||||
payload: map[string]interface{}{
|
||||
payload: map[string]any{
|
||||
"entity_type": entityType,
|
||||
"sender": userID,
|
||||
"domain": domainID,
|
||||
@@ -369,7 +369,7 @@ func TestCallout_Operations(t *testing.T) {
|
||||
{
|
||||
desc: "empty operations list calls always",
|
||||
operations: []string{},
|
||||
payload: map[string]interface{}{
|
||||
payload: map[string]any{
|
||||
"entity_type": entityType,
|
||||
"sender": userID,
|
||||
"domain": domainID,
|
||||
|
||||
@@ -41,7 +41,7 @@ func (_m *Callout) EXPECT() *Callout_Expecter {
|
||||
}
|
||||
|
||||
// Callout provides a mock function for the type Callout
|
||||
func (_mock *Callout) Callout(ctx context.Context, perm string, pl map[string]interface{}) error {
|
||||
func (_mock *Callout) Callout(ctx context.Context, perm string, pl map[string]any) error {
|
||||
ret := _mock.Called(ctx, perm, pl)
|
||||
|
||||
if len(ret) == 0 {
|
||||
@@ -49,7 +49,7 @@ func (_mock *Callout) Callout(ctx context.Context, perm string, pl map[string]in
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, string, map[string]interface{}) error); ok {
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, string, map[string]any) error); ok {
|
||||
r0 = returnFunc(ctx, perm, pl)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
@@ -65,12 +65,12 @@ type Callout_Callout_Call struct {
|
||||
// Callout is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - perm string
|
||||
// - pl map[string]interface{}
|
||||
// - pl map[string]any
|
||||
func (_e *Callout_Expecter) Callout(ctx interface{}, perm interface{}, pl interface{}) *Callout_Callout_Call {
|
||||
return &Callout_Callout_Call{Call: _e.mock.On("Callout", ctx, perm, pl)}
|
||||
}
|
||||
|
||||
func (_c *Callout_Callout_Call) Run(run func(ctx context.Context, perm string, pl map[string]interface{})) *Callout_Callout_Call {
|
||||
func (_c *Callout_Callout_Call) Run(run func(ctx context.Context, perm string, pl map[string]any)) *Callout_Callout_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
@@ -80,9 +80,9 @@ func (_c *Callout_Callout_Call) Run(run func(ctx context.Context, perm string, p
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(string)
|
||||
}
|
||||
var arg2 map[string]interface{}
|
||||
var arg2 map[string]any
|
||||
if args[2] != nil {
|
||||
arg2 = args[2].(map[string]interface{})
|
||||
arg2 = args[2].(map[string]any)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
@@ -98,7 +98,7 @@ func (_c *Callout_Callout_Call) Return(err error) *Callout_Callout_Call {
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *Callout_Callout_Call) RunAndReturn(run func(ctx context.Context, perm string, pl map[string]interface{}) error) *Callout_Callout_Call {
|
||||
func (_c *Callout_Callout_Call) RunAndReturn(run func(ctx context.Context, perm string, pl map[string]any) error) *Callout_Callout_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ var (
|
||||
errUpdatedAt = errors.New("failed to parse 'updated_at' time")
|
||||
)
|
||||
|
||||
func ToDomains(data map[string]interface{}) (domains.Domain, error) {
|
||||
func ToDomains(data map[string]any) (domains.Domain, error) {
|
||||
var d domains.Domain
|
||||
id, ok := data["id"].(string)
|
||||
if !ok {
|
||||
@@ -83,7 +83,7 @@ func ToDomains(data map[string]interface{}) (domains.Domain, error) {
|
||||
d.CreatedAt = ct
|
||||
|
||||
// Following fields of groups are allowed to be empty.
|
||||
itags, ok := data["tags"].([]interface{})
|
||||
itags, ok := data["tags"].([]any)
|
||||
if ok {
|
||||
tags, err := rconsumer.ToStrings(itags)
|
||||
if err != nil {
|
||||
@@ -92,7 +92,7 @@ func ToDomains(data map[string]interface{}) (domains.Domain, error) {
|
||||
d.Tags = tags
|
||||
}
|
||||
|
||||
meta, ok := data["metadata"].(map[string]interface{})
|
||||
meta, ok := data["metadata"].(map[string]any)
|
||||
if ok {
|
||||
d.Metadata = meta
|
||||
}
|
||||
@@ -114,12 +114,12 @@ func ToDomains(data map[string]interface{}) (domains.Domain, error) {
|
||||
return d, nil
|
||||
}
|
||||
|
||||
func decodeCreateDomainEvent(data map[string]interface{}) (domains.Domain, []roles.RoleProvision, error) {
|
||||
func decodeCreateDomainEvent(data map[string]any) (domains.Domain, []roles.RoleProvision, error) {
|
||||
d, err := ToDomains(data)
|
||||
if err != nil {
|
||||
return domains.Domain{}, []roles.RoleProvision{}, errors.Wrap(errDecodeCreateDomainEvent, err)
|
||||
}
|
||||
irps, ok := data["roles_provisioned"].([]interface{})
|
||||
irps, ok := data["roles_provisioned"].([]any)
|
||||
if !ok {
|
||||
return domains.Domain{}, []roles.RoleProvision{}, errors.Wrap(errDecodeCreateDomainEvent, errors.New("missing or invalid 'roles_provisioned'"))
|
||||
}
|
||||
@@ -131,7 +131,7 @@ func decodeCreateDomainEvent(data map[string]interface{}) (domains.Domain, []rol
|
||||
return d, rps, nil
|
||||
}
|
||||
|
||||
func decodeUpdateDomainEvent(data map[string]interface{}) (domains.Domain, error) {
|
||||
func decodeUpdateDomainEvent(data map[string]any) (domains.Domain, error) {
|
||||
var d domains.Domain
|
||||
|
||||
id, ok := data["id"].(string)
|
||||
@@ -150,7 +150,7 @@ func decodeUpdateDomainEvent(data map[string]interface{}) (domains.Domain, error
|
||||
d.Route = route
|
||||
}
|
||||
|
||||
itags, ok := data["tags"].([]interface{})
|
||||
itags, ok := data["tags"].([]any)
|
||||
if ok {
|
||||
tags, err := rconsumer.ToStrings(itags)
|
||||
if err != nil {
|
||||
@@ -159,7 +159,7 @@ func decodeUpdateDomainEvent(data map[string]interface{}) (domains.Domain, error
|
||||
d.Tags = tags
|
||||
}
|
||||
|
||||
meta, ok := data["metadata"].(map[string]interface{})
|
||||
meta, ok := data["metadata"].(map[string]any)
|
||||
if ok {
|
||||
d.Metadata = meta
|
||||
}
|
||||
@@ -181,7 +181,7 @@ func decodeUpdateDomainEvent(data map[string]interface{}) (domains.Domain, error
|
||||
return d, nil
|
||||
}
|
||||
|
||||
func decodeEnableDomainEvent(data map[string]interface{}) (domains.Domain, error) {
|
||||
func decodeEnableDomainEvent(data map[string]any) (domains.Domain, error) {
|
||||
var d domains.Domain
|
||||
id, ok := data["id"].(string)
|
||||
if !ok {
|
||||
@@ -206,7 +206,7 @@ func decodeEnableDomainEvent(data map[string]interface{}) (domains.Domain, error
|
||||
return d, nil
|
||||
}
|
||||
|
||||
func decodeDisableDomainEvent(data map[string]interface{}) (domains.Domain, error) {
|
||||
func decodeDisableDomainEvent(data map[string]any) (domains.Domain, error) {
|
||||
var d domains.Domain
|
||||
id, ok := data["id"].(string)
|
||||
if !ok {
|
||||
@@ -231,7 +231,7 @@ func decodeDisableDomainEvent(data map[string]interface{}) (domains.Domain, erro
|
||||
return d, nil
|
||||
}
|
||||
|
||||
func decodeFreezeDomainEvent(data map[string]interface{}) (domains.Domain, error) {
|
||||
func decodeFreezeDomainEvent(data map[string]any) (domains.Domain, error) {
|
||||
var d domains.Domain
|
||||
id, ok := data["id"].(string)
|
||||
if !ok {
|
||||
@@ -256,11 +256,11 @@ func decodeFreezeDomainEvent(data map[string]interface{}) (domains.Domain, error
|
||||
return d, nil
|
||||
}
|
||||
|
||||
func decodeUserDeleteDomainEvent(_ map[string]interface{}) (domains.Domain, error) {
|
||||
func decodeUserDeleteDomainEvent(_ map[string]any) (domains.Domain, error) {
|
||||
return domains.Domain{}, fmt.Errorf("not implemented decode domain user delete event ")
|
||||
}
|
||||
|
||||
func decodeDeleteDomainEvent(data map[string]interface{}) (domains.Domain, error) {
|
||||
func decodeDeleteDomainEvent(data map[string]any) (domains.Domain, error) {
|
||||
var d domains.Domain
|
||||
id, ok := data["id"].(string)
|
||||
if !ok {
|
||||
|
||||
@@ -100,7 +100,7 @@ func (es *eventHandler) Handle(ctx context.Context, event events.Event) error {
|
||||
return es.rolesEventHandler.Handle(ctx, op, msg)
|
||||
}
|
||||
|
||||
func (es *eventHandler) createDomainHandler(ctx context.Context, data map[string]interface{}) error {
|
||||
func (es *eventHandler) createDomainHandler(ctx context.Context, data map[string]any) error {
|
||||
d, rps, err := decodeCreateDomainEvent(data)
|
||||
if err != nil {
|
||||
return errors.Wrap(errCreateDomainEvent, err)
|
||||
@@ -116,7 +116,7 @@ func (es *eventHandler) createDomainHandler(ctx context.Context, data map[string
|
||||
return nil
|
||||
}
|
||||
|
||||
func (es *eventHandler) updateDomainHandler(ctx context.Context, data map[string]interface{}) error {
|
||||
func (es *eventHandler) updateDomainHandler(ctx context.Context, data map[string]any) error {
|
||||
d, err := decodeUpdateDomainEvent(data)
|
||||
if err != nil {
|
||||
return errors.Wrap(errUpdateDomainEvent, err)
|
||||
@@ -139,7 +139,7 @@ func (es *eventHandler) updateDomainHandler(ctx context.Context, data map[string
|
||||
return nil
|
||||
}
|
||||
|
||||
func (es *eventHandler) enableDomainHandler(ctx context.Context, data map[string]interface{}) error {
|
||||
func (es *eventHandler) enableDomainHandler(ctx context.Context, data map[string]any) error {
|
||||
d, err := decodeEnableDomainEvent(data)
|
||||
if err != nil {
|
||||
return errors.Wrap(errEnableDomainGroupEvent, err)
|
||||
@@ -153,7 +153,7 @@ func (es *eventHandler) enableDomainHandler(ctx context.Context, data map[string
|
||||
return nil
|
||||
}
|
||||
|
||||
func (es *eventHandler) disableDomainHandler(ctx context.Context, data map[string]interface{}) error {
|
||||
func (es *eventHandler) disableDomainHandler(ctx context.Context, data map[string]any) error {
|
||||
d, err := decodeDisableDomainEvent(data)
|
||||
if err != nil {
|
||||
return errors.Wrap(errDisableDomainGroupEvent, err)
|
||||
@@ -167,7 +167,7 @@ func (es *eventHandler) disableDomainHandler(ctx context.Context, data map[strin
|
||||
return nil
|
||||
}
|
||||
|
||||
func (es *eventHandler) freezeDomainHandler(ctx context.Context, data map[string]interface{}) error {
|
||||
func (es *eventHandler) freezeDomainHandler(ctx context.Context, data map[string]any) error {
|
||||
d, err := decodeFreezeDomainEvent(data)
|
||||
if err != nil {
|
||||
return errors.Wrap(errFreezeDomainGroupEvent, err)
|
||||
@@ -181,7 +181,7 @@ func (es *eventHandler) freezeDomainHandler(ctx context.Context, data map[string
|
||||
return nil
|
||||
}
|
||||
|
||||
func (es *eventHandler) userDeleteDomainHandler(_ context.Context, data map[string]interface{}) error {
|
||||
func (es *eventHandler) userDeleteDomainHandler(_ context.Context, data map[string]any) error {
|
||||
_, err := decodeUserDeleteDomainEvent(data)
|
||||
if err != nil {
|
||||
return errors.Wrap(errUserDeleteDomainEvent, err)
|
||||
@@ -190,7 +190,7 @@ func (es *eventHandler) userDeleteDomainHandler(_ context.Context, data map[stri
|
||||
return fmt.Errorf("not implemented user delete domain handler")
|
||||
}
|
||||
|
||||
func (es *eventHandler) deleteDomainHandler(ctx context.Context, data map[string]interface{}) error {
|
||||
func (es *eventHandler) deleteDomainHandler(ctx context.Context, data map[string]any) error {
|
||||
d, err := decodeDeleteDomainEvent(data)
|
||||
if err != nil {
|
||||
return errors.Wrap(errDeleteDomainEvent, err)
|
||||
|
||||
@@ -20,7 +20,7 @@ const (
|
||||
// Event represents an event.
|
||||
type Event interface {
|
||||
// Encode encodes event to map.
|
||||
Encode() (map[string]interface{}, error)
|
||||
Encode() (map[string]any, error)
|
||||
}
|
||||
|
||||
// Publisher specifies events publishing API.
|
||||
@@ -58,7 +58,7 @@ type Subscriber interface {
|
||||
|
||||
// Read reads value from event map.
|
||||
// If value is not of type T, returns default value.
|
||||
func Read[T any](event map[string]interface{}, key string, def T) T {
|
||||
func Read[T any](event map[string]any, key string, def T) T {
|
||||
val, ok := event[key].(T)
|
||||
if !ok {
|
||||
return def
|
||||
@@ -69,10 +69,10 @@ func Read[T any](event map[string]interface{}, key string, def T) T {
|
||||
|
||||
// ReadStringSlice reads string slice from event map.
|
||||
// If value is not a string slice, returns empty slice.
|
||||
func ReadStringSlice(event map[string]interface{}, key string) []string {
|
||||
func ReadStringSlice(event map[string]any, key string) []string {
|
||||
var res []string
|
||||
|
||||
vals, ok := event[key].([]interface{})
|
||||
vals, ok := event[key].([]any)
|
||||
if !ok {
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -19,18 +19,18 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
eventsChan = make(chan map[string]interface{})
|
||||
eventsChan = make(chan map[string]any)
|
||||
logger = smqlog.NewMock()
|
||||
errFailed = errors.New("failed")
|
||||
numEvents = 100
|
||||
)
|
||||
|
||||
type testEvent struct {
|
||||
Data map[string]interface{}
|
||||
Data map[string]any
|
||||
}
|
||||
|
||||
func (te testEvent) Encode() (map[string]interface{}, error) {
|
||||
data := make(map[string]interface{})
|
||||
func (te testEvent) Encode() (map[string]any, error) {
|
||||
data := make(map[string]any)
|
||||
for k, v := range te.Data {
|
||||
switch v.(type) {
|
||||
case string:
|
||||
@@ -74,13 +74,13 @@ func TestPublish(t *testing.T) {
|
||||
|
||||
cases := []struct {
|
||||
desc string
|
||||
event map[string]interface{}
|
||||
event map[string]any
|
||||
err error
|
||||
}{
|
||||
{
|
||||
desc: "publish event successfully",
|
||||
err: nil,
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"temperature": fmt.Sprintf("%f", rand.Float64()),
|
||||
"humidity": fmt.Sprintf("%f", rand.Float64()),
|
||||
"sensor_id": "abc123",
|
||||
@@ -99,7 +99,7 @@ func TestPublish(t *testing.T) {
|
||||
{
|
||||
desc: "publish event with invalid event location",
|
||||
err: fmt.Errorf("json: unsupported type: chan int"),
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"temperature": fmt.Sprintf("%f", rand.Float64()),
|
||||
"humidity": fmt.Sprintf("%f", rand.Float64()),
|
||||
"sensor_id": "abc123",
|
||||
@@ -113,7 +113,7 @@ func TestPublish(t *testing.T) {
|
||||
{
|
||||
desc: "publish event with nested sting value",
|
||||
err: nil,
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"temperature": fmt.Sprintf("%f", rand.Float64()),
|
||||
"humidity": fmt.Sprintf("%f", rand.Float64()),
|
||||
"sensor_id": "abc123",
|
||||
@@ -275,7 +275,7 @@ func TestUnavailablePublish(t *testing.T) {
|
||||
assert.Nil(t, err, fmt.Sprintf("got unexpected error on closing publisher: %s", err))
|
||||
|
||||
// read all the events from the channel and assert that they are 10.
|
||||
var receivedEvents []map[string]interface{}
|
||||
var receivedEvents []map[string]any
|
||||
for i := 0; i < numEvents; i++ {
|
||||
event := <-eventsChan
|
||||
receivedEvents = append(receivedEvents, event)
|
||||
@@ -285,7 +285,7 @@ func TestUnavailablePublish(t *testing.T) {
|
||||
|
||||
func generateRandomEvent() testEvent {
|
||||
return testEvent{
|
||||
Data: map[string]interface{}{
|
||||
Data: map[string]any{
|
||||
"temperature": fmt.Sprintf("%f", rand.Float64()),
|
||||
"humidity": fmt.Sprintf("%f", rand.Float64()),
|
||||
"sensor_id": fmt.Sprintf("%d", rand.Intn(1000)),
|
||||
|
||||
@@ -83,10 +83,10 @@ func (es *subEventStore) Close() error {
|
||||
}
|
||||
|
||||
type event struct {
|
||||
Data map[string]interface{}
|
||||
Data map[string]any
|
||||
}
|
||||
|
||||
func (re event) Encode() (map[string]interface{}, error) {
|
||||
func (re event) Encode() (map[string]any, error) {
|
||||
return re.Data, nil
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ type eventHandler struct {
|
||||
|
||||
func (eh *eventHandler) Handle(msg *messaging.Message) error {
|
||||
event := event{
|
||||
Data: make(map[string]interface{}),
|
||||
Data: make(map[string]any),
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(msg.GetPayload(), &event.Data); err != nil {
|
||||
|
||||
@@ -19,18 +19,18 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
eventsChan = make(chan map[string]interface{})
|
||||
eventsChan = make(chan map[string]any)
|
||||
logger = smqlog.NewMock()
|
||||
errFailed = errors.New("failed")
|
||||
numEvents = 100
|
||||
)
|
||||
|
||||
type testEvent struct {
|
||||
Data map[string]interface{}
|
||||
Data map[string]any
|
||||
}
|
||||
|
||||
func (te testEvent) Encode() (map[string]interface{}, error) {
|
||||
data := make(map[string]interface{})
|
||||
func (te testEvent) Encode() (map[string]any, error) {
|
||||
data := make(map[string]any)
|
||||
for k, v := range te.Data {
|
||||
switch v.(type) {
|
||||
case string:
|
||||
@@ -74,13 +74,13 @@ func TestPublish(t *testing.T) {
|
||||
|
||||
cases := []struct {
|
||||
desc string
|
||||
event map[string]interface{}
|
||||
event map[string]any
|
||||
err error
|
||||
}{
|
||||
{
|
||||
desc: "publish event successfully",
|
||||
err: nil,
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"temperature": fmt.Sprintf("%f", rand.Float64()),
|
||||
"humidity": fmt.Sprintf("%f", rand.Float64()),
|
||||
"sensor_id": "abc123",
|
||||
@@ -99,7 +99,7 @@ func TestPublish(t *testing.T) {
|
||||
{
|
||||
desc: "publish event with invalid event location",
|
||||
err: fmt.Errorf("json: unsupported type: chan int"),
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"temperature": fmt.Sprintf("%f", rand.Float64()),
|
||||
"humidity": fmt.Sprintf("%f", rand.Float64()),
|
||||
"sensor_id": "abc123",
|
||||
@@ -113,7 +113,7 @@ func TestPublish(t *testing.T) {
|
||||
{
|
||||
desc: "publish event with nested sting value",
|
||||
err: nil,
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"temperature": fmt.Sprintf("%f", rand.Float64()),
|
||||
"humidity": fmt.Sprintf("%f", rand.Float64()),
|
||||
"sensor_id": "abc123",
|
||||
@@ -276,7 +276,7 @@ func TestUnavailablePublish(t *testing.T) {
|
||||
assert.Nil(t, err, fmt.Sprintf("got unexpected error on closing publisher: %s", err))
|
||||
|
||||
// read all the events from the channel and assert that they are 10.
|
||||
var receivedEvents []map[string]interface{}
|
||||
var receivedEvents []map[string]any
|
||||
for i := 0; i < numEvents; i++ {
|
||||
event := <-eventsChan
|
||||
receivedEvents = append(receivedEvents, event)
|
||||
@@ -286,7 +286,7 @@ func TestUnavailablePublish(t *testing.T) {
|
||||
|
||||
func generateRandomEvent() testEvent {
|
||||
return testEvent{
|
||||
Data: map[string]interface{}{
|
||||
Data: map[string]any{
|
||||
"temperature": fmt.Sprintf("%f", rand.Float64()),
|
||||
"humidity": fmt.Sprintf("%f", rand.Float64()),
|
||||
"sensor_id": fmt.Sprintf("%d", rand.Intn(1000)),
|
||||
|
||||
@@ -69,10 +69,10 @@ func (es *subEventStore) Close() error {
|
||||
}
|
||||
|
||||
type event struct {
|
||||
Data map[string]interface{}
|
||||
Data map[string]any
|
||||
}
|
||||
|
||||
func (re event) Encode() (map[string]interface{}, error) {
|
||||
func (re event) Encode() (map[string]any, error) {
|
||||
return re.Data, nil
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ type eventHandler struct {
|
||||
|
||||
func (eh *eventHandler) Handle(msg *messaging.Message) error {
|
||||
event := event{
|
||||
Data: make(map[string]interface{}),
|
||||
Data: make(map[string]any),
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(msg.GetPayload(), &event.Data); err != nil {
|
||||
|
||||
@@ -53,7 +53,7 @@ func (es *pubEventStore) Publish(ctx context.Context, stream string, event event
|
||||
Stream: eventsPrefix + stream,
|
||||
MaxLen: events.MaxEventStreamLen,
|
||||
Approx: true,
|
||||
Values: map[string]interface{}{"data": string(data)},
|
||||
Values: map[string]any{"data": string(data)},
|
||||
}
|
||||
|
||||
switch err := es.checkConnection(ctx); err {
|
||||
|
||||
@@ -20,19 +20,19 @@ import (
|
||||
var (
|
||||
stream = "tests.events"
|
||||
consumer = "test-consumer"
|
||||
eventsChan = make(chan map[string]interface{})
|
||||
eventsChan = make(chan map[string]any)
|
||||
logger = smqlog.NewMock()
|
||||
errFailed = errors.New("failed")
|
||||
numEvents = 100
|
||||
)
|
||||
|
||||
type testEvent struct {
|
||||
Data map[string]interface{}
|
||||
Data map[string]any
|
||||
}
|
||||
|
||||
func (te testEvent) Encode() (map[string]interface{}, error) {
|
||||
func (te testEvent) Encode() (map[string]any, error) {
|
||||
if te.Data == nil {
|
||||
return map[string]interface{}{}, nil
|
||||
return map[string]any{}, nil
|
||||
}
|
||||
|
||||
return te.Data, nil
|
||||
@@ -66,13 +66,13 @@ func TestPublish(t *testing.T) {
|
||||
|
||||
cases := []struct {
|
||||
desc string
|
||||
event map[string]interface{}
|
||||
event map[string]any
|
||||
err error
|
||||
}{
|
||||
{
|
||||
desc: "publish event successfully",
|
||||
err: nil,
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"temperature": float64(rand.Float64()),
|
||||
"humidity": float64(rand.Float64()),
|
||||
"sensor_id": "abc123",
|
||||
@@ -91,7 +91,7 @@ func TestPublish(t *testing.T) {
|
||||
{
|
||||
desc: "publish event with invalid event location",
|
||||
err: fmt.Errorf("json: unsupported type: chan int"),
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"temperature": float64(rand.Float64()),
|
||||
"humidity": float64(rand.Float64()),
|
||||
"sensor_id": "abc123",
|
||||
@@ -105,7 +105,7 @@ func TestPublish(t *testing.T) {
|
||||
{
|
||||
desc: "publish event with nested sting value",
|
||||
err: nil,
|
||||
event: map[string]interface{}{
|
||||
event: map[string]any{
|
||||
"temperature": float64(rand.Float64()),
|
||||
"humidity": float64(rand.Float64()),
|
||||
"sensor_id": "abc123",
|
||||
@@ -271,7 +271,7 @@ func TestUnavailablePublish(t *testing.T) {
|
||||
err = publisher.Close()
|
||||
assert.Nil(t, err, fmt.Sprintf("got unexpected error on closing publisher: %s", err))
|
||||
|
||||
var receivedEvents []map[string]interface{}
|
||||
var receivedEvents []map[string]any
|
||||
for i := 0; i < numEvents; i++ {
|
||||
event := <-eventsChan
|
||||
receivedEvents = append(receivedEvents, event)
|
||||
@@ -281,7 +281,7 @@ func TestUnavailablePublish(t *testing.T) {
|
||||
|
||||
func generateRandomEvent() testEvent {
|
||||
return testEvent{
|
||||
Data: map[string]interface{}{
|
||||
Data: map[string]any{
|
||||
"temperature": fmt.Sprintf("%f", rand.Float64()),
|
||||
"humidity": fmt.Sprintf("%f", rand.Float64()),
|
||||
"sensor_id": fmt.Sprintf("%d", rand.Intn(1000)),
|
||||
|
||||
@@ -90,16 +90,16 @@ func (es *subEventStore) Close() error {
|
||||
}
|
||||
|
||||
type redisEvent struct {
|
||||
Data map[string]interface{}
|
||||
Data map[string]any
|
||||
}
|
||||
|
||||
func (re redisEvent) Encode() (map[string]interface{}, error) {
|
||||
func (re redisEvent) Encode() (map[string]any, error) {
|
||||
return re.Data, nil
|
||||
}
|
||||
|
||||
func (es *subEventStore) handle(ctx context.Context, stream string, msgs []redis.XMessage, h events.EventHandler) {
|
||||
for _, msg := range msgs {
|
||||
var data map[string]interface{}
|
||||
var data map[string]any
|
||||
if err := json.Unmarshal([]byte(msg.Values["data"].(string)), &data); err != nil {
|
||||
es.logger.Warn(fmt.Sprintf("failed to unmarshal redis event: %s", err))
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ var (
|
||||
|
||||
const layout = "2006-01-02T15:04:05.999999Z"
|
||||
|
||||
func ToGroups(data map[string]interface{}) (groups.Group, error) {
|
||||
func ToGroups(data map[string]any) (groups.Group, error) {
|
||||
var g groups.Group
|
||||
id, ok := data["id"].(string)
|
||||
if !ok {
|
||||
@@ -88,7 +88,7 @@ func ToGroups(data map[string]interface{}) (groups.Group, error) {
|
||||
g.Parent = parent
|
||||
}
|
||||
|
||||
meta, ok := data["metadata"].(map[string]interface{})
|
||||
meta, ok := data["metadata"].(map[string]any)
|
||||
if ok {
|
||||
g.Metadata = meta
|
||||
}
|
||||
@@ -110,12 +110,12 @@ func ToGroups(data map[string]interface{}) (groups.Group, error) {
|
||||
return g, nil
|
||||
}
|
||||
|
||||
func decodeCreateGroupEvent(data map[string]interface{}) (groups.Group, []roles.RoleProvision, error) {
|
||||
func decodeCreateGroupEvent(data map[string]any) (groups.Group, []roles.RoleProvision, error) {
|
||||
g, err := ToGroups(data)
|
||||
if err != nil {
|
||||
return groups.Group{}, []roles.RoleProvision{}, errors.Wrap(errDecodeCreateGroupEvent, err)
|
||||
}
|
||||
irps, ok := data["roles_provisioned"].([]interface{})
|
||||
irps, ok := data["roles_provisioned"].([]any)
|
||||
if !ok {
|
||||
return groups.Group{}, []roles.RoleProvision{}, errors.Wrap(errDecodeCreateGroupEvent, errors.New("missing or invalid 'roles_provisioned'"))
|
||||
}
|
||||
@@ -127,7 +127,7 @@ func decodeCreateGroupEvent(data map[string]interface{}) (groups.Group, []roles.
|
||||
return g, rps, nil
|
||||
}
|
||||
|
||||
func decodeUpdateGroupEvent(data map[string]interface{}) (groups.Group, error) {
|
||||
func decodeUpdateGroupEvent(data map[string]any) (groups.Group, error) {
|
||||
g, err := ToGroups(data)
|
||||
if err != nil {
|
||||
return groups.Group{}, errors.Wrap(errDecodeUpdateGroupEvent, err)
|
||||
@@ -135,7 +135,7 @@ func decodeUpdateGroupEvent(data map[string]interface{}) (groups.Group, error) {
|
||||
return g, nil
|
||||
}
|
||||
|
||||
func ToGroupStatus(data map[string]interface{}) (groups.Group, error) {
|
||||
func ToGroupStatus(data map[string]any) (groups.Group, error) {
|
||||
var g groups.Group
|
||||
id, ok := data["id"].(string)
|
||||
if !ok {
|
||||
@@ -170,7 +170,7 @@ func ToGroupStatus(data map[string]interface{}) (groups.Group, error) {
|
||||
return g, nil
|
||||
}
|
||||
|
||||
func decodeChangeStatusGroupEvent(data map[string]interface{}) (groups.Group, error) {
|
||||
func decodeChangeStatusGroupEvent(data map[string]any) (groups.Group, error) {
|
||||
g, err := ToGroupStatus(data)
|
||||
if err != nil {
|
||||
return groups.Group{}, errors.Wrap(errDecodeChangeStatusGroupEvent, err)
|
||||
@@ -178,7 +178,7 @@ func decodeChangeStatusGroupEvent(data map[string]interface{}) (groups.Group, er
|
||||
return g, nil
|
||||
}
|
||||
|
||||
func decodeRemoveGroupEvent(data map[string]interface{}) (groups.Group, error) {
|
||||
func decodeRemoveGroupEvent(data map[string]any) (groups.Group, error) {
|
||||
var g groups.Group
|
||||
id, ok := data["id"].(string)
|
||||
if !ok {
|
||||
@@ -189,7 +189,7 @@ func decodeRemoveGroupEvent(data map[string]interface{}) (groups.Group, error) {
|
||||
return g, nil
|
||||
}
|
||||
|
||||
func decodeAddParentGroupEvent(data map[string]interface{}) (id string, parent string, err error) {
|
||||
func decodeAddParentGroupEvent(data map[string]any) (id string, parent string, err error) {
|
||||
id, ok := data["id"].(string)
|
||||
if !ok {
|
||||
return "", "", errors.Wrap(errAddParentGroupEvent, errID)
|
||||
@@ -203,7 +203,7 @@ func decodeAddParentGroupEvent(data map[string]interface{}) (id string, parent s
|
||||
return id, parent, nil
|
||||
}
|
||||
|
||||
func decodeRemoveParentGroupEvent(data map[string]interface{}) (id string, err error) {
|
||||
func decodeRemoveParentGroupEvent(data map[string]any) (id string, err error) {
|
||||
id, ok := data["id"].(string)
|
||||
if !ok {
|
||||
return "", errors.Wrap(errDecodeRemoveParentGroupEvent, errID)
|
||||
@@ -212,12 +212,12 @@ func decodeRemoveParentGroupEvent(data map[string]interface{}) (id string, err e
|
||||
return id, nil
|
||||
}
|
||||
|
||||
func decodeAddChildrenGroupEvent(data map[string]interface{}) (id string, childrenIDs []string, err error) {
|
||||
func decodeAddChildrenGroupEvent(data map[string]any) (id string, childrenIDs []string, err error) {
|
||||
id, ok := data["id"].(string)
|
||||
if !ok {
|
||||
return "", []string{}, errors.Wrap(errDecodeAddChildrenGroupsEvent, errID)
|
||||
}
|
||||
chIDs, ok := data["children_ids"].([]interface{})
|
||||
chIDs, ok := data["children_ids"].([]any)
|
||||
if !ok {
|
||||
return "", []string{}, errors.Wrap(errDecodeAddChildrenGroupsEvent, errChildrenIDs)
|
||||
}
|
||||
@@ -228,12 +228,12 @@ func decodeAddChildrenGroupEvent(data map[string]interface{}) (id string, childr
|
||||
return id, cids, nil
|
||||
}
|
||||
|
||||
func decodeRemoveChildrenGroupEvent(data map[string]interface{}) (id string, childrenIDs []string, err error) {
|
||||
func decodeRemoveChildrenGroupEvent(data map[string]any) (id string, childrenIDs []string, err error) {
|
||||
id, ok := data["id"].(string)
|
||||
if !ok {
|
||||
return "", []string{}, errors.Wrap(errDecodeRemoveChildrenGroupsEvent, errID)
|
||||
}
|
||||
chIDs, ok := data["children_ids"].([]interface{})
|
||||
chIDs, ok := data["children_ids"].([]any)
|
||||
if !ok {
|
||||
return "", []string{}, errors.Wrap(errDecodeRemoveChildrenGroupsEvent, errChildrenIDs)
|
||||
}
|
||||
@@ -244,7 +244,7 @@ func decodeRemoveChildrenGroupEvent(data map[string]interface{}) (id string, chi
|
||||
return id, cids, nil
|
||||
}
|
||||
|
||||
func decodeRemoveAllChildrenGroupEvent(data map[string]interface{}) (id string, err error) {
|
||||
func decodeRemoveAllChildrenGroupEvent(data map[string]any) (id string, err error) {
|
||||
id, ok := data["id"].(string)
|
||||
if !ok {
|
||||
return "", errors.Wrap(errDecodeRemoveChildrenGroupsEvent, errID)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user