Skip to content

Add function to lock a machine #1

Description

@dougpenny

Code below provided by Rick Schuler:

def classic_lock_computer(self, id: int) -> Union[str, None]:
    """
    Create a new class in Jamf Pro.

    Args:
        new_class (Computer Id):
            Integer Id of the Device to lock

    Returns:
        If creation is successful, the ID of the machine
        otherwise, None.
    """
    data = f"<computer_command><general><command>DeviceLock</command><passcode>885344</passcode></general><computers><computer><id>{id}</id></computer></computers></computer_command>"
    class_response: Response = self.make_api_request("/JSSResource/computercommands/command/DeviceLock", data=data, method=[jamf.HTTPMethod.POST](http://jamf.httpmethod.post/), classic=True)
    if class_response:
        if class_response.status_code == 201:
            xml_data = ET.fromstring(class_response.text)
            return xml_data.findtext('id')
    else:
        return None

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions