From 1f1704bf76666f60c8ba42a2f5bcf0222458baea Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Tue, 3 Jan 2023 13:47:11 +0530 Subject: [PATCH] feat: define Release --- src/lib.rs | 2 ++ src/release.rs | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 src/release.rs diff --git a/src/lib.rs b/src/lib.rs index 6759843..05163fa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,6 +28,7 @@ pub mod milestone; pub mod project; pub mod pullrequest; pub mod reaction; +pub mod release; pub mod repository; pub mod topic; pub mod user; @@ -40,6 +41,7 @@ pub use milestone::Milestone; pub use project::Project; pub use pullrequest::PullRequest; pub use reaction::Reaction; +pub use release::ReleaseAsset; pub use repository::Repository; pub use topic::Topic; pub use user::User; diff --git a/src/release.rs b/src/release.rs new file mode 100644 index 0000000..1ffa450 --- /dev/null +++ b/src/release.rs @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2023 Aravinth Manivannan + * + * 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 . + */ +//! 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, + + /// 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, + + /// List of assets associated with the release. + pub assets: Option>, + + // 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, +}