|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +""" |
| 3 | +Lacework TeamUsers API wrapper (Experimental). |
| 4 | +""" |
| 5 | + |
| 6 | +from laceworksdk.api.crud_endpoint import CrudEndpoint |
| 7 | +import logging |
| 8 | +logger = logging.getLogger(__name__) |
| 9 | + |
| 10 | +class TeamUsersAPI(CrudEndpoint): |
| 11 | + def __init__(self, session): |
| 12 | + super().__init__(session, "TeamUsers") |
| 13 | + |
| 14 | + def get(self, guid=None): |
| 15 | + """ |
| 16 | + (Experimental API) A method to get TeamUsers objects. |
| 17 | +
|
| 18 | + :param guid: A string representing the object GUID. |
| 19 | +
|
| 20 | + :return response json |
| 21 | + """ |
| 22 | + |
| 23 | + return super().get(id=guid) |
| 24 | + |
| 25 | + def get_by_guid(self, guid): |
| 26 | + """ |
| 27 | + (Experimental API) A method to get a TeamUsers object by GUID. |
| 28 | +
|
| 29 | + :param guid: A string representing the object GUID. |
| 30 | +
|
| 31 | + :return response json |
| 32 | + """ |
| 33 | + |
| 34 | + return self.get(guid=guid) |
| 35 | + |
| 36 | + def create(self, |
| 37 | + name, |
| 38 | + email=None, |
| 39 | + company=None, |
| 40 | + description=None, |
| 41 | + type="StandardUser", |
| 42 | + **request_params): |
| 43 | + """ |
| 44 | + (Experimental API) A method to create a new TeamUsers standard user object. |
| 45 | +
|
| 46 | + :param name: A string representing the friendly name of the user. |
| 47 | + :param email: A string representing the email address of the user (valid only for StandardUser). |
| 48 | + :param company: A string representing the company of the user (valid only for StandardUser). |
| 49 | + :param description: A description text for describing service accounts (valid only for ServiceUser). |
| 50 | + :param type: A string representing the type of the user to create. |
| 51 | + (StandardUser or ServiceUser) |
| 52 | + :param request_params: Additional request parameters. |
| 53 | + (provides support for parameters that may be added in the future) |
| 54 | +
|
| 55 | + :return response json |
| 56 | + """ |
| 57 | + |
| 58 | + return super().create( |
| 59 | + name=name, |
| 60 | + email=email, |
| 61 | + description=description, |
| 62 | + company=company, |
| 63 | + type=type, |
| 64 | + **request_params |
| 65 | + ) |
| 66 | + |
| 67 | + def update(self, |
| 68 | + guid, |
| 69 | + name=None, |
| 70 | + user_enabled=None, |
| 71 | + description=None, |
| 72 | + **request_params): |
| 73 | + """ |
| 74 | + (Experimental API) A method to update a TeamUsers object. |
| 75 | +
|
| 76 | + :param guid: A string representing the object GUID. |
| 77 | + :param name: A string representing the friendly name of the object. |
| 78 | + :param userEnabled: A boolean/integer representing whether the object is enabled. |
| 79 | + (0 or 1) |
| 80 | + :param description: A description text for describing service accounts (only valid for service accounts). |
| 81 | +
|
| 82 | + :return response json |
| 83 | + """ |
| 84 | + |
| 85 | + if user_enabled is not None: |
| 86 | + user_enabled = int(bool(user_enabled)) |
| 87 | + |
| 88 | + return super().update( |
| 89 | + id=guid, |
| 90 | + name=name, |
| 91 | + user_enabled=user_enabled, |
| 92 | + description=description, |
| 93 | + **request_params |
| 94 | + ) |
| 95 | + |
| 96 | + def delete(self, guid): |
| 97 | + """ |
| 98 | + (Experimental API) A method to delete a TeamUsers object. |
| 99 | +
|
| 100 | + :param guid: A string representing the object GUID. |
| 101 | +
|
| 102 | + :return response json |
| 103 | + """ |
| 104 | + |
| 105 | + return super().delete(id=guid) |
0 commit comments