--- /dev/null
+/*
+==================================================================================
+
+Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+==================================================================================
+*/
+
+package utils
+
+import (
+ "encoding/json"
+ "net/http"
+)
+
+func WriteSuccess(w http.ResponseWriter, code int, data []byte) {
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(code)
+ w.Write(data)
+}
+
+func WriteError(w http.ResponseWriter, err error) {
+ data := make(map[string]interface{})
+ data["message"] = err.Error()
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusNotFound)
+ w.Write(ChangeToJson(data))
+}
+
+func ChangeToJson(src map[string]interface{}) []byte {
+ dst, err := json.Marshal(src)
+ if err != nil {
+ return nil
+ }
+ return dst
+}
"github.com/gin-gonic/gin"
"gerrit.o-ran-sc.org/r/aiml-fw/aihp/ips/kserve-adapter/pkg/api/commons/url"
+ "gerrit.o-ran-sc.org/r/aiml-fw/aihp/ips/kserve-adapter/pkg/api/v1/deployment"
"gerrit.o-ran-sc.org/r/aiml-fw/aihp/ips/kserve-adapter/pkg/commons/logger"
)
+var deploymentExecutor deployment.Command
+
+func init() {
+ deploymentExecutor = deployment.Executor{}
+}
+
func setupRouter() (router *gin.Engine) {
router = gin.Default()
{
deployment := v1.Group(url.IPS())
{
- // deployment.POST
+ deployment.POST("", deploymentExecutor.Deploy)
// deployment.PUT
// deployment.DELETE
}
info := v1.Group(url.IPS() + url.Info())
// info.GET()
- _, _, _, _, _ = deployment, healthcheck, revision, status, info
+ _, _, _, _ = healthcheck, revision, status, info
}
return
--- /dev/null
+/*
+==================================================================================
+
+Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+==================================================================================
+*/
+
+package deployment
+
+import (
+ "errors"
+ "net/http"
+
+ "github.com/gin-gonic/gin"
+
+ "gerrit.o-ran-sc.org/r/aiml-fw/aihp/ips/kserve-adapter/pkg/api/commons/utils"
+ "gerrit.o-ran-sc.org/r/aiml-fw/aihp/ips/kserve-adapter/pkg/commons/logger"
+)
+
+type Command interface {
+ Deploy(c *gin.Context)
+}
+
+type Executor struct {
+ Command
+}
+
+func (Executor) Deploy(c *gin.Context) {
+ logger.Logging(logger.DEBUG, "IN")
+ defer logger.Logging(logger.DEBUG, "OUT")
+
+ name := c.Query("name")
+ if name == "" {
+ utils.WriteError(c.Writer, errors.New("empty query"))
+ return
+ }
+
+ version := c.Query("version")
+ if version == "" {
+ utils.WriteError(c.Writer, errors.New("empty query"))
+ return
+ }
+
+ // kserve client deploy logic
+
+ utils.WriteSuccess(c.Writer, http.StatusCreated, nil)
+}