-
-
Notifications
You must be signed in to change notification settings - Fork 598
Refactor no models application service #1151
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
wtfzdotnet
wants to merge
7
commits into
KnpLabs:master
from
wtfzdotnet:refactor-no-models-application-service
Closed
Refactor no models application service #1151
wtfzdotnet
wants to merge
7
commits into
KnpLabs:master
from
wtfzdotnet:refactor-no-models-application-service
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 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.
Feat/initial argocd client
This commit completes a major refactoring to remove data model objects for API requests and responses. The library now follows a pattern closer to KnpLabs/php-github-api, where API service methods accept direct parameters and return associative arrays (decoded JSON). Key changes include: 1. **Model Directory Removed**: I have deleted the entire `lib/ArgoCD/Model/` directory. 2. **Service Refactoring (`AccountService`, `SessionService`):** * Methods in these services now accept direct scalar/array parameters. * Request bodies are constructed internally as associative arrays. * Responses are returned directly as associative arrays. 3. **`Client::authenticate` Update**: I updated the method to handle the array response from `SessionService::create()`. 4. **`ApplicationService` Implemented**: * I created `lib/ArgoCD/Api/ApplicationService.php`. * Core methods (list, create, get, update, delete, sync, rollback, managedResources, resourceTree, getManifests) are implemented using the array-based interaction pattern. 5. **Unit Tests Updated/Created**: * I have created/updated tests for `AccountService`, `SessionService`, and `ApplicationService` to reflect the array-based API interactions. 6. **Documentation (`AI.md`) Updated**: `AI.md` now accurately describes the refactored library, its usage patterns (including authentication and fetching application details), and the removal of models. 7. **Test Cleanup**: I removed obsolete organization-related tests. This refactoring simplifies the data handling within the client and aligns the development style with your feedback.
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.
No description provided.