File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,12 @@ export default class Model extends ReplicateObject {
4040 return `GET /v1/models/${ this . owner } /${ this . name } /versions/${ this . version } ` ;
4141 }
4242
43+ async deleteVersion ( ) {
44+ await this . client . request (
45+ `DELETE /v1/models/${ this . owner } /${ this . name } /versions/${ this . version } `
46+ ) ;
47+ }
48+
4349 async predict (
4450 input ,
4551 { onUpdate, onTemporaryError } = { } ,
Original file line number Diff line number Diff line change @@ -69,6 +69,18 @@ describe("load()", () => {
6969 } ) ;
7070} ) ;
7171
72+ describe ( "deleteVersion()" , ( ) => {
73+ it ( "makes request to delete model version" , async ( ) => {
74+ jest . spyOn ( client , "request" ) . mockResolvedValue ( ) ;
75+
76+ await model . deleteVersion ( ) ;
77+
78+ expect ( client . request ) . toHaveBeenCalledWith (
79+ "DELETE /v1/models/test-owner/test-name/versions/testversion"
80+ ) ;
81+ } ) ;
82+ } ) ;
83+
7284describe ( "predict()" , ( ) => {
7385 it ( "makes request to create prediction" , async ( ) => {
7486 jest . spyOn ( model , "createPrediction" ) . mockResolvedValue (
Original file line number Diff line number Diff line change @@ -147,7 +147,7 @@ export default class ReplicateClient {
147147 }
148148
149149 #parseAction( action ) {
150- const result = / ^ ( G E T | P O S T ) ( \/ [ ^ \s ] + ) $ / . exec ( action ) ;
150+ const result = / ^ ( G E T | P O S T | D E L E T E ) ( \/ [ ^ \s ] + ) $ / . exec ( action ) ;
151151
152152 if ( ! result ) {
153153 throw new ReplicateError ( `Invalid action: ${ action } ` ) ;
You can’t perform that action at this time.
0 commit comments