romm_cli/endpoints/
platforms.rs1use crate::types::Platform;
2
3use super::Endpoint;
4use serde_json::Value;
5
6#[derive(Debug, Default, Clone)]
8pub struct ListPlatforms;
9
10impl Endpoint for ListPlatforms {
11 type Output = Vec<Platform>;
12
13 fn method(&self) -> &'static str {
14 "GET"
15 }
16
17 fn path(&self) -> String {
18 "/api/platforms".into()
19 }
20}
21
22#[derive(Debug, Clone)]
24pub struct GetPlatform {
25 pub id: u64,
26}
27
28impl Endpoint for GetPlatform {
29 type Output = Platform;
30
31 fn method(&self) -> &'static str {
32 "GET"
33 }
34
35 fn path(&self) -> String {
36 format!("/api/platforms/{}", self.id)
37 }
38}
39
40#[derive(Debug, Default, Clone)]
42pub struct ListSupportedPlatforms;
43
44impl Endpoint for ListSupportedPlatforms {
45 type Output = Value;
46
47 fn method(&self) -> &'static str {
48 "GET"
49 }
50
51 fn path(&self) -> String {
52 "/api/platforms/supported".into()
53 }
54}
55
56#[derive(Debug, Clone)]
58pub struct PutPlatform {
59 pub id: u64,
60 pub body: Value,
61}
62
63impl Endpoint for PutPlatform {
64 type Output = Value;
65
66 fn method(&self) -> &'static str {
67 "PUT"
68 }
69
70 fn path(&self) -> String {
71 format!("/api/platforms/{}", self.id)
72 }
73
74 fn body(&self) -> Option<Value> {
75 Some(self.body.clone())
76 }
77}
78
79#[derive(Debug, Clone)]
81pub struct DeletePlatform {
82 pub id: u64,
83}
84
85impl Endpoint for DeletePlatform {
86 type Output = Value;
87
88 fn method(&self) -> &'static str {
89 "DELETE"
90 }
91
92 fn path(&self) -> String {
93 format!("/api/platforms/{}", self.id)
94 }
95}