Skip to content

feat: implement site management routes with validation - #396

Open
suvanbanerjee wants to merge 1 commit into
feat/sites-v1from
feat/sites-v1-crud
Open

suvanbanerjee wants to merge 1 commit into
feat/sites-v1from
feat/sites-v1-crud

Conversation

@suvanbanerjee

Copy link
Copy Markdown
Member

Pull Request

Description

Adds GET, POST, GET/{site_id} and PUT under /v1/{country}/{source}/sites

  • Listing supports filters for status, name (case-insensitive substring) and a bounding box, which must be given in full or not at all. Results are sorted by name, then by site id.
  • Access is scoped to the caller's company. A site belonging to another company returns 404, the same as one that doesn't exist, so nothing leaks. A caller with no company gets 403.
  • Create takes capacity_kW directly, which must be above zero, since the platform won't create a location without one. The site's internal location_name is generated from its UUID, because the platform only allows lowercase names and client_site_name is free text.
  • Update is partial. Latitude, longitude, tilt and orientation are marked on the models as set-once and rejected with a 400 if sent. An update with nothing to save returns 400 instead of writing a new version.
  • Source-specific fields (tilt, orientation, module and inverter capacity) are defined only on SolarMetadata, and the source in the URL decides which class validates them. One set of routes serves any source, and wind needs no route changes.

Notes

  • Only solar is accepted for now.

Fixes #387

How Has This Been Tested?

  • Locally

Checklist:

  • My code follows OCF's coding style guidelines
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked my code and corrected any misspellings

@suvanbanerjee suvanbanerjee self-assigned this Sep 18, 2026
@suvanbanerjee
suvanbanerjee added this pull request to stack #397 September 18, 2026 04:31
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.

1 participant