Skip to content

Commit

Permalink
updated drivers index endpoint, generated OpenAPI doc
Browse files Browse the repository at this point in the history
  • Loading branch information
naqvis committed Nov 15, 2023
1 parent 75bcfd6 commit 8f84edc
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
28 changes: 28 additions & 0 deletions OPENAPI_DOC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5438,6 +5438,14 @@ paths:
- websocket
- logic
nullable: true
- name: update_available
in: query
description: list only drivers for which update is available
example: "true"
required: false
schema:
type: boolean
nullable: true
- name: q
in: query
description: returns results based on a [simple query string](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html)
Expand Down Expand Up @@ -19165,6 +19173,26 @@ components:
ignore_connected:
type: boolean
nullable: true
update_available:
type: boolean
nullable: true
update_info:
type: object
properties:
commit:
type: string
message:
type: string
author:
type: string
nullable: true
date:
type: string
nullable: true
required:
- commit
- message
nullable: true
repository_id:
type: string
nullable: true
Expand Down
4 changes: 2 additions & 2 deletions shard.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ shards:

action-controller:
git: https://github.com/spider-gazelle/action-controller.git
version: 7.2.3
version: 7.3.0

active-model:
git: https://github.com/spider-gazelle/active-model.git
Expand Down Expand Up @@ -267,7 +267,7 @@ shards:

placeos-models:
git: https://github.com/placeos/models.git
version: 9.26.0
version: 9.27.0

placeos-resource:
git: https://github.com/place-labs/resource.git
Expand Down
10 changes: 9 additions & 1 deletion src/placeos-rest-api/controllers/drivers.cr
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ module PlaceOS::Api
@[AC::Route::GET("/")]
def index(
@[AC::Param::Info(description: "filter by the type of driver", example: "Logic")]
role : Model::Driver::Role? = nil
role : Model::Driver::Role? = nil,
@[AC::Param::Info(description: "list only drivers for which update is available", example: "true")]
update_available : Bool? = nil
) : Array(Model::Driver)
elastic = Model::Driver.elastic
query = elastic.query(search_params)
Expand All @@ -49,6 +51,12 @@ module PlaceOS::Api
})
end

if update_available
query.filter({
"update_available" => [update_available.as(Bool)],
})
end

query.search_field "name"
query.sort(NAME_SORT_ASC)
paginate_results(elastic, query)
Expand Down

0 comments on commit 8f84edc

Please sign in to comment.