Commit 5f1c66ef authored by Mubeena Ishaq's avatar Mubeena Ishaq
Browse files

fix minor issues for meep-app-enablement

parent 97d64753
Loading
Loading
Loading
Loading
+33 −9
Original line number Diff line number Diff line
@@ -466,7 +466,7 @@ func applicationsSubscriptionGET(w http.ResponseWriter, r *http.Request) {

	// Validate subscription
	if sub.Cfg.AppId != appId || sub.Cfg.Type != APP_TERMINATION_NOTIF_SUB_TYPE {
		err = errors.New("Subscription not found")
		err = errors.New("subscription not found")
		log.Error(err.Error())
		errHandlerProblemDetails(w, err.Error(), http.StatusNotFound)
		return
@@ -519,7 +519,7 @@ func applicationsSubscriptionDELETE(w http.ResponseWriter, r *http.Request) {

	// Validate subscription
	if sub.Cfg.AppId != appId || sub.Cfg.Type != APP_TERMINATION_NOTIF_SUB_TYPE {
		err = errors.New("Subscription not found")
		err = errors.New("subscription not found")
		log.Error(err.Error())
		errHandlerProblemDetails(w, err.Error(), http.StatusNotFound)
		return
@@ -588,7 +588,6 @@ func applicationsSubscriptionsGET(w http.ResponseWriter, r *http.Request) {
	for _, sub := range subList {
		// Create subscription reference & append it to link list
		subscription := MecAppSuptApiSubscriptionLinkListSubscription{
			// In v2.2.1 it should be SubscriptionType, but spec is expecting "rel" as per v1.1.1
			SubscriptionType: APP_TERMINATION_NOTIF_SUB_TYPE,
			Href:             sub.Cfg.Self,
		}
@@ -647,6 +646,13 @@ func timingCurrentTimeGET(w http.ResponseWriter, r *http.Request) {
	fmt.Fprint(w, string(jsonResponse))
}

/*
* appRegistrationPOST handles the registration of applications.
* It decodes the request body into an AppInfo struct, validates mandatory parameters, retrieves app instance information, validates the app info, and stores it in Redis.
* @param {string} keyName	App Info stored with this key
* @param {jsonResponse} contains APP Info response
* @return {error} error An error will return if occurs
 */
func appRegistrationPOST(w http.ResponseWriter, r *http.Request) {
	log.Info(">>> appRegistrationPOST: ", r)

@@ -677,7 +683,7 @@ func appRegistrationPOST(w http.ResponseWriter, r *http.Request) {

	if appInfo.IsInsByMec == false && appInfo.Endpoint == nil {
		log.Error("Shall be present when IsInsByMec is FALSE")
		errHandlerProblemDetails(w, "Shall be present when IsInsByMec is FALSE.", http.StatusBadRequest)
		errHandlerProblemDetails(w, "Endpoint shall be present when IsInsByMec is FALSE.", http.StatusBadRequest)
		return
	}

@@ -725,6 +731,13 @@ func appRegistrationPOST(w http.ResponseWriter, r *http.Request) {
	fmt.Fprint(w, jsonResponse)
}

/*
* appRegistrationGET handles retrieving the registration information of an application.
* It fetches the appInstanceId from the URL variables, retrieves the associated application info from Redis, and sends it back in the response. If the appInstanceId is not found or an error occurs, it responds with the appropriate status and error message.
* @param {http.ResponseWriter} w   HTTP response writer
* @param {string} jsonAppInfo Application information
* @return {error} error An error will return if occurs
 */
func appRegistrationGET(w http.ResponseWriter, r *http.Request) {
	log.Info(">>> appRegistrationGET: ", r)

@@ -763,6 +776,14 @@ func appRegistrationGET(w http.ResponseWriter, r *http.Request) {
	fmt.Fprint(w, jsonResponse)
}

/*
* appRegistrationPUT modifies the registration information of an application.
* It fetches the appInstanceId from the URL variables, decodes the request body into an AppInfo struct, validates the parameters, checks for the existence of the app info in Redis, updates the Redis entry if validation passes,and responds with the appropriate status.
* @param {string} jsonAppInfo Application information
* @param {http.ResponseWriter} w   HTTP response writer
* @param {http.Request} r          HTTP request
* @return {error} error An error will return if occurs
 */
func appRegistrationPUT(w http.ResponseWriter, r *http.Request) {
	log.Info(">>> appRegistrationPUT: ", r)

@@ -820,13 +841,16 @@ func appRegistrationPUT(w http.ResponseWriter, r *http.Request) {
		log.Error("Failed to store AppInfo in the redis DB: ", err)
	}

	// Prepare & send response
	jsonResponse := convertAppInfoToJson(&appInfoPut)

	w.WriteHeader(http.StatusOK)
	fmt.Fprint(w, jsonResponse)
	w.WriteHeader(http.StatusNoContent)
}

/*
* appRegistrationDELETE handles the deletion of an application's registration information.
* It fetches the appInstanceId from the URL variables, checks if the app info exists in Redis, deletes the Redis entry if it exists, and responds with the appropriate status.
* @param {http.ResponseWriter} w   HTTP response writer
* @param {http.Request} r          HTTP request
* @return {error} error An error will return if occurs
 */
func appRegistrationDELETE(w http.ResponseWriter, r *http.Request) {
	log.Info("Delete appInfo by appInstanceId")

+2 −2
Original line number Diff line number Diff line
@@ -12,8 +12,8 @@ To see how to make this your own, look here:

[README](https://github.com/swagger-api/swagger-codegen/blob/master/README.md)

- API version: 2.2.1
- Build date: 2022-12-19T08:32:22.065107-05:00[America/Toronto]
- API version: 3.1.1
- Build date: 2024-03-25T08:32:22.065107-05:00


### Running the server
+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
 *
 * MEC Service Management Service is AdvantEDGE's implementation of [ETSI MEC ISG MEC011 Application Enablement API](https://www.etsi.org/deliver/etsi_gs/MEC/001_099/011/03.01.01_60/gs_MEC011v030101p.pdf) <p>[Copyright (c) ETSI 2024](https://forge.etsi.org/etsi-forge-copyright-notice.txt) <p>**Micro-service**<br>[meep-app-enablement](https://github.com/InterDigitalInc/AdvantEDGE/tree/master/go-apps/meep-app-enablement/server/service-mgmt) <p>**Type & Usage**<br>Edge Service used by edge applications that want to get information about services in the network <p>**Note**<br>AdvantEDGE supports all of Service Management API endpoints (see below).
 *
 * API version: 2.2.1
 * API version: 3.1.1
 * Contact: AdvantEDGE@InterDigital.com
 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
 */