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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
* Tapis PgREST API
*
* The Tapis PgREST API provides a RESTful interface to a managed SQL-db-as-a-service.
*
* The version of the OpenAPI document: 1.0.0
* Contact: cicsupport@tacc.utexas.edu
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// TableColumns : A description of the columns of the table, in key/value pair format. Each key corresponds to a single collumn; the name of the key is the name of the column, and the value of the key decribes the type of the column and any additional validation information.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct TableColumns {
/// Whether the column can contain null values.
#[serde(rename = "null", skip_serializing_if = "Option::is_none")]
pub null: Option<bool>,
/// The Postgres type of the column, such as \"integer\", \"varchar\", etc.
#[serde(rename = "data_type")]
pub data_type: String,
/// For columns of type \"varchar\", the max length of the column.
#[serde(rename = "char_len", skip_serializing_if = "Option::is_none")]
pub char_len: Option<i32>,
/// Text area to describe column. Shown in manage endpoints.
#[serde(rename = "comments", skip_serializing_if = "Option::is_none")]
pub comments: Option<String>,
/// Whether the column can contain null values.
#[serde(rename = "unique", skip_serializing_if = "Option::is_none")]
pub unique: Option<bool>,
/// Whether the column can contain null values.
#[serde(rename = "default", skip_serializing_if = "Option::is_none")]
pub default: Option<bool>,
/// Allows user to specify which column to act as a primary_key rather than defaulting to {table_name}_id.
#[serde(rename = "primary_key", skip_serializing_if = "Option::is_none")]
pub primary_key: Option<String>,
/// Whether this column should reference a foreign key in another table.
#[serde(rename = "foreign_key", skip_serializing_if = "Option::is_none")]
pub foreign_key: Option<bool>,
/// Only if foreign_key, sets which table to reference.
#[serde(rename = "reference_table", skip_serializing_if = "Option::is_none")]
pub reference_table: Option<String>,
/// Only if foreign_key, sets when table column to reference.
#[serde(rename = "reference_column", skip_serializing_if = "Option::is_none")]
pub reference_column: Option<String>,
/// Only if foreign_key, sets whether to use ON DELETE or ON UPDATE postgres definition.
#[serde(rename = "on_event", skip_serializing_if = "Option::is_none")]
pub on_event: Option<OnEvent>,
/// Only if foreign_key, sets which event action to call when on_event event occurs.
#[serde(rename = "event_action", skip_serializing_if = "Option::is_none")]
pub event_action: Option<EventAction>,
/// Only if data_type is serial. Delegates what number the data_type will start at.
#[serde(rename = "serial_start", skip_serializing_if = "Option::is_none")]
pub serial_start: Option<i32>,
/// Only if data_type is serial. Delegates what the serial increment between rows will be.
#[serde(rename = "serial_increment", skip_serializing_if = "Option::is_none")]
pub serial_increment: Option<i32>,
}
impl TableColumns {
/// A description of the columns of the table, in key/value pair format. Each key corresponds to a single collumn; the name of the key is the name of the column, and the value of the key decribes the type of the column and any additional validation information.
pub fn new(data_type: String) -> TableColumns {
TableColumns {
null: None,
data_type,
char_len: None,
comments: None,
unique: None,
default: None,
primary_key: None,
foreign_key: None,
reference_table: None,
reference_column: None,
on_event: None,
event_action: None,
serial_start: None,
serial_increment: None,
}
}
}
/// Only if foreign_key, sets whether to use ON DELETE or ON UPDATE postgres definition.
#[derive(
Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize, Default,
)]
pub enum OnEvent {
#[serde(rename = "ON DELETE")]
#[default]
OnDelete,
#[serde(rename = "ON UPDATE")]
OnUpdate,
}
/// Only if foreign_key, sets which event action to call when on_event event occurs.
#[derive(
Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize, Default,
)]
pub enum EventAction {
#[serde(rename = "CASCADE")]
#[default]
Cascade,
#[serde(rename = "SET NULL")]
SetNull,
#[serde(rename = "SET DEFAULT")]
SetDefault,
#[serde(rename = "RESTRICT")]
Restrict,
#[serde(rename = "NO ACTION")]
NoAction,
}