Skip to content

feat: Initial ArgoCD PHP Client Structure and Core Services #1150

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

Closed

Conversation

wtfzdotnet
Copy link

This commit introduces the initial structure and core functionality for a new PHP client for the ArgoCD API, refactored from the KnpLabs GitHub API client.

Key changes and accomplishments so far:

  1. Project Setup:

    • Established new directory structure under argocd-php-client/src/ArgoCD/.
    • Initialized composer.json with PSR-4 autoloading and base dependencies.
  2. Core Client (ArgoCD/Client.php):

    • Adapted from the GitHub client.
    • Handles ArgoCD server URL.
    • authenticate() method implemented to either:
      • Fetch a bearer token from /api/v1/session using username/password via SessionService.
      • Use a provided bearer token directly.
    • api() factory method for accessing service classes.
  3. HTTP Layer:

    • HttpClient/Builder.php adapted for constructing the HTTP client.
    • HttpClient/Plugin/Authentication.php implemented for bearer token injection.
    • HttpClient/Plugin/ArgoCdExceptionThrower.php for basic error handling.
    • Api/AbstractApi.php provides base HTTP request methods.
    • HttpClient/Message/ResponseMediator.php for processing JSON responses.
  4. Exception Handling:

    • Custom exception classes created in ArgoCD/Exception/.
    • ArgoCdExceptionThrower parses JSON error responses from ArgoCD.
  5. Models (ArgoCD/Model/):

    • Initial set of PHP model classes generated based on ArgoCD OpenAPI definitions for session and account services (e.g., AccountAccount, SessionSessionResponse, V1Time).
  6. API Services (ArgoCD/Api/):

    • SessionService.php implemented with create (login), delete (logout), and getUserInfo methods.
    • AccountService.php implemented with methods for account listing, password updates, and token management.
    • Placeholders for ApplicationService.php.

This work lays the foundation for a comprehensive ArgoCD PHP client. Further development will involve implementing remaining API services and models, writing unit tests, and updating documentation.

This commit introduces the initial structure and core functionality for a new PHP client for the ArgoCD API, refactored from the KnpLabs GitHub API client.

Key changes and accomplishments so far:

1.  **Project Setup:**
    *   Established new directory structure under `argocd-php-client/src/ArgoCD/`.
    *   Initialized `composer.json` with PSR-4 autoloading and base dependencies.

2.  **Core Client (`ArgoCD/Client.php`):**
    *   Adapted from the GitHub client.
    *   Handles ArgoCD server URL.
    *   `authenticate()` method implemented to either:
        *   Fetch a bearer token from `/api/v1/session` using username/password via `SessionService`.
        *   Use a provided bearer token directly.
    *   `api()` factory method for accessing service classes.

3.  **HTTP Layer:**
    *   `HttpClient/Builder.php` adapted for constructing the HTTP client.
    *   `HttpClient/Plugin/Authentication.php` implemented for bearer token injection.
    *   `HttpClient/Plugin/ArgoCdExceptionThrower.php` for basic error handling.
    *   `Api/AbstractApi.php` provides base HTTP request methods.
    *   `HttpClient/Message/ResponseMediator.php` for processing JSON responses.

4.  **Exception Handling:**
    *   Custom exception classes created in `ArgoCD/Exception/`.
    *   `ArgoCdExceptionThrower` parses JSON error responses from ArgoCD.

5.  **Models (`ArgoCD/Model/`):**
    *   Initial set of PHP model classes generated based on ArgoCD OpenAPI definitions for session and account services (e.g., `AccountAccount`, `SessionSessionResponse`, `V1Time`).

6.  **API Services (`ArgoCD/Api/`):**
    *   `SessionService.php` implemented with `create` (login), `delete` (logout), and `getUserInfo` methods.
    *   `AccountService.php` implemented with methods for account listing, password updates, and token management.
    *   Placeholders for `ApplicationService.php`.

This work lays the foundation for a comprehensive ArgoCD PHP client. Further development will involve implementing remaining API services and models, writing unit tests, and updating documentation.
This commit establishes the foundational components for a PHP client for the ArgoCD API, refactored from the KnpLabs GitHub API client.

Includes:
- Core client structure (`Client.php`, `HttpClient/Builder.php`, `Api/AbstractApi.php`, `HttpClient/Message/ResponseMediator.php`).
- Basic exception handling (`ArgoCD/Exception/` and `HttpClient/Plugin/ArgoCdExceptionThrower.php`).
- Authentication mechanism via bearer tokens, with `HttpClient/Plugin/Authentication.php`.
- Implemented `SessionService` for login/logout and user info.
- Implemented `AccountService` for account and token management.
- Initial data models for Session and Account services.
- `AI.md` detailing the AI-assisted development process.
- `reference/argocd_swagger.json` containing the ArgoCD OpenAPI spec.
- Updated `README.md` for the ArgoCD client.

I attempted to restructure the project to remove the 'argocd-php-client' sub-directory and update CI workflows for PHP 8.3+, but I encountered persistent errors related to file system access and state. These changes are therefore not included in this commit and will need to be revisited.
This session aimed to apply styling patches and update GitHub Actions CI workflows to PHP 8.3+.

- Styling patches were attempted, and a majority of files were processed. However, persistent errors prevented me from successfully patching a few specific model files (`src/ArgoCD/Model/RuntimeError.php`, `src/ArgoCD/Model/SessionSessionCreateRequest.php`), making it unsafe to commit the partially applied styling. These changes have been omitted to maintain consistency.
- My attempts to update `.github/workflows/ci.yml` and `.github/workflows/backwards-compatibility.yml` also failed due to similar persistent errors, indicating potential issues with file system access or state tracking, especially after project restructuring operations.

No functional code changes from the previous submission (`feat/argocd-client-foundation`) are included in this commit. The purpose of this commit is to document the attempted work and highlight the issues that prevented completion of the planned tasks. Further investigation into the stability of my environment is recommended before proceeding with these changes.
@wtfzdotnet wtfzdotnet closed this May 28, 2025
@wtfzdotnet wtfzdotnet deleted the feat/initial-argocd-client branch May 28, 2025 07:29
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