@@ -24,9 +24,10 @@ const (
2424 ApplicationTag Tag = "Application"
2525 BrickTag Tag = "Brick"
2626 AIModels Tag = "AIModels"
27+ SystemTag Tag = "System"
2728)
2829
29- var validTags = []Tag {ApplicationTag , BrickTag , AIModels }
30+ var validTags = []Tag {ApplicationTag , BrickTag , AIModels , SystemTag }
3031
3132type Generator struct {
3233 reflector * openapi3.Reflector
@@ -115,6 +116,24 @@ func NewOpenApiGenerator(version string) *Generator {
115116 },
116117 },
117118 },
119+ "NoContent" : {
120+ Response : & openapi3.Response {
121+ Description : "No Content" ,
122+ Content : map [string ]openapi3.MediaType {
123+ "application/json" : {
124+ Example : f .Ptr (interface {}(map [string ]interface {}{
125+ "code" : 204 ,
126+ "message" : "No content to return." ,
127+ })),
128+ Schema : & openapi3.SchemaOrRef {
129+ SchemaReference : & openapi3.SchemaReference {
130+ Ref : ErrorResponseSchema ,
131+ },
132+ },
133+ },
134+ },
135+ },
136+ },
118137 "PreconditionFailed" : {
119138 Response : & openapi3.Response {
120139 Description : "Precondition Failed" ,
@@ -573,6 +592,82 @@ Contains a JSON object with the details of an error.
573592 {StatusCode : http .StatusInternalServerError , Reference : "#/components/responses/InternalServerError" },
574593 },
575594 },
595+ {
596+ OperationId : "checkUpdate" ,
597+ Method : http .MethodGet ,
598+ Path : "/v1/system/update/check" ,
599+ Parameters : (* struct {
600+ OnlyArduino bool `query:"only-arduino" description:"If true, check only for Arduino packages that require an upgrade. Default is false."`
601+ })(nil ),
602+ CustomSuccessResponse : & CustomResponseDef {
603+ ContentType : "application/json" ,
604+ DataStructure : handlers.UpdateCheckResult {},
605+ Description : "Successful response" ,
606+ StatusCode : http .StatusOK ,
607+ },
608+ Description : "Returns the details of packages to be upgraded." ,
609+ Summary : "Get the packages that requires an upgrade" ,
610+ Tags : []Tag {SystemTag },
611+ PossibleErrors : []ErrorResponse {
612+ {StatusCode : http .StatusInternalServerError , Reference : "#/components/responses/InternalServerError" },
613+ {StatusCode : http .StatusBadRequest , Reference : "#/components/responses/BadRequest" },
614+ {StatusCode : http .StatusNoContent , Reference : "#/components/responses/NoContent" },
615+ },
616+ },
617+ {
618+ OperationId : "applyUpdate" ,
619+ Method : http .MethodPut ,
620+ Path : "/v1/system/update/apply" ,
621+ Parameters : (* struct {
622+ OnlyArduino bool `query:"only-arduino" description:"If true, upgrade only the Arduino packages that require an upgrade. Default is false."`
623+ })(nil ),
624+ CustomSuccessResponse : & CustomResponseDef {
625+ Description : "Successful response" ,
626+ StatusCode : http .StatusOK ,
627+ },
628+ Description : "Start the upgrade process." ,
629+ Summary : "Start the upgrade process in background" ,
630+ Tags : []Tag {SystemTag },
631+ PossibleErrors : []ErrorResponse {
632+ {StatusCode : http .StatusConflict , Reference : "#/components/responses/Conflict" },
633+ {StatusCode : http .StatusNoContent , Reference : "#/components/responses/NoContent" },
634+ {StatusCode : http .StatusInternalServerError , Reference : "#/components/responses/InternalServerError" },
635+ },
636+ },
637+ {
638+ OperationId : "eventsUpdate" ,
639+ Method : http .MethodGet ,
640+ Path : "/v1/system/update/events" ,
641+ Request : nil ,
642+ Description : "Returns the events of current update process." ,
643+ Summary : "SSE stream of the update process" ,
644+ Tags : []Tag {SystemTag },
645+ CustomSuccessResponse : & CustomResponseDef {
646+ ContentType : "text/event-stream" ,
647+ DataStructure : "" ,
648+ Description : `A stream of Server-Sent Events (SSE) that notifies the progress of the update process.
649+ The client will receive events formatted as follows:
650+
651+ **Event 'log'**:
652+ Contains a log message of the apt upgrade command.
653+ 'event: log'
654+ 'data: "updating package: 0.25"'
655+
656+ **Event 'restarting'**:
657+ Contains a string with the message that the upgrade is completed and the system is restarting.
658+ 'event: restarting'
659+ 'data: Upgrade completed. Restarting'
660+
661+ **Event 'error'**:
662+ Contains a JSON object with the details of an error.
663+ 'event: error'
664+ 'data: {"code":"internal_service_err","message":"An error occurred during operation"}'
665+ ` ,
666+ },
667+ PossibleErrors : []ErrorResponse {
668+ {StatusCode : http .StatusInternalServerError , Reference : "#/components/responses/InternalServerError" },
669+ },
670+ },
576671 }
577672
578673 for _ , op := range operations {
0 commit comments