feat: migrate Role APIs to Connect RPC #1184
Merged
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.
Migrate Role APIs to Connect RPC
This PR migrates Role APIs from gRPC to Connect RPC framework, following the established migration patterns and maintaining full backward compatibility.
🎯 Migration Overview
This migration converts gRPC role handlers to Connect RPC handlers with the following key changes:
connect.Request[T]
andconnect.Response[T]
✅ Migrated Role APIs (6 APIs)
Platform-Wide Role Management
Organization Role Management
🔧 Technical Implementation
Error Handling
connect.CodeInternal
,connect.CodeNotFound
,connect.CodeInvalidArgument
, etc.)ErrRoleNotFound
error constant for consistent role error handlingValidation & Security
utils.IsNullUUID()
roleMetaSchema
Audit & Compliance
audit.RoleCreatedEvent
,audit.RoleUpdatedEvent
,audit.RoleDeletedEvent
)Platform vs Organization Roles
schema.PlatformOrgID.String()
)orgId
)🧪 Testing Coverage
Comprehensive Test Cases (15+ tests)
Test Quality
testify/mock
andmocks.RoleService
✅ Quality Assurance
make build
)make test
)make lint
)📋 Files Changed
Core Implementation
internal/api/v1beta1connect/role.go
- Added 5 new organization role APIs + platform ListRoles APIinternal/api/v1beta1connect/errors.go
- AddedErrRoleNotFound
error constantTest Coverage
internal/api/v1beta1connect/role_test.go
- AddedTestHandler_ListRoles
with comprehensive test cases🔄 Migration Pattern
This migration follows the established Connect RPC patterns:
🚀 Benefits
📈 Summary
APIs Migrated: 6 role management APIs
Test Cases Added: 15+ comprehensive test scenarios
Error Constants Added: 1 new role-specific error constant
Files Modified: 2 implementation files + 1 test file
This migration maintains full backward compatibility while modernizing the role management API infrastructure for improved developer experience and system reliability.