diff --git a/design/design.go b/design/design.go index 3e5bc9fd35b9fe5578ec2ef4bdff0eb9aed77d2d..61c3c44bd84ef660711cc450524e9eb0b002a66d 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 c003fe04928b050c4c31cc88d99414daca1c16b7..e301f2853833ccdc5e3cb2492ca05cc42e87c8d0 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 929e18c02fd206e83548d6434969bb54cd788477..1ece3bde5aced10eebfd3cc80be169559f9219dd 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 4abd44f0e18a7acc6cc212b53bf305a3690d12b5..6bdfe1e0bcd63693b3d374b5299529d5da628647 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 9471ba5faaefea2d67b787a89ff07dcbc4507778..87a090f190b3ffbe4dbf6f512778849e5b146884 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 843953c8f1c2ebd994eb1769f66cb5417e58fcc8..19b3d6f6ac832251d7eabf7eb4fa10ed05b00c6e 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 8f66c95bada522cb67328bec3978efbae30f07ca..6c7a2f3de3bd9512648d739dcf32997fe49d240a 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 5f2cca5429dbde1f3d823d2f5b96d95dab33c7c4..1c250b7f0fe983fa41867089b64dd5d84605b6fa 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 2efb567ba490000eabba333917639eb55ac1e64a..93034da05768a8ef6b23ac765245e41bf46973c5 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 6b7ffabff8b3a70474a43562fbc9850805f3cd95..16478f42e89729506ed08f68b12b845849eeaa76 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 c6dd8e7d80cd2c229a19ced8462d257de6e6f4d9..9d3e84aeda6baad9ceeabf0b929c5c1d1f5556ca 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 70ce94337c1fbae2962dc6fc3c463638323a8f41..a9bb7fb2182a67452be4748675371a7ec81a0149 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 1a20ddf5006e4abaeb11d5a67889b0551e49b405..286fb98a6a65ff95280f1075817cf654227d205c 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