Valid for nomad version >= 0.7.0
You must have nomad ENTERPRISE Edition
Get all policies
https://www.nomadproject.io/api/sentinel-policies.html#list-policies
Example:
import nomad
my_nomad = nomad.Nomad(host='192.168.33.10', token='10f0cf19-2c8c-cb4b-721a-fda2a388740b', verify=False)
policies = my_nomad.sentinel.get_policies()
Create a policy
https://www.nomadproject.io/api/sentinel-policies.html#create-or-update-policy
Example:
import nomad
my_nomad = nomad.Nomad(host='192.168.33.10', token='10f0cf19-2c8c-cb4b-721a-fda2a388740b', verify=False)
policy = {
"Name": "my-policy",
"Description": "This is a great policy",
"Scope": "submit-job",
"EnforcementLevel": "advisory",
"Policy": "main = rule { true }",
}
my_nomad.sentinel.create_policy("my-policy", policy)
Update specific policy
https://www.nomadproject.io/api/sentinel-policies.html#create-or-update-policy
Example:
import nomad
my_nomad = nomad.Nomad(host='192.168.33.10', token='10f0cf19-2c8c-cb4b-721a-fda2a388740b', verify=False)
policy = {
"Name": "my-policy",
"Description": "Updated policy",
"Scope": "submit-job",
"EnforcementLevel": "advisory",
"Policy": "main = rule { true }",
}
my_nomad.sentinel.update_policy("my-policy", policy)
Get specific policy
https://www.nomadproject.io/api/sentinel-policies.html#read-policy
Example:
import nomad
my_nomad = nomad.Nomad(host='192.168.33.10', token='10f0cf19-2c8c-cb4b-721a-fda2a388740b', verify=False)
policy = my_nomad.sentinel.get_policy("my-policy")
Delete specific policy
https://www.nomadproject.io/api/sentinel-policies.html#delete-policy
Example:
import nomad
my_nomad = nomad.Nomad(host='192.168.33.10', token='10f0cf19-2c8c-cb4b-721a-fda2a388740b', verify=False)
my_nomad.sentinel.delete_policy("my-policy")