Skip to content

Commit 94eeae5

Browse files
author
Dana Stiefel
committed
better endpoint
1 parent b9d3490 commit 94eeae5

6 files changed

Lines changed: 35 additions & 19 deletions

File tree

backend/compact-connect/docs/internal/api-specification/latest-oas30.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
],
1212
"paths": {
13-
"/v1/compacts/live": {
13+
"/v1/public/compacts/jurisdictions/live": {
1414
"get": {
1515
"summary": "Get live compact jurisdictions",
1616
"description": "Returns all jurisdictions that are live (enabled for operations) across all compacts or for a specific compact if the optional compact query parameter is provided.",

backend/compact-connect/lambdas/python/compact-configuration/handlers/compact_configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def compact_configuration_api_handler(event: dict, context: LambdaContext): # n
2828
return _get_staff_users_compact_jurisdictions(event, context)
2929
if event['httpMethod'] == 'GET' and event['resource'] == '/v1/public/compacts/{compact}/jurisdictions':
3030
return _get_public_compact_jurisdictions(event, context)
31-
if event['httpMethod'] == 'GET' and event['resource'] == '/v1/compacts/live':
31+
if event['httpMethod'] == 'GET' and event['resource'] == '/v1/public/compacts/jurisdictions/live':
3232
return _get_live_public_compact_jurisdictions(event, context)
3333
if event['httpMethod'] == 'GET' and event['resource'] == '/v1/compacts/{compact}':
3434
return _get_staff_users_compact_configuration(event, context)

backend/compact-connect/lambdas/python/compact-configuration/tests/function/test_compact_configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
STAFF_USERS_COMPACT_JURISDICTION_ENDPOINT_RESOURCE = '/v1/compacts/{compact}/jurisdictions'
1414
PUBLIC_COMPACT_JURISDICTION_ENDPOINT_RESOURCE = '/v1/public/compacts/{compact}/jurisdictions'
15-
LIVE_COMPACT_JURISDICTIONS_ENDPOINT_RESOURCE = '/v1/compacts/live'
15+
LIVE_COMPACT_JURISDICTIONS_ENDPOINT_RESOURCE = '/v1/public/compacts/jurisdictions/live'
1616

1717
COMPACT_CONFIGURATION_ENDPOINT_RESOURCE = '/v1/compacts/{compact}'
1818
JURISDICTION_CONFIGURATION_ENDPOINT_RESOURCE = '/v1/compacts/{compact}/jurisdictions/{jurisdiction}'

backend/compact-connect/stacks/api_stack/v1_api/api.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ def __init__(
127127
# POST /v1/public/compacts/{compact}/providers/query
128128
# GET /v1/public/compacts/{compact}/providers/{providerId}
129129
self.public_compacts_resource = self.public_resource.add_resource('compacts')
130+
# /v1/public/compacts/jurisdictions
131+
self.public_compacts_jurisdictions_resource = self.public_compacts_resource.add_resource('jurisdictions')
132+
# /v1/public/compacts/jurisdictions/live
133+
self.live_compacts_jurisdictions_resource = self.public_compacts_jurisdictions_resource.add_resource('live')
130134
self.public_compacts_compact_resource = self.public_compacts_resource.add_resource('{compact}')
131135
self.public_compacts_compact_providers_resource = self.public_compacts_compact_resource.add_resource(
132136
'providers'
@@ -160,8 +164,6 @@ def __init__(
160164

161165
# /v1/compacts
162166
self.compacts_resource = self.resource.add_resource('compacts')
163-
# /v1/compacts/live
164-
self.live_compacts_resource = self.compacts_resource.add_resource('live')
165167
# /v1/compacts/{compact}
166168
self.compact_resource = self.compacts_resource.add_resource('{compact}')
167169

@@ -207,7 +209,7 @@ def __init__(
207209
self.compact_configuration_api = CompactConfigurationApi(
208210
api=self.api,
209211
compact_resource=self.compact_resource,
210-
live_compacts_resource=self.live_compacts_resource,
212+
live_compacts_jurisdictions_resource=self.live_compacts_jurisdictions_resource,
211213
jurisdictions_resource=self.jurisdictions_resource,
212214
public_jurisdictions_resource=self.public_compacts_compact_jurisdictions_resource,
213215
jurisdiction_resource=self.jurisdiction_resource,

backend/compact-connect/stacks/api_stack/v1_api/compact_configuration_api.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __init__(
2525
*,
2626
api: CCApi,
2727
compact_resource: Resource,
28-
live_compacts_resource: Resource,
28+
live_compacts_jurisdictions_resource: Resource,
2929
jurisdictions_resource: Resource,
3030
public_jurisdictions_resource: Resource,
3131
jurisdiction_resource: Resource,
@@ -39,8 +39,8 @@ def __init__(
3939
self.api = api
4040
# /v1/compacts/{compact}
4141
self.staff_users_compact_resource = compact_resource
42-
# /v1/compacts/live
43-
self.live_compacts_resource = live_compacts_resource
42+
# /v1/public/compacts/jurisdictions/live
43+
self.live_compacts_jurisdictions_resource = live_compacts_jurisdictions_resource
4444
# /v1/compacts/{compact}/jurisdictions
4545
self.staff_users_jurisdictions_resource = jurisdictions_resource
4646
# /v1/compacts/{compact}/jurisdictions/{jurisdiction}
@@ -162,8 +162,8 @@ def _add_public_get_compact_jurisdictions_endpoint(self, compact_configuration_a
162162
)
163163

164164
def _add_get_live_compact_jurisdictions_endpoint(self, compact_configuration_api_handler: PythonFunction):
165-
"""Add GET endpoint for /v1/compacts/live"""
166-
get_live_compact_jurisdictions_method = self.live_compacts_resource.add_method(
165+
"""Add GET endpoint for /v1/public/compacts/jurisdictions/live"""
166+
get_live_compact_jurisdictions_method = self.live_compacts_jurisdictions_resource.add_method(
167167
'GET',
168168
LambdaIntegration(compact_configuration_api_handler),
169169
method_responses=[

backend/compact-connect/tests/app/test_api/test_compact_configuration_api.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,33 +146,47 @@ def test_synth_generates_get_public_compact_jurisdictions_resource(self):
146146
)
147147

148148
def test_synth_generates_get_live_compact_jurisdictions_resource(self):
149-
"""Test that the GET /v1/compacts/live endpoint is properly configured as a public endpoint"""
149+
"""Test that the GET /v1/public/compacts/jurisdictions/live endpoint is properly configured as a public endpoint"""
150150
api_stack = self.app.sandbox_backend_stage.api_stack
151151
api_stack_template = Template.from_stack(api_stack)
152152

153-
# Ensure the resource is created with expected path
153+
# Ensure the /v1/public/compacts/jurisdictions resource is created
154+
api_stack_template.has_resource_properties(
155+
type=CfnResource.CFN_RESOURCE_TYPE_NAME,
156+
props={
157+
'ParentId': {
158+
# Verify the parent id matches the expected 'public/compacts' resource
159+
'Ref': api_stack.get_logical_id(api_stack.api.v1_api.public_compacts_resource.node.default_child),
160+
},
161+
'PathPart': 'jurisdictions',
162+
},
163+
)
164+
165+
# Ensure the /v1/public/compacts/jurisdictions/live resource is created
154166
api_stack_template.has_resource_properties(
155167
type=CfnResource.CFN_RESOURCE_TYPE_NAME,
156168
props={
157169
'ParentId': {
158-
# Verify the parent id matches the expected 'compacts' resource
159-
'Ref': api_stack.get_logical_id(api_stack.api.v1_api.compacts_resource.node.default_child),
170+
# Verify the parent id matches the expected 'public/compacts/jurisdictions' resource
171+
'Ref': api_stack.get_logical_id(
172+
api_stack.api.v1_api.public_compacts_jurisdictions_resource.node.default_child
173+
),
160174
},
161175
'PathPart': 'live',
162176
},
163177
)
164178

165-
# Get the live compacts resource
166-
live_compacts_resource_id = api_stack.get_logical_id(
167-
api_stack.api.v1_api.live_compacts_resource.node.default_child
179+
# Get the live compacts jurisdictions resource
180+
live_compacts_jurisdictions_resource_id = api_stack.get_logical_id(
181+
api_stack.api.v1_api.live_compacts_jurisdictions_resource.node.default_child
168182
)
169183

170184
# Ensure the GET method is configured with the lambda integration (no authorizer since it's public)
171185
api_stack_template.has_resource_properties(
172186
type=CfnMethod.CFN_RESOURCE_TYPE_NAME,
173187
props={
174188
'HttpMethod': 'GET',
175-
'ResourceId': {'Ref': live_compacts_resource_id},
189+
'ResourceId': {'Ref': live_compacts_jurisdictions_resource_id},
176190
# ensure the lambda integration is configured with the expected handler
177191
'Integration': TestApi.generate_expected_integration_object(
178192
api_stack.get_logical_id(

0 commit comments

Comments
 (0)