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
2 changes: 2 additions & 0 deletions javascript/lib/types/CreateInstanceRequest.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { DcsSettingsPayload } from "./DcsSettingsPayload";
import type { Region } from "./Region";
import type { Terrain } from "./Terrain";

export type CreateInstanceRequest = {
product_id: string;
region: Region;
settings: DcsSettingsPayload;
active_mods: Array<string>;
wanted_terrains: Array<Terrain>;
Expand Down
2 changes: 2 additions & 0 deletions javascript/lib/types/Node.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { Region } from "./Region";

export type Node = {
id: string;
name: string;
region: Region;
ip: string;
port: number;
max_cpu: number;
Expand Down
3 changes: 3 additions & 0 deletions javascript/lib/types/Region.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type Region = "de" | "us" | "invalid";
4 changes: 4 additions & 0 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use anyhow::{bail, Ok, Result};
use serde::Serialize;
pub use types::instance::{Instance, InstanceStatus, Terrain};
pub use types::region::Region;
use types::{dcs_runtime::DcsRuntime, system_resources::ServerResources};
use uuid::Uuid;

Expand All @@ -11,6 +12,7 @@ mod types;
#[cfg_attr(test, ts(export, export_to = "../../javascript/lib/types/"))]
pub struct CreateInstanceRequest {
pub product_id: Uuid,
pub region: Region,
pub settings: DcsSettingsPayload,
pub active_mods: Vec<String>,
pub wanted_terrains: Vec<Terrain>,
Expand Down Expand Up @@ -51,6 +53,7 @@ impl Client {

pub async fn create_server(
&self,
region: Region,
name: impl Into<String>,
password: Option<impl Into<String>>,
max_players: u32,
Expand All @@ -64,6 +67,7 @@ impl Client {
) -> Result<Instance> {
let payload = CreateInstanceRequest {
product_id: plan,
region,
settings: DcsSettingsPayload {
initial_server_name: name.into(),
initial_server_password: password.map(|p| p.into()).unwrap_or_default(),
Expand Down
1 change: 1 addition & 0 deletions rust/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub mod dcs_runtime;
pub mod dcs_settings;
pub mod instance;
pub mod node;
pub mod region;
pub mod system_resources;

fn deserialize_array_object<'de, D, T>(deserializer: D) -> Result<Vec<T>, D::Error>
Expand Down
3 changes: 3 additions & 0 deletions rust/src/types/node.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
use serde::Deserialize;
use uuid::Uuid;

use crate::types::region::Region;

#[derive(Debug, Deserialize, Clone)]
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(test, ts(export, export_to = "../../javascript/lib/types/"))]
pub struct Node {
pub id: Uuid,
pub name: String,
pub region: Region,
pub ip: String,
pub port: u32,
pub max_cpu: u32,
Expand Down
13 changes: 13 additions & 0 deletions rust/src/types/region.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use serde::{Deserialize, Serialize};

#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(test, ts(export, export_to = "../../javascript/lib/types/"))]
pub enum Region {
#[serde(rename = "de")]
Germany,
#[serde(rename = "us")]
USA,
#[serde(rename = "invalid")]
Invalid,
}