HHS / simpler-grants-gov

https://simpler.grants.gov
Other
46 stars 13 forks source link

Create the `ExtractMetadata` API #2793

Closed mikehgrantsgov closed 3 days ago

mikehgrantsgov commented 2 weeks ago

Related to 2454

Summary

2792 creates the input/output schemas needed to support the API. This ticket creates the API to read params from the request and send back extract metadata information.

Something like:

POST /v1/extracts/opportunities

Input: ExtractMetadataRequestSchema

If extract_type is not provided, default to opportunity_data_extract (we may support more later) If start_date and end_date not provided, default to where created_at is within the last 7 days.

Something like (rough pseudocode):

@opportunity_blueprint.post("/extracts/opportunities")
@opportunity_blueprint.output(extract_metadata_schemas.ExtractMetadataListResponseSchema)
@opportunity_blueprint.auth_required(api_key_auth)
@flask_db.with_db_session()
def extract_metadata_get(db_session: db.Session) -> ApiResponse:
    # Get query parameters

    # Default to last 7 days if no date range is provided

    # Call service with params to get results

    # Serialize results

    # return ApiResponse(message="Success", data=metadata_list)

Acceptance criteria

chouinar commented 1 week ago

We'll want to be careful about doing GET with a request body. It's fuzzy whether that's technically "right" in HTTP requests. Some libraries apparently won't let you do that. Either need everything to be request params or just make it a POST endpoint (I generally just prefer the latter).

I'm trying to think if we'll have more extracts in the future to warrant a naming schema like:

mikehgrantsgov commented 1 week ago

Makes sense, adapted this for /v1/extracts/opportunities now and can add more.