Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Typespec for container mirror and status #677

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
5 changes: 5 additions & 0 deletions typespec/models/ContainerRequest.tsp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import "./ContainerConfig.tsp";
import "./Packages.tsp";
import "./ScanMode.tsp";
import "./ScanLevel.tsp";

@doc("Request payload for creating a container token.")
model ContainerRequest {
Expand All @@ -16,7 +18,10 @@ model ContainerRequest {
format: "sif" | "docker";
freeze?: boolean;
nameStrategy?: "none" | "tagPrefix" | "imageSuffix";
mirrorRegistry?: string;
packages?: Packages;
scanMode?: ScanMode;
scanLevels?: ScanLevel[];
timestamp: string;
towerAccessToken?: string;
towerEndpoint?: string;
Expand Down
10 changes: 8 additions & 2 deletions typespec/models/ContainerResponse.tsp
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import "./ContainerStatus.tsp";

@doc("Response payload for container token creation.")
model ContainerResponse {
buildId: string;
cached: boolean;
containerImage: string;
containerToken: string;
expiration: string;
freeze?: boolean;
freeze: boolean;
mirror: boolean;
requestId: string;
scanId: string;
status: ContainerStatus;
targetImage: string;
}
}
6 changes: 6 additions & 0 deletions typespec/models/ContainerStatus.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
enum ContainerStatus {
PENDING,
BUILDING,
SCANNING,
DONE
}
21 changes: 21 additions & 0 deletions typespec/models/ContainerStatusResponse.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import "./ContainerStatus.tsp";

@doc("Response payload for container status.")
model ContainerStatusResponse {
id: string;
status: ContainerStatus;
buildId: string;
mirrorId: string;
scanId: string;
vulnerabilities: Record<vulnerability>;
succeeded: boolean;
reason: string;
detailsUri: string;
creationTime: string;
duration: string;
}

model vulnerability {
severity: string;
count: int32
}
6 changes: 6 additions & 0 deletions typespec/models/ScanLevel.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
enum ScanLevel {
LOW,
MEDIUM,
HIGH,
CRITICAL
}
5 changes: 5 additions & 0 deletions typespec/models/ScanMode.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
enum ScanMode{
none,
async,
required
}
1 change: 1 addition & 0 deletions typespec/models/models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ import "./WaveBuildRecord.tsp";
import "./ValidateRegistryCredsRequest.tsp";
import "./WaveContainerRecord.tsp";
import "./ContainerMirrorResponse.tsp";
import "./ContainerStatusResponse.tsp";
12 changes: 10 additions & 2 deletions typespec/routes.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,21 @@ namespace wave {
@statusCode statusCode: 200;
};

@route("/{token}")
@get op getContainerDetails(@path token: string): {
@route("/container/{requestId}")
@get op getContainerDetails(@path requestId: string): {
@body response: WaveContainerRecord;
@statusCode statusCode: 200;
}|{
@statusCode statusCode: 404;
};

@route("/{requestId}/status")
@get op getContainerStatus(@path requestId: string): {
@body response: ContainerStatusResponse;
@statusCode statusCode: 200;
}|{
@statusCode statusCode: 404;
};
}

@route("/v1alpha1/builds/{buildId}")
Expand Down