free5gc / smf

Apache License 2.0
16 stars 89 forks source link

Add REST APIs to user_plane_information (upNodes, links). #64

Closed aviweit closed 1 year ago

aviweit commented 1 year ago

This PR addresses the task item mentioned in pkg/factory/factory.go ("Support configuration update from REST api") It introduces the below REST APIs:

Get upNodes

List list_user_plane_information upNodes

curl -H "Content-type: application/json" -X GET http://<smf_ip_address>:<smf_port>/upi/v1/upNodes

REST path:

    smf_ip_address - ipaddress of SMF service
    smf_port       - the service port

Return:

    status - 200
    list of upNode elements (json)

Post upNodes

Add upNodes to user_plane_information

curl -H "Content-type: application/json" -X POST -d '{ "upNodes": {...} }' http://<smf_ip_address>:<smf_port>/upi/v1/upNodes

REST path:

    smf_ip_address - ipaddress of SMF service
    smf_port       - the service port

Data payload:

  list of upNode elements keyed by their names (json)

Return:

    status - 200

Example:

curl -X POST \
  http://127.0.0.1:8000/upi/v1/upNodes \
  -H 'content-type: application/json' \
  -d '{
  "upNodes": {
      "UPF-2": {
          "type": "UPF",
          "nodeID": "upf-2.free5gc.org",
          "sNssaiUpfInfos": [
              {
                  "sNssai": {"sst": 1, "sd": "010203"},
                  "dnnUpfInfoList": [
                      {
                          "dnn": "internet",
                          "pools": [{"cidr": "10.62.0.0/16"}]
                      }
                  ]
              }
          ],
          "interfaces": [
              {
                  "interfaceType": "N3",
                  "endpoints": ["upf-2.free5gc.org"],
                  "networkInstance": "internet"
              }
          ]
      }
  }
}'

Get links

List list_user_plane_information links

curl -H "Content-type: application/json" -X GET http://<smf_ip_address>:<smf_port>/upi/v1/links

REST path:

    smf_ip_address - ipaddress of SMF service
    smf_port       - the service port

Return:

    status - 200
    list of link elements (json)

Post links

Add links to user_plane_information

curl -H "Content-type: application/json" -X POST -d '{ "links": [...] }' http://<smf_ip_address>:<smf_port>/upi/v1/links

REST path:

    smf_ip_address - ipaddress of SMF service
    smf_port       - the service port

Data payload:

  list of link elements (json)

Return:

    status - 200

Example:

curl -X POST \
  http://127.0.0.1:8000/upi/v1/links \
  -H 'content-type: application/json' \
  -d '{
  "links": [
      {
          "A": "gNB",
          "B": "UPF-2"
      }
  ]
}'
aviweit commented 1 year ago

Hi, It seems that this line fails lint line length check. Can you please let me know how to fix it? Thanks.

tim-ywliu commented 1 year ago

Hi, It seems that this line fails lint line length check. Can you please let me know how to fix it? Thanks.

Fix it like this:

NetworkInstance string                 `json:"networkInstance" yaml:"networkInstance" valid:"required"`
aviweit commented 1 year ago

Hi @tim-ywliu , I have updated the line per your comment. Thanks.

aviweit commented 1 year ago

An updated PR had been opened. Thanks.