Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 350d921

Browse files
committedMar 29, 2019
Add docs for indexes.list
1 parent 5999fe2 commit 350d921

File tree

16 files changed

+315
-10
lines changed

16 files changed

+315
-10
lines changed
 

‎design/docs.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package design
2+
3+
import . "goa.design/goa/dsl"
4+
5+
var _ = Service("docs", func() {
6+
HTTP(func() {
7+
Path("/docs")
8+
})
9+
Files("/pkgs", "docs/pkgs.html")
10+
})

‎docs/pkgs.html

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<title>Interactive docs for pkgs api</title>
6+
</head>
7+
8+
<body>
9+
<p>pkgs api manage the indexes and tools installed on the system.</p>
10+
11+
<p>An index file contains the info about a core and its tools. You can see an example at <a href="" target="_blank">https://downloads.arduino.cc/packages/package_index.json</a></p>
12+
13+
<p>index files are saved (with an urlencoded filename) in the folder ~/.arduino-create/indexes</p>
14+
15+
<textarea cols="100" id="indexesGet">
16+
fetch('http://localhost:8991/v2/pkgs/indexes')
17+
</textarea><br>
18+
<textarea cols="100" rows="10" id="indexesGetRes">
19+
20+
</textarea><br>
21+
<button onclick="tryCode('indexesGet', 'indexesGetRes');">Try</button>
22+
</body>
23+
24+
<script>
25+
function tryCode(code, target) {
26+
code = document.getElementById(code).textContent;
27+
target = document.getElementById(target);
28+
29+
var result = eval(code);
30+
result.then(function (res) {
31+
target.innerHTML = res.statusText + "\n";
32+
return res.json();
33+
}).then(function (body) {
34+
debugger
35+
target.innerHTML = target.innerHTML + JSON.stringify(body, " ", " ");
36+
return;
37+
})
38+
.catch(function (err) {
39+
40+
console.log(err)
41+
42+
target.innerText = JSON.stringify(err);
43+
})
44+
45+
console.debug(code, target, result)
46+
}
47+
</script>
48+
49+
</html>

‎gen/docs/client.go

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎gen/docs/endpoints.go

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎gen/docs/service.go

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎gen/http/docs/client/client.go

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎gen/http/docs/client/encode_decode.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎gen/http/docs/client/paths.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎gen/http/docs/client/types.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎gen/http/docs/server/encode_decode.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎gen/http/docs/server/paths.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎gen/http/docs/server/server.go

Lines changed: 73 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎gen/http/docs/server/types.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎gen/http/openapi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"swagger":"2.0","info":{"title":"Arduino Create Agent","description":"A companion of Arduino Create. \n\tAllows the website to perform operations on the user computer, \n\tsuch as detecting which boards are connected and upload sketches on them.","version":""},"host":"localhost:80","basePath":"/v2","consumes":["application/json","application/xml","application/gob"],"produces":["application/json","application/xml","application/gob"],"paths":{"/pkgs/indexes":{"get":{"tags":["indexes"],"summary":"list indexes","operationId":"indexes#list","responses":{"200":{"description":"OK response.","schema":{"type":"array","items":{"type":"string","example":"Qui magnam saepe quisquam."}}},"400":{"description":"Bad Request response.","schema":{"$ref":"#/definitions/Indexeslist_invalid_url_response_body"}}},"schemes":["http"]}},"/pkgs/indexes/{url}":{"put":{"tags":["indexes"],"summary":"add indexes","operationId":"indexes#add","parameters":[{"name":"url","in":"path","description":"The url of the index file","required":true,"type":"string"}],"responses":{"200":{"description":"OK response."},"400":{"description":"Bad Request response.","schema":{"$ref":"#/definitions/Indexesadd_invalid_url_response_body"}}},"schemes":["http"]},"delete":{"tags":["indexes"],"summary":"remove indexes","operationId":"indexes#remove","parameters":[{"name":"url","in":"path","description":"The url of the index file","required":true,"type":"string"}],"responses":{"200":{"description":"OK response."},"400":{"description":"Bad Request response.","schema":{"$ref":"#/definitions/Indexesremove_invalid_url_response_body"}}},"schemes":["http"]}},"/pkgs/tools/available":{"get":{"tags":["tools"],"summary":"available tools","operationId":"tools#available","responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/ToolsToolResponseCollection"}}},"schemes":["http"]}},"/pkgs/tools/installed":{"get":{"tags":["tools"],"summary":"installed tools","operationId":"tools#installed","responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/ToolsToolResponseCollection"}}},"schemes":["http"]},"put":{"tags":["tools"],"summary":"install tools","operationId":"tools#install","parameters":[{"name":"InstallRequestBody","in":"body","required":true,"schema":{"$ref":"#/definitions/ToolsInstallRequestBody","required":["name","version","packager"]}}],"responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/pkgs/tools/installed/{packager}/{name}/{version}":{"delete":{"tags":["tools"],"summary":"remove tools","operationId":"tools#remove","parameters":[{"name":"packager","in":"path","description":"The packager of the tool","required":true,"type":"string"},{"name":"name","in":"path","description":"The name of the tool","required":true,"type":"string"},{"name":"version","in":"path","description":"The version of the tool","required":true,"type":"string"}],"responses":{"200":{"description":"OK response."}},"schemes":["http"]}}},"definitions":{"Indexesadd_invalid_url_response_body":{"title":"Mediatype identifier: application/vnd.goa.error; view=default","type":"object","properties":{"fault":{"type":"boolean","description":"Is the error a server-side fault?","example":false},"id":{"type":"string","description":"ID is a unique identifier for this particular occurrence of the problem.","example":"123abc"},"message":{"type":"string","description":"Message is a human-readable explanation specific to this occurrence of the problem.","example":"parameter 'p' must be an integer"},"name":{"type":"string","description":"Name is the name of this class of errors.","example":"bad_request"},"temporary":{"type":"boolean","description":"Is the error temporary?","example":true},"timeout":{"type":"boolean","description":"Is the error a timeout?","example":false}},"description":"url invalid (default view)","example":{"fault":true,"id":"123abc","message":"parameter 'p' must be an integer","name":"bad_request","temporary":false,"timeout":false},"required":["name","id","message","temporary","timeout","fault"]},"Indexeslist_invalid_url_response_body":{"title":"Mediatype identifier: application/vnd.goa.error; view=default","type":"object","properties":{"fault":{"type":"boolean","description":"Is the error a server-side fault?","example":false},"id":{"type":"string","description":"ID is a unique identifier for this particular occurrence of the problem.","example":"123abc"},"message":{"type":"string","description":"Message is a human-readable explanation specific to this occurrence of the problem.","example":"parameter 'p' must be an integer"},"name":{"type":"string","description":"Name is the name of this class of errors.","example":"bad_request"},"temporary":{"type":"boolean","description":"Is the error temporary?","example":false},"timeout":{"type":"boolean","description":"Is the error a timeout?","example":true}},"description":"url invalid (default view)","example":{"fault":true,"id":"123abc","message":"parameter 'p' must be an integer","name":"bad_request","temporary":true,"timeout":true},"required":["name","id","message","temporary","timeout","fault"]},"Indexesremove_invalid_url_response_body":{"title":"Mediatype identifier: application/vnd.goa.error; view=default","type":"object","properties":{"fault":{"type":"boolean","description":"Is the error a server-side fault?","example":true},"id":{"type":"string","description":"ID is a unique identifier for this particular occurrence of the problem.","example":"123abc"},"message":{"type":"string","description":"Message is a human-readable explanation specific to this occurrence of the problem.","example":"parameter 'p' must be an integer"},"name":{"type":"string","description":"Name is the name of this class of errors.","example":"bad_request"},"temporary":{"type":"boolean","description":"Is the error temporary?","example":true},"timeout":{"type":"boolean","description":"Is the error a timeout?","example":true}},"description":"url invalid (default view)","example":{"fault":true,"id":"123abc","message":"parameter 'p' must be an integer","name":"bad_request","temporary":false,"timeout":false},"required":["name","id","message","temporary","timeout","fault"]},"ToolResponse":{"title":"Mediatype identifier: application/vnd.arduino.tool; view=default","type":"object","properties":{"name":{"type":"string","description":"The name of the tool","example":"avrdude"},"packager":{"type":"string","description":"The packager of the tool","example":"arduino"},"version":{"type":"string","description":"The version of the tool","example":"6.3.0-arduino9"}},"description":"A tool is an executable program that can upload sketches. (default view)","example":{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"},"required":["name","version","packager"]},"ToolsInstallRequestBody":{"title":"ToolsInstallRequestBody","type":"object","properties":{"name":{"type":"string","description":"The name of the tool","example":"avrdude"},"packager":{"type":"string","description":"The packager of the tool","example":"arduino"},"version":{"type":"string","description":"The version of the tool","example":"6.3.0-arduino9"}},"example":{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"},"required":["name","version","packager"]},"ToolsToolResponseCollection":{"title":"Mediatype identifier: application/vnd.arduino.tool; type=collection; view=default","type":"array","items":{"$ref":"#/definitions/ToolResponse"},"description":"AvailableResponseBody is the result type for an array of ToolResponse (default view)","example":[{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"},{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"}]}}}
1+
{"swagger":"2.0","info":{"title":"Arduino Create Agent","description":"A companion of Arduino Create. \n\tAllows the website to perform operations on the user computer, \n\tsuch as detecting which boards are connected and upload sketches on them.","version":""},"host":"localhost:80","consumes":["application/json","application/xml","application/gob"],"produces":["application/json","application/xml","application/gob"],"paths":{"/v2/docs/pkgs":{"get":{"summary":"Download docs/pkgs.html","operationId":"docs#/v2/docs/pkgs","responses":{"200":{"description":"File downloaded","schema":{"type":"file"}}},"schemes":["http"]}},"/v2/pkgs/indexes":{"get":{"tags":["indexes"],"summary":"list indexes","operationId":"indexes#list","responses":{"200":{"description":"OK response.","schema":{"type":"array","items":{"type":"string","example":"Qui magnam saepe quisquam."}}},"400":{"description":"Bad Request response.","schema":{"$ref":"#/definitions/Indexeslist_invalid_url_response_body"}}},"schemes":["http"]}},"/v2/pkgs/indexes/{url}":{"put":{"tags":["indexes"],"summary":"add indexes","operationId":"indexes#add","parameters":[{"name":"url","in":"path","description":"The url of the index file","required":true,"type":"string"}],"responses":{"200":{"description":"OK response."},"400":{"description":"Bad Request response.","schema":{"$ref":"#/definitions/Indexesadd_invalid_url_response_body"}}},"schemes":["http"]},"delete":{"tags":["indexes"],"summary":"remove indexes","operationId":"indexes#remove","parameters":[{"name":"url","in":"path","description":"The url of the index file","required":true,"type":"string"}],"responses":{"200":{"description":"OK response."},"400":{"description":"Bad Request response.","schema":{"$ref":"#/definitions/Indexesremove_invalid_url_response_body"}}},"schemes":["http"]}},"/v2/pkgs/tools/available":{"get":{"tags":["tools"],"summary":"available tools","operationId":"tools#available","responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/ToolsToolResponseCollection"}}},"schemes":["http"]}},"/v2/pkgs/tools/installed":{"get":{"tags":["tools"],"summary":"installed tools","operationId":"tools#installed","responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/ToolsToolResponseCollection"}}},"schemes":["http"]},"put":{"tags":["tools"],"summary":"install tools","operationId":"tools#install","parameters":[{"name":"InstallRequestBody","in":"body","required":true,"schema":{"$ref":"#/definitions/ToolsInstallRequestBody","required":["name","version","packager"]}}],"responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/v2/pkgs/tools/installed/{packager}/{name}/{version}":{"delete":{"tags":["tools"],"summary":"remove tools","operationId":"tools#remove","parameters":[{"name":"packager","in":"path","description":"The packager of the tool","required":true,"type":"string"},{"name":"name","in":"path","description":"The name of the tool","required":true,"type":"string"},{"name":"version","in":"path","description":"The version of the tool","required":true,"type":"string"}],"responses":{"200":{"description":"OK response."}},"schemes":["http"]}}},"definitions":{"Indexesadd_invalid_url_response_body":{"title":"Mediatype identifier: application/vnd.goa.error; view=default","type":"object","properties":{"fault":{"type":"boolean","description":"Is the error a server-side fault?","example":false},"id":{"type":"string","description":"ID is a unique identifier for this particular occurrence of the problem.","example":"123abc"},"message":{"type":"string","description":"Message is a human-readable explanation specific to this occurrence of the problem.","example":"parameter 'p' must be an integer"},"name":{"type":"string","description":"Name is the name of this class of errors.","example":"bad_request"},"temporary":{"type":"boolean","description":"Is the error temporary?","example":true},"timeout":{"type":"boolean","description":"Is the error a timeout?","example":false}},"description":"url invalid (default view)","example":{"fault":true,"id":"123abc","message":"parameter 'p' must be an integer","name":"bad_request","temporary":false,"timeout":false},"required":["name","id","message","temporary","timeout","fault"]},"Indexeslist_invalid_url_response_body":{"title":"Mediatype identifier: application/vnd.goa.error; view=default","type":"object","properties":{"fault":{"type":"boolean","description":"Is the error a server-side fault?","example":false},"id":{"type":"string","description":"ID is a unique identifier for this particular occurrence of the problem.","example":"123abc"},"message":{"type":"string","description":"Message is a human-readable explanation specific to this occurrence of the problem.","example":"parameter 'p' must be an integer"},"name":{"type":"string","description":"Name is the name of this class of errors.","example":"bad_request"},"temporary":{"type":"boolean","description":"Is the error temporary?","example":false},"timeout":{"type":"boolean","description":"Is the error a timeout?","example":true}},"description":"url invalid (default view)","example":{"fault":true,"id":"123abc","message":"parameter 'p' must be an integer","name":"bad_request","temporary":true,"timeout":true},"required":["name","id","message","temporary","timeout","fault"]},"Indexesremove_invalid_url_response_body":{"title":"Mediatype identifier: application/vnd.goa.error; view=default","type":"object","properties":{"fault":{"type":"boolean","description":"Is the error a server-side fault?","example":true},"id":{"type":"string","description":"ID is a unique identifier for this particular occurrence of the problem.","example":"123abc"},"message":{"type":"string","description":"Message is a human-readable explanation specific to this occurrence of the problem.","example":"parameter 'p' must be an integer"},"name":{"type":"string","description":"Name is the name of this class of errors.","example":"bad_request"},"temporary":{"type":"boolean","description":"Is the error temporary?","example":true},"timeout":{"type":"boolean","description":"Is the error a timeout?","example":true}},"description":"url invalid (default view)","example":{"fault":true,"id":"123abc","message":"parameter 'p' must be an integer","name":"bad_request","temporary":false,"timeout":false},"required":["name","id","message","temporary","timeout","fault"]},"ToolResponse":{"title":"Mediatype identifier: application/vnd.arduino.tool; view=default","type":"object","properties":{"name":{"type":"string","description":"The name of the tool","example":"avrdude"},"packager":{"type":"string","description":"The packager of the tool","example":"arduino"},"version":{"type":"string","description":"The version of the tool","example":"6.3.0-arduino9"}},"description":"A tool is an executable program that can upload sketches. (default view)","example":{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"},"required":["name","version","packager"]},"ToolsInstallRequestBody":{"title":"ToolsInstallRequestBody","type":"object","properties":{"name":{"type":"string","description":"The name of the tool","example":"avrdude"},"packager":{"type":"string","description":"The packager of the tool","example":"arduino"},"version":{"type":"string","description":"The version of the tool","example":"6.3.0-arduino9"}},"example":{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"},"required":["name","version","packager"]},"ToolsToolResponseCollection":{"title":"Mediatype identifier: application/vnd.arduino.tool; type=collection; view=default","type":"array","items":{"$ref":"#/definitions/ToolResponse"},"description":"AvailableResponseBody is the result type for an array of ToolResponse (default view)","example":[{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"},{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"}]}}}

‎gen/http/openapi.yaml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ info:
66
sketches on them."
77
version: ""
88
host: localhost:80
9-
basePath: /v2
109
consumes:
1110
- application/json
1211
- application/xml
@@ -16,7 +15,18 @@ produces:
1615
- application/xml
1716
- application/gob
1817
paths:
19-
/pkgs/indexes:
18+
/v2/docs/pkgs:
19+
get:
20+
summary: Download docs/pkgs.html
21+
operationId: docs#/v2/docs/pkgs
22+
responses:
23+
"200":
24+
description: File downloaded
25+
schema:
26+
type: file
27+
schemes:
28+
- http
29+
/v2/pkgs/indexes:
2030
get:
2131
tags:
2232
- indexes
@@ -36,7 +46,7 @@ paths:
3646
$ref: '#/definitions/Indexeslist_invalid_url_response_body'
3747
schemes:
3848
- http
39-
/pkgs/indexes/{url}:
49+
/v2/pkgs/indexes/{url}:
4050
put:
4151
tags:
4252
- indexes
@@ -77,7 +87,7 @@ paths:
7787
$ref: '#/definitions/Indexesremove_invalid_url_response_body'
7888
schemes:
7989
- http
80-
/pkgs/tools/available:
90+
/v2/pkgs/tools/available:
8191
get:
8292
tags:
8393
- tools
@@ -90,7 +100,7 @@ paths:
90100
$ref: '#/definitions/ToolsToolResponseCollection'
91101
schemes:
92102
- http
93-
/pkgs/tools/installed:
103+
/v2/pkgs/tools/installed:
94104
get:
95105
tags:
96106
- tools
@@ -123,7 +133,7 @@ paths:
123133
description: OK response.
124134
schemes:
125135
- http
126-
/pkgs/tools/installed/{packager}/{name}/{version}:
136+
/v2/pkgs/tools/installed/{packager}/{name}/{version}:
127137
delete:
128138
tags:
129139
- tools

‎v2/http.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"net/http"
66

7+
docssvr "github.com/arduino/arduino-create-agent/gen/http/docs/server"
78
indexessvr "github.com/arduino/arduino-create-agent/gen/http/indexes/server"
89
toolssvr "github.com/arduino/arduino-create-agent/gen/http/tools/server"
910
indexessvc "github.com/arduino/arduino-create-agent/gen/indexes"
@@ -31,13 +32,15 @@ func Server() http.Handler {
3132
indexessvr.Mount(mux, indexesServer)
3233

3334
// Mount tools
34-
toolsSvc := pkgs.Tools{
35-
Log: logger,
36-
}
35+
toolsSvc := pkgs.Tools{}
3736
toolsEndpoints := toolssvc.NewEndpoints(&toolsSvc)
3837
toolsServer := toolssvr.New(toolsEndpoints, mux, goahttp.RequestDecoder, goahttp.ResponseEncoder, errorHandler(logger))
3938
toolssvr.Mount(mux, toolsServer)
4039

40+
// Mount docs
41+
docssvr.New(nil, mux, goahttp.RequestDecoder, goahttp.ResponseEncoder, errorHandler(logger))
42+
docssvr.Mount(mux)
43+
4144
// Mount middlewares
4245
handler := middleware.Log(logAdapter)(mux)
4346
handler = middleware.RequestID()(handler)

0 commit comments

Comments
 (0)
Please sign in to comment.