Skip to content

Commit

Permalink
Add update method in connections api file
Browse files Browse the repository at this point in the history
  • Loading branch information
pavish committed Nov 30, 2023
1 parent 3ad92b0 commit bf82d39
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions mathesar_ui/src/api/connections.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
import type { Database } from '@mathesar/AppTypes';
import { getAPI, type PaginatedResponse } from './utils/requestUtils';
import { getAPI, patchAPI, type PaginatedResponse } from './utils/requestUtils';

export type Connection = Database;

interface ConnectionWithPassword extends Connection {
password: string;
}

function list() {
return getAPI<PaginatedResponse<Database>>(
return getAPI<PaginatedResponse<Connection>>(
'/api/db/v0/connections/?limit=500',
);
}

function update(
connectionId: Connection['id'],
properties: Partial<Omit<ConnectionWithPassword, 'id' | 'nickname'>>,
) {
return patchAPI<Connection>(
`/api/db/v0/connections/${connectionId}/`,
properties,
);
}

export default {
list,
update,
};

0 comments on commit bf82d39

Please sign in to comment.