ya_client_model/market/
proposal.rs

1/*
2 * Yagna Market API
3 *
4 * The version of the OpenAPI document: 1.6.1
5 *
6 * Generated by: https://openapi-generator.tech
7 */
8
9use chrono::{DateTime, Utc};
10use serde::{Deserialize, Serialize};
11
12use crate::{ErrorMessage, NodeId};
13
14#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
15pub struct Proposal {
16    /// The object which includes all the Proposal properties.
17    /// This is a JSON object in \"flat convention\" - where keys are full
18    /// property names and their values indicate properties.
19    ///
20    /// The value's Javascript type shall conform with the type of the
21    /// property (as indicated in Golem Standards).
22    ///
23    /// ### Example property object:
24    /// ```json
25    /// {
26    ///     "golem.com.pricing.model": "linear",
27    ///     "golem.com.pricing.model.linear.coeffs": [0.001, 0.002, 0.0],
28    ///     "golem.com.scheme": "payu",
29    ///     "golem.com.scheme.payu.interval_sec": 6.0,
30    ///     "golem.com.usage.vector": ["golem.usage.duration_sec", "golem.usage.cpu_sec"],
31    ///     "golem.inf.cpu.architecture": "x86_64",
32    ///     "golem.inf.cpu.cores": 4,
33    ///     "golem.inf.cpu.threads": 7,
34    ///     "golem.inf.mem.gib": 10.612468048930168,
35    ///     "golem.inf.storage.gib": 81.7227783203125,
36    ///     "golem.node.debug.subnet": "market-devnet",
37    ///     "golem.node.id.name": "tworec@mf-market-devnet",
38    ///     "golem.runtime.name": "vm",
39    ///     "golem.runtime.version@v": "0.1.0"
40    /// }
41    /// ```        #[serde(rename = "properties")]
42    pub properties: serde_json::Value,
43    #[serde(rename = "constraints")]
44    pub constraints: String,
45    #[serde(rename = "proposalId")]
46    pub proposal_id: String,
47    #[serde(rename = "issuerId")]
48    pub issuer_id: NodeId,
49    /// See [State](enum.State.html).
50    #[serde(rename = "state")]
51    pub state: State,
52    /// Object creation timestamp
53    #[serde(rename = "timestamp")]
54    pub timestamp: DateTime<Utc>,
55    /// id of the proposal from other side which this proposal responds to
56    #[serde(rename = "prevProposalId", skip_serializing_if = "Option::is_none")]
57    pub prev_proposal_id: Option<String>,
58}
59
60impl Proposal {
61    pub fn new(
62        properties: serde_json::Value,
63        constraints: String,
64        proposal_id: String,
65        issuer_id: NodeId,
66        state: State,
67        timestamp: DateTime<Utc>,
68    ) -> Proposal {
69        Proposal {
70            properties,
71            constraints,
72            proposal_id,
73            issuer_id,
74            state,
75            timestamp,
76            prev_proposal_id: None,
77        }
78    }
79
80    pub fn prev_proposal_id(&self) -> Result<&String, ErrorMessage> {
81        self.prev_proposal_id
82            .as_ref()
83            .ok_or("no previous proposal id".into())
84    }
85}
86
87/// * `Initial` - proposal arrived from the market as response to subscription
88/// * `Draft` - bespoke counter-proposal issued by one party directly to other party (negotiation phase)
89/// * `Rejected` by other party
90/// * `Accepted` - promoted into the Agreement draft
91/// * `Expired` - not accepted nor rejected before validity period
92#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
93pub enum State {
94    #[serde(rename = "Initial")]
95    /// Proposal arrived from the market as response to subscription
96    Initial,
97    #[serde(rename = "Draft")]
98    /// Bespoke counter-proposal issued by one party directly to other party (negotiation phase)
99    Draft,
100    #[serde(rename = "Rejected")]
101    /// Rejected by other party
102    Rejected,
103    #[serde(rename = "Accepted")]
104    /// Promoted to the Agreement draft
105    Accepted,
106    #[serde(rename = "Expired")]
107    /// Not accepted nor rejected before validity period
108    Expired,
109}