github.com/smintz/nomad@v0.8.3/website/source/api/sentinel-policies.html.md (about)

     1  ---
     2  layout: api
     3  page_title: Sentinel Policies - HTTP API
     4  sidebar_current: api-sentinel-policies
     5  description: |-
     6    The /sentinel/policy/ endpoints are used to configure and manage Sentinel policies.
     7  ---
     8  
     9  # Sentinel Policies HTTP API
    10  
    11  The `/sentinel/policies` and `/sentinel/policy/` endpoints are used to manage Sentinel policies.
    12  For more details about Sentinel policies, please see the [Sentinel Policy Guide](/guides/sentinel-policy.html).
    13  
    14  Sentinel endpoints are only available when ACLs are enabled. For more details about ACLs, please see the [ACL Guide](/guides/acl.html).
    15  
    16  ~> **Enterprise Only!** This API endpoint and functionality only exists in
    17  Nomad Enterprise. This is not present in the open source version of Nomad.
    18  
    19  ## List Policies
    20  
    21  This endpoint lists all Sentinel policies. This lists the policies that have been replicated
    22  to the region, and may lag behind the authoritative region.
    23  
    24  | Method | Path                         | Produces                   |
    25  | ------ | ---------------------------- | -------------------------- |
    26  | `GET`  | `/sentinel/policies`         | `application/json`         |
    27  
    28  The table below shows this endpoint's support for
    29  [blocking queries](/api/index.html#blocking-queries), [consistency modes](/api/index.html#consistency-modes) and
    30  [required ACLs](/api/index.html#acls).
    31  
    32  | Blocking Queries | Consistency Modes | ACL Required |
    33  | ---------------- | ----------------- | ------------ |
    34  | `YES`            | `all`             | `management` |
    35  
    36  
    37  ### Sample Request
    38  
    39  ```text
    40  $ curl \
    41      https://localhost:4646/v1/sentinel/policies
    42  ```
    43  
    44  ### Sample Response
    45  
    46  ```json
    47  [
    48    {
    49      "Name": "foo",
    50      "Description": "test policy",
    51      "Scope": "submit-job",
    52      "EnforcementLevel": "advisory",
    53      "Hash": "CIs8aNX5OfFvo4D7ihWcQSexEJpHp+Za+dHSncVx5+8=",
    54      "CreateIndex": 8,
    55      "ModifyIndex": 8
    56    }
    57  ]
    58  ```
    59  
    60  ## Create or Update Policy
    61  
    62  This endpoint creates or updates an Sentinel Policy. This request is always forwarded to the
    63  authoritative region.
    64  
    65  | Method | Path                         | Produces                   |
    66  | ------ | ---------------------------- | -------------------------- |
    67  | `POST` | `/sentinel/policy/:policy_name`   | `(empty body)`             |
    68  
    69  The table below shows this endpoint's support for
    70  [blocking queries](/api/index.html#blocking-queries) and
    71  [required ACLs](/api/index.html#acls).
    72  
    73  | Blocking Queries | ACL Required       |
    74  | ---------------- | ------------------ |
    75  | `NO`             | `management`       |
    76  
    77  ### Parameters
    78  
    79  - `Name` `(string: <required>)` - Specifies the name of the policy.
    80    Creates the policy if the name does not exist, otherwise updates the existing policy.
    81  
    82  - `Description` `(string: <optional>)` - Specifies a human readable description.
    83  
    84  - `Scope` `(string: <required>)` - Specifies the scope of when this policy applies. Only `submit-job` is currently supported.
    85  
    86  - `EnforcementLevel` `(string: <required>)` - Specifies the enforcement level of the policy. Can be `advisory` which warns on failure,
    87      `hard-mandatory` which prevents an operation on failure, and `soft-mandatory` which is like `hard-mandatory` but can be overridden.
    88  
    89  - `Policy` `(string: <required>)` - Specifies the Sentinel policy itself.
    90  
    91  ### Sample Payload
    92  
    93  ```json
    94  {
    95      "Name": "my-policy",
    96      "Description": "This is a great policy",
    97      "Scope": "submit-job",
    98      "EnforcementLevel": "advisory",
    99      "Policy": "main = rule { true }",
   100  }
   101  ```
   102  
   103  ### Sample Request
   104  
   105  ```text
   106  $ curl \
   107      --request POST \
   108      --data @payload.json \
   109      https://localhost:4646/v1/sentinel/policy/my-policy
   110  ```
   111  
   112  ## Read Policy
   113  
   114  This endpoint reads a Sentinel policy with the given name. This queries the policy that have been
   115  replicated to the region, and may lag behind the authoritative region.
   116  
   117  
   118  | Method | Path                         | Produces                   |
   119  | ------ | ---------------------------- | -------------------------- |
   120  | `GET` | `/sentinel/policy/:policy_name`   | `application/json`         |
   121  
   122  The table below shows this endpoint's support for
   123  [blocking queries](/api/index.html#blocking-queries), [consistency modes](/api/index.html#consistency-modes) and
   124  [required ACLs](/api/index.html#acls).
   125  
   126  | Blocking Queries | Consistency Modes | ACL Required |
   127  | ---------------- | ----------------- | ------------ |
   128  | `YES`            | `all`             | `management` |
   129  
   130  ### Sample Request
   131  
   132  ```text
   133  $ curl \
   134      https://localhost:4646/v1/sentinel/policy/foo
   135  ```
   136  
   137  ### Sample Response
   138  
   139  ```json
   140  {
   141    "Name": "foo",
   142    "Description": "test policy",
   143    "Scope": "submit-job",
   144    "EnforcementLevel": "advisory",
   145    "Policy": "main = rule { true }\n",
   146    "Hash": "CIs8aNX5OfFvo4D7ihWcQSexEJpHp+Za+dHSncVx5+8=",
   147    "CreateIndex": 8,
   148    "ModifyIndex": 8
   149  }
   150  ```
   151  
   152  ## Delete Policy
   153  
   154  This endpoint deletes the named Sentinel policy. This request is always forwarded to the
   155  authoritative region.
   156  
   157  | Method   | Path                         | Produces                   |
   158  | -------- | ---------------------------- | -------------------------- |
   159  | `DELETE` | `/sentinel/policy/:policy_name`   | `(empty body)`             |
   160  
   161  The table below shows this endpoint's support for
   162  [blocking queries](/api/index.html#blocking-queries) and
   163  [required ACLs](/api/index.html#acls).
   164  
   165  | Blocking Queries | ACL Required  |
   166  | ---------------- | ------------- |
   167  | `NO`             | `management`  |
   168  
   169  ### Parameters
   170  
   171  - `policy_name` `(string: <required>)` - Specifies the policy name to delete.
   172  
   173  ### Sample Request
   174  
   175  ```text
   176  $ curl \
   177      --request DELETE \
   178      https://localhost:4646/v1/sentinel/policy/foo
   179  ```
   180