예제 #1
0
    def Device(self, **kwargs):  # pylint: disable=invalid-name
        """
        Get a Device object pre-initialised with this API client

        Allowed parameters are documented on the
            :py:class:`fleet.models.Device` class

        :returns: :py:class:`fl33t.models.Device`
        """
        return Device(client=self, **kwargs)
예제 #2
0
    def get_device(self, device_id):
        """
        Get a device by ID from fl33t.

        :param str device_id: The device ID to retrieve information for
        :returns: :py:class:`fl33t.models.Device`
        :raises InvalidDeviceIdError: if the device does not exist
        :raises UnprivilegedToken: if the session token does not have enough
            privilege to perform this action
        :raises Fl33tApiException: if there was a 5xx error returned by fl33t
        """

        url = "/".join((self.base_team_url, 'device/{}'.format(device_id)))

        result = self.get(url)

        if result.status_code in (400, 404):
            raise InvalidDeviceIdError(device_id)

        if 'device' in result.json():
            device = result.json()['device']
            return Device(client=self, **device)

        raise Fl33tApiException(ENDPOINT_FAILED_MSG.format('device retrieval'))
예제 #3
0
def test_checkin_no_client():
    device = Device(device_id='asdfasd')
    with pytest.raises(Fl33tClientException):
        device.checkin()
예제 #4
0
def test_create_no_client():
    device = Device(device_id='asdfasd')
    with pytest.raises(Fl33tClientException):
        device.create()
예제 #5
0
def test_no_device_id():
    with pytest.raises(ValueError):
        device = Device()