assert_api.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from common import config
  2. from common.util import req_api
  3. class AssertApi:
  4. def __init__(self):
  5. self.headers = None
  6. def get_assert(self, page_index: int = 10, page_size:int=4000, position_path:str = None, asset_status:list = None,
  7. dns:list = None):
  8. params = {}
  9. params['pageIndex'] = page_index
  10. params['pageSize'] = page_size
  11. if position_path is not None:
  12. params['positionPath'] = position_path
  13. if asset_status is not None:
  14. params['assetStatus'] = asset_status
  15. if dns is not None:
  16. params['dns'] = dns
  17. return req_api(f'{config.DCIM_BASE_URL}/rest/openapi/neteco/nbi/v2/assert', headers=self.headers,
  18. params=params)
  19. def get_capacity(self, page_index: int = 10, page_size:int=4000, dns:list = None):
  20. params = {}
  21. params['pageIndex'] = page_index
  22. params['pageSize'] = page_size
  23. if dns is not None:
  24. params['dns'] = dns
  25. return req_api(f'{config.DCIM_BASE_URL}/rest/openapi/neteco/capacity', headers=self.headers,
  26. params=params)
  27. def get_customer_and_rack(self, page_index: int = 10, page_size:int=4000, customer_ids:list = None):
  28. params = {}
  29. params['pageIndex'] = page_index
  30. params['pageSize'] = page_size
  31. if customer_ids is not None:
  32. params['customerIds'] = customer_ids
  33. return req_api(f'{config.DCIM_BASE_URL}/rest/openapi/neteco/nbi/asset/relation/customerAndRack',
  34. headers=self.headers, params=params)
  35. def get_customer_and_asset(self, page_index: int = 10, page_size:int=4000, customer_names:list = None):
  36. params = {}
  37. params['pageIndex'] = page_index
  38. params['pageSize'] = page_size
  39. if customer_names is not None:
  40. params['customerNames'] = customer_names
  41. return req_api(f'{config.DCIM_BASE_URL}/rest/openapi/neteco/nbi/v2/asset/relation/customerAndAsset',
  42. headers=self.headers, params=params)