You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
consul/ui/packages/consul-ui/app/adapters/partition.js

62 lines
1.5 KiB

import Adapter from './application';
import { SLUG_KEY } from 'consul-ui/models/partition';
// Blocking query support for partitions is currently disabled
export default class PartitionAdapter extends Adapter {
async requestForQuery(request, { ns, dc, index }) {
const respond = await request`
GET /v1/partitions?${{ dc }}
${{ index }}
`;
await respond((headers, body) => delete headers['x-consul-index']);
return respond;
}
// TODO: Not used until we do Partition CRUD
async requestForQueryRecord(request, { ns, dc, index, id }) {
if (typeof id === 'undefined') {
throw new Error('You must specify an id');
}
const respond = await request`
GET /v1/partition/${id}?${{ dc }}
${{ index }}
`;
await respond((headers, body) => delete headers['x-consul-index']);
return respond;
}
async requestForCreateRecord(request, serialized, data) {
return request`
PUT /v1/partition/${data[SLUG_KEY]}?${{
dc: data.Datacenter,
}}
${{
Name: serialized.Name,
Description: serialized.Description,
}}
`;
}
async requestForUpdateRecord(request, serialized, data) {
return request`
PUT /v1/partition/${data[SLUG_KEY]}?${{
dc: data.Datacenter,
}}
${{
Description: serialized.Description,
}}
`;
}
async requestForDeleteRecord(request, serialized, data) {
return request`
DELETE /v1/partition/${data[SLUG_KEY]}?${{
dc: data.Datacenter,
}}
`;
}
}