Skip to content

Commit 2cc39cb

Browse files
bug: api stage now set properly, more nisar static layer endpoint prototyping
1 parent db6a7fc commit 2cc39cb

9 files changed

Lines changed: 31 additions & 28 deletions

File tree

.github/workflows/deploy-prod-staging.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ jobs:
7878
with:
7979
aws-account-id: ${{ secrets.AWS_ACCOUNT_ID }}
8080
staging: true
81+
maturity: prod-staging
8182

8283
run-prod-staging-integration-tests:
8384
needs: [deploy-prod-staging]

.github/workflows/deploy-prod.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ jobs:
4040
uses: ./.github/workflows/search-api-composite
4141
with:
4242
aws-account-id: ${{ secrets.AWS_ACCOUNT_ID }}
43+
maturity: prod
4344

.github/workflows/deploy-test-staging.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ jobs:
7878
with:
7979
aws-account-id: ${{ secrets.AWS_ACCOUNT_ID }}
8080
staging: true
81+
maturity: test-staging
8182

8283
run-test-staging-integration-tests:
8384
needs: [deploy-test-staging]

.github/workflows/deploy-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ jobs:
4040
uses: ./.github/workflows/search-api-composite
4141
with:
4242
aws-account-id: ${{ secrets.AWS_ACCOUNT_ID }}
43+
maturity: test

.github/workflows/search-api-composite/action.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ inputs:
1313
security-group:
1414
required: true
1515
type: string
16-
17-
staging:
18-
required: false
19-
type: boolean
16+
maturity:
17+
required: true
18+
type: string
2019

2120
runs:
2221
using: "composite"
@@ -57,5 +56,4 @@ runs:
5756
--context vpc_id=${{ inputs.vpc-id }} \
5857
--context subnet_ids=${{ inputs.subnet-ids }} \
5958
--context security_group=${{ inputs.security-group }} \
60-
--context staging=${{ inputs.staging }}
61-
59+
--context api_stage=${{ inputs.maturity }}

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
3232

3333
### Fixed
3434
- boolean values are properly capitalized in `python` output file
35-
35+
- API maturity set for each level of deployment stage
3636
------
3737
## [1.0.7](https://github.com/asfadmin/Discovery-SearchAPI-v3/compare/v1.0.6...v1.0.7)
3838
### Changed

cdk/app.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
app = cdk.App()
1010

11-
staging = app.node.try_get_context('staging')
12-
if staging is None:
13-
staging = False
14-
11+
staging = False
1512
suffix = ''
16-
if staging:
13+
api_stage = app.node.try_get_context('api_stage')
14+
15+
if api_stage.endswith('staging'):
16+
staging = True
1717
suffix = '-Staging'
1818

1919
SearchAPIStack(app, f"SearchAPIStack{suffix}",
@@ -24,6 +24,7 @@
2424
# Uncomment the next line to specialize this stack for the AWS Account
2525
# and Region that are implied by the current CLI configuration.
2626
staging=staging,
27+
api_stage=api_stage,
2728
env=cdk.Environment(
2829
account=os.getenv('CDK_DEFAULT_ACCOUNT'),
2930
region=os.getenv('CDK_DEFAULT_REGION')

cdk/cdk/cdk_stack.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
class SearchAPIStack(Stack):
1414

15-
def __init__(self, scope: Construct, construct_id: str, staging: bool = False, **kwargs) -> None:
15+
def __init__(self, scope: Construct, construct_id: str, api_stage: str, staging: bool = False, **kwargs) -> None:
1616
super().__init__(scope, construct_id, **kwargs)
1717

1818
try:
@@ -60,7 +60,7 @@ def __init__(self, scope: Construct, construct_id: str, staging: bool = False, *
6060
memory_size=5308,
6161
code=lambda_.DockerImageCode.from_image_asset(
6262
directory='..',
63-
# build_args={'MATURITY': }
63+
build_args={'MATURITY': api_stage},
6464
),
6565
**lambda_vpc_kwargs,
6666
)

src/SearchAPI/application/application.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
from datetime import datetime
21
import json
32

43
import os
5-
from typing import Optional
64
import dateparser
75

86
import asf_search as asf
97
from fastapi import Depends, FastAPI, Request, HTTPException, APIRouter, UploadFile
10-
from fastapi.responses import RedirectResponse, Response, JSONResponse
8+
from fastapi.responses import Response, JSONResponse
119
from fastapi.middleware.cors import CORSMiddleware
1210

1311
from .log_router import LoggingRoute
@@ -228,17 +226,19 @@ async def file_to_wkt(files: list[UploadFile]):
228226
headers=constants.DEFAULT_HEADERS
229227
)
230228

231-
# @router.get('/redirect/{shortName}')
232-
# async def nisar_static_layer(shortName: str, granule_id: str, cmr_token: Optional[str], cmr_host: Optional[str]='uat'):
229+
# @router.get('/redirect/{short_name}/{granule_id}')
230+
# async def nisar_static_layer(environment: Literal['prod', 'test'], short_name: str, granule_id: str):
231+
# """
232+
# environment: 'prod' or 'test' (whether to search the cmr prod or uat record)
233+
# short_name: the CMR static layer collection short name to search
234+
# granule_id: the granule id of the product to find the static layer for
235+
236+
# returns: redirect to file url
237+
# """
233238
# opts = asf.ASFSearchOptions()
234-
# if cmr_token is not None:
235-
# if cmr_host == 'uat':
236-
# host = asf.INTERNAL.CMR_HOST_UAT
237-
# else:
238-
# host = asf.INTERNAL.CMR_HOST
239-
# session = asf.ASFSession(cmr_host=host).auth_with_token(cmr_token)
240-
# opts.session = session
241-
# opts.host = host
239+
# if environment == 'test':
240+
# opts.host = asf.INTERNAL.CMR_HOST_UAT
241+
242242
# try:
243243
# granule = asf.search(
244244
# granule_list=[granule_id],
@@ -247,7 +247,7 @@ async def file_to_wkt(files: list[UploadFile]):
247247
# except IndexError:
248248
# raise HTTPException(status_code=400, detail=f'Unable to find static layer, provided scene named "{granule_id}" not found in CMR record')
249249

250-
# static_layer = granule.get_static_layer(opts=asf.ASFSearchOptions(shortName=shortName))
250+
# static_layer = granule.get_static_layer(opts=asf.ASFSearchOptions(shortName=short_name))
251251
# if static_layer is None:
252252
# raise HTTPException(status_code=500, detail=f'Static layer not found for scene named "{granule_id}"')
253253

0 commit comments

Comments
 (0)