@@ -27,20 +27,27 @@ use crate::{
2727} ;
2828
2929#[ derive( Serialize , Debug , ToSchema ) ]
30- #[ serde( rename_all = "camelCase" ) ]
3130pub struct ListComponentsV1Response {
3231 #[ schema(
3332 value_type = Vec <ComponentDetailsV1 >,
3433 example = json!( [
3534 {
36- "component_id " : "01H9ZQD35JPMBGHH69BT0Q79AA" ,
35+ "componentId " : "01H9ZQD35JPMBGHH69BT0Q79AA" ,
3736 "name" : "my-vpc" ,
38- "schema_name " : "AWS::EC2::VPC"
37+ "schemaName " : "AWS::EC2::VPC"
3938 } ,
4039 {
41- "component_id " : "01H9ZQD35JPMBGHH69BT0Q79BB" ,
40+ "componentId " : "01H9ZQD35JPMBGHH69BT0Q79BB" ,
4241 "name" : "Public 1" ,
43- "schema_name" : "AWS::EC2::Subnet"
42+ "schemaName" : "AWS::EC2::Subnet" ,
43+ "qualificationStatus" : {
44+ "total" : 2 ,
45+ "succeeded" : 1 ,
46+ "warned" : 0 ,
47+ "failed" : 0 ,
48+ "running" : 1
49+ } ,
50+ "canBeUpgraded" : true
4451 }
4552 ] )
4653 ) ]
@@ -56,8 +63,34 @@ pub struct ComponentDetailsV1 {
5663 pub name : String ,
5764 pub schema_name : String ,
5865 pub codegen : Option < Value > ,
66+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
67+ pub qualification_status : Option < QualificationStatusV1 > ,
68+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
69+ pub can_be_upgraded : Option < bool > ,
70+ }
71+
72+ #[ derive( Serialize , Debug , ToSchema ) ]
73+ pub struct QualificationStatusV1 {
74+ pub total : u64 ,
75+ pub succeeded : u64 ,
76+ pub warned : u64 ,
77+ pub failed : u64 ,
78+ pub running : u64 ,
5979}
6080
81+ impl From < si_frontend_types:: ComponentQualificationStats > for QualificationStatusV1 {
82+ fn from ( stats : si_frontend_types:: ComponentQualificationStats ) -> Self {
83+ Self {
84+ total : stats. total ,
85+ succeeded : stats. succeeded ,
86+ warned : stats. warned ,
87+ failed : stats. failed ,
88+ running : stats. running ,
89+ }
90+ }
91+ }
92+
93+
6194#[ utoipa:: path(
6295 get,
6396 path = "/v1/w/{workspace_id}/change-sets/{change_set_id}/components" ,
@@ -67,21 +100,31 @@ pub struct ComponentDetailsV1 {
67100 ( "limit" = Option <String >, Query , description = "Maximum number of results to return (default: 50, max: 300)" ) ,
68101 ( "cursor" = Option <String >, Query , description = "Cursor for pagination (ComponentId of the last item from previous page)" ) ,
69102 ( "includeCodegen" = Option <bool >, Query , description = "Allow returning the codegen for the cloudformation template for the component (if it exists)" ) ,
103+ ( "includeQualifications" = Option <bool >, Query , description = "Include real-time qualification status" ) ,
104+ ( "includeUpgradeStatus" = Option <bool >, Query , description = "Include upgrade-ability information" ) ,
70105 ) ,
71106 summary = "List all components" ,
72107 tag = "components" ,
73108 responses(
74109 ( status = 200 , description = "Components retrieved successfully" , body = ListComponentsV1Response , example = json!( {
75110 "componentDetails" : [
76111 {
77- "component_id " : "01H9ZQD35JPMBGHH69BT0Q79AA" ,
112+ "componentId " : "01H9ZQD35JPMBGHH69BT0Q79AA" ,
78113 "name" : "my-vpc" ,
79- "schema_name " : "AWS::EC2::VPC"
114+ "schemaName " : "AWS::EC2::VPC"
80115 } ,
81116 {
82- "component_id " : "01H9ZQD35JPMBGHH69BT0Q79BB" ,
117+ "componentId " : "01H9ZQD35JPMBGHH69BT0Q79BB" ,
83118 "name" : "Public 1" ,
84- "schema_name" : "AWS::EC2::Subnet"
119+ "schemaName" : "AWS::EC2::Subnet" ,
120+ "qualificationStatus" : {
121+ "total" : 2 ,
122+ "succeeded" : 1 ,
123+ "warned" : 0 ,
124+ "failed" : 0 ,
125+ "running" : 1
126+ } ,
127+ "canBeUpgraded" : true
85128 }
86129 ] ,
87130 "nextCursor" : null
@@ -143,21 +186,32 @@ pub async fn list_components(
143186 name,
144187 schema_name,
145188 codegen : None ,
189+ qualification_status : None ,
190+ can_be_upgraded : None ,
146191 } ;
147192
148- if let Some ( codegen ) = params . include_codegen {
149- if codegen {
150- let code_map_av_id =
151- Component :: find_code_map_attribute_value_id ( ctx, component. id ( ) ) . await ?;
193+ // Handle existing includeCodegen parameter for backward compatibility
194+ if let Some ( true ) = params . include_codegen {
195+ let code_map_av_id =
196+ Component :: find_code_map_attribute_value_id ( ctx, component. id ( ) ) . await ?;
152197
153- let view = AttributeValue :: view ( ctx, code_map_av_id) . await ?;
154- if let Some ( v) = view {
155- let details = v. get ( "awsCloudFormationLint" ) ;
156- comp_response. codegen = details. cloned ( ) ;
157- }
198+ let view = AttributeValue :: view ( ctx, code_map_av_id) . await ?;
199+ if let Some ( v) = view {
200+ let details = v. get ( "awsCloudFormationLint" ) ;
201+ comp_response. codegen = details. cloned ( ) ;
158202 }
159203 }
160204
205+ // Handle new inclusion parameters
206+ if let Some ( true ) = params. include_qualifications {
207+ let stats = super :: get_qualification_stats_with_realtime_running ( ctx, component. id ( ) ) . await ?;
208+ comp_response. qualification_status = Some ( stats) ;
209+ }
210+
211+ if let Some ( true ) = params. include_upgrade_status {
212+ comp_response. can_be_upgraded = Some ( component. can_be_upgraded ( ctx) . await ?) ;
213+ }
214+
161215 comp_details. push ( comp_response) ;
162216 }
163217
0 commit comments