Skip to content

Commit 714207f

Browse files
martindubejordan-wright
authored andcommitted
Added campaign completion feature. (gophish#3)
1 parent e1d48c9 commit 714207f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

gophish/api/api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ def __init__(self, api, endpoint=None, cls=None):
2525
self.endpoint = endpoint
2626
self._cls = cls
2727

28-
def get(self, resource_id=None):
28+
def get(self, resource_id=None, resource_action=None):
2929
""" Gets the details for one or more resources by ID
3030
3131
Args:
3232
cls - gophish.models.Model - The resource class
3333
resource_id - str - The endpoint (URL path) for the resource
34+
resource_action - str - An action to perform on the resource
3435
3536
Returns:
3637
One or more instances of cls parsed from the returned JSON
@@ -41,6 +42,9 @@ def get(self, resource_id=None):
4142
if resource_id:
4243
endpoint = '{}/{}'.format(endpoint, resource_id)
4344

45+
if resource_action:
46+
endpoint = '{}/{}'.format(endpoint, resource_action)
47+
4448
response = self.api.execute("GET", endpoint)
4549
if not response.ok:
4650
return Error.parse(response.json())

gophish/api/campaigns.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ def delete(self, campaign_id):
3030

3131
return super(API, self).delete(campaign_id)
3232

33+
def complete(self, campaign_id):
34+
""" Complete an existing campaign (Stop processing events) """
35+
36+
return super(API, self).get(resource_id=campaign_id,
37+
resource_action='complete')
38+
3339
def summary(campaign_id=None):
3440
""" Returns the summary of one or more campaigns. """
3541
raise NotImplementedError

0 commit comments

Comments
 (0)