From 004705243754461d00b8defd93b7b0e2b833cd19 Mon Sep 17 00:00:00 2001 From: Yordan Kinkov <yordan.kinkov@vereign.com> Date: Wed, 5 Oct 2022 18:04:06 +0300 Subject: [PATCH] #8 Vendor dependencies and add goa generated code --- gen/http/cli/policy/cli.go | 14 +-- gen/http/openapi.json | 2 +- gen/http/openapi.yaml | 15 +++ gen/http/openapi3.json | 2 +- gen/http/openapi3.yaml | 90 ++++++++++++------ gen/http/policy/client/cli.go | 18 +++- gen/http/policy/client/encode_decode.go | 6 ++ gen/http/policy/server/encode_decode.go | 18 +++- gen/http/policy/server/types.go | 3 +- gen/policy/service.go | 2 + go.sum | 2 - .../tsa/golib/ptr/ptr.go | Bin 0 -> 1629 bytes vendor/modules.txt | Bin 13699 -> 13771 bytes 13 files changed, 128 insertions(+), 44 deletions(-) create mode 100644 vendor/gitlab.com/gaia-x/data-infrastructure-federation-services/tsa/golib/ptr/ptr.go diff --git a/gen/http/cli/policy/cli.go b/gen/http/cli/policy/cli.go index 1cf7727a..ca43ff33 100644 --- a/gen/http/cli/policy/cli.go +++ b/gen/http/cli/policy/cli.go @@ -32,7 +32,7 @@ policy (evaluate|lock|unlock) // UsageExamples produces an example of a valid invocation of the CLI tool. func UsageExamples() string { return os.Args[0] + ` health liveness` + "\n" + - os.Args[0] + ` policy evaluate --body "Id odio aperiam voluptatem molestias corrupti sunt." --group "example" --policy-name "example" --version "1.0" --evaluation-id "Et voluptates."` + "\n" + + os.Args[0] + ` policy evaluate --body "Ipsum nihil quo." --group "example" --policy-name "example" --version "1.0" --evaluation-id "Aut id odio." --ttl 1804438149079407927` + "\n" + "" } @@ -60,6 +60,7 @@ func ParseEndpoint( policyEvaluatePolicyNameFlag = policyEvaluateFlags.String("policy-name", "REQUIRED", "Policy name.") policyEvaluateVersionFlag = policyEvaluateFlags.String("version", "REQUIRED", "Policy version.") policyEvaluateEvaluationIDFlag = policyEvaluateFlags.String("evaluation-id", "", "") + policyEvaluateTTLFlag = policyEvaluateFlags.String("ttl", "", "") policyLockFlags = flag.NewFlagSet("lock", flag.ExitOnError) policyLockGroupFlag = policyLockFlags.String("group", "REQUIRED", "Policy group.") @@ -172,7 +173,7 @@ func ParseEndpoint( switch epn { case "evaluate": endpoint = c.Evaluate() - data, err = policyc.BuildEvaluatePayload(*policyEvaluateBodyFlag, *policyEvaluateGroupFlag, *policyEvaluatePolicyNameFlag, *policyEvaluateVersionFlag, *policyEvaluateEvaluationIDFlag) + data, err = policyc.BuildEvaluatePayload(*policyEvaluateBodyFlag, *policyEvaluateGroupFlag, *policyEvaluatePolicyNameFlag, *policyEvaluateVersionFlag, *policyEvaluateEvaluationIDFlag, *policyEvaluateTTLFlag) case "lock": endpoint = c.Lock() data, err = policyc.BuildLockPayload(*policyLockGroupFlag, *policyLockPolicyNameFlag, *policyLockVersionFlag) @@ -239,7 +240,7 @@ Additional help: `, os.Args[0]) } func policyEvaluateUsage() { - fmt.Fprintf(os.Stderr, `%[1]s [flags] policy evaluate -body JSON -group STRING -policy-name STRING -version STRING -evaluation-id STRING + fmt.Fprintf(os.Stderr, `%[1]s [flags] policy evaluate -body JSON -group STRING -policy-name STRING -version STRING -evaluation-id STRING -ttl INT Evaluate executes a policy with the given 'data' as input. -body JSON: @@ -247,9 +248,10 @@ Evaluate executes a policy with the given 'data' as input. -policy-name STRING: Policy name. -version STRING: Policy version. -evaluation-id STRING: + -ttl INT: Example: - %[1]s policy evaluate --body "Id odio aperiam voluptatem molestias corrupti sunt." --group "example" --policy-name "example" --version "1.0" --evaluation-id "Et voluptates." + %[1]s policy evaluate --body "Ipsum nihil quo." --group "example" --policy-name "example" --version "1.0" --evaluation-id "Aut id odio." --ttl 1804438149079407927 `, os.Args[0]) } @@ -262,7 +264,7 @@ Lock a policy so that it cannot be evaluated. -version STRING: Policy version. Example: - %[1]s policy lock --group "Explicabo beatae quisquam officiis libero voluptatibus." --policy-name "Repudiandae dolore quod." --version "Aut ut fuga quae eius minus." + %[1]s policy lock --group "Repudiandae dolore quod." --policy-name "Aut ut fuga quae eius minus." --version "Architecto quibusdam ab." `, os.Args[0]) } @@ -275,6 +277,6 @@ Unlock a policy so it can be evaluated again. -version STRING: Policy version. Example: - %[1]s policy unlock --group "Incidunt unde consequatur voluptas dolorem nisi temporibus." --policy-name "Omnis quasi aut consequuntur." --version "Tempore minus." + %[1]s policy unlock --group "Omnis quasi aut consequuntur." --policy-name "Tempore minus." --version "Quis quos qui earum velit illum." `, os.Args[0]) } diff --git a/gen/http/openapi.json b/gen/http/openapi.json index f5208fb3..f8333f00 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":{"get":{"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"]},"post":{"tags":["policy"],"summary":"Evaluate policy","description":"Evaluate executes a policy with the given 'data' as input.","operationId":"policy#Evaluate#2","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}/evaluation/did.json":{"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"]}},"/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#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":"x-cache-ttl","in":"header","description":"Policy result cache TTL in seconds","required":false,"type":"integer"},{"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#2","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":"x-cache-ttl","in":"header","description":"Policy result cache TTL in seconds","required":false,"type":"integer"},{"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}/evaluation/did.json":{"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":"x-cache-ttl","in":"header","description":"Policy result cache TTL in seconds","required":false,"type":"integer"},{"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 5612466d..ec5b9852 100644 --- a/gen/http/openapi.yaml +++ b/gen/http/openapi.yaml @@ -52,6 +52,11 @@ paths: description: EvaluationID allows overwriting the randomly generated evaluationID required: false type: string + - name: x-cache-ttl + in: header + description: Policy result cache TTL in seconds + required: false + type: integer - name: any in: body description: Input data passed to the policy execution runtime. @@ -98,6 +103,11 @@ paths: description: EvaluationID allows overwriting the randomly generated evaluationID required: false type: string + - name: x-cache-ttl + in: header + description: Policy result cache TTL in seconds + required: false + type: integer - name: any in: body description: Input data passed to the policy execution runtime. @@ -145,6 +155,11 @@ paths: description: EvaluationID allows overwriting the randomly generated evaluationID required: false type: string + - name: x-cache-ttl + in: header + description: Policy result cache TTL in seconds + required: false + type: integer - name: any in: body description: Input data passed to the policy execution runtime. diff --git a/gen/http/openapi3.json b/gen/http/openapi3.json index 33bdcd88..6f1ce7b8 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":{"get":{"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":"Aut voluptas."}}},"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":"Sint nam voluptatem ea consequatur similique et."},"example":"Ut commodi perspiciatis corporis."}},"content":{"application/json":{"schema":{"type":"string","description":"Arbitrary JSON response.","example":"Aliquam atque voluptatum ut dolorem.","format":"binary"},"example":"Accusamus autem sequi."}}}}},"post":{"tags":["policy"],"summary":"Evaluate policy","description":"Evaluate executes a policy with the given 'data' as input.","operationId":"policy#Evaluate#2","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":"Et nulla."}}},"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":"In quis nesciunt autem et."},"example":"Commodi nemo fugiat id praesentium accusantium expedita."}},"content":{"application/json":{"schema":{"type":"string","description":"Arbitrary JSON response.","example":"Aliquam atque voluptatum ut dolorem.","format":"binary"},"example":"Qui non quia."}}}}}},"/policy/{group}/{policyName}/{version}/evaluation/did.json":{"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":"Ab accusantium ut ut aliquid sint animi."}},"content":{"application/json":{"schema":{"type":"string","description":"Arbitrary JSON response.","example":"Aliquam atque voluptatum ut dolorem.","format":"binary"},"example":"Dolorem cumque laborum quis nesciunt."}}}}}},"/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":"Quam dolores architecto itaque."},"example":"Voluptas ad corporis adipisci inventore ipsum."},{"name":"policyName","in":"path","description":"Policy name.","required":true,"schema":{"type":"string","description":"Policy name.","example":"Recusandae dolorum nisi distinctio vitae ad."},"example":"Perspiciatis voluptatem."},{"name":"version","in":"path","description":"Policy version.","required":true,"schema":{"type":"string","description":"Policy version.","example":"Corporis est rem."},"example":"Totam officia necessitatibus tempore nulla animi."}],"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":"Error maxime quasi quia non voluptatibus error."},"example":"Optio quia et laborum."},{"name":"policyName","in":"path","description":"Policy name.","required":true,"schema":{"type":"string","description":"Policy name.","example":"In libero perspiciatis voluptatum ut soluta."},"example":"Ut amet."},{"name":"version","in":"path","description":"Policy version.","required":true,"schema":{"type":"string","description":"Policy version.","example":"Accusamus enim."},"example":"Recusandae est rerum corrupti quia."}],"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#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"},{"name":"x-cache-ttl","in":"header","description":"Policy result cache TTL in seconds","allowEmptyValue":true,"schema":{"type":"integer","description":"Policy result cache TTL in seconds","example":60,"format":"int64"},"example":60}],"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":"Aliquam atque voluptatum ut dolorem.","format":"binary"},"example":"Sint nam voluptatem ea consequatur similique et."}}},"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":"Non mollitia nesciunt impedit facere."},"example":"Accusamus autem sequi."}},"content":{"application/json":{"schema":{"type":"string","description":"Arbitrary JSON response.","example":"Aut facere veniam repudiandae id.","format":"binary"},"example":"Et nulla."}}}}},"post":{"tags":["policy"],"summary":"Evaluate policy","description":"Evaluate executes a policy with the given 'data' as input.","operationId":"policy#Evaluate#2","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"},{"name":"x-cache-ttl","in":"header","description":"Policy result cache TTL in seconds","allowEmptyValue":true,"schema":{"type":"integer","description":"Policy result cache TTL in seconds","example":60,"format":"int64"},"example":60}],"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":"Aliquam atque voluptatum ut dolorem.","format":"binary"},"example":"In quis nesciunt autem et."}}},"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":"Sunt in et quia cum."},"example":"Qui non quia."}},"content":{"application/json":{"schema":{"type":"string","description":"Arbitrary JSON response.","example":"Aut facere veniam repudiandae id.","format":"binary"},"example":"Error maxime quasi quia non voluptatibus error."}}}}}},"/policy/{group}/{policyName}/{version}/evaluation/did.json":{"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"},{"name":"x-cache-ttl","in":"header","description":"Policy result cache TTL in seconds","allowEmptyValue":true,"schema":{"type":"integer","description":"Policy result cache TTL in seconds","example":60,"format":"int64"},"example":60}],"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":"Aliquam atque voluptatum ut dolorem.","format":"binary"},"example":"Aut minus alias."}}},"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":"At eos facilis molestias in voluptas rem."},"example":"Dolorem cumque laborum quis nesciunt."}},"content":{"application/json":{"schema":{"type":"string","description":"Arbitrary JSON response.","example":"Aut facere veniam repudiandae id.","format":"binary"},"example":"Aut voluptas."}}}}}},"/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":"Voluptas ad corporis adipisci inventore ipsum."},"example":"Recusandae dolorum nisi distinctio vitae ad."},{"name":"policyName","in":"path","description":"Policy name.","required":true,"schema":{"type":"string","description":"Policy name.","example":"Perspiciatis voluptatem."},"example":"Corporis est rem."},{"name":"version","in":"path","description":"Policy version.","required":true,"schema":{"type":"string","description":"Policy version.","example":"Totam officia necessitatibus tempore nulla animi."},"example":"Consequatur vel rerum rem ipsam nam."}],"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":"Optio quia et laborum."},"example":"In libero perspiciatis voluptatum ut soluta."},{"name":"policyName","in":"path","description":"Policy name.","required":true,"schema":{"type":"string","description":"Policy name.","example":"Ut amet."},"example":"Accusamus enim."},{"name":"version","in":"path","description":"Policy version.","required":true,"schema":{"type":"string","description":"Policy version.","example":"Recusandae est rerum corrupti quia."},"example":"Quam dolores architecto itaque."}],"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 089b16b6..30ff1a7a 100644 --- a/gen/http/openapi3.yaml +++ b/gen/http/openapi3.yaml @@ -60,6 +60,16 @@ paths: description: EvaluationID allows overwriting the randomly generated evaluationID example: did:web:example.com example: did:web:example.com + - name: x-cache-ttl + in: header + description: Policy result cache TTL in seconds + allowEmptyValue: true + schema: + type: integer + description: Policy result cache TTL in seconds + example: 60 + format: int64 + example: 60 requestBody: description: Input data passed to the policy execution runtime. required: true @@ -68,9 +78,9 @@ paths: schema: type: string description: Input data passed to the policy execution runtime. - example: Quis quos qui earum velit illum. + example: Aliquam atque voluptatum ut dolorem. format: binary - example: Aut voluptas. + example: Sint nam voluptatem ea consequatur similique et. responses: "200": description: OK response. @@ -81,16 +91,16 @@ paths: schema: type: string description: ETag contains unique identifier of the policy evaluation and can be used to later retrieve the results from Cache. - example: Sint nam voluptatem ea consequatur similique et. - example: Ut commodi perspiciatis corporis. + example: Non mollitia nesciunt impedit facere. + example: Accusamus autem sequi. content: application/json: schema: type: string description: Arbitrary JSON response. - example: Aliquam atque voluptatum ut dolorem. + example: Aut facere veniam repudiandae id. format: binary - example: Accusamus autem sequi. + example: Et nulla. post: tags: - policy @@ -134,6 +144,16 @@ paths: description: EvaluationID allows overwriting the randomly generated evaluationID example: did:web:example.com example: did:web:example.com + - name: x-cache-ttl + in: header + description: Policy result cache TTL in seconds + allowEmptyValue: true + schema: + type: integer + description: Policy result cache TTL in seconds + example: 60 + format: int64 + example: 60 requestBody: description: Input data passed to the policy execution runtime. required: true @@ -142,9 +162,9 @@ paths: schema: type: string description: Input data passed to the policy execution runtime. - example: Quis quos qui earum velit illum. + example: Aliquam atque voluptatum ut dolorem. format: binary - example: Et nulla. + example: In quis nesciunt autem et. responses: "200": description: OK response. @@ -155,16 +175,16 @@ paths: schema: type: string description: ETag contains unique identifier of the policy evaluation and can be used to later retrieve the results from Cache. - example: In quis nesciunt autem et. - example: Commodi nemo fugiat id praesentium accusantium expedita. + example: Sunt in et quia cum. + example: Qui non quia. content: application/json: schema: type: string description: Arbitrary JSON response. - example: Aliquam atque voluptatum ut dolorem. + example: Aut facere veniam repudiandae id. format: binary - example: Qui non quia. + example: Error maxime quasi quia non voluptatibus error. /policy/{group}/{policyName}/{version}/evaluation/did.json: get: tags: @@ -209,6 +229,16 @@ paths: description: EvaluationID allows overwriting the randomly generated evaluationID example: did:web:example.com example: did:web:example.com + - name: x-cache-ttl + in: header + description: Policy result cache TTL in seconds + allowEmptyValue: true + schema: + type: integer + description: Policy result cache TTL in seconds + example: 60 + format: int64 + example: 60 requestBody: description: Input data passed to the policy execution runtime. required: true @@ -217,9 +247,9 @@ paths: schema: type: string description: Input data passed to the policy execution runtime. - example: Quis quos qui earum velit illum. + example: Aliquam atque voluptatum ut dolorem. format: binary - example: Aut facere veniam repudiandae id. + example: Aut minus alias. responses: "200": description: OK response. @@ -230,16 +260,16 @@ paths: 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: Ab accusantium ut ut aliquid sint animi. + example: At eos facilis molestias in voluptas rem. + example: Dolorem cumque laborum quis nesciunt. content: application/json: schema: type: string description: Arbitrary JSON response. - example: Aliquam atque voluptatum ut dolorem. + example: Aut facere veniam repudiandae id. format: binary - example: Dolorem cumque laborum quis nesciunt. + example: Aut voluptas. /policy/{group}/{policyName}/{version}/lock: delete: tags: @@ -255,8 +285,8 @@ paths: schema: type: string description: Policy group. - example: Quam dolores architecto itaque. - example: Voluptas ad corporis adipisci inventore ipsum. + example: Voluptas ad corporis adipisci inventore ipsum. + example: Recusandae dolorum nisi distinctio vitae ad. - name: policyName in: path description: Policy name. @@ -264,8 +294,8 @@ paths: schema: type: string description: Policy name. - example: Recusandae dolorum nisi distinctio vitae ad. - example: Perspiciatis voluptatem. + example: Perspiciatis voluptatem. + example: Corporis est rem. - name: version in: path description: Policy version. @@ -273,8 +303,8 @@ paths: schema: type: string description: Policy version. - example: Corporis est rem. - example: Totam officia necessitatibus tempore nulla animi. + example: Totam officia necessitatibus tempore nulla animi. + example: Consequatur vel rerum rem ipsam nam. responses: "200": description: OK response. @@ -292,8 +322,8 @@ paths: schema: type: string description: Policy group. - example: Error maxime quasi quia non voluptatibus error. - example: Optio quia et laborum. + example: Optio quia et laborum. + example: In libero perspiciatis voluptatum ut soluta. - name: policyName in: path description: Policy name. @@ -301,8 +331,8 @@ paths: schema: type: string description: Policy name. - example: In libero perspiciatis voluptatum ut soluta. - example: Ut amet. + example: Ut amet. + example: Accusamus enim. - name: version in: path description: Policy version. @@ -310,8 +340,8 @@ paths: schema: type: string description: Policy version. - example: Accusamus enim. - example: Recusandae est rerum corrupti quia. + example: Recusandae est rerum corrupti quia. + example: Quam dolores architecto itaque. responses: "200": description: OK response. diff --git a/gen/http/policy/client/cli.go b/gen/http/policy/client/cli.go index 4b914733..c588b40d 100644 --- a/gen/http/policy/client/cli.go +++ b/gen/http/policy/client/cli.go @@ -11,19 +11,20 @@ package client import ( "encoding/json" "fmt" + "strconv" policy "gitlab.com/gaia-x/data-infrastructure-federation-services/tsa/policy/gen/policy" ) // BuildEvaluatePayload builds the payload for the policy Evaluate endpoint // from CLI flags. -func BuildEvaluatePayload(policyEvaluateBody string, policyEvaluateGroup string, policyEvaluatePolicyName string, policyEvaluateVersion string, policyEvaluateEvaluationID string) (*policy.EvaluateRequest, error) { +func BuildEvaluatePayload(policyEvaluateBody string, policyEvaluateGroup string, policyEvaluatePolicyName string, policyEvaluateVersion string, policyEvaluateEvaluationID string, policyEvaluateTTL string) (*policy.EvaluateRequest, error) { var err error var body interface{} { err = json.Unmarshal([]byte(policyEvaluateBody), &body) if err != nil { - return nil, fmt.Errorf("invalid JSON for body, \nerror: %s, \nexample of valid JSON:\n%s", err, "\"Id odio aperiam voluptatem molestias corrupti sunt.\"") + return nil, fmt.Errorf("invalid JSON for body, \nerror: %s, \nexample of valid JSON:\n%s", err, "\"Ipsum nihil quo.\"") } } var group string @@ -44,6 +45,18 @@ func BuildEvaluatePayload(policyEvaluateBody string, policyEvaluateGroup string, evaluationID = &policyEvaluateEvaluationID } } + var ttl *int + { + if policyEvaluateTTL != "" { + var v int64 + v, err = strconv.ParseInt(policyEvaluateTTL, 10, strconv.IntSize) + val := int(v) + ttl = &val + if err != nil { + return nil, fmt.Errorf("invalid value for ttl, must be INT") + } + } + } v := body res := &policy.EvaluateRequest{ Input: &v, @@ -52,6 +65,7 @@ func BuildEvaluatePayload(policyEvaluateBody string, policyEvaluateGroup string, res.PolicyName = policyName res.Version = version res.EvaluationID = evaluationID + res.TTL = ttl return res, nil } diff --git a/gen/http/policy/client/encode_decode.go b/gen/http/policy/client/encode_decode.go index fb9dc7c9..e47b120e 100644 --- a/gen/http/policy/client/encode_decode.go +++ b/gen/http/policy/client/encode_decode.go @@ -14,6 +14,7 @@ import ( "io" "net/http" "net/url" + "strconv" policy "gitlab.com/gaia-x/data-infrastructure-federation-services/tsa/policy/gen/policy" goahttp "goa.design/goa/v3/http" @@ -61,6 +62,11 @@ func EncodeEvaluateRequest(encoder func(*http.Request) goahttp.Encoder) func(*ht head := *p.EvaluationID req.Header.Set("x-evaluation-id", head) } + if p.TTL != nil { + head := *p.TTL + headStr := strconv.Itoa(head) + req.Header.Set("x-cache-ttl", headStr) + } body := p.Input if err := encoder(req).Encode(&body); err != nil { return goahttp.ErrEncodingError("policy", "Evaluate", err) diff --git a/gen/http/policy/server/encode_decode.go b/gen/http/policy/server/encode_decode.go index a8f93f06..23541d26 100644 --- a/gen/http/policy/server/encode_decode.go +++ b/gen/http/policy/server/encode_decode.go @@ -12,6 +12,7 @@ import ( "context" "io" "net/http" + "strconv" policy "gitlab.com/gaia-x/data-infrastructure-federation-services/tsa/policy/gen/policy" goahttp "goa.design/goa/v3/http" @@ -53,6 +54,7 @@ func DecodeEvaluateRequest(mux goahttp.Muxer, decoder func(*http.Request) goahtt policyName string version string evaluationID *string + ttl *int params = mux.Vars(r) ) @@ -63,7 +65,21 @@ func DecodeEvaluateRequest(mux goahttp.Muxer, decoder func(*http.Request) goahtt if evaluationIDRaw != "" { evaluationID = &evaluationIDRaw } - payload := NewEvaluateRequest(body, group, policyName, version, evaluationID) + { + ttlRaw := r.Header.Get("x-cache-ttl") + if ttlRaw != "" { + v, err2 := strconv.ParseInt(ttlRaw, 10, strconv.IntSize) + if err2 != nil { + err = goa.MergeErrors(err, goa.InvalidFieldTypeError("ttl", ttlRaw, "integer")) + } + pv := int(v) + ttl = &pv + } + } + if err != nil { + return nil, err + } + payload := NewEvaluateRequest(body, group, policyName, version, evaluationID, ttl) return payload, nil } diff --git a/gen/http/policy/server/types.go b/gen/http/policy/server/types.go index a640ce9f..9c2d515d 100644 --- a/gen/http/policy/server/types.go +++ b/gen/http/policy/server/types.go @@ -13,7 +13,7 @@ import ( ) // NewEvaluateRequest builds a policy service Evaluate endpoint payload. -func NewEvaluateRequest(body interface{}, group string, policyName string, version string, evaluationID *string) *policy.EvaluateRequest { +func NewEvaluateRequest(body interface{}, group string, policyName string, version string, evaluationID *string, ttl *int) *policy.EvaluateRequest { v := body res := &policy.EvaluateRequest{ Input: &v, @@ -22,6 +22,7 @@ func NewEvaluateRequest(body interface{}, group string, policyName string, versi res.PolicyName = policyName res.Version = version res.EvaluationID = evaluationID + res.TTL = ttl return res } diff --git a/gen/policy/service.go b/gen/policy/service.go index 75c54e93..e1695f45 100644 --- a/gen/policy/service.go +++ b/gen/policy/service.go @@ -45,6 +45,8 @@ type EvaluateRequest struct { // Identifier created by external system and passed as parameter to overwrite // the randomly generated evaluationID. EvaluationID *string + // Cache TTL for storing policy result in cache + TTL *int } // EvaluateResult is the result type of the policy service Evaluate method. diff --git a/go.sum b/go.sum index 71a70efe..b8629642 100644 --- a/go.sum +++ b/go.sum @@ -290,8 +290,6 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/zach-klippenstein/goregen v0.0.0-20160303162051-795b5e3961ea h1:CyhwejzVGvZ3Q2PSbQ4NRRYn+ZWv5eS1vlaEusT+bAI= github.com/zach-klippenstein/goregen v0.0.0-20160303162051-795b5e3961ea/go.mod h1:eNr558nEUjP8acGw8FFjTeWvSgU1stO7FAO6eknhHe4= -gitlab.com/gaia-x/data-infrastructure-federation-services/tsa/golib v0.0.0-20220913103832-19b72aa5e623 h1:VuWLKBdO5bTGimppwkk6v+cJZ6onc2J16hBXHf048GU= -gitlab.com/gaia-x/data-infrastructure-federation-services/tsa/golib v0.0.0-20220913103832-19b72aa5e623/go.mod h1:5BPRkziGjdCI9xVfJBGY+7Ea51gtiEEs7+rbYeC8lnY= gitlab.com/gaia-x/data-infrastructure-federation-services/tsa/golib v0.0.0-20220914094252-e40da1dc603b h1:H6PS64kBP+oNZbYFUQYpLGyek3cC9hwWL+rrwhx+0lM= gitlab.com/gaia-x/data-infrastructure-federation-services/tsa/golib v0.0.0-20220914094252-e40da1dc603b/go.mod h1:5BPRkziGjdCI9xVfJBGY+7Ea51gtiEEs7+rbYeC8lnY= go.mongodb.org/mongo-driver v1.10.2 h1:4Wk3cnqOrQCn0P92L3/mmurMxzdvWWs5J9jinAVKD+k= diff --git a/vendor/gitlab.com/gaia-x/data-infrastructure-federation-services/tsa/golib/ptr/ptr.go b/vendor/gitlab.com/gaia-x/data-infrastructure-federation-services/tsa/golib/ptr/ptr.go new file mode 100644 index 0000000000000000000000000000000000000000..fd522b7a70d7449dccc01ee3b2b3181eb9e7600e GIT binary patch literal 1629 zcmdPb;tEJi&Q45ERVXMaQb^9vD@n}ED^@5i$;`<tsZ>ZS%}XxH%+D)UNXrLHm!%e! zWagzSlqKerrWPxd<SP{9XXcfp7C}YyxU}@S3J^weab@Nf<QJ7FD3xU9rYdo9>FX;v z<>%)p6s4Aw7UdNyB*G0S$yZ2JNCL@$4cFrWSq@gLkpvdkRL}xTS95VfbStPOan(YM ztSm{zX(UJv#mLH%RFILCC8;1ILDE=^^vo;4VPc*_W?l)zzfebd=9Oq<f<!eHv_Nu5 z#$`fX=$ThyfzLb(bOS9QCR#v@v{1lqrlA==Lk-Q)O*J%w7;9(-G1t%xhrz~1_zX5S zLO0mh2x73Y5yW6)BOC^sncy?n%mm$FGZToxW+o7W%}lTv9105dBJ63Z6eNe706>a0 zN)<rjnhIJV3fag~XpDhW;fgY_UeqW9D~Fm2iZqb1D6xiYF3xBJ8;llhAd?Nvphklu z4rDfJ%pn_&GwQ&GqeUIaaAPB=;o!&v8IBrz$cE#LKCt0v(FZcz%mivUI08Y2qsAc2 zaJQWN#1h<2PlHM$$0JmWMw$XtR#QO>%0iCNG-!l^mE(3lSSOkXpju!yfV}`yhm;{< zHUyRCrQ%543Pm6}WY>cfYZQUSH5IhL(nv-YK^+}jQUoe*i?Ao{Vu&oVu@DU!#R?EP vO$99o135&Bp@xTK=BDCuFQ~lM11mr_9VDPpq5zlFRM3L6k!>j9s^tOz=6VoD literal 0 HcmV?d00001 diff --git a/vendor/modules.txt b/vendor/modules.txt index ed9642b410b5f8097e70ddd0cc8dbf472ffc4829..ffa34e8242fb30107a3b9d3e451a8af7abb780b0 100644 GIT binary patch delta 20 bcmZq9KApWmKyk8xf(vs&NzrD0#S#$!QLF~> delta 19 acmX?|-JHEaK#@sVVX~pJ^yX5<FcAPmg9ZQq -- GitLab