mirror of
https://github.com/Noratrieb/terustform.git
synced 2026-01-16 17:35:13 +01:00
Improvements
This commit is contained in:
parent
edf7b7dac3
commit
bf7bd330b3
10 changed files with 189 additions and 72 deletions
|
|
@ -4,7 +4,9 @@ mod resources;
|
|||
use std::collections::HashMap;
|
||||
|
||||
use eyre::Context;
|
||||
use terustform::{datasource::DataSource, provider::Provider, DResult, EyreExt, Schema, Value};
|
||||
use terustform::{
|
||||
datasource::DataSource, provider::Provider, resource::Resource, DResult, EyreExt, Schema, Value,
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> eyre::Result<()> {
|
||||
|
|
@ -49,6 +51,6 @@ impl Provider for ExampleProvider {
|
|||
}
|
||||
|
||||
fn resources(&self) -> terustform::provider::Resources<Self> {
|
||||
vec![]
|
||||
vec![resources::class_resource::ClassResource::erase()]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,78 @@
|
|||
use terustform::{datasource::DataSource, DResult, Value};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use terustform::{resource::Resource, Attribute, DResult, Mode, Schema, Value};
|
||||
|
||||
use crate::client::CorsClient;
|
||||
|
||||
pub struct ClassResource {
|
||||
client: CorsClient,
|
||||
}
|
||||
|
||||
impl Resource for ClassResource {
|
||||
type ProviderData = CorsClient;
|
||||
|
||||
async fn read(&self, config: Value) -> DResult<Value> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
async fn create(&self, config: Value) -> DResult<Value> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
async fn update(&self, config: Value) -> DResult<Value> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
async fn delete(&self, state: Value) -> DResult<Value> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn name(provider_name: &str) -> String {
|
||||
format!("{provider_name}_class")
|
||||
}
|
||||
|
||||
fn schema() -> terustform::Schema {
|
||||
Schema {
|
||||
description: "A class".into(),
|
||||
attributes: HashMap::from([
|
||||
(
|
||||
"id".to_owned(),
|
||||
// TODO: UUID validation :3
|
||||
Attribute::String {
|
||||
description: "The UUID".to_owned(),
|
||||
mode: Mode::Computed,
|
||||
sensitive: false,
|
||||
},
|
||||
),
|
||||
(
|
||||
"name".to_owned(),
|
||||
Attribute::String {
|
||||
description: "The description".to_owned(),
|
||||
mode: Mode::Required,
|
||||
sensitive: false,
|
||||
},
|
||||
),
|
||||
(
|
||||
"description".to_owned(),
|
||||
Attribute::String {
|
||||
description: "The description".to_owned(),
|
||||
mode: Mode::Optional,
|
||||
sensitive: false,
|
||||
},
|
||||
),
|
||||
(
|
||||
"discord_id".to_owned(),
|
||||
Attribute::String {
|
||||
description: "The discord ID of the class".to_owned(),
|
||||
mode: Mode::Optional,
|
||||
sensitive: false,
|
||||
},
|
||||
),
|
||||
]),
|
||||
}
|
||||
}
|
||||
|
||||
fn new(client: Self::ProviderData) -> DResult<Self> {
|
||||
Ok(Self { client })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue