Commit 30440d36 authored by Yann Garcia's avatar Yann Garcia
Browse files

Finalyse the first version of the PoC (no authentication, no metrics)

parent 3c832c6f
Loading
Loading
Loading
Loading
+87 −1
Original line number Diff line number Diff line
Demo 6 is a MEC application to illustrate the usage of the MEC Sandbox command line APIs.

go version 1.18 is required to build demo 6
# How to use it

go version 1.18+ is required to build demo 6

```sh
~$ docker pull golang
~$ cd ~/AdvantEDGE/examples/demo6 
~/AdvantEDGE/examples/demo6$ docker run --rm -it -v$PWD:/opt/local/etsi/demo6 golang bash -c "cd /opt/local/etsi/demo6 && ./build-demo6.sh"
~/AdvantEDGE/examples/demo6$ docker run --rm -it -v$PWD:/opt/local/etsi/demo6 golang
```

# Menu description

Below is the menu proposed by the demo6 application:

```sh
Mandatory commands:
        l: Login, L: Logout, s: Get scenarios list
        a <index>: Activate a scenario, d <index>: Terminate a scenario
Optional commands:
        S <index>: Get scenario description
        m: Get MEC services list
        i: Get application instances list, c: Create a new application instance, D: Delete a new application instance
MEC 030:
        u: Get V2X UU unicast setting
q: Quit
Enter your choice:
```

## Mandatories commands

Mandatories commands are the sequence of command to execute before to execute with the optionals commands.

### Login command

The Login command (l) authenticates and authorizes the MEC application demo6 and creates a new MEC sandbox instance.

### Logout command

The Logout command (L) terminates an existing MEC sandbox instance.

### Get scenarios list

After the login step, it is mandatory to request the list of available network scenarios in order to execute with the optional commands.

## Optional commands

### Get scenario description

This option (S) uses the index of the network scenario (starting from 0) to retrieve the description of the selected network scenario.

### Activate a network scenario

This option (a) uses the index of the network scenario (starting from 0) to activate the selected network scenario. This command requests the MEC Sandbox instance to start all the MEC services attached to the activated network scenario.

### Deactivate a network scenario

This option (d) uses the index of the network scenario (starting from 0) to deactivate the selected network scenario. This command requests the MEC Sandbox instance to terminate all the MEC services attached to the activated network scenario.

### Get MEC services list

This option (m) retrieves the list of the MEC services available with the activated network scenario.

### Get application instances list

This option (i) retrieves the list of the MEC applications available with the activated network scenario.

### Create a new application instance

This option (c) creates the a new USER MEC application. The application instance id is generated automatically and its name is "demo6".
This new application is attached to "mep1".

### Delete a new application instance

This option (D) terminates an existing MEC application.

## MEC Services commands

Theses commands provides some example of access to the MEC services available with the activated network scenario.

### Get V2X UU unicast setting

This option (u) retrieve the UU Unicast settings from the MEC 030 service. To use it, the V2X network scenarion shall be activated (see [Activate a network scenario](#activate_a_network_scenario)).

## Terminate the demo6 application

The command Quit (q) terminates the demo6 application. If a Login commands was executed, the termination process does the logout.
+10 −8
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ The MEC Sandbox API described using OpenAPI
## Overview
This API client was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project.  By using the [swagger-spec](https://github.com/swagger-api/swagger-spec) from a remote server, you can easily generate an API client.

- API version: 0.0.6
- API version: 0.0.7
- Package version: 1.0.0
- Build package: io.swagger.codegen.v3.generators.go.GoClientCodegen

@@ -21,22 +21,24 @@ All URIs are relative to *http://localhost/sandbox-api/v1*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*AuthorizationApi* | [**Login**](docs/AuthorizationApi.md#login) | **Post** /login | Initiate OAuth login procedure and creates MEC Sandbox
*AuthorizationApi* | [**Logout**](docs/AuthorizationApi.md#logout) | **Post** /logout | Terminates User Session and User Sandbox
*SandboxAppInstancesApi* | [**SandboxAppInstancesGET**](docs/SandboxAppInstancesApi.md#sandboxappinstancesget) | **Get** /sandboxAppInstances | get the list of the available application instance identifier
*AuthorizationApi* | [**Login**](docs/AuthorizationApi.md#login) | **Post** /login | Initiate OAuth login procedure and creates a MEC Sandbox instance
*AuthorizationApi* | [**Logout**](docs/AuthorizationApi.md#logout) | **Post** /logout | Terminates User Session and delete the Sandbox instance
*SandboxAppInstancesApi* | [**SandboxAppInstancesDELETE**](docs/SandboxAppInstancesApi.md#sandboxappinstancesdelete) | **Delete** /sandboxAppInstances/{app_instance_id} | Delete an existing application instance
*SandboxAppInstancesApi* | [**SandboxAppInstancesGET**](docs/SandboxAppInstancesApi.md#sandboxappinstancesget) | **Get** /sandboxAppInstances | Get the list of the available application instance identifiers
*SandboxAppInstancesApi* | [**SandboxAppInstancesPOST**](docs/SandboxAppInstancesApi.md#sandboxappinstancespost) | **Post** /sandboxAppInstances | Create a new application instance identifier
*SandboxLogsSubscriptionsApi* | [**SandboxLogsSubscriptionsDELETE**](docs/SandboxLogsSubscriptionsApi.md#sandboxlogssubscriptionsdelete) | **Delete** /sandboxLogsSubscriptions/{subscription_reference} | Subscription to receive logs from the sandbox
*SandboxLogsSubscriptionsApi* | [**SandboxLogsSubscriptionsPOST**](docs/SandboxLogsSubscriptionsApi.md#sandboxlogssubscriptionspost) | **Post** /sandboxLogsSubscriptions | Subscription to receive logs from the sandbox
*SandboxMECServicesApi* | [**SandboxMecServicesGET**](docs/SandboxMECServicesApi.md#sandboxmecservicesget) | **Get** /sandboxMecServices | get the list of the available MEC services
*SandboxMECServicesApi* | [**SandboxMecServicesPOST**](docs/SandboxMECServicesApi.md#sandboxmecservicespost) | **Post** /sandboxMecServices/{mec_service_name} | select the MEC services to use
*SandboxMECServicesApi* | [**SandboxMecServicesGET**](docs/SandboxMECServicesApi.md#sandboxmecservicesget) | **Get** /sandboxMecServices | Get the list of the available MEC services
*SandboxNetworkScenariosApi* | [**SandboxIndividualNetworkScenariosGET**](docs/SandboxNetworkScenariosApi.md#sandboxindividualnetworkscenariosget) | **Get** /sandboxNetworkScenarios/{network_scenario_id} | Get description of a Network Scenario to be used.
*SandboxNetworkScenariosApi* | [**SandboxNetworkScenarioDELETE**](docs/SandboxNetworkScenariosApi.md#sandboxnetworkscenariodelete) | **Delete** /sandboxNetworkScenarios/{network_scenario_id} | Deactivate the Network Scenario.
*SandboxNetworkScenariosApi* | [**SandboxNetworkScenarioPOST**](docs/SandboxNetworkScenariosApi.md#sandboxnetworkscenariopost) | **Post** /sandboxNetworkScenarios/{network_scenario_id} | Selects the Network Scenario to be used.
*SandboxNetworkScenariosApi* | [**SandboxNetworkScenariosGET**](docs/SandboxNetworkScenariosApi.md#sandboxnetworkscenariosget) | **Get** /sandboxNetworkScenarios | Get the list of the available network scenarios
*SandboxUEControllerApi* | [**SandboxUeControllerGET**](docs/SandboxUEControllerApi.md#sandboxuecontrollerget) | **Get** /sandboxUeController | get the list of the available UEs (e.g. \&quot;Stationary UE\&quot;)
*SandboxUEControllerApi* | [**SandboxUeControllerPATCH**](docs/SandboxUEControllerApi.md#sandboxuecontrollerpatch) | **Patch** /sandboxUeController/{user_equipment_id} | set the new value of the UE
*SandboxUEControllerApi* | [**SandboxUeControllerGET**](docs/SandboxUEControllerApi.md#sandboxuecontrollerget) | **Get** /sandboxUeController | Get the list of the available UEs (e.g. \&quot;Stationary UE\&quot;)
*SandboxUEControllerApi* | [**SandboxUeControllerPATCH**](docs/SandboxUEControllerApi.md#sandboxuecontrollerpatch) | **Patch** /sandboxUeController/{user_equipment_id}/{user_equipment_value} | set the new value of the UE

## Documentation For Models

 - [ApplicationInfo](docs/ApplicationInfo.md)
 - [CellularDomainConfig](docs/CellularDomainConfig.md)
 - [CellularPoaConfig](docs/CellularPoaConfig.md)
 - [ConnectivityConfig](docs/ConnectivityConfig.md)
+591 −477

File changed.

Preview size limit exceeded, changes collapsed.

+5 −5
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@
 *
 * The MEC Sandbox API described using OpenAPI
 *
 * API version: 0.0.6
 * API version: 0.0.7
 * Contact: cti_support@etsi.org
 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
 */
@@ -25,8 +25,8 @@ var (

type AuthorizationApiService service
/*
AuthorizationApiService Initiate OAuth login procedure and creates MEC Sandbox
Redirect the browser to the provider login page and creates your MEC Sandbox on successful login and authorization
AuthorizationApiService Initiate OAuth login procedure and creates a MEC Sandbox instance
Initiate OAuth login procedure and creates a MEC Sandbox instance
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param provider Oauth provider
@return Sandbox
@@ -110,8 +110,8 @@ func (a *AuthorizationApiService) Login(ctx context.Context, provider string) (S
	return localVarReturnValue, localVarHttpResponse, nil
}
/*
AuthorizationApiService Terminates User Session and User Sandbox
Terminates User Session and User Sandbox
AuthorizationApiService Terminates User Session and delete the Sandbox instance
Terminates User Session and delete the Sandbox instance
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param sandboxName Sandbox identifier

+180 −19
Original line number Diff line number Diff line

/*
 * MEC Sandbox API
 *
 * The MEC Sandbox API described using OpenAPI
 *
 * API version: 0.0.6
 * API version: 0.0.7
 * Contact: cti_support@etsi.org
 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
 */
@@ -12,6 +11,7 @@ package client

import (
	"context"
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"
@@ -24,23 +24,95 @@ var (
)

type SandboxAppInstancesApiService service

/*
SandboxAppInstancesApiService Delete an existing application instance
This method removes an existing application instance
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param sandboxName Sandbox identifier
 * @param appInstanceId It uniquely identifies a MEC application instance identifier

*/
func (a *SandboxAppInstancesApiService) SandboxAppInstancesDELETE(ctx context.Context, sandboxName string, appInstanceId string) (*http.Response, error) {
	var (
		localVarHttpMethod = strings.ToUpper("Delete")
		localVarPostBody   interface{}
		localVarFileName   string
		localVarFileBytes  []byte
	)

	// create path and map variables
	localVarPath := a.client.cfg.BasePath + "/sandboxAppInstances/{sandbox_name}/{app_instance_id}"
	localVarPath = strings.Replace(localVarPath, "{"+"sandbox_name"+"}", fmt.Sprintf("%v", sandboxName), -1)
	localVarPath = strings.Replace(localVarPath, "{"+"app_instance_id"+"}", fmt.Sprintf("%v", appInstanceId), -1)

	localVarHeaderParams := make(map[string]string)
	localVarQueryParams := url.Values{}
	localVarFormParams := url.Values{}

	// to determine the Content-Type header
	localVarHttpContentTypes := []string{}

	// set Content-Type header
	localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
	if localVarHttpContentType != "" {
		localVarHeaderParams["Content-Type"] = localVarHttpContentType
	}

	// to determine the Accept header
	localVarHttpHeaderAccepts := []string{}

	// set Accept header
	localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
	if localVarHttpHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
	}
	r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
	if err != nil {
		return nil, err
	}

	localVarHttpResponse, err := a.client.callAPI(r)
	if err != nil || localVarHttpResponse == nil {
		return localVarHttpResponse, err
	}

	localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
	localVarHttpResponse.Body.Close()
	if err != nil {
		return localVarHttpResponse, err
	}

	if localVarHttpResponse.StatusCode >= 300 {
		newErr := GenericSwaggerError{
			body:  localVarBody,
			error: localVarHttpResponse.Status,
		}
		return localVarHttpResponse, newErr
	}

	return localVarHttpResponse, nil
}

/*
SandboxAppInstancesApiService get the list of the available application instance identifier
This method retrieves the list of the available application instance identifier.
SandboxAppInstancesApiService Get the list of the available application instance identifiers
This method retrieves the list of the available application instance identifiers
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return []SandboxAppInstances
 * @param sandboxName Sandbox identifier
@return []ApplicationInfo
*/
func (a *SandboxAppInstancesApiService) SandboxAppInstancesGET(ctx context.Context) ([]SandboxAppInstances, *http.Response, error) {
func (a *SandboxAppInstancesApiService) SandboxAppInstancesGET(ctx context.Context, sandboxName string) ([]ApplicationInfo, *http.Response, error) {
	var (
		localVarHttpMethod  = strings.ToUpper("Get")
		localVarPostBody    interface{}
		localVarFileName    string
		localVarFileBytes   []byte
		localVarReturnValue []SandboxAppInstances
		localVarReturnValue []ApplicationInfo
	)

	// create path and map variables
	localVarPath := a.client.cfg.BasePath + "/sandboxAppInstances"
	localVarPath := a.client.cfg.BasePath + "/sandboxAppInstances/{sandbox_name}"
	localVarPath = strings.Replace(localVarPath, "{"+"sandbox_name"+"}", fmt.Sprintf("%v", sandboxName), -1)

	localVarHeaderParams := make(map[string]string)
	localVarQueryParams := url.Values{}
@@ -81,7 +153,7 @@ func (a *SandboxAppInstancesApiService) SandboxAppInstancesGET(ctx context.Conte

	if localVarHttpResponse.StatusCode < 300 {
		// If we succeed, return the data, otherwise pass on to decode error.
		err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
		err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
		if err == nil {
			return localVarReturnValue, localVarHttpResponse, err
		}
@@ -93,8 +165,97 @@ func (a *SandboxAppInstancesApiService) SandboxAppInstancesGET(ctx context.Conte
			error: localVarHttpResponse.Status,
		}
		if localVarHttpResponse.StatusCode == 200 {
			var v []SandboxAppInstances
			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
			var v []ApplicationInfo
			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHttpResponse, newErr
			}
			newErr.model = v
			return localVarReturnValue, localVarHttpResponse, newErr
		}
		return localVarReturnValue, localVarHttpResponse, newErr
	}

	return localVarReturnValue, localVarHttpResponse, nil
}

/*
SandboxAppInstancesApiService Create a new application instance identifier
This method creates a new application instance
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param body Pet to add to the store
 * @param sandboxName Sandbox identifier
@return []ApplicationInfo
*/
func (a *SandboxAppInstancesApiService) SandboxAppInstancesPOST(ctx context.Context, body ApplicationInfo, sandboxName string) ([]ApplicationInfo, *http.Response, error) {
	var (
		localVarHttpMethod  = strings.ToUpper("Post")
		localVarPostBody    interface{}
		localVarFileName    string
		localVarFileBytes   []byte
		localVarReturnValue []ApplicationInfo
	)

	// create path and map variables
	localVarPath := a.client.cfg.BasePath + "/sandboxAppInstances/{sandbox_name}"
	localVarPath = strings.Replace(localVarPath, "{"+"sandbox_name"+"}", fmt.Sprintf("%v", sandboxName), -1)

	localVarHeaderParams := make(map[string]string)
	localVarQueryParams := url.Values{}
	localVarFormParams := url.Values{}

	// to determine the Content-Type header
	localVarHttpContentTypes := []string{"application/json"}

	// set Content-Type header
	localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
	if localVarHttpContentType != "" {
		localVarHeaderParams["Content-Type"] = localVarHttpContentType
	}

	// to determine the Accept header
	localVarHttpHeaderAccepts := []string{"application/json"}

	// set Accept header
	localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
	if localVarHttpHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
	}
	// body params
	localVarPostBody = &body
	r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
	if err != nil {
		return localVarReturnValue, nil, err
	}

	localVarHttpResponse, err := a.client.callAPI(r)
	if err != nil || localVarHttpResponse == nil {
		return localVarReturnValue, localVarHttpResponse, err
	}

	localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
	localVarHttpResponse.Body.Close()
	if err != nil {
		return localVarReturnValue, localVarHttpResponse, err
	}

	if localVarHttpResponse.StatusCode < 300 {
		// If we succeed, return the data, otherwise pass on to decode error.
		err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
		if err == nil {
			return localVarReturnValue, localVarHttpResponse, err
		}
	}

	if localVarHttpResponse.StatusCode >= 300 {
		newErr := GenericSwaggerError{
			body:  localVarBody,
			error: localVarHttpResponse.Status,
		}
		if localVarHttpResponse.StatusCode == 201 {
			var v []ApplicationInfo
			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHttpResponse, newErr
Loading