Skip to main content

fastly_api/models/
automation_token.rs

1/*
2 * Fastly API
3 *
4 * Via the Fastly API you can perform any of the operations that are possible within the management console,  including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The API is organized into collections of endpoints that allow manipulation of objects related to Fastly services and accounts. For the most accurate and up-to-date API reference content, visit our [Developer Hub](https://www.fastly.com/documentation/reference/api/) 
5 *
6 */
7
8
9
10
11#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
12pub struct AutomationToken {
13    /// The name of the token.
14    #[serde(rename = "name", skip_serializing_if = "Option::is_none")]
15    pub name: Option<String>,
16    /// The primary role on the token. For tokens with multiple roles, this returns the highest-priority role for backwards compatibility.
17    #[serde(rename = "role", skip_serializing_if = "Option::is_none")]
18    pub role: Option<Role>,
19    /// All roles assigned to the token. Each role includes an `id` and `name`.
20    #[serde(rename = "roles", skip_serializing_if = "Option::is_none")]
21    pub roles: Option<Vec<crate::models::AutomationTokenRole>>,
22    /// The service IDs of the services the token has access to. Empty when `limit_services` is `false` (full access) or when the token has no service access.
23    #[serde(rename = "services", skip_serializing_if = "Option::is_none")]
24    pub services: Option<Vec<String>>,
25    /// When `true`, the token is restricted to only the services in the `services` array. When `false`, the token has access to all services.
26    #[serde(rename = "limit_services", skip_serializing_if = "Option::is_none")]
27    pub limit_services: Option<bool>,
28    /// When `true`, the token is restricted to only the workspaces in the `workspaces` array. When `false`, the token has access to all workspaces. Only applies to roles that support workspace access.
29    #[serde(rename = "limit_workspaces", skip_serializing_if = "Option::is_none")]
30    pub limit_workspaces: Option<bool>,
31    /// The workspace IDs of the workspaces the token has access to. Returns an empty array for tokens without workspace access.
32    #[serde(rename = "workspaces", skip_serializing_if = "Option::is_none")]
33    pub workspaces: Option<Vec<String>>,
34    /// A space-delimited list of authorization scope.
35    #[serde(rename = "scope", skip_serializing_if = "Option::is_none")]
36    pub scope: Option<Scope>,
37    /// A UTC timestamp of when the token expires.
38    #[serde(rename = "expires_at", skip_serializing_if = "Option::is_none")]
39    pub expires_at: Option<String>,
40}
41
42impl AutomationToken {
43    pub fn new() -> AutomationToken {
44        AutomationToken {
45            name: None,
46            role: None,
47            roles: None,
48            services: None,
49            limit_services: None,
50            limit_workspaces: None,
51            workspaces: None,
52            scope: None,
53            expires_at: None,
54        }
55    }
56}
57
58/// The primary role on the token. For tokens with multiple roles, this returns the highest-priority role for backwards compatibility.
59#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
60pub enum Role {
61    #[serde(rename = "billing")]
62    Billing,
63    #[serde(rename = "engineer")]
64    Engineer,
65    #[serde(rename = "user")]
66    User,
67    #[serde(rename = "ngwaf_user_imported")]
68    NgwafUserImported,
69    #[serde(rename = "ngwaf_admin_imported")]
70    NgwafAdminImported,
71    #[serde(rename = "ngwaf_owner_imported")]
72    NgwafOwnerImported,
73    #[serde(rename = "ngwaf_observer_imported")]
74    NgwafObserverImported,
75    #[serde(rename = "tls_admin")]
76    TlsAdmin,
77    #[serde(rename = "tls_viewer")]
78    TlsViewer,
79}
80
81impl Default for Role {
82    fn default() -> Role {
83        Self::Billing
84    }
85}
86/// A space-delimited list of authorization scope.
87#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
88pub enum Scope {
89    #[serde(rename = "global")]
90    Global,
91    #[serde(rename = "purge_select")]
92    PurgeSelect,
93    #[serde(rename = "purge_all")]
94    PurgeAll,
95    #[serde(rename = "global:read")]
96    Globalread,
97}
98
99impl Default for Scope {
100    fn default() -> Scope {
101        Self::Global
102    }
103}
104