Commit 1ce8f389 authored by Yann Garcia's avatar Yann Garcia
Browse files

Add meep-sandbox-api server side

parent 7733d107
Loading
Loading
Loading
Loading
+20 −11
Original line number Diff line number Diff line
FROM golang:1.10 AS build
WORKDIR /go/src
COPY go ./go
COPY main.go .
# Copyright (c) 2024  The AdvantEDGE Authors
# 
# 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.

ENV CGO_ENABLED=0
RUN go get -d -v ./...
FROM debian:11.7-slim
COPY ./meep-sandbox-api /meep-sandbox-api
COPY ./api /api
COPY ./user-api /user-api
COPY ./data /

RUN go build -a -installsuffix cgo -o swagger .
RUN chmod +x /entrypoint.sh

FROM scratch AS runtime
COPY --from=build /go/src/swagger ./
EXPOSE 8080/tcp
ENTRYPOINT ["./swagger"]
ENTRYPOINT ["/entrypoint.sh"]
+12 −0
Original line number Diff line number Diff line
curl --verbose --request POST https://mec-platform.etsi.org/sandbox-api/v1/login?provider=gitlab --header "Accept: application/json"

curl --verbose --request GET https://mec-platform.etsi.org/sandbox-api/v1/sandboxNetworkScenarios --header "Accept: application/json"

curl --verbose --request GET https://mec-platform.etsi.org/sandbox-api/v1/sandboxNetworkScenarios/4g-5g-macro-v2x --header "Accept: application/json"

curl --verbose --request POST https://mec-platform.etsi.org/sandbox-api/v1/sandboxNetworkScenarios/4g-5g-macro-v2x?sandbox_name=sbx5zg770k --header "Accept: application/json"

curl --verbose --request POST https://mec-platform.etsi.org/sandbox-api/v1/logout?sandbox_name=sbx5zg770k --header "Accept: application/json"

kubectl logs meep-auth-svc-5b68d569d8-mzfcs > meep-auth-svc.log 2>&1
kubectl logs meep-sandbox-api-6f497778b5-g5qsv > meep-sandbox-api.log 2>&1
 No newline at end of file
+117 −8
Original line number Diff line number Diff line
@@ -7,9 +7,9 @@ info:
  license:
    name: BSD-3-Clause
    url: https://forge.etsi.org/legal-matters
  version: 0.0.3
  version: 0.0.2
servers:
- url: https://loaclhost:8081/sandboxname/sandbox_api/v1
- url: http://localhost/sandbox-api/v1
paths:
  /login:
    post:
@@ -32,9 +32,12 @@ paths:
          - GITHUB
          - GITLAB (EOL ACCOUNT)
      responses:
        "302":
          description: Found
          content: {}
        "200":
          description: OK
          content: 
            application/json:
              schema:
                $ref: '#/components/schemas/Sandbox'
  /logout:
    post:
      tags:
@@ -42,6 +45,15 @@ paths:
      summary: Terminates User Session and User Sandbox
      description: Terminates User Session and User Sandbox
      operationId: logout
      parameters:
      - name: sandbox_name
        in: query
        description: sandbox name to logout
        required: true
        style: form
        explode: true
        schema:
          type: string
      responses:
        "200":
          description: OK
@@ -49,11 +61,14 @@ paths:
        "401":
          description: Unauthorized
          content: {}
        "404":
          description: Unauthorized
          content: {}
  /sandboxNetworkScenarios:
    get:
      tags:
      - Sandbox Network Scenarios
      summary: get the list of the available network scenarios
      summary: Get the list of the available network scenarios
      description: This method retrieves the list of the available network scenarios.
      operationId: SandboxNetworkScenarios_GET
      responses:
@@ -75,13 +90,48 @@ paths:
        "404":
          description: "Not Found : No network scenario found."
  /sandboxNetworkScenarios/{network_scenario_id}:
    get:
      tags:
      - Sandbox Network Scenarios
      summary: Get description of a Network Scenario to be used.
      description: This method retrive description of a the network scenario
      operationId: SandboxIndividualNetworkScenariosGET
      parameters:
      - name: network_scenario_id
        in: path
        description: Network scenario to retrieve
        required: true
        style: simple
        explode: false
        schema:
          type: string
          enum:
          - 4g-5g-macro-v2x
          - 4g-5g-wifi-macro
          - 4g-macro
          - 4g-wifi-macro
          - dual-mep-4g-5g-wifi-macro
          - dual-mep-short-path
          x-exportParamName: Provider
          x-optionalDataType: String
      responses:
        "201":
          description: "Upon success, an empty response message."
        "400":
          description: "Bad Request : used to indicate that incorrect parameters were\
            \ passed to the request."
        "401":
          description: "Unauthorized : used when the client did not submit credentials."
        "404":
          description: "Not Found :  used when a client provided a URI that cannot\
            \ be mapped to a valid resource URI."
    post:
      tags:
      - Sandbox Network Scenarios
      summary: Selects the Network Scenario to be used.
      description: This method selects the network scenario to be used. This request
        initiates the creation of necessary MEC services for specific network scenario
      operationId: SandboxNetworkScenarios_POST
      operationId: SandboxNetworkScenario_POST
      parameters:
      - name: network_scenario_id
        in: path
@@ -100,6 +150,13 @@ paths:
          - dual-mep-short-path
          x-exportParamName: Provider
          x-optionalDataType: String
      - name: sandbox_name
        description: Network scenario to retrieve
        in: query
        required: true
        style: simple
        schema:
          type: string
      responses:
        "201":
          description: "Upon success, an empty response message."
@@ -111,6 +168,48 @@ paths:
        "404":
          description: "Not Found :  used when a client provided a URI that cannot\
            \ be mapped to a valid resource URI."
    delete:
      tags:
      - Sandbox Network Scenarios
      summary: Deactivate the Network Scenario.
      description: This method deactivates the network scenario
      operationId: SandboxNetworkScenario_DELETE
      parameters:
      - name: network_scenario_id
        in: path
        description: Network scenario to be used
        required: true
        style: simple
        explode: false
        schema:
          type: string
          enum:
          - 4g-5g-macro-v2x
          - 4g-5g-wifi-macro
          - 4g-macro
          - 4g-wifi-macro
          - dual-mep-4g-5g-wifi-macro
          - dual-mep-short-path
          x-exportParamName: Provider
          x-optionalDataType: String
      - name: sandbox_name
        description: Network scenario to retrieve
        in: query
        required: true
        style: simple
        schema:
          type: string
      responses:
        "204":
          description: "Upon success, an empty response message."
        "400":
          description: "Bad Request : used to indicate that incorrect parameters were\
            \ passed to the request."
        "401":
          description: "Unauthorized : used when the client did not submit credentials."
        "404":
          description: "Not Found :  used when a client provided a URI that cannot\
            \ be mapped to a valid resource URI."
  /sandboxUeController:
    get:
      tags:
@@ -118,6 +217,14 @@ paths:
      summary: get the list of the available UEs (e.g. "Stationary UE")
      description: This method retrieves the list of the available available UEs.
      operationId: SandboxUeController_GET
      parameters:
      - name: sandbox_name
        description: Network scenario to retrieve
        in: query
        required: true
        style: simple
        schema:
          type: string
      responses:
        "200":
          description: "Upon success, a response message content containing an array\
@@ -390,8 +497,10 @@ components:
      type: object
      properties:
        name:
          type: string
          description: Sandbox name
          type: string
          x-etsi-mec-cardinality: '1'
          x-etsi-mec-origin-type: String
      description: Sandbox object
      example: {}
    ProblemDetails:
+49 −0
Original line number Diff line number Diff line
#!/bin/bash
set -e

echo "MEEP_HOST_URL: ${MEEP_HOST_URL}"
echo "MEEP_SANDBOX_NAME: ${MEEP_SANDBOX_NAME}"
echo "MEEP_MEP_NAME: ${MEEP_MEP_NAME}"
echo "MEEP_CODECOV: ${MEEP_CODECOV}"

if [[ ! -z "${MEEP_MEP_NAME}" ]]; then
    svcPath="${MEEP_SANDBOX_NAME}/${MEEP_MEP_NAME}"
else
    svcPath="${MEEP_SANDBOX_NAME}"
fi

# Update API yaml basepaths to enable "Try-it-out" feature
# OAS2: Set relative path to sandbox name + endpoint path (origin will be derived from browser URL)
# OAS3: Set full path to provided Host URL + sandbox name + endpoint path
setBasepath() {
    # OAS3
    hostName=$(echo "${MEEP_HOST_URL}" | sed -E 's/^\s*.*:\/\///g')
    echo "Replacing [localhost] with ${hostName} to url in: '$1'"
    sed -i "s,localhost,${hostName},g" "$1";

    # OAS2 and OAS3
    echo "Replacing [sandboxname] with ${svcPath} to basepath or url in: '$1'"
    sed -i "s,sandboxname,${svcPath},g" "$1";
}

# Set basepath for API files
for file in /api/*; do
    if [[ ! -e "$file" ]]; then continue; fi
    setBasepath "$file"
done

# Set basepath for user-supplied API files
for file in /user-api/*; do
    if [[ ! -e "$file" ]]; then continue; fi
    setBasepath "$file"
done

# Start service
currenttime=`date "+%Y%m%d-%H%M%S"`
filepath="/codecov/codecov-meep-sandbox-api-"
filename=$filepath$currenttime".out"
if [ "$MEEP_CODECOV" = 'true' ]; then
  exec /meep-sandbox-api -test.coverprofile=$filename __DEVEL--code-cov
else
  exec /meep-sandbox-api
fi
+49 −0
Original line number Diff line number Diff line
module github.com/InterDigitalInc/AdvantEDGE/go-apps/meep-sandbox-api

go 1.12

require (
	github.com/InterDigitalInc/AdvantEDGE/go-apps/meep-loc-serv v0.0.0-20230530211153-8f6edbeaf367 // indirect
	github.com/InterDigitalInc/AdvantEDGE/go-apps/meep-rnis v0.0.0-20230530211153-8f6edbeaf367 // indirect
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-app-support-client v0.0.0 // indirect
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-auth-svc-client v0.0.0-00010101000000-000000000000
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-key-mgr v0.0.0 // indirect
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-model v0.0.0 // indirect
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-gis-cache v0.0.0 // indirect
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-gis-engine-client v0.0.0 // indirect
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-http-logger v0.0.0 // indirect
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger v0.0.0
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-metrics v0.0.0
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-model v0.0.0 // indirect
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-mq v0.0.0
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-platform-ctrl-client v0.0.0-20230530211153-8f6edbeaf367
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-redis v0.0.0
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-sandbox-ctrl-client v0.0.0
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-service-mgmt-client v0.0.0 // indirect
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-sessions v0.0.0-20230530211153-8f6edbeaf367
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-swagger-api-mgr v0.0.0 // indirect
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-users v0.0.0-20230530211153-8f6edbeaf367
	github.com/antihax/optional v1.0.0 // indirect
	github.com/gorilla/handlers v1.4.0
	github.com/gorilla/mux v1.8.0
	github.com/prometheus/client_golang v1.9.0
)

replace (
	github.com/InterDigitalInc/AdvantEDGE/go-apps/meep-sandbox-api => ../../go-apps/meep-sandbox-api
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-app-support-client => ../../go-packages/meep-app-support-client
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-auth-svc-client => ../../go-packages/meep-auth-svc-client
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-key-mgr => ../../go-packages/meep-data-key-mgr
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-model => ../../go-packages/meep-data-model
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-gis-cache => ../../go-packages/meep-gis-cache
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-gis-engine-client => ../../go-packages/meep-gis-engine-client
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-http-logger => ../../go-packages/meep-http-logger
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger => ../../go-packages/meep-logger
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-metrics => ../../go-packages/meep-metrics
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-model => ../../go-packages/meep-model
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-mq => ../../go-packages/meep-mq
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-redis => ../../go-packages/meep-redis
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-sandbox-ctrl-client => ../../go-packages/meep-sandbox-ctrl-client
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-service-mgmt-client => ../../go-packages/meep-service-mgmt-client
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-swagger-api-mgr => ../../go-packages/meep-swagger-api-mgr
)
Loading