コード例 #1
0
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 __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))
コード例 #3
0
from __future__ import print_function
import sys
import time
import argparse
import requests
import esperclient
from esperclient.rest import ApiException

ACTIVE_DEVICE_LIST = []
INACTIVE_DEVICE_LIST = []

#### Enterprise Configuration #######

# Please fill the varibales under <>
CONFIGURATION = esperclient.Configuration()
CONFIGURATION.host = 'https://<endpoint-name>-api.shoonyacloud.com/api'
CONFIGURATION.api_key['Authorization'] = '<API-KEY>'
CONFIGURATION.api_key_prefix['Authorization'] = 'Bearer'
ENTERPRISE_ID = '<ENTERPRISE-ID>'

# int | Number of results to return per page. (optional) (default to 20)
CONFIGURATION.per_page_limit = 5000
# int | The initial index from which to return the results.(optional) default to 0)
CONFIGURATION.per_page_offset = 0

###############################
"""
Whitelist the package name on the device using API
"""
コード例 #4
0
import esperclient
from esperclient.rest import ApiException
from utils import get_esper_credentials, get_enterprise_for_env

esper_creds = get_esper_credentials()

# Configuration
configuration = esperclient.Configuration()
configuration.host = esper_creds.get('host')
configuration.api_key['Authorization'] = esper_creds.get('key')
configuration.api_key_prefix['Authorization'] = 'Bearer'


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"


def test_enterprise_detail():
コード例 #5
0
 def getEsperConfig(self, host, apiKey, auth="Bearer"):
     configuration = esperclient.Configuration()
     configuration.host = host.replace("/v0/enterprise/", "")
     configuration.api_key["Authorization"] = apiKey
     configuration.api_key_prefix["Authorization"] = auth
     return configuration