fastly_api/models/
snippet.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 Snippet {
13    /// The name for the snippet.
14    #[serde(rename = "name", skip_serializing_if = "Option::is_none")]
15    pub name: Option<String>,
16    /// The location in generated VCL where the snippet should be placed.
17    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
18    pub _type: Option<Type>,
19    /// The VCL code that specifies exactly what the snippet does.
20    #[serde(rename = "content", skip_serializing_if = "Option::is_none")]
21    pub content: Option<String>,
22    /// Priority determines execution order. Lower numbers execute first.
23    #[serde(rename = "priority", skip_serializing_if = "Option::is_none")]
24    pub priority: Option<String>,
25    /// Sets the snippet version.
26    #[serde(rename = "dynamic", skip_serializing_if = "Option::is_none")]
27    pub dynamic: Option<Dynamic>,
28}
29
30impl Snippet {
31    pub fn new() -> Snippet {
32        Snippet {
33            name: None,
34            _type: None,
35            content: None,
36            priority: None,
37            dynamic: None,
38        }
39    }
40}
41
42/// The location in generated VCL where the snippet should be placed.
43#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
44pub enum Type {
45    #[serde(rename = "init")]
46    Init,
47    #[serde(rename = "recv")]
48    Recv,
49    #[serde(rename = "hash")]
50    Hash,
51    #[serde(rename = "hit")]
52    Hit,
53    #[serde(rename = "miss")]
54    Miss,
55    #[serde(rename = "pass")]
56    Pass,
57    #[serde(rename = "fetch")]
58    Fetch,
59    #[serde(rename = "error")]
60    Error,
61    #[serde(rename = "deliver")]
62    Deliver,
63    #[serde(rename = "log")]
64    Log,
65    #[serde(rename = "none")]
66    None,
67}
68
69impl Default for Type {
70    fn default() -> Type {
71        Self::Init
72    }
73}
74/// Sets the snippet version.
75#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
76pub enum Dynamic {
77    #[serde(rename = "0")]
78    Regular,
79    #[serde(rename = "1")]
80    Dynamic,
81}
82
83impl Default for Dynamic {
84    fn default() -> Dynamic {
85        Self::Regular
86    }
87}
88