File tree 4 files changed +38
-0
lines changed
4 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -236,6 +236,10 @@ declare module "replicate" {
236
236
| { max_instances : number }
237
237
)
238
238
) : Promise < Deployment > ;
239
+ delete (
240
+ deployment_owner : string ,
241
+ deployment_name : string
242
+ ) : Promise < boolean > ;
239
243
list ( ) : Promise < Page < Deployment > > ;
240
244
} ;
241
245
Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ class Replicate {
71
71
get : deployments . get . bind ( this ) ,
72
72
create : deployments . create . bind ( this ) ,
73
73
update : deployments . update . bind ( this ) ,
74
+ delete : deployments . delete . bind ( this ) ,
74
75
list : deployments . list . bind ( this ) ,
75
76
predictions : {
76
77
create : deployments . predictions . create . bind ( this ) ,
Original file line number Diff line number Diff line change @@ -999,6 +999,20 @@ describe("Replicate client", () => {
999
999
// Add more tests for error handling, edge cases, etc.
1000
1000
} ) ;
1001
1001
1002
+ describe ( "deployments.delete" , ( ) => {
1003
+ test ( "Calls the correct API route with the correct payload" , async ( ) => {
1004
+ nock ( BASE_URL )
1005
+ . delete ( "/deployments/acme/my-app-image-generator" )
1006
+ . reply ( 204 ) ;
1007
+
1008
+ const success = await client . deployments . delete (
1009
+ "acme" ,
1010
+ "my-app-image-generator"
1011
+ ) ;
1012
+ expect ( success ) . toBe ( true ) ;
1013
+ } ) ;
1014
+ } ) ;
1015
+
1002
1016
describe ( "deployments.list" , ( ) => {
1003
1017
test ( "Calls the correct API route" , async ( ) => {
1004
1018
nock ( BASE_URL )
Original file line number Diff line number Diff line change @@ -118,6 +118,24 @@ async function updateDeployment(
118
118
return response . json ( ) ;
119
119
}
120
120
121
+ /**
122
+ * Delete a deployment
123
+ *
124
+ * @param {string } deployment_owner - Required. The username of the user or organization who owns the deployment
125
+ * @param {string } deployment_name - Required. The name of the deployment
126
+ * @returns {Promise<boolean> } Resolves with true if the deployment was deleted
127
+ */
128
+ async function deleteDeployment ( deployment_owner , deployment_name ) {
129
+ const response = await this . request (
130
+ `/deployments/${ deployment_owner } /${ deployment_name } ` ,
131
+ {
132
+ method : "DELETE" ,
133
+ }
134
+ ) ;
135
+
136
+ return response . status === 204 ;
137
+ }
138
+
121
139
/**
122
140
* List all deployments
123
141
*
@@ -139,4 +157,5 @@ module.exports = {
139
157
create : createDeployment ,
140
158
update : updateDeployment ,
141
159
list : listDeployments ,
160
+ delete : deleteDeployment ,
142
161
} ;
You can’t perform that action at this time.
0 commit comments