def validateConfiguration(host,
                          entId,
                          key,
                          prefix="Bearer",
                          maxAttempt=Globals.MAX_RETRY):
    configuration = esperclient.Configuration()
    configuration.host = host
    configuration.api_key["Authorization"] = key
    configuration.api_key_prefix["Authorization"] = prefix

    api_instance = esperclient.EnterpriseApi(
        esperclient.ApiClient(configuration))
    enterprise_id = entId

    try:
        api_response = None
        for attempt in range(maxAttempt):
            try:
                api_response = api_instance.get_enterprise(enterprise_id)
                break
            except Exception as e:
                if attempt == maxAttempt - 1:
                    ApiToolLog().LogError(e)
                    raise e
                time.sleep(Globals.RETRY_SLEEP)
        if hasattr(api_response, "id"):
            return True
    except ApiException as e:
        print("Exception when calling EnterpriseApi->get_enterprise: %s\n" % e)
        ApiToolLog().LogError(e)
    return False
Пример #2
0
def get_enterprise_for_env():
    api_instance = esperclient.EnterpriseApi(esperclient.ApiClient(configuration))

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

    return api_response.results[0].id
Пример #3
0
def test_enterprise_list():
    api_instance = esperclient.EnterpriseApi(
        esperclient.ApiClient(configuration))

    # Enterprise list
    try:
        # List all enterprises
        api_response = api_instance.get_all_enterprises()
        # print(api_response)
    except ApiException as e:
        print(
            "Exception when calling EnterpriseApi->get_all_enterprises: %s\n" %
            e)

    assert (api_response.count == 1), "Only one enterprise supported"
Пример #4
0
def test_enterprise_partial_update():
    api_instance = esperclient.EnterpriseApi(
        esperclient.ApiClient(configuration))

    # Enterprise patch
    enterprise_id = get_enterprise_for_env()
    data = esperclient.EnterpriseUpdate(name='Shoonya Default Enterprise')

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

    assert api_response.name == "Shoonya Default Enterprise", "Enterprise name patch failed"
Пример #5
0
def test_enterprise_detail():
    api_instance = esperclient.EnterpriseApi(
        esperclient.ApiClient(configuration))

    # Enterprise detail
    enterprise_id = get_enterprise_for_env()

    try:
        # Get your enterprise information
        api_response = api_instance.get_enterprise(enterprise_id)
        #print(api_response)
    except ApiException as e:
        print("Exception when calling EnterpriseApi->get_enterprise: %s\n" % e)

    assert api_response.name is not None
    assert api_response.short_code is not None
    assert api_response.registered_name is not None
    assert api_response.registered_address is not None
    assert api_response.location is not None
    assert api_response.zipcode is not None
    assert api_response.contact_email is not None
Пример #6
0
 def get_enterprise_api_client(self):
     return client.EnterpriseApi(client.ApiClient(self.config))