lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README | LICENSE

plot_gcs_location.rs (3496B)


      1 use radroots_types::types::{IResult, IResultList};
      2 use serde::{Deserialize, Serialize};
      3 use serde_json::Value;
      4 
      5 #[derive(Serialize, Deserialize)]
      6 pub struct PlotGcsLocation {
      7     pub id: String,
      8     pub created_at: String,
      9     pub updated_at: String,
     10     pub plot_id: String,
     11     pub gcs_location_id: String,
     12     pub role: String,
     13 }
     14 
     15 #[derive(Clone, Deserialize, Serialize)]
     16 pub struct IPlotGcsLocationFields {
     17     pub plot_id: String,
     18     pub gcs_location_id: String,
     19     pub role: String,
     20 }
     21 
     22 #[derive(Clone, Deserialize, Serialize)]
     23 pub struct IPlotGcsLocationFieldsPartial {
     24     pub plot_id: Option<serde_json::Value>,
     25     pub gcs_location_id: Option<serde_json::Value>,
     26     pub role: Option<serde_json::Value>,
     27 }
     28 
     29 #[derive(Clone, Deserialize, Serialize)]
     30 pub struct IPlotGcsLocationFieldsFilter {
     31     pub id: Option<String>,
     32     pub created_at: Option<String>,
     33     pub updated_at: Option<String>,
     34     pub plot_id: Option<String>,
     35     pub gcs_location_id: Option<String>,
     36     pub role: Option<String>,
     37 }
     38 
     39 #[derive(Clone, Deserialize, Serialize)]
     40 #[serde(untagged)]
     41 pub enum PlotGcsLocationQueryBindValues {
     42     Id { id: String },
     43     PlotId { plot_id: String },
     44     GcsLocationId { gcs_location_id: String },
     45 }
     46 impl PlotGcsLocationQueryBindValues {
     47     pub fn to_filter_param(&self) -> (&'static str, Value) {
     48         match self {
     49             Self::Id { id } => ("id", Value::from(id.clone())),
     50             Self::PlotId { plot_id } => ("plot_id", Value::from(plot_id.clone())),
     51             Self::GcsLocationId { gcs_location_id } => {
     52                 ("gcs_location_id", Value::from(gcs_location_id.clone()))
     53             }
     54         }
     55     }
     56 
     57     pub fn primary_key(&self) -> Option<String> {
     58         match self {
     59             Self::Id { id } => Some(id.clone()),
     60             _ => None,
     61         }
     62     }
     63 
     64     pub fn lookup_key(&self) -> String {
     65         match self {
     66             Self::Id { id } => id.clone(),
     67             Self::PlotId { plot_id } => plot_id.clone(),
     68             Self::GcsLocationId { gcs_location_id } => gcs_location_id.clone(),
     69         }
     70     }
     71 }
     72 
     73 pub struct IPlotGcsLocationCreateTs;
     74 pub type IPlotGcsLocationCreate = IPlotGcsLocationFields;
     75 pub struct IPlotGcsLocationCreateResolveTs;
     76 pub type IPlotGcsLocationCreateResolve = IResult<PlotGcsLocation>;
     77 #[derive(Deserialize, Serialize)]
     78 pub struct IPlotGcsLocationFindOneArgs {
     79     pub on: PlotGcsLocationQueryBindValues,
     80 }
     81 
     82 #[derive(Deserialize, Serialize)]
     83 #[serde(untagged)]
     84 pub enum IPlotGcsLocationFindOne {
     85     On(IPlotGcsLocationFindOneArgs),
     86 }
     87 
     88 pub struct IPlotGcsLocationFindOneResolveTs;
     89 pub type IPlotGcsLocationFindOneResolve = IResult<Option<PlotGcsLocation>>;
     90 #[derive(Deserialize, Serialize)]
     91 pub struct IPlotGcsLocationFindManyArgs {
     92     pub filter: Option<IPlotGcsLocationFieldsFilter>,
     93 }
     94 pub type IPlotGcsLocationFindMany = IPlotGcsLocationFindManyArgs;
     95 pub struct IPlotGcsLocationFindManyResolveTs;
     96 pub type IPlotGcsLocationFindManyResolve = IResultList<PlotGcsLocation>;
     97 pub struct IPlotGcsLocationDeleteTs;
     98 pub type IPlotGcsLocationDelete = IPlotGcsLocationFindOne;
     99 pub struct IPlotGcsLocationDeleteResolveTs;
    100 pub type IPlotGcsLocationDeleteResolve = IResult<String>;
    101 #[derive(Deserialize, Serialize)]
    102 pub struct IPlotGcsLocationUpdateArgs {
    103     pub on: PlotGcsLocationQueryBindValues,
    104     pub fields: IPlotGcsLocationFieldsPartial,
    105 }
    106 pub type IPlotGcsLocationUpdate = IPlotGcsLocationUpdateArgs;
    107 pub struct IPlotGcsLocationUpdateResolveTs;
    108 pub type IPlotGcsLocationUpdateResolve = IResult<PlotGcsLocation>;