stcloud/models/
generic_api_response.rs

1/* 
2 * Sematext Cloud API
3 *
4 * API Explorer provides access and documentation for Sematext REST API. The REST API requires the API Key to be sent as part of `Authorization` header. E.g.: `Authorization : apiKey e5f18450-205a-48eb-8589-7d49edaea813`.
5 *
6 * OpenAPI spec version: v3
7 * 
8 * Generated by: https://github.com/swagger-api/swagger-codegen.git
9 */
10#![allow(unused_imports)]
11/// GenericApiResponse : Generic wrapper class for all API responses
12
13use serde_json::Value;
14use bigdecimal::BigDecimal;
15use chrono::{Date, NaiveDateTime, NaiveDate, DateTime, FixedOffset, Utc};
16
17use crate::models::*;
18use crate::date_serializer;
19use crate::date_serializer_opt;
20use crate::serialize_quoted_numbers;
21use crate::serialize_quoted_numbers_opt;
22//Uncomment this to deal with limited rfc support on server side
23//use crate::datetime_serializer::*;
24
25#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
26pub struct GenericApiResponse {
27  #[serde(rename = "data")]
28  #[serde(default)]
29  data: Option<Value>, 
30  #[serde(rename = "errors")]
31  #[serde(default)]
32  errors: Option<Vec<Error>>, 
33  #[serde(rename = "message")]
34  #[serde(default)]
35  message: Option<String>, 
36  #[serde(rename = "success")]
37  #[serde(default)]
38  success: Option<bool> 
39}
40
41impl GenericApiResponse {
42  pub fn new() -> GenericApiResponse {
43    GenericApiResponse {
44      data: None,
45      errors: None,
46      message: None,
47      success: None
48    }
49  }
50
51  pub fn set_data(&mut self, data: Value) {
52    self.data = Some(data);
53  }
54
55  pub fn with_data(mut self, data: Value) -> GenericApiResponse {
56    self.data = Some(data);
57    self
58  }
59
60  pub fn data(&self) -> Option<&Value> {
61    self.data.as_ref()
62  }
63
64  pub fn reset_data(&mut self) {
65    self.data = None;
66  }
67
68  pub fn set_errors(&mut self, errors: Vec<Error>) {
69    self.errors = Some(errors);
70  }
71
72  pub fn with_errors(mut self, errors: Vec<Error>) -> GenericApiResponse {
73    self.errors = Some(errors);
74    self
75  }
76
77  pub fn errors(&self) -> Option<&Vec<Error>> {
78    self.errors.as_ref()
79  }
80
81  pub fn reset_errors(&mut self) {
82    self.errors = None;
83  }
84
85  pub fn set_message(&mut self, message: String) {
86    self.message = Some(message);
87  }
88
89  pub fn with_message(mut self, message: String) -> GenericApiResponse {
90    self.message = Some(message);
91    self
92  }
93
94  pub fn message(&self) -> Option<&String> {
95    self.message.as_ref()
96  }
97
98  pub fn reset_message(&mut self) {
99    self.message = None;
100  }
101
102  pub fn set_success(&mut self, success: bool) {
103    self.success = Some(success);
104  }
105
106  pub fn with_success(mut self, success: bool) -> GenericApiResponse {
107    self.success = Some(success);
108    self
109  }
110
111  pub fn success(&self) -> Option<&bool> {
112    self.success.as_ref()
113  }
114
115  pub fn reset_success(&mut self) {
116    self.success = None;
117  }
118
119
120  pub fn validate(&self) {
121  }
122
123}
124
125