Skip to content

Commit d512d60

Browse files
committed
fix(ndbc): restore station deployment hierarchy severed by prior PUT
The fix_platform_links.py PUT to /deployments/{id} was treated by csapi-go-v2 as a full replacement, silently dropping the ogc-rel:parentDeployment link and promoting all 5 station deployments to top-level. reparent_station_deployments.py: - Deletes the 5 orphaned top-level station deployments - Re-POSTs each under /deployments/{group_id}/subdeployments with the corrected platform@link.href (includes /systems/ segment) - Executed live 2026-05-10; hierarchy restored under NDBC Buoy Stations bootstrap_ndbc.py: _deploy_station() now accepts base_url so future bootstrap runs produce the correct href from the start. PUT-based updates to change deployment properties must be issued via /deployments/{parent}/subdeployments or the parent link must be explicitly re-included.
1 parent b662445 commit d512d60

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

reparent_station_deployments.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
"""Re-parent the 5 NDBC station deployments back under the Buoy Stations group.
2+
3+
The previous PUT to update platform@link.href used the root /deployments/{id}
4+
endpoint which the server treated as a full replacement, severing the
5+
ogc-rel:parentDeployment link and promoting each deployment to top-level.
6+
7+
Fix: delete each orphaned deployment, then re-POST under the correct parent via
8+
/deployments/{group_id}/subdeployments with the correct platform@link.href.
9+
"""
10+
from publishers.bootstrap_helpers import api_post, api_delete, get_config, _auth_header, find_by_uid
11+
12+
cfg = get_config()
13+
base_url = cfg['base_url']
14+
auth = _auth_header(cfg['user'], cfg['password'])
15+
16+
GROUP_ID = '04d825a0-d6d9-4aba-8b4a-7eed9992ff60' # NDBC Buoy Stations
17+
VALID_TIME_START = '2026-01-01T00:00:00Z'
18+
19+
# (station_id, display_name, lon, lat, system_server_id)
20+
stations = [
21+
('44025', 'Long Island, NY', -73.164, 40.251, 'd5bb1466-dbf0-492f-a30b-380739e0d499'),
22+
('41009', 'Cape Canaveral East, FL', -80.166, 28.519, '24e78589-74a8-48b3-939c-402c2c6bba40'),
23+
('42036', 'Gulf of Mexico', -84.517, 28.5, '0a72b89e-e0b7-40d7-8259-0d481a8bc654'),
24+
('46025', 'Santa Monica Basin, CA', -119.053, 33.749, '83c9707b-ac5f-4f7d-87c4-26cf21f67441'),
25+
('46013', 'Bodega Bay, CA', -123.301, 38.242, 'd8cf20d5-f03a-4f87-bd3a-95574227e544'),
26+
]
27+
28+
for st_id, name, lon, lat, sys_id in stations:
29+
uid = 'urn:os4csapi:deployment:ndbc-' + st_id + ':v1'
30+
system_href = base_url.rstrip('/') + '/systems/' + sys_id
31+
32+
# 1. Find and delete the orphaned top-level deployment
33+
existing_id = find_by_uid(base_url, auth, 'deployments', uid)
34+
if existing_id:
35+
api_delete(base_url, 'deployments/' + existing_id, auth)
36+
print(' [DEL] deployments/' + existing_id + ' (' + st_id + ')')
37+
else:
38+
print(' [SKIP-DEL] ' + uid + ' not found at top level')
39+
40+
# 2. Re-POST under the group as a subdeployment with corrected platform@link
41+
body = {
42+
'type': 'Feature',
43+
'geometry': {'type': 'Point', 'coordinates': [lon, lat]},
44+
'properties': {
45+
'featureType': 'sosa:Deployment',
46+
'uid': uid,
47+
'name': 'Buoy ' + st_id + ' Feed',
48+
'description': 'NDBC buoy ' + st_id + ' (' + name + ') observation feed.',
49+
'validTime': [VALID_TIME_START, '..'],
50+
'platform@link': {
51+
'href': system_href,
52+
'uid': 'urn:os4csapi:system:ndbc:' + st_id + ':v1',
53+
'title': 'NDBC ' + st_id,
54+
},
55+
},
56+
}
57+
result = api_post(base_url, 'deployments/' + GROUP_ID + '/subdeployments', body, auth)
58+
new_id = result.get('id') if result else None
59+
print(' [POST] ' + st_id + ' -> new id=' + str(new_id) + ' href=' + system_href)
60+
61+
print('Done.')

0 commit comments

Comments
 (0)