What's Changed
New Contributors
Full Changelog: v2.0.9...v2.0.10
Domain List API - Release Summary
Overview
Enhanced the ListDomains API with filtering and pagination capabilities to provide more flexible and efficient domain management operations.
Changes
New Features
1. Domain Type Filtering
The ListDomains API now supports filtering domains by type:
- ALLOWED_EMAIL_DOMAIN: Filter for allowed email domains only
- ORGANIZATION_DOMAIN: Filter for organization domains only
- DOMAIN_TYPE_UNSPECIFIED: Unspecified domain type
Usage Example:
// List only organization domains
orgDomains, err := client.Domain().ListDomains(ctx, organizationId, &scalekit.ListDomainOptions{
DomainType: scalekit.DomainTypeOrganization,
})
// List only allowed email domains
allowedEmailDomains, err := client.Domain().ListDomains(ctx, organizationId, &scalekit.ListDomainOptions{
DomainType: scalekit.DomainTypeAllowedEmail,
})
2. Pagination Support
Added pagination controls to manage large result sets:
- PageSize: Number of domains to return per page (default: 100)
- PageNumber: Page number to retrieve (1-indexed)
Usage Example:
// List domains with custom pagination
domains, err := client.Domain().ListDomains(ctx, organizationId, &scalekit.ListDomainOptions{
PageSize: 50,
PageNumber: 1,
})
3. Combined Filtering and Pagination
Filter and paginate simultaneously for efficient domain queries:
Usage Example:
// List organization domains with pagination
orgDomains, err := client.Domain().ListDomains(ctx, organizationId, &scalekit.ListDomainOptions{
DomainType: scalekit.DomainTypeOrganization,
PageSize: 25,
PageNumber: 1,
})
API Signature
Before:
ListDomains(ctx context.Context, organizationId string) (*ListDomainResponse, error)
After:
ListDomains(ctx context.Context, organizationId string, options ...*ListDomainOptions) (*ListDomainResponse, error)
Backward Compatibility
✅ Fully backward compatible - The API can still be called without options:
// Still works - returns all domains with default page size of 10
allDomains, err := client.Domain().ListDomains(ctx, organizationId)
New Types
ListDomainOptions
type ListDomainOptions struct {
DomainType DomainType // Optional: Filter by domain type
PageSize uint32 // Optional: Number of results per page (default: 10)
PageNumber uint32 // Optional: Page number to retrieve
}
Implementation Details
Default Behavior
- When no options are provided, the API returns all domains with a default page size of 10
- Domain type filtering is optional and can be omitted
- Pagination parameters are optional; if not specified, default page size applies
Type Conversion
The SDK automatically converts string domain type constants to the appropriate gRPC enum values:
scalekit.DomainTypeAllowedEmail → domains.DomainType_ALLOWED_EMAIL_DOMAIN
scalekit.DomainTypeOrganization → domains.DomainType_ORGANIZATION_DOMAIN
scalekit.DomainTypeUnspecified → domains.DomainType_DOMAIN_TYPE_UNSPECIFIED
Testing
Comprehensive test coverage has been added in test/domain_test.go:
- ✅ Test listing all domains (no filter)
- ✅ Test filtering by
ORGANIZATION_DOMAIN type
- ✅ Test filtering by
ALLOWED_EMAIL_DOMAIN type
- ✅ Test verification that filtered results only contain domains of the specified type
- ✅ Test that created domains appear in the list
Migration Guide
No Changes Required
Existing code continues to work without modification:
// Existing code - no changes needed
domains, err := client.Domain().ListDomains(ctx, organizationId)
Optional: Add Filtering
To take advantage of new filtering capabilities:
// New: Filter by domain type
orgDomains, err := client.Domain().ListDomains(ctx, organizationId, &scalekit.ListDomainOptions{
DomainType: scalekit.DomainTypeOrganization,
})
Benefits
- Performance: Filtering reduces unnecessary data transfer and processing
- Scalability: Pagination enables handling of large domain lists efficiently
- Flexibility: Combined filtering and pagination for precise queries
- Backward Compatibility: No breaking changes to existing implementations
Related Files
domain.go: Core implementation with ListDomainOptions and enhanced ListDomains method
test/domain_test.go: Comprehensive test suite including TestListDomains function
pkg/grpc/scalekit/v1/domains/: gRPC protocol buffer definitions