Skip to content
Open
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
59 changes: 56 additions & 3 deletions grid-proxy/docs/docs.go

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

59 changes: 56 additions & 3 deletions grid-proxy/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@
"description": "Min number of public ips in the 'node' contract",
"name": "number_of_public_ips",
"in": "query"
},
{
"type": "string",
"description": "Select specific fields to return. Comma-separated values. E.g., 'contractId,twinId,state'. Supports snake_case and camelCase field names.",
"name": "select",
"in": "query"
}
],
"responses": {
Expand Down Expand Up @@ -823,6 +829,12 @@
"name": "randomize",
"in": "query"
},
{
"type": "string",
"description": "Select specific fields to return. Comma-separated values. E.g., 'id,farmId,country'. Supports snake_case and camelCase field names.",
"name": "select",
"in": "query"
},
{
"enum": [
"status",
Expand Down Expand Up @@ -1375,6 +1387,12 @@
"description": "Get only the free ips, based on the ip have a contract id or not",
"name": "free",
"in": "query"
},
{
"type": "string",
"description": "Select specific fields to return. Comma-separated values. E.g., 'id,ip,farmId'. Supports snake_case and camelCase field names.",
"name": "select",
"in": "query"
}
],
"responses": {
Expand Down Expand Up @@ -1531,6 +1549,12 @@
"description": "Twin public key",
"name": "public_key",
"in": "query"
},
{
"type": "string",
"description": "Select specific fields to return. Comma-separated values. E.g., 'twinId,accountId,relay'. Supports snake_case and camelCase field names.",
"name": "select",
"in": "query"
}
],
"responses": {
Expand Down Expand Up @@ -1724,6 +1748,29 @@
}
}
},
"types.CpuBenchmark": {
"type": "object",
"properties": {
"multi": {
"type": "number"
},
"node_twin_id": {
"type": "integer"
},
"single": {
"type": "number"
},
"threads": {
"type": "integer"
},
"updated_at": {
"type": "integer"
},
"workloads": {
"type": "integer"
}
}
},
"types.Dmi": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1794,14 +1841,14 @@
"country": {
"type": "string"
},
"region": {
"type": "string"
},
"latitude": {
"type": "number"
},
"longitude": {
"type": "number"
},
"region": {
"type": "string"
}
}
},
Expand All @@ -1828,6 +1875,9 @@
"country": {
"type": "string"
},
"cpu_benchmark": {
"$ref": "#/definitions/types.CpuBenchmark"
},
"created": {
"type": "integer"
},
Expand Down Expand Up @@ -2035,6 +2085,9 @@
"country": {
"type": "string"
},
"cpu_benchmark": {
"$ref": "#/definitions/types.CpuBenchmark"
},
"created": {
"type": "integer"
},
Expand Down
43 changes: 41 additions & 2 deletions grid-proxy/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ definitions:
timestamp:
type: integer
type: object
types.CpuBenchmark:
properties:
multi:
type: number
node_twin_id:
type: integer
single:
type: number
threads:
type: integer
updated_at:
type: integer
workloads:
type: integer
type: object
types.Dmi:
properties:
baseboard:
Expand Down Expand Up @@ -121,12 +136,12 @@ definitions:
type: string
country:
type: string
region:
type: string
latitude:
type: number
longitude:
type: number
region:
type: string
type: object
types.Memory:
properties:
Expand All @@ -143,6 +158,8 @@ definitions:
type: string
country:
type: string
cpu_benchmark:
$ref: '#/definitions/types.CpuBenchmark'
created:
type: integer
dedicated:
Expand Down Expand Up @@ -279,6 +296,8 @@ definitions:
type: string
country:
type: string
cpu_benchmark:
$ref: '#/definitions/types.CpuBenchmark'
created:
type: integer
dedicated:
Expand Down Expand Up @@ -550,6 +569,11 @@ paths:
in: query
name: number_of_public_ips
type: integer
- description: Select specific fields to return. Comma-separated values. E.g.,
'contractId,twinId,state'. Supports snake_case and camelCase field names.
in: query
name: select
type: string
produces:
- application/json
responses:
Expand Down Expand Up @@ -1026,6 +1050,11 @@ paths:
in: query
name: randomize
type: boolean
- description: Select specific fields to return. Comma-separated values. E.g.,
'id,farmId,country'. Supports snake_case and camelCase field names.
in: query
name: select
type: string
- description: Sort by specific node field
enum:
- status
Expand Down Expand Up @@ -1404,6 +1433,11 @@ paths:
in: query
name: free
type: boolean
- description: Select specific fields to return. Comma-separated values. E.g.,
'id,ip,farmId'. Supports snake_case and camelCase field names.
in: query
name: select
type: string
produces:
- application/json
responses:
Expand Down Expand Up @@ -1509,6 +1543,11 @@ paths:
in: query
name: public_key
type: string
- description: Select specific fields to return. Comma-separated values. E.g.,
'twinId,accountId,relay'. Supports snake_case and camelCase field names.
in: query
name: select
type: string
produces:
- application/json
responses:
Expand Down
12 changes: 11 additions & 1 deletion grid-proxy/internal/explorer/param_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,19 @@ func parseQueryParams(r *http.Request, types_ ...interface{}) error {
}

for _, type_ := range types_ {
if types.IsSelectType(type_) {
if err := types.ParseSelectFields(params, type_); err != nil {
return fmt.Errorf("failed to parse select fields: %w", err)
}
continue
}
// separate the values of filter/limit into two maps so it is clear what we decode in this iteration
// not doing this will make the decoding always fails cause r.URL.Query slice will not fit in only filter or limit
// but it has values for both
// but it has values for both (select is handled separately with custom parsing)
for key, val := range params {
if key == "select" {
continue
}
if _, ok := limitKeys[key]; ok {
limitParams[key] = val
} else {
Expand All @@ -48,6 +57,7 @@ func parseQueryParams(r *http.Request, types_ ...interface{}) error {
// deciding which param values will be decoded in the iteration
// default it will be the filter map (for nodes/farms/etc..)
// but if the interface is inferable to `Limit` type then it is limit
// or if it's a select type then use custom select parsing
param := filterParams
if _, ok := type_.(*types.Limit); ok {
param = limitParams
Expand Down
Loading