-
Couldn't load subscription status.
- Fork 290
Add MosAPI client #2850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
njshah301
wants to merge
11
commits into
google:master
Choose a base branch
from
njshah301:feature/mosapi-client
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add MosAPI client #2850
+1,876
−0
Conversation
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
This commit introduces a new client for interacting with the ICANN Monitoring System API (MoSAPI), along with a command-line tool for testing the login and logout functionality. The key changes in this commit are: - **`MosApiClient`**: A new client that handles the session lifecycle (login/logout) for the MoSAPI service. It uses a `Function` provider to dynamically fetch credentials from Secret Manager for each TLD. - **`MosApiCredentialModule`**: A new Dagger module that provides the MoSAPI URL and the credential providers for the username and password. This module securely retrieves credentials from Google Cloud Secret Manager. - **`HttpModule`**: A new Dagger module that provides a configured `HttpClient.Builder` for making HTTP requests. This work is part of the effort to create a MoSAPI client
Add a reusable HttpUtils class for making HTTP requests. This class provides simple methods for sending GET and POST requests and handles common exceptions
…ure/mosapi-client
- The `MosApiClient` is now a singleton to address the MoSAPI rate-limiting requirements. This ensures that a single, shared instance of the client is used throughout the application, preventing multiple login attempts in a short period. - Data cleanup and java format check issue resolved
Problem: The existing MosApiClient was stateful, using an in-memory CookieManager. This design is incompatible with a multi-pod environment, leading to authentication failures as session state wasn't shared. It also lacked automatic handling for session expiry (401 errors). Solution: - Introduced `MosApiSessionCache` to store session cookies externally in Secret Manager, enabling shared state across pods. - Refactored `MosApiClient` into a stateless "engine" that utilizes `MosApiSessionCache` for session management. - Implemented automatic re-login and retry logic within `MosApiClient` to handle 401 Unauthorized errors transparently. It now attempts to log in and retries the original request once upon encountering a 401. - Added specific handling for 429 Rate Limit Exceeded errors during login. - Refactored status codes into constants, using standard `HttpURLConnection` constants where applicable. This change makes the MoSAPI integration robust, scalable in a multi-pod setup, and significantly more maintainable.
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.
This commit introduces a new client for interacting with the ICANN
Monitoring System API (MoSAPI)
The key changes in this commit are:
MosApiClient: A new client that handles the session lifecycle(login/logout) for the MoSAPI service. It uses a
Functionproviderto dynamically fetch credentials from Secret Manager for each TLD.
MosApiCredentialModule: A new Dagger module that provides theMoSAPI URL and the credential providers for the username and password.
This module securely retrieves credentials from Google Cloud Secret Manager.
HttpModule: A new Dagger module that provides a configuredHttpClient.Builderfor making HTTP requests.This work is part of the effort to create a MoSAPI client
This change is