Skip to content

refactor!: use idiomatic C# enums for run status/origin, permission level, webhook event types - #4

Closed
Pijukatel wants to merge 5 commits into
masterfrom
claude/sleepy-albattani-nm574i
Closed

refactor!: use idiomatic C# enums for run status/origin, permission level, webhook event types#4
Pijukatel wants to merge 5 commits into
masterfrom
claude/sleepy-albattani-nm574i

Conversation

@Pijukatel

Copy link
Copy Markdown
Collaborator

Summary

Refactors the .NET/C# client to be more idiomatic C#, per the updated orchestration consistency requirement ("Consistency with the reference implementation that would go against idiomatic use of the language is not desired") with breaking public-interface changes explicitly permitted. This is not an OpenAPI spec sync — the client remains on v2-2026-07-07T132551Z. Consistency is kept with the JS reference at the API-surface level, not with sibling clients. Version bumped 0.1.10.2.0.

Idiomatic changes (breaking)

  • Four public enums replacing stringly-typed closed sets (values verified against the spec schemas): ActorJobStatus (+ IsTerminal()), RunOrigin, WebhookEventType (+ ToWireValue()) in Apify.Client.Models; PermissionLevel in Apify.Client.Options.
  • Model outputs typed: ActorRun.Status/Build.StatusActorJobStatus?; Webhook.EventTypesIReadOnlyList<WebhookEventType>?. Unrecognized/absent wire values degrade to null (or are skipped in lists) and never throw; raw JSON stays reachable via Get(...)/ToJsonObject().
  • Option inputs typed: LastRunOptions.Status/Origin, RunListOptions.Status, ActorStartOptions.ForcePermissionLevel.
  • Removed the internal Statuses helper (terminal logic now on ActorJobStatus.IsTerminal()). Enum extension classes are public only when they expose a member consumers need (WebhookEventType.ToWireValue, ActorJobStatus.IsTerminal); the rest are internal.

Tests / docs

  • New Unit/ApiEnumTests.cs (wire mapping, terminal helper, unknown→null / list skip-unknown); updated request-shape/run/webhook tests; the CI-run examples exercise RunOrigin + multi-status filtering.
  • New "API enums" docs section plus updated actors/runs/webhooks/examples docs; CHANGELOG entry added.

Verification

  • The .NET SDK is not available in the authoring environment, so build/format/test were not run locally — the CI workflow runs restore → dotnet format --verify-no-changes → build (warnings-as-errors) → unit → integration → examples on this PR.

NuGet Trusted-Publishing (OIDC) workflow and package metadata are unchanged.


Generated by Claude Code

claude added 5 commits July 9, 2026 12:26
…evel, webhook event types

Replace stringly-typed API-enum fields with real C# enums (ActorJobStatus,
RunOrigin, WebhookEventType, PermissionLevel), each with a ToWireValue mapping.
Model outputs (ActorRun.Status, Build.Status, Webhook.EventTypes) and option
inputs (LastRunOptions, RunListOptions, ActorStartOptions) are now typed;
unknown wire values degrade to null and never throw. Removed the internal
Statuses helper. Updated tests, examples, docs, CHANGELOG; bumped 0.1.1 -> 0.2.0.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JvkiV9GQnM5qo4iAnX43K7
…cy, runnable examples

- Make ToWireValue public only for WebhookEventType (needed to build webhook
  defs); ActorJobStatus.ToWireValue and RunOriginExtensions are now internal
  (ActorJobStatus.IsTerminal stays public).
- Scope the models.md/CHANGELOG enum-coverage claim; note fields left as strings.
- Spell out full WebhookEventType member names in models.md; document IsTerminal
  preference; fix ToWireValue publicness claim.
- Add runnable Status+Origin (actors.md) and multi-status list (runs.md) snippets
  with correct usings; extend the CI-run RunAndLastRunStorages example (and its
  examples.md twin) to exercise RunOrigin and multi-status filtering.
- Reword .editorconfig CA1711 justification to cite the API/JS reference only.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JvkiV9GQnM5qo4iAnX43K7
…ippet, align examples preamble

Addresses iteration-2 review (N1-N3, doc-only):
- CHANGELOG: only WebhookEventType.ToWireValue is public; enums otherwise via typed options/models.
- webhooks.md: add using System.Linq for EventTypes?.Contains(...).
- examples.md: use ApifyClientOptions form (matches CI runner); token param is string? so no NRT warning.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JvkiV9GQnM5qo4iAnX43K7
…d IsTerminal() example and option-type namespaces

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JvkiV9GQnM5qo4iAnX43K7
@Pijukatel

Copy link
Copy Markdown
Collaborator Author

Contaminated by other implementations.

@Pijukatel Pijukatel closed this Jul 9, 2026
@Pijukatel
Pijukatel deleted the claude/sleepy-albattani-nm574i branch July 10, 2026 10:58
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.

3 participants