forked from open-policy-agent/contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
openapi.yaml
1290 lines (1254 loc) · 46.4 KB
/
openapi.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Needs review by SMEs
# 'pretty' parameter setting does not appear to affect anything. Omitting, setting to true or false all has the same result - always human-readable
openapi: 3.0.3
# servers:
# - url: 'http://localhost:8181'
# description: Docker
tags:
- name: Policy API
description: 'Allows you to add, remove and modify policy modules. *Policy module identifiers are only used for management purposes. They are not used outside the Policy API.*'
- name: Data API
description: 'Exposes endpoints for reading and writing documents in OPA. For an explanation of the different types of documents, see [the OPA document model](https://www.openpolicyagent.org/docs/latest/philosophy/#the-opa-document-model)'
- name: Query API
description: Posting queries to OPA
- name: Compile API
description: Posting partial queries to OPA
- name: Health API
description: Executes a simple built-in policy query to verify that the server is operational
info:
title: Open Policy Agent (OPA) REST API
description: |-
OPA provides policy-based control for cloud native environments. The following *endpoints* (such as `PUT /v1/policies`) provide reference documentation for the OPA REST API.
### API specification viewing options
- **[View the specification in *Redoc* (default)](index.html)**
- **[View the specification in *Swagger UI*](swagger-ui.html)**
version: 0.28.0
x-logo:
url: 'https://github.com/open-policy-agent/opa/blob/master/docs/website/static/img/logos/opa-horizontal-color.png?raw=true'
backgroundColor: '#FFFFFF'
altText: 'OPA logo'
contact:
name: The OPA team
url: 'https://github.com/open-policy-agent/opa'
license:
name: Apache 2.0
url: 'https://www.apache.org/licenses/LICENSE-2.0'
externalDocs:
description: OPA documentation
url: 'https://www.openpolicyagent.org/docs/latest/'
paths:
/v1/policies:
get:
summary: List policies
description: This API endpoint responds with a list of all policy modules on the server (result response)
operationId: getPolicies
parameters:
- $ref: '#/components/parameters/prettyParameter'
tags:
- Policy API
responses:
'200':
$ref: '#/components/responses/successResult'
'500':
$ref: '#/components/responses/serverErrorResponse'
x-code-samples:
- lang: JavaScript
source: |
fetch("http://localhost:8181/v1/policies", {
"method": "GET",
"headers": {}
})
.then(response => {
console.log(response);
})
.catch(err => {
console.error(err);
});
- lang: Python
source: |
import http.client
conn = http.client.HTTPConnection("localhost:8181")
conn.request("GET", "/v1/policies")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
- lang: Java
source: |
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("GET", "http://localhost:8181/v1/policies")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
- lang: Go
source: |
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "http://localhost:8181/v1/policies"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
'/v1/policies/{id}':
parameters:
- $ref: '#/components/parameters/idParameter'
get:
summary: Get a policy module
description: This API endpoint returns the details of the specified policy module (`{id}`)
operationId: getPolicyModule
parameters:
- $ref: '#/components/parameters/prettyParameter'
tags:
- Policy API
responses:
'200':
$ref: '#/components/responses/successResult'
'404':
$ref: '#/components/responses/notFoundResponse'
'500':
$ref: '#/components/responses/serverErrorResponse'
put:
summary: Create or update a policy module
description: |-
- If the policy module does not exist, it is created.
- If the policy module already exists, it is replaced.
If the policy module isn't correctly defined, a *bad request* (400) response is returned.
### Example policy module
```yaml
package opa.examples
import data.servers
import data.networks
import data.ports
public_servers[server] {
some k, m
server := servers[_]
server.ports[_] == ports[k].id
ports[k].networks[_] == networks[m].id
networks[m].public == true
}
```
operationId: putPolicyModule
parameters:
- $ref: '#/components/parameters/prettyParameter'
- $ref: '#/components/parameters/metricsParameter'
requestBody:
required: true
content:
text/plain:
schema:
type: string
example: |-
package opa.examples
import data.servers
import data.networks
import data.ports
public_servers[server] {
some k, m
server := servers[_]
server.ports[_] == ports[k].id
ports[k].networks[_] == networks[m].id
networks[m].public == true
}
tags:
- Policy API
responses:
'200':
$ref: '#/components/responses/successResult'
'400':
$ref: '#/components/responses/badRequestResponse'
'500':
$ref: '#/components/responses/serverErrorResponse'
delete:
summary: Delete a policy module
description: This API endpoint removes an existing policy module from the server
operationId: deletePolicyModule
parameters:
- $ref: '#/components/parameters/prettyParameter'
tags:
- Policy API
responses:
'200':
$ref: '#/components/responses/successResponse'
'400':
$ref: '#/components/responses/badRequestResponse'
'404':
$ref: '#/components/responses/notFoundResponse'
'500':
$ref: '#/components/responses/serverErrorResponse'
'/v1/data/{path}':
parameters:
- $ref: '#/components/parameters/pathParameter'
get:
summary: Get a document
description: |-
This API endpoint returns the document specified by `path`.
The server will return a *bad request* (400) response if either:
- The query requires an input document and you do not provide it
- You provide the input document but the query has already defined it.
operationId: getDocument
parameters:
- $ref: '#/components/parameters/inputParameter'
- $ref: '#/components/parameters/prettyParameter'
- $ref: '#/components/parameters/provenanceParameter'
- $ref: '#/components/parameters/explainParameter'
- $ref: '#/components/parameters/metricsParameter'
- $ref: '#/components/parameters/instrumentParameter'
tags:
- Data API
responses:
'200':
$ref: '#/components/responses/successResponse'
'400':
$ref: '#/components/responses/badRequestResponse'
'500':
$ref: '#/components/responses/serverErrorResponse'
put:
summary: Create or overwrite a document
description: |-
If the path does not refer to an existing document (for example *us-west/servers*), the server will attempt to create all the necessary containing documents.
This behavior is similar to the Unix command [mkdir -p](https://en.wikipedia.org/wiki/Mkdir#Options).
operationId: putDocument
requestBody:
description: The JSON document to write to the specified path.
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/dataSchema'
parameters:
- $ref: '#/components/parameters/ifNoneMatchParameter'
tags:
- Data API
responses:
'204':
description: Success
'304':
description: Document was not modified
'400':
$ref: '#/components/responses/badRequestResponse'
'404':
$ref: '#/components/responses/notFoundResponse'
'500':
$ref: '#/components/responses/serverErrorResponse'
patch:
summary: Update a document
description: 'This API endpoint updates an existing document on the server by describing the changes required (using [JSON patch operations](http://jsonpatch.com/))'
operationId: patchDocument
requestBody:
description: The list of JSON patch operations.
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/patchesSchema'
tags:
- Data API
responses:
'204':
description: Success
'400':
$ref: '#/components/responses/badRequestResponse'
'404':
$ref: '#/components/responses/notFoundResponse'
'500':
$ref: '#/components/responses/serverErrorResponse'
delete:
summary: Delete a document
description: 'This API endpoint deletes an existing document from the server'
operationId: deleteDocument
tags:
- Data API
responses:
'204':
description: Success
'404':
$ref: '#/components/responses/notFoundResponse'
'500':
$ref: '#/components/responses/serverErrorResponse'
post:
summary: Get a document (with input)
description: |-
The server will return a *bad request* (400) response if either:
- The query requires an input document and you do not provide it
- You provided an input document but the query has already defined it.
If `path` indexes into an array, the server will attempt to convert the array index to an integer. If the path element cannot be converted to an integer, a *not found* response (404) will be returned.
operationId: getDocumentWithPath
parameters:
- $ref: '#/components/parameters/prettyParameter'
- $ref: '#/components/parameters/provenanceParameter'
- $ref: '#/components/parameters/explainParameter'
- $ref: '#/components/parameters/metricsParameter'
- $ref: '#/components/parameters/instrumentParameter'
requestBody:
description: The input document (in JSON format)
required: true
content:
application/x-yaml:
schema:
$ref: '#/components/schemas/inputSchema'
tags:
- Data API
responses:
'200':
$ref: '#/components/responses/successResponse'
'400':
$ref: '#/components/responses/badRequestResponse'
'500':
$ref: '#/components/responses/serverErrorResponse'
'/v0/data/{path}':
parameters:
- $ref: '#/components/parameters/webhookPathParameter'
post:
summary: Get a document (with webhook)
description: |
The example given here assumes you have created a policy (with `PUT /v1/policies/{path}`), such as:
```yaml
package opa.examples
import input.example.flag
allow_request { flag == true }
```
The server will return a *not found* (404) response if the requested document is missing or undefined.
operationId: getDocumentWithWebHook
parameters:
- $ref: '#/components/parameters/prettyParameter'
requestBody:
description: The input document (in JSON format)
required: true
content:
application/x-yaml:
schema:
$ref: '#/components/schemas/webhookInputSchema'
tags:
- Data API
responses:
'200':
$ref: '#/components/responses/successResponse'
'400':
$ref: '#/components/responses/badRequestResponse'
'404':
$ref: '#/components/responses/notFoundResponse'
'500':
$ref: '#/components/responses/serverErrorResponse'
/:
post:
summary: Execute a simple query
description: |-
This API queries the document at */data/system/main* by default (however, you can [configure OPA](https://www.openpolicyagent.org/docs/latest/configuration/) to use a different path to serve these queries). That document defines the response.
For example, use the following in `PUT /v1/policies/{path}`) to define a rule that will produce a value for the */data/system/main* document:
```yaml
package system
main = msg {
msg := sprintf("hello, %v", input.user)
}
```
The server will return a *not found* (404) response if */data/system/main* is undefined.
operationId: postSimpleQuery
parameters:
- $ref: '#/components/parameters/prettyParameter'
requestBody:
description: The text of the input document (in JSON format)
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/queryInputSchema'
tags:
- Query API
responses:
'200':
description: Success
'400':
$ref: '#/components/responses/badRequestResponse'
'404':
$ref: '#/components/responses/notFoundResponse'
'500':
$ref: '#/components/responses/serverErrorResponse'
/v1/query:
get:
summary: Execute an ad-hoc query (simple)
description: |-
This API endpoint returns bindings for the variables in the query.
For more complex JSON queries, use `POST /v1/query` instead.
operationId: getQuery
parameters:
- $ref: '#/components/parameters/qParameter'
- $ref: '#/components/parameters/prettyParameter'
- $ref: '#/components/parameters/explainParameter'
- $ref: '#/components/parameters/metricsParameter'
tags:
- Query API
responses:
'200':
$ref: '#/components/responses/successQuery'
'400':
$ref: '#/components/responses/badRequestResponse'
'500':
$ref: '#/components/responses/serverErrorResponse'
post:
summary: Execute an ad-hoc query (complex)
description: |-
This API endpoint returns bindings for the variables in the query.
For simpler JSON queries, you may use `GET /v1/query` instead.
operationId: postQuery
parameters:
- $ref: '#/components/parameters/prettyParameter'
- $ref: '#/components/parameters/explainParameter'
- $ref: '#/components/parameters/metricsParameter'
requestBody:
description: The test of the query (in JSON format)
required: true
content:
application/x-yaml:
schema:
$ref: '#/components/schemas/qSchema'
tags:
- Query API
responses:
'200':
$ref: '#/components/responses/successQuery'
'400':
$ref: '#/components/responses/badRequestResponse'
'500':
$ref: '#/components/responses/serverErrorResponse'
'501':
description: Streaming not implemented
'/v1/compile':
post:
summary: Compile
description: |-
This API endpoint allows you to partially evaluate Rego queries and obtain a simplified version of the policy. The example below assumes that OPA has been given the following policy (use `PUT /v1/policies/{path}`):
```yaml
package example
allow {
input.subject.clearance_level >= data.reports[_].clearance_level
}
```
Compile API **request body** so that it contain the following fields:
| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `query` | `string` | Yes | The query to partially evaluate and compile. |
| `input` | `any` | No | The input document to use during partial evaluation (default: undefined). |
| `unknowns` | `array[string]` | No | The terms to treat as unknown during partial evaluation (default: `["input"]`]). |
For example:
```json
{
"query": "data.example.allow == true",
"input": {
"subject": {
"clearance_level": 4
}
},
"unknowns": [
"data.reports"
]
}
```
### Partial evaluation
In some cases, the result of partial valuation is a conclusive, unconditional answer. See [the guidance](https://www.openpolicyagent.org/docs/latest/rest-api/#unconditional-results-from-partial-evaluation) for details.
externalDocs:
description: Partial evaluation article
url: 'https://blog.openpolicyagent.org/partial-evaluation-162750eaf422'
operationId: postCompile
parameters:
- $ref: '#/components/parameters/prettyParameter'
- $ref: '#/components/parameters/explainParameter'
- $ref: '#/components/parameters/metricsParameter'
- $ref: '#/components/parameters/instrumentParameter'
requestBody:
description: The query (in JSON format)
required: false
content:
application/json:
schema:
$ref: '#/components/schemas/partialQuerySchema'
tags:
- Compile API
responses:
'200':
$ref: '#/components/responses/successQuery'
'400':
$ref: '#/components/responses/badRequestResponse'
'500':
$ref: '#/components/responses/serverErrorResponse'
/health:
get:
summary: Health
description: |-
This API endpoint verifies that the server is operational.
The response from the server is either 200 or 500:
- **200** - OPA service is healthy. If `bundles` is true, then all configured bundles have been activated. If `plugins` is true, then all plugins are in an 'OK' state.
- **500** - OPA service is *not* healthy. If `bundles` is true, at least one of configured bundles has not yet been activated. If `plugins` is true, at least one plugins is in a 'not OK' state.
---
**Note**
This check is only for initial bundle activation. Subsequent downloads will not affect the health check.
Use the **status** endpoint (in the (management API)[management.html]) for more fine-grained bundle status monitoring.
---
externalDocs:
description: Bundles
url: 'https://www.openpolicyagent.org/docs/latest/management/#bundles'
operationId: getHealth
parameters:
- $ref: '#/components/parameters/bundlesParameter'
- $ref: '#/components/parameters/pluginsParameter'
tags:
- Health API
responses:
'200':
description: OPA service is healthy
'500':
description: OPA service is not healthy
/v1/config:
get:
summary: Get configurations
description: |-
This API endpoint responds with active configuration (result response)
---
**Note**
The `credentials` field in the `services` configuration and
The `private_key` and `key` fields in the `keys` configuration will be omitted from the API response
---
operationId: getConfig
parameters:
- $ref: '#/components/parameters/prettyParameter'
tags:
- Config API
responses:
'200':
$ref: '#/components/responses/successSingleResult'
'500':
$ref: '#/components/responses/serverErrorResponse'
components:
parameters:
idParameter:
name: id
description: The name of a policy module
example: example1
in: path
required: true
schema:
type: string
prettyParameter:
name: pretty
description: 'If true, response will be in a human-readable format.'
example: true
in: query
required: false
schema:
type: boolean
metricsParameter:
name: metrics
description: 'If true, compiler performance metrics will be returned in the response.'
example: false
in: query
required: false
schema:
type: boolean
pathParameter:
name: path
description: 'A backslash (/) delimited path to access values inside object and array documents. If the path points to an array, the server will attempt to convert the array index to an integer. If the path element cannot be converted to an integer, the server will respond with 404.'
example: opa/examples/public_servers
in: path
required: true
allowReserved: true
schema:
type: string
webhookPathParameter:
name: path
description: 'A backslash (/) delimited path to access values inside object and array documents. If the path points to an array, the server will attempt to convert the array index to an integer. If the path element cannot be converted to an integer, the server will respond with 404.'
example: opa/examples/allow_request
in: path
required: true
schema:
type: string
provenanceParameter:
name: provenance
description: 'If true, response will include build and version information in addition to the result.'
example: false
in: query
required: false
schema:
type: boolean
explainParameter:
name: explain
description: 'If set to *full*, response will include query explanations in addition to the result.'
example: full
in: query
required: false
schema:
type: string
instrumentParameter:
name: instrument
description: |-
If true, response will return additional performance metrics in addition to the result and the standard metrics.
**Caution:** This can add significant overhead to query evaluation. The recommendation is to only use this parameter if you are debugging a performance problem.
example: false
in: query
required: false
schema:
type: boolean
ifNoneMatchParameter:
name: If-None-Match
description: 'The server will respect the If-None-Match header if it is set to * (in other words, it will not overwrite an existing document located at the specified `path`).'
example: '*'
in: header
required: false
schema:
type: string
qParameter:
name: q
description: 'The [URL-encoded](https://www.w3schools.com/tags/ref_urlencode.ASP) ad-hoc query to execute.'
example: '{"query": "data.servers[i].ports[_] = \"p2\"; data.servers[i].name = name"}'
in: query
required: true
schema:
type: string
inputParameter:
name: input
description: 'Provide the text for an [input document](https://www.openpolicyagent.org/docs/latest/kubernetes-primer/#input-document) in JSON format'
in: query
required: false
schema:
type: object
additionalProperties: {}
example: {"input": {"example": {"flag": true}}}
bundlesParameter:
name: bundles
description: |-
Reports on bundle activation status (useful for 'ready' checks at startup).
This includes any discovery bundles or bundles defined in the loaded discovery configuration.
example: true
in: query
required: false
schema:
type: boolean
pluginsParameter:
name: plugins
description: Reports on plugin status
example: false
in: query
required: false
schema:
type: boolean
responses:
successResult:
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/200Result'
successSingleResult:
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/200SingleResult'
successResponse:
description: Success
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/200Result'
- $ref: '#/components/schemas/200Provenance'
- $ref: '#/components/schemas/200Metrics'
- $ref: '#/components/schemas/200Explanations'
successQuery:
description: Success
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/200Result'
- $ref: '#/components/schemas/200Metrics'
- $ref: '#/components/schemas/200Explanations'
successZipResponse:
description: Success. You will find a gzip file is in the response's message body
content:
application/gzip:
schema:
type: string
format: binary
notFoundResponse:
description: Not found (for example, a requested policy module or document does not exist)
content:
application/json:
schema:
$ref: '#/components/schemas/404'
badRequestResponse:
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/400'
serverErrorResponse:
description: Server error
content:
application/json:
schema:
$ref: '#/components/schemas/400'
schemas:
'400':
type: object
properties:
code:
description: The error code name
example: invalid_parameter
type: string
minLength: 1
message:
description: The description of the error
type: string
minLength: 1
example: error(s) occurred while compiling module(s)
errors:
description: 'Errors that may have been generated during the parse, compile, or installation of a policy module'
type: array
uniqueItems: true
items:
properties:
code:
description: The error code name
type: string
minLength: 1
example: rego_unsafe_var_error
message:
description: A general description of the error
type: string
minLength: 1
example: var x is unsafe
location:
description: Where the error occurred
type: object
properties:
file:
description: The policy module name that generated the error
type: string
example: example1
row:
description: The line number in the policy module where the error occurred
type: number
example: 3
col:
description: The column in the policy module where the error occurred
type: number
example: 1
required:
- code
- message
'404':
type: object
properties:
code:
description: The error code name
example: resource_not_found
type: string
minLength: 1
message:
description: The description of the error (including the name of any undefined policy module)
example: 'storage_not_found_error: policy id \"partial\"'
type: string
minLength: 1
required:
- code
- message
inputSchema:
type: object
example: |-
{
"input": {
"example": {
"flag": true
}
}
}
additionalProperties: {}
x-examples:
example: |-
{
"input": {
"example": {
"flag": true
}
}
}
dataSchema:
example: |-
{
"users": {
"user-id-1": {
"isAdmin": true
}
}
}
webhookInputSchema:
type: object
example: |-
{
"example": {
"flag": true
}
}
additionalProperties: {}
queryInputSchema:
type: object
example: |-
{
"user": ["alice"]
}
additionalProperties: {}
qSchema:
type: object
example: |-
{
"query": "data.servers[i].ports[_] = \"p2\"; data.servers[i].name = name"
}
additionalProperties: {}
partialQuerySchema:
type: object
example: |-
{
"query": "data.example.allow == true",
"input": {
"subject": {
"clearance_level": 4
}
},
"unknowns": [
"data.reports"
]
}
additionalProperties: {}
patchesSchema:
type: array
minItems: 1
description: 'A list of one or more [JSON patch operations](http://jsonpatch.com/)'
items:
type: object
description: A JSON patch operation
properties:
op:
type: string
minLength: 1
description: JSON patch operation type
enum:
- add
- remove
- replace
- move
- copy
- test
example: add
path:
type: string
minLength: 1
example: '-'
description: |-
A [JSON pointer](https://tools.ietf.org/html/rfc6901) to a location within the target document where the operation is performed.
The *effective path* is this value prefixed with the API call's `path` parameter.
The server will return a *bad request* (404) response if:
- The *parent* of the effective path does not refer to an existing document
- For **remove** and **replace** operations, the effective path does not refer to an existing document.
value:
type: object
example: |-
{
"id": "s5",
"name": "job",
"protocols": ["amqp"],
"ports": ["p3"]
}
description: 'The value to add, replace or test.'
additionalProperties: {}
required:
- op
- path
200Result:
type: object
properties:
result:
type: array
items:
properties:
id:
description: The name of a policy module
example: example2
type: string
minLength: 1
raw:
description: 'A string representation of the full Rego policy'
type: string
example: 'package opa.examples\n\nimport data.servers\n\nviolations[server] {\n\tserver = servers[_]\n\tserver.protocols[_] = \"http\"\n\tpublic_servers[server]\n}\n'
minLength: 1
ast:
description: The types for declarations and runtime objects passed to your implementation. This consists of an abstract syntax tree (AST) of policy modules, package and import declarations, rules, expressions, and terms.
externalDocs:
description: AST
url: 'https://godoc.org/github.com/open-policy-agent/opa/ast'
type: object
properties:
package:
type: object
properties:
path:
description: 'The path to the package'
type: array
items:
properties:
type:
description: The type of the path operation
example: import
type: string
enum:
- import
- package
value:
description: The path variable
example: data.opa.example
type: string
rules:
description: 'When OPA evaluates a rule, it generates the content of a [virtual documents](https://www.openpolicyagent.org/docs/latest/philosophy/#the-opa-document-model)'
externalDocs:
description: Rules
url: 'https://www.openpolicyagent.org/docs/latest/policy-language/#rules'
type: array
uniqueItems: true
items:
properties:
head:
type: object
properties:
name:
description: The head of the rule
example: violations
type: string
key:
description: The type/value pairing for this rule's head
type: object
properties:
type:
description: The type of the head
example: var
type: string
value:
description: The value of the head
example: $0
type: string
body:
description: A list of the terms in this rule
type: array
items:
properties:
index:
description: The location of this term in the list (starts at 0)
example: 1
type: number
terms:
description: The type/value pairing for this term
type: array
items:
properties:
type:
description: The type of the term variable
example: var
type: string
value:
description: The list of types and values for the term variable
type: array
items:
properties: