feat: Add FastAPI service and auto-generated client adapter for mail client operations#1
Open
gsiri-code wants to merge 12 commits into
Open
feat: Add FastAPI service and auto-generated client adapter for mail client operations#1gsiri-code wants to merge 12 commits into
gsiri-code wants to merge 12 commits into
Conversation
Updated config.yml
…oss-taapp into hw1-final-submission
7e99a21 to
097299f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Summary
This PR introduces two new components to the mail client workspace: a FastAPI service (
mail_client_service) and an adapter (mail_client_adapter) that wraps an auto-generated service client. These components enable the mail client to operate as both a local library and a distributed service, maintaining the same interface regardless of deployment topology.The FastAPI service provides a thin REST wrapper around the existing
mail_client_api.Clientinterface, exposing four RESTful endpoints:GET /messagesfor listing messages,GET /messages/{message_id}for retrieving specific messages,POST /messages/{message_id}/mark-as-readfor marking messages as read, andDELETE /messages/{message_id}for deleting messages. The service uses FastAPI's dependency injection to cleanly separate concerns and includes comprehensive error handling with appropriate HTTP status codes.The auto-generated service client (
mail_client_service_client) is created using theopenapi-python-clientpackage, providing type-safe HTTP communication with both sync and async support. The service adapter (mail_client_adapter) implements themail_client_api.Clientprotocol, translating service responses toMessageobjects and providing seamless integration that works identically to the localgmail_client_impl. This architecture enables geographic flexibility - the same consumer code can work with either a local library or a remote service without modification. Swappinggmail_client_implwithmail_client_adapterworks seamlessly inmain.py, demonstrating the interface consistency across deployment models.The implementation includes comprehensive testing infrastructure with unit tests for FastAPI endpoints using mocked dependencies, integration tests that verify end-to-end service calls through the adapter layer, and end-to-end tests that validate the complete system against the real Gmail API. The testing strategy uses FastAPI's
TestClientfor unit testing, mocks the Gmail client for integration testing, and runs against live infrastructure for E2E validation, ensuring robust coverage across all deployment scenarios.Change Type
Impacted Areas
mail_client_servicemail_client_service_clientmail_client_adaptermail_client_apigmail_client_implTesting
Commands executed
Results
Quality Checklist
Notes for Reviewers
We have verified that swapping the adapter for the original gmail client implementation in
main.pyworks. Please give it a try!