1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
 * Copyright (C) 2023  Aravinth Manivannan <realaravinth@batsense.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
//! Assets that constitute a release for a given tag.
use serde::{Deserialize, Serialize};

/// Assets that constitute a release for a given tag.
#[derive(Clone, Debug, Serialize, Deserialize, Default, Eq, PartialEq)]
pub struct Release {
    /// Unique identifier
    pub index: usize,

    /// Git tag name of the release.
    pub tag_name: String,

    /// Specifies the commitish value that determines where the Git tag is created from. Can be any
    /// branch or commit SHA. Unused if the Git tag already exists.
    pub target_commitish: Option<String>,

    /// The name of the release
    pub name: String,

    /// Text describing the contents of the release.
    pub body: String,

    /// True if the release is a draft.
    pub draft: bool,

    /// True if the release is a pre-release.
    pub prerelease: bool,

    /// Unique identifier of the user who authored the release.
    pub publisher_id: usize,

    /// Name of the user who authored the release.
    pub publisher_name: String,

    /// Email of the user who authored the release.
    pub publisher_email: Option<String>,

    /// List of assets associated with the release.
    pub assets: Option<Vec<ReleaseAsset>>,

    // TODO: add validation for format "date-time"
    /// Creation time
    pub created: String,

    // TODO: add validation for format "date-time"
    /// Publication time.
    pub published: String,
}

/// A file associated with a release.
#[derive(Clone, Debug, Serialize, Deserialize, Default, Eq, PartialEq)]
pub struct ReleaseAsset {
    /// Unique identifier of the release asset.
    pub index: usize,

    /// The name of the release asset.
    pub name: String,

    /// The content type of the release asset (application/zip, etc.).
    pub content_type: String,

    /// Size in bytes of the release asset.
    pub size: String,

    /// The number of times the release asset was downloaded.
    pub download_count: usize,

    // TODO: add validation for format "date-time"
    /// Creation time
    pub created: String,

    // TODO: add validation for format "date-time"
    /// Last update time.
    pub updated: String,

    /// The URL from which the release asset can be downloaded.
    pub download_url: String,
}