Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ using OpenAPI;
@route("/api/hyperfleet/v1")
namespace HyperFleet;

// Override BearerAuth to use lowercase "bearer" as required by kin-openapi
model BearerAuth {
type: AuthType.http;
scheme: "bearer";
}

6 changes: 3 additions & 3 deletions models-core/cluster/example_cluster.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ const exampleCluster: Cluster = #{
updated_time: "2021-01-01T00:00:00Z",
generation: 1,
status: #{
phase: "Ready",
phase: ResourcePhase.Ready,
last_transition_time: "2021-01-01T00:00:00Z",
observed_generation: 1,
last_updated_time: "2021-01-01T00:00:00Z",
conditions: #[
#{
type: "ValidationSuccessful",
status: "True",
status: ConditionStatus.True,
reason: "All validations passed",
message: "All 30 validation tests passed",
observed_generation: 1,
Expand All @@ -29,7 +29,7 @@ const exampleCluster: Cluster = #{
},
#{
type: "DNSSuccessful",
status: "True",
status: ConditionStatus.True,
reason: "DNS configured",
message: "DNS records created for custom.domain.com",
observed_generation: 1,
Expand Down
6 changes: 3 additions & 3 deletions models-core/nodepool/example_nodepool.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ const exampleNodePool: NodePool = #{
href: "https://api.hyperfleet.com/v1/clusters/cluster-123",
},
status: #{
phase: "Ready",
phase: ResourcePhase.Ready,
last_transition_time: "2021-01-01T10:00:00Z",
observed_generation: 1,
last_updated_time: "2021-01-01T10:02:00Z",
conditions: #[
#{
type: "ValidationSuccessful",
status: "True",
status: ConditionStatus.True,
reason: "All validations passed",
message: "NodePool validation passed",
observed_generation: 1,
Expand All @@ -35,7 +35,7 @@ const exampleNodePool: NodePool = #{
},
#{
type: "NodePoolSuccessful",
status: "True",
status: ConditionStatus.True,
reason: "NodePool provisioned successfully",
message: "NodePool has been scaled to desired count",
observed_generation: 1,
Expand Down
6 changes: 3 additions & 3 deletions models-gcp/cluster/example_cluster.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ const exampleCluster: Cluster = #{
updated_time: "2021-01-01T00:00:00Z",
generation: 1,
status: #{
phase: "Ready",
phase: ResourcePhase.Ready,
last_transition_time: "2021-01-01T00:00:00Z",
observed_generation: 1,
last_updated_time: "2021-01-01T00:00:00Z",
conditions: #[
#{
type: "ValidationSuccessful",
status: "True",
status: ConditionStatus.True,
reason: "All validations passed",
message: "All 30 validation tests passed",
observed_generation: 1,
Expand All @@ -51,7 +51,7 @@ const exampleCluster: Cluster = #{
},
#{
type: "DNSSuccessful",
status: "True",
status: ConditionStatus.True,
reason: "DNS configured",
message: "DNS records created for custom.domain.com",
observed_generation: 1,
Expand Down
6 changes: 3 additions & 3 deletions models-gcp/nodepool/example_nodepool.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ const exampleNodePool: NodePool = #{
href: "https://api.hyperfleet.com/v1/clusters/cluster-123",
},
status: #{
phase: "Ready",
phase: ResourcePhase.Ready,
last_transition_time: "2021-01-01T10:00:00Z",
observed_generation: 1,
last_updated_time: "2021-01-01T10:02:00Z",
conditions: #[
#{
type: "ValidationSuccessful",
status: "True",
status: ConditionStatus.True,
reason: "All validations passed",
message: "NodePool validation passed",
observed_generation: 1,
Expand All @@ -57,7 +57,7 @@ const exampleNodePool: NodePool = #{
},
#{
type: "NodePoolSuccessful",
status: "True",
status: ConditionStatus.True,
reason: "NodePool provisioned successfully",
message: "NodePool has 3 nodes running",
observed_generation: 1,
Expand Down
2 changes: 1 addition & 1 deletion models/clusters/model.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ model ClusterStatus {
* Updated when conditions are reported.
* Note: status.phase provides aggregated view from all conditions.
*/
phase: "NotReady" | "Ready" | "Failed";
phase: ResourcePhase;

/**
* When cluster last transitioned (used by Sentinel for backoff)
Expand Down
19 changes: 18 additions & 1 deletion models/common/model.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ alias KindClusterStatus = "ClusterStatus";
alias KindNodePoolStatus = "NodePoolStatus";
alias KindNodePool = "NodePool";

/**
* Phase of a resource (Cluster or NodePool)
*/
enum ResourcePhase {
NotReady,
Ready,
Failed,
}

model ID {
/** Resource identifier */
id?: Identifier;
Expand Down Expand Up @@ -47,6 +56,14 @@ model Error {
code?: string;
reason?: string;
operation_id?: string;

/** Field-level validation errors (optional) */
details?: {
/** Field path that failed validation */
field?: string;
/** Validation error message for this field */
error?: string;
}[];
}

model ErrorResponse<Kind, ErrorCode> {
Expand Down Expand Up @@ -94,7 +111,7 @@ model QueryParams extends SearchParams {
orderBy?: string = "created_time";

@query
order?: OrderDirection = OrderDirection.desc;
order?: OrderDirection;
}

model List {
Expand Down
2 changes: 1 addition & 1 deletion models/nodepools/model.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ model NodePoolStatus {
* Updated when conditions are reported.
* Note: status.phase provides aggregated view from all conditions.
*/
phase: "NotReady" | "Ready" | "Failed";
phase: ResourcePhase;

/**
* Last generation processed
Expand Down
16 changes: 8 additions & 8 deletions models/statuses/example_adapter_status.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ const exampleAdapterStatus: AdapterStatus = (#{
conditions: #[
#{
type: "Available",
status: "True",
status: ConditionStatus.True,
reason: "All validations passed",
message: "All 30 validation tests passed",
last_transition_time: "2021-01-01T10:00:00Z",
},
#{
type: "Applied",
status: "True",
status: ConditionStatus.True,
reason: "Validation job applied",
message: "Validation job applied successfully",
last_transition_time: "2021-01-01T10:00:00Z",
},
#{
type: "Health",
status: "True",
status: ConditionStatus.True,
reason: "All adapter operations completed successfully",
message: "All adapter runtime operations completed successfully",
last_transition_time: "2021-01-01T10:00:00Z",
Expand Down Expand Up @@ -54,19 +54,19 @@ const exampleAdapterStatusCreateRequest: AdapterStatusCreateRequest = (#{
conditions: #[
#{
type: "Available",
status: "True",
status: ConditionStatus.True,
reason: "All validations passed",
message: "All 30 validation tests passed",
},
#{
type: "Applied",
status: "True",
status: ConditionStatus.True,
reason: "Validation job applied",
message: "Validation job applied successfully",
},
#{
type: "Health",
status: "True",
status: ConditionStatus.True,
reason: "All adapter operations completed successfully",
message: "All adapter runtime operations completed successfully",
}
Expand Down Expand Up @@ -101,7 +101,7 @@ const exampleAdapterStatusList: AdapterStatusList = (#{
conditions: #[
#{
type: "Available",
status: "True",
status: ConditionStatus.True,
reason: "All validations passed",
message: "All 30 validation tests passed",
last_transition_time: "2021-01-01T10:00:00Z",
Expand All @@ -120,7 +120,7 @@ const exampleAdapterStatusList: AdapterStatusList = (#{
conditions: #[
#{
type: "Available",
status: "True",
status: ConditionStatus.True,
reason: "DNS configured",
message: "DNS records created",
last_transition_time: "2021-01-01T10:01:00Z",
Expand Down
14 changes: 11 additions & 3 deletions models/statuses/model.tsp
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import "../common/model.tsp";
import "./example_adapter_status.tsp";

/**
* Status value for conditions
*/
enum ConditionStatus {
True: "True",
False: "False",
Unknown,
}

/**
* Base condition fields shared by all condition types
*/
Expand All @@ -13,7 +22,7 @@ model ConditionBase {
/**
* Condition status
*/
status: "True" | "False" | "Unknown";
status: ConditionStatus;

/**
* Machine-readable reason code
Expand Down Expand Up @@ -72,7 +81,7 @@ model ResourceCondition extends ConditionBase {
*/
model ConditionRequest {
type: string;
status: "True" | "False" | "Unknown";
status: ConditionStatus;
reason?: string;
message?: string;
}
Expand Down Expand Up @@ -153,6 +162,5 @@ model AdapterStatusCreateRequest extends AdapterStatusBase {
*/
@example(exampleAdapterStatusList)
model AdapterStatusList extends List {
kind: "AdapterStatusList";
items: AdapterStatus[];
}
Loading