643 matches

[Overview](/catalog)[AI & ML7](/catalog/category/ai-ml)[Analytics8](/catalog/category/analytics)[Communication18](/catalog/category/communication)[CRM4](/catalog/category/crm)[Developer Tools6](/catalog/category/developer-tools)[E-commerce40](/catalog/category/e-commerce)[Finance52](/catalog/category/finance)[Infrastructure28](/catalog/category/infrastructure)[Marketing20](/catalog/category/marketing)[Other409](/catalog/category/other)[Productivity10](/catalog/category/productivity)[Security17](/catalog/category/security)[Social20](/catalog/category/social)[Storage2](/catalog/category/storage)[Support2](/catalog/category/support)

Request a provider

643 matches

[Overview](/catalog)[AI & ML7](/catalog/category/ai-ml)[Analytics8](/catalog/category/analytics)[Communication18](/catalog/category/communication)[CRM4](/catalog/category/crm)[Developer Tools6](/catalog/category/developer-tools)[E-commerce40](/catalog/category/e-commerce)[Finance52](/catalog/category/finance)[Infrastructure28](/catalog/category/infrastructure)[Marketing20](/catalog/category/marketing)[Other409](/catalog/category/other)[Productivity10](/catalog/category/productivity)[Security17](/catalog/category/security)[Social20](/catalog/category/social)[Storage2](/catalog/category/storage)[Support2](/catalog/category/support)

[Actions](/catalog/openpolicy)

14 actions

![](https://www.google.com/s2/favicons?domain=openpolicy.local&sz=64)

Open Policy Agent (OPA) REST

14 actions

* [CompilePOSTv1.0.0](/catalog/openpolicy/post%5Fcompile)
* [Create or overwrite a documentPUTv1.0.0](/catalog/openpolicy/put%5Fdocument)
* [Create or update a policy modulePUTv1.0.0](/catalog/openpolicy/put%5Fpolicy%5Fmodule)
* [Delete a documentDELETEv1.0.0](/catalog/openpolicy/delete%5Fdocument)
* [Delete a policy moduleDELETEv1.0.0](/catalog/openpolicy/delete%5Fpolicy%5Fmodule)
* [Execute a simple queryPOSTv1.0.0](/catalog/openpolicy/post%5Fsimple%5Fquery)
* [Execute an ad-hoc query (complex)POSTv1.0.0](/catalog/openpolicy/post%5Fquery)
* [Execute an ad-hoc query (simple)GETv1.0.0](/catalog/openpolicy/get%5Fquery)
* [Get a documentGETv1.0.0](/catalog/openpolicy/get%5Fdocument)
* [Get a document (with input)POSTv1.0.0](/catalog/openpolicy/get%5Fdocument%5Fwith%5Fpath)
* [Get a policy moduleGETv1.0.0](/catalog/openpolicy/get%5Fpolicy%5Fmodule)
* [Get configurationsGETv1.0.0](/catalog/openpolicy/get%5Fconfig)
* [List policiesGETv1.0.0](/catalog/openpolicy/get%5Fpolicies)
* [Update a documentPATCHv1.0.0](/catalog/openpolicy/patch%5Fdocument)

Other/Open Policy Agent (OPA) REST

# Create or update a policy module

v1.0.0swirls add openpolicy put\_policy\_module

* 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.serversimport data.networksimport 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}
```

SchemasSource

## Input

1. 1
2. 2
3. 3
4. 4
5. 5
6. 6
7. 7
8. 8
9. 9
10. 10
11. 11
12. 12

```
{
  "type": "object",
  "properties": {
    "metrics": {
      "type": "boolean"
    },
    "pretty": {
      "type": "boolean"
    }
  },
  "additionalProperties": false
}
```

## Output

1. 1
2. 2
3. 3
4. 4
5. 5
6. 6
7. 7
8. 8
9. 9
10. 10
11. 11
12. 12
13. 13
14. 14
15. 15
16. 16
17. 17
18. 18
19. 19
20. 20
21. 21
22. 22
23. 23
24. 24
25. 25
26. 26
27. 27
28. 28
29. 29
30. 30
31. 31
32. 32
33. 33
34. 34
35. 35
36. 36
37. 37
38. 38
39. 39
40. 40
41. 41
42. 42
43. 43
44. 44
45. 45
46. 46
47. 47
48. 48
49. 49
50. 50
51. 51
52. 52
53. 53
54. 54
55. 55
56. 56
57. 57
58. 58
59. 59
60. 60
61. 61
62. 62
63. 63
64. 64
65. 65
66. 66
67. 67
68. 68
69. 69
70. 70
71. 71
72. 72
73. 73
74. 74
75. 75
76. 76
77. 77
78. 78
79. 79
80. 80
81. 81
82. 82
83. 83
84. 84
85. 85
86. 86
87. 87
88. 88
89. 89
90. 90
91. 91
92. 92
93. 93
94. 94
95. 95
96. 96
97. 97
98. 98

```
{
  "type": "object",
  "properties": {
    "result": {
      "type": "array",
      "items": {
        "properties": {
          "ast": {
            "type": "object",
            "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.",
            "properties": {
              "package": {
                "type": "object",
                "properties": {
                  "path": {
                    "type": "array",
                    "description": "The path to the package",
                    "items": {
                      "properties": {
                        "type": {
                          "type": "string",
                          "description": "The type of the path operation",
                          "enum": [
                            "import",
                            "package"
                          ]
                        },
                        "value": {
                          "type": "string",
                          "description": "The path variable"
                        }
                      }
                    }
                  }
                }
              },
              "rules": {
                "type": "array",
                "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)",
                "items": {
                  "properties": {
                    "body": {
                      "type": "array",
                      "description": "A list of the terms in this rule",
                      "items": {
                        "properties": {
                          "index": {
                            "type": "object",
                            "additionalProperties": true
                          },
                          "terms": {
                            "type": "object",
                            "additionalProperties": true
                          }
                        }
                      }
                    },
                    "head": {
                      "type": "object",
                      "properties": {
                        "key": {
                          "type": "object",
                          "description": "The type/value pairing for this rule's head",
                          "properties": {
                            "type": {
                              "type": "object",
                              "additionalProperties": true
                            },
                            "value": {
                              "type": "object",
                              "additionalProperties": true
                            }
                          }
                        },
                        "name": {
                          "type": "string",
                          "description": "The head of the rule"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "id": {
            "type": "string",
            "description": "The name of a policy module"
          },
          "raw": {
            "type": "string",
            "description": "A string representation of the full Rego policy"
          }
        }
      }
    }
  }
}
```