diff --git a/design/pkgs.go b/design/pkgs.go index f47ca0fe0..50d839fdc 100644 --- a/design/pkgs.go +++ b/design/pkgs.go @@ -105,8 +105,7 @@ var IndexPayload = Type("arduino.index", func() { }) var ToolPayload = Type("arduino.tool", func() { - Description(`A tool is an executable program that can upload sketches. - If url is absent the tool will be searched among the package index installed`) + Description("A tool is an executable program that can upload sketches.") TypeName("ToolPayload") Attribute("name", String, "The name of the tool", func() { @@ -118,13 +117,6 @@ var ToolPayload = Type("arduino.tool", func() { Attribute("packager", String, "The packager of the tool", func() { Example("arduino") }) - - Attribute("url", String, `The url where the package can be found. Optional. - If present checksum must also be present.`) - - Attribute("checksum", String, `A checksum of the archive. Mandatory when url is present. - This ensures that the package is downloaded correcly.`) - Required("name", "version", "packager") }) diff --git a/gen/http/cli/arduino_create_agent/cli.go b/gen/http/cli/arduino_create_agent/cli.go index 75ec883ef..179b1d82f 100644 --- a/gen/http/cli/arduino_create_agent/cli.go +++ b/gen/http/cli/arduino_create_agent/cli.go @@ -65,7 +65,6 @@ func ParseEndpoint( toolsInstallBodyFlag = toolsInstallFlags.String("body", "REQUIRED", "") toolsRemoveFlags = flag.NewFlagSet("remove", flag.ExitOnError) - toolsRemoveBodyFlag = toolsRemoveFlags.String("body", "REQUIRED", "") toolsRemovePackagerFlag = toolsRemoveFlags.String("packager", "REQUIRED", "The packager of the tool") toolsRemoveNameFlag = toolsRemoveFlags.String("name", "REQUIRED", "The name of the tool") toolsRemoveVersionFlag = toolsRemoveFlags.String("version", "REQUIRED", "The version of the tool") @@ -191,7 +190,7 @@ func ParseEndpoint( data, err = toolsc.BuildInstallPayload(*toolsInstallBodyFlag) case "remove": endpoint = c.Remove() - data, err = toolsc.BuildRemovePayload(*toolsRemoveBodyFlag, *toolsRemovePackagerFlag, *toolsRemoveNameFlag, *toolsRemoveVersionFlag) + data, err = toolsc.BuildRemovePayload(*toolsRemovePackagerFlag, *toolsRemoveNameFlag, *toolsRemoveVersionFlag) } } } @@ -297,28 +296,22 @@ Install implements install. Example: %[1]s tools install --body '{ - "checksum": "Beatae dolor adipisci nulla et quam voluptas.", "name": "avrdude", "packager": "arduino", - "url": "Deserunt voluptatem impedit iusto libero.", "version": "6.3.0-arduino9" }' `, os.Args[0]) } func toolsRemoveUsage() { - fmt.Fprintf(os.Stderr, `%[1]s [flags] tools remove -body JSON -packager STRING -name STRING -version STRING + fmt.Fprintf(os.Stderr, `%[1]s [flags] tools remove -packager STRING -name STRING -version STRING Remove implements remove. - -body JSON: -packager STRING: The packager of the tool -name STRING: The name of the tool -version STRING: The version of the tool Example: - %[1]s tools remove --body '{ - "checksum": "Ipsa minima quia.", - "url": "Expedita rem ipsum quasi harum nostrum." - }' --packager "arduino" --name "avrdude" --version "6.3.0-arduino9" + %[1]s tools remove --packager "arduino" --name "avrdude" --version "6.3.0-arduino9" `, os.Args[0]) } diff --git a/gen/http/openapi.json b/gen/http/openapi.json index e6a796113..e1d9d75b6 100644 --- a/gen/http/openapi.json +++ b/gen/http/openapi.json @@ -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","plain/text"],"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":"Repudiandae dignissimos consectetur eos molestiae culpa soluta."}}},"400":{"description":"Bad Request response.","schema":{"$ref":"#/definitions/IndexesListInvalidURLResponseBody"}}},"schemes":["http"]}},"/pkgs/indexes/add":{"post":{"tags":["indexes"],"summary":"add indexes","operationId":"indexes#add","parameters":[{"name":"AddRequestBody","in":"body","required":true,"schema":{"$ref":"#/definitions/IndexesAddRequestBody","required":["url"]}}],"responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/IndexesAddResponseBody"}},"400":{"description":"Bad Request response.","schema":{"$ref":"#/definitions/IndexesAddInvalidURLResponseBody"}}},"schemes":["http"]}},"/pkgs/indexes/delete":{"post":{"tags":["indexes"],"summary":"remove indexes","operationId":"indexes#remove","parameters":[{"name":"RemoveRequestBody","in":"body","required":true,"schema":{"$ref":"#/definitions/IndexesRemoveRequestBody","required":["url"]}}],"responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/IndexesRemoveResponseBody"}},"400":{"description":"Bad Request response.","schema":{"$ref":"#/definitions/IndexesRemoveInvalidURLResponseBody"}}},"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"]},"post":{"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.","schema":{"$ref":"#/definitions/ToolsInstallResponseBody"}}},"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"},{"name":"RemoveRequestBody","in":"body","required":true,"schema":{"$ref":"#/definitions/ToolsRemoveRequestBody"}}],"responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/ToolsRemoveResponseBody"}}},"schemes":["http"]}}},"definitions":{"IndexesAddInvalidURLResponseBody":{"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":false}},"description":"url invalid (default view)","example":{"fault":false,"id":"123abc","message":"parameter 'p' must be an integer","name":"bad_request","temporary":false,"timeout":false},"required":["name","id","message","temporary","timeout","fault"]},"IndexesAddRequestBody":{"title":"IndexesAddRequestBody","type":"object","properties":{"url":{"type":"string","description":"The url of the index file","example":"https://downloads.arduino.cc/packages/package_index.json"}},"example":{"url":"https://downloads.arduino.cc/packages/package_index.json"},"required":["url"]},"IndexesAddResponseBody":{"title":"Mediatype identifier: application/vnd.arduino.operation; view=default","type":"object","properties":{"status":{"type":"string","description":"The status of the operation","example":"ok"}},"description":"AddResponseBody result type (default view)","example":{"status":"ok"},"required":["status"]},"IndexesListInvalidURLResponseBody":{"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":false},"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":true,"timeout":true},"required":["name","id","message","temporary","timeout","fault"]},"IndexesRemoveInvalidURLResponseBody":{"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":true}},"description":"url invalid (default view)","example":{"fault":false,"id":"123abc","message":"parameter 'p' must be an integer","name":"bad_request","temporary":true,"timeout":false},"required":["name","id","message","temporary","timeout","fault"]},"IndexesRemoveRequestBody":{"title":"IndexesRemoveRequestBody","type":"object","properties":{"url":{"type":"string","description":"The url of the index file","example":"https://downloads.arduino.cc/packages/package_index.json"}},"example":{"url":"https://downloads.arduino.cc/packages/package_index.json"},"required":["url"]},"IndexesRemoveResponseBody":{"title":"Mediatype identifier: application/vnd.arduino.operation; view=default","type":"object","properties":{"status":{"type":"string","description":"The status of the operation","example":"ok"}},"description":"RemoveResponseBody result type (default view)","example":{"status":"ok"},"required":["status"]},"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":{"checksum":{"type":"string","description":"A checksum of the archive. Mandatory when url is present. \n\tThis ensures that the package is downloaded correcly.","example":"Totam cum inventore exercitationem in."},"name":{"type":"string","description":"The name of the tool","example":"avrdude"},"packager":{"type":"string","description":"The packager of the tool","example":"arduino"},"url":{"type":"string","description":"The url where the package can be found. Optional. \n\tIf present checksum must also be present.","example":"Totam vero ipsum corporis nihil voluptatem id."},"version":{"type":"string","description":"The version of the tool","example":"6.3.0-arduino9"}},"example":{"checksum":"Modi dolorem reprehenderit perspiciatis illo aspernatur.","name":"avrdude","packager":"arduino","url":"Officia optio inventore atque in voluptatibus qui.","version":"6.3.0-arduino9"},"required":["name","version","packager"]},"ToolsInstallResponseBody":{"title":"Mediatype identifier: application/vnd.arduino.operation; view=default","type":"object","properties":{"status":{"type":"string","description":"The status of the operation","example":"ok"}},"description":"InstallResponseBody result type (default view)","example":{"status":"ok"},"required":["status"]},"ToolsRemoveRequestBody":{"title":"ToolsRemoveRequestBody","type":"object","properties":{"checksum":{"type":"string","description":"A checksum of the archive. Mandatory when url is present. \n\tThis ensures that the package is downloaded correcly.","example":"Et qui id et cumque illo."},"url":{"type":"string","description":"The url where the package can be found. Optional. \n\tIf present checksum must also be present.","example":"Officia maiores reiciendis est nemo."}},"example":{"checksum":"Corporis eum et numquam sapiente.","url":"Est voluptatem eos reprehenderit quo sint quod."}},"ToolsRemoveResponseBody":{"title":"Mediatype identifier: application/vnd.arduino.operation; view=default","type":"object","properties":{"status":{"type":"string","description":"The status of the operation","example":"ok"}},"description":"RemoveResponseBody result type (default view)","example":{"status":"ok"},"required":["status"]},"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"}]}}} \ No newline at end of file +{"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","plain/text"],"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":"Pariatur laudantium inventore qui."}}},"400":{"description":"Bad Request response.","schema":{"$ref":"#/definitions/IndexesListInvalidURLResponseBody"}}},"schemes":["http"]}},"/pkgs/indexes/add":{"post":{"tags":["indexes"],"summary":"add indexes","operationId":"indexes#add","parameters":[{"name":"AddRequestBody","in":"body","required":true,"schema":{"$ref":"#/definitions/IndexesAddRequestBody","required":["url"]}}],"responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/IndexesAddResponseBody"}},"400":{"description":"Bad Request response.","schema":{"$ref":"#/definitions/IndexesAddInvalidURLResponseBody"}}},"schemes":["http"]}},"/pkgs/indexes/delete":{"post":{"tags":["indexes"],"summary":"remove indexes","operationId":"indexes#remove","parameters":[{"name":"RemoveRequestBody","in":"body","required":true,"schema":{"$ref":"#/definitions/IndexesRemoveRequestBody","required":["url"]}}],"responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/IndexesRemoveResponseBody"}},"400":{"description":"Bad Request response.","schema":{"$ref":"#/definitions/IndexesRemoveInvalidURLResponseBody"}}},"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"]},"post":{"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.","schema":{"$ref":"#/definitions/ToolsInstallResponseBody"}}},"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.","schema":{"$ref":"#/definitions/ToolsRemoveResponseBody"}}},"schemes":["http"]}}},"definitions":{"IndexesAddInvalidURLResponseBody":{"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":false,"id":"123abc","message":"parameter 'p' must be an integer","name":"bad_request","temporary":true,"timeout":false},"required":["name","id","message","temporary","timeout","fault"]},"IndexesAddRequestBody":{"title":"IndexesAddRequestBody","type":"object","properties":{"url":{"type":"string","description":"The url of the index file","example":"https://downloads.arduino.cc/packages/package_index.json"}},"example":{"url":"https://downloads.arduino.cc/packages/package_index.json"},"required":["url"]},"IndexesAddResponseBody":{"title":"Mediatype identifier: application/vnd.arduino.operation; view=default","type":"object","properties":{"status":{"type":"string","description":"The status of the operation","example":"ok"}},"description":"AddResponseBody result type (default view)","example":{"status":"ok"},"required":["status"]},"IndexesListInvalidURLResponseBody":{"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":false,"id":"123abc","message":"parameter 'p' must be an integer","name":"bad_request","temporary":false,"timeout":true},"required":["name","id","message","temporary","timeout","fault"]},"IndexesRemoveInvalidURLResponseBody":{"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":false},"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":true,"timeout":true},"required":["name","id","message","temporary","timeout","fault"]},"IndexesRemoveRequestBody":{"title":"IndexesRemoveRequestBody","type":"object","properties":{"url":{"type":"string","description":"The url of the index file","example":"https://downloads.arduino.cc/packages/package_index.json"}},"example":{"url":"https://downloads.arduino.cc/packages/package_index.json"},"required":["url"]},"IndexesRemoveResponseBody":{"title":"Mediatype identifier: application/vnd.arduino.operation; view=default","type":"object","properties":{"status":{"type":"string","description":"The status of the operation","example":"ok"}},"description":"RemoveResponseBody result type (default view)","example":{"status":"ok"},"required":["status"]},"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"]},"ToolsInstallResponseBody":{"title":"Mediatype identifier: application/vnd.arduino.operation; view=default","type":"object","properties":{"status":{"type":"string","description":"The status of the operation","example":"ok"}},"description":"InstallResponseBody result type (default view)","example":{"status":"ok"},"required":["status"]},"ToolsRemoveResponseBody":{"title":"Mediatype identifier: application/vnd.arduino.operation; view=default","type":"object","properties":{"status":{"type":"string","description":"The status of the operation","example":"ok"}},"description":"RemoveResponseBody result type (default view)","example":{"status":"ok"},"required":["status"]},"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"},{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"},{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"}]}}} \ No newline at end of file diff --git a/gen/http/openapi.yaml b/gen/http/openapi.yaml index 4079b44c9..28b21c706 100644 --- a/gen/http/openapi.yaml +++ b/gen/http/openapi.yaml @@ -26,7 +26,7 @@ paths: type: array items: type: string - example: Repudiandae dignissimos consectetur eos molestiae culpa soluta. + example: Pariatur laudantium inventore qui. "400": description: Bad Request response. schema: @@ -153,11 +153,6 @@ paths: description: The version of the tool required: true type: string - - name: RemoveRequestBody - in: body - required: true - schema: - $ref: '#/definitions/ToolsRemoveRequestBody' responses: "200": description: OK response. @@ -193,14 +188,14 @@ definitions: timeout: type: boolean description: Is the error a timeout? - example: false + example: true description: url invalid (default view) example: fault: false id: 123abc message: parameter 'p' must be an integer name: bad_request - temporary: false + temporary: true timeout: false required: - name @@ -241,7 +236,7 @@ definitions: fault: type: boolean description: Is the error a server-side fault? - example: true + example: false id: type: string description: ID is a unique identifier for this particular occurrence of the problem. @@ -261,14 +256,14 @@ definitions: timeout: type: boolean description: Is the error a timeout? - example: false + example: true description: url invalid (default view) example: - fault: true + fault: false id: 123abc message: parameter 'p' must be an integer name: bad_request - temporary: true + temporary: false timeout: true required: - name @@ -284,7 +279,7 @@ definitions: fault: type: boolean description: Is the error a server-side fault? - example: false + example: true id: type: string description: ID is a unique identifier for this particular occurrence of the problem. @@ -300,19 +295,19 @@ definitions: temporary: type: boolean description: Is the error temporary? - example: true + example: false timeout: type: boolean description: Is the error a timeout? - example: true + example: false description: url invalid (default view) example: - fault: false + fault: true id: 123abc message: parameter 'p' must be an integer name: bad_request temporary: true - timeout: false + timeout: true required: - name - id @@ -374,10 +369,6 @@ definitions: title: ToolsInstallRequestBody type: object properties: - checksum: - type: string - description: "A checksum of the archive. Mandatory when url is present. \n\tThis ensures that the package is downloaded correcly." - example: Totam cum inventore exercitationem in. name: type: string description: The name of the tool @@ -386,19 +377,13 @@ definitions: type: string description: The packager of the tool example: arduino - url: - type: string - description: "The url where the package can be found. Optional. \n\tIf present checksum must also be present." - example: Totam vero ipsum corporis nihil voluptatem id. version: type: string description: The version of the tool example: 6.3.0-arduino9 example: - checksum: Modi dolorem reprehenderit perspiciatis illo aspernatur. name: avrdude packager: arduino - url: Officia optio inventore atque in voluptatibus qui. version: 6.3.0-arduino9 required: - name @@ -417,21 +402,6 @@ definitions: status: ok required: - status - ToolsRemoveRequestBody: - title: ToolsRemoveRequestBody - type: object - properties: - checksum: - type: string - description: "A checksum of the archive. Mandatory when url is present. \n\tThis ensures that the package is downloaded correcly." - example: Et qui id et cumque illo. - url: - type: string - description: "The url where the package can be found. Optional. \n\tIf present checksum must also be present." - example: Officia maiores reiciendis est nemo. - example: - checksum: Corporis eum et numquam sapiente. - url: Est voluptatem eos reprehenderit quo sint quod. ToolsRemoveResponseBody: title: 'Mediatype identifier: application/vnd.arduino.operation; view=default' type: object @@ -458,3 +428,9 @@ definitions: - name: avrdude packager: arduino version: 6.3.0-arduino9 + - name: avrdude + packager: arduino + version: 6.3.0-arduino9 + - name: avrdude + packager: arduino + version: 6.3.0-arduino9 diff --git a/gen/http/openapi3.json b/gen/http/openapi3.json index 200367bbf..ec0545c9c 100644 --- a/gen/http/openapi3.json +++ b/gen/http/openapi3.json @@ -1 +1 @@ -{"openapi":"3.0.3","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":"1.0"},"servers":[{"url":"http://localhost:80","description":"Default server for arduino-create-agent"}],"paths":{"/v2/pkgs/indexes":{"get":{"tags":["indexes"],"summary":"list indexes","operationId":"indexes#list","responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"array","items":{"type":"string","example":"Eveniet iure nihil optio qui."},"example":["Et perferendis eveniet voluptas.","Ut aut illum eaque dolor magni.","Amet illo veritatis laudantium optio."]},"example":["Illo enim vero qui rerum ut inventore.","Dolorem nihil autem minima alias."]}}},"400":{"description":"invalid_url: url invalid","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v2/pkgs/indexes/add":{"post":{"tags":["indexes"],"summary":"add indexes","operationId":"indexes#add","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddRequestBody"},"example":{"url":"https://downloads.arduino.cc/packages/package_index.json"}}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Operation"},"example":{"status":"ok"}}}},"400":{"description":"invalid_url: url invalid","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v2/pkgs/indexes/delete":{"post":{"tags":["indexes"],"summary":"remove indexes","operationId":"indexes#remove","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddRequestBody"},"example":{"url":"https://downloads.arduino.cc/packages/package_index.json"}}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Operation"},"example":{"status":"ok"}}}},"400":{"description":"invalid_url: url invalid","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v2/pkgs/tools/available":{"get":{"tags":["tools"],"summary":"available tools","operationId":"tools#available","responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolCollection"},"example":[{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"},{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"},{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"}]}}}}}},"/v2/pkgs/tools/installed":{"get":{"tags":["tools"],"summary":"installed tools","operationId":"tools#installed","responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolCollection"},"example":[{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"},{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"},{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"}]}}}}},"post":{"tags":["tools"],"summary":"install tools","operationId":"tools#install","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InstallRequestBody"},"example":{"checksum":"Beatae dolor adipisci nulla et quam voluptas.","name":"avrdude","packager":"arduino","url":"Deserunt voluptatem impedit iusto libero.","version":"6.3.0-arduino9"}}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Operation"},"example":{"status":"ok"}}}}}}},"/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,"schema":{"type":"string","description":"The packager of the tool","example":"arduino"},"example":"arduino"},{"name":"name","in":"path","description":"The name of the tool","required":true,"schema":{"type":"string","description":"The name of the tool","example":"avrdude"},"example":"avrdude"},{"name":"version","in":"path","description":"The version of the tool","required":true,"schema":{"type":"string","description":"The version of the tool","example":"6.3.0-arduino9"},"example":"6.3.0-arduino9"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RemoveRequestBody"},"example":{"checksum":"Ipsa minima quia.","url":"Expedita rem ipsum quasi harum nostrum."}}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Operation"},"example":{"status":"ok"}}}}}}}},"components":{"schemas":{"AddRequestBody":{"type":"object","properties":{"url":{"type":"string","description":"The url of the index file","example":"https://downloads.arduino.cc/packages/package_index.json"}},"example":{"url":"https://downloads.arduino.cc/packages/package_index.json"},"required":["url"]},"ArduinoTool":{"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.","example":{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"},"required":["name","version","packager"]},"Error":{"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":false}},"description":"url invalid","example":{"fault":false,"id":"123abc","message":"parameter 'p' must be an integer","name":"bad_request","temporary":false,"timeout":true},"required":["name","id","message","temporary","timeout","fault"]},"InstallRequestBody":{"type":"object","properties":{"checksum":{"type":"string","description":"A checksum of the archive. Mandatory when url is present. \n\tThis ensures that the package is downloaded correcly.","example":"Sint odio sed consequatur numquam."},"name":{"type":"string","description":"The name of the tool","example":"avrdude"},"packager":{"type":"string","description":"The packager of the tool","example":"arduino"},"url":{"type":"string","description":"The url where the package can be found. Optional. \n\tIf present checksum must also be present.","example":"Et quo doloremque sapiente atque."},"version":{"type":"string","description":"The version of the tool","example":"6.3.0-arduino9"}},"example":{"checksum":"Mollitia commodi sunt.","name":"avrdude","packager":"arduino","url":"Quae reprehenderit provident provident debitis illo.","version":"6.3.0-arduino9"},"required":["name","version","packager"]},"Operation":{"type":"object","properties":{"status":{"type":"string","description":"The status of the operation","example":"ok"}},"example":{"status":"ok"},"required":["status"]},"RemoveRequestBody":{"type":"object","properties":{"checksum":{"type":"string","description":"A checksum of the archive. Mandatory when url is present. \n\tThis ensures that the package is downloaded correcly.","example":"Ea culpa."},"url":{"type":"string","description":"The url where the package can be found. Optional. \n\tIf present checksum must also be present.","example":"Odit officiis illo qui quia provident illo."}},"example":{"checksum":"Rerum eum esse corporis ex.","url":"Molestiae dolor quaerat enim."}},"ToolCollection":{"type":"array","items":{"$ref":"#/components/schemas/ArduinoTool"},"example":[{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"},{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"},{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"},{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"}]}}},"tags":[{"name":"indexes","description":"The indexes service manages the package_index files"},{"name":"tools","description":"The tools service manages the available and installed tools"}]} \ No newline at end of file +{"openapi":"3.0.3","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":"1.0"},"servers":[{"url":"http://localhost:80","description":"Default server for arduino-create-agent"}],"paths":{"/v2/pkgs/indexes":{"get":{"tags":["indexes"],"summary":"list indexes","operationId":"indexes#list","responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"array","items":{"type":"string","example":"Rerum et soluta laudantium."},"example":["Et deserunt.","Impedit iusto libero explicabo.","Dolor adipisci nulla.","Quam voluptas voluptates expedita rem ipsum."]},"example":["Dignissimos consectetur eos molestiae culpa soluta deserunt.","Nobis sint dolorem unde.","Quia doloremque.","Atque iusto tempore sit quod dolor repellat."]}}},"400":{"description":"invalid_url: url invalid","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v2/pkgs/indexes/add":{"post":{"tags":["indexes"],"summary":"add indexes","operationId":"indexes#add","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddRequestBody"},"example":{"url":"https://downloads.arduino.cc/packages/package_index.json"}}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Operation"},"example":{"status":"ok"}}}},"400":{"description":"invalid_url: url invalid","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v2/pkgs/indexes/delete":{"post":{"tags":["indexes"],"summary":"remove indexes","operationId":"indexes#remove","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddRequestBody"},"example":{"url":"https://downloads.arduino.cc/packages/package_index.json"}}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Operation"},"example":{"status":"ok"}}}},"400":{"description":"invalid_url: url invalid","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v2/pkgs/tools/available":{"get":{"tags":["tools"],"summary":"available tools","operationId":"tools#available","responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolCollection"},"example":[{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"},{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"},{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"}]}}}}}},"/v2/pkgs/tools/installed":{"get":{"tags":["tools"],"summary":"installed tools","operationId":"tools#installed","responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolCollection"},"example":[{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"},{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"},{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"}]}}}}},"post":{"tags":["tools"],"summary":"install tools","operationId":"tools#install","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InstallRequestBody"},"example":{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"}}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Operation"},"example":{"status":"ok"}}}}}}},"/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,"schema":{"type":"string","description":"The packager of the tool","example":"arduino"},"example":"arduino"},{"name":"name","in":"path","description":"The name of the tool","required":true,"schema":{"type":"string","description":"The name of the tool","example":"avrdude"},"example":"avrdude"},{"name":"version","in":"path","description":"The version of the tool","required":true,"schema":{"type":"string","description":"The version of the tool","example":"6.3.0-arduino9"},"example":"6.3.0-arduino9"}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Operation"},"example":{"status":"ok"}}}}}}}},"components":{"schemas":{"AddRequestBody":{"type":"object","properties":{"url":{"type":"string","description":"The url of the index file","example":"https://downloads.arduino.cc/packages/package_index.json"}},"example":{"url":"https://downloads.arduino.cc/packages/package_index.json"},"required":["url"]},"ArduinoTool":{"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.","example":{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"},"required":["name","version","packager"]},"Error":{"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","example":{"fault":false,"id":"123abc","message":"parameter 'p' must be an integer","name":"bad_request","temporary":true,"timeout":false},"required":["name","id","message","temporary","timeout","fault"]},"InstallRequestBody":{"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"]},"Operation":{"type":"object","properties":{"status":{"type":"string","description":"The status of the operation","example":"ok"}},"example":{"status":"ok"},"required":["status"]},"ToolCollection":{"type":"array","items":{"$ref":"#/components/schemas/ArduinoTool"},"example":[{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"},{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"},{"name":"avrdude","packager":"arduino","version":"6.3.0-arduino9"}]}}},"tags":[{"name":"indexes","description":"The indexes service manages the package_index files"},{"name":"tools","description":"The tools service manages the available and installed tools"}]} \ No newline at end of file diff --git a/gen/http/openapi3.yaml b/gen/http/openapi3.yaml index 84ccfb1a9..6913bd490 100644 --- a/gen/http/openapi3.yaml +++ b/gen/http/openapi3.yaml @@ -22,14 +22,17 @@ paths: type: array items: type: string - example: Eveniet iure nihil optio qui. + example: Rerum et soluta laudantium. example: - - Et perferendis eveniet voluptas. - - Ut aut illum eaque dolor magni. - - Amet illo veritatis laudantium optio. + - Et deserunt. + - Impedit iusto libero explicabo. + - Dolor adipisci nulla. + - Quam voluptas voluptates expedita rem ipsum. example: - - Illo enim vero qui rerum ut inventore. - - Dolorem nihil autem minima alias. + - Dignissimos consectetur eos molestiae culpa soluta deserunt. + - Nobis sint dolorem unde. + - Quia doloremque. + - Atque iusto tempore sit quod dolor repellat. "400": description: 'invalid_url: url invalid' content: @@ -152,10 +155,8 @@ paths: schema: $ref: '#/components/schemas/InstallRequestBody' example: - checksum: Beatae dolor adipisci nulla et quam voluptas. name: avrdude packager: arduino - url: Deserunt voluptatem impedit iusto libero. version: 6.3.0-arduino9 responses: "200": @@ -200,15 +201,6 @@ paths: description: The version of the tool example: 6.3.0-arduino9 example: 6.3.0-arduino9 - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/RemoveRequestBody' - example: - checksum: Ipsa minima quia. - url: Expedita rem ipsum quasi harum nostrum. responses: "200": description: OK response. @@ -277,7 +269,7 @@ components: temporary: type: boolean description: Is the error temporary? - example: false + example: true timeout: type: boolean description: Is the error a timeout? @@ -288,8 +280,8 @@ components: id: 123abc message: parameter 'p' must be an integer name: bad_request - temporary: false - timeout: true + temporary: true + timeout: false required: - name - id @@ -300,10 +292,6 @@ components: InstallRequestBody: type: object properties: - checksum: - type: string - description: "A checksum of the archive. Mandatory when url is present. \n\tThis ensures that the package is downloaded correcly." - example: Sint odio sed consequatur numquam. name: type: string description: The name of the tool @@ -312,19 +300,13 @@ components: type: string description: The packager of the tool example: arduino - url: - type: string - description: "The url where the package can be found. Optional. \n\tIf present checksum must also be present." - example: Et quo doloremque sapiente atque. version: type: string description: The version of the tool example: 6.3.0-arduino9 example: - checksum: Mollitia commodi sunt. name: avrdude packager: arduino - url: Quae reprehenderit provident provident debitis illo. version: 6.3.0-arduino9 required: - name @@ -341,20 +323,6 @@ components: status: ok required: - status - RemoveRequestBody: - type: object - properties: - checksum: - type: string - description: "A checksum of the archive. Mandatory when url is present. \n\tThis ensures that the package is downloaded correcly." - example: Ea culpa. - url: - type: string - description: "The url where the package can be found. Optional. \n\tIf present checksum must also be present." - example: Odit officiis illo qui quia provident illo. - example: - checksum: Rerum eum esse corporis ex. - url: Molestiae dolor quaerat enim. ToolCollection: type: array items: @@ -369,9 +337,6 @@ components: - name: avrdude packager: arduino version: 6.3.0-arduino9 - - name: avrdude - packager: arduino - version: 6.3.0-arduino9 tags: - name: indexes description: The indexes service manages the package_index files diff --git a/gen/http/tools/client/cli.go b/gen/http/tools/client/cli.go index c6b125ff9..ab5c42111 100644 --- a/gen/http/tools/client/cli.go +++ b/gen/http/tools/client/cli.go @@ -22,15 +22,13 @@ func BuildInstallPayload(toolsInstallBody string) (*tools.ToolPayload, error) { { err = json.Unmarshal([]byte(toolsInstallBody), &body) if err != nil { - return nil, fmt.Errorf("invalid JSON for body, \nerror: %s, \nexample of valid JSON:\n%s", err, "'{\n \"checksum\": \"Beatae dolor adipisci nulla et quam voluptas.\",\n \"name\": \"avrdude\",\n \"packager\": \"arduino\",\n \"url\": \"Deserunt voluptatem impedit iusto libero.\",\n \"version\": \"6.3.0-arduino9\"\n }'") + return nil, fmt.Errorf("invalid JSON for body, \nerror: %s, \nexample of valid JSON:\n%s", err, "'{\n \"name\": \"avrdude\",\n \"packager\": \"arduino\",\n \"version\": \"6.3.0-arduino9\"\n }'") } } v := &tools.ToolPayload{ Name: body.Name, Version: body.Version, Packager: body.Packager, - URL: body.URL, - Checksum: body.Checksum, } return v, nil @@ -38,15 +36,7 @@ func BuildInstallPayload(toolsInstallBody string) (*tools.ToolPayload, error) { // BuildRemovePayload builds the payload for the tools remove endpoint from CLI // flags. -func BuildRemovePayload(toolsRemoveBody string, toolsRemovePackager string, toolsRemoveName string, toolsRemoveVersion string) (*tools.ToolPayload, error) { - var err error - var body RemoveRequestBody - { - err = json.Unmarshal([]byte(toolsRemoveBody), &body) - if err != nil { - return nil, fmt.Errorf("invalid JSON for body, \nerror: %s, \nexample of valid JSON:\n%s", err, "'{\n \"checksum\": \"Ipsa minima quia.\",\n \"url\": \"Expedita rem ipsum quasi harum nostrum.\"\n }'") - } - } +func BuildRemovePayload(toolsRemovePackager string, toolsRemoveName string, toolsRemoveVersion string) (*tools.ToolPayload, error) { var packager string { packager = toolsRemovePackager @@ -59,10 +49,7 @@ func BuildRemovePayload(toolsRemoveBody string, toolsRemovePackager string, tool { version = toolsRemoveVersion } - v := &tools.ToolPayload{ - URL: body.URL, - Checksum: body.Checksum, - } + v := &tools.ToolPayload{} v.Packager = packager v.Name = name v.Version = version diff --git a/gen/http/tools/client/client.go b/gen/http/tools/client/client.go index 540a1c8a8..20d211cb5 100644 --- a/gen/http/tools/client/client.go +++ b/gen/http/tools/client/client.go @@ -130,7 +130,6 @@ func (c *Client) Install() goa.Endpoint { // remove server. func (c *Client) Remove() goa.Endpoint { var ( - encodeRequest = EncodeRemoveRequest(c.encoder) decodeResponse = DecodeRemoveResponse(c.decoder, c.RestoreResponseBody) ) return func(ctx context.Context, v any) (any, error) { @@ -138,10 +137,6 @@ func (c *Client) Remove() goa.Endpoint { if err != nil { return nil, err } - err = encodeRequest(req, v) - if err != nil { - return nil, err - } resp, err := c.RemoveDoer.Do(req) if err != nil { return nil, goahttp.ErrRequestError("tools", "remove", err) diff --git a/gen/http/tools/client/encode_decode.go b/gen/http/tools/client/encode_decode.go index 81266c7dc..48558947e 100644 --- a/gen/http/tools/client/encode_decode.go +++ b/gen/http/tools/client/encode_decode.go @@ -235,22 +235,6 @@ func (c *Client) BuildRemoveRequest(ctx context.Context, v any) (*http.Request, return req, nil } -// EncodeRemoveRequest returns an encoder for requests sent to the tools remove -// server. -func EncodeRemoveRequest(encoder func(*http.Request) goahttp.Encoder) func(*http.Request, any) error { - return func(req *http.Request, v any) error { - p, ok := v.(*tools.ToolPayload) - if !ok { - return goahttp.ErrInvalidType("tools", "remove", "*tools.ToolPayload", v) - } - body := NewRemoveRequestBody(p) - if err := encoder(req).Encode(&body); err != nil { - return goahttp.ErrEncodingError("tools", "remove", err) - } - return nil - } -} - // DecodeRemoveResponse returns a decoder for responses returned by the tools // remove endpoint. restoreBody controls whether the response body should be // restored after having been read. diff --git a/gen/http/tools/client/types.go b/gen/http/tools/client/types.go index 0b2a81488..cabeeabf8 100644 --- a/gen/http/tools/client/types.go +++ b/gen/http/tools/client/types.go @@ -22,23 +22,6 @@ type InstallRequestBody struct { Version string `form:"version" json:"version" xml:"version"` // The packager of the tool Packager string `form:"packager" json:"packager" xml:"packager"` - // The url where the package can be found. Optional. - // If present checksum must also be present. - URL *string `form:"url,omitempty" json:"url,omitempty" xml:"url,omitempty"` - // A checksum of the archive. Mandatory when url is present. - // This ensures that the package is downloaded correcly. - Checksum *string `form:"checksum,omitempty" json:"checksum,omitempty" xml:"checksum,omitempty"` -} - -// RemoveRequestBody is the type of the "tools" service "remove" endpoint HTTP -// request body. -type RemoveRequestBody struct { - // The url where the package can be found. Optional. - // If present checksum must also be present. - URL *string `form:"url,omitempty" json:"url,omitempty" xml:"url,omitempty"` - // A checksum of the archive. Mandatory when url is present. - // This ensures that the package is downloaded correcly. - Checksum *string `form:"checksum,omitempty" json:"checksum,omitempty" xml:"checksum,omitempty"` } // AvailableResponseBody is the type of the "tools" service "available" @@ -80,18 +63,6 @@ func NewInstallRequestBody(p *tools.ToolPayload) *InstallRequestBody { Name: p.Name, Version: p.Version, Packager: p.Packager, - URL: p.URL, - Checksum: p.Checksum, - } - return body -} - -// NewRemoveRequestBody builds the HTTP request body from the payload of the -// "remove" endpoint of the "tools" service. -func NewRemoveRequestBody(p *tools.ToolPayload) *RemoveRequestBody { - body := &RemoveRequestBody{ - URL: p.URL, - Checksum: p.Checksum, } return body } diff --git a/gen/http/tools/server/encode_decode.go b/gen/http/tools/server/encode_decode.go index 5b09d8e0b..12e0aec73 100644 --- a/gen/http/tools/server/encode_decode.go +++ b/gen/http/tools/server/encode_decode.go @@ -94,18 +94,6 @@ func EncodeRemoveResponse(encoder func(context.Context, http.ResponseWriter) goa // endpoint. func DecodeRemoveRequest(mux goahttp.Muxer, decoder func(*http.Request) goahttp.Decoder) func(*http.Request) (any, error) { return func(r *http.Request) (any, error) { - var ( - body RemoveRequestBody - err error - ) - err = decoder(r).Decode(&body) - if err != nil { - if err == io.EOF { - return nil, goa.MissingPayloadError() - } - return nil, goa.DecodePayloadError(err.Error()) - } - var ( packager string name string @@ -116,7 +104,7 @@ func DecodeRemoveRequest(mux goahttp.Muxer, decoder func(*http.Request) goahttp. packager = params["packager"] name = params["name"] version = params["version"] - payload := NewRemoveToolPayload(&body, packager, name, version) + payload := NewRemoveToolPayload(packager, name, version) return payload, nil } diff --git a/gen/http/tools/server/types.go b/gen/http/tools/server/types.go index 6aaeb823f..e348372ee 100644 --- a/gen/http/tools/server/types.go +++ b/gen/http/tools/server/types.go @@ -22,23 +22,6 @@ type InstallRequestBody struct { Version *string `form:"version,omitempty" json:"version,omitempty" xml:"version,omitempty"` // The packager of the tool Packager *string `form:"packager,omitempty" json:"packager,omitempty" xml:"packager,omitempty"` - // The url where the package can be found. Optional. - // If present checksum must also be present. - URL *string `form:"url,omitempty" json:"url,omitempty" xml:"url,omitempty"` - // A checksum of the archive. Mandatory when url is present. - // This ensures that the package is downloaded correcly. - Checksum *string `form:"checksum,omitempty" json:"checksum,omitempty" xml:"checksum,omitempty"` -} - -// RemoveRequestBody is the type of the "tools" service "remove" endpoint HTTP -// request body. -type RemoveRequestBody struct { - // The url where the package can be found. Optional. - // If present checksum must also be present. - URL *string `form:"url,omitempty" json:"url,omitempty" xml:"url,omitempty"` - // A checksum of the archive. Mandatory when url is present. - // This ensures that the package is downloaded correcly. - Checksum *string `form:"checksum,omitempty" json:"checksum,omitempty" xml:"checksum,omitempty"` } // ToolResponseCollection is the type of the "tools" service "available" @@ -103,19 +86,14 @@ func NewInstallToolPayload(body *InstallRequestBody) *tools.ToolPayload { Name: *body.Name, Version: *body.Version, Packager: *body.Packager, - URL: body.URL, - Checksum: body.Checksum, } return v } // NewRemoveToolPayload builds a tools service remove endpoint payload. -func NewRemoveToolPayload(body *RemoveRequestBody, packager string, name string, version string) *tools.ToolPayload { - v := &tools.ToolPayload{ - URL: body.URL, - Checksum: body.Checksum, - } +func NewRemoveToolPayload(packager string, name string, version string) *tools.ToolPayload { + v := &tools.ToolPayload{} v.Packager = packager v.Name = name v.Version = version diff --git a/gen/tools/service.go b/gen/tools/service.go index 783204c4f..7b53c4518 100644 --- a/gen/tools/service.go +++ b/gen/tools/service.go @@ -63,12 +63,6 @@ type ToolPayload struct { Version string // The packager of the tool Packager string - // The url where the package can be found. Optional. - // If present checksum must also be present. - URL *string - // A checksum of the archive. Mandatory when url is present. - // This ensures that the package is downloaded correcly. - Checksum *string } // MakeNotFound builds a goa.ServiceError from an error. diff --git a/main_test.go b/main_test.go index 238ae2a2d..ec0d00a86 100644 --- a/main_test.go +++ b/main_test.go @@ -27,7 +27,6 @@ import ( "testing" "github.com/arduino/arduino-create-agent/config" - "github.com/arduino/arduino-create-agent/gen/tools" v2 "github.com/arduino/arduino-create-agent/v2" "github.com/gin-gonic/gin" "github.com/stretchr/testify/require" @@ -54,17 +53,21 @@ func TestInstallToolDifferentContentType(t *testing.T) { r.Any("/v2/*path", gin.WrapH(goa)) ts := httptest.NewServer(r) - URL := "http://downloads.arduino.cc/tools/bossac-1.7.0-arduino3-linux64.tar.gz" - Checksum := "SHA-256:1ae54999c1f97234a5c603eb99ad39313b11746a4ca517269a9285afa05f9100" - request := tools.ToolPayload{ - Name: "bossac", - Version: "1.7.0-arduino3", - Packager: "arduino", - URL: &URL, - Checksum: &Checksum, + oldRequest := struct { + Name string + Version string + Packager string + URL string + Checksum string + }{ + "bossac", + "1.7.0-arduino3", + "arduino", + "http://downloads.arduino.cc/tools/bossac-1.7.0-arduino3-linux64.tar.gz", + "SHA-256:1ae54999c1f97234a5c603eb99ad39313b11746a4ca517269a9285afa05f9100", } - payload, err := json.Marshal(request) + payload, err := json.Marshal(oldRequest) require.NoError(t, err) // for some reason the fronted sends requests with "text/plain" content type. diff --git a/v2/pkgs/tools.go b/v2/pkgs/tools.go index 13189c9e4..50e89f577 100644 --- a/v2/pkgs/tools.go +++ b/v2/pkgs/tools.go @@ -133,12 +133,6 @@ func (c *Tools) Installed(ctx context.Context) (tools.ToolCollection, error) { // Install crawles the Index folder, downloads the specified tool, extracts the archive in the Tools Folder. // It checks for the Signature specified in the package index. func (c *Tools) Install(ctx context.Context, payload *tools.ToolPayload) (*tools.Operation, error) { - path := filepath.Join(payload.Packager, payload.Name, payload.Version) - - if payload.URL != nil { - return c.install(ctx, path, *payload.URL, *payload.Checksum) - } - list, err := c.Indexes.List(ctx) if err != nil { return nil, err @@ -159,9 +153,7 @@ func (c *Tools) Install(ctx context.Context, payload *tools.ToolPayload) (*tools if tool.Name == payload.Name && tool.Version == payload.Version { - sys := tool.GetFlavourCompatibleWith(runtime.GOOS, runtime.GOARCH) - - return c.install(ctx, path, sys.URL, sys.Checksum) + return c.install(ctx, payload.Packager, tool) } } } @@ -172,9 +164,12 @@ func (c *Tools) Install(ctx context.Context, payload *tools.ToolPayload) (*tools payload.Packager, payload.Name, payload.Version)) } -func (c *Tools) install(ctx context.Context, path, url, checksum string) (*tools.Operation, error) { +func (c *Tools) install(ctx context.Context, packager string, tool Tool) (*tools.Operation, error) { + sys := tool.GetFlavourCompatibleWith(runtime.GOOS, runtime.GOARCH) + path := filepath.Join(packager, tool.Name, tool.Version) + // Download - res, err := http.Get(url) + res, err := http.Get(sys.URL) if err != nil { return nil, err } @@ -199,7 +194,7 @@ func (c *Tools) install(ctx context.Context, path, url, checksum string) (*tools sum := sha256.Sum256(buffer.Bytes()) sumString := "SHA-256:" + hex.EncodeToString(sum[:sha256.Size]) - if sumString != checksum { + if sumString != sys.Checksum { os.RemoveAll(path) return nil, errors.New("checksum doesn't match") } diff --git a/v2/pkgs/tools_test.go b/v2/pkgs/tools_test.go index 581b30b1f..4f8802fd4 100644 --- a/v2/pkgs/tools_test.go +++ b/v2/pkgs/tools_test.go @@ -20,7 +20,6 @@ import ( "net/http" "net/http/httptest" "os" - "runtime" "strings" "testing" @@ -130,52 +129,4 @@ func TestTools(t *testing.T) { if len(installed) != 0 { t.Fatalf("expected %d == %d (%s)", len(installed), 0, "len(installed)") } - - // Install a tool by specifying url and checksum - _, err = service.Install(ctx, &tools.ToolPayload{ - Packager: "arduino", - Name: "avrdude", - Version: "6.0.1-arduino2", - URL: strpoint(url()), - Checksum: strpoint(checksum()), - }) - if err != nil { - t.Fatal(err) - } - - installed, err = service.Installed(ctx) - if err != nil { - t.Fatal(err) - } - if len(installed) != 1 { - t.Fatalf("expected %d == %d (%s)", len(installed), 1, "len(installed)") - } -} - -func strpoint(s string) *string { - return &s -} - -func url() string { - urls := map[string]string{ - "linuxamd64": "https://downloads.arduino.cc/tools/avrdude-6.0.1-arduino2-x86_64-pc-linux-gnu.tar.bz2", - "linux386": "https://downloads.arduino.cc/tools/avrdude-6.0.1-arduino2-i686-pc-linux-gnu.tar.bz2", - "darwinamd64": "https://downloads.arduino.cc/tools/avrdude-6.0.1-arduino2-i386-apple-darwin11.tar.bz2", - "windows386": "https://downloads.arduino.cc/tools/avrdude-6.0.1-arduino2-i686-mingw32.zip", - "windowsamd64": "https://downloads.arduino.cc/tools/avrdude-6.0.1-arduino2-i686-mingw32.zip", - } - - return urls[runtime.GOOS+runtime.GOARCH] -} - -func checksum() string { - checksums := map[string]string{ - "linuxamd64": "SHA-256:2489004d1d98177eaf69796760451f89224007c98b39ebb5577a9a34f51425f1", - "linux386": "SHA-256:6f633dd6270ad0d9ef19507bcbf8697b414a15208e4c0f71deec25ef89cdef3f", - "darwinamd64": "SHA-256:71117cce0096dad6c091e2c34eb0b9a3386d3aec7d863d2da733d9e5eac3a6b1", - "windows386": "SHA-256:6c5483800ba753c80893607e30cade8ab77b182808fcc5ea15fa3019c63d76ae", - "windowsamd64": "SHA-256:6c5483800ba753c80893607e30cade8ab77b182808fcc5ea15fa3019c63d76ae", - } - return checksums[runtime.GOOS+runtime.GOARCH] - }