summaryrefslogtreecommitdiffstats
path: root/mock-sdc
diff options
context:
space:
mode:
authorMichal Jagiello <michal.jagiello@t-mobile.pl>2023-03-13 11:00:21 +0000
committerMichal Jagiello <michal.jagiello@t-mobile.pl>2023-03-14 14:25:16 +0000
commit870ff702088b89549bc21631eb48443fff0bcd71 (patch)
tree5d52aca25035644bdc2ac687275ed858ba524e7e /mock-sdc
parent98e0e65ba145ab4c85c301118d4a0d02940221ec (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-sdc')
-rw-r--r--mock-sdc/.dockerignore16
-rw-r--r--mock-sdc/Dockerfile33
-rw-r--r--mock-sdc/README.md2
-rw-r--r--mock-sdc/generic_handlers.go32
-rw-r--r--mock-sdc/mock-sdc.go71
-rw-r--r--mock-sdc/resource_handlers.go1379
-rw-r--r--mock-sdc/sdc_handlers.go210
-rw-r--r--mock-sdc/vendor_handlers.go185
-rw-r--r--mock-sdc/vsp_handlers.go418
9 files changed, 2346 insertions, 0 deletions
diff --git a/mock-sdc/.dockerignore b/mock-sdc/.dockerignore
new file mode 100644
index 0000000..53b2e85
--- /dev/null
+++ b/mock-sdc/.dockerignore
@@ -0,0 +1,16 @@
+# Binaries for programs and plugins
+mock-sdc
+*.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
+
+# Dependency directories (remove the comment below to include it)
+# vendor/
diff --git a/mock-sdc/Dockerfile b/mock-sdc/Dockerfile
new file mode 100644
index 0000000..524c178
--- /dev/null
+++ b/mock-sdc/Dockerfile
@@ -0,0 +1,33 @@
+FROM golang: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 env -w GO111MODULE=auto
+RUN go get github.com/satori/go.uuid
+RUN go get github.com/labstack/echo
+RUN go get github.com/golang-jwt/jwt
+RUN go get golang.org/x/time/rate
+
+RUN set -ex && \
+ CGO_ENABLED=0 GOOS=linux go build \
+ -tags netgo \
+ -installsuffix cgo \
+ -v -a \
+ -ldflags '-extldflags "-static"' \
+ -o mock-sdc .
+
+RUN ls -la
+
+FROM scratch
+
+# Retrieve the binary from the previous stage
+COPY --from=builder /go/src/mock-sdc /app/mock-sdc
+WORKDIR /app
+
+# Set the binary as the entrypoint of the container
+ENTRYPOINT [ "./mock-sdc" ]
diff --git a/mock-sdc/README.md b/mock-sdc/README.md
new file mode 100644
index 0000000..ae7ae66
--- /dev/null
+++ b/mock-sdc/README.md
@@ -0,0 +1,2 @@
+# mock-sdc
+
diff --git a/mock-sdc/generic_handlers.go b/mock-sdc/generic_handlers.go
new file mode 100644
index 0000000..a24cb45
--- /dev/null
+++ b/mock-sdc/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 {
+ generateInitialVendorList()
+ generateInitialVspList()
+ generateInitialResourceList()
+ return c.String(http.StatusCreated, "reset done!")
+}
diff --git a/mock-sdc/mock-sdc.go b/mock-sdc/mock-sdc.go
new file mode 100644
index 0000000..0b53afe
--- /dev/null
+++ b/mock-sdc/mock-sdc.go
@@ -0,0 +1,71 @@
+// 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("/sdc1/feProxy/onboarding-api/v1.0/items/:itemID/versions", getItemVersions)
+ e.GET("/sdc1/feProxy/onboarding-api/v1.0/items/:itemID/versions/:versionID", getItemVersion)
+ e.PUT("/sdc1/feProxy/onboarding-api/v1.0/items/:itemID/versions/:versionID/actions", updateItemVersion)
+ e.GET("/sdc1/feProxy/onboarding-api/v1.0/vendor-license-models", getVendorServiceModels)
+ e.POST("/sdc1/feProxy/onboarding-api/v1.0/vendor-license-models", postVendorServiceModels)
+ e.PUT("/sdc1/feProxy/onboarding-api/v1.0/vendor-license-models/:vendorID/versions/:versionID/actions", updateVendorVersion)
+ e.GET("/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products", getVendorSoftwareProducts)
+ e.POST("/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products", postVendorSoftwareProducts)
+ e.GET("/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/:vspID/versions/:versionID", getVspVersion)
+ e.PUT("/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/:vspID/versions/:versionID/actions", updateVspVersion)
+ e.POST("/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/:vspID/versions/:versionID/orchestration-template-candidate", uploadArtifacts)
+ e.PUT("/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/:vspID/versions/:versionID/orchestration-template-candidate/process", validateArtifacts)
+ e.GET("/sdc1/feProxy/rest/v1/followed", getAllResources)
+ e.GET("/sdc1/feProxy/rest/v1/screen", getAllResources)
+ e.GET("/sdc/v1/catalog/resources", getResources)
+ e.GET("/sdc/v1/catalog/services", getServices)
+ e.GET("/sdc/v1/artifactTypes", getArtifactTypes)
+ e.GET("/sdc/v1/distributionKafkaData", distributionKafkaData)
+ e.POST("/sdc/v1/registerForDistribution", registerForDistribution)
+ e.POST("/sdc/v1/unRegisterForDistribution", unRegisterForDistribution)
+ e.POST("/sdc1/feProxy/rest/v1/catalog/resources", postResources)
+ e.POST("/sdc1/feProxy/rest/v1/catalog/resources/:resourceID/lifecycleState/:action", postResourceAction)
+ e.POST("/sdc1/feProxy/rest/v1/catalog/services", postResources)
+ e.POST("/sdc1/feProxy/rest/v1/catalog/services/:resourceID/resourceInstance", postAddResourceToService)
+ e.POST("/sdc1/feProxy/rest/v1/catalog/services/:resourceID/lifecycleState/:action", postResourceAction)
+ e.POST("/sdc1/feProxy/rest/v1/catalog/services/:resourceID/distribution-state/:action", postResourceAction)
+ e.POST("/sdc1/feProxy/rest/v1/catalog/services/:resourceID/distribution/PROD/:action", postResourceAction)
+ e.GET("/sdc1/feProxy/rest/v1/catalog/services/:resourceID/distribution", getDistribution)
+ e.GET("/sdc1/feProxy/rest/v1/catalog/services/distribution/:distributionID", getDistributionList)
+ e.GET("/sdc1/feProxy/rest/v1/catalog/services/:resourceID", getServiceUniqueIdentifier)
+ e.POST("/sdc1/feProxy/rest/v1/catalog/services/:resourceID/resourceInstance/:vfID/artifacts", uploadTcaArtifact)
+ e.POST("/sdc1/feProxy/rest/v1/catalog/services/:resourceID/properties", postResourceProperties)
+ e.POST("/sdc1/feProxy/rest/v1/catalog/services/:resourceID/create/inputs", postResourceInputs)
+ e.POST("/sdc1/feProxy/rest/v1/catalog/resources/:resourceID/create/inputs", postResourceInputs)
+ e.GET("/sdc1/feProxy/rest/v1/catalog/resources/:resourceID/filteredDataByParams", getResourcefilteredData)
+ e.GET("/sdc1/feProxy/rest/v1/catalog/services/:resourceID/filteredDataByParams", getResourcefilteredData)
+ e.GET("/sdc1/feProxy/rest/v1/setup/ui", getCategories)
+ e.POST("/reset", reset)
+ generateInitialVendorList()
+ generateInitialVspList()
+ generateInitialResourceList()
+ generateDistributionStatusList()
+ e.Logger.Fatal(e.Start(":30206"))
+}
diff --git a/mock-sdc/resource_handlers.go b/mock-sdc/resource_handlers.go
new file mode 100644
index 0000000..53aa98f
--- /dev/null
+++ b/mock-sdc/resource_handlers.go
@@ -0,0 +1,1379 @@
+// 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 (
+ "container/list"
+ "encoding/json"
+ "net/http"
+ "errors"
+ "io/ioutil"
+
+ "github.com/labstack/echo"
+ uuid "github.com/satori/go.uuid"
+)
+
+// ResourceLight describes license model in SDC
+type ResourceLight struct {
+ ID string `json:"uuid"`
+ InvariantID string `json:"invariantUUID"`
+ ResourceType string `json:"resourceType"`
+ Name string `json:"name"`
+ Category string `json:"category"`
+ SubCategory string `json:"subCategory"`
+ LastUpdaterUserID string `json:"lastUpdaterUserId"`
+ LifecycleState string `json:"lifecycleState"`
+ Version string `json:"version"`
+ ToscaModelURL string `json:"toscaModelURL"`
+ DistributionStatus string `json:"distributionStatus"`
+}
+
+// SubCategory describes SubCategory model in SDC
+type SubCategory struct {
+ Name string `json:"name"`
+ NormalizedName string `json:"normalizedName"`
+ UniqueID string `json:"uniqueId"`
+ Icons []string `json:"icons"`
+ Groupings string `json:"groupings"`
+ OwnerID string `json:"ownerId"`
+ Empty bool `json:"empty"`
+ Version string `json:"version"`
+ Type string `json:"type"`
+}
+
+// Category describes Category model in SDC
+type Category struct {
+ Name string `json:"name"`
+ NormalizedName string `json:"normalizedName"`
+ UniqueID string `json:"uniqueId"`
+ Icons []string `json:"icons"`
+ Subcategories []SubCategory `json:"subcategories"`
+ OwnerID string `json:"ownerId"`
+ Empty bool `json:"empty"`
+ Type string `json:"type"`
+ Version string `json:"version"`
+}
+
+//ArtifactAdd Describes ressource component Instances artifacts in SDC
+type ArtifactAdd struct {
+ ArtifactName string `json:"artifactName"`
+ ArtifactLabel string `json:"artifactLabel"`
+ ArtifactType string `json:"artifactType"`
+ Description string `json:"description"`
+}
+
+//ComponentInstance Describes ressource component Instances in SDC
+type ComponentInstance struct {
+ UniqueID string `json:"uniqueId"`
+ Name string `json:"name"`
+ ComponentName string `json:"componentName"`
+ OriginType string `json:"originType"`
+ ComponentVersion string `json:"componentVersion"`
+ DeploymentArtifacts []ArtifactAdd `json:"deploymentArtifacts"`
+}
+
+// Resource describes Resource model in SDC
+type Resource struct {
+ ID string `json:"uuid"`
+ InvariantID string `json:"invariantUUID"`
+ UniqueID string `json:"uniqueId"`
+ ResourceType string `json:"resourceType"`
+ Name string `json:"name"`
+ Category string `json:"category"`
+ SubCategory string `json:"subCategory"`
+ LastUpdaterUserID string `json:"lastUpdaterUserId"`
+ LifecycleState string `json:"lifecycleState"`
+ Version string `json:"version"`
+ ToscaModelURL string `json:"toscaModelURL"`
+ Artifacts struct{} `json:"artifacts"`
+ Attributes []string `json:"attributes"`
+ Capabilities struct{} `json:"capabilities"`
+ Categories []Category `json:"categories"`
+ ComponentInstances []ComponentInstance `json:"componentInstances"`
+ ComponentInstancesAttributes struct{} `json:"componentInstancesAttributes"`
+ ComponentInstancesProperties struct{} `json:"componentInstancesProperties"`
+ ComponentType string `json:"componentType"`
+ ContactID string `json:"contactId"`
+ CsarUUID string `json:"csarUUID"`
+ CsarVersion string `json:"csarVersion"`
+ DeploymentArtifacts struct{} `json:"deploymentArtifacts"`
+ Description string `json:"description"`
+ Icon string `json:"icon"`
+ Properties []Property `json:"properties"`
+ Requirements struct{} `json:"requirements"`
+ Tags []string `json:"tags"`
+ ToscaArtifacts struct{} `json:"toscaArtifacts"`
+ VendorName string `json:"vendorName"`
+ VendorRelease string `json:"vendorRelease"`
+ DistributionStatus string `json:"distributionStatus"`
+ DistributionID string `json:"distributionID"`
+ Inputs []Input
+}
+
+// ResourceList is the way to return Resources in SDC via DeepLoad
+type ResourceList struct {
+ Resources []Resource `json:"resources"`
+ Services []Resource `json:"services"`
+}
+
+// ActionBody yolo
+type ActionBody struct {
+ UserRemarks string `json:"userRemarks"`
+}
+
+// ResourceAdd to a Service
+type ResourceAdd struct {
+ Name string `json:"name"`
+ ComponentVersion string `json:"componentVersion"`
+ PosY int `json:"posY"`
+ PosX int `json:"posX"`
+ UniqueID string `json:"uniqueId"`
+ OriginType string `json:"originType"`
+ ComponentUID string `json:"componentUid"`
+ Icon string `json:"icon"`
+}
+
+// DistributionIDResult format
+type DistributionIDResult struct {
+ DistributionID string `json:"distributionID"`
+ UserID string `json:"userId"`
+ DeployementStatus string `json:"deployementStatus"`
+}
+
+// DistributionIDList format
+type DistributionIDList struct {
+ DistributionStatusOfServiceList []DistributionIDResult `json:"distributionStatusOfServiceList"`
+}
+
+//DistributionStatus format
+type DistributionStatus struct {
+ OmfComponentID string `json:"omfComponentID"`
+ Timestamp string `json:"timestamp"`
+ URL string `json:"url"`
+ Status string `json:"status"`
+ ErrorReason string `json:"errorReason"`
+}
+
+// DistributionStatusList format
+type DistributionStatusList struct {
+ DistributionStatusList []DistributionStatus `json:"distributionStatusList"`
+}
+
+// NewUploadResult format
+type NewUploadResult struct {
+ Description string `json:"description"`
+ ArtifactType string `json:"artifactType"`
+ ArtifactName string `json:"artifactName"`
+}
+
+//Property format
+type Property struct {
+ Name string `json:"name"`
+ Value string `json:"value"`
+ Type string `json:"type"`
+ UniqueID string `json:"uniqueId"`
+ ParentUniqueID string `json:"parentUniqueId"`
+}
+
+//Input format
+type Input struct {
+ Name string `json:"name"`
+ Value string `json:"value"`
+ Type string `json:"type"`
+ UniqueID string `json:"uniqueId"`
+}
+
+var resourceList []Resource
+var distributionList []DistributionStatus
+
+func generateInitialResourceList() {
+ resourceList = nil
+ resourceList = append(resourceList, Resource{
+ ID: "6c4952d2-0ecc-4697-a039-d9766565feae",
+ InvariantID: "803cbaf5-deea-4022-a731-709d285435d6",
+ UniqueID: "1e6e90ec-632a-492f-9511-f2787a2befaf",
+ ResourceType: "Configuration",
+ Name: "VLAN Network Receptor Configuration",
+ Category: "Configuration",
+ SubCategory: "Configuration",
+ LastUpdaterUserID: "jh0003",
+ LifecycleState: "CERTIFIED",
+ Version: "1.0",
+ ToscaModelURL: "/sdc/v1/catalog/resources/6c4952d2-0ecc-4697-a039-d9766565feae/toscaModel",
+ })
+ resourceList = append(resourceList, Resource{
+ ID: "85a9a912-b0ca-4cc9-9dc4-a480546ef93b",
+ InvariantID: "2df7615c-38f5-45e2-ac40-f9a8f97baec2",
+ UniqueID: "1e6e90ec-632a-492f-9511-f2787a2befaf",
+ ResourceType: "CP",
+ Name: "contrailV2VLANSubInterfaceV2",
+ Category: "Generic",
+ SubCategory: "Network Elements",
+ LastUpdaterUserID: "jh0003",
+ LifecycleState: "CERTIFIED",
+ Version: "1.0",
+ ToscaModelURL: "/sdc/v1/catalog/resources/85a9a912-b0ca-4cc9-9dc4-a480546ef93b/toscaModel",
+ })
+ resourceList = append(resourceList, Resource{
+ ID: "7c6b6644-590d-4e60-84d7-0dfba3ad4694",
+ InvariantID: "1e6e90ec-632a-492f-9511-f2787a2bef9f",
+ UniqueID: "1e6e90ec-632a-492f-9511-f2787a2befaf",
+ ResourceType: "VFC",
+ Name: "VDU Compute",
+ Category: "Generic",
+ SubCategory: "Infrastructure",
+ LastUpdaterUserID: "jh0003",
+ LifecycleState: "CERTIFIED",
+ Version: "1.0",
+ ToscaModelURL: "/sdc/v1/catalog/resources/7c6b6644-590d-4e60-84d7-0dfba3ad4694/toscaModel",
+ })
+ resourceList = append(resourceList, Resource{
+ ID: "9391354f-8f25-462d-b331-841e6cc5c851",
+ InvariantID: "85cd3f14-cb9c-4a28-811b-d076e9a48303",
+ UniqueID: "1e6e90ec-632a-492f-9511-f2787a2befaf",
+ ResourceType: "VFC",
+ Name: "Cp",
+ Category: "Generic",
+ SubCategory: "Infrastructure",
+ LastUpdaterUserID: "jh0003",
+ LifecycleState: "CERTIFIED",
+ Version: "1.0",
+ ToscaModelURL: "/sdc/v1/catalog/resources/9391354f-8f25-462d-b331-841e6cc5c851/toscaModel",
+ })
+}
+
+func getResources(c echo.Context) error {
+ resourceType := c.QueryParam("resourceType")
+ resources := []ResourceLight{}
+ for _, r := range resourceList {
+ if (r.ComponentType != "SERVICE") &&
+ ((resourceType == "") || (r.ResourceType == resourceType)) {
+ resources = append(resources, ResourceLight{
+ ID: r.ID,
+ InvariantID: r.InvariantID,
+ ResourceType: r.ResourceType,
+ Name: r.Name,
+ Category: r.Category,
+ SubCategory: r.SubCategory,
+ LastUpdaterUserID: r.LastUpdaterUserID,
+ LifecycleState: r.LifecycleState,
+ Version: r.Version,
+ ToscaModelURL: r.ToscaModelURL,
+ })
+ }
+ }
+ if len(resources) != 0 {
+ return c.JSON(http.StatusOK, resources)
+ }
+ return c.JSON(http.StatusNotFound, SdcError{
+ Message: "No Resources found",
+ ErrorCode: "SVC4642",
+ Status: "Not Found"})
+}
+
+func getServices(c echo.Context) error {
+ resources := []ResourceLight{}
+ for _, r := range resourceList {
+ if r.ComponentType == "SERVICE" {
+ resources = append(resources, ResourceLight{
+ ID: r.ID,
+ InvariantID: r.InvariantID,
+ ResourceType: r.ResourceType,
+ Name: r.Name,
+ Category: r.Category,
+ SubCategory: r.SubCategory,
+ LastUpdaterUserID: r.LastUpdaterUserID,
+ LifecycleState: r.LifecycleState,
+ Version: r.Version,
+ ToscaModelURL: r.ToscaModelURL,
+ DistributionStatus: r.DistributionStatus,
+ })
+ }
+ }
+ if len(resources) != 0 {
+ return c.JSON(http.StatusOK, resources)
+ }
+ return c.JSON(http.StatusNotFound, SdcError{
+ Message: "No Resources found",
+ ErrorCode: "SVC4642",
+ Status: "Not Found"})
+}
+
+func postResources(c echo.Context) error {
+ resource := new(Resource)
+ if err := c.Bind(resource); err != nil {
+ return err
+ }
+ for _, r := range resourceList {
+ if resource.Name == r.Name && r.ResourceType == resource.ResourceType {
+ return c.JSON(http.StatusBadRequest, SdcError{
+ Message: "Resource of same Name and ResourceType exists",
+ ErrorCode: "SVC3642",
+ Status: "Exists"})
+ }
+ }
+ resource.ID = uuid.Must(uuid.NewV4()).String()
+ resource.InvariantID = uuid.Must(uuid.NewV4()).String()
+ resource.UniqueID = uuid.Must(uuid.NewV4()).String()
+ resource.Version = "0.1"
+ resource.LifecycleState = "NOT_CERTIFIED_CHECKOUT"
+ resource.DistributionStatus = "DISTRIBUTION_NOT_APPROVED"
+
+ resourceList = append(resourceList, *resource)
+
+ return c.JSON(http.StatusCreated, resource)
+}
+
+func postResourceAction(c echo.Context) error {
+ resourceID := c.Param("resourceID")
+ action := c.Param("action")
+ actionBody := new(ActionBody)
+ if err := c.Bind(actionBody); err != nil {
+ return err
+ }
+ for i, r := range resourceList {
+ if r.UniqueID == resourceID {
+ if r.LifecycleState == "NOT_CERTIFIED_CHECKOUT" && action == "Certify" {
+ resourceList[i].Version = "1.0"
+ resourceList[i].LifecycleState = "CERTIFIED"
+ return c.JSON(http.StatusCreated, resourceList[i])
+ }
+ if r.LifecycleState == "NOT_CERTIFIED_CHECKOUT" && action == "checkin" {
+ resourceList[i].LifecycleState = "NOT_CERTIFIED_CHECKIN"
+ return c.JSON(http.StatusOK, resourceList[i])
+ }
+ if r.LifecycleState == "NOT_CERTIFIED_CHECKIN" && action == "Certify" {
+ resourceList[i].LifecycleState = "CERTIFIED"
+ resourceList[i].Version = "1.0"
+ resourceList[i].DistributionStatus = "DISTRIBUTION_APPROVED"
+ return c.JSON(http.StatusOK, resourceList[i])
+ }
+ if r.LifecycleState == "CERTIFIED" &&
+ r.DistributionStatus == "DISTRIBUTION_APPROVED" &&
+ action == "activate" {
+ resourceList[i].DistributionStatus = "DISTRIBUTED"
+ return c.JSON(http.StatusOK, resourceList[i])
+ }
+ return c.JSON(http.StatusBadRequest, SdcError{
+ Message: "Cannot perform this action",
+ ErrorCode: "SVC3642",
+ Status: "Bad Action"})
+ }
+ }
+ return c.JSON(http.StatusNotFound, SdcError{
+ Message: "Resource not found",
+ ErrorCode: "SVC4642",
+ Status: "Not Found"})
+}
+
+func postAddResourceToService(c echo.Context) error {
+ resourceID := c.Param("resourceID")
+ resourceAdd := new(ResourceAdd)
+ if err := c.Bind(resourceAdd); err != nil {
+ return err
+ }
+ for i, r := range resourceList {
+ if r.UniqueID == resourceID {
+ if r.LifecycleState == "NOT_CERTIFIED_CHECKOUT" {
+ for _, rr := range resourceList {
+ if rr.UniqueID == resourceAdd.UniqueID &&
+ rr.UniqueID == resourceAdd.ComponentUID &&
+ rr.Name == resourceAdd.Name &&
+ rr.Version == resourceAdd.ComponentVersion &&
+ rr.ResourceType == resourceAdd.OriginType {
+ if rr.ResourceType == "VF" {
+ ci := ComponentInstance{
+ UniqueID: uuid.Must(uuid.NewV4()).String(),
+ Name: resourceAdd.Name,
+ ComponentName: resourceAdd.Name,
+ OriginType: "VF",
+ ComponentVersion: "1.0",
+ }
+ resourceList[i].ComponentInstances = append(r.ComponentInstances, ci)
+ }
+ return c.JSON(http.StatusCreated, r)
+ }
+ }
+ }
+
+ return c.JSON(http.StatusBadRequest, SdcError{
+ Message: "Cannot perform this action",
+ ErrorCode: "SVC3642",
+ Status: "Bad Action"})
+ }
+ }
+
+ return c.JSON(http.StatusNotFound, SdcError{
+ Message: "Resource not found",
+ ErrorCode: "SVC4642",
+ Status: "Not Found"})
+}
+
+func getDistribution(c echo.Context) error {
+ resourceID := c.Param("resourceID")
+ for i, r := range resourceList {
+ if r.ID == resourceID {
+ distributionIDResult := new(DistributionIDResult)
+ if r.DistributionStatus == "DISTRIBUTED" {
+ if len(r.DistributionID) < 1 {
+ resourceList[i].DistributionID = uuid.Must(uuid.NewV4()).String()
+ }
+ distributionIDResult.DeployementStatus = "Distributed"
+ distributionIDResult.UserID = "Oper P(op0001)"
+ distributionIDResult.DistributionID = resourceList[i].DistributionID
+ }
+ distributionIDList := new(DistributionIDList)
+ distributionIDList.DistributionStatusOfServiceList = append(distributionIDList.DistributionStatusOfServiceList, *distributionIDResult)
+ return c.JSON(http.StatusOK, distributionIDList)
+ }
+ }
+ return c.JSON(http.StatusNotFound, SdcError{
+ Message: "Resource not found",
+ ErrorCode: "SVC4642",
+ Status: "Not Found"})
+}
+
+func getDistributionList(c echo.Context) error {
+ distributionID := c.Param("distributionID")
+ for _, r := range resourceList {
+ if r.DistributionID == distributionID {
+ d := new(DistributionStatusList)
+ d.DistributionStatusList = distributionList
+ return c.JSON(http.StatusOK, d)
+ }
+ }
+ return c.JSON(http.StatusNotFound, SdcError{
+ Message: "Resource not found",
+ ErrorCode: "SVC4642",
+ Status: "Not Found"})
+}
+
+func getAllResources(c echo.Context) error {
+
+ var listResources []Resource
+ var listServices []Resource
+
+ for _, r := range resourceList {
+ if r.ComponentType != "SERVICE" {
+ listResources = append(listResources, r)
+ } else {
+ listServices = append(listServices, r)
+ }
+ }
+ list := &ResourceList{listResources, listServices}
+ return c.JSON(http.StatusOK, list)
+}
+
+func getServiceUniqueIdentifier(c echo.Context) error {
+ resourceID := c.Param("resourceID")
+ for _, r := range resourceList {
+ if r.UniqueID == resourceID {
+ return c.JSON(http.StatusOK, r)
+ }
+ }
+
+ return c.JSON(http.StatusNotFound, SdcError{
+ Message: "Resource not found",
+ ErrorCode: "SVC4642",
+ Status: "Not Found"})
+}
+
+func uploadTcaArtifact(c echo.Context) error {
+ resourceID := c.Param("resourceID")
+ vfID := c.Param("vfID")
+ for _, r := range resourceList {
+ if r.UniqueID == resourceID {
+ if r.LifecycleState == "NOT_CERTIFIED_CHECKOUT" {
+ for _, cc := range r.ComponentInstances {
+ if cc.UniqueID == vfID {
+ newArtifact := new(ArtifactAdd)
+ if err := c.Bind(newArtifact); err != nil {
+ return err
+ }
+ cc.DeploymentArtifacts = append(cc.DeploymentArtifacts, *newArtifact)
+ NewUploadResult := NewUploadResult{
+ Description: newArtifact.Description,
+ ArtifactType: newArtifact.ArtifactType,
+ ArtifactName: newArtifact.ArtifactName,
+ }
+ return c.JSON(http.StatusCreated, NewUploadResult)
+ }
+ }
+ }
+ return c.JSON(http.StatusBadRequest, SdcError{
+ Message: "Cannot perform this action",
+ ErrorCode: "SVC3642",
+ Status: "Bad Action"})
+ }
+ }
+ return c.JSON(http.StatusNotFound, SdcError{
+ Message: "Resource not found",
+ ErrorCode: "SVC4642",
+ Status: "Not Found"})
+}
+
+func postResourceProperties(c echo.Context) error {
+ resourceID := c.Param("resourceID")
+ var bodyBytes []byte
+ if c.Request().Body != nil {
+ bodyBytes, _ = ioutil.ReadAll(c.Request().Body)
+ }
+ var dat map[string]interface{}
+ if err := json.Unmarshal(bodyBytes, &dat); err != nil {
+ return err
+ }
+ for i, r := range resourceList {
+ if r.UniqueID == resourceID {
+ for key := range dat {
+ propertyBody := new(Property)
+ propertyBody.Name = dat[key].(map[string]interface{})["name"].(string)
+ propertyBody.Type = dat[key].(map[string]interface{})["type"].(string)
+ resourceList[i].Properties = append(r.Properties, *propertyBody)
+ }
+ return c.JSON(http.StatusOK, "")
+ }
+ }
+ return c.JSON(http.StatusNotFound, "")
+}
+
+func getResourceProperties(c echo.Context) error {
+ resourceID := c.Param("resourceID")
+ for _, r := range resourceList {
+ if r.UniqueID == resourceID {
+ return c.JSON(http.StatusOK, map[string][]Property{
+ "properties": r.Properties,
+ })
+ }
+ }
+ return c.JSON(http.StatusNotFound, "")
+}
+
+func postResourceInputs(c echo.Context) error {
+ resourceID := c.Param("resourceID")
+ inputBody := new(Input)
+ if err := c.Bind(inputBody); err != nil {
+ return err
+ }
+ for i, r := range resourceList {
+ if r.UniqueID == resourceID {
+ resourceList[i].Inputs = append(r.Inputs, *inputBody)
+ return c.JSON(http.StatusOK, r.Inputs)
+ }
+ }
+ return c.JSON(http.StatusNotFound, "")
+}
+
+func getResourcefilteredData(c echo.Context) error {
+ paramType := c.QueryParam("include")
+ switch paramType {
+ case "inputs":
+ return getResourceInputs(c)
+ case "properties":
+ return getResourceProperties(c)
+ }
+ return errors.New("Invalid query param")
+}
+
+func getResourceInputs(c echo.Context) error {
+ resourceID := c.Param("resourceID")
+ for _, r := range resourceList {
+ if r.UniqueID == resourceID {
+ return c.JSON(http.StatusOK, map[string][]Input{
+ "inputs": r.Inputs,
+ })
+ }
+ }
+ return c.JSON(http.StatusNotFound, "")
+}
+
+func generateDistributionStatusList() {
+ distributionList = nil
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "SO-COpenSource-Env11",
+ Timestamp: "1574774740421",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vf-license-model.xml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "aai-ml",
+ Timestamp: "1574774737842",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vf-license-model.xml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "SO-COpenSource-Env11",
+ Timestamp: "1574774740421",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-template.yml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "cds",
+ Timestamp: "1574774726254",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-csar.csar",
+ Status: "NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-windriver-id",
+ Timestamp: "1574774731805",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-csar.csar",
+ Status: "NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "sdc-COpenSource-Env11-sdnc-dockero",
+ Timestamp: "1574774720318",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vsrx0_modules.json",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "sdc-COpenSource-Env11-sdnc-dockero",
+ Timestamp: "1574774737396",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-csar.csar",
+ Status: "DEPLOY_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "clamp",
+ Timestamp: "1574774737925",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vendor-license-model.xml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-k8s-id",
+ Timestamp: "1574774750490",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vsrx0_modules.json",
+ Status: "DEPLOY_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-k8s-id",
+ Timestamp: "1574774736174",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vsrx0_modules.json",
+ Status: "NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-windriver-id",
+ Timestamp: "1574774731805",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.env",
+ Status: "NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "SO-COpenSource-Env11",
+ Timestamp: "1574774740421",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-csar.csar",
+ Status: "NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "clamp",
+ Timestamp: "1574774737925",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vf-license-model.xml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "policy-id",
+ Timestamp: "1574774728667",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.yaml",
+ Status: "NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-starlingx-id",
+ Timestamp: "1574774737784",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.env",
+ Status: "NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "clamp",
+ Timestamp: "1574774737925",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-template.yml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-k8s-id",
+ Timestamp: "1574774744883",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vsrx0_modules.json",
+ Status: "DOWNLOAD_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-windriver-id",
+ Timestamp: "1574774731805",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vsrx0_modules.json",
+ Status: "NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-windriver-id",
+ Timestamp: "1574774731805",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.yaml",
+ Status: "NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "SO-COpenSource-Env11",
+ Timestamp: "1574774740421",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.yaml",
+ Status: "NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "SO-COpenSource-Env11",
+ Timestamp: "1574774756945",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.env",
+ Status: "DEPLOY_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "SO-COpenSource-Env11",
+ Timestamp: "1574774752508",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.yaml",
+ Status: "DOWNLOAD_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "cds",
+ Timestamp: "1574774726254",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vsrx0_modules.json",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-k8s-id",
+ Timestamp: "1574774736174",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vendor-license-model.xml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "aai-ml",
+ Timestamp: "1574774745892",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-csar.csar",
+ Status: "DOWNLOAD_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "cds",
+ Timestamp: "1574774726254",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vf-license-model.xml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "aai-ml",
+ Timestamp: "1574774737842",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-csar.csar",
+ Status: "NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "SO-COpenSource-Env11",
+ Timestamp: "1574774757951",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-csar.csar",
+ Status: "DEPLOY_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "aai-ml",
+ Timestamp: "1574774737842",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.yaml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-starlingx-id",
+ Timestamp: "1574774737784",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vf-license-model.xml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "clamp",
+ Timestamp: "1574774737925",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-csar.csar",
+ Status: "NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "cds",
+ Timestamp: "1574774726254",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-template.yml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "dcae-sch",
+ Timestamp: "1574774724083",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vf-license-model.xml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-k8s-id",
+ Timestamp: "1574774749381",
+ URL: "",
+ Status: "COMPONENT_DONE_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-k8s-id",
+ Timestamp: "1574774736174",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vf-license-model.xml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-k8s-id",
+ Timestamp: "1574774746542",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.yaml",
+ Status: "DOWNLOAD_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "policy-id",
+ Timestamp: "1574774728667",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-template.yml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-k8s-id",
+ Timestamp: "1574774736174",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.env",
+ Status: "NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "cds",
+ Timestamp: "1574774726254",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.yaml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "cds",
+ Timestamp: "1574774735595",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-csar.csar",
+ Status: "DOWNLOAD_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-starlingx-id",
+ Timestamp: "1574774737784",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vsrx0_modules.json",
+ Status: "NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-k8s-id",
+ Timestamp: "1574774736174",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-template.yml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "dcae-sch",
+ Timestamp: "1574774724083",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vsrx0_modules.json",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "SO-COpenSource-Env11",
+ Timestamp: "1574774748752",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-csar.csar",
+ Status: "DOWNLOAD_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "cds",
+ Timestamp: "1574774736609",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-csar.csar",
+ Status: "COMPONENT_DONE_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "SO-COpenSource-Env11",
+ Timestamp: "1574774969197",
+ URL: "",
+ Status: "DISTRIBUTION_COMPLETE_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "dcae-sch",
+ Timestamp: "1574774724083",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-csar.csar",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "aai-ml",
+ Timestamp: "1574774737842",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-template.yml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "aai-ml",
+ Timestamp: "1574774750517",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-csar.csar",
+ Status: "DEPLOY_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-windriver-id",
+ Timestamp: "1574774744623",
+ URL: "",
+ Status: "COMPONENT_DONE_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "dcae-sch",
+ Timestamp: "1574774724083",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.yaml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "dcae-sch",
+ Timestamp: "1574774724083",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.env",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-windriver-id",
+ Timestamp: "1574774731805",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-template.yml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-starlingx-id",
+ Timestamp: "1574774750947",
+ URL: "",
+ Status: "COMPONENT_DONE_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "sdc-COpenSource-Env11-sdnc-dockero",
+ Timestamp: "1574774735764",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-csar.csar",
+ Status: "DOWNLOAD_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-starlingx-id",
+ Timestamp: "1574774737784",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-csar.csar",
+ Status: "NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "cds",
+ Timestamp: "1574774726254",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vendor-license-model.xml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "clamp",
+ Timestamp: "1574774750026",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-csar.csar",
+ Status: "ALREADY_DOWNLOADED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "SO-COpenSource-Env11",
+ Timestamp: "1574774753902",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.env",
+ Status: "DOWNLOAD_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-k8s-id",
+ Timestamp: "1574774736174",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-csar.csar",
+ Status: "NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "policy-id",
+ Timestamp: "1574774728667",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-csar.csar",
+ Status: "NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "policy-id",
+ Timestamp: "1574774737376",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-csar.csar",
+ Status: "DOWNLOAD_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "policy-id",
+ Timestamp: "1574774728667",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vsrx0_modules.json",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "sdc-COpenSource-Env11-sdnc-dockero",
+ Timestamp: "1574774720318",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-template.yml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "SO-COpenSource-Env11",
+ Timestamp: "1574774754939",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vsrx0_modules.json",
+ Status: "DEPLOY_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-windriver-id",
+ Timestamp: "1574774731805",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vf-license-model.xml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "sdc-COpenSource-Env11-sdnc-dockero",
+ Timestamp: "1574774720318",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-csar.csar",
+ Status: "NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "sdc-COpenSource-Env11-sdnc-dockero",
+ Timestamp: "1574774720318",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.yaml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-k8s-id",
+ Timestamp: "1574774748190",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.env",
+ Status: "DOWNLOAD_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "policy-id",
+ Timestamp: "1574774728667",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vendor-license-model.xml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-windriver-id",
+ Timestamp: "1574774742014",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.yaml",
+ Status: "DOWNLOAD_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "sdc-COpenSource-Env11-sdnc-dockero",
+ Timestamp: "1574774720318",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.env",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "policy-id",
+ Timestamp: "1574774728667",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.env",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-windriver-id",
+ Timestamp: "1574774745715",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vsrx0_modules.json",
+ Status: "DEPLOY_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "SO-COpenSource-Env11",
+ Timestamp: "1574774740421",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vsrx0_modules.json",
+ Status: "NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "dcae-sch",
+ Timestamp: "1574774724083",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vendor-license-model.xml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-k8s-id",
+ Timestamp: "1574774736174",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.yaml",
+ Status: "NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "sdc-COpenSource-Env11-sdnc-dockero",
+ Timestamp: "1574774738399",
+ URL: "",
+ Status: "COMPONENT_DONE_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-windriver-id",
+ Timestamp: "1574774740487",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vsrx0_modules.json",
+ Status: "DOWNLOAD_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-windriver-id",
+ Timestamp: "1574774731805",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vendor-license-model.xml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "policy-id",
+ Timestamp: "1574774740598",
+ URL: "",
+ Status: "COMPONENT_DONE_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "clamp",
+ Timestamp: "1574774737925",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vsrx0_modules.json",
+ Status: "NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "aai-ml",
+ Timestamp: "1574774737842",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.env",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "clamp",
+ Timestamp: "1574774737925",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.env",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-starlingx-id",
+ Timestamp: "1574774737784",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-template.yml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-starlingx-id",
+ Timestamp: "1574774749858",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.env",
+ Status: "DOWNLOAD_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-starlingx-id",
+ Timestamp: "1574774748343",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.yaml",
+ Status: "DOWNLOAD_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "aai-ml",
+ Timestamp: "1574774751522",
+ URL: "",
+ Status: "COMPONENT_DONE_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "cds",
+ Timestamp: "1574774726254",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.env",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "sdc-COpenSource-Env11-sdnc-dockero",
+ Timestamp: "1574774720318",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vendor-license-model.xml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "SO-COpenSource-Env11",
+ Timestamp: "1574774740421",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.env",
+ Status: "NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "policy-id",
+ Timestamp: "1574774739512",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-csar.csar",
+ Status: "DEPLOY_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-starlingx-id",
+ Timestamp: "1574774737784",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vendor-license-model.xml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-starlingx-id",
+ Timestamp: "1574774746621",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vsrx0_modules.json",
+ Status: "DOWNLOAD_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "clamp",
+ Timestamp: "1574774751028",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-csar.csar",
+ Status: "ALREADY_DEPLOYED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "SO-COpenSource-Env11",
+ Timestamp: "1574774740421",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vendor-license-model.xml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-starlingx-id",
+ Timestamp: "1574774737784",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.yaml",
+ Status: "NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "sdc-COpenSource-Env11-sdnc-dockero",
+ Timestamp: "1574774720318",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vf-license-model.xml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "policy-id",
+ Timestamp: "1574774728667",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vf-license-model.xml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "aai-ml",
+ Timestamp: "1574774737842",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vsrx0_modules.json",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "SO-COpenSource-Env11",
+ Timestamp: "1574774751123",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vsrx0_modules.json",
+ Status: "DOWNLOAD_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "aai-ml",
+ Timestamp: "1574774737842",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vendor-license-model.xml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "dcae-sch",
+ Timestamp: "1574774724083",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/artifacts/service-Test12-template.yml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-starlingx-id",
+ Timestamp: "1574774752037",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/vsrx0_modules.json",
+ Status: "DEPLOY_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "SO-COpenSource-Env11",
+ Timestamp: "1574774755942",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.yaml",
+ Status: "DEPLOY_OK",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "clamp",
+ Timestamp: "1574774737925",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.yaml",
+ Status: "NOT_NOTIFIED",
+ ErrorReason: "null",
+ })
+ distributionList = append(distributionList, DistributionStatus{
+ OmfComponentID: "multicloud-windriver-id",
+ Timestamp: "1574774743466",
+ URL: "/sdc/v1/catalog/services/Test12/1.0/resourceInstances/vsrx0/artifacts/base_ubuntu16.env",
+ Status: "DOWNLOAD_OK",
+ ErrorReason: "null",
+ })
+}
+
+func getArtifactTypes(c echo.Context) error {
+ list := []string{"HEAT"}
+ return c.JSON(http.StatusOK, list)
+}
+
+func registerForDistribution(c echo.Context) error {
+ distributionRegistration := map[string]string{
+ "distrNotificationTopicName":"testName",
+ "distrStatusTopicName":"testTopic",
+ }
+ return c.JSON(http.StatusOK, distributionRegistration)
+}
+
+func unRegisterForDistribution(c echo.Context) error {
+ return c.JSON(http.StatusOK, list.New())
+}
+
+func distributionKafkaData(c echo.Context) error {
+ kafkaData := map[string]string{
+ "kafkaBootStrapServer":"localhost:43219",
+ "distrNotificationTopicName":"SDC-DIST-NOTIF-TOPIC",
+ "distrStatusTopicName":"SDC-DIST-STATUS-TOPIC",
+ }
+ return c.JSON(http.StatusOK, kafkaData)
+}
+
diff --git a/mock-sdc/sdc_handlers.go b/mock-sdc/sdc_handlers.go
new file mode 100644
index 0000000..02f8a11
--- /dev/null
+++ b/mock-sdc/sdc_handlers.go
@@ -0,0 +1,210 @@
+// 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"
+)
+
+// VersionList describe the list return in SDC
+type VersionList struct {
+ ListCount int `json:"listCount"`
+ Results []VersionLight `json:"results"`
+}
+
+// Version describe version model in SDC
+type Version struct {
+ ID string `json:"id"`
+ Name string `json:"name"`
+ Description string `json:"description"`
+ BaseID string `json:"baseId"`
+ Status string `json:"status"`
+ RealStatus string
+ CreationTime int64 `json:"creationTime"`
+ ModificationTime int64 `json:"modificationTime"`
+ AdditionalInfo struct {
+ OptionalCreationMethods []string `json:"OptionalCreationMethods"`
+ } `json:"additionalInfo"`
+ State struct {
+ SynchronizationState string `json:"synchronizationState"`
+ Dirty bool `json:"dirty"`
+ } `json:"state"`
+}
+
+// VersionLight describe version model in SDC
+type VersionLight struct {
+ ID string `json:"id"`
+ Name string `json:"name"`
+ Description string `json:"description"`
+ BaseID string `json:"baseId"`
+ Status string `json:"status"`
+ CreationTime int64 `json:"creationTime"`
+ ModificationTime int64 `json:"modificationTime"`
+ AdditionalInfo struct {
+ OptionalCreationMethods []string `json:"OptionalCreationMethods"`
+ } `json:"additionalInfo"`
+}
+
+// VersionDetails show details of a version
+type VersionDetails struct {
+ ID string `json:"id"`
+ Name string `json:"name"`
+ Description string `json:"description"`
+ Status string `json:"status"`
+ CreationTime int64 `json:"creationTime"`
+ ModificationTime int64 `json:"modificationTime"`
+ State struct {
+ SynchronizationState string `json:"synchronizationState"`
+ Dirty bool `json:"dirty"`
+ } `json:"state"`
+}
+
+// CreatedVersion of a CreatedVendor in SDC
+type CreatedVersion struct {
+ ID string `json:"id"`
+ Name string `json:"name"`
+ Description string `json:"description"`
+ Status string `json:"status"`
+}
+
+// CreatedItem model in SDC
+type CreatedItem struct {
+ ItemID string `json:"itemId"`
+ Version CreatedVersion `json:"version"`
+}
+
+// Action describe the action on items in SDC
+type Action struct {
+ Action string `json:"action"`
+}
+
+// SdcError is the way to return Error in SDC
+type SdcError struct {
+ Status string `json:"status"`
+ ErrorCode string `json:"errorCode"`
+ Message string `json:"message"`
+}
+
+func getItemVersions(c echo.Context) error {
+ itemID := c.Param("itemID")
+ for _, v := range vendorList {
+ if v.ID == itemID {
+ versionList := generateVersionList(v.Versions)
+ list := &VersionList{len(versionList), versionList}
+ return c.JSON(http.StatusOK, list)
+ }
+ }
+ for _, v := range vspList {
+ if v.ID == itemID {
+ versionList := generateVersionList(v.Versions)
+ list := &VersionList{len(versionList), versionList}
+ return c.JSON(http.StatusOK, list)
+ }
+ }
+ return echo.NewHTTPError(http.StatusNotFound, "Item Not Found")
+}
+
+func generateVersionList(versions []Version) []VersionLight {
+ versionList := []VersionLight{}
+ for _, version := range versions {
+ versionList = append(versionList, VersionLight{
+ ID: version.ID,
+ Name: version.Name,
+ Description: version.Description,
+ BaseID: version.BaseID,
+ Status: version.Status,
+ CreationTime: version.CreationTime,
+ ModificationTime: version.ModificationTime,
+ AdditionalInfo: version.AdditionalInfo,
+ })
+
+ }
+ return versionList
+}
+
+func getItemVersion(c echo.Context) error {
+ itemID := c.Param("itemID")
+ versionID := c.Param("versionID")
+ for _, v := range vendorList {
+ if v.ID == itemID {
+ for _, version := range v.Versions {
+ if version.ID == versionID {
+ versionDetails := VersionDetails{
+ ID: version.ID,
+ Name: version.Name,
+ Description: version.Description,
+ Status: version.Status,
+ CreationTime: version.CreationTime,
+ ModificationTime: version.ModificationTime,
+ State: version.State,
+ }
+ return c.JSON(http.StatusOK, versionDetails)
+ }
+ }
+ }
+ }
+ for _, v := range vspList {
+ if v.ID == itemID {
+ for _, version := range v.Versions {
+ if version.ID == versionID {
+ versionDetails := VersionDetails{
+ ID: version.ID,
+ Name: version.Name,
+ Description: version.Description,
+ Status: version.Status,
+ CreationTime: version.CreationTime,
+ ModificationTime: version.ModificationTime,
+ State: version.State,
+ }
+ return c.JSON(http.StatusOK, versionDetails)
+ }
+ }
+ }
+ }
+ return echo.NewHTTPError(http.StatusNotFound, "Item Not Found")
+}
+
+func updateItemVersion(c echo.Context) error {
+ action := new(Action)
+ if err := c.Bind(action); err != nil {
+ return err
+ }
+ itemID := c.Param("itemID")
+ versionID := c.Param("versionID")
+ for i, v := range vspList {
+ if v.ID == itemID {
+ for j, version := range v.Versions {
+ if version.ID == versionID {
+ if action.Action == "Commit" {
+ if version.RealStatus == "Validated" {
+ vspList[i].Versions[j].RealStatus = "Commited"
+ vspList[i].Versions[j].State.Dirty = false
+ return c.String(http.StatusOK, "{}")
+ }
+ return echo.NewHTTPError(http.StatusNotFound, "Item not in good state")
+ }
+ return echo.NewHTTPError(http.StatusNotFound, "Unknown Action")
+ }
+ }
+ }
+ }
+ return echo.NewHTTPError(http.StatusNotFound, "Item Not Found")
+}
+
+func getCategories(c echo.Context) error {
+ return c.String(http.StatusOK, `{"categories":{"resourceCategories":[{"name":"Application L4+","normalizedName":"application l4+","uniqueId":"resourceNewCategory.application l4+","icons":null,"subcategories":[{"name":"Media Servers","normalizedName":"media servers","uniqueId":"resourceNewCategory.application l4+.media servers","icons":["applicationServer"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Database","normalizedName":"database","uniqueId":"resourceNewCategory.application l4+.database","icons":["database"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Border Element","normalizedName":"border element","uniqueId":"resourceNewCategory.application l4+.border element","icons":["borderElement"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Application Server","normalizedName":"application server","uniqueId":"resourceNewCategory.application l4+.application server","icons":["applicationServer"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Firewall","normalizedName":"firewall","uniqueId":"resourceNewCategory.application l4+.firewall","icons":["firewall"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Call Control","normalizedName":"call control","uniqueId":"resourceNewCategory.application l4+.call control","icons":["call_controll"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Web Server","normalizedName":"web server","uniqueId":"resourceNewCategory.application l4+.web server","icons":["applicationServer"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Load Balancer","normalizedName":"load balancer","uniqueId":"resourceNewCategory.application l4+.load balancer","icons":["loadBalancer"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null}],"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Network Connectivity","normalizedName":"network connectivity","uniqueId":"resourceNewCategory.network connectivity","icons":null,"subcategories":[{"name":"Connection Points","normalizedName":"connection points","uniqueId":"resourceNewCategory.network connectivity.connection points","icons":["cp"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Virtual Links","normalizedName":"virtual links","uniqueId":"resourceNewCategory.network connectivity.virtual links","icons":["vl"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null}],"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Allotted Resource","normalizedName":"allotted resource","uniqueId":"resourceNewCategory.allotted resource","icons":null,"subcategories":[{"name":"BRG","normalizedName":"brg","uniqueId":"resourceNewCategory.allotted resource.brg","icons":["brg"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"TunnelXConn","normalizedName":"tunnelxconn","uniqueId":"resourceNewCategory.allotted resource.tunnelxconn","icons":["tunnel_x_connect"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"IP Mux Demux","normalizedName":"ip mux demux","uniqueId":"resourceNewCategory.allotted resource.ip mux demux","icons":["ip_mux_demux"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Security Zone","normalizedName":"security zone","uniqueId":"resourceNewCategory.allotted resource.security zone","icons":["security_zone"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Service Admin","normalizedName":"service admin","uniqueId":"resourceNewCategory.allotted resource.service admin","icons":["service_admin"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Allotted Resource","normalizedName":"allotted resource","uniqueId":"resourceNewCategory.allotted resource.allotted resource","icons":["allotted_resource"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Contrail Route","normalizedName":"contrail route","uniqueId":"resourceNewCategory.allotted resource.contrail route","icons":["contrail_route"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null}],"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Configuration","normalizedName":"configuration","uniqueId":"resourceNewCategory.configuration","icons":null,"subcategories":[{"name":"Configuration","normalizedName":"configuration","uniqueId":"resourceNewCategory.configuration.configuration","icons":["pmc"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null}],"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Network L4+","normalizedName":"network l4+","uniqueId":"resourceNewCategory.network l4+","icons":null,"subcategories":[{"name":"Common Network Resources","normalizedName":"common network resources","uniqueId":"resourceNewCategory.network l4+.common network resources","icons":["network"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null}],"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Generic","normalizedName":"generic","uniqueId":"resourceNewCategory.generic","icons":null,"subcategories":[{"name":"Abstract","normalizedName":"abstract","uniqueId":"resourceNewCategory.generic.abstract","icons":["objectStorage","compute"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Network Service","normalizedName":"network service","uniqueId":"resourceNewCategory.generic.network service","icons":["network"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Rules","normalizedName":"rules","uniqueId":"resourceNewCategory.generic.rules","icons":["networkrules","securityrules"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Infrastructure","normalizedName":"infrastructure","uniqueId":"resourceNewCategory.generic.infrastructure","icons":["connector"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Network Elements","normalizedName":"network elements","uniqueId":"resourceNewCategory.generic.network elements","icons":["network","connector"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Database","normalizedName":"database","uniqueId":"resourceNewCategory.generic.database","icons":["database"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null}],"version":null,"ownerId":null,"empty":false,"type":null},{"name":"DCAE Component","normalizedName":"dcae component","uniqueId":"resourceNewCategory.dcae component","icons":null,"subcategories":[{"name":"Analytics","normalizedName":"analytics","uniqueId":"resourceNewCategory.dcae component.analytics","icons":["dcae_analytics"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Database","normalizedName":"database","uniqueId":"resourceNewCategory.dcae component.database","icons":["dcae_database"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Policy","normalizedName":"policy","uniqueId":"resourceNewCategory.dcae component.policy","icons":["dcae_policy"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Machine Learning","normalizedName":"machine learning","uniqueId":"resourceNewCategory.dcae component.machine learning","icons":["dcae_machineLearning"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Microservice","normalizedName":"microservice","uniqueId":"resourceNewCategory.dcae component.microservice","icons":["dcae_microservice"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Source","normalizedName":"source","uniqueId":"resourceNewCategory.dcae component.source","icons":["dcae_source"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Collector","normalizedName":"collector","uniqueId":"resourceNewCategory.dcae component.collector","icons":["dcae_collector"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Utility","normalizedName":"utility","uniqueId":"resourceNewCategory.dcae component.utility","icons":["dcae_utilty"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null}],"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Network L2-3","normalizedName":"network l2-3","uniqueId":"resourceNewCategory.network l2-3","icons":null,"subcategories":[{"name":"Gateway","normalizedName":"gateway","uniqueId":"resourceNewCategory.network l2-3.gateway","icons":["gateway"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"WAN Connectors","normalizedName":"wan connectors","uniqueId":"resourceNewCategory.network l2-3.wan connectors","icons":["network","connector","port"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Infrastructure","normalizedName":"infrastructure","uniqueId":"resourceNewCategory.network l2-3.infrastructure","icons":["ucpe"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Router","normalizedName":"router","uniqueId":"resourceNewCategory.network l2-3.router","icons":["router","vRouter"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"LAN Connectors","normalizedName":"lan connectors","uniqueId":"resourceNewCategory.network l2-3.lan connectors","icons":["network","connector","port"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null}],"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Template","normalizedName":"template","uniqueId":"resourceNewCategory.template","icons":null,"subcategories":[{"name":"Base Monitoring Template","normalizedName":"base monitoring template","uniqueId":"resourceNewCategory.template.base monitoring template","icons":["monitoring_template"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Monitoring Template","normalizedName":"monitoring template","uniqueId":"resourceNewCategory.template.monitoring template","icons":["monitoring_template"],"groupings":null,"version":null,"ownerId":null,"empty":false,"type":null}],"version":null,"ownerId":null,"empty":false,"type":null}],"serviceCategories":[{"name":"Mobility","normalizedName":"mobility","uniqueId":"serviceNewCategory.mobility","icons":["mobility"],"subcategories":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Network L4+","normalizedName":"network l4+","uniqueId":"serviceNewCategory.network l4+","icons":["network_l_4"],"subcategories":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"E2E Service","normalizedName":"e2e service","uniqueId":"serviceNewCategory.e2e service","icons":["network_l_1-3"],"subcategories":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"VoIP Call Control","normalizedName":"voip call control","uniqueId":"serviceNewCategory.voip call control","icons":["call_controll"],"subcategories":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Network Service","normalizedName":"network service","uniqueId":"serviceNewCategory.network service","icons":["network_l_1-3"],"subcategories":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Network L1-3","normalizedName":"network l1-3","uniqueId":"serviceNewCategory.network l1-3","icons":["network_l_1-3"],"subcategories":null,"version":null,"ownerId":null,"empty":false,"type":null},{"name":"Partner Domain Service","normalizedName":"partner domain service","uniqueId":"serviceNewCategory.partner domain service","icons":["partner_domain_service"],"subcategories":null,"version":null,"ownerId":null,"empty":false,"type":null}],"productCategories":[]},"version":"1.6.7"}`)
+}
diff --git a/mock-sdc/vendor_handlers.go b/mock-sdc/vendor_handlers.go
new file mode 100644
index 0000000..2bdde87
--- /dev/null
+++ b/mock-sdc/vendor_handlers.go
@@ -0,0 +1,185 @@
+// 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"
+)
+
+// Vendor describes license model in SDC
+type Vendor struct {
+ ID string `json:"id"`
+ Type string `json:"type"`
+ Name string `json:"name"`
+ Description string `json:"description"`
+ Owner string `json:"owner"`
+ Status string `json:"status"`
+ Properties struct {
+ } `json:"properties"`
+ Versions []Version `json:"-"`
+}
+
+// NewVendor describe the vendor creation model in SDC
+type NewVendor struct {
+ IconRef string `json:"iconRef"`
+ VendorName string `json:"vendorName"`
+ Description string `json:"description"`
+}
+
+// VendorList is the way to return Vendors in SDC
+type VendorList struct {
+ ListCount int `json:"listCount"`
+ Results []Vendor `json:"results"`
+}
+
+var vendorList []Vendor
+
+func generateInitialVendorList() {
+ vendorList = nil
+ var empty struct{}
+ version1 := Version{
+ ID: "61c134e128f54119934b3960c77a3f33",
+ Name: "1.0",
+ Description: "Initial version",
+ BaseID: "",
+ Status: "Certified",
+ RealStatus: "Certified",
+ CreationTime: 1559565688604,
+ ModificationTime: 1559565787436,
+ AdditionalInfo: struct {
+ OptionalCreationMethods []string `json:"OptionalCreationMethods"`
+ }{
+ OptionalCreationMethods: []string{"major"}},
+ }
+ version2 := Version{
+ ID: "2e3ba48c748d47e3bd4afdd8348bdfb9",
+ Name: "1.0",
+ Description: "Initial version",
+ BaseID: "",
+ Status: "Certified",
+ RealStatus: "Certified",
+ CreationTime: 1559562354868,
+ ModificationTime: 1559562421476,
+ AdditionalInfo: struct {
+ OptionalCreationMethods []string `json:"OptionalCreationMethods"`
+ }{
+ OptionalCreationMethods: []string{"major"}},
+ }
+ vendorList = append(vendorList,
+ Vendor{
+ ID: "212a52b2630749388a7693086ac1467e",
+ Type: "vlm",
+ Name: "wvfw",
+ Description: "wvfw",
+ Owner: "cs0008",
+ Status: "ACTIVE",
+ Properties: empty,
+ Versions: []Version{version1}})
+ vendorList = append(vendorList, Vendor{
+ ID: "e78eb0b1c73e43138f705cd92c0e4ace",
+ Type: "vlm",
+ Name: "vfw_test",
+ Description: "test vfw",
+ Owner: "cs0008",
+ Status: "ACTIVE",
+ Properties: empty,
+ Versions: []Version{version2}})
+}
+
+func getVendorServiceModels(c echo.Context) error {
+ list := &VendorList{len(vendorList), vendorList}
+ return c.JSON(http.StatusOK, list)
+}
+
+func postVendorServiceModels(c echo.Context) error {
+ newVendor := new(NewVendor)
+ if err := c.Bind(newVendor); err != nil {
+ return err
+ }
+
+ u1 := uuid.Must(uuid.NewV4()).String()
+ version := Version{
+ ID: u1,
+ Name: "1.0",
+ Description: "Initial version",
+ BaseID: "",
+ Status: "Draft",
+ RealStatus: "Draft",
+ CreationTime: (time.Now().UnixNano() / 1000000),
+ ModificationTime: (time.Now().UnixNano() / 1000000),
+ AdditionalInfo: struct {
+ OptionalCreationMethods []string `json:"OptionalCreationMethods"`
+ }{
+ OptionalCreationMethods: []string{"major"}},
+ State: struct {
+ SynchronizationState string `json:"synchronizationState"`
+ Dirty bool `json:"dirty"`
+ }{
+ SynchronizationState: "UpToDate",
+ Dirty: false,
+ },
+ }
+ u2 := uuid.Must(uuid.NewV4()).String()
+ var empty struct{}
+ vendorList = append(vendorList, Vendor{
+ ID: u2,
+ Type: "vlm",
+ Name: newVendor.VendorName,
+ Description: newVendor.Description,
+ Owner: "cs0008",
+ Status: "ACTIVE",
+ Properties: empty,
+ Versions: []Version{version}})
+
+ createdVendor := CreatedItem{
+ ItemID: u2,
+ Version: CreatedVersion{
+ ID: u1,
+ Name: "1.0",
+ Description: "Initial version",
+ Status: "Draft",
+ },
+ }
+ return c.JSON(http.StatusCreated, createdVendor)
+}
+
+func updateVendorVersion(c echo.Context) error {
+ action := new(Action)
+ if err := c.Bind(action); err != nil {
+ return err
+ }
+ if action.Action == "Submit" {
+ vendorID := c.Param("vendorID")
+ versionID := c.Param("versionID")
+ for i, vendor := range vendorList {
+ if vendor.ID == vendorID {
+ for j, version := range vendor.Versions {
+ if version.ID == versionID {
+ vendorList[i].Versions[j].Status = "Certified"
+ vendorList[i].Versions[j].RealStatus = "Certified"
+ }
+ return c.String(http.StatusOK, "{}")
+ }
+ return echo.NewHTTPError(http.StatusNotFound, "Version Not Found")
+ }
+ }
+ return echo.NewHTTPError(http.StatusNotFound, "Vendor Not Found")
+ }
+ return echo.NewHTTPError(http.StatusNotFound, "Unknown Action")
+}
diff --git a/mock-sdc/vsp_handlers.go b/mock-sdc/vsp_handlers.go
new file mode 100644
index 0000000..6b45774
--- /dev/null
+++ b/mock-sdc/vsp_handlers.go
@@ -0,0 +1,418 @@
+// 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"
+ "strings"
+ "time"
+
+ "github.com/labstack/echo"
+ uuid "github.com/satori/go.uuid"
+)
+
+// Vsp describes software product in SDC
+type Vsp struct {
+ ID string `json:"id"`
+ Icon string `json:"icon"`
+ OnboardingMethod string `json:"onboardingMethod"`
+ Name string `json:"name"`
+ Description string `json:"description"`
+ Owner string `json:"owner"`
+ Status string `json:"status"`
+ VendorName string `json:"vendorName"`
+ VendorID string `json:"vendorId"`
+ Category string `json:"category"`
+ SubCategory string `json:"subCategory"`
+ CandidateOnboardingOrigin string `json:"candidateOnboardingOrigin"`
+ OnboardingOrigin string `json:"onboardingOrigin"`
+ NetworkPackageName string `json:"networkPackageName"`
+ ValidationData struct {
+ ImportStructure struct {
+ Heat string `json:"heat"`
+ } `json:"importStructure"`
+ } `json:"validationData"`
+ Versions []Version `json:"-"`
+}
+
+// VspLight describes software product in SDC lists
+type VspLight struct {
+ ID string `json:"id"`
+ OnboardingMethod string `json:"onboardingMethod"`
+ Name string `json:"name"`
+ Description string `json:"description"`
+ Owner string `json:"owner"`
+ Status string `json:"status"`
+ VendorName string `json:"vendorName"`
+ VendorID string `json:"vendorId"`
+}
+
+// VspList is the way to return Vsps in SDC
+type VspList struct {
+ ListCount int `json:"listCount"`
+ Results []VspLight `json:"results"`
+}
+
+// VspDetailsDraft describes software product in SDC
+type VspDetailsDraft struct {
+ ID string `json:"id"`
+ Icon string `json:"icon"`
+ OnboardingMethod string `json:"onboardingMethod"`
+ Name string `json:"name"`
+ Description string `json:"description"`
+ VendorName string `json:"vendorName"`
+ VendorID string `json:"vendorId"`
+ Version string `json:"version"`
+ Category string `json:"category"`
+ SubCategory string `json:"subCategory"`
+}
+
+// VspDetailsUploaded describes software product in SDC
+type VspDetailsUploaded struct {
+ ID string `json:"id"`
+ Icon string `json:"icon"`
+ OnboardingMethod string `json:"onboardingMethod"`
+ Name string `json:"name"`
+ Description string `json:"description"`
+ VendorName string `json:"vendorName"`
+ VendorID string `json:"vendorId"`
+ Version string `json:"version"`
+ Category string `json:"category"`
+ SubCategory string `json:"subCategory"`
+ CandidateOnboardingOrigin string `json:"candidateOnboardingOrigin"`
+ NetworkPackageName string `json:"networkPackageName"`
+}
+
+// VspDetailsValidated describes software product in SDC
+type VspDetailsValidated struct {
+ ID string `json:"id"`
+ Icon string `json:"icon"`
+ OnboardingMethod string `json:"onboardingMethod"`
+ Name string `json:"name"`
+ Description string `json:"description"`
+ VendorName string `json:"vendorName"`
+ VendorID string `json:"vendorId"`
+ Version string `json:"version"`
+ Category string `json:"category"`
+ SubCategory string `json:"subCategory"`
+ OnboardingOrigin string `json:"onboardingOrigin"`
+ NetworkPackageName string `json:"networkPackageName"`
+ ValidationData struct {
+ ImportStructure struct {
+ Heat string `json:"heat"`
+ } `json:"importStructure"`
+ } `json:"validationData"`
+}
+
+// NewVsp describe the vsp creation model in SDC
+type NewVsp struct {
+ Icon string `json:"iconRef"`
+ Name string `json:"name"`
+ VendorName string `json:"vendorName"`
+ VendorID string `json:"vendorId"`
+ Description string `json:"description"`
+ Category string `json:"category"`
+ SubCategory string `json:"subCategory"`
+ LicensingData struct{} `json:"licensingData"`
+ OnboardingMethod string `json:"onboardingMethod"`
+}
+
+// ArtifactUploadResult bla
+type ArtifactUploadResult struct {
+ Errors struct{} `json:"errors"`
+ Status string `json:"status"`
+ OnboardingOrigin string `json:"onboardingOrigin"`
+ NetworkPackageName string `json:"networkPackageName"`
+}
+
+// ArtifactValidationResult bla
+type ArtifactValidationResult struct {
+ Errors struct{} `json:"errors"`
+ Status string `json:"status"`
+ FileNames []string `json:"fileNames"`
+}
+
+// CsarCreateResult bla
+type CsarCreateResult struct {
+ Description string `json:"description"`
+ VspName string `json:"vspName"`
+ Version string `json:"version"`
+ PackageID string `json:"packageId"`
+ Category string `json:"category"`
+ SubCategory string `json:"subCategory"`
+ VendorName string `json:"vendorName"`
+ VendorRelease string `json:"vendorRelease"`
+ PackageType string `json:"packageType"`
+ ResourceType string `json:"resourceType"`
+}
+
+var vspList []Vsp
+
+func generateInitialVspList() {
+ vspList = []Vsp{}
+}
+
+func getVendorSoftwareProducts(c echo.Context) error {
+ vspLights := []VspLight{}
+ for _, v := range vspList {
+ vspLights = append(vspLights, VspLight{
+ ID: v.ID,
+ OnboardingMethod: v.OnboardingMethod,
+ Name: v.Name,
+ Description: v.Description,
+ Owner: v.Owner,
+ Status: v.Status,
+ VendorName: v.VendorName,
+ VendorID: v.VendorID,
+ })
+ }
+ list := &VspList{len(vspLights), vspLights}
+ return c.JSON(http.StatusOK, list)
+}
+
+func postVendorSoftwareProducts(c echo.Context) error {
+ newVsp := new(NewVsp)
+ if err := c.Bind(newVsp); err != nil {
+ return err
+ }
+
+ u1 := uuid.Must(uuid.NewV4()).String()
+ version := Version{
+ ID: u1,
+ Name: "1.0",
+ Description: "Initial version",
+ BaseID: "",
+ Status: "Draft",
+ RealStatus: "Draft",
+ CreationTime: (time.Now().UnixNano() / 1000000),
+ ModificationTime: (time.Now().UnixNano() / 1000000),
+ AdditionalInfo: struct {
+ OptionalCreationMethods []string `json:"OptionalCreationMethods"`
+ }{
+ OptionalCreationMethods: []string{"major"}},
+ State: struct {
+ SynchronizationState string `json:"synchronizationState"`
+ Dirty bool `json:"dirty"`
+ }{
+ SynchronizationState: "UpToDate",
+ Dirty: false,
+ },
+ }
+ u2 := uuid.Must(uuid.NewV4()).String()
+ vspList = append(vspList, Vsp{
+ ID: u2,
+ OnboardingMethod: "NetworkPackage",
+ Name: newVsp.Name,
+ Description: newVsp.Description,
+ Owner: "cs0008",
+ Status: "ACTIVE",
+ VendorName: newVsp.VendorName,
+ VendorID: newVsp.VendorID,
+ Category: "resourceNewCategory.generic",
+ SubCategory: "resourceNewCategory.generic.abstract",
+ Icon: "icon",
+ Versions: []Version{version}})
+
+ createdVsp := CreatedItem{
+ ItemID: u2,
+ Version: CreatedVersion{
+ ID: u1,
+ Name: "1.0",
+ Description: "Initial version",
+ Status: "Draft",
+ },
+ }
+ return c.JSON(http.StatusCreated, createdVsp)
+}
+
+func uploadArtifacts(c echo.Context) error {
+ vspID := c.Param("vspID")
+ versionID := c.Param("versionID")
+ for i, v := range vspList {
+ if v.ID == vspID {
+ for j, version := range v.Versions {
+ if version.ID == versionID {
+ if version.RealStatus == "Draft" {
+ file, err := c.FormFile("upload")
+ if err != nil {
+ return err
+ }
+ fileName := strings.Split(file.Filename, ".")[0]
+ fileExtension := strings.Split(file.Filename, ".")[1]
+ vspList[i].NetworkPackageName = fileName
+ vspList[i].CandidateOnboardingOrigin = fileExtension
+ vspList[i].Versions[j].RealStatus = "Uploaded"
+ var empty struct{}
+ artifactUploadResult := ArtifactUploadResult{
+ Errors: empty,
+ Status: "Success",
+ OnboardingOrigin: fileExtension,
+ NetworkPackageName: fileName,
+ }
+ return c.JSON(http.StatusCreated, artifactUploadResult)
+ }
+ }
+ }
+ }
+ }
+ return echo.NewHTTPError(http.StatusNotFound, "Item Not Found")
+}
+
+func validateArtifacts(c echo.Context) error {
+ vspID := c.Param("vspID")
+ versionID := c.Param("versionID")
+ for i, v := range vspList {
+ if v.ID == vspID {
+ for j, version := range v.Versions {
+ if version.ID == versionID {
+ if version.RealStatus == "Uploaded" {
+ vspList[i].OnboardingOrigin = vspList[i].CandidateOnboardingOrigin
+ vspList[i].Versions[j].State.Dirty = true
+ vspList[i].ValidationData = struct {
+ ImportStructure struct {
+ Heat string `json:"heat"`
+ } `json:"importStructure"`
+ }{
+ ImportStructure: struct {
+ Heat string `json:"heat"`
+ }{
+ Heat: "Yes",
+ },
+ }
+ vspList[i].Versions[j].RealStatus = "Validated"
+ var empty struct{}
+ artifactValidationResult := ArtifactValidationResult{
+ Errors: empty,
+ FileNames: []string{
+ "base_ubuntu16.env",
+ "base_ubuntu16.yaml",
+ },
+ Status: "Success",
+ }
+ return c.JSON(http.StatusOK, artifactValidationResult)
+ }
+ }
+ }
+ }
+ }
+ return echo.NewHTTPError(http.StatusNotFound, "Item Not Found")
+}
+
+func updateVspVersion(c echo.Context) error {
+ action := new(Action)
+ if err := c.Bind(action); err != nil {
+ return err
+ }
+ vspID := c.Param("vspID")
+ versionID := c.Param("versionID")
+ for i, v := range vspList {
+ if v.ID == vspID {
+ for j, version := range v.Versions {
+ if version.ID == versionID {
+ if action.Action == "Submit" {
+ if version.RealStatus == "Commited" {
+ vspList[i].Versions[j].RealStatus = "Certified"
+ vspList[i].Versions[j].Status = "Certified"
+ return c.String(http.StatusOK, "{}")
+ }
+ return echo.NewHTTPError(http.StatusNotFound, "Item not in good state")
+ }
+ if action.Action == "Create_Package" {
+ if version.RealStatus == "Certified" {
+ csarCreateResult := CsarCreateResult{
+ Description: v.Description,
+ VspName: v.Name,
+ Version: version.Name,
+ PackageID: v.ID,
+ Category: v.Category,
+ SubCategory: v.SubCategory,
+ VendorName: v.VendorName,
+ VendorRelease: "1.0",
+ PackageType: "CSAR",
+ ResourceType: "VF",
+ }
+ return c.JSON(http.StatusOK, csarCreateResult)
+ }
+ return echo.NewHTTPError(http.StatusNotFound, "Item not in good state")
+ }
+ return echo.NewHTTPError(http.StatusNotFound, "Unknown Action")
+ }
+ }
+ }
+ }
+ return echo.NewHTTPError(http.StatusNotFound, "Item Not Found")
+}
+
+func getVspVersion(c echo.Context) error {
+ vspID := c.Param("vspID")
+ versionID := c.Param("versionID")
+ for _, v := range vspList {
+ if v.ID == vspID {
+ for _, version := range v.Versions {
+ if version.ID == versionID {
+ if version.RealStatus == "Draft" {
+ vspDetails := VspDetailsDraft{
+ ID: v.ID,
+ Icon: v.Icon,
+ OnboardingMethod: v.OnboardingMethod,
+ Name: v.Name,
+ Description: v.Description,
+ VendorName: v.VendorName,
+ VendorID: v.VendorID,
+ Version: version.ID,
+ Category: v.Category,
+ SubCategory: v.SubCategory,
+ }
+ return c.JSON(http.StatusOK, vspDetails)
+ }
+ if version.RealStatus == "Uploaded" {
+ vspDetails := VspDetailsUploaded{
+ ID: v.ID,
+ Icon: v.Icon,
+ OnboardingMethod: v.OnboardingMethod,
+ Name: v.Name,
+ Description: v.Description,
+ VendorName: v.VendorName,
+ VendorID: v.VendorID,
+ Version: version.ID,
+ Category: v.Category,
+ SubCategory: v.SubCategory,
+ CandidateOnboardingOrigin: v.CandidateOnboardingOrigin,
+ NetworkPackageName: v.NetworkPackageName,
+ }
+ return c.JSON(http.StatusOK, vspDetails)
+ }
+ vspDetails := VspDetailsValidated{
+ ID: v.ID,
+ Icon: v.Icon,
+ OnboardingMethod: v.OnboardingMethod,
+ Name: v.Name,
+ Description: v.Description,
+ VendorName: v.VendorName,
+ VendorID: v.VendorID,
+ Version: version.ID,
+ Category: v.Category,
+ SubCategory: v.SubCategory,
+ OnboardingOrigin: v.OnboardingOrigin,
+ NetworkPackageName: v.NetworkPackageName,
+ ValidationData: v.ValidationData,
+ }
+ return c.JSON(http.StatusOK, vspDetails)
+ }
+ }
+ }
+ }
+ return echo.NewHTTPError(http.StatusNotFound, "Item Not Found")
+}