Files
deploy/server/account/account.proto
zeekayandHanzo Dev 472238ddb0 cd: the API is /v1, not /api/v1 — no /api prefix anywhere
House rule: /v1/ is the API prefix, everywhere, and /api/ is never added on
top of it. The api.* subdomain names the API; a path prefix restating it is
noise. This applies it to the whole route surface:

  /api/v1/*      -> /v1/*        106 proto annotations, 109 gateway patterns
  /api/version   -> /v1/version
  /api/badge     -> /v1/badge
  /api/webhook   -> /v1/webhook  (server + applicationset controller)
  /api/dex/*     -> /v1/dex/*    (constants; dex is built, not deployed)

The grpc-gateway .pb.gw.go files are generated, and the plugin toolchain is
not on this machine, so they were rewritten by a script that applies exactly
the transform codegen would: for /api/v1 paths, drop the leading "api"
literal-push opcode pair and decrement every LitPush(2,N)/Capture(5,N) pool
index; for /api/version, rename the segment. ConcatN(4,N) operands are
counts, not pool indexes, and are untouched. The .proto annotations moved in
the same commit, so the next real codegen run is a no-op against these files.

MustPattern panics at package init on a malformed pattern, so every rewritten
pattern is validated by any import of pkg/apiclient — those tests pass.

Also moved: assets/swagger.json (82 paths), the UI's two roots (apiRoot()
'/v1', version-service '/v1/version') and its two relative composers (app
logs download, badge panel), the five audit-pattern regexes in server.go, and
the tests that asserted the old paths. terminal_test's request URL claimed
/api/v1/terminal, a route that never existed — the handler is mounted at
/terminal; the fixture now says so.

NOT touched, deliberately: /api/v3 in GitHub Enterprise base-url examples
(GitHub's URL shape, not ours), util/vendored/kubeclientmetrics (parses the
KUBERNETES API server's /api/v1 paths), and util/http's cookie-path fixture
(arbitrary string exercising slash normalization).

go build ./... clean. Pre-existing failures in badge/session/webhook/account
tests reproduce identically on the parent commit (rebrand fallout — badge
colors, cookie name length, dex issuer) and are not made worse here.

External consumers checked: universe has zero references to cd.hanzo.ai/api;
the CLI speaks gRPC, not the REST gateway; UI and server ship in one image so
they move together.

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-29 12:01:34 -07:00

114 lines
2.3 KiB
Protocol Buffer

syntax = "proto3";
option go_package = "github.com/hanzoai/cd/pkg/apiclient/account";
// Account Service
//
// Account Service API updates Hanzo CD account settings
package account;
import "google/api/annotations.proto";
message UpdatePasswordRequest {
string newPassword = 1;
string currentPassword = 2;
string name = 3;
}
message UpdatePasswordResponse {}
message CanIRequest {
string resource = 1;
string action = 2;
string subresource = 3;
}
message CanIResponse {
string value = 1;
}
message GetAccountRequest {
string name = 1;
}
message Account {
string name = 1;
bool enabled = 2;
repeated string capabilities = 3;
repeated Token tokens = 4;
}
message AccountsList {
repeated Account items = 1;
}
message Token {
string id = 1;
int64 issuedAt = 2;
int64 expiresAt = 3;
}
message TokensList {
repeated Token items = 1;
}
message CreateTokenRequest {
string name = 1;
// expiresIn represents a duration in seconds
int64 expiresIn = 2;
string id = 3;
}
message CreateTokenResponse {
string token = 1;
}
message DeleteTokenRequest {
string name = 1;
string id = 2;
}
message ListAccountRequest {
}
message EmptyResponse {}
service AccountService {
// CanI checks if the current account has permission to perform an action
rpc CanI(CanIRequest) returns (CanIResponse) {
option (google.api.http).get = "/v1/account/can-i/{resource}/{action}/{subresource=**}";
}
// UpdatePassword updates an account's password to a new value
rpc UpdatePassword(UpdatePasswordRequest) returns (UpdatePasswordResponse) {
option (google.api.http) = {
put: "/v1/account/password"
body: "*"
};
}
// ListAccounts returns the list of accounts
rpc ListAccounts(ListAccountRequest) returns (AccountsList) {
option (google.api.http).get = "/v1/account";
}
// GetAccount returns an account
rpc GetAccount(GetAccountRequest) returns (Account) {
option (google.api.http).get = "/v1/account/{name}";
}
// CreateToken creates a token
rpc CreateToken(CreateTokenRequest) returns (CreateTokenResponse) {
option (google.api.http) = {
post: "/v1/account/{name}/token"
body: "*"
};
}
// DeleteToken deletes a token
rpc DeleteToken(DeleteTokenRequest) returns (EmptyResponse) {
option (google.api.http).delete = "/v1/account/{name}/token/{id}";
}
}