Skip to content

feat: add UserService and GroupService#11

Open
deevus wants to merge 4 commits intomainfrom
feat/user-group-services
Open

feat: add UserService and GroupService#11
deevus wants to merge 4 commits intomainfrom
feat/user-group-services

Conversation

@deevus
Copy link
Owner

@deevus deevus commented Feb 27, 2026

Summary

  • Adds GroupService with CRUD operations (Create, Get, GetByName, GetByGID, List, Update, Delete) via the group.* API namespace
  • Adds UserService with CRUD operations (Create, Get, GetByUsername, GetByUID, List, Update, Delete) via the user.* API namespace
  • Both services use the Caller interface (synchronous operations only)
  • Full test coverage: conversion logic, CRUD operations, not-found handling, mock/interface compliance

Closes #7

Migrates API layer from terraform-provider-truenas#7 by @mircea-pavel-anton.

Test plan

  • All conversion tests pass (groupFromResponse, userFromResponse, opts-to-params)
  • CRUD tests verify correct API method names and parameter shapes
  • Not-found returns (nil, nil) via isNotFoundError
  • Mock/interface compile-time checks pass
  • Full suite passes with -race flag
  • go vet clean

🤖 Generated with Claude Code

@github-actions
Copy link

github-actions bot commented Feb 27, 2026

⬆️ Go test coverage increased from 86.4% to 87.3% compared to c25763d

Updated Package Coverages:

# Package Name                        |  Prior |    New
+ github.com/deevus/truenas-go        |  83.2% |  85.2%
+ github.com/deevus/truenas-go/client |  88.9% |  89.1%
View coverage for all packages
# Package Name                                   | Coverage
+ github.com/deevus/truenas-go                   |    85.2%
+ github.com/deevus/truenas-go/api               |    87.5%
+ github.com/deevus/truenas-go/client            |    89.1%
+ github.com/deevus/truenas-go/cmd/featurematrix |    92.9%

@deevus deevus force-pushed the feat/user-group-services branch 2 times, most recently from 768801a to 30ce808 Compare February 27, 2026 00:19
Add CRUD services for TrueNAS user and group management via the
user.* and group.* API namespaces. Both services use the Caller
interface (synchronous operations only).

GroupService: Create, Get, GetByName, GetByGID, List, Update, Delete
UserService: Create, Get, GetByUsername, GetByUID, List, Update, Delete

Includes full test coverage for conversion logic, CRUD operations,
not-found handling, and mock/interface compliance.

Closes #7

Co-Authored-By: Mircea-Pavel Anton <contact@mirceanton.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@deevus deevus force-pushed the feat/user-group-services branch from 30ce808 to 92d81ec Compare February 27, 2026 00:28
deevus and others added 3 commits February 27, 2026 11:41
- Parse user.create response as {"id": N} object instead of bare int
- Always send email field in create/update params (allows clearing)
- Make group_create and home_create conditional (only sent when true)
- Update tests to match corrected API call patterns

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Change sampleUserJSON() to return json.RawMessage (matches all other
  test helpers)
- Add Delete_Error tests for both UserService and GroupService
- Add comment explaining "group" filter field in GetByName
- Regenerate feature matrix

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add user and group services

1 participant