2021-12-14 22:04:02 +00:00
|
|
|
---
|
|
|
|
layout: api
|
|
|
|
page_title: Admin Partition - HTTP API
|
|
|
|
description: The /partition endpoints allow for managing Consul Enterprise Admin Partitions.
|
|
|
|
---
|
|
|
|
|
2022-02-25 04:31:25 +00:00
|
|
|
@include 'http_api_and_cli_characteristics_links.mdx'
|
|
|
|
|
2021-12-14 22:04:02 +00:00
|
|
|
# Admin Partition - HTTP API
|
|
|
|
|
|
|
|
<EnterpriseAlert />
|
|
|
|
|
|
|
|
The functionality described here is available only in
|
|
|
|
[Consul Enterprise](https://www.hashicorp.com/products/consul/) version 1.11.0 and later.
|
|
|
|
|
|
|
|
## Create a Partition
|
|
|
|
|
2022-02-25 04:31:25 +00:00
|
|
|
This endpoint creates a new partition and has the following characteristics:
|
2021-12-14 22:04:02 +00:00
|
|
|
|
2022-02-25 04:31:25 +00:00
|
|
|
| Characteristic | Value |
|
|
|
|
| -------------- | ----- |
|
2022-07-20 22:56:31 +00:00
|
|
|
| HTTP method | `PUT` |
|
|
|
|
| URL path | `/v1/partition` |
|
|
|
|
| Response type | `application/json` |
|
2022-02-25 04:31:25 +00:00
|
|
|
| [Required ACLs] | `operator:write` |
|
2022-07-20 22:56:31 +00:00
|
|
|
| Corresponding CLI command | [`consul partition create`](/commands/partition#create) |
|
|
|
|
| [Consistency modes] | N/A |
|
|
|
|
| [Blocking queries] | N/A |
|
|
|
|
| [Agent caching] | N/A |
|
2022-01-11 16:46:50 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### JSON Request Body Schema
|
2021-12-14 22:04:02 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `Name` `(string: <required>)` - The partition name. This field must be a valid
|
2021-12-14 22:04:02 +00:00
|
|
|
DNS hostname label.
|
|
|
|
|
|
|
|
- `Description` `(string: "")` - Free form partition description.
|
|
|
|
|
|
|
|
### Sample Payload
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"Name": "na-west",
|
2022-01-12 23:05:01 +00:00
|
|
|
"Description": "Partition for North America West"
|
2021-12-14 22:04:02 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Sample Request
|
|
|
|
|
|
|
|
```shell-session
|
2022-01-12 23:05:01 +00:00
|
|
|
$ curl ---request PUT \
|
|
|
|
--header "X-Consul-Token: 5cdcae6c-0cce-4210-86fe-5dff3b984a6e" \
|
2021-12-14 22:04:02 +00:00
|
|
|
--data @payload.json \
|
|
|
|
http://127.0.0.1:8500/v1/partition
|
|
|
|
```
|
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### Sample Response
|
2021-12-14 22:04:02 +00:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"Name": "na-west",
|
|
|
|
"Description": "Partition for North America West",
|
|
|
|
"CreateIndex": 55,
|
|
|
|
"ModifyIndex": 55
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Read a Partition
|
|
|
|
|
2022-02-25 04:31:25 +00:00
|
|
|
This endpoint reads a partition with the given name and has the following characteristics:
|
2021-12-14 22:04:02 +00:00
|
|
|
|
2022-02-25 04:31:25 +00:00
|
|
|
| Characteristic | Value |
|
|
|
|
| -------------- | ----- |
|
2022-07-20 22:56:31 +00:00
|
|
|
| HTTP method | `GET` |
|
|
|
|
| URL path | `/v1/partition/:name` |
|
|
|
|
| Response type | `application/json` |
|
2022-02-25 04:31:25 +00:00
|
|
|
| [Required ACLs] | `operator:read`; however, a non-anonymous token can always read its own partition |
|
2022-07-20 22:56:31 +00:00
|
|
|
| Corresponding CLI command | [`consul partition read`](/commands/partition#read) |
|
|
|
|
| [Consistency modes] | `default`, `consistent` |
|
|
|
|
| [Blocking queries] | No |
|
|
|
|
| [Agent caching] | No |
|
2022-01-11 16:46:50 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### Path Parameters
|
2021-12-14 22:04:02 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `name` `(string: <required>)` - Specifies the partition to read.
|
2021-12-14 22:04:02 +00:00
|
|
|
|
|
|
|
### Sample Request
|
|
|
|
|
|
|
|
```shell-session
|
2022-01-12 23:05:01 +00:00
|
|
|
$ curl --header "X-Consul-Token: b23b3cad-5ea1-4413-919e-c76884b9ad60" \
|
2021-12-14 22:04:02 +00:00
|
|
|
http://127.0.0.1:8500/v1/partition/na-west
|
|
|
|
```
|
|
|
|
|
2022-02-25 04:31:25 +00:00
|
|
|
### Sample Response
|
2021-12-14 22:04:02 +00:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"Name": "na-west",
|
|
|
|
"Description": "Partition for North America West",
|
|
|
|
"CreateIndex": 55,
|
|
|
|
"ModifyIndex": 55
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Update a Partition
|
|
|
|
|
2022-02-25 04:31:25 +00:00
|
|
|
This endpoint updates a partition description and has the following characteristics:
|
2021-12-14 22:04:02 +00:00
|
|
|
|
2022-02-25 04:31:25 +00:00
|
|
|
| Characteristic | Value |
|
|
|
|
| -------------- | ----- |
|
2022-07-20 22:56:31 +00:00
|
|
|
| HTTP method | `PUT` |
|
|
|
|
| URL path | `/v1/partition/:name` |
|
|
|
|
| Response type | `application/json` |
|
2022-02-25 04:31:25 +00:00
|
|
|
| [Required ACLs] | `operator:write` |
|
2022-07-20 22:56:31 +00:00
|
|
|
| Corresponding CLI command | [`consul partition write`](/commands/partition#write) |
|
|
|
|
| [Consistency modes] | N/A |
|
|
|
|
| [Blocking queries] | N/A |
|
|
|
|
| [Agent caching] | N/A |
|
2022-01-11 16:46:50 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### Path Parameters
|
|
|
|
|
|
|
|
- `name` `(string: <required>)` - Specifies the partition to update.
|
|
|
|
This parameter must be a valid DNS hostname label.
|
2021-12-14 22:04:02 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### JSON Request Body Schema
|
|
|
|
|
|
|
|
- `Name` `(string: <optional>)` - If specified, this field must be an exact match
|
|
|
|
with the `name` path parameter.
|
2021-12-14 22:04:02 +00:00
|
|
|
|
|
|
|
- `Description` `(string: "")` - Free form partition description.
|
|
|
|
|
|
|
|
### Sample Payload
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"Description": "North America West Partition"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Sample Request
|
|
|
|
|
|
|
|
```shell-session
|
2022-01-12 23:05:01 +00:00
|
|
|
$ curl --request PUT \
|
|
|
|
--header "X-Consul-Token: 5cdcae6c-0cce-4210-86fe-5dff3b984a6e" \
|
2021-12-14 22:04:02 +00:00
|
|
|
--data @payload.json \
|
|
|
|
http://127.0.0.1:8500/v1/partition/na-west
|
|
|
|
```
|
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### Sample Response
|
2021-12-14 22:04:02 +00:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"Name": "na-west",
|
|
|
|
"Description": "North America West Partition",
|
|
|
|
"CreateIndex": 55,
|
|
|
|
"ModifyIndex": 60
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Delete a Partition
|
|
|
|
|
2022-02-25 04:31:25 +00:00
|
|
|
This endpoint marks a partition for deletion. Once marked Consul will
|
2021-12-14 22:04:02 +00:00
|
|
|
deleted all the associated partitioned data in the background. Only once
|
2022-02-25 04:31:25 +00:00
|
|
|
all associated data has been deleted will the partition actually disappear.
|
2021-12-14 22:04:02 +00:00
|
|
|
Until then, further reads can be performed on the partition and a `DeletedAt`
|
2022-02-25 04:31:25 +00:00
|
|
|
field will now be populated with the timestamp of when the partition was
|
2021-12-14 22:04:02 +00:00
|
|
|
marked for deletion.
|
|
|
|
|
2022-02-25 04:31:25 +00:00
|
|
|
This endpoint has the following characteristics:
|
2021-12-14 22:04:02 +00:00
|
|
|
|
2022-02-25 04:31:25 +00:00
|
|
|
| Characteristic | Value |
|
|
|
|
| -------------- | ----- |
|
2022-07-20 22:56:31 +00:00
|
|
|
| HTTP method | `DELETE` |
|
|
|
|
| URL path | `/v1/partition/:name` |
|
|
|
|
| Response type | none; success or failure is indicated by the HTTP response status code |
|
2022-02-25 04:31:25 +00:00
|
|
|
| [Required ACLs] | `operator:write` |
|
2022-07-20 22:56:31 +00:00
|
|
|
| Corresponding CLI command | [`consul partition delete`](/commands/partition#delete) |
|
|
|
|
| [Consistency modes] | N/A |
|
|
|
|
| [Blocking queries] | N/A |
|
|
|
|
| [Agent caching] | N/A |
|
2022-01-11 16:46:50 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### Path Parameters
|
2021-12-14 22:04:02 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `name` `(string: <required>)` - Specifies the partition to delete.
|
2021-12-14 22:04:02 +00:00
|
|
|
|
|
|
|
### Sample Request
|
|
|
|
|
|
|
|
```shell-session
|
2022-01-12 23:05:01 +00:00
|
|
|
$ curl --request DELETE \
|
|
|
|
--header "X-Consul-Token: b23b3cad-5ea1-4413-919e-c76884b9ad60" \
|
2021-12-14 22:04:02 +00:00
|
|
|
http://127.0.0.1:8500/v1/partition/na-west
|
|
|
|
```
|
|
|
|
|
|
|
|
### Sample Read Output After Deletion Prior to Removal
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"Name": "na-west",
|
|
|
|
"Description": "North America West Partition",
|
|
|
|
"DeletedAt": "2021-12-14T23:00:00Z",
|
|
|
|
"CreateIndex": 55,
|
|
|
|
"ModifyIndex": 100
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## List all Partitions
|
|
|
|
|
2022-02-25 04:31:25 +00:00
|
|
|
This endpoint lists all the partitions and has the following characteristics:
|
|
|
|
|
|
|
|
| Characteristic | Value |
|
|
|
|
| -------------- | ----- |
|
2022-07-20 22:56:31 +00:00
|
|
|
| HTTP method | `GET` |
|
|
|
|
| URL path | `/v1/partitions` |
|
|
|
|
| Response type | `application/json` |
|
2022-02-25 04:31:25 +00:00
|
|
|
| [Required ACLs] | `operator:read` |
|
2022-07-20 22:56:31 +00:00
|
|
|
| Corresponding CLI command | [`consul partition list`](/commands/partition#list) |
|
|
|
|
| [Consistency modes] | `default`, `consistent` |
|
|
|
|
| [Blocking queries] | No |
|
|
|
|
| [Agent caching] | No |
|
2022-01-11 16:46:50 +00:00
|
|
|
|
2021-12-14 22:04:02 +00:00
|
|
|
### Sample Request
|
|
|
|
|
|
|
|
```shell-session
|
2022-01-12 23:05:01 +00:00
|
|
|
$ curl --header "X-Consul-Token: 0137db51-5895-4c25-b6cd-d9ed992f4a52" \
|
2021-12-14 22:04:02 +00:00
|
|
|
http://127.0.0.1:8500/v1/partitions
|
|
|
|
```
|
|
|
|
|
|
|
|
### Sample Response
|
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"Name": "default",
|
|
|
|
"Description": "Builtin Default Partition",
|
|
|
|
"CreateIndex": 6,
|
|
|
|
"ModifyIndex": 6
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Name": "na-west",
|
|
|
|
"Description": "North America West Partition",
|
|
|
|
"CreateIndex": 55,
|
|
|
|
"ModifyIndex": 55
|
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|