From 26a414af6e3f498f9b4085c34703b843bcc2a65f Mon Sep 17 00:00:00 2001 From: Lyuben Penkovski <lyuben.penkovski@vereign.com> Date: Tue, 28 Jun 2022 12:44:13 +0300 Subject: [PATCH] Allow policy evalution with HTTP GET request --- design/design.go | 1 + design/types.go | 2 +- gen/http/openapi.json | 2 +- gen/http/openapi.yaml | 49 +++++++++++- gen/http/openapi3.json | 2 +- gen/http/openapi3.yaml | 102 +++++++++++++++++++++--- gen/http/policy/client/cli.go | 2 +- gen/http/policy/client/encode_decode.go | 2 +- gen/http/policy/client/paths.go | 5 ++ gen/http/policy/server/encode_decode.go | 5 +- gen/http/policy/server/paths.go | 5 ++ gen/http/policy/server/server.go | 2 + gen/http/policy/server/types.go | 2 +- 13 files changed, 159 insertions(+), 22 deletions(-) diff --git a/design/design.go b/design/design.go index 3e5bc9fd..61c3c44b 100644 --- a/design/design.go +++ b/design/design.go @@ -23,6 +23,7 @@ var _ = Service("policy", func() { Payload(EvaluateRequest) Result(EvaluateResult) HTTP(func() { + GET("/policy/{group}/{policyName}/{version}/evaluation") POST("/policy/{group}/{policyName}/{version}/evaluation") Header("evaluationID:x-evaluation-id", String, "EvaluationID allows overwriting the randomly generated evaluationID", func() { Example("did:web:example.com") diff --git a/design/types.go b/design/types.go index c003fe04..e301f285 100644 --- a/design/types.go +++ b/design/types.go @@ -15,7 +15,7 @@ var EvaluateRequest = Type("EvaluateRequest", func() { }) Field(4, "input", Any, "Input data passed to the policy execution runtime.") Field(5, "evaluationID", String, "Identifier created by external system and passed as parameter to overwrite the randomly generated evaluationID.") - Required("group", "policyName", "version", "input") + Required("group", "policyName", "version") }) var EvaluateResult = Type("EvaluateResult", func() { diff --git a/gen/http/openapi.json b/gen/http/openapi.json index 929e18c0..1ece3bde 100644 --- a/gen/http/openapi.json +++ b/gen/http/openapi.json @@ -1 +1 @@ -{"swagger":"2.0","info":{"title":"Policy Service","description":"The policy service exposes HTTP API for executing policies.","version":""},"host":"localhost:8081","consumes":["application/json","application/xml","application/gob"],"produces":["application/json","application/xml","application/gob"],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/policy/{group}/{policyName}/{version}/evaluation":{"post":{"tags":["policy"],"summary":"Evaluate policy","description":"Evaluate executes a policy with the given 'data' as input.","operationId":"policy#Evaluate","parameters":[{"name":"group","in":"path","description":"Policy group.","required":true,"type":"string"},{"name":"policyName","in":"path","description":"Policy name.","required":true,"type":"string"},{"name":"version","in":"path","description":"Policy version.","required":true,"type":"string"},{"name":"x-evaluation-id","in":"header","description":"EvaluationID allows overwriting the randomly generated evaluationID","required":false,"type":"string"},{"name":"any","in":"body","description":"Input data passed to the policy execution runtime.","required":true,"schema":{"type":"string","format":"binary"}}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"binary"},"headers":{"ETag":{"description":"ETag contains unique identifier of the policy evaluation and can be used to later retrieve the results from Cache.","type":"string"}}}},"schemes":["http"]}},"/policy/{group}/{policyName}/{version}/lock":{"post":{"tags":["policy"],"summary":"Lock policy","description":"Lock a policy so that it cannot be evaluated.","operationId":"policy#Lock","parameters":[{"name":"group","in":"path","description":"Policy group.","required":true,"type":"string"},{"name":"policyName","in":"path","description":"Policy name.","required":true,"type":"string"},{"name":"version","in":"path","description":"Policy version.","required":true,"type":"string"}],"responses":{"200":{"description":"OK response."}},"schemes":["http"]},"delete":{"tags":["policy"],"summary":"Unlock policy","description":"Unlock a policy so it can be evaluated again.","operationId":"policy#Unlock","parameters":[{"name":"group","in":"path","description":"Policy group.","required":true,"type":"string"},{"name":"policyName","in":"path","description":"Policy name.","required":true,"type":"string"},{"name":"version","in":"path","description":"Policy version.","required":true,"type":"string"}],"responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}}}} \ No newline at end of file +{"swagger":"2.0","info":{"title":"Policy Service","description":"The policy service exposes HTTP API for executing policies.","version":""},"host":"localhost:8081","consumes":["application/json","application/xml","application/gob"],"produces":["application/json","application/xml","application/gob"],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/policy/{group}/{policyName}/{version}/evaluation":{"get":{"tags":["policy"],"summary":"Evaluate policy","description":"Evaluate executes a policy with the given 'data' as input.","operationId":"policy#Evaluate","parameters":[{"name":"group","in":"path","description":"Policy group.","required":true,"type":"string"},{"name":"policyName","in":"path","description":"Policy name.","required":true,"type":"string"},{"name":"version","in":"path","description":"Policy version.","required":true,"type":"string"},{"name":"x-evaluation-id","in":"header","description":"EvaluationID allows overwriting the randomly generated evaluationID","required":false,"type":"string"},{"name":"any","in":"body","description":"Input data passed to the policy execution runtime.","required":true,"schema":{"type":"string","format":"binary"}}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"binary"},"headers":{"ETag":{"description":"ETag contains unique identifier of the policy evaluation and can be used to later retrieve the results from Cache.","type":"string"}}}},"schemes":["http"]},"post":{"tags":["policy"],"summary":"Evaluate policy","description":"Evaluate executes a policy with the given 'data' as input.","operationId":"policy#Evaluate#1","parameters":[{"name":"group","in":"path","description":"Policy group.","required":true,"type":"string"},{"name":"policyName","in":"path","description":"Policy name.","required":true,"type":"string"},{"name":"version","in":"path","description":"Policy version.","required":true,"type":"string"},{"name":"x-evaluation-id","in":"header","description":"EvaluationID allows overwriting the randomly generated evaluationID","required":false,"type":"string"},{"name":"any","in":"body","description":"Input data passed to the policy execution runtime.","required":true,"schema":{"type":"string","format":"binary"}}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"binary"},"headers":{"ETag":{"description":"ETag contains unique identifier of the policy evaluation and can be used to later retrieve the results from Cache.","type":"string"}}}},"schemes":["http"]}},"/policy/{group}/{policyName}/{version}/lock":{"post":{"tags":["policy"],"summary":"Lock policy","description":"Lock a policy so that it cannot be evaluated.","operationId":"policy#Lock","parameters":[{"name":"group","in":"path","description":"Policy group.","required":true,"type":"string"},{"name":"policyName","in":"path","description":"Policy name.","required":true,"type":"string"},{"name":"version","in":"path","description":"Policy version.","required":true,"type":"string"}],"responses":{"200":{"description":"OK response."}},"schemes":["http"]},"delete":{"tags":["policy"],"summary":"Unlock policy","description":"Unlock a policy so it can be evaluated again.","operationId":"policy#Unlock","parameters":[{"name":"group","in":"path","description":"Policy group.","required":true,"type":"string"},{"name":"policyName","in":"path","description":"Policy name.","required":true,"type":"string"},{"name":"version","in":"path","description":"Policy version.","required":true,"type":"string"}],"responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}}}} \ No newline at end of file diff --git a/gen/http/openapi.yaml b/gen/http/openapi.yaml index 4abd44f0..6bdfe1e0 100644 --- a/gen/http/openapi.yaml +++ b/gen/http/openapi.yaml @@ -25,7 +25,7 @@ paths: schemes: - http /policy/{group}/{policyName}/{version}/evaluation: - post: + get: tags: - policy summary: Evaluate policy @@ -72,6 +72,53 @@ paths: type: string schemes: - http + post: + tags: + - policy + summary: Evaluate policy + description: Evaluate executes a policy with the given 'data' as input. + operationId: policy#Evaluate#1 + parameters: + - name: group + in: path + description: Policy group. + required: true + type: string + - name: policyName + in: path + description: Policy name. + required: true + type: string + - name: version + in: path + description: Policy version. + required: true + type: string + - name: x-evaluation-id + in: header + description: EvaluationID allows overwriting the randomly generated evaluationID + required: false + type: string + - name: any + in: body + description: Input data passed to the policy execution runtime. + required: true + schema: + type: string + format: binary + responses: + "200": + description: OK response. + schema: + type: string + format: binary + headers: + ETag: + description: ETag contains unique identifier of the policy evaluation + and can be used to later retrieve the results from Cache. + type: string + schemes: + - http /policy/{group}/{policyName}/{version}/lock: post: tags: diff --git a/gen/http/openapi3.json b/gen/http/openapi3.json index 9471ba5f..87a090f1 100644 --- a/gen/http/openapi3.json +++ b/gen/http/openapi3.json @@ -1 +1 @@ -{"openapi":"3.0.3","info":{"title":"Policy Service","description":"The policy service exposes HTTP API for executing policies.","version":"1.0"},"servers":[{"url":"http://localhost:8081","description":"Policy Server"}],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}}}},"/policy/{group}/{policyName}/{version}/evaluation":{"post":{"tags":["policy"],"summary":"Evaluate policy","description":"Evaluate executes a policy with the given 'data' as input.","operationId":"policy#Evaluate","parameters":[{"name":"group","in":"path","description":"Policy group.","required":true,"schema":{"type":"string","description":"Policy group.","example":"example"},"example":"example"},{"name":"policyName","in":"path","description":"Policy name.","required":true,"schema":{"type":"string","description":"Policy name.","example":"example"},"example":"example"},{"name":"version","in":"path","description":"Policy version.","required":true,"schema":{"type":"string","description":"Policy version.","example":"1.0"},"example":"1.0"},{"name":"x-evaluation-id","in":"header","description":"EvaluationID allows overwriting the randomly generated evaluationID","allowEmptyValue":true,"schema":{"type":"string","description":"EvaluationID allows overwriting the randomly generated evaluationID","example":"did:web:example.com"},"example":"did:web:example.com"}],"requestBody":{"description":"Input data passed to the policy execution runtime.","required":true,"content":{"application/json":{"schema":{"type":"string","description":"Input data passed to the policy execution runtime.","example":"Quis quos qui earum velit illum.","format":"binary"},"example":"Aut facere veniam repudiandae id."}}},"responses":{"200":{"description":"OK response.","headers":{"ETag":{"description":"ETag contains unique identifier of the policy evaluation and can be used to later retrieve the results from Cache.","required":true,"schema":{"type":"string","description":"ETag contains unique identifier of the policy evaluation and can be used to later retrieve the results from Cache.","example":"Aut minus alias."},"example":"At eos facilis molestias in voluptas rem."}},"content":{"application/json":{"schema":{"type":"string","description":"Arbitrary JSON response.","example":"Aliquam atque voluptatum ut dolorem.","format":"binary"},"example":"Ab accusantium ut ut aliquid sint animi."}}}}}},"/policy/{group}/{policyName}/{version}/lock":{"delete":{"tags":["policy"],"summary":"Unlock policy","description":"Unlock a policy so it can be evaluated again.","operationId":"policy#Unlock","parameters":[{"name":"group","in":"path","description":"Policy group.","required":true,"schema":{"type":"string","description":"Policy group.","example":"Et nulla."},"example":"In quis nesciunt autem et."},{"name":"policyName","in":"path","description":"Policy name.","required":true,"schema":{"type":"string","description":"Policy name.","example":"Sunt in et quia cum."},"example":"Commodi nemo fugiat id praesentium accusantium expedita."},{"name":"version","in":"path","description":"Policy version.","required":true,"schema":{"type":"string","description":"Policy version.","example":"Qui non quia."},"example":"Error maxime quasi quia non voluptatibus error."}],"responses":{"200":{"description":"OK response."}}},"post":{"tags":["policy"],"summary":"Lock policy","description":"Lock a policy so that it cannot be evaluated.","operationId":"policy#Lock","parameters":[{"name":"group","in":"path","description":"Policy group.","required":true,"schema":{"type":"string","description":"Policy group.","example":"Dolorem cumque laborum quis nesciunt."},"example":"Aut voluptas."},{"name":"policyName","in":"path","description":"Policy name.","required":true,"schema":{"type":"string","description":"Policy name.","example":"Sint nam voluptatem ea consequatur similique et."},"example":"Non mollitia nesciunt impedit facere."},{"name":"version","in":"path","description":"Policy version.","required":true,"schema":{"type":"string","description":"Policy version.","example":"Ut commodi perspiciatis corporis."},"example":"Accusamus autem sequi."}],"responses":{"200":{"description":"OK response."}}}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}}}}},"components":{},"tags":[{"name":"health","description":"Health service provides health check endpoints."},{"name":"policy","description":"Policy Service provides evaluation of policies through Open Policy Agent."}]} \ No newline at end of file +{"openapi":"3.0.3","info":{"title":"Policy Service","description":"The policy service exposes HTTP API for executing policies.","version":"1.0"},"servers":[{"url":"http://localhost:8081","description":"Policy Server"}],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}}}},"/policy/{group}/{policyName}/{version}/evaluation":{"get":{"tags":["policy"],"summary":"Evaluate policy","description":"Evaluate executes a policy with the given 'data' as input.","operationId":"policy#Evaluate","parameters":[{"name":"group","in":"path","description":"Policy group.","required":true,"schema":{"type":"string","description":"Policy group.","example":"example"},"example":"example"},{"name":"policyName","in":"path","description":"Policy name.","required":true,"schema":{"type":"string","description":"Policy name.","example":"example"},"example":"example"},{"name":"version","in":"path","description":"Policy version.","required":true,"schema":{"type":"string","description":"Policy version.","example":"1.0"},"example":"1.0"},{"name":"x-evaluation-id","in":"header","description":"EvaluationID allows overwriting the randomly generated evaluationID","allowEmptyValue":true,"schema":{"type":"string","description":"EvaluationID allows overwriting the randomly generated evaluationID","example":"did:web:example.com"},"example":"did:web:example.com"}],"requestBody":{"description":"Input data passed to the policy execution runtime.","required":true,"content":{"application/json":{"schema":{"type":"string","description":"Input data passed to the policy execution runtime.","example":"Quis quos qui earum velit illum.","format":"binary"},"example":"Aut facere veniam repudiandae id."}}},"responses":{"200":{"description":"OK response.","headers":{"ETag":{"description":"ETag contains unique identifier of the policy evaluation and can be used to later retrieve the results from Cache.","required":true,"schema":{"type":"string","description":"ETag contains unique identifier of the policy evaluation and can be used to later retrieve the results from Cache.","example":"Aut minus alias."},"example":"At eos facilis molestias in voluptas rem."}},"content":{"application/json":{"schema":{"type":"string","description":"Arbitrary JSON response.","example":"Aliquam atque voluptatum ut dolorem.","format":"binary"},"example":"Ab accusantium ut ut aliquid sint animi."}}}}},"post":{"tags":["policy"],"summary":"Evaluate policy","description":"Evaluate executes a policy with the given 'data' as input.","operationId":"policy#Evaluate#1","parameters":[{"name":"group","in":"path","description":"Policy group.","required":true,"schema":{"type":"string","description":"Policy group.","example":"example"},"example":"example"},{"name":"policyName","in":"path","description":"Policy name.","required":true,"schema":{"type":"string","description":"Policy name.","example":"example"},"example":"example"},{"name":"version","in":"path","description":"Policy version.","required":true,"schema":{"type":"string","description":"Policy version.","example":"1.0"},"example":"1.0"},{"name":"x-evaluation-id","in":"header","description":"EvaluationID allows overwriting the randomly generated evaluationID","allowEmptyValue":true,"schema":{"type":"string","description":"EvaluationID allows overwriting the randomly generated evaluationID","example":"did:web:example.com"},"example":"did:web:example.com"}],"requestBody":{"description":"Input data passed to the policy execution runtime.","required":true,"content":{"application/json":{"schema":{"type":"string","description":"Input data passed to the policy execution runtime.","example":"Quis quos qui earum velit illum.","format":"binary"},"example":"Dolorem cumque laborum quis nesciunt."}}},"responses":{"200":{"description":"OK response.","headers":{"ETag":{"description":"ETag contains unique identifier of the policy evaluation and can be used to later retrieve the results from Cache.","required":true,"schema":{"type":"string","description":"ETag contains unique identifier of the policy evaluation and can be used to later retrieve the results from Cache.","example":"Aut voluptas."},"example":"Sint nam voluptatem ea consequatur similique et."}},"content":{"application/json":{"schema":{"type":"string","description":"Arbitrary JSON response.","example":"Aliquam atque voluptatum ut dolorem.","format":"binary"},"example":"Non mollitia nesciunt impedit facere."}}}}}},"/policy/{group}/{policyName}/{version}/lock":{"delete":{"tags":["policy"],"summary":"Unlock policy","description":"Unlock a policy so it can be evaluated again.","operationId":"policy#Unlock","parameters":[{"name":"group","in":"path","description":"Policy group.","required":true,"schema":{"type":"string","description":"Policy group.","example":"Qui non quia."},"example":"Error maxime quasi quia non voluptatibus error."},{"name":"policyName","in":"path","description":"Policy name.","required":true,"schema":{"type":"string","description":"Policy name.","example":"Optio quia et laborum."},"example":"In libero perspiciatis voluptatum ut soluta."},{"name":"version","in":"path","description":"Policy version.","required":true,"schema":{"type":"string","description":"Policy version.","example":"Ut amet."},"example":"Accusamus enim."}],"responses":{"200":{"description":"OK response."}}},"post":{"tags":["policy"],"summary":"Lock policy","description":"Lock a policy so that it cannot be evaluated.","operationId":"policy#Lock","parameters":[{"name":"group","in":"path","description":"Policy group.","required":true,"schema":{"type":"string","description":"Policy group.","example":"Ut commodi perspiciatis corporis."},"example":"Accusamus autem sequi."},{"name":"policyName","in":"path","description":"Policy name.","required":true,"schema":{"type":"string","description":"Policy name.","example":"Et nulla."},"example":"In quis nesciunt autem et."},{"name":"version","in":"path","description":"Policy version.","required":true,"schema":{"type":"string","description":"Policy version.","example":"Sunt in et quia cum."},"example":"Commodi nemo fugiat id praesentium accusantium expedita."}],"responses":{"200":{"description":"OK response."}}}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}}}}},"components":{},"tags":[{"name":"health","description":"Health service provides health check endpoints."},{"name":"policy","description":"Policy Service provides evaluation of policies through Open Policy Agent."}]} \ No newline at end of file diff --git a/gen/http/openapi3.yaml b/gen/http/openapi3.yaml index 843953c8..19b3d6f6 100644 --- a/gen/http/openapi3.yaml +++ b/gen/http/openapi3.yaml @@ -17,7 +17,7 @@ paths: "200": description: OK response. /policy/{group}/{policyName}/{version}/evaluation: - post: + get: tags: - policy summary: Evaluate policy @@ -93,6 +93,82 @@ paths: example: Aliquam atque voluptatum ut dolorem. format: binary example: Ab accusantium ut ut aliquid sint animi. + post: + tags: + - policy + summary: Evaluate policy + description: Evaluate executes a policy with the given 'data' as input. + operationId: policy#Evaluate#1 + parameters: + - name: group + in: path + description: Policy group. + required: true + schema: + type: string + description: Policy group. + example: example + example: example + - name: policyName + in: path + description: Policy name. + required: true + schema: + type: string + description: Policy name. + example: example + example: example + - name: version + in: path + description: Policy version. + required: true + schema: + type: string + description: Policy version. + example: "1.0" + example: "1.0" + - name: x-evaluation-id + in: header + description: EvaluationID allows overwriting the randomly generated evaluationID + allowEmptyValue: true + schema: + type: string + description: EvaluationID allows overwriting the randomly generated evaluationID + example: did:web:example.com + example: did:web:example.com + requestBody: + description: Input data passed to the policy execution runtime. + required: true + content: + application/json: + schema: + type: string + description: Input data passed to the policy execution runtime. + example: Quis quos qui earum velit illum. + format: binary + example: Dolorem cumque laborum quis nesciunt. + responses: + "200": + description: OK response. + headers: + ETag: + description: ETag contains unique identifier of the policy evaluation + and can be used to later retrieve the results from Cache. + required: true + schema: + type: string + description: ETag contains unique identifier of the policy evaluation + and can be used to later retrieve the results from Cache. + example: Aut voluptas. + example: Sint nam voluptatem ea consequatur similique et. + content: + application/json: + schema: + type: string + description: Arbitrary JSON response. + example: Aliquam atque voluptatum ut dolorem. + format: binary + example: Non mollitia nesciunt impedit facere. /policy/{group}/{policyName}/{version}/lock: delete: tags: @@ -108,8 +184,8 @@ paths: schema: type: string description: Policy group. - example: Et nulla. - example: In quis nesciunt autem et. + example: Qui non quia. + example: Error maxime quasi quia non voluptatibus error. - name: policyName in: path description: Policy name. @@ -117,8 +193,8 @@ paths: schema: type: string description: Policy name. - example: Sunt in et quia cum. - example: Commodi nemo fugiat id praesentium accusantium expedita. + example: Optio quia et laborum. + example: In libero perspiciatis voluptatum ut soluta. - name: version in: path description: Policy version. @@ -126,8 +202,8 @@ paths: schema: type: string description: Policy version. - example: Qui non quia. - example: Error maxime quasi quia non voluptatibus error. + example: Ut amet. + example: Accusamus enim. responses: "200": description: OK response. @@ -145,8 +221,8 @@ paths: schema: type: string description: Policy group. - example: Dolorem cumque laborum quis nesciunt. - example: Aut voluptas. + example: Ut commodi perspiciatis corporis. + example: Accusamus autem sequi. - name: policyName in: path description: Policy name. @@ -154,8 +230,8 @@ paths: schema: type: string description: Policy name. - example: Sint nam voluptatem ea consequatur similique et. - example: Non mollitia nesciunt impedit facere. + example: Et nulla. + example: In quis nesciunt autem et. - name: version in: path description: Policy version. @@ -163,8 +239,8 @@ paths: schema: type: string description: Policy version. - example: Ut commodi perspiciatis corporis. - example: Accusamus autem sequi. + example: Sunt in et quia cum. + example: Commodi nemo fugiat id praesentium accusantium expedita. responses: "200": description: OK response. diff --git a/gen/http/policy/client/cli.go b/gen/http/policy/client/cli.go index 8f66c95b..6c7a2f3d 100644 --- a/gen/http/policy/client/cli.go +++ b/gen/http/policy/client/cli.go @@ -45,7 +45,7 @@ func BuildEvaluatePayload(policyEvaluateBody string, policyEvaluateGroup string, } v := body res := &policy.EvaluateRequest{ - Input: v, + Input: &v, } res.Group = group res.PolicyName = policyName diff --git a/gen/http/policy/client/encode_decode.go b/gen/http/policy/client/encode_decode.go index 5f2cca54..1c250b7f 100644 --- a/gen/http/policy/client/encode_decode.go +++ b/gen/http/policy/client/encode_decode.go @@ -37,7 +37,7 @@ func (c *Client) BuildEvaluateRequest(ctx context.Context, v interface{}) (*http version = p.Version } u := &url.URL{Scheme: c.scheme, Host: c.host, Path: EvaluatePolicyPath(group, policyName, version)} - req, err := http.NewRequest("POST", u.String(), nil) + req, err := http.NewRequest("GET", u.String(), nil) if err != nil { return nil, goahttp.ErrInvalidURL("policy", "Evaluate", u.String(), err) } diff --git a/gen/http/policy/client/paths.go b/gen/http/policy/client/paths.go index 2efb567b..93034da0 100644 --- a/gen/http/policy/client/paths.go +++ b/gen/http/policy/client/paths.go @@ -16,6 +16,11 @@ func EvaluatePolicyPath(group string, policyName string, version string) string return fmt.Sprintf("/policy/%v/%v/%v/evaluation", group, policyName, version) } +// EvaluatePolicyPath2 returns the URL path to the policy service Evaluate HTTP endpoint. +func EvaluatePolicyPath2(group string, policyName string, version string) string { + return fmt.Sprintf("/policy/%v/%v/%v/evaluation", group, policyName, version) +} + // LockPolicyPath returns the URL path to the policy service Lock HTTP endpoint. func LockPolicyPath(group string, policyName string, version string) string { return fmt.Sprintf("/policy/%v/%v/%v/lock", group, policyName, version) diff --git a/gen/http/policy/server/encode_decode.go b/gen/http/policy/server/encode_decode.go index 6b7ffabf..16478f42 100644 --- a/gen/http/policy/server/encode_decode.go +++ b/gen/http/policy/server/encode_decode.go @@ -41,9 +41,10 @@ func DecodeEvaluateRequest(mux goahttp.Muxer, decoder func(*http.Request) goahtt err = decoder(r).Decode(&body) if err != nil { if err == io.EOF { - return nil, goa.MissingPayloadError() + err = nil + } else { + return nil, goa.DecodePayloadError(err.Error()) } - return nil, goa.DecodePayloadError(err.Error()) } var ( diff --git a/gen/http/policy/server/paths.go b/gen/http/policy/server/paths.go index c6dd8e7d..9d3e84ae 100644 --- a/gen/http/policy/server/paths.go +++ b/gen/http/policy/server/paths.go @@ -16,6 +16,11 @@ func EvaluatePolicyPath(group string, policyName string, version string) string return fmt.Sprintf("/policy/%v/%v/%v/evaluation", group, policyName, version) } +// EvaluatePolicyPath2 returns the URL path to the policy service Evaluate HTTP endpoint. +func EvaluatePolicyPath2(group string, policyName string, version string) string { + return fmt.Sprintf("/policy/%v/%v/%v/evaluation", group, policyName, version) +} + // LockPolicyPath returns the URL path to the policy service Lock HTTP endpoint. func LockPolicyPath(group string, policyName string, version string) string { return fmt.Sprintf("/policy/%v/%v/%v/lock", group, policyName, version) diff --git a/gen/http/policy/server/server.go b/gen/http/policy/server/server.go index 70ce9433..a9bb7fb2 100644 --- a/gen/http/policy/server/server.go +++ b/gen/http/policy/server/server.go @@ -57,6 +57,7 @@ func New( ) *Server { return &Server{ Mounts: []*MountPoint{ + {"Evaluate", "GET", "/policy/{group}/{policyName}/{version}/evaluation"}, {"Evaluate", "POST", "/policy/{group}/{policyName}/{version}/evaluation"}, {"Lock", "POST", "/policy/{group}/{policyName}/{version}/lock"}, {"Unlock", "DELETE", "/policy/{group}/{policyName}/{version}/lock"}, @@ -98,6 +99,7 @@ func MountEvaluateHandler(mux goahttp.Muxer, h http.Handler) { h.ServeHTTP(w, r) } } + mux.Handle("GET", "/policy/{group}/{policyName}/{version}/evaluation", f) mux.Handle("POST", "/policy/{group}/{policyName}/{version}/evaluation", f) } diff --git a/gen/http/policy/server/types.go b/gen/http/policy/server/types.go index 1a20ddf5..286fb98a 100644 --- a/gen/http/policy/server/types.go +++ b/gen/http/policy/server/types.go @@ -15,7 +15,7 @@ import ( func NewEvaluateRequest(body interface{}, group string, policyName string, version string, evaluationID *string) *policy.EvaluateRequest { v := body res := &policy.EvaluateRequest{ - Input: v, + Input: &v, } res.Group = group res.PolicyName = policyName -- GitLab