Skip to content

Conversation

@njshah301
Copy link
Collaborator

@njshah301 njshah301 commented Oct 17, 2025

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 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


This change is Reviewable

njshah301 and others added 2 commits October 17, 2025 09:28
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
@njshah301 njshah301 requested a review from CydeWeys October 17, 2025 13:15
njshah301 and others added 9 commits October 19, 2025 18:22
Add a reusable HttpUtils class for making HTTP requests. This class
provides simple methods for sending GET and POST requests and handles common exceptions
- 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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant