An error occurred while loading the file. Please try again.
-
Szymon Zimnowoda authoreddda4da55
use serde::{Deserialize, Serialize};
use crate::api_model::Platforms;
pub type Rowid = i64;
pub type DbTime = i64;
/// Fields common to all items
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ItemBase {
pub rowid: Rowid,
pub id: String,
#[serde(rename = "type")]
pub _type: String,
pub date_created: DbTime,
pub date_modified: DbTime,
pub date_server_modified: DbTime,
pub deleted: bool,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct ItemWithBase<T> {
#[serde(flatten)]
pub base: ItemBase,
#[serde(flatten)]
pub item: T,
}
/// Property name of PluginRun object, containing port on which plugin starts to
/// listen it's webserver.
pub const WEBSERVER_PORT: &str = "webserverPort";
pub const WEBSERVER_URL: &str = "webserverUrl";
pub const CONTAINER_ID: &str = "containerId";
pub const PLUGIN_ALIAS: &str = "pluginAlias";
pub const CONTAINER_IMAGE: &str = "containerImage";
pub const UNIQUE_ID: &str = "uniqueId";
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct PluginRunItem {
/// Link to an image example: gitlab.memri.io:5050/..../plugin_name:main-latest
pub container_image: String,
/// The same as ID in the database
pub target_item_id: String,
pub webserver_port: u32,
pub webserver_url: String,
/// Unique name of the container
pub container_id: String,
/// Run status of the plugin
pub status: Option<String>,
/// Human friendly name for the plugin, used while interacting with it's API
pub plugin_alias: Option<String>,
/// Only one plugin with given id can be present at a time, id might be
/// for example twitter account number.
pub unique_id: Option<String>,
/// Name of the class that runs as a plugin
pub plugin_name: String,
/// Choose where to run the model, on CPU, or GPU
#[serde(default)]
pub execute_on: PluginExecutionPlatform,
}
#[derive(Serialize, Deserialize, Debug, Default, PartialEq)]
#[serde(rename_all = "camelCase")]
pub enum PluginExecutionPlatform {
#[default]
Cpu,
Gpu,
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Trigger {
pub action: String,
pub filter_created_after: i64,
pub filter_created_after_property_name: String,
// TODO: use base item
pub id: String,
pub plugin_run_id: String,
pub trigger_on: String,
}
pub const OAUTH2_FLOW: &str = "Oauth2Flow";
pub const ACCESS_TOKEN: &str = "accessToken";
pub const REFRESH_TOKEN: &str = "refreshToken";
pub const TOKEN_TYPE: &str = "tokenType";
pub const REDIRECT_URI: &str = "redirectUri";
pub const PLATFORM: &str = "platform";
pub const EXPIRES_AFTER: &str = "expiresAfter";
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Oauth2Flow {
pub access_token: String,
pub refresh_token: String,
pub token_type: String,
pub redirect_uri: String,
pub platform: Platforms,
pub expires_after: DbTime,
#[serde(flatten)]
pub base: ItemBase,
}
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
#[serde(rename_all = "camelCase")]
pub enum RegisterState {
VerifyEmailSent,
RegistrationComplete,
}
pub const POD_ACCOUNT: &str = "PodUserAccount";
pub const LOGIN_HASH: &str = "loginHash";
pub const PASSWORD_HASH: &str = "passwordHash";
pub const SALT: &str = "salt";
pub const STATE: &str = "state";
pub const ENCRYPTED_PASS: &str = "encryptedPassword";
pub const CODE: &str = "code";
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct PodUserAccount {
pub login_hash: String,
/// In PHC format
pub password_hash: String,
pub salt: String,
pub state: RegisterState,
pub encrypted_password: String,
pub code: String,
}