Skip to main content

windmill_api/models/
token_introspection.rs

1/*
2 * Windmill API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 1.887.0
7 * Contact: contact@windmill.dev
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct TokenIntrospection {
16    #[serde(rename = "kind")]
17    pub kind: Kind,
18    #[serde(rename = "email")]
19    pub email: String,
20    #[serde(rename = "username")]
21    pub username: String,
22    #[serde(rename = "label", skip_serializing_if = "Option::is_none")]
23    pub label: Option<String>,
24    #[serde(rename = "token_prefix", skip_serializing_if = "Option::is_none")]
25    pub token_prefix: Option<String>,
26    #[serde(rename = "created_at", skip_serializing_if = "Option::is_none")]
27    pub created_at: Option<String>,
28    #[serde(rename = "expiration", skip_serializing_if = "Option::is_none")]
29    pub expiration: Option<String>,
30    /// the one workspace the token is bound to; absent when it is not bound
31    #[serde(rename = "workspace_id", skip_serializing_if = "Option::is_none")]
32    pub workspace_id: Option<String>,
33    /// the workspaces a signed token is bound to, when it names several
34    #[serde(rename = "workspace_ids", skip_serializing_if = "Option::is_none")]
35    pub workspace_ids: Option<Vec<String>>,
36    /// absent when the token is unrestricted
37    #[serde(rename = "scopes", skip_serializing_if = "Option::is_none")]
38    pub scopes: Option<Vec<String>>,
39    #[serde(rename = "read_only")]
40    pub read_only: bool,
41    /// the token does not carry its owner's workspace admin rights; the rights it does hold in a workspace are in `workspace` 
42    #[serde(rename = "admin_withheld")]
43    pub admin_withheld: bool,
44    /// whether the token reaches superadmin routes: its owner is a superadmin, and it is neither a job token nor one that withholds those rights 
45    #[serde(rename = "super_admin")]
46    pub super_admin: bool,
47    #[serde(rename = "allowed_ips", skip_serializing_if = "Option::is_none")]
48    pub allowed_ips: Option<Vec<String>>,
49    #[serde(rename = "job_id", skip_serializing_if = "Option::is_none")]
50    pub job_id: Option<uuid::Uuid>,
51    #[serde(rename = "workspace", skip_serializing_if = "Option::is_none")]
52    pub workspace: Option<Box<models::TokenWorkspaceAccess>>,
53    #[serde(rename = "route", skip_serializing_if = "Option::is_none")]
54    pub route: Option<Box<models::TokenRouteCheck>>,
55}
56
57impl TokenIntrospection {
58    pub fn new(kind: Kind, email: String, username: String, read_only: bool, admin_withheld: bool, super_admin: bool) -> TokenIntrospection {
59        TokenIntrospection {
60            kind,
61            email,
62            username,
63            label: None,
64            token_prefix: None,
65            created_at: None,
66            expiration: None,
67            workspace_id: None,
68            workspace_ids: None,
69            scopes: None,
70            read_only,
71            admin_withheld,
72            super_admin,
73            allowed_ips: None,
74            job_id: None,
75            workspace: None,
76            route: None,
77        }
78    }
79}
80/// 
81#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
82pub enum Kind {
83    #[serde(rename = "session")]
84    Session,
85    #[serde(rename = "api_token")]
86    ApiToken,
87    #[serde(rename = "jwt")]
88    Jwt,
89    #[serde(rename = "external")]
90    External,
91    #[serde(rename = "superadmin_secret")]
92    SuperadminSecret,
93}
94
95impl Default for Kind {
96    fn default() -> Kind {
97        Self::Session
98    }
99}
100