Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion internal/api/docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,7 @@ components:
properties:
bricks:
items:
$ref: '#/components/schemas/BrickInstance'
$ref: '#/components/schemas/BrickInstanceListItem'
nullable: true
type: array
type: object
Expand Down Expand Up @@ -1380,6 +1380,31 @@ components:
for backward compatibility.'
type: object
type: object
BrickInstanceListItem:
properties:
author:
type: string
category:
type: string
config_variables:
items:
$ref: '#/components/schemas/BrickConfigVariable'
type: array
id:
type: string
model:
type: string
name:
type: string
status:
type: string
variables:
additionalProperties:
type: string
description: 'Deprecated: use config_variables instead. This field is kept
for backward compatibility.'
type: object
type: object
BrickListItem:
properties:
author:
Expand Down
16 changes: 15 additions & 1 deletion internal/e2e/client/client.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/orchestrator/bricks/bricks.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (s *Service) List() (BrickListResult, error) {
}

func (s *Service) AppBrickInstancesList(a *app.ArduinoApp) (AppBrickInstancesResult, error) {
res := AppBrickInstancesResult{BrickInstances: make([]BrickInstance, len(a.Descriptor.Bricks))}
res := AppBrickInstancesResult{BrickInstances: make([]BrickInstanceListItem, len(a.Descriptor.Bricks))}
for i, brickInstance := range a.Descriptor.Bricks {
brick, found := s.bricksIndex.FindBrickByID(brickInstance.ID)
if !found {
Expand All @@ -80,19 +80,19 @@ func (s *Service) AppBrickInstancesList(a *app.ArduinoApp) (AppBrickInstancesRes

variablesMap, configVariables := getBrickConfigDetails(brick, brickInstance.Variables)

res.BrickInstances[i] = BrickInstance{
res.BrickInstances[i] = BrickInstanceListItem{
ID: brick.ID,
Name: brick.Name,
Author: "Arduino", // TODO: for now we only support our bricks
Category: brick.Category,
Status: "installed",
RequireModel: brick.RequireModel,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the require_model must be kept in the response, isn't it ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I preferred to restart the PR here: #120
Ensuring to have an up-to-date repo and integrating unit and e2e tests.

ModelID: brickInstance.Model, // TODO: in case is not set by the user, should we return the default model?
Variables: variablesMap, // TODO: do we want to show also the default value of not explicitly set variables?
ConfigVariables: configVariables,
}

}

return res, nil
}

Expand Down
13 changes: 12 additions & 1 deletion internal/orchestrator/bricks/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,18 @@ type BrickListItem struct {
}

type AppBrickInstancesResult struct {
BrickInstances []BrickInstance `json:"bricks"`
BrickInstances []BrickInstanceListItem `json:"bricks"`
}

type BrickInstanceListItem struct {
ID string `json:"id"`
Name string `json:"name"`
Author string `json:"author"`
Category string `json:"category"`
Status string `json:"status"`
Variables map[string]string `json:"variables,omitempty" description:"Deprecated: use config_variables instead. This field is kept for backward compatibility."`
ConfigVariables []BrickConfigVariable `json:"config_variables,omitempty"`
ModelID string `json:"model,omitempty"`
}

type BrickInstance struct {
Expand Down