Refactor API endpoint construction and add ID validation#85
Merged
arslanbekov merged 1 commit intomainfrom Jan 27, 2026
Merged
Conversation
Signed-off-by: Denis Arslanbekov <denis@arslanbekov.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR standardizes how CloudConnexa API endpoints are constructed and adds basic ID validation to fail fast on empty identifiers before making requests.
Changes:
- Introduces
buildURLfor consistent endpoint construction with escaped path segments. - Adds
validateID(andErrEmptyID) and applies it across multiple service methods that require IDs. - Updates route/connector pagination endpoints to use
url.Valuesfor safer query-string construction.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| cloudconnexa/cloudconnexa.go | Adds buildURL helper (with path escaping) and validateID helper. |
| cloudconnexa/errors.go | Introduces ErrEmptyID used by validateID. |
| cloudconnexa/cloudconnexa_test.go | Adds unit tests for buildURL and validateID. |
| cloudconnexa/users.go | Uses buildURL and adds validateID checks for user ID-based operations. |
| cloudconnexa/user_groups.go | Uses buildURL and adds validateID checks for user-group ID operations. |
| cloudconnexa/networks.go | Uses buildURL and adds validateID checks for network ID operations. |
| cloudconnexa/routes.go | Adds validateID checks and uses url.Values for query params; uses buildURL for path-based endpoints. |
| cloudconnexa/hosts.go | Uses buildURL and adds validateID checks for host ID operations. |
| cloudconnexa/host_routes.go | Adds validateID checks; uses url.Values for query params; uses buildURL for ID endpoints. |
| cloudconnexa/host_connectors.go | Adds validateID checks; uses url.Values for query params; uses buildURL for ID endpoints. |
| cloudconnexa/network_connectors.go | Adds validateID checks; uses url.Values for query params; uses buildURL for ID endpoints. |
| cloudconnexa/host_ip_services.go | Uses buildURL and adds validateID checks for IP service ID operations. |
| cloudconnexa/network_ip_services.go | Uses buildURL and adds validateID checks for IP service ID operations. |
| cloudconnexa/host_applications.go | Uses buildURL and adds validateID checks for application ID operations. |
| cloudconnexa/network_applications.go | Uses buildURL and adds validateID checks for application ID operations. |
| cloudconnexa/location_contexts.go | Uses buildURL and adds validateID checks for location-context ID operations. |
| cloudconnexa/dns_records.go | Uses buildURL and adds validateID checks for DNS record ID operations. |
| cloudconnexa/devices.go | Uses buildURL and adds validateID checks for device ID operations. |
| cloudconnexa/access_groups.go | Uses buildURL and adds validateID checks for access-group ID operations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Description
buildURLfunction for consistency and readability across multiple services.validateIDchecks in various service methods to ensure that IDs are valid before making API requests, enhancing error handling and robustness.HostApplicationsService,HostConnectorsService,HostIPServicesService,HostRoutesService,HostsService,LocationContextsService,NetworkApplicationsService,NetworkConnectorsService,NetworkIPServicesService,NetworksService,RoutesService,UserGroupsService, andUsersServiceto reflect these changes.