gitea_client/models/
change_file_operation.rs

1/*
2 * Gitea API
3 *
4 * This documentation describes the Gitea API.
5 *
6 * The version of the OpenAPI document: 1.22.1
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// ChangeFileOperation : ChangeFileOperation for creating, updating or deleting a file
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct ChangeFileOperation {
17    /// new or updated file content, must be base64 encoded
18    #[serde(rename = "content", skip_serializing_if = "Option::is_none")]
19    pub content: Option<String>,
20    /// old path of the file to move
21    #[serde(rename = "from_path", skip_serializing_if = "Option::is_none")]
22    pub from_path: Option<String>,
23    /// indicates what to do with the file
24    #[serde(rename = "operation")]
25    pub operation: Operation,
26    /// path to the existing or new file
27    #[serde(rename = "path")]
28    pub path: String,
29    /// sha is the SHA for the file that already exists, required for update or delete
30    #[serde(rename = "sha", skip_serializing_if = "Option::is_none")]
31    pub sha: Option<String>,
32}
33
34impl ChangeFileOperation {
35    /// ChangeFileOperation for creating, updating or deleting a file
36    pub fn new(operation: Operation, path: String) -> ChangeFileOperation {
37        ChangeFileOperation {
38            content: None,
39            from_path: None,
40            operation,
41            path,
42            sha: None,
43        }
44    }
45}
46/// indicates what to do with the file
47#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
48pub enum Operation {
49    #[serde(rename = "create")]
50    Create,
51    #[serde(rename = "update")]
52    Update,
53    #[serde(rename = "delete")]
54    Delete,
55}
56
57impl Default for Operation {
58    fn default() -> Operation {
59        Self::Create
60    }
61}
62