TheThingsNetwork / lorawan-stack

The Things Stack, an Open Source LoRaWAN Network Server
https://www.thethingsindustries.com/stack/
Apache License 2.0
992 stars 309 forks source link

Implement MAC settings profile CRUD API #7396

Closed halimi closed 8 hours ago

halimi commented 5 days ago

Summary

References: https://github.com/TheThingsNetwork/lorawan-stack/issues/7380

This PR implements the MAC settings profile CRUD API. This is the first step (1 out of 6) of the proposed implementation plan.

Changes

Testing

Steps

Pre-requisite: Create an application

Tests:

Results

Request:

 POST http://localhost:1885/api/v3/ns/applications/myapp/mac_settings_profiles
> Authorization: Bearer  MFRWG.QRQCFEX537L4S3ETCM56BLPQKTT2OGOSHRHUCXI.AKJG32COZUA2VD74Z7KOQMKWJPENCDT4KIHPAWYSHHTMKYJL4OIQ
> content-type: application/json
> data
{
  "mac_settings_profile": {
    "ids": {
      "application_ids": {
        "application_id": "myapp"
      },
      "profile_id": "prof-01"
    },
    "mac_settings": {
      "resets_f_cnt": false,
      "factory_preset_frequencies": [
        1,
        2,
        3
      ]
    }
  }
}

Response:

{
  "mac_settings_profile": {
    "ids": {
      "application_ids": {
        "application_id": "myapp"
      },
      "profile_id": "prof-01"
    },
    "mac_settings": {
      "factory_preset_frequencies": [
        "1",
        "2",
        "3"
      ],
      "resets_f_cnt": false
    }
  }
}

Request:

GET http://localhost:1885/api/v3/ns/applications/myapp/mac_settings_profiles/prof-01?field_mask=ids
> Authorization: Bearer MFRWG.QRQCFEX537L4S3ETCM56BLPQKTT2OGOSHRHUCXI.AKJG32COZUA2VD74Z7KOQMKWJPENCDT4KIHPAWYSHHTMKYJL4OIQ

Response:

{
  "mac_settings_profile": {
    "ids": {
      "application_ids": {
        "application_id": "myapp"
      },
      "profile_id": "prof-01"
    }
  }
}

Request:

PUT http://localhost:1885/api/v3/ns/applications/myapp/mac_settings_profiles/prof-01
> Authorization: Bearer MFRWG.QRQCFEX537L4S3ETCM56BLPQKTT2OGOSHRHUCXI.AKJG32COZUA2VD74Z7KOQMKWJPENCDT4KIHPAWYSHHTMKYJL4OIQ
> content-type: application/json
> data
{
  "mac_settings_profile": {
    "ids": {
      "application_ids": {
        "application_id": "myapp"
      },
      "profile_id": "prof-01"
    },
    "mac_settings": {
      "resets_f_cnt": true,
      "factory_preset_frequencies": [
        1,
        2,
        3,
        4,
        5
      ]
    }
  }
}

Response:

{
  "mac_settings_profile": {
    "ids": {
      "application_ids": {
        "application_id": "myapp"
      },
      "profile_id": "prof-01"
    },
    "mac_settings": {
      "factory_preset_frequencies": [
        "1",
        "2",
        "3",
        "4",
        "5"
      ],
      "resets_f_cnt": true
    }
  }
}

Request:

GET http://localhost:1885/api/v3/ns/applications/myapp/mac_settings_profiles?field_mask=ids
> Authorization: Bearer MFRWG.QRQCFEX537L4S3ETCM56BLPQKTT2OGOSHRHUCXI.AKJG32COZUA2VD74Z7KOQMKWJPENCDT4KIHPAWYSHHTMKYJL4OIQ

Response:

{
  "mac_settings_profiles": [
    {
      "ids": {
        "application_ids": {
          "application_id": "myapp"
        },
        "profile_id": "prof-01"
      }
    },
    {
      "ids": {
        "application_ids": {
          "application_id": "myapp"
        },
        "profile_id": "prof-02"
      }
    }
  ]
}

Request:

DELETE http://localhost:1885/api/v3/ns/applications/myapp/mac_settings_profiles/prof-01
> Authorization: Bearer MFRWG.QRQCFEX537L4S3ETCM56BLPQKTT2OGOSHRHUCXI.AKJG32COZUA2VD74Z7KOQMKWJPENCDT4KIHPAWYSHHTMKYJL4OIQ

Response:

{}
Regressions

...

Notes for Reviewers

...

Checklist

KrishnaIyer commented 15 hours ago

Should we mark this API as experimental until we complete the rest of the ToDo items this is tested with end devices?

johanstokking commented 15 hours ago

Should we mark this API as experimental until we complete the rest of the ToDo items this is tested with end devices?

Yeah good call, let's do that.

halimi commented 10 hours ago

Should we mark this API as experimental until we complete the rest of the ToDo items this is tested with end devices?

@KrishnaIyer Can you please help me out? What should I do to mark it as experimental? Is it just the CHANGELOG or more?

KrishnaIyer commented 9 hours ago
  1. Changelog: Add a comment (This feature is experimental and subject to change)
  2. Service comment in the proto file: NsMACSettingsProfileRegistry EXPERIMENTAL: This service is subject to change.