Skip to content

Commit 47843d9

Browse files
Revert "feat: plugin creation support (#5630)" (#5778)
This reverts commit 4296366.
1 parent 4296366 commit 47843d9

File tree

8 files changed

+103
-757
lines changed

8 files changed

+103
-757
lines changed

api/restHandler/GlobalPluginRestHandler.go

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535

3636
type GlobalPluginRestHandler interface {
3737
PatchPlugin(w http.ResponseWriter, r *http.Request)
38-
CreatePlugin(w http.ResponseWriter, r *http.Request)
3938

4039
GetAllGlobalVariables(w http.ResponseWriter, r *http.Request)
4140
ListAllPlugins(w http.ResponseWriter, r *http.Request)
@@ -47,7 +46,6 @@ type GlobalPluginRestHandler interface {
4746
GetPluginDetailByIds(w http.ResponseWriter, r *http.Request)
4847
GetAllUniqueTags(w http.ResponseWriter, r *http.Request)
4948
MigratePluginData(w http.ResponseWriter, r *http.Request)
50-
GetAllPluginMinData(w http.ResponseWriter, r *http.Request)
5149
}
5250

5351
func NewGlobalPluginRestHandler(logger *zap.SugaredLogger, globalPluginService plugin.GlobalPluginService,
@@ -422,68 +420,3 @@ func (handler *GlobalPluginRestHandlerImpl) MigratePluginData(w http.ResponseWri
422420
}
423421
common.WriteJsonResp(w, nil, nil, http.StatusOK)
424422
}
425-
426-
func (handler *GlobalPluginRestHandlerImpl) CreatePlugin(w http.ResponseWriter, r *http.Request) {
427-
userId, err := handler.userService.GetLoggedInUser(r)
428-
if userId == 0 || err != nil {
429-
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
430-
return
431-
}
432-
token := r.Header.Get("token")
433-
appId, err := common.ExtractIntQueryParam(w, r, "appId", 0)
434-
if err != nil {
435-
return
436-
}
437-
ok, err := handler.IsUserAuthorized(token, appId)
438-
if err != nil {
439-
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
440-
return
441-
}
442-
if !ok {
443-
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden)
444-
return
445-
}
446-
decoder := json.NewDecoder(r.Body)
447-
var pluginDataDto bean.PluginParentMetadataDto
448-
err = decoder.Decode(&pluginDataDto)
449-
if err != nil {
450-
handler.logger.Errorw("request err, CreatePlugin", "error", err, "payload", pluginDataDto)
451-
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
452-
return
453-
}
454-
handler.logger.Infow("request payload received for creating plugins", pluginDataDto, "userId", userId)
455-
456-
pluginVersionId, err := handler.globalPluginService.CreatePluginOrVersions(&pluginDataDto, userId)
457-
if err != nil {
458-
handler.logger.Errorw("service error, error in creating plugin", "pluginCreateRequestDto", pluginDataDto, "err", err)
459-
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
460-
return
461-
}
462-
463-
common.WriteJsonResp(w, nil, bean.NewPluginMinDto().WithPluginVersionId(pluginVersionId), http.StatusOK)
464-
}
465-
466-
func (handler *GlobalPluginRestHandlerImpl) GetAllPluginMinData(w http.ResponseWriter, r *http.Request) {
467-
token := r.Header.Get("token")
468-
appId, err := common.ExtractIntQueryParam(w, r, "appId", 0)
469-
if err != nil {
470-
return
471-
}
472-
ok, err := handler.IsUserAuthorized(token, appId)
473-
if err != nil {
474-
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
475-
return
476-
}
477-
if !ok {
478-
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden)
479-
return
480-
}
481-
482-
pluginDetail, err := handler.globalPluginService.GetAllPluginMinData()
483-
if err != nil {
484-
handler.logger.Errorw("error in getting all unique tags", "err", err)
485-
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
486-
return
487-
}
488-
common.WriteJsonResp(w, nil, pluginDetail, http.StatusOK)
489-
}

api/router/GlobalPluginRouter.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ type GlobalPluginRouterImpl struct {
4141
func (impl *GlobalPluginRouterImpl) initGlobalPluginRouter(globalPluginRouter *mux.Router) {
4242
globalPluginRouter.Path("/migrate").
4343
HandlerFunc(impl.globalPluginRestHandler.MigratePluginData).Methods("PUT")
44-
globalPluginRouter.Path("/create").
45-
HandlerFunc(impl.globalPluginRestHandler.CreatePlugin).Methods("POST")
44+
4645
// versioning impact handling to be done for below apis,
4746
globalPluginRouter.Path("").
4847
HandlerFunc(impl.globalPluginRestHandler.PatchPlugin).Methods("POST")
@@ -69,7 +68,5 @@ func (impl *GlobalPluginRouterImpl) initGlobalPluginRouter(globalPluginRouter *m
6968

7069
globalPluginRouter.Path("/list/tags").
7170
HandlerFunc(impl.globalPluginRestHandler.GetAllUniqueTags).Methods("GET")
72-
globalPluginRouter.Path("/list/v2/min").
73-
HandlerFunc(impl.globalPluginRestHandler.GetAllPluginMinData).Methods("GET")
7471

7572
}

internal/util/ErrorUtil.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"google.golang.org/grpc/codes"
2727
"google.golang.org/grpc/status"
2828
"net/http"
29-
"strconv"
3029
)
3130

3231
type ApiError struct {
@@ -37,14 +36,6 @@ type ApiError struct {
3736
UserDetailMessage string `json:"userDetailMessage,omitempty"`
3837
}
3938

40-
func GetApiError(code int, userMessage, internalMessage string) *ApiError {
41-
return &ApiError{
42-
HttpStatusCode: code,
43-
Code: strconv.Itoa(code),
44-
InternalMessage: internalMessage,
45-
UserMessage: userMessage,
46-
}
47-
}
4839
func NewApiError() *ApiError {
4940
return &ApiError{}
5041
}

0 commit comments

Comments
 (0)