Comment on page
Groups
The groups endpoint allows you to create, view, and manage Gophish groups.
This example shows how to retrieve the name and size of every group in Gophish.
from gophish import Gophish
api_key = 'API_KEY'
api = Gophish(api_key)
for group in api.groups.get():
print '{} has {} users'.format(group.name, len(group.targets))
Attributes
id
(int) The user IDfirst_name
(str) The first namelast_name
(str) The last nameemail
(str) The email addressposition
(str) The position (job role)Methods__init__(self, **kwargs)
- Returns a new User Example:
A group contains one or more
models.User
objects. The group name must be unique.Attributes
id
(int) The group IDtargets
(list(models.User)) The group's usersname
(str) The group namemodified_date
(optional: datetime.datetime) The scheduled time for group launch
Methods
__init__(self, **kwargs)
- Returns a new Group
Example:
from gophish.models import *
targets = [
User(first_name='John', last_name='Doe', email='[email protected]'),
User(first_name='Jane', last_name='Doe', email='[email protected]')]
group = Group(name='Doe Company', targets=targets)
Gets the details for one or more groups. To get a particular group, set the ID to the group ID.
If the
group_id
is not set, all groups owned by the current user will be returned.Returns
- If the
group
is set:models.Group
- If
group_id
isNone
:list(models.Group)
Creates a new group. This endpoint requires you to submit a
gophish.models.Group
object.Returns
The
gophish.models.Group
object that was created.Edits an existing group. This endpoint requires you to submit an existing
gophish.models.Group
object with its id
attribute set correctly.Returns
The
gophish.models.Group
object that was edited.Deletes the group specified by
group_id
.Returns
A
gophish.models.Status
message.Here are some examples to show how to use the API.
All of these examples assume the following setup:
from gophish import Gophish
from gophish.models import *
api_key = 'API_KEY'
api = Gophish(api_key)
groups = api.groups.get()
group = api.groups.get(group_id=1)
targets = [
User(first_name='John', last_name='Doe', email='[email protected]'),
User(first_name='Jane', last_name='Doe', email='[email protected]')]
group = Group(name='Doe Company', targets=targets)
group = api.groups.post(group)
print group.id
Last modified 5yr ago