import sys from pathlib import Path # Ensure the script can locate utils.py sys.path.append(str(Path(__file__).parent)) # Import custom functions from utils import * from config import * def sync_ad_groups(): # Getting total number of records url = f"{BASE_URL}/{WORKSPACE_ID}/v1/objecttype/{objectTypeId}" response = send_request(url, credentials, method="GET") objectCount = response.get('objectCount') # Fetching all records 1000 records per request url = f"{BASE_URL}/{WORKSPACE_ID}/v1/object/navlist/aql" #cmdb_df = fetch_all_records(url, credentials, objectCount, page_size=5000) cmdb_df = pd.read_csv("cmdb_df.csv") print(cmdb_df) # Save into csv file # cmdb_df.to_csv("cmdb_df.csv", index=False) # # Fetching ALL Ad Groups #ad_df = get_ad_groups_entries() ad_df = pd.read_csv("ad_df.csv") print(ad_df) # Save into csv file # ad_df.to_csv("ad_df.csv", index=False) # Get list of entries which should be set Inactive in CMDB to_be_set_inactive = rows_not_in_df2(cmdb_df, ad_df) print("Following records no longer exist") print(to_be_set_inactive) set_inactive_in_cmdb(to_be_set_inactive) # Get a list of entries to be created in CMDB to_be_created = rows_new_in_df2(cmdb_df, ad_df) print("Following records are new") print(to_be_created) create_new_in_cmdb(to_be_created) def main(): print("Starting data collection, processing and API calls...") # sync_zones() # sync_zone_groups() sync_ad_groups() print("Process completed successfully.") if __name__ == "__main__": main()