diff --git a/tools/rest/policy.http b/tools/rest/policy.http new file mode 100644 index 0000000000000000000000000000000000000000..9a4f3bc2e91076a82129cdfbfdf7f54e3935dc94 --- /dev/null +++ b/tools/rest/policy.http @@ -0,0 +1,121 @@ +# -------HTTP REST CLIENT ------- +# https://marketplace.visualstudio.com/items?itemName=humao.rest-client + +## This script provides a few samples for calling policy. + + + +# ----------------------- +# OAUTH (Variables) +# ----------------------- +### +@login_base = login.microsoftonline.com/{{TENANT_ID}} +@oauth_token_host = {{login_base}}/oauth2/v2.0/token +@scopes = {{CLIENT_ID}}/.default openid profile offline_access + + + +# ----------------------- +# OAUTH refresh_token +# ----------------------- +### +# @name refresh +POST https://{{oauth_token_host}} HTTP/1.1 +Content-Type: application/x-www-form-urlencoded + +grant_type=refresh_token +&client_id={{CLIENT_ID}} +&client_secret={{CLIENT_SECRET}} +&refresh_token={{INITIAL_TOKEN}} +&scope={{scopes}} + + +# ----------------------- +# API (Variables) +# ----------------------- +### +@access_token = {{refresh.response.body.access_token}} +@ENDPOINT = https://{{OSDU_HOST}} +@POLICY_HOST = {{ENDPOINT}}/api/policy/v1 +@data_partition_id = opendes + +# ----------------------- +# API: Policies +# ----------------------- + +### +# @name Get Policies +GET {{POLICY_HOST}}/policies +Authorization: Bearer {{access_token}} +Accept: application/json +data-partition-id: {{data_partition_id}} + +### +# @name Get Policy - Search +GET {{POLICY_HOST}}/policies/search +Authorization: Bearer {{access_token}} +Accept: application/json +data-partition-id: {{data_partition_id}} + +### +# @name Evaluate policy +POST {{POLICY_HOST}}/evaluations/query +data-partition-id: {{data_partition_id}} +Authorization: Bearer {{access_token}} +Accept: application/json + +{ + "policyId" : "search", + "input": { + "groups" : [ + { + "name": "service.legal.user", + "description": "Datalake Legal users", + "email": "service.legal.user@opendes.contoso.com" + } + ], + "operation" : "view", + "record" : + { + "id" : "123", + "acl": "dummy", + "legal": "123", + "kind": "123.123service.legal.user", + "tags": "123" + } + } +} + +### +# @name Create policy +PUT {{POLICY_HOST}}/policies/test +data-partition-id: {{data_partition_id}} +Authorization: Bearer {{access_token}} +Accept: application/json + +package test +default allow = false +allow = true { + input.operation == "view" +} + +### +# @name Get Policy - test +GET {{POLICY_HOST}}/policies/test +Authorization: Bearer {{access_token}} +Accept: application/json +data-partition-id: {{data_partition_id}} + +### +# @name Delete policy +DELETE {{POLICY_HOST}}/policies/test +data-partition-id: {{data_partition_id}} +Authorization: Bearer {{access_token}} +Accept: application/json + +### +# @name Get Deleted Policy - test +GET {{POLICY_HOST}}/policies/test +Authorization: Bearer {{access_token}} +Accept: application/json +data-partition-id: {{data_partition_id}} \ No newline at end of file