windmill-api 1.889.0

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
Documentation
/*
 * Windmill API
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 1.889.0
 * Contact: contact@windmill.dev
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct TokenIntrospection {
    #[serde(rename = "kind")]
    pub kind: Kind,
    #[serde(rename = "email")]
    pub email: String,
    #[serde(rename = "username")]
    pub username: String,
    #[serde(rename = "label", skip_serializing_if = "Option::is_none")]
    pub label: Option<String>,
    #[serde(rename = "token_prefix", skip_serializing_if = "Option::is_none")]
    pub token_prefix: Option<String>,
    #[serde(rename = "created_at", skip_serializing_if = "Option::is_none")]
    pub created_at: Option<String>,
    #[serde(rename = "expiration", skip_serializing_if = "Option::is_none")]
    pub expiration: Option<String>,
    /// the one workspace the token is bound to; absent when it is not bound
    #[serde(rename = "workspace_id", skip_serializing_if = "Option::is_none")]
    pub workspace_id: Option<String>,
    /// the workspaces a signed token is bound to, when it names several
    #[serde(rename = "workspace_ids", skip_serializing_if = "Option::is_none")]
    pub workspace_ids: Option<Vec<String>>,
    /// absent when the token is unrestricted
    #[serde(rename = "scopes", skip_serializing_if = "Option::is_none")]
    pub scopes: Option<Vec<String>>,
    #[serde(rename = "read_only")]
    pub read_only: bool,
    /// the token does not carry its owner's workspace admin rights; the rights it does hold in a workspace are in `workspace` 
    #[serde(rename = "admin_withheld")]
    pub admin_withheld: bool,
    /// whether the token reaches superadmin routes: its owner is a superadmin, and it is neither a job token nor one that withholds those rights 
    #[serde(rename = "super_admin")]
    pub super_admin: bool,
    #[serde(rename = "allowed_ips", skip_serializing_if = "Option::is_none")]
    pub allowed_ips: Option<Vec<String>>,
    #[serde(rename = "job_id", skip_serializing_if = "Option::is_none")]
    pub job_id: Option<uuid::Uuid>,
    #[serde(rename = "workspace", skip_serializing_if = "Option::is_none")]
    pub workspace: Option<Box<models::TokenWorkspaceAccess>>,
    #[serde(rename = "route", skip_serializing_if = "Option::is_none")]
    pub route: Option<Box<models::TokenRouteCheck>>,
}

impl TokenIntrospection {
    pub fn new(kind: Kind, email: String, username: String, read_only: bool, admin_withheld: bool, super_admin: bool) -> TokenIntrospection {
        TokenIntrospection {
            kind,
            email,
            username,
            label: None,
            token_prefix: None,
            created_at: None,
            expiration: None,
            workspace_id: None,
            workspace_ids: None,
            scopes: None,
            read_only,
            admin_withheld,
            super_admin,
            allowed_ips: None,
            job_id: None,
            workspace: None,
            route: None,
        }
    }
}
/// 
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Kind {
    #[serde(rename = "session")]
    Session,
    #[serde(rename = "api_token")]
    ApiToken,
    #[serde(rename = "jwt")]
    Jwt,
    #[serde(rename = "external")]
    External,
    #[serde(rename = "superadmin_secret")]
    SuperadminSecret,
}

impl Default for Kind {
    fn default() -> Kind {
        Self::Session
    }
}