Example #1
0
    # configure the logging
    logging.basicConfig(level=config.roles['logging']["level"], datefmt="%m-%d-%Y %H:%M:%Srm ",
                        format="%(asctime)s %(name)s %(levelname)s: %(message)s",
                        handlers=[RotatingFileHandler(config.roles['logging']["file_name"], maxBytes=config.roles['logging']["max_bytes"], backupCount=config.roles['logging']['back_up_count'])])
    log = logging.getLogger(__name__)

    # time start
    time_util = xmatters.TimeCalc()
    start = time_util.get_time_now()
    log.info("Starting Process: " + time_util.format_date_time_now(start))

    # instantiate classes
    environment = xmatters.xMattersAPI(config.environment["url"], config.environment["username"], config.environment["password"])

    xm_roster = xmatters.xMattersRoster(environment)
    xm_person = xmatters.xMattersPerson(environment)
    xm_libraries = xmatters.xMattersLibraries(environment)
    xm_collection = xmatters.xMattersCollection(environment)

    # retrieve the group-roles mapping
    group_roles = None
    if config.roles['role_mapping']["enable_web_ui"]:
        libraries = xm_libraries.get_libraries(config.roles['role_mapping']["plan_name"])
        for script in libraries["data"]:
            if script["name"] == config.roles['role_mapping']["library_name"]:
                group_roles = json.loads(base64.b64decode(script["script"]))["data"]
                break
    else:
        with open(config.roles['role_mapping']["local_file_name"]) as f:  # read the json file
            group_roles = json.load(f)["data"]
Example #2
0
def main() -> object:

    xm_person = xmatters.xMattersPerson(environment)
    user = xm_person.get_person('mhenry')
    log.info("Received user: " + json.dumps(user))