diff options
author | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2023-03-13 11:00:21 +0000 |
---|---|---|
committer | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2023-03-14 14:25:16 +0000 |
commit | 870ff702088b89549bc21631eb48443fff0bcd71 (patch) | |
tree | 5d52aca25035644bdc2ac687275ed858ba524e7e /mock-clamp | |
parent | 98e0e65ba145ab4c85c301118d4a0d02940221ec (diff) |
Migrate mock applications from Orange GitLab
Move from Orange repositories into ONAP one.
Issue-ID: INT-2208
Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl>
Change-Id: I6e165da5144c28a6ff151e02e32f5ae89ce124e3
Diffstat (limited to 'mock-clamp')
-rw-r--r-- | mock-clamp/.dockerignore | 13 | ||||
-rw-r--r-- | mock-clamp/Dockerfile | 32 | ||||
-rw-r--r-- | mock-clamp/README.md | 1 | ||||
-rw-r--r-- | mock-clamp/clamp_handlers.go | 130 | ||||
-rw-r--r-- | mock-clamp/generic_handlers.go | 32 | ||||
-rw-r--r-- | mock-clamp/loop_handlers.go | 404 | ||||
-rw-r--r-- | mock-clamp/mock-clamp.go | 44 | ||||
-rw-r--r-- | mock-clamp/policies_handlers.go | 98 |
8 files changed, 754 insertions, 0 deletions
diff --git a/mock-clamp/.dockerignore b/mock-clamp/.dockerignore new file mode 100644 index 0000000..393fc3b --- /dev/null +++ b/mock-clamp/.dockerignore @@ -0,0 +1,13 @@ +# Binaries for programs and plugins +mock-clamp +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out
\ No newline at end of file diff --git a/mock-clamp/Dockerfile b/mock-clamp/Dockerfile new file mode 100644 index 0000000..12a3a07 --- /dev/null +++ b/mock-clamp/Dockerfile @@ -0,0 +1,32 @@ +FROM golang:1.17-alpine AS builder + +# Add all the source code (except what's ignored +# under `.dockerignore`) to the build context. +ADD ./ /go/src/ + +WORKDIR /go/src + +RUN apk add --no-cache git +RUN go mod init onap.com/mock-clamp +RUN go get github.com/satori/go.uuid +RUN go get github.com/labstack/echo +RUN go get github.com/dgrijalva/jwt-go + +RUN set -ex && \ + CGO_ENABLED=0 GOOS=linux go build \ + -tags netgo \ + -installsuffix cgo \ + -v -a \ + -ldflags '-extldflags "-static"' \ + -o mock-clamp . + +RUN ls -la + +FROM scratch + +# Retrieve the binary from the previous stage +COPY --from=builder /go/src/mock-clamp /app/mock-clamp +WORKDIR /app + +# Set the binary as the entrypoint of the container +ENTRYPOINT [ "./mock-clamp" ] diff --git a/mock-clamp/README.md b/mock-clamp/README.md new file mode 100644 index 0000000..53540d1 --- /dev/null +++ b/mock-clamp/README.md @@ -0,0 +1 @@ +# mock-clamp
\ No newline at end of file diff --git a/mock-clamp/clamp_handlers.go b/mock-clamp/clamp_handlers.go new file mode 100644 index 0000000..edccf22 --- /dev/null +++ b/mock-clamp/clamp_handlers.go @@ -0,0 +1,130 @@ +// Copyright 2023 Deutsche Telekom AG, Orange +// +// 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 main + +import ( + "net/http" + + "github.com/labstack/echo" + "github.com/satori/go.uuid" +) + +//describes loop template in Clamp database +type LoopTemplate struct { + Name string `json:"name"` + DcaeBlueprintId string `json:"dcaeBlueprintId"` + ModelService struct { + ServiceDetails struct { + Name string `json:"name"` + } `json:"serviceDetails"` + } `json:"modelService"` +} + +//describes policy in Clamp database +type Policy struct { + PolicyModelType string `json:"policyModelType"` + Version string `json:"version"` + PolicyAcronym string `json:"policyAcronym"` + CreatedDate string `json:"createdDate"` + UpdatedDate string `json:"updatedDate"` + UpdatedBy string `json:"updatedBy"` + CreatedBy string `json:"createdBy"` +} + +//ClampError is the way to return Error in CLAMP +type ClampError struct { + Message string `json:"message"` + Error string `json:"error"` + Status string `json:"status"` +} + +var templateList []LoopTemplate + +//must modify this function to generate template with service model name +func generateInitialTemplateList() { + templateList = nil + u1 := uuid.NewV4().String() + loop1 := new(LoopTemplate) + loop1.Name = "template_service01" + loop1.DcaeBlueprintId = u1 + loop1.ModelService.ServiceDetails.Name = "service01" + templateList = append(templateList, *loop1) + u2 := uuid.NewV4().String() + loop2 := new(LoopTemplate) + loop2.Name = "template_service02" + loop2.DcaeBlueprintId = u2 + loop2.ModelService.ServiceDetails.Name = "service02" + templateList = append(templateList, *loop2) +} + +var policyList []Policy + +func generateInitialPolicyList() { + policyList = nil + policyList = append(policyList, Policy{ + PolicyModelType: "onap.policies.controlloop.MinMax", + Version: "1.0.0", + PolicyAcronym: "MinMax", + CreatedDate: "2020-04-30T09:03:30.362897Z", + UpdatedDate: "2020-04-30T09:03:30.362897Z", + UpdatedBy: "Not found", + CreatedBy: "Not found", + }) + policyList = append(policyList, Policy{ + PolicyModelType: "onap.policies.controlloop.Guard", + Version: "1.0.0", + PolicyAcronym: "Guard", + CreatedDate: "2020-04-30T09:03:30.362897Z", + UpdatedDate: "2020-04-30T09:03:30.362897Z", + UpdatedBy: "Not found", + CreatedBy: "Not found", + }) + policyList = append(policyList, Policy{ + PolicyModelType: "onap.policies.controlloop.guard.common.FrequencyLimiter", + Version: "1.0.0", + PolicyAcronym: "FrequencyLimiter", + CreatedDate: "2020-04-30T09:03:30.362897Z", + UpdatedDate: "2020-04-30T09:03:30.362897Z", + UpdatedBy: "Not found", + CreatedBy: "Not found", + }) +} + +func getTemplates(c echo.Context) error { + var templates []LoopTemplate + for _, t := range templateList { + //service must be distributed from sdc + if t.DcaeBlueprintId != "" { + templates = append(templates, t) + } + } + if len(templates) != 0 { + return c.JSON(http.StatusOK, templates) + } + return c.JSON(http.StatusNotFound, ClampError{ + Message: "No Templates found", + Error: "Not Found", + Status: "404"}) +} + +func getPolicies(c echo.Context) error { + if len(policyList) != 0 { + return c.JSON(http.StatusOK, policyList) + } + return c.JSON(http.StatusNotFound, ClampError{ + Message: "No Policies found", + Error: "Not Found", + Status: "404"}) +} diff --git a/mock-clamp/generic_handlers.go b/mock-clamp/generic_handlers.go new file mode 100644 index 0000000..a636ea1 --- /dev/null +++ b/mock-clamp/generic_handlers.go @@ -0,0 +1,32 @@ +// Copyright 2023 Deutsche Telekom AG, Orange +// +// 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 main + +import ( + "net/http" + + "github.com/labstack/echo" +) + +func index(c echo.Context) error { + return c.String(http.StatusOK, "Hello, World!") +} + +func reset(c echo.Context) error { + generateInitialTemplateList() + generateInitialPolicyList() + generateInitialLoopInstances() + return c.String(http.StatusCreated, "reset done!") +} diff --git a/mock-clamp/loop_handlers.go b/mock-clamp/loop_handlers.go new file mode 100644 index 0000000..ff8a552 --- /dev/null +++ b/mock-clamp/loop_handlers.go @@ -0,0 +1,404 @@ +// Copyright 2023 Deutsche Telekom AG, Orange +// +// 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 main + +import ( + "net/http" + "time" + + "github.com/labstack/echo" + uuid "github.com/satori/go.uuid" +) + +//describes the loop state in term of policy and DCAE +type State struct { + ComponentState struct { + StateName string `json:"stateName"` + } `json:"componentState"` +} + +//describes entity id in CLAMP got from SDC +type Resource struct { + ResourceID struct { + VfModuleModelName string `json:"vfModuleModelName"` + VfModuleModelInvariantUUID string `json:"vfModuleModelInvariantUUID"` + VfModuleModelUUID string `json:"vfModuleModelUUID"` + VfModuleModelVersion string `json:"vfModuleModelVersion"` + VfModuleModelCustomizationUUID string `json:"vfModuleModelCustomizationUUID"` + } `json:"resourceID"` +} + +//frequency limiter configuration +type Frequency_payload struct { + ID string `json:"id"` + Actor string `json:"actor"` + Operation string `json:"operation"` + Limit int `json:"limit"` + TimeWindow int `json:"timeWindow"` + TimeUnits string `json:"timeUnits"` +} + +/* +//describes operational policy configuration in CLAMP +type OperationalPolicy struct { + Name string `json:"name"` + PolicyModel Policy `json:"policyModel"` + ConfigurationsJson struct{ Frequency_payload } `json:"configurationsJson"` //depends on operational policy model +} +*/ +//describes TCA POLICY in CLAMP +type Tca_policy struct { + Domain string `json:"Domain"` + MetricsPerEventName []struct { + PolicyScope string `json:"policyScope"` + Thresholds []struct { + Version string `json:"version"` + Severity string `json:"severity"` + ThresholdValue int `json:"thresholdValue"` + ClosedLoopEventStatus string `json:"closedLoopEventStatus"` + ClosedLoopControlName string `json:"closedLoopControlName"` + Direction string `json:"direction"` + FieldPath string `json:"fieldPath"` + } `json:"thresholds"` + EventName string `json:"eventName"` + PolicyVersion string `json:"policyVersion"` + ControlLoopSchemaType string `json:"controlLoopSchemaType"` + PolicyName string `json:"policyName"` + } `json:"metricsPerEventName"` +} + +//describes TCA POLICY payload in CLAMP +type Tca_policy_struct struct { + TcaPolicy Tca_policy `json:"tca.policy"` +} + +//describes microservice policy configuration in CLAMP +type MicroServicePolicy struct { + Name string `json:"name"` + ConfigurationsJson Tca_policy_struct `json:"configurationsJson"` + PdpGroup string `json:"pdpGroup"` + PdpSubgroup string `json:"pdpSubgroup"` +} + +//LoopDetails describes loop innstance in CLAMP +type LoopDetails struct { + Name string `json:"name"` + Template LoopTemplate `json:"loopTemplate"` + GlobalPropertiesJSON struct { + DcaeDeployParameters struct { + UniqueBlueprintParameters struct { + PolicyID string `json:"policy_id"` + } `json:"uniqueBlueprintParameters"` + } `json:"dcaeDeployParameters"` + } `json:"globalPropertiesJson"` + LoopElementModelsUsed []string `json:"loopElementModelsUsed"` //microservices from sdc + Components struct { + POLICY State `json:"POLICY"` + DCAE State `json:"DCAE"` + } `json:"components"` + ModelService struct { + ResourceDetails struct { + VFModule Resource `json:"VFModule"` + } `json:"resourceDetails"` + } `json:"modelService"` + OperationalPolicies []OperationalPolicy_payload `json:"operationalPolicies"` + MicroServicePolicies []MicroServicePolicy `json:"microServicePolicies"` +} + +var loopInstanceList []LoopDetails + +func generateInitialLoopInstances() { + loopInstanceList = nil + loop1 := new(LoopDetails) + loop1.Template = templateList[0] + loop1.Name = "intance_template01" + loopInstanceList = append(loopInstanceList, *loop1) + loop2 := new(LoopDetails) + loop2.Name = "intance_template02" + loop2.Template = templateList[1] + loopInstanceList = append(loopInstanceList, *loop2) +} + +func updateLoopDetails(c echo.Context) error { + loopID := c.Param("loopID") + for _, loop := range loopInstanceList { + if loop.Name == loopID { + return c.JSON(http.StatusOK, loop) + } + } + return c.JSON(http.StatusNotFound, ClampError{ + Message: "No ClosedLoop found", + Error: "Not Found", + Status: "404"}) +} + +func createLoopInstance(c echo.Context) error { + loopID := c.Param("loopID") + templateName := c.QueryParam("templateName") + loop := new(LoopDetails) + + //must add the constraint of limit number of instances for a template + for _, l := range loopInstanceList { + if l.Name == loopID && + l.Template.Name == templateName { + //in reality it's overwritten + return c.JSON(http.StatusBadRequest, ClampError{ + Message: "loop of same Name and for same template exists", + Error: "Exists", + Status: "500"}) + } + } + loop.Name = loopID + loop.Template.Name = templateName + //For drools configuration + resource := new(Resource) + resource.ResourceID.VfModuleModelUUID = uuid.NewV4().String() + resource.ResourceID.VfModuleModelName = uuid.NewV4().String() + resource.ResourceID.VfModuleModelInvariantUUID = uuid.NewV4().String() + resource.ResourceID.VfModuleModelVersion = uuid.NewV4().String() + resource.ResourceID.VfModuleModelCustomizationUUID = uuid.NewV4().String() + loop.ModelService.ResourceDetails.VFModule = *resource + //must generate as much microservices as tca blueprints count + loop.LoopElementModelsUsed = append(loop.LoopElementModelsUsed, "microservice01") + nb_microservices := len(loop.LoopElementModelsUsed) + for i := 0; i < nb_microservices; i++ { + loop.MicroServicePolicies = append(loop.MicroServicePolicies, MicroServicePolicy{ + Name: "Microservice" + uuid.NewV4().String(), + }) + } + loop.GlobalPropertiesJSON.DcaeDeployParameters.UniqueBlueprintParameters.PolicyID = "Microservice" + uuid.NewV4().String() + state := new(State) + state.ComponentState.StateName = "NOT_SENT" + loop.Components.POLICY = *state + state.ComponentState.StateName = "BLUEPRINT_DEPLOYED" + loop.Components.DCAE = *state + + loopInstanceList = append(loopInstanceList, *loop) + return c.JSON(http.StatusCreated, *loop) +} + +func addOperationaPolicy(c echo.Context) error { + loopID := c.Param("loopID") + policyType := c.Param("policyType") + policyVersion := c.Param("policyVersion") + op_policy := new(struct { + PolicyModelType string `json:"policyModelType"` + Version string `json:"version"` + PolicyAcronym string `json:"policyAcronym"` + PolicyPdpGroup struct { + SupportedPdpGroups []struct { + DefaultGroup []string `json:"defaultGroup"` + } `json:"supportedPdpGroups"` + } `json:"policyPdpGroup"` + CreatedDate time.Time `json:"createdDate"` + UpdatedDate time.Time `json:"updatedDate"` + UpdatedBy string `json:"updatedBy"` + CreatedBy string `json:"createdBy"` + }) + for _, p := range policyList { + if p.PolicyModelType == policyType && + p.Version == policyVersion { + for j, l := range loopInstanceList { + if l.Name == loopID { + op_policy.PolicyAcronym = p.PolicyAcronym + loopInstanceList[j].OperationalPolicies = append(loopInstanceList[j].OperationalPolicies, + OperationalPolicy_payload{ + Name: "OPERATIONAL" + uuid.NewV4().String(), + PolicyModel: *op_policy, + }) + return c.JSON(http.StatusOK, loopInstanceList[j]) + } + } + return c.JSON(http.StatusBadRequest, ClampError{ + Message: "loop not found", + Error: "Not Found", + Status: "404"}) + } + } + return c.JSON(http.StatusBadRequest, ClampError{ + Message: "Policy not found", + Error: "Not Found", + Status: "404"}) +} + +//remove operation is not working in the real CLAMP +func removeOperationaPolicy(c echo.Context) error { + loopID := c.Param("loopID") + policyType := c.Param("policyType") + policyVersion := c.Param("policyVersion") + + for j, l := range loopInstanceList { + if l.Name == loopID { + for i, pp := range l.OperationalPolicies { + if pp.PolicyModel.PolicyModelType == policyType && + pp.PolicyModel.Version == policyVersion { + loopInstanceList[j].OperationalPolicies = append(loopInstanceList[j].OperationalPolicies[:i], + loopInstanceList[j].OperationalPolicies[i+1:]...) + return c.JSON(http.StatusOK, l) + } + } + return c.JSON(http.StatusBadRequest, ClampError{ + Message: "Policy not found", + Error: "Not Found", + Status: "404"}) + } + } + return c.JSON(http.StatusBadRequest, ClampError{ + Message: "loop not found", + Error: "Not Found", + Status: "404"}) +} + +//must review tca_policy struct +func addTcaConfig(c echo.Context) error { + loopID := c.Param("loopID") + data := new(MicroServicePolicy) + if err := c.Bind(data); err != nil { + return err + } + for j, l := range loopInstanceList { + if l.Name == loopID { + if l.MicroServicePolicies != nil { + for i, _ := range l.MicroServicePolicies { + loopInstanceList[j].MicroServicePolicies[i] = *data + } + return c.JSON(http.StatusOK, loopInstanceList[j].MicroServicePolicies[0]) + } + return c.JSON(http.StatusBadRequest, ClampError{ + Message: "Microservice policy not found", + Error: "Not Found", + Status: "404"}) + } + } + return c.JSON(http.StatusBadRequest, ClampError{ + Message: "Loop not found", + Error: "Not Found", + Status: "404"}) +} + +func addOperationalPolicyConfig(c echo.Context) error { + loopID := c.Param("loopID") + for j, l := range loopInstanceList { + if l.Name == loopID { + /* + //cannot bind a list as said in labstack echo bind + data := new([]OperationalPolicy_payload) + if err := c.Bind(data); err != nil { + return err + } + */ + if l.OperationalPolicies != nil { + //loopInstanceList[j].OperationalPolicies = *data + loopInstanceList[j].OperationalPolicies[len(l.OperationalPolicies)-1].ConfigurationsJSON.Actor = "Test" + return c.JSON(http.StatusOK, loopInstanceList[j]) + } + return c.JSON(http.StatusBadRequest, ClampError{ + Message: "Operational Policy not found", + Error: "Not Found", + Status: "404"}) + } + } + return c.JSON(http.StatusBadRequest, ClampError{ + Message: "Loop not found", + Error: "Not Found", + Status: "404"}) +} + +//util function +func checkPoliciesConfiguration(l LoopDetails) bool { + var empty struct { + Actor string `json:"actor"` + Operation string `json:"operation"` + Limit int `json:"limit"` + TimeWindow int `json:"timeWindow"` + TimeUnits string `json:"timeUnits"` + } + + for i, _ := range l.MicroServicePolicies { + if l.MicroServicePolicies[i].ConfigurationsJson.TcaPolicy.Domain == "" { + return false + } + } + for i, _ := range l.OperationalPolicies { + if l.OperationalPolicies[i].ConfigurationsJSON == empty { + return false + } + } + return true +} + +func putLoopAction(c echo.Context) error { + action := c.Param("action") + loopID := c.Param("loopID") + state := new(State) + for j, l := range loopInstanceList { + if l.Name == loopID { + //POLICY actions + if action == "submit" { + if checkPoliciesConfiguration(loopInstanceList[j]) { + state.ComponentState.StateName = "SENT_AND_DEPLOYED" + loopInstanceList[j].Components.POLICY = *state + return c.JSON(http.StatusOK, loopInstanceList[j].Components.POLICY.ComponentState) + } + return c.JSON(http.StatusBadRequest, ClampError{ + Message: "Policies are not well Configured", + Error: "Bad Action", + Status: "401"}) + } + if action == "stop" { + if l.Components.POLICY.ComponentState.StateName == "NOT_SENT" { + return c.JSON(http.StatusBadRequest, ClampError{ + Message: "Cannot perform this action", + Error: "Bad Action", + Status: "400"}) + } + state.ComponentState.StateName = "SENT" + loopInstanceList[j].Components.POLICY = *state + return c.JSON(http.StatusOK, "{}") + } + if action == "restart" { + state.ComponentState.StateName = "SENT_AND_DEPLOYED" + loopInstanceList[j].Components.POLICY = *state + return c.JSON(http.StatusOK, "{}") + } + //DCAE actions + if action == "deploy" { + //must add deploy failure + state.ComponentState.StateName = "MICROSERVICE_INSTALLED_SUCCESSFULLY" + loopInstanceList[j].Components.DCAE = *state + return c.JSON(http.StatusOK, "{}") + } + if action == "undeploy" { + state.ComponentState.StateName = "MICROSERVICE_UNINSTALLED_SUCCESSFULLY" + loopInstanceList[j].Components.DCAE = *state + return c.JSON(http.StatusOK, "{}") + } + //LOOP action + if action == "delete" { + loopInstanceList = append(loopInstanceList[:j], loopInstanceList[j+1:]...) + return c.JSON(http.StatusOK, "{}") + } + //action failure + return c.JSON(http.StatusBadRequest, ClampError{ + Message: "Cannot perform this action", + Error: "Bad Action", + Status: "400"}) + } + } + return c.JSON(http.StatusBadRequest, ClampError{ + Message: "Loop not found", + Error: "Not Found", + Status: "404"}) +} diff --git a/mock-clamp/mock-clamp.go b/mock-clamp/mock-clamp.go new file mode 100644 index 0000000..6e82d7f --- /dev/null +++ b/mock-clamp/mock-clamp.go @@ -0,0 +1,44 @@ +// Copyright 2023 Deutsche Telekom AG, Orange +// +// 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 main + +import ( + "github.com/labstack/echo" + "github.com/labstack/echo/middleware" + "github.com/labstack/gommon/log" +) + +func main() { + e := echo.New() + e.Use(middleware.Logger()) + e.Logger.SetLevel(log.DEBUG) + e.GET("/", index) + e.GET("/restservices/clds/v2/templates/", getTemplates) + e.GET("/restservices/clds/v2/policyToscaModels/", getPolicies) + + e.GET("/restservices/clds/v2/loop/:loopID", updateLoopDetails) + e.GET("/restservices/clds/v2/loop/getstatus/:loopID", updateLoopDetails) //refresh status + e.POST("/restservices/clds/v2/loop/create/:loopID", createLoopInstance) + e.PUT("/restservices/clds/v2/loop/addOperationaPolicy/:loopID/policyModel/:policyType/:policyVersion", addOperationaPolicy) + e.PUT("/restservices/clds/v2/loop/removeOperationaPolicy/:loopID/policyModel/:policyType/:policyVersion", removeOperationaPolicy) + e.POST("/restservices/clds/v2/loop/updateMicroservicePolicy/:loopID", addTcaConfig) //modify + e.POST("/restservices/clds/v2/loop/updateOperationalPolicies/:loopID", addOperationalPolicyConfig) //modify + e.PUT("/restservices/clds/v2/loop/:action/:loopID", putLoopAction) + e.POST("/reset", reset) + generateInitialTemplateList() + generateInitialPolicyList() + generateInitialLoopInstances() + e.Logger.Fatal(e.Start(":30258")) +} diff --git a/mock-clamp/policies_handlers.go b/mock-clamp/policies_handlers.go new file mode 100644 index 0000000..52cc04a --- /dev/null +++ b/mock-clamp/policies_handlers.go @@ -0,0 +1,98 @@ +// Copyright 2023 Deutsche Telekom AG, Orange +// +// 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 main + +import "time" + +//describes operational policy configuration in CLAMP +type OperationalPolicy_payload struct { + Name string `json:"name"` + JSONRepresentation struct { + Title string `json:"title"` + Type string `json:"type"` + Description string `json:"description"` + Required []string `json:"required"` + Properties struct { + ID struct { + Type string `json:"type"` + Description string `json:"description"` + } `json:"id"` + Actor struct { + Type string `json:"type"` + Description string `json:"description"` + } `json:"actor"` + Operation struct { + Type string `json:"type"` + Description string `json:"description"` + } `json:"operation"` + TimeRange struct { + Title string `json:"title"` + Type string `json:"type"` + Required []string `json:"required"` + Properties struct { + StartTime struct { + Type string `json:"type"` + Format string `json:"format"` + } `json:"start_time"` + EndTime struct { + Type string `json:"type"` + Format string `json:"format"` + } `json:"end_time"` + } `json:"properties"` + } `json:"timeRange"` + Limit struct { + Type string `json:"type"` + Description string `json:"description"` + ExclusiveMinimum string `json:"exclusiveMinimum"` + } `json:"limit"` + TimeWindow struct { + Type string `json:"type"` + Description string `json:"description"` + } `json:"timeWindow"` + TimeUnits struct { + Type string `json:"type"` + Description string `json:"description"` + Enum []string `json:"enum"` + } `json:"timeUnits"` + } `json:"properties"` + } `json:"jsonRepresentation"` + ConfigurationsJSON struct { + Actor string `json:"actor"` + Operation string `json:"operation"` + Limit int `json:"limit"` + TimeWindow int `json:"timeWindow"` + TimeUnits string `json:"timeUnits"` + } `json:"configurationsJson"` + PolicyModel struct { + PolicyModelType string `json:"policyModelType"` + Version string `json:"version"` + PolicyAcronym string `json:"policyAcronym"` + PolicyPdpGroup struct { + SupportedPdpGroups []struct { + DefaultGroup []string `json:"defaultGroup"` + } `json:"supportedPdpGroups"` + } `json:"policyPdpGroup"` + CreatedDate time.Time `json:"createdDate"` + UpdatedDate time.Time `json:"updatedDate"` + UpdatedBy string `json:"updatedBy"` + CreatedBy string `json:"createdBy"` + } `json:"policyModel"` + CreatedDate time.Time `json:"createdDate"` + UpdatedDate time.Time `json:"updatedDate"` + UpdatedBy string `json:"updatedBy"` + CreatedBy string `json:"createdBy"` + PdpGroup string `json:"pdpGroup"` + PdpSubgroup string `json:"pdpSubgroup"` +} |