Files
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

149 lines
4.8 KiB
Protocol Buffer

syntax = "proto3";
option go_package = "github.com/hanzoai/cd/pkg/apiclient/project";
// Project Service
//
// Project Service API performs CRUD actions against project resources
package project;
import "google/api/annotations.proto";
import "github.com/hanzoai/cd/pkg/apis/application/v1alpha1/generated.proto";
import "github.com/hanzoai/cd/server/application/application.proto";
import "github.com/hanzoai/cd/server/events/events.proto";
// ProjectCreateRequest defines project creation parameters.
message ProjectCreateRequest {
github.com.argoproj.argo_cd.v3.pkg.apis.application.v1alpha1.AppProject project = 1;
bool upsert = 2;
}
// ProjectTokenCreateRequest defines project token deletion parameters.
message ProjectTokenDeleteRequest {
string project = 1;
string role = 2;
int64 iat = 3;
string id = 4;
}
// ProjectTokenCreateRequest defines project token creation parameters.
message ProjectTokenCreateRequest {
string project = 1;
string description = 2;
string role = 3;
// expiresIn represents a duration in seconds
int64 expiresIn = 4;
string id = 5;
}
// ProjectTokenResponse wraps the created token or returns an empty string if deleted.
message ProjectTokenResponse {
string token = 1;
}
// ProjectQuery is a query for Project resources
message ProjectQuery {
string name = 1;
}
message ProjectUpdateRequest {
github.com.argoproj.argo_cd.v3.pkg.apis.application.v1alpha1.AppProject project = 1;
}
message EmptyResponse {}
message SyncWindowsQuery {
string name = 1;
}
message SyncWindowsResponse {
repeated github.com.argoproj.argo_cd.v3.pkg.apis.application.v1alpha1.SyncWindow windows = 1;
}
message GlobalProjectsResponse {
repeated github.com.argoproj.argo_cd.v3.pkg.apis.application.v1alpha1.AppProject items = 1;
}
message DetailedProjectsResponse {
repeated github.com.argoproj.argo_cd.v3.pkg.apis.application.v1alpha1.AppProject globalProjects = 1;
github.com.argoproj.argo_cd.v3.pkg.apis.application.v1alpha1.AppProject project = 2;
repeated github.com.argoproj.argo_cd.v3.pkg.apis.application.v1alpha1.Repository repositories = 3;
repeated github.com.argoproj.argo_cd.v3.pkg.apis.application.v1alpha1.Cluster clusters = 4;
}
message ListProjectLinksRequest {
string name = 1;
}
// ProjectService
service ProjectService {
// Create a new project token
rpc CreateToken(ProjectTokenCreateRequest) returns (ProjectTokenResponse) {
option (google.api.http) = {
post: "/v1/projects/{project}/roles/{role}/token"
body: "*"
};
}
// Delete a new project token
rpc DeleteToken(ProjectTokenDeleteRequest) returns (EmptyResponse) {
option (google.api.http).delete = "/v1/projects/{project}/roles/{role}/token/{iat}";
}
// Create a new project
rpc Create(ProjectCreateRequest) returns (github.com.argoproj.argo_cd.v3.pkg.apis.application.v1alpha1.AppProject) {
option (google.api.http) = {
post: "/v1/projects"
body: "*"
};
}
// List returns list of projects
rpc List(ProjectQuery) returns (github.com.argoproj.argo_cd.v3.pkg.apis.application.v1alpha1.AppProjectList) {
option (google.api.http).get = "/v1/projects";
}
// GetDetailedProject returns a project that include project, global project and scoped resources by name
rpc GetDetailedProject(ProjectQuery) returns (DetailedProjectsResponse) {
option (google.api.http).get = "/v1/projects/{name}/detailed";
}
// Get returns a project by name
rpc Get(ProjectQuery) returns (github.com.argoproj.argo_cd.v3.pkg.apis.application.v1alpha1.AppProject) {
option (google.api.http).get = "/v1/projects/{name}";
}
// Get returns a virtual project by name
rpc GetGlobalProjects(ProjectQuery) returns (GlobalProjectsResponse) {
option (google.api.http).get = "/v1/projects/{name}/globalprojects";
}
// Update updates a project
rpc Update(ProjectUpdateRequest) returns (github.com.argoproj.argo_cd.v3.pkg.apis.application.v1alpha1.AppProject) {
option (google.api.http) = {
put: "/v1/projects/{project.metadata.name}"
body: "*"
};
}
// Delete deletes a project
rpc Delete(ProjectQuery) returns (EmptyResponse) {
option (google.api.http).delete = "/v1/projects/{name}";
}
// ListEvents returns a list of project events
rpc ListEvents(ProjectQuery) returns (events.EventList) {
option (google.api.http).get = "/v1/projects/{name}/events";
}
// GetSchedulesState returns true if there are any active sync syncWindows
rpc GetSyncWindowsState(SyncWindowsQuery) returns (SyncWindowsResponse) {
option (google.api.http).get = "/v1/projects/{name}/syncwindows";
}
// ListLinks returns all deep links for the particular project
rpc ListLinks(ListProjectLinksRequest) returns (application.LinksResponse) {
option (google.api.http).get = "/v1/projects/{name}/links";
}
}