lib

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

farm_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 FarmGcsLocation {
      7     pub id: String,
      8     pub created_at: String,
      9     pub updated_at: String,
     10     pub farm_id: String,
     11     pub gcs_location_id: String,
     12     pub role: String,
     13 }
     14 
     15 #[derive(Clone, Deserialize, Serialize)]
     16 pub struct IFarmGcsLocationFields {
     17     pub farm_id: String,
     18     pub gcs_location_id: String,
     19     pub role: String,
     20 }
     21 
     22 #[derive(Clone, Deserialize, Serialize)]
     23 pub struct IFarmGcsLocationFieldsPartial {
     24     pub farm_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 IFarmGcsLocationFieldsFilter {
     31     pub id: Option<String>,
     32     pub created_at: Option<String>,
     33     pub updated_at: Option<String>,
     34     pub farm_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 FarmGcsLocationQueryBindValues {
     42     Id { id: String },
     43     FarmId { farm_id: String },
     44     GcsLocationId { gcs_location_id: String },
     45 }
     46 impl FarmGcsLocationQueryBindValues {
     47     pub fn to_filter_param(&self) -> (&'static str, Value) {
     48         match self {
     49             Self::Id { id } => ("id", Value::from(id.clone())),
     50             Self::FarmId { farm_id } => ("farm_id", Value::from(farm_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::FarmId { farm_id } => farm_id.clone(),
     68             Self::GcsLocationId { gcs_location_id } => gcs_location_id.clone(),
     69         }
     70     }
     71 }
     72 
     73 pub struct IFarmGcsLocationCreateTs;
     74 pub type IFarmGcsLocationCreate = IFarmGcsLocationFields;
     75 pub struct IFarmGcsLocationCreateResolveTs;
     76 pub type IFarmGcsLocationCreateResolve = IResult<FarmGcsLocation>;
     77 #[derive(Deserialize, Serialize)]
     78 pub struct IFarmGcsLocationFindOneArgs {
     79     pub on: FarmGcsLocationQueryBindValues,
     80 }
     81 
     82 #[derive(Deserialize, Serialize)]
     83 #[serde(untagged)]
     84 pub enum IFarmGcsLocationFindOne {
     85     On(IFarmGcsLocationFindOneArgs),
     86 }
     87 
     88 pub struct IFarmGcsLocationFindOneResolveTs;
     89 pub type IFarmGcsLocationFindOneResolve = IResult<Option<FarmGcsLocation>>;
     90 #[derive(Deserialize, Serialize)]
     91 pub struct IFarmGcsLocationFindManyArgs {
     92     pub filter: Option<IFarmGcsLocationFieldsFilter>,
     93 }
     94 pub type IFarmGcsLocationFindMany = IFarmGcsLocationFindManyArgs;
     95 pub struct IFarmGcsLocationFindManyResolveTs;
     96 pub type IFarmGcsLocationFindManyResolve = IResultList<FarmGcsLocation>;
     97 pub struct IFarmGcsLocationDeleteTs;
     98 pub type IFarmGcsLocationDelete = IFarmGcsLocationFindOne;
     99 pub struct IFarmGcsLocationDeleteResolveTs;
    100 pub type IFarmGcsLocationDeleteResolve = IResult<String>;
    101 #[derive(Deserialize, Serialize)]
    102 pub struct IFarmGcsLocationUpdateArgs {
    103     pub on: FarmGcsLocationQueryBindValues,
    104     pub fields: IFarmGcsLocationFieldsPartial,
    105 }
    106 pub type IFarmGcsLocationUpdate = IFarmGcsLocationUpdateArgs;
    107 pub struct IFarmGcsLocationUpdateResolveTs;
    108 pub type IFarmGcsLocationUpdateResolve = IResult<FarmGcsLocation>;