Migrate from legacy RestClient to ThingsboardClient#32
Open
ViacheslavKlimov wants to merge 2 commits intodevelop/4.4from
Open
Migrate from legacy RestClient to ThingsboardClient#32ViacheslavKlimov wants to merge 2 commits intodevelop/4.4from
ViacheslavKlimov wants to merge 2 commits intodevelop/4.4from
Conversation
Replace the hand-written RestClient (~5200 lines) with the auto-generated
ThingsboardClient from thingsboard-java-client. The new client provides
type-safe OpenAPI-generated methods with built-in auth management and
rate-limit retry.
Key changes:
- Remove org.thingsboard.common:data, util, java-jwt, spring-web deps
- Add thingsboard-pe-client as sole TB dependency (uses ${thingsboard.version})
- Rewrite RestClientService to use ThingsboardClient builder with auto token refresh
- Delete RestClient.java and RestJsonConverter.java
- Create JsonUtils helper to replace JacksonUtil from removed util dep
- Migrate all 11 tool classes to use string IDs and flat pagination params
- Migrate all 10 test files to mock ThingsboardClient instead of RestClient
- All 175 tests pass
| import com.fasterxml.jackson.databind.JsonNode; | ||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
|
||
| public class JsonUtils { |
Member
Author
There was a problem hiding this comment.
Rename to JacksonUtil
Member
Author
ViacheslavKlimov
left a comment
There was a problem hiding this comment.
Review summary
Reviewed 30 changed files in Migrate from legacy RestClient to ThingsboardClient. Left 5 comment(s) inline.
Clean migration overall — the move from hand-rolled RestClient + JacksonUtil to the generated ThingsboardClient simplifies the codebase significantly. The CeOnly variable rename fix in EditionAwareToolProvider is a nice catch. A few inconsistencies in the pagination parameter handling across PE-only methods stood out.
Additional findings
These observations are about existing code outside the PR's diff — spotted while reading surrounding context.
src/main/java/org/thingsboard/ai/mcp/server/tools/ota/OtaTools.java:255—rest.replace("/", "\\\\")replaces each/with two literal backslash characters (\\) instead of one. The first path separator uses a single backslash (":\\"→:\), so the result is inconsistent (e.g.,C:\Users\\foo\\file.bin). Should berest.replace("/", "\\")for single backslashes. Windows APIs tolerate this, but it's a latent bug.
This review was auto-generated by Claude. Findings may contain errors — please verify before applying changes.
- Rename JsonUtils to JacksonUtil per reviewer request - Add null guard in RestClientService.initClient() to fail fast when no credentials are configured instead of NPE in detectEdition() - Add comments explaining why PE-only API methods use String pagination params while CE methods use Integer (generated client inconsistency)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the hand-written RestClient with the auto-generated ThingsboardClient from thingsboard-java-client. The new client provides type-safe OpenAPI-generated methods with built-in auth management and rate-limit retry.
Key changes:
Type of change
Checklist
Breaking changes (if any)