File tree Expand file tree Collapse file tree 4 files changed +38
-0
lines changed Expand file tree Collapse file tree 4 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -236,6 +236,10 @@ declare module "replicate" {
236236 | { max_instances : number }
237237 )
238238 ) : Promise < Deployment > ;
239+ delete (
240+ deployment_owner : string ,
241+ deployment_name : string
242+ ) : Promise < boolean > ;
239243 list ( ) : Promise < Page < Deployment > > ;
240244 } ;
241245
Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ class Replicate {
7171 get : deployments . get . bind ( this ) ,
7272 create : deployments . create . bind ( this ) ,
7373 update : deployments . update . bind ( this ) ,
74+ delete : deployments . delete . bind ( this ) ,
7475 list : deployments . list . bind ( this ) ,
7576 predictions : {
7677 create : deployments . predictions . create . bind ( this ) ,
Original file line number Diff line number Diff line change @@ -999,6 +999,20 @@ describe("Replicate client", () => {
999999 // Add more tests for error handling, edge cases, etc.
10001000 } ) ;
10011001
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+
10021016 describe ( "deployments.list" , ( ) => {
10031017 test ( "Calls the correct API route" , async ( ) => {
10041018 nock ( BASE_URL )
Original file line number Diff line number Diff line change @@ -118,6 +118,24 @@ async function updateDeployment(
118118 return response . json ( ) ;
119119}
120120
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+
121139/**
122140 * List all deployments
123141 *
@@ -139,4 +157,5 @@ module.exports = {
139157 create : createDeployment ,
140158 update : updateDeployment ,
141159 list : listDeployments ,
160+ delete : deleteDeployment ,
142161} ;
You can’t perform that action at this time.
0 commit comments