Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Endpoint for claiming gateways using a qr code #7272

Merged
merged 6 commits into from
Sep 10, 2024

Conversation

vlasebian
Copy link
Contributor

@vlasebian vlasebian commented Aug 28, 2024

Summary

References #7270

Changes

  • Adding a grpc endpoint to claim gateways using a qr code
  • Extending the qrcodegenerator pkg to support gateway qrs

Testing

curl -H "Authorization: $TTN_AUTH_TOKEN" 'http://localhost:1885/api/v3/qr-codes/gateways/ttigpro1/parse' -X POST -d '{"qr_code": "aHR0cHM6Ly90dGlnLnByby9jL2VjNjU2ZWZmZmUwMDAxMjgvYWJjZGVmMTIzNDU2"}'

where the qr_code field is the base64 encoded value of:

https://ttig.pro/c/ec656efffe000128/abcdef123456

or without specifying the format:

curl -H "Authorization: $TTN_AUTH_TOKEN" 'http://localhost:1885/api/v3/qr-codes/gateways/parse' -X POST -d '{"qr_code": "aHR0cHM6Ly90dGlnLnByby9jL2VjNjU2ZWZmZmUwMDAxMjgvYWJjZGVmMTIzNDU2"}'
Results
{"format_id":"ttigpro1","gateway_eui":"EC656EFFFE000128","owner_token":"abcdef123456"}
Regressions

None.

Notes for Reviewers

None.

Checklist

  • Scope: The referenced issue is addressed, there are no unrelated changes.
  • Compatibility: The changes are backwards compatible with existing API, storage, configuration and CLI, according to the compatibility commitments in README.md for the chosen target branch.
  • Documentation: Relevant documentation is added or updated.
  • Testing: The steps/process to test this feature are clearly explained including testing for regressions.
  • Infrastructure: If infrastructural changes (e.g., new RPC, configuration) are needed, a separate issue is created in the infrastructural repositories.
  • Changelog: Significant features, behavior changes, deprecations and fixes are added to CHANGELOG.md.
  • Commits: Commit messages follow guidelines in CONTRIBUTING.md, there are no fixup commits left.

@vlasebian vlasebian self-assigned this Aug 28, 2024
pkg/qrcodegenerator/grpc_gateways.go Outdated Show resolved Hide resolved
pkg/qrcodegenerator/grpc_gateways_test.go Show resolved Hide resolved
pkg/qrcodegenerator/grpc_gateways_test.go Outdated Show resolved Hide resolved
pkg/qrcodegenerator/qrcode/gateways/ttigpro1.go Outdated Show resolved Hide resolved
pkg/qrcodegenerator/qrcode/gateways/ttigpro1.go Outdated Show resolved Hide resolved
pkg/qrcodegenerator/qrcode/gateways/ttigpro1.go Outdated Show resolved Hide resolved
pkg/qrcodegenerator/qrcode/gateways/ttigpro1.go Outdated Show resolved Hide resolved
pkg/qrcodegenerator/qrcode/gateways/ttigpro1.go Outdated Show resolved Hide resolved
pkg/qrcodegenerator/qrcode/gateways/ttigpro1.go Outdated Show resolved Hide resolved
pkg/qrcodegenerator/qrcode/gateways/ttigpro1.go Outdated Show resolved Hide resolved
@vlasebian vlasebian force-pushed the feature/claim-gateways-using-qr-be branch from 8ec181c to 0571b93 Compare September 2, 2024 14:22
@github-actions github-actions bot added the ui/web This is related to a web interface label Sep 2, 2024
@vlasebian
Copy link
Contributor Author

vlasebian commented Sep 4, 2024

What should be filled in for the rest of the ClaimGatewayRequest? The full request looks like this:

{
  "authenticated_identifiers": {
    "gateway_eui": "70B3D57ED000ABCD", // this is taken from the url
    "authentication_code": "string" // this is taken from the url too
  },
  "qr_code": "string", // if authenticated_identifiers are provided, this doesn't have to be filled in
  // how should the collaborator item be filled?
  "collaborator": {
    "organization_ids": {
      "organization_id": "string"
    },
    "user_ids": {
      "user_id": "string",
      "email": "string"
    }
  },
  // there is a comment for target_gateway_id in the protobuf message definition:
  // 'If this is not set, the target ID for the target gateway will be set 
  // to `<gateway-eui>`.' -> I guess this can be set to the gatewayEUI 
  "target_gateway_id": "string",
  "target_gateway_server_address": "string", // what value should we use for this? we let the user select it?
  // cups_redirection is deprecated
  "cups_redirection": {},
  // target_frequency_plan_id is deprecated
  "target_frequency_plan_id": "string",
  // what should we use for this?
  "target_frequency_plan_ids": [
    "string"
  ]
}

@vlasebian vlasebian marked this pull request as ready for review September 4, 2024 14:05
@vlasebian vlasebian requested review from a team as code owners September 4, 2024 14:05
Copy link
Member

@johanstokking johanstokking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good. Please address lint errors and set up the linting tool in your editor.

pkg/qrcodegenerator/qrcode/gateways/ttigpro1.go Outdated Show resolved Hide resolved
pkg/qrcodegenerator/qrcode/gateways/ttigpro1.go Outdated Show resolved Hide resolved
pkg/qrcodegenerator/qrcode/gateways/ttigpro1.go Outdated Show resolved Hide resolved
@vlasebian vlasebian force-pushed the feature/claim-gateways-using-qr-be branch 3 times, most recently from 1371c77 to 84deef9 Compare September 4, 2024 15:35
@vlasebian vlasebian requested a review from a team as a code owner September 4, 2024 15:35
@vlasebian vlasebian force-pushed the feature/claim-gateways-using-qr-be branch from 84deef9 to a546ae6 Compare September 5, 2024 09:41
api/ttn/lorawan/v3/qrcodegenerator.proto Outdated Show resolved Hide resolved
pkg/qrcodegenerator/grpc_gateways_test.go Outdated Show resolved Hide resolved
pkg/qrcodegenerator/qrcode/gateways/gateways_test.go Outdated Show resolved Hide resolved
pkg/qrcodegenerator/qrcode/gateways/gateways_test.go Outdated Show resolved Hide resolved
pkg/qrcodegenerator/qrcode/gateways/ttigpro1.go Outdated Show resolved Hide resolved
Copy link
Member

@KrishnaIyer KrishnaIyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

pkg/qrcodegenerator/qrcode/gateways/gateways.go Outdated Show resolved Hide resolved
@vlasebian vlasebian force-pushed the feature/claim-gateways-using-qr-be branch from f5be211 to d780ef2 Compare September 10, 2024 13:20
@vlasebian vlasebian merged commit 8298a38 into v3.32 Sep 10, 2024
16 checks passed
@vlasebian vlasebian deleted the feature/claim-gateways-using-qr-be branch September 10, 2024 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ui/web This is related to a web interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants