Skip to content

refactor: introduce SubResource/SubResourceList abstractions#183

Open
Xiol wants to merge 1 commit into
masterfrom
refactor/sub-resource-abstractions
Open

refactor: introduce SubResource/SubResourceList abstractions#183
Xiol wants to merge 1 commit into
masterfrom
refactor/sub-resource-abstractions

Conversation

@Xiol

@Xiol Xiol commented May 13, 2026

Copy link
Copy Markdown
Contributor

Add generic SubResource[T, ParentID, ChildID] and SubResourceList[T, ParentID] types to pkg/service/internal/resource/ to eliminate repeated sub-resource boilerplate across all services.

Constructors:

  • NewStringSubResourceList / NewIntSubResourceList (validated)
  • NewUncheckedStringSubResourceList (no validation, for firewall rule ports, network rule ports, affinity rule members, network NICs)
  • NewStringIntSubResource / NewIntIntSubResource / NewStringStringSubResource

Methods: List, ListPaginated, Get, Create, Update (PUT), Patch (PATCH→error), PatchReturning (PATCH→T), Delete

Services migrated (public interfaces unchanged):

  • safedns: zone records, zone notes, template records
  • ddosx: domain records, properties, WAF rule sets/rules/advanced rules, ACL GeoIP/IP rules, CDN rules, HSTS rules
  • loadbalancer: listener certs/binds/access-IPs/ACLs, targetgroup targets/ACLs
  • ecloud: vpc/instance/firewallpolicy/firewallrule/networkpolicy/networkrule/ router/vpngateway/vpnsession/affinityrulemember/volume/image/ availabilityzone/host/hostgroup/network/nic/floatingip/volumegroup/ vpnendpoint/vpngatewayspecs/vpnservice/dhcp sub-resources
  • pss: request replies/conversation
  • draas: solution backup resources/failover plans/compute resources/hardware plans

Also adds subresource_test.go covering all CRUD operations.

All 21 test packages continue to pass.

Add generic SubResource[T, ParentID, ChildID] and SubResourceList[T, ParentID]
types to pkg/service/internal/resource/ to eliminate repeated sub-resource
boilerplate across all services.

Constructors:
- NewStringSubResourceList / NewIntSubResourceList (validated)
- NewUncheckedStringSubResourceList (no validation, for firewall rule ports,
  network rule ports, affinity rule members, network NICs)
- NewStringIntSubResource / NewIntIntSubResource / NewStringStringSubResource

Methods: List, ListPaginated, Get, Create, Update (PUT), Patch (PATCH→error),
PatchReturning (PATCH→T), Delete

Services migrated (public interfaces unchanged):
- safedns: zone records, zone notes, template records
- ddosx: domain records, properties, WAF rule sets/rules/advanced rules,
  ACL GeoIP/IP rules, CDN rules, HSTS rules
- loadbalancer: listener certs/binds/access-IPs/ACLs, targetgroup targets/ACLs
- ecloud: vpc/instance/firewallpolicy/firewallrule/networkpolicy/networkrule/
  router/vpngateway/vpnsession/affinityrulemember/volume/image/
  availabilityzone/host/hostgroup/network/nic/floatingip/volumegroup/
  vpnendpoint/vpngatewayspecs/vpnservice/dhcp sub-resources
- pss: request replies/conversation
- draas: solution backup resources/failover plans/compute resources/hardware plans

Also adds subresource_test.go covering all CRUD operations.

All 21 test packages continue to pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Xiol Xiol force-pushed the refactor/sub-resource-abstractions branch from 2a45c89 to 98fd341 Compare May 13, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant