1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- from api.dcim.alarm_api import AlarmApi
- from api.dcim.login_api import LoginApi
- from api.dcim.assert_api import AssertApi
- from api.riil.utils import save_json
- class DcimApi(
- LoginApi,
- AlarmApi,
- AssertApi
- ):
- def __init__(self):
- super().__init__()
- self.headers = self.login().get('data')
- def save_alarm_current(self):
- page_index = 1
- alarm_list = []
- while True:
- data = self.get_alarm_current(page_index=page_index)
- alarm_list.extend(data.get('data', []))
- if page_index >= data.get('totalPage'):
- break
- page_index += 1
- save_json(alarm_list, "result/dcim/alarm_current.json")
- def save_alarm_history(self):
- page_index = 1
- alarm_list = []
- while True:
- data = self.get_alarm_current(page_index=page_index, is_history=True)
- alarm_list.extend(data.get('data', []))
- if page_index >= data.get('totalPage'):
- break
- page_index += 1
- save_json(alarm_list, "result/dcim/alarm_current.json")
- def save_capacity(self):
- page_index = 1
- capacity_list = []
- while True:
- data = self.get_capacity(page_index=page_index)
- capacity_list.extend(data.get('data', []))
- if page_index >= data.get('totalPage'):
- break
- page_index += 1
- save_json(capacity_list, "result/dcim/capacity.json")
- def save_assert(self):
- page_index = 1
- assert_list = []
- while True:
- data = self.get_assert(page_index=page_index)
- assert_list.extend(data.get('data', []))
- if page_index >= data.get('totalPage'):
- break
- page_index += 1
- save_json(assert_list, "result/dcim/assert.json")
- def save_customer_and_rack(self):
- page_index = 1
- customer_and_rack_list = []
- while True:
- data = self.get_customer_and_rack(page_index=page_index)
- customer_and_rack_list.extend(data.get('data', []))
- if page_index >= data.get('totalPage'):
- break
- page_index += 1
- save_json(customer_and_rack_list, "result/dcim/customer_and_rack.json")
- def save_customer_and_asset(self):
- page_index = 1
- customer_and_asset_list = []
- while True:
- data = self.get_customer_and_asset(page_index=page_index)
- customer_and_asset_list.extend(data.get('data', []))
- if page_index >= data.get('totalPage'):
- break
- page_index += 1
- save_json(customer_and_asset_list, "result/dcim/customer_and_asset.json")
|