Ejemplo n.º 1
0
def test_add_device_in_group():
    # create group
    api_instance = esperclient.DeviceGroupApi(
        esperclient.ApiClient(configuration))
    data = esperclient.DeviceGroup(name='TestBotGroup')  # DeviceGroup |

    try:
        api_response = api_instance.create_group(enterprise_id, data)
        print(api_response)
    except ApiException as e:
        print("Exception when calling DeviceGroupApi->create_group: %s\n" % e)

    assert api_response.id is not None, "Id cannot be None"
    assert api_response.device_count == 0, "Invalid device count"

    group_id = api_response.id
    devices = [
        '63325b67-1564-472a-9bd8-10728984231a',
        'cd2d9e3b-953c-482f-abbc-168910851bad'
    ]  #Add valid uuid
    data = esperclient.DeviceGroupUpdate(
        device_ids=devices)  # DeviceGroupUpdate

    try:
        # Partial update group
        api_response = api_instance.partial_update_group(
            group_id, enterprise_id, data)
        print(api_response)
    except ApiException as e:
        print(
            "Exception when calling DeviceGroupApi->partial_update_group: %s\n"
            % e)

    assert api_response.device_count == 2, "Invalid device count"
Ejemplo n.º 2
0
def get_group_for_enterprise(enterprise_id):
    api_instance = esperclient.DeviceGroupApi(esperclient.ApiClient(configuration))

    try:
        api_response = api_instance.get_all_groups(enterprise_id)
    except ApiException as e:
        print("Exception when calling DeviceGroupApi->get_all_groups: %s\n" % e)

    return api_response.results[0].id
Ejemplo n.º 3
0
def test_device_group_detail():
    # create an instance of the API class
    api_instance = esperclient.DeviceGroupApi(
        esperclient.ApiClient(configuration))

    try:
        # Get device group information
        api_response = api_instance.get_group_by_id(group_id, enterprise_id)
    except ApiException as e:
        print("Exception when calling DeviceGroupApi->get_group_by_id: %s\n" %
              e)

    assert api_response.id is not None, "Id cannot be null"
Ejemplo n.º 4
0
def test_list_device_group():
    api_instance = esperclient.DeviceGroupApi(
        esperclient.ApiClient(configuration))
    #name = 'name_example'  # str | filter by group name (optional)
    #limit = 20  # int | Number of results to return per page. (optional) (default to 20)
    #offset = 56  # int | The initial index from which to return the results. (optional)

    try:
        api_response = api_instance.get_all_groups(enterprise_id)
    except ApiException as e:
        print("Exception when calling DeviceGroupApi->get_all_groups: %s\n" %
              e)

    assert api_response.count > 0, "Atleast one device group is needed for testing"
    assert api_response.results[0].id is not None, "Id cannot be null"
Ejemplo n.º 5
0
def managed_configuration_all_groups():
    # create an instance of the API class
    api_instance = esperclient.DeviceGroupApi(esperclient.ApiClient(configuration))
    try:
        api_response = api_instance.get_all_groups(enterprise_id,
                                                    limit=configuration.per_page_limit,
                                                    offset=configuration.per_page_offset)
        if len(api_response.results):
            for group in api_response.results:
                # add all the devices in this group to global list of devices
                run_managed_configuration(group.id)
        #print(allgroups)

    except ApiException as e:
        print("Exception when calling DeviceGroupApi->get_all_groups: %s\n" % e)
Ejemplo n.º 6
0
def get_all_devices_in_enterprise():
    # create an instance of the API class
    api_instance = esperclient.DeviceGroupApi(
        esperclient.ApiClient(CONFIGURATION))
    try:
        api_response = api_instance.get_all_groups(
            ENTERPRISE_ID,
            limit=CONFIGURATION.per_page_limit,
            offset=CONFIGURATION.per_page_offset)
        if len(api_response.results):
            for group in api_response.results:
                # add all the devices in this group to global list of devices
                get_devices_in_group(group.id)

    except ApiException as e:
        print("Exception when calling DeviceGroupApi->get_all_groups: %s\n" %
              e)
def getDeviceGroupsForHost(config,
                           enterprise_id,
                           maxAttempt=Globals.MAX_RETRY):
    try:
        api_instance = esperclient.DeviceGroupApi(
            esperclient.ApiClient(config))
        api_response = None
        for attempt in range(maxAttempt):
            try:
                api_response = api_instance.get_all_groups(
                    enterprise_id, limit=Globals.limit, offset=Globals.offset)
                break
            except Exception as e:
                if attempt == maxAttempt - 1:
                    ApiToolLog().LogError(e)
                    raise e
                time.sleep(Globals.RETRY_SLEEP)
        return api_response
    except Exception as e:
        raise e
Ejemplo n.º 8
0
def test_create_device_group():
    # create group
    api_instance = esperclient.DeviceGroupApi(
        esperclient.ApiClient(configuration))
    data = esperclient.DeviceGroup(name='TestBotGroup')  # DeviceGroup |

    try:
        api_response = api_instance.create_group(enterprise_id, data)
        print(api_response)
    except ApiException as e:
        print("Exception when calling DeviceGroupApi->create_group: %s\n" % e)

    assert api_response.id is not None, "Id cannot be None"
    assert api_response.name == "TestBotGroup", "Invalid group name"

    # delete
    group_id = api_response.id
    try:
        api_instance.delete_group(group_id, enterprise_id)
    except ApiException as e:
        print("Exception when calling DeviceGroupApi->delete_group: %s\n" % e)
def createDeviceGroupForHost(config,
                             enterprise_id,
                             group,
                             maxAttempt=Globals.MAX_RETRY):
    try:
        api_instance = esperclient.DeviceGroupApi(
            esperclient.ApiClient(config))
        api_response = None
        for attempt in range(maxAttempt):
            try:
                api_response = api_instance.create_group(enterprise_id,
                                                         data={"name": group})
                break
            except Exception as e:
                if attempt == maxAttempt - 1:
                    ApiToolLog().LogError(e)
                    raise e
                time.sleep(Globals.RETRY_SLEEP)
        return api_response
    except Exception as e:
        raise e
def getAllGroups(maxAttempt=Globals.MAX_RETRY):
    """ Make a API call to get all Groups belonging to the Enterprise """
    try:
        api_instance = esperclient.DeviceGroupApi(
            esperclient.ApiClient(Globals.configuration))
        api_response = None
        for attempt in range(maxAttempt):
            try:
                api_response = api_instance.get_all_groups(
                    Globals.enterprise_id,
                    limit=Globals.limit,
                    offset=Globals.offset)
                break
            except Exception as e:
                if attempt == maxAttempt - 1:
                    ApiToolLog().LogError(e)
                    raise e
                time.sleep(Globals.RETRY_SLEEP)
        postEventToFrame(wxThread.myEVT_LOG, "---> Group API Request Finished")
        return api_response
    except ApiException as e:
        raise Exception(
            "Exception when calling DeviceGroupApi->get_all_groups: %s\n" % e)
Ejemplo n.º 11
0
 def get_group_api_client(self):
     return client.DeviceGroupApi(client.ApiClient(self.config))