From 0f3f58b155ea7716e27ab9cb9ac0b486cca9ea20 Mon Sep 17 00:00:00 2001 From: Roberto Sora Date: Tue, 16 Apr 2019 14:12:31 +0200 Subject: [PATCH 1/2] change install method /pkgs/tools/installed to POST to please firefox --- design/pkgs.go | 2 +- gen/http/cli/arduino_create_agent/cli.go | 12 +++++------ gen/http/openapi.json | 2 +- gen/http/openapi.yaml | 2 +- gen/http/tools/client/encode_decode.go | 2 +- gen/http/tools/server/server.go | 4 ++-- gen/indexes/views/view.go | 10 +++++++++ gen/tools/views/view.go | 27 ++++++++++++++++++++++++ 8 files changed, 49 insertions(+), 12 deletions(-) diff --git a/design/pkgs.go b/design/pkgs.go index 5fba81bf6..f99adb91e 100644 --- a/design/pkgs.go +++ b/design/pkgs.go @@ -64,7 +64,7 @@ var _ = Service("tools", func() { Payload(ToolPayload) Result(Operation) HTTP(func() { - PUT("/pkgs/tools/installed") + POST("/pkgs/tools/installed") Response(StatusOK) }) }) diff --git a/gen/http/cli/arduino_create_agent/cli.go b/gen/http/cli/arduino_create_agent/cli.go index bdf38b33c..76e9a56e2 100644 --- a/gen/http/cli/arduino_create_agent/cli.go +++ b/gen/http/cli/arduino_create_agent/cli.go @@ -86,7 +86,7 @@ func ParseEndpoint( return nil, nil, err } - if len(os.Args) < flag.NFlag()+3 { + if flag.NArg() < 2 { // two non flag args are required: SERVICE and ENDPOINT (aka COMMAND) return nil, nil, fmt.Errorf("not enough arguments") } @@ -95,7 +95,7 @@ func ParseEndpoint( svcf *flag.FlagSet ) { - svcn = os.Args[1+flag.NFlag()] + svcn = flag.Arg(0) switch svcn { case "indexes": svcf = indexesFlags @@ -105,7 +105,7 @@ func ParseEndpoint( return nil, nil, fmt.Errorf("unknown service %q", svcn) } } - if err := svcf.Parse(os.Args[2+flag.NFlag():]); err != nil { + if err := svcf.Parse(flag.Args()[1:]); err != nil { return nil, nil, err } @@ -114,7 +114,7 @@ func ParseEndpoint( epf *flag.FlagSet ) { - epn = os.Args[2+flag.NFlag()+svcf.NFlag()] + epn = svcf.Arg(0) switch svcn { case "indexes": switch epn { @@ -152,8 +152,8 @@ func ParseEndpoint( } // Parse endpoint flags if any - if len(os.Args) > 2+flag.NFlag()+svcf.NFlag() { - if err := epf.Parse(os.Args[3+flag.NFlag()+svcf.NFlag():]); err != nil { + if svcf.NArg() > 1 { + if err := epf.Parse(svcf.Args()[1:]); err != nil { return nil, nil, err } } diff --git a/gen/http/openapi.json b/gen/http/openapi.json index 231102e1a..2638bb9af 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","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":"Harum nostrum qui ipsa minima quia dolorem."}}},"400":{"description":"Bad Request response.","schema":{"$ref":"#/definitions/Indexeslist_invalid_url_response_body"}}},"schemes":["http"]}},"/v2/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/Indexesadd_invalid_url_response_body"}}},"schemes":["http"]}},"/v2/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/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.","schema":{"$ref":"#/definitions/ToolsInstallResponseBody"}}},"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"},{"name":"RemoveRequestBody","in":"body","required":true,"schema":{"$ref":"#/definitions/ToolsRemoveRequestBody"}}],"responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/ToolsRemoveResponseBody"}}},"schemes":["http"]}}},"definitions":{"IndexesAddRequestBody":{"title":"IndexesAddRequestBody","type":"object","properties":{"url":{"type":"string","description":"The url of the index file","example":"http://downloads.arduino.cc/packages/package_index.json"}},"example":{"url":"http://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"]},"IndexesRemoveRequestBody":{"title":"IndexesRemoveRequestBody","type":"object","properties":{"url":{"type":"string","description":"The url of the index file","example":"http://downloads.arduino.cc/packages/package_index.json"}},"example":{"url":"http://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"]},"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":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"]},"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":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":false,"id":"123abc","message":"parameter 'p' must be an integer","name":"bad_request","temporary":false,"timeout":false},"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":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"]},"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":"Occaecati eum."},"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":"Sit quod dolor repellat."},"version":{"type":"string","description":"The version of the tool","example":"6.3.0-arduino9"}},"example":{"checksum":"Id ut totam.","name":"avrdude","packager":"arduino","url":"Vero ipsum corporis nihil.","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":"Nobis officia optio inventore."},"url":{"type":"string","description":"The url where the package can be found. Optional. \n\tIf present checksum must also be present.","example":"Inventore exercitationem."}},"example":{"checksum":"Qui modi dolorem.","url":"In voluptatibus."}},"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 +{"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":"Harum nostrum qui ipsa minima quia dolorem."}}},"400":{"description":"Bad Request response.","schema":{"$ref":"#/definitions/Indexeslist_invalid_url_response_body"}}},"schemes":["http"]}},"/v2/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/Indexesadd_invalid_url_response_body"}}},"schemes":["http"]}},"/v2/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/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"]},"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"]}},"/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"},{"name":"RemoveRequestBody","in":"body","required":true,"schema":{"$ref":"#/definitions/ToolsRemoveRequestBody"}}],"responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/ToolsRemoveResponseBody"}}},"schemes":["http"]}}},"definitions":{"IndexesAddRequestBody":{"title":"IndexesAddRequestBody","type":"object","properties":{"url":{"type":"string","description":"The url of the index file","example":"http://downloads.arduino.cc/packages/package_index.json"}},"example":{"url":"http://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"]},"IndexesRemoveRequestBody":{"title":"IndexesRemoveRequestBody","type":"object","properties":{"url":{"type":"string","description":"The url of the index file","example":"http://downloads.arduino.cc/packages/package_index.json"}},"example":{"url":"http://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"]},"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":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"]},"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":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":false,"id":"123abc","message":"parameter 'p' must be an integer","name":"bad_request","temporary":false,"timeout":false},"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":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"]},"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":"Occaecati eum."},"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":"Sit quod dolor repellat."},"version":{"type":"string","description":"The version of the tool","example":"6.3.0-arduino9"}},"example":{"checksum":"Id ut totam.","name":"avrdude","packager":"arduino","url":"Vero ipsum corporis nihil.","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":"Nobis officia optio inventore."},"url":{"type":"string","description":"The url where the package can be found. Optional. \n\tIf present checksum must also be present.","example":"Inventore exercitationem."}},"example":{"checksum":"Qui modi dolorem.","url":"In voluptatibus."}},"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 00cf0a760..f887b2660 100644 --- a/gen/http/openapi.yaml +++ b/gen/http/openapi.yaml @@ -122,7 +122,7 @@ paths: $ref: '#/definitions/ToolsToolResponseCollection' schemes: - http - put: + post: tags: - tools summary: install tools diff --git a/gen/http/tools/client/encode_decode.go b/gen/http/tools/client/encode_decode.go index beda9d7a8..acb1d0468 100644 --- a/gen/http/tools/client/encode_decode.go +++ b/gen/http/tools/client/encode_decode.go @@ -137,7 +137,7 @@ func DecodeInstalledResponse(decoder func(*http.Response) goahttp.Decoder, resto // set to call the "tools" service "install" endpoint func (c *Client) BuildInstallRequest(ctx context.Context, v interface{}) (*http.Request, error) { u := &url.URL{Scheme: c.scheme, Host: c.host, Path: InstallToolsPath()} - req, err := http.NewRequest("PUT", u.String(), nil) + req, err := http.NewRequest("POST", u.String(), nil) if err != nil { return nil, goahttp.ErrInvalidURL("tools", "install", u.String(), err) } diff --git a/gen/http/tools/server/server.go b/gen/http/tools/server/server.go index a25ff092d..f758b2c20 100644 --- a/gen/http/tools/server/server.go +++ b/gen/http/tools/server/server.go @@ -54,7 +54,7 @@ func New( Mounts: []*MountPoint{ {"Available", "GET", "/v2/pkgs/tools/available"}, {"Installed", "GET", "/v2/pkgs/tools/installed"}, - {"Install", "PUT", "/v2/pkgs/tools/installed"}, + {"Install", "POST", "/v2/pkgs/tools/installed"}, {"Remove", "DELETE", "/v2/pkgs/tools/installed/{packager}/{name}/{version}"}, }, Available: NewAvailableHandler(e.Available, mux, dec, enc, eh), @@ -180,7 +180,7 @@ func MountInstallHandler(mux goahttp.Muxer, h http.Handler) { h.ServeHTTP(w, r) } } - mux.Handle("PUT", "/v2/pkgs/tools/installed", f) + mux.Handle("POST", "/v2/pkgs/tools/installed", f) } // NewInstallHandler creates a HTTP handler which loads the HTTP request and diff --git a/gen/indexes/views/view.go b/gen/indexes/views/view.go index 15af1da02..fb5d90fc8 100644 --- a/gen/indexes/views/view.go +++ b/gen/indexes/views/view.go @@ -25,6 +25,16 @@ type OperationView struct { Status *string } +var ( + // OperationMap is a map of attribute names in result type Operation indexed by + // view name. + OperationMap = map[string][]string{ + "default": []string{ + "status", + }, + } +) + // ValidateOperation runs the validations defined on the viewed result type // Operation. func ValidateOperation(result *Operation) (err error) { diff --git a/gen/tools/views/view.go b/gen/tools/views/view.go index 10bd4e8ea..38df0ae7b 100644 --- a/gen/tools/views/view.go +++ b/gen/tools/views/view.go @@ -46,6 +46,33 @@ type OperationView struct { Status *string } +var ( + // ToolCollectionMap is a map of attribute names in result type ToolCollection + // indexed by view name. + ToolCollectionMap = map[string][]string{ + "default": []string{ + "name", + "version", + "packager", + }, + } + // OperationMap is a map of attribute names in result type Operation indexed by + // view name. + OperationMap = map[string][]string{ + "default": []string{ + "status", + }, + } + // ToolMap is a map of attribute names in result type Tool indexed by view name. + ToolMap = map[string][]string{ + "default": []string{ + "name", + "version", + "packager", + }, + } +) + // ValidateToolCollection runs the validations defined on the viewed result // type ToolCollection. func ValidateToolCollection(result ToolCollection) (err error) { From acca9aa034ad4ba5d845421cac2823dbea1c868c Mon Sep 17 00:00:00 2001 From: Roberto Sora Date: Tue, 16 Apr 2019 14:15:53 +0200 Subject: [PATCH 2/2] add brief info about using goa V2 in this project --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9d957c6f6..92aeb0b3f 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,16 @@ arduino-create-agent ==================== +## GOA 2 refactoring +The agent is currently transitioning to the v2 of the GOA framework for API management, please refer to the following +[documentation](https://github.com/goadesign/goa/tree/v2) in order to install tools and libraries + + +i.e. to regenerate code from design use: +```bash +goa gen github.com/arduino/arduino-create-agent/design +``` + ## Installation Get the latest version of the Agent for all supported platforms: @@ -459,4 +469,4 @@ By making a contribution to this project, I certify that: ## Creating a release Just create a new release on GitHub, and our drone server will build and upload -the compiled binaries for every architecture in a zip file in the release itself. +the compiled binaries for every architecture in a zip file in the release itself. \ No newline at end of file