Loading examples/demo6/golang/go.mod +0 −4 Original line number Diff line number Diff line Loading @@ -17,11 +17,7 @@ require ( github.com/magiconair/properties v1.8.0 // indirect github.com/mitchellh/mapstructure v1.1.2 // indirect github.com/pelletier/go-toml v1.2.0 // indirect github.com/spf13/afero v1.1.2 // indirect github.com/spf13/cast v1.3.0 // indirect github.com/spf13/jwalterweatherman v1.0.0 // indirect github.com/spf13/pflag v1.0.3 // indirect golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a // indirect golang.org/x/text v0.3.0 // indirect gopkg.in/yaml.v2 v2.2.2 // indirect ) examples/demo6/golang/go.sum +1549 −0 File changed.Preview size limit exceeded, changes collapsed. Show changes examples/demo6/golang/main.go +118 −27 Original line number Diff line number Diff line Loading @@ -83,6 +83,20 @@ type ServiceInfo struct { links Links `json:"_links"` } // MEC 030 V2X Subscription type V2xMsgSubscription struct { Links *Links `json:"_links,omitempty"` CallbackReference string `json:"callbackReference,omitempty"` FilterCriteria *V2xMsgSubscriptionFilterCriteria `json:"filterCriteria"` RequestTestNotification bool `json:"requestTestNotification,omitempty"` SubscriptionType string `json:"subscriptionType"` } type V2xMsgSubscriptionFilterCriteria struct { MsgType []int32 `json:"msgType,omitempty"` StdOrganization string `json:"stdOrganization"` } // MEC Common types type LinkType struct { // URI referring to a resource href string `json:"href,omitempty"` Loading @@ -99,7 +113,7 @@ type UeContext struct { var ( dir string fileName string provider string = "github" provider string = "Jupyter2024" //"github" run bool = true done chan bool cfg *client.Configuration = nil Loading Loading @@ -140,7 +154,9 @@ const ( LIST_UES = "u" INC_UE = "x" DEC_UE = "X" MEC030_UU_SETTINGS = "z" MEC030_UU_SETTINGS = "Y" MEC030_V2X_SUB = "z" MEC030_V2X_DEL_SUB = "Z" QUIT = "q" ) Loading @@ -164,9 +180,9 @@ func menu(message string) []string { "MEC 011 Service Management:\n"+ "\t%s: Create new service, %s: Delete service\n"+ "MEC 030:\n"+ "\t%s: Get V2X UU unicast setting\n"+ "\t%s: Get V2X UU unicast setting', %s: V2X Msg subscription, %s <subID>: Delete V2X subscription\n"+ "%s: Quit\n", LOGIN, NAMESPACE, LOGOUT, LIST_SC, ACTIVATE, DEACTIVATE, SC, LIST_SERVICES, LIST_APP, CREATE_APP, DELETE_APP, LIST_UES, INC_UE, DEC_UE, MEC011_CONFIRM_READY, MEC011_REGISTRATION, MEC011_DEREGISTRATION, MEC011_CREATE_SVC, MEC011_DELETE_SVC, MEC030_UU_SETTINGS, QUIT) LOGIN, NAMESPACE, LOGOUT, LIST_SC, ACTIVATE, DEACTIVATE, SC, LIST_SERVICES, LIST_APP, CREATE_APP, DELETE_APP, LIST_UES, INC_UE, DEC_UE, MEC011_CONFIRM_READY, MEC011_REGISTRATION, MEC011_DEREGISTRATION, MEC011_CREATE_SVC, MEC011_DELETE_SVC, MEC030_UU_SETTINGS, MEC030_V2X_SUB, MEC030_V2X_DEL_SUB, QUIT) if message != "" { fmt.Println("Last message: ", message) } Loading Loading @@ -462,7 +478,7 @@ func mec011_send_confirm_ready() (body []byte, response *http.Response, err erro // Set URL url := mecUrl + "/" + sandboxName + "/" + mecPlateform + "/mec_app_support/v2/applications/" + appsInfo.Id + "/confirm_ready" fmt.Println(">>> mec011_send_confirm_ready: url: " + url) fmt.Println("mec011_send_confirm_ready: url: " + url) // Build message body json_body := "{\"indication\":\"READY\"}" io_body := strings.NewReader(json_body) Loading @@ -487,7 +503,7 @@ func mec011_send_registration() (body []byte, response *http.Response, err error // Set URL url := mecUrl + "/" + sandboxName + "/" + mecPlateform + "/mec_app_support/v2/registrations" fmt.Println(">>> mec011_send_confirm_ready: url: " + url) fmt.Println("mec011_send_confirm_ready: url: " + url) // Build message body appInfo := AppInfo{ appName: appsInfo.Name, Loading Loading @@ -522,7 +538,7 @@ func mec011_send_deregistration() (body []byte, response *http.Response, err err // Set URL url := mecUrl + "/" + sandboxName + "/" + mecPlateform + "/mec_app_support/v2/registrations/" + appsInfo.Id fmt.Println(">>> mec011_send_deregistration: url: " + url) fmt.Println("mec011_send_deregistration: url: " + url) // Send request and await response body, response, err = send_mec_service_request(http.MethodDelete, url, nil, nil, nil, nil) if err != nil { Loading @@ -546,7 +562,7 @@ func mec011_create_service() (body []byte, response *http.Response, err error) { // Set URL url := mecUrl + "/" + sandboxName + "/" + mecPlateform + "/mec_service_mgmt/v1/applications/" + appsInfo.Id + "/services" fmt.Println(">>> mec011_create_service: url: " + url) fmt.Println("mec011_create_service: url: " + url) // Build message body appServiceInfo = ServiceInfo{ serInstanceId: uuid.New().String(), Loading Loading @@ -589,7 +605,7 @@ func mec011_delete_service() (err error) { // Set URL url := mecUrl + "/" + sandboxName + "/" + mecPlateform + "/mec_service_mgmt/v1/applications/" + appsInfo.Id + "/services/" + appServiceInfo.serInstanceId fmt.Println(">>> mec011_delete_service: url: " + url) fmt.Println("mec011_delete_service: url: " + url) // Send request and await response _, _, err = send_mec_service_request(http.MethodDelete, url, nil, nil, nil, nil) if err != nil { Loading @@ -599,24 +615,6 @@ func mec011_delete_service() (err error) { return nil } func mec030_get_v2x_uu_unicast_setting() (body []byte, response *http.Response, err error) { fmt.Println(">>> mec030_get_v2x_uu_unicast_setting") // Sanity checks if sandboxName == "" { return nil, nil, errors.New("No sandbox available") } url := mecUrl + "/" + sandboxName + "/" + mecPlateform + "/vis/v2/queries/uu_unicast_provisioning_info?location_info=ecgi,33139970001614,33139971112725" fmt.Println(">>> send_mec_service_request: url: " + url) body, response, err = send_mec_service_request(http.MethodGet, url, nil, nil, nil, nil) if err != nil { return nil, nil, err } return body, response, nil } func send_mec_service_request(method string, path string, body io.Reader, vars url.Values, queryParams url.Values, location *string) (resbody []byte, res *http.Response, err error) { fmt.Println(">>> send_mec_service_request") Loading Loading @@ -687,6 +685,83 @@ func send_mec_service_request(method string, path string, body io.Reader, vars u return resbody, res, err } func mec030_get_v2x_uu_unicast_setting() (body []byte, response *http.Response, err error) { fmt.Println(">>> mec030_get_v2x_uu_unicast_setting") // Sanity checks if sandboxName == "" { return nil, nil, errors.New("No sandbox available") } url := mecUrl + "/" + sandboxName + "/" + mecPlateform + "/vis/v2/queries/uu_unicast_provisioning_info?location_info=ecgi,33139970001614,33139971112725" fmt.Println("send_mec_service_request: url: " + url) body, response, err = send_mec_service_request(http.MethodGet, url, nil, nil, nil, nil) if err != nil { return nil, nil, err } return body, response, nil } func mec030_subscribe_v2x_messages() (body []byte, response *http.Response, err error) { fmt.Println(">>> mec030_subscribe_v2x_messages") // Sanity checks if sandboxName == "" { return nil, nil, errors.New("No sandbox available") } // Set URL url := mecUrl + "/" + sandboxName + "/" + mecPlateform + "/vis/v2/subscriptions" fmt.Println("mec030_subscribe_v2x_messages: url: " + url) // Build message body var v2xMsgSubscription = V2xMsgSubscription{ CallbackReference: "http://mec-platform.etsi.org/vis/v2/v2x_msg_notification", FilterCriteria: &V2xMsgSubscriptionFilterCriteria{ MsgType: []int32{1, 2}, StdOrganization: "ETSI", }, SubscriptionType: "V2xMsgSubscription", } json_body, err := json.Marshal(v2xMsgSubscription) if err != nil { return nil, nil, err } io_body := bytes.NewReader(json_body) // Send request and await response body, response, err = send_mec_service_request(http.MethodPost, url, io_body, nil, nil, nil) if err != nil { return nil, nil, err } return body, response, nil } func mec030_delete_v2x_messages_subscription(choice string) (response *http.Response, err error) { fmt.Println(">>> mec030_delete_v2x_messages_subscription: ", choice) // Sanity checks if sandboxName == "" { return nil, errors.New("No sandbox available") } // Set URL url := mecUrl + "/" + sandboxName + "/" + mecPlateform + "/vis/v2/subscriptions/" + choice fmt.Println("mec030_delete_v2x_messages_subscription: url: " + url) // Send request and await response _, response, err = send_mec_service_request(http.MethodDelete, url, nil, nil, nil, nil) if err != nil { return nil, err } return response, nil } func v2x_msg_notification(w http.ResponseWriter, r *http.Request) { fmt.Println(">>> v2x_msg_notification: ", r) w.WriteHeader(http.StatusOK) } func main() { if len(os.Args) < 2 { // no config argument Loading Loading @@ -992,6 +1067,22 @@ func process_choice(choice []string) string { return err.Error() } message = fmt.Sprintf("response body: %s", string(body)) } else if strings.Compare(choice[0], MEC030_V2X_SUB) == 0 { var err error body, _, err := mec030_subscribe_v2x_messages() if err != nil { return err.Error() } message = fmt.Sprintf("response body: %s", string(body)) } else if strings.Compare(choice[0], MEC030_V2X_DEL_SUB) == 0 { if len(choice) == 1 { return fmt.Sprintf("Subscription ID is not set") } _, err := mec030_delete_v2x_messages_subscription(choice[1]) if err != nil { return err.Error() } message = fmt.Sprintf("response body: Subscription %s deleted", choice[1]) } else { message = fmt.Sprintf("Invalid command: %s", choice) } Loading examples/demo6/golang/routers.go +3 −3 Original line number Diff line number Diff line Loading @@ -67,8 +67,8 @@ var routes = Routes{ }, Route{ "Index", "GET", "/demo6/v1/", Index, "POST", "/vis/v2/v2x_msg_notification", v2x_msg_notification, }, } Loading
examples/demo6/golang/go.mod +0 −4 Original line number Diff line number Diff line Loading @@ -17,11 +17,7 @@ require ( github.com/magiconair/properties v1.8.0 // indirect github.com/mitchellh/mapstructure v1.1.2 // indirect github.com/pelletier/go-toml v1.2.0 // indirect github.com/spf13/afero v1.1.2 // indirect github.com/spf13/cast v1.3.0 // indirect github.com/spf13/jwalterweatherman v1.0.0 // indirect github.com/spf13/pflag v1.0.3 // indirect golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a // indirect golang.org/x/text v0.3.0 // indirect gopkg.in/yaml.v2 v2.2.2 // indirect )
examples/demo6/golang/go.sum +1549 −0 File changed.Preview size limit exceeded, changes collapsed. Show changes
examples/demo6/golang/main.go +118 −27 Original line number Diff line number Diff line Loading @@ -83,6 +83,20 @@ type ServiceInfo struct { links Links `json:"_links"` } // MEC 030 V2X Subscription type V2xMsgSubscription struct { Links *Links `json:"_links,omitempty"` CallbackReference string `json:"callbackReference,omitempty"` FilterCriteria *V2xMsgSubscriptionFilterCriteria `json:"filterCriteria"` RequestTestNotification bool `json:"requestTestNotification,omitempty"` SubscriptionType string `json:"subscriptionType"` } type V2xMsgSubscriptionFilterCriteria struct { MsgType []int32 `json:"msgType,omitempty"` StdOrganization string `json:"stdOrganization"` } // MEC Common types type LinkType struct { // URI referring to a resource href string `json:"href,omitempty"` Loading @@ -99,7 +113,7 @@ type UeContext struct { var ( dir string fileName string provider string = "github" provider string = "Jupyter2024" //"github" run bool = true done chan bool cfg *client.Configuration = nil Loading Loading @@ -140,7 +154,9 @@ const ( LIST_UES = "u" INC_UE = "x" DEC_UE = "X" MEC030_UU_SETTINGS = "z" MEC030_UU_SETTINGS = "Y" MEC030_V2X_SUB = "z" MEC030_V2X_DEL_SUB = "Z" QUIT = "q" ) Loading @@ -164,9 +180,9 @@ func menu(message string) []string { "MEC 011 Service Management:\n"+ "\t%s: Create new service, %s: Delete service\n"+ "MEC 030:\n"+ "\t%s: Get V2X UU unicast setting\n"+ "\t%s: Get V2X UU unicast setting', %s: V2X Msg subscription, %s <subID>: Delete V2X subscription\n"+ "%s: Quit\n", LOGIN, NAMESPACE, LOGOUT, LIST_SC, ACTIVATE, DEACTIVATE, SC, LIST_SERVICES, LIST_APP, CREATE_APP, DELETE_APP, LIST_UES, INC_UE, DEC_UE, MEC011_CONFIRM_READY, MEC011_REGISTRATION, MEC011_DEREGISTRATION, MEC011_CREATE_SVC, MEC011_DELETE_SVC, MEC030_UU_SETTINGS, QUIT) LOGIN, NAMESPACE, LOGOUT, LIST_SC, ACTIVATE, DEACTIVATE, SC, LIST_SERVICES, LIST_APP, CREATE_APP, DELETE_APP, LIST_UES, INC_UE, DEC_UE, MEC011_CONFIRM_READY, MEC011_REGISTRATION, MEC011_DEREGISTRATION, MEC011_CREATE_SVC, MEC011_DELETE_SVC, MEC030_UU_SETTINGS, MEC030_V2X_SUB, MEC030_V2X_DEL_SUB, QUIT) if message != "" { fmt.Println("Last message: ", message) } Loading Loading @@ -462,7 +478,7 @@ func mec011_send_confirm_ready() (body []byte, response *http.Response, err erro // Set URL url := mecUrl + "/" + sandboxName + "/" + mecPlateform + "/mec_app_support/v2/applications/" + appsInfo.Id + "/confirm_ready" fmt.Println(">>> mec011_send_confirm_ready: url: " + url) fmt.Println("mec011_send_confirm_ready: url: " + url) // Build message body json_body := "{\"indication\":\"READY\"}" io_body := strings.NewReader(json_body) Loading @@ -487,7 +503,7 @@ func mec011_send_registration() (body []byte, response *http.Response, err error // Set URL url := mecUrl + "/" + sandboxName + "/" + mecPlateform + "/mec_app_support/v2/registrations" fmt.Println(">>> mec011_send_confirm_ready: url: " + url) fmt.Println("mec011_send_confirm_ready: url: " + url) // Build message body appInfo := AppInfo{ appName: appsInfo.Name, Loading Loading @@ -522,7 +538,7 @@ func mec011_send_deregistration() (body []byte, response *http.Response, err err // Set URL url := mecUrl + "/" + sandboxName + "/" + mecPlateform + "/mec_app_support/v2/registrations/" + appsInfo.Id fmt.Println(">>> mec011_send_deregistration: url: " + url) fmt.Println("mec011_send_deregistration: url: " + url) // Send request and await response body, response, err = send_mec_service_request(http.MethodDelete, url, nil, nil, nil, nil) if err != nil { Loading @@ -546,7 +562,7 @@ func mec011_create_service() (body []byte, response *http.Response, err error) { // Set URL url := mecUrl + "/" + sandboxName + "/" + mecPlateform + "/mec_service_mgmt/v1/applications/" + appsInfo.Id + "/services" fmt.Println(">>> mec011_create_service: url: " + url) fmt.Println("mec011_create_service: url: " + url) // Build message body appServiceInfo = ServiceInfo{ serInstanceId: uuid.New().String(), Loading Loading @@ -589,7 +605,7 @@ func mec011_delete_service() (err error) { // Set URL url := mecUrl + "/" + sandboxName + "/" + mecPlateform + "/mec_service_mgmt/v1/applications/" + appsInfo.Id + "/services/" + appServiceInfo.serInstanceId fmt.Println(">>> mec011_delete_service: url: " + url) fmt.Println("mec011_delete_service: url: " + url) // Send request and await response _, _, err = send_mec_service_request(http.MethodDelete, url, nil, nil, nil, nil) if err != nil { Loading @@ -599,24 +615,6 @@ func mec011_delete_service() (err error) { return nil } func mec030_get_v2x_uu_unicast_setting() (body []byte, response *http.Response, err error) { fmt.Println(">>> mec030_get_v2x_uu_unicast_setting") // Sanity checks if sandboxName == "" { return nil, nil, errors.New("No sandbox available") } url := mecUrl + "/" + sandboxName + "/" + mecPlateform + "/vis/v2/queries/uu_unicast_provisioning_info?location_info=ecgi,33139970001614,33139971112725" fmt.Println(">>> send_mec_service_request: url: " + url) body, response, err = send_mec_service_request(http.MethodGet, url, nil, nil, nil, nil) if err != nil { return nil, nil, err } return body, response, nil } func send_mec_service_request(method string, path string, body io.Reader, vars url.Values, queryParams url.Values, location *string) (resbody []byte, res *http.Response, err error) { fmt.Println(">>> send_mec_service_request") Loading Loading @@ -687,6 +685,83 @@ func send_mec_service_request(method string, path string, body io.Reader, vars u return resbody, res, err } func mec030_get_v2x_uu_unicast_setting() (body []byte, response *http.Response, err error) { fmt.Println(">>> mec030_get_v2x_uu_unicast_setting") // Sanity checks if sandboxName == "" { return nil, nil, errors.New("No sandbox available") } url := mecUrl + "/" + sandboxName + "/" + mecPlateform + "/vis/v2/queries/uu_unicast_provisioning_info?location_info=ecgi,33139970001614,33139971112725" fmt.Println("send_mec_service_request: url: " + url) body, response, err = send_mec_service_request(http.MethodGet, url, nil, nil, nil, nil) if err != nil { return nil, nil, err } return body, response, nil } func mec030_subscribe_v2x_messages() (body []byte, response *http.Response, err error) { fmt.Println(">>> mec030_subscribe_v2x_messages") // Sanity checks if sandboxName == "" { return nil, nil, errors.New("No sandbox available") } // Set URL url := mecUrl + "/" + sandboxName + "/" + mecPlateform + "/vis/v2/subscriptions" fmt.Println("mec030_subscribe_v2x_messages: url: " + url) // Build message body var v2xMsgSubscription = V2xMsgSubscription{ CallbackReference: "http://mec-platform.etsi.org/vis/v2/v2x_msg_notification", FilterCriteria: &V2xMsgSubscriptionFilterCriteria{ MsgType: []int32{1, 2}, StdOrganization: "ETSI", }, SubscriptionType: "V2xMsgSubscription", } json_body, err := json.Marshal(v2xMsgSubscription) if err != nil { return nil, nil, err } io_body := bytes.NewReader(json_body) // Send request and await response body, response, err = send_mec_service_request(http.MethodPost, url, io_body, nil, nil, nil) if err != nil { return nil, nil, err } return body, response, nil } func mec030_delete_v2x_messages_subscription(choice string) (response *http.Response, err error) { fmt.Println(">>> mec030_delete_v2x_messages_subscription: ", choice) // Sanity checks if sandboxName == "" { return nil, errors.New("No sandbox available") } // Set URL url := mecUrl + "/" + sandboxName + "/" + mecPlateform + "/vis/v2/subscriptions/" + choice fmt.Println("mec030_delete_v2x_messages_subscription: url: " + url) // Send request and await response _, response, err = send_mec_service_request(http.MethodDelete, url, nil, nil, nil, nil) if err != nil { return nil, err } return response, nil } func v2x_msg_notification(w http.ResponseWriter, r *http.Request) { fmt.Println(">>> v2x_msg_notification: ", r) w.WriteHeader(http.StatusOK) } func main() { if len(os.Args) < 2 { // no config argument Loading Loading @@ -992,6 +1067,22 @@ func process_choice(choice []string) string { return err.Error() } message = fmt.Sprintf("response body: %s", string(body)) } else if strings.Compare(choice[0], MEC030_V2X_SUB) == 0 { var err error body, _, err := mec030_subscribe_v2x_messages() if err != nil { return err.Error() } message = fmt.Sprintf("response body: %s", string(body)) } else if strings.Compare(choice[0], MEC030_V2X_DEL_SUB) == 0 { if len(choice) == 1 { return fmt.Sprintf("Subscription ID is not set") } _, err := mec030_delete_v2x_messages_subscription(choice[1]) if err != nil { return err.Error() } message = fmt.Sprintf("response body: Subscription %s deleted", choice[1]) } else { message = fmt.Sprintf("Invalid command: %s", choice) } Loading
examples/demo6/golang/routers.go +3 −3 Original line number Diff line number Diff line Loading @@ -67,8 +67,8 @@ var routes = Routes{ }, Route{ "Index", "GET", "/demo6/v1/", Index, "POST", "/vis/v2/v2x_msg_notification", v2x_msg_notification, }, }