Skip to content

Commit 6259d00

Browse files
authored
feat: Add delete_sysdig_capture method (#185)
1 parent 87a1454 commit 6259d00

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

sdcclient/_common.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,23 @@ def download_sysdig_capture(self, capture_id):
547547

548548
return True, res.content
549549

550+
def delete_sysdig_capture(self, capture_id):
551+
"""
552+
Removes an existing Sysdig Capture from Monitor
553+
554+
Args:
555+
capture_id: ID of the capture to remove
556+
557+
Returns: A touple of (bool, error) where the first value is false if there's an error and the second value is the error.
558+
"""
559+
560+
res = self.http.delete(f'{self.url}/api/sysdig/{capture_id}', headers=self.hdrs, verify=self.ssl_verify)
561+
562+
if not self._checkResponse(res):
563+
return False, self.lasterr
564+
565+
return True, None
566+
550567
def create_user(self, user_email, first_name=None, last_name=None, password=None):
551568
'''
552569
Provisions a new user to use Sysdig without sending an email notification.

specs/monitor/captures_v1_spec.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from expects import expect, have_key, contain
88
from expects.matchers import _Or
99
from expects.matchers.built_in import have_keys, equal
10-
from mamba import description, it, before
10+
from mamba import description, it, before, after
1111

1212
from sdcclient import SdMonitorClient
1313
from specs import be_successful_api_call
@@ -25,6 +25,14 @@ def randomword(length):
2525
self.capture_name = f"apicapture-sdk-{randomword(10)}"
2626
self.hostname = socket.gethostname()
2727

28+
with after.all:
29+
ok, res = self.client.get_sysdig_captures()
30+
expect((ok, res)).to(be_successful_api_call)
31+
32+
for capture in res["dumps"]:
33+
ok, res = self.client.delete_sysdig_capture(capture["id"])
34+
expect((ok, res)).to(be_successful_api_call)
35+
2836
with it("is able to create a capture"):
2937
ok, res = self.client.create_sysdig_capture(hostname=self.hostname,
3038
capture_name=self.capture_name,

0 commit comments

Comments
 (0)