コード例 #1
0
def test_application_upload_delete():
    # upload
    api_instance = esperclient.ApplicationApi(
        esperclient.ApiClient(configuration))
    enterprise = enterprise_id

    try:
        api_response = api_instance.upload(enterprise_id, enterprise, app_file)
        print(api_response)
    except ApiException as e:
        print("Exception when calling ApplicationApi->upload: %s\n" % e)

    assert api_response.application.is_active, "application not successful, app not active"
    assert len(
        api_response.application.versions) > 0, "No version present for app"

    # delete
    application_id = api_response.application.id
    try:
        # Delete an application
        api_instance.delete_application(application_id, enterprise_id)
    except ApiException as e:
        print(
            "Exception when calling ApplicationApi->delete_application: %s\n" %
            e)
コード例 #2
0
def getAllApplications(maxAttempt=Globals.MAX_RETRY):
    """ Make a API call to get all Applications belonging to the Enterprise """
    try:
        api_instance = esperclient.ApplicationApi(
            esperclient.ApiClient(Globals.configuration))
        api_response = None
        for attempt in range(maxAttempt):
            try:
                api_response = api_instance.get_all_applications(
                    Globals.enterprise_id,
                    limit=Globals.limit,
                    offset=Globals.offset,
                    is_hidden=False,
                )
                break
            except Exception as e:
                if attempt == maxAttempt - 1:
                    ApiToolLog().LogError(e)
                    raise e
                time.sleep(Globals.RETRY_SLEEP)
        postEventToFrame(wxThread.myEVT_LOG, "---> App API Request Finished")
        return api_response
    except ApiException as e:
        raise Exception(
            "Exception when calling ApplicationApi->get_all_applications: %s\n"
            % e)
コード例 #3
0
def getAllApplicationsForHost(config,
                              enterprise_id,
                              maxAttempt=Globals.MAX_RETRY):
    """ Make a API call to get all Applications belonging to the Enterprise """
    try:
        api_instance = esperclient.ApplicationApi(
            esperclient.ApiClient(config))
        api_response = None
        for attempt in range(maxAttempt):
            try:
                api_response = api_instance.get_all_applications(
                    enterprise_id,
                    limit=Globals.limit,
                    offset=0,
                    is_hidden=False,
                )
                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 Exception(
            "Exception when calling ApplicationApi->get_all_applications: %s\n"
            % e)
コード例 #4
0
def getInstallDevices(version_id,
                      application_id,
                      maxAttempt=Globals.MAX_RETRY):
    api_instance = esperclient.ApplicationApi(
        esperclient.ApiClient(Globals.configuration))
    enterprise_id = Globals.enterprise_id
    for attempt in range(maxAttempt):
        try:
            # List install devices
            api_response = api_instance.get_install_devices(
                version_id,
                application_id,
                enterprise_id,
                limit=Globals.limit,
                offset=Globals.offset,
            )
            return api_response
        except ApiException as e:
            if attempt == maxAttempt - 1:
                ApiToolLog().LogError(e)
                print(
                    "Exception when calling ApplicationApi->get_install_devices: %s\n"
                    % e)
                raise e
            time.sleep(1)
コード例 #5
0
def getAppVersions(application_id,
                   version_code="",
                   build_number="",
                   maxAttempt=Globals.MAX_RETRY):
    api_instance = esperclient.ApplicationApi(
        esperclient.ApiClient(Globals.configuration))
    enterprise_id = Globals.enterprise_id
    for attempt in range(maxAttempt):
        try:
            api_response = api_instance.get_app_versions(
                application_id,
                enterprise_id,
                version_code=version_code,
                build_number=build_number,
                limit=Globals.limit,
                offset=Globals.offset,
            )
            return api_response
        except Exception as e:
            if attempt == maxAttempt - 1:
                ApiToolLog().LogError(e)
                print(
                    "Exception when calling ApplicationApi->get_app_versions: %s\n"
                    % e)
                raise e
            time.sleep(1)
コード例 #6
0
ファイル: utils.py プロジェクト: tr0n-p46/esper-client-py
def get_version_for_app(application_id, enterprise_id):
    api_instance = esperclient.ApplicationApi(esperclient.ApiClient(configuration))

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

    return api_response.results[0].id
コード例 #7
0
 def __init__(self, host, key, eid):
     self.eid = eid
     self.configuration = esperclient.Configuration()
     self.configuration.host = f"https://{host}-api.esper.cloud/api"
     self.configuration.api_key['Authorization'] = key
     self.configuration.api_key_prefix['Authorization'] = 'Bearer'
     self.app_api_instance = esperclient.ApplicationApi(
         esperclient.ApiClient(self.configuration))
     self.cmd_api_instance = esperclient.CommandsV2Api(
         esperclient.ApiClient(self.configuration))
     self.dev_api_instance = esperclient.DeviceApi(
         esperclient.ApiClient(self.configuration))
コード例 #8
0
def getApplication(application_id):
    api_instance = esperclient.ApplicationApi(
        esperclient.ApiClient(Globals.configuration))
    enterprise_id = Globals.enterprise_id
    try:
        # Get application information
        api_response = api_instance.get_application(application_id,
                                                    enterprise_id)
        return api_response
    except ApiException as e:
        print("Exception when calling ApplicationApi->get_application: %s\n" %
              e)
コード例 #9
0
def test_app_version_detail():
    api_instance = esperclient.ApplicationApi(
        esperclient.ApiClient(configuration))

    try:
        api_response = api_instance.get_app_version(version_id, application_id,
                                                    enterprise_id)
        #print(api_response)
    except ApiException as e:
        print("Exception when calling ApplicationApi->get_app_version: %s\n" %
              e)

    assert api_response.id is not None, "Id cannot be None"
コード例 #10
0
def test_application_list():
    api_instance = esperclient.ApplicationApi(
        esperclient.ApiClient(configuration))

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

    assert api_response.count > 0, "At least one application is needed for testing"
    assert api_response.results[0].id is not None, "Id cannot be null"
コード例 #11
0
def test_app_version_delete():
    api_instance = esperclient.ApplicationApi(
        esperclient.ApiClient(configuration))
    version_id = '2b233cc3-ec02-4319-8601-43edcd5a3ed7'  # replace with valid uui
    application_id = 'c968e4a2-7e30-49fd-a548-85f11f05e972'  # replace with valid uuid

    try:
        # Delete app version
        api_instance.delete_app_version(version_id, application_id,
                                        enterprise_id)
    except ApiException as e:
        print(
            "Exception when calling ApplicationApi->delete_app_version: %s\n" %
            e)
コード例 #12
0
def test_app_version_list():
    api_instance = esperclient.ApplicationApi(
        esperclient.ApiClient(configuration))
    #version_code = 'version_code_example'  # str | filter by version code (optional)
    #build_number = 'build_number_example'  # str | filter by build number (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_app_versions(application_id,
                                                     enterprise_id)
        #print(api_response)
    except ApiException as e:
        print("Exception when calling ApplicationApi->get_app_versions: %s\n" %
              e)

    assert api_response.count > 0, "No active version is present"
    assert api_response.results[0].id is not None, "Id cannot be None"
コード例 #13
0
def getAppVersion(version_id, application_id, maxAttempt=Globals.MAX_RETRY):
    api_instance = esperclient.ApplicationApi(
        esperclient.ApiClient(Globals.configuration))
    enterprise_id = Globals.enterprise_id
    for attempt in range(maxAttempt):
        try:
            # Get app version information
            api_response = api_instance.get_app_version(
                version_id, application_id, enterprise_id)
            return api_response
        except ApiException as e:
            if attempt == maxAttempt - 1:
                ApiToolLog().LogError(e)
                print(
                    "Exception when calling ApplicationApi->get_app_version: %s\n"
                    % e)
                raise e
            time.sleep(1)
コード例 #14
0
def uploadApplicationForHost(config,
                             enterprise_id,
                             file,
                             maxAttempt=Globals.MAX_RETRY):
    try:
        api_instance = esperclient.ApplicationApi(
            esperclient.ApiClient(config))
        api_response = None
        for attempt in range(maxAttempt):
            try:
                api_response = api_instance.upload(enterprise_id, file)
                break
            except Exception as e:
                if attempt == maxAttempt - 1:
                    ApiToolLog().LogError(e)
                    raise e
                time.sleep(Globals.RETRY_SLEEP)
        return api_response
    except ApiException as e:
        raise Exception("Exception when calling ApplicationApi->upload: %s\n" %
                        e)
コード例 #15
0
def get_app_id(package_name, version_code):
    try:
        app_api_instance = esperclient.ApplicationApi(
            esperclient.ApiClient(CONFIGURATION))
        response = app_api_instance.get_all_applications(ENTERPRISE_ID)
        i = 0  # loop over all the packages in system

        while (response is not None and i < response.count):
            # found the package already present in the environment
            if response.results[i] and response.results[
                    i].package_name == package_name:
                version_len = (len(response.results[i].versions))

                # if version_code is none, then use the first version provided to install
                j = 0  # loop over all the versions of this app
                while (j < version_len and version_code is not None):
                    if response.results[i].versions is not None and \
                            response.results[i].versions[j].version_code == version_code:
                        # found the same version code to install, store the j value to use
                        # else use the first instance of App version given
                        break
                    else:
                        j = j + 1

                if j == version_len:
                    # this means that specific version code is not found in the list, do nothing
                    # bail out from here
                    print("Version not found")
                    return None

                # Here will come if version found or no version is provided to install
                app_version_id = response.results[i].versions[j].id
                return app_version_id
            else:
                # check for next package in list
                i = i + 1
    except Exception as exception:
        print("Exception when calling CommandsApi->run_command: %s\n" %
              exception)
    return None
コード例 #16
0
ファイル: api_client.py プロジェクト: ammar2168/esper-cli
 def get_application_api_client(self):
     return client.ApplicationApi(client.ApiClient(self.config))