This commit is contained in:
mbecker20
2023-08-06 23:17:15 -04:00
parent 6884453b0f
commit 0b6d955672
6 changed files with 140 additions and 137 deletions

View File

@@ -28,6 +28,8 @@ export type ReadResponses = {
GetDockerNetworks: Types.DockerNetwork[];
GetServerActionState: Types.ServerActionState;
GetHistoricalServerStats: Types.GetHistoricalServerStatsResponse;
GetAvailableAccounts: Types.GetAvailableAccountsResponse;
GetAvailableNetworks: Types.GetAvailableNetworksResponse;
// ==== DEPLOYMENT ====
GetDeploymentsSummary: Types.GetDeploymentsSummaryResponse;

View File

@@ -2,13 +2,11 @@
Generated by typeshare 1.6.0
*/
export type _PartialCustomAlerterConfig = Partial<CustomAlerterConfig>;
export interface MongoIdObj {
$oid: string;
}
export type _PartialSlackAlerterConfig = Partial<SlackAlerterConfig>;
export type _PartialBuilderConfig = Partial<BuilderConfig>;
export type _PartialAwsBuilderConfig = Partial<AwsBuilderConfig>;
export type MongoId = MongoIdObj;
export enum PermissionLevel {
None = "none",
@@ -21,48 +19,30 @@ export type PermissionsMap = Record<string, PermissionLevel>;
export type I64 = number;
export type U64 = number;
export type MongoDocument = any;
export interface MongoIdObj {
$oid: string;
}
export type MongoId = MongoIdObj;
export type _PartialBuildConfig = Partial<BuildConfig>;
export type _PartialDeploymentConfig = Partial<DeploymentConfig>;
export type _PartialRepoConfig = Partial<RepoConfig>;
export type _PartialServerConfig = Partial<ServerConfig>;
export type _PartialCustomTag = Partial<CustomTag>;
export type AlerterConfig =
| { type: "Custom", params: CustomAlerterConfig }
| { type: "Slack", params: SlackAlerterConfig };
export interface Alerter {
export interface Resource<Config, Info> {
_id?: MongoId;
name: string;
description?: string;
permissions?: PermissionsMap;
updated_at?: I64;
tags?: string[];
info?: Info;
config: Config;
}
export type AlerterConfig =
| { type: "Custom", params: CustomAlerterConfig }
| { type: "Slack", params: SlackAlerterConfig };
export interface AlerterInfo {
is_default?: boolean;
config: AlerterConfig;
}
export interface CustomAlerterConfig {
url: string;
}
export type Alerter = Resource<AlerterConfig, AlerterInfo>;
export interface SlackAlerterConfig {
url: string;
}
export type _PartialCustomAlerterConfig = Partial<CustomAlerterConfig>;
export type _PartialSlackAlerterConfig = Partial<SlackAlerterConfig>;
export type BuildBuilderConfig =
| { type: "Server", params: {
@@ -105,45 +85,20 @@ export interface BuildConfig {
use_buildx?: boolean;
}
export interface Build {
_id?: MongoId;
name: string;
description?: string;
permissions?: PermissionsMap;
updated_at?: I64;
last_built_at?: I64;
tags?: string[];
config: BuildConfig;
export interface BuildInfo {
last_built_at: I64;
}
export interface BuildActionState {
building: boolean;
updating: boolean;
}
export type Build = Resource<BuildConfig, BuildInfo>;
export type BuilderConfig =
| { type: "Aws", params: AwsBuilderConfig };
export interface Builder {
_id?: MongoId;
name: string;
description?: string;
permissions?: PermissionsMap;
updated_at?: I64;
tags?: string[];
config: BuilderConfig;
}
export type Builder = Resource<BuilderConfig, undefined>;
export interface AwsBuilderConfig {
region: string;
instance_type: string;
volume_gb: number;
ami_id: string;
subnet_id: string;
security_group_ids: string[];
key_pair_name: string;
assign_public_ip: boolean;
}
export type _PartialBuilderConfig = Partial<BuilderConfig>;
export type _PartialAwsBuilderConfig = Partial<AwsBuilderConfig>;
export type DeploymentImage =
| { type: "Image", params: {
@@ -197,14 +152,74 @@ export interface DeploymentConfig {
docker_account?: string;
}
export interface Deployment {
_id?: MongoId;
name: string;
description?: string;
permissions?: PermissionsMap;
updated_at?: I64;
tags?: string[];
config: DeploymentConfig;
export type Deployment = Resource<DeploymentConfig, undefined>;
export interface RepoConfig {
server_id: string;
repo: string;
branch: string;
github_account?: string;
on_clone?: SystemCommand;
on_pull?: SystemCommand;
}
export interface RepoInfo {
last_pulled_at: I64;
}
export type Repo = Resource<RepoConfig, RepoInfo>;
export interface ServerConfig {
address: string;
enabled: boolean;
auto_prune: boolean;
region?: string;
cpu_warning: number;
cpu_critical: number;
mem_warning: number;
mem_critical: number;
disk_warning: number;
disk_critical: number;
}
export type Server = Resource<ServerConfig, undefined>;
export type U64 = number;
export type MongoDocument = any;
export type _PartialBuildConfig = Partial<BuildConfig>;
export type _PartialDeploymentConfig = Partial<DeploymentConfig>;
export type _PartialRepoConfig = Partial<RepoConfig>;
export type _PartialServerConfig = Partial<ServerConfig>;
export type _PartialCustomTag = Partial<CustomTag>;
export interface CustomAlerterConfig {
url: string;
}
export interface SlackAlerterConfig {
url: string;
}
export interface BuildActionState {
building: boolean;
updating: boolean;
}
export interface AwsBuilderConfig {
region: string;
instance_type: string;
volume_gb: number;
ami_id: string;
subnet_id: string;
security_group_ids: string[];
key_pair_name: string;
assign_public_ip: boolean;
}
export enum DockerContainerState {
@@ -256,26 +271,6 @@ export interface CloneArgs {
github_account?: string;
}
export interface RepoConfig {
server_id: string;
repo: string;
branch: string;
github_account?: string;
on_clone?: SystemCommand;
on_pull?: SystemCommand;
}
export interface Repo {
_id?: MongoId;
name: string;
description?: string;
permissions?: PermissionsMap;
updated_at?: I64;
last_pulled_at?: I64;
tags?: string[];
config: RepoConfig;
}
export interface RepoActionState {
cloning: boolean;
pulling: boolean;
@@ -346,29 +341,6 @@ export interface DockerNetwork {
Labels?: Record<string, string>;
}
export interface ServerConfig {
address: string;
enabled: boolean;
auto_prune: boolean;
region?: string;
cpu_warning: number;
cpu_critical: number;
mem_warning: number;
mem_critical: number;
disk_warning: number;
disk_critical: number;
}
export interface Server {
_id?: MongoId;
name: string;
description?: string;
permissions?: PermissionsMap;
updated_at?: I64;
tags?: string[];
config: ServerConfig;
}
export interface ServerActionState {
pruning_networks: boolean;
pruning_containers: boolean;
@@ -606,6 +578,18 @@ export interface Update {
version: Version;
}
export interface UpdateListItem {
id: string;
operation: Operation;
start_ts: I64;
success: boolean;
username: string;
operator: string;
target: ResourceTarget;
status: UpdateStatus;
version: Version;
}
export interface ApiSecret {
name: string;
hash?: string;
@@ -1049,6 +1033,23 @@ export interface GetServersSummaryResponse {
disabled: I64;
}
export interface GetAvailableAccounts {
server_id: string;
}
export interface GetAvailableAccountsResponse {
github: string[];
docker: string[];
}
export interface GetAvailableNetworks {
server_id: string;
}
export interface GetAvailableNetworksResponse {
networks: DockerNetwork[];
}
export interface GetTag {
id: string;
}
@@ -1066,18 +1067,6 @@ export interface ListUpdates {
page?: number;
}
export interface UpdateListItem {
id: string;
operation: Operation;
start_ts: I64;
success: boolean;
username: string;
operator: string;
target: ResourceTarget;
status: UpdateStatus;
version: Version;
}
export interface ListUpdatesResponse {
updates: UpdateListItem[];
next_page?: number;
@@ -1246,6 +1235,16 @@ export interface RenameServer {
name: string;
}
export interface CreateNetwork {
id: string;
name: string;
}
export interface DeleteNetwork {
id: string;
name: string;
}
export interface CreateTag {
name: string;
category?: string;
@@ -1313,6 +1312,8 @@ export type ReadRequest =
| { type: "GetDockerNetworks", params: GetDockerNetworks }
| { type: "GetServerActionState", params: GetServerActionState }
| { type: "GetHistoricalServerStats", params: GetHistoricalServerStats }
| { type: "GetAvailableAccounts", params: GetAvailableAccounts }
| { type: "GetAvailableNetworks", params: GetAvailableNetworks }
| { type: "GetDeploymentsSummary", params: GetDeploymentsSummary }
| { type: "GetDeployment", params: GetDeployment }
| { type: "ListDeployments", params: ListDeployments }

View File

@@ -9,7 +9,7 @@ use typeshare::typeshare;
use super::resource::Resource;
#[typeshare]
pub type Builder = Resource<BuilderConfig>;
pub type Builder = Resource<BuilderConfig, ()>;
#[typeshare(serialized_as = "Partial<BuilderConfig>")]
pub type _PartialBuilderConfig = PartialBuilderConfig;

View File

@@ -9,7 +9,7 @@ use typeshare::typeshare;
use super::{resource::Resource, EnvironmentVar, Version};
#[typeshare]
pub type Deployment = Resource<DeploymentConfig>;
pub type Deployment = Resource<DeploymentConfig, ()>;
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Builder, Partial, MungosIndexed)]

View File

@@ -9,7 +9,7 @@ use super::PermissionsMap;
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Builder)]
pub struct Resource<Config, Info: Default = ()> {
pub struct Resource<Config, Info: Default> {
#[serde(
default,
rename = "_id",

View File

@@ -11,7 +11,7 @@ pub mod docker_network;
pub mod stats;
#[typeshare]
pub type Server = Resource<ServerConfig>;
pub type Server = Resource<ServerConfig, ()>;
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Builder, Partial, MungosIndexed)]