-
-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add update method in connections api file
- Loading branch information
Showing
1 changed file
with
19 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; |