@@ -48,12 +48,40 @@ impl GenerateResponse for PutMachineConfigurationOutcome {
48
48
}
49
49
}
50
50
51
+ impl GenerateResponse for MachineConfiguration {
52
+ fn generate_response ( & self ) -> Response {
53
+ let vcpu_count = match self . vcpu_count {
54
+ Some ( v) => v. to_string ( ) ,
55
+ None => String :: from ( "Uninitialized" ) ,
56
+ } ;
57
+ let mem_size = match self . mem_size_mib {
58
+ Some ( v) => v. to_string ( ) ,
59
+ None => String :: from ( "Uninitialized" ) ,
60
+ } ;
61
+
62
+ json_response (
63
+ StatusCode :: Ok ,
64
+ format ! (
65
+ "{{ \" vcpu_count\" : {:?}, \" mem_size_mib\" : {:?} }}" ,
66
+ vcpu_count, mem_size
67
+ ) ,
68
+ )
69
+ }
70
+ }
71
+
51
72
impl IntoParsedRequest for MachineConfiguration {
52
- fn into_parsed_request ( self , _method : Method ) -> result:: Result < ParsedRequest , String > {
73
+ fn into_parsed_request ( self , method : Method ) -> result:: Result < ParsedRequest , String > {
53
74
let ( sender, receiver) = oneshot:: channel ( ) ;
54
- Ok ( ParsedRequest :: Sync (
55
- SyncRequest :: PutMachineConfiguration ( self , sender) ,
56
- receiver,
57
- ) )
75
+ match method {
76
+ Method :: Get => Ok ( ParsedRequest :: Sync (
77
+ SyncRequest :: GetMachineConfiguration ( sender) ,
78
+ receiver,
79
+ ) ) ,
80
+ Method :: Put => Ok ( ParsedRequest :: Sync (
81
+ SyncRequest :: PutMachineConfiguration ( self , sender) ,
82
+ receiver,
83
+ ) ) ,
84
+ _ => Ok ( ParsedRequest :: Dummy ) ,
85
+ }
58
86
}
59
87
}
0 commit comments