From 0b6d9556721f3e4333ebd20dabc7e429a4086726 Mon Sep 17 00:00:00 2001 From: mbecker20 Date: Sun, 6 Aug 2023 23:17:15 -0400 Subject: [PATCH] client --- client/ts/src/responses.ts | 2 + client/ts/src/types.ts | 267 ++++++++++++++------------- lib/types/src/entities/builder.rs | 2 +- lib/types/src/entities/deployment.rs | 2 +- lib/types/src/entities/resource.rs | 2 +- lib/types/src/entities/server/mod.rs | 2 +- 6 files changed, 140 insertions(+), 137 deletions(-) diff --git a/client/ts/src/responses.ts b/client/ts/src/responses.ts index af0a04e4f..ead7eacb4 100644 --- a/client/ts/src/responses.ts +++ b/client/ts/src/responses.ts @@ -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; diff --git a/client/ts/src/types.ts b/client/ts/src/types.ts index 6151adbbf..51247e9e0 100644 --- a/client/ts/src/types.ts +++ b/client/ts/src/types.ts @@ -2,13 +2,11 @@ Generated by typeshare 1.6.0 */ -export type _PartialCustomAlerterConfig = Partial; +export interface MongoIdObj { + $oid: string; +} -export type _PartialSlackAlerterConfig = Partial; - -export type _PartialBuilderConfig = Partial; - -export type _PartialAwsBuilderConfig = Partial; +export type MongoId = MongoIdObj; export enum PermissionLevel { None = "none", @@ -21,48 +19,30 @@ export type PermissionsMap = Record; 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; - -export type _PartialDeploymentConfig = Partial; - -export type _PartialRepoConfig = Partial; - -export type _PartialServerConfig = Partial; - -export type _PartialCustomTag = Partial; - -export type AlerterConfig = - | { type: "Custom", params: CustomAlerterConfig } - | { type: "Slack", params: SlackAlerterConfig }; - -export interface Alerter { +export interface Resource { _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; -export interface SlackAlerterConfig { - url: string; -} +export type _PartialCustomAlerterConfig = Partial; + +export type _PartialSlackAlerterConfig = Partial; 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; 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; -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; + +export type _PartialAwsBuilderConfig = Partial; 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; + +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; + +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; + +export type U64 = number; + +export type MongoDocument = any; + +export type _PartialBuildConfig = Partial; + +export type _PartialDeploymentConfig = Partial; + +export type _PartialRepoConfig = Partial; + +export type _PartialServerConfig = Partial; + +export type _PartialCustomTag = Partial; + +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; } -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 } diff --git a/lib/types/src/entities/builder.rs b/lib/types/src/entities/builder.rs index e165d3c84..031f59518 100644 --- a/lib/types/src/entities/builder.rs +++ b/lib/types/src/entities/builder.rs @@ -9,7 +9,7 @@ use typeshare::typeshare; use super::resource::Resource; #[typeshare] -pub type Builder = Resource; +pub type Builder = Resource; #[typeshare(serialized_as = "Partial")] pub type _PartialBuilderConfig = PartialBuilderConfig; diff --git a/lib/types/src/entities/deployment.rs b/lib/types/src/entities/deployment.rs index 04f3c196f..4e9116683 100644 --- a/lib/types/src/entities/deployment.rs +++ b/lib/types/src/entities/deployment.rs @@ -9,7 +9,7 @@ use typeshare::typeshare; use super::{resource::Resource, EnvironmentVar, Version}; #[typeshare] -pub type Deployment = Resource; +pub type Deployment = Resource; #[typeshare] #[derive(Serialize, Deserialize, Debug, Clone, Builder, Partial, MungosIndexed)] diff --git a/lib/types/src/entities/resource.rs b/lib/types/src/entities/resource.rs index 37487d0bf..e9a0e76d5 100644 --- a/lib/types/src/entities/resource.rs +++ b/lib/types/src/entities/resource.rs @@ -9,7 +9,7 @@ use super::PermissionsMap; #[typeshare] #[derive(Serialize, Deserialize, Debug, Clone, Builder)] -pub struct Resource { +pub struct Resource { #[serde( default, rename = "_id", diff --git a/lib/types/src/entities/server/mod.rs b/lib/types/src/entities/server/mod.rs index 08e25ec61..5ff7b5965 100644 --- a/lib/types/src/entities/server/mod.rs +++ b/lib/types/src/entities/server/mod.rs @@ -11,7 +11,7 @@ pub mod docker_network; pub mod stats; #[typeshare] -pub type Server = Resource; +pub type Server = Resource; #[typeshare] #[derive(Serialize, Deserialize, Debug, Clone, Builder, Partial, MungosIndexed)]