feat(servers): add hybrid org context + Servers reads#18
Merged
Conversation
Introduces the org-context layer: - `$forge->org($slug)` returns an immutable clone bound to the given org, carrying any attached MockClient over so test chains stay mocked - `OrganizationNotSetException` (extends ForgeException, not ApiException — it's a client-side guard, not an HTTP error) - `servers()` and `server($id)` accessors throw the guard when no org is bound via constructor, env, config, or chain Adds the read side of Servers: - `Data\Server` DTO (26 fields, dates → DateTimeImmutable) - `Data\ListServersOptions` (pagination + sort + 8 filter fields) - `Enums\ServerType` (constants for the spec-enumerated server roles) - `Requests\Servers\GetServer` / `GetServers` - `Resources\ServerResource` / `ServersResource` (uses `ParsesPage` trait) Tests + fixtures: - ForgeTest split per-method into `tests/Unit/Forge/<Method>Test.php` (constructor, fromEnvironment, fromConfig, accessors) - `Tests\Utils\ServerFixture` extends `ForgeFixture` with server-specific redactions (IPs, SSH key, timezone, ssh_port, identifier, credential_id, stable pagination cursors) - `tests/Pest.php` no longer disables Saloon's auto-record default — match ortto-sdk; missing fixtures are recorded from the live API - 4 fixtures recorded: servers/list, servers/get, servers/list-page-1, servers/list-page-2 (the last pair drives the cursor-walk test, which breaks out of iteration after 2 yields so no third call is made) Read-side of issue #5; write side (create/update/delete + /actions) lands in a follow-up PR. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
3 tasks
fbarrento
added a commit
that referenced
this pull request
May 15, 2026
#19) Completes the Servers slice for #5. The read side landed in #18; this PR adds the mutating surface: - `CreateServerData` (top-level required: name/provider/type/ubuntuVersion; optional: credentialId/phpVersion/databaseType + provider sub-config) - `UpdateServerData` (all optional; `toArray()` strips nulls so partial updates only send the keys that changed) - `HetznerServerConfig` — first provider sub-config DTO; AWS/Akamai/etc. follow the same shape when needed - Input enums for spec-closed sets: `PhpVersion`, `DatabaseType`, `UbuntuVersion`, `ServerAction` - Requests: `CreateServer` (POST), `UpdateServer` (PUT), `DeleteServer` (DELETE), `SendServerAction` (POST /actions) - Resource methods: `ServersResource::create()`, `ServerResource::update()` / `delete()` / `reboot()` / `powerCycle()` `Server` DTO loosened: `revoked` and `connection_status` are now nullable because freshly-created (202 async) responses return them as null — contrary to the OpenAPI spec but matching observed runtime behavior. Recording / cleanup: - One end-to-end `ServerWriteLifecycleTest` creates a real Hetzner cax11 server, exercises update/reboot, then deletes it. A try/finally safety-net delete catches any partway-through failure so we don't leak billed infra. - Recorded four fixtures (`create.json`, `update.json`, `action-reboot.json`, `delete.json`) against the live Forge API. - `ServerFixture` extended to redact the freshly-leaking `meta.sudo_password` (Forge returns this on create — it's the generated server SSH password). `tests/Pest.php` already auto-records via Saloon's native default (set up in #18). Recording requires `.env` with FORGE_TEST_TOKEN, FORGE_TEST_ORG_SLUG, FORGE_TEST_HETZNER_CREDENTIAL_ID, FORGE_TEST_HETZNER_REGION (Forge id/code/alt all accepted), FORGE_TEST_HETZNER_SIZE (must be the size *code* like `cax11`, not the numeric Forge id), FORGE_TEST_HETZNER_NETWORK_ID. Replay needs nothing. 241 tests / 469 assertions / 100% coverage. Closes #5. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
fbarrento
added a commit
that referenced
this pull request
May 19, 2026
Captures the four spec mismatches surfaced while building the Servers slice (#18 + #19) plus the open-strings-not-enums decision from the Providers slice (#16 + #17). Append future findings here so the next debugging session can find the answer without re-running live-fire investigations. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2 tasks
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.
Summary
$forge->org($slug)returns an immutable clone bound to the chained org slug (preserves attachedMockClientso chained calls don't escape mocks in tests).OrganizationNotSetExceptionguards$forge->servers()/$forge->server($id)when no org has been bound via constructor, env, config, or chain.Data\Server,Data\ListServersOptions,Enums\ServerType,GetServer/GetServersrequests,ServerResource/ServersResource.tests/Pest.phpnow leaves Saloon's auto-record default in place (matches ortto-sdk). Missing fixtures are recorded from the live API on first run.Tests\Utils\ServerFixtureextendsForgeFixtureto redact server-specific PII: IPs, SSH public key, timezone, ssh_port, identifier, credential_id, and pagination cursors (which embed timestamps).ForgeTest.phpintotests/Unit/Forge/<Method>Test.phpper the established convention.Partial closure of #5 (write side —
create/update/delete//actions— lands in a follow-up).Test plan
composer test— pint, rector, phpstan, 202 tests / 407 assertions, 100% coverage.tests/Fixtures/Saloon/servers/*.jsonfixtures recorded against the real Forge API and verified redacted (no real IPs, SSH keys, timezones, or cursor tokens).🤖 Generated with Claude Code