Skip to content

Add update credentials API endpoint#152

Draft
sjmiller609 wants to merge 5 commits intomainfrom
hypeship/update-credentials-api
Draft

Add update credentials API endpoint#152
sjmiller609 wants to merge 5 commits intomainfrom
hypeship/update-credentials-api

Conversation

@sjmiller609
Copy link
Collaborator

@sjmiller609 sjmiller609 commented Mar 19, 2026

Summary

Adds PATCH /instances/{id}/credentials endpoint for updating/rotating credential brokering policies after instance creation.

Since real secrets live host-side and the egress proxy rewrites headers at request time, credential updates require no VM changes.

Merge semantics — only credentials included in the request are updated:

  • Credentials matched by name are overridden with new values
  • New credentials (not matching any existing name) are added
  • Existing credentials not in the request are left untouched

If the instance is running with an active egress proxy, the proxy policy is updated atomically. For stopped/standby instances, the config is persisted and takes effect on next start/restore.

Changes

  • openapi.yamlUpdateCredentialsRequest schema + PATCH /instances/{id}/credentials endpoint
  • lib/egressproxy/service.goUpdateInstancePolicy() for atomic policy replacement
  • lib/egressproxy/types.goErrInstanceNotRegistered sentinel error
  • lib/instances/update_credentials.go — merge logic: validate, normalize, merge with existing, update proxy, persist
  • lib/instances/manager.goUpdateCredentials on Manager interface
  • lib/instances/types.goUpdateCredentialsRequest domain type
  • cmd/api/api/instances.go — HTTP handler
  • lib/egressproxy/README.md — credential rotation docs
  • lib/oapi/oapi.go — regenerated

Tests

  • 6 unit tests for UpdateInstancePolicy (replace, clear, unregistered error, idempotent, isolation, register-then-update)
  • 7 unit tests for updateCredentials (egress required, env binding validation, merge with existing, override by name, preserve unspecified, normalization, not-found)

🤖 Generated with Claude Code

Adds an API endpoint to replace credential brokering policies on an
existing instance. Since real secrets live host-side and the egress
proxy rewrites headers at request time, updating credentials requires
no VM changes — hypeman updates stored metadata and the proxy policy.

Key changes:
- openapi.yaml: UpdateCredentialsRequest schema + PUT endpoint
- lib/egressproxy: UpdateInstancePolicy method for atomic rule replacement
- lib/instances: UpdateCredentials on Manager interface + implementation
- cmd/api/api: UpdateInstanceCredentials handler
- Tests: 6 egress proxy tests + 7 instance domain tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Mar 19, 2026

✱ Stainless preview builds

This PR will update the hypeman SDKs with the following commit message.

feat: Add update credentials API endpoint

Edit this comment to update it. It will appear in the SDK's changelogs.

hypeman-typescript studio · code · diff

Your SDK build had at least one "note" diagnostic, but this did not represent a regression.
generate ✅build ✅lint ✅test ✅

npm install https://pkg.stainless.com/s/hypeman-typescript/41e1013f520ee8b9391d5d65d99b2d9caa7ec3cb/dist.tar.gz
New diagnostics (1 note)
💡 Endpoint/NotConfigured: Skipped endpoint because it's not in your Stainless config: `patch /instances/{id}/credentials`
hypeman-openapi studio · code · diff

Your SDK build had at least one "note" diagnostic, but this did not represent a regression.
generate ✅

New diagnostics (1 note)
💡 Endpoint/NotConfigured: Skipped endpoint because it's not in your Stainless config: `patch /instances/{id}/credentials`
hypeman-go studio · code · diff

Your SDK build had at least one "note" diagnostic, but this did not represent a regression.
generate ✅build ✅lint ✅test ✅

go get github.com/stainless-sdks/hypeman-go@bf4306f15b29080f9ffaaa6a29813ea50fe581d8
New diagnostics (1 note)
💡 Endpoint/NotConfigured: Skipped endpoint because it's not in your Stainless config: `patch /instances/{id}/credentials`

This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push.
If you push custom code to the preview branch, re-run this workflow to update the comment.
Last updated: 2026-03-19 20:03:36 UTC

sjmiller609 and others added 4 commits March 19, 2026 19:45
Credentials included in the request are added or updated by name;
credentials not mentioned in the request are left unchanged. This is
more useful for secret rotation where you typically rotate one
credential at a time without disturbing others.

- openapi.yaml: PUT -> PATCH, updated descriptions for merge behavior
- lib/instances/update_credentials.go: merge incoming over existing
  credentials map instead of full replacement
- Tests: replaced clear-credentials test with preserve/merge/override
  tests (9 total, all passing)
- lib/oapi/oapi.go: regenerated

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fixes CI failure: TestAllRoutesHaveScopes requires every registered
route to have a scope mapping. Uses InstanceWrite, matching other
instance mutation endpoints.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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