def delete_segment(workspace, segment_name): title = "Are you sure?" options = [{ "option_name": "Yes", "operation": lambda: segments_api.delete_segment(workspace["id"], segment_name) }, { "option_name": "No", "go_back": True }] menu.select_operation(title, options)
def delete_definition(workspace, split, environment): title = "Are you sure?" options = [{ "option_name": "Yes", "operation": lambda: definitions_api.delete(workspace["id"], environment["name"], split["name"]) }, { "option_name": "No", "go_back": True }] menu.select_operation(title, options)
def newUserPrompt(): menu.info_message(text2art(f"Welcome to Split!")) options = [{ "option_name": "No, I need to create an account", "operation": lambda: signup.create_account() }, { "option_name": "Yes, take me to sign in", "operation": lambda: signin.sign_in() }, { "option_name": "Exit", "operation": exit }] title = f"Do you have an existing account?" menu.select_operation(title, options)
def manage_segment(workspace, segment_name): while True: environments = environments_api.list_environments(workspace["id"]) options = [] for environment in environments: definition = get_instance(workspace, segment_name, environment) option = environment if definition == None: option["option_name"] = "Create in " + option["name"] else: option["option_name"] = "Manage in " + option["name"] option["operation"] = lambda bound_option=option: manage_instance( workspace, segment_name, bound_option) options.append(option) options.append({ "option_name": "Delete segment", "operation": lambda: delete_segment(workspace, segment_name), "go_back": True }) options.append({"option_name": "Go back", "go_back": True}) title = "Managing segment: " + segment_name _, go_back = menu.select_operation(title, options) if go_back: return
def manage_segments(): workspace = core_selectors.selection_workspace() while True: segments = segments_api.list_segments(workspace["id"]) title = None if len(segments) == 0: title = "No segments exist yet" else: title = "Select segment to Manage" options = [] for segment in segments: option = segment option["option_name"] = segment["name"] option["operation"] = lambda bound_segment=segment: manage_segment( workspace, bound_segment["name"]) options.append(option) options.append({ "option_name": "Create a new segment", "operation": lambda: create_segment(workspace) }) options.append({"option_name": "Go back", "go_back": True}) _, go_back = menu.select_operation(title, options) if go_back: return
def manage_split(workspace, split): while True: environments = environments_api.list_environments(workspace["id"]) options = [] for environment in environments: definition = definition_selectors.get_definition_operator( workspace["id"], environment["name"], split["name"]) option = environment if definition == None: option["option_name"] = "Create in " + option["name"] else: option["option_name"] = "Manage in " + option["name"] option[ "operation"] = lambda bound_option=option: definition_selectors.manage_definition( workspace, split, bound_option) options.append(option) options.append({ "option_name": "Delete split", "operation": lambda: delete_split(workspace, split), "go_back": True }) options.append({"option_name": "Go back", "go_back": True}) title = "Managing split: " + split["name"] _, go_back = menu.select_operation(title, options) if go_back: return
def select_treatments(): title = "Select Treatments" options = [{ "option_name": "Simple Rollout - on & off treatments", "operation": lambda: (["on", "off"], "off") }, { "option_name": "Custom & Multivariant - create any treatments needed", "operation": lambda: input_treatments() }] selection, _ = menu.select_operation(title, options) return selection
def knownUserPrompt(user): menu.info_message(text2art(f"Hi {user.firstname}!!!")) options = [ { "option_name": "Manage Splits", "operation": split_selectors.manage_splits }, { "option_name": "Manage Segments", "operation": segment_selectors.manage_segments }, # {"option_name": "Manage Metrics", "operation": metric_selectors.manage_metrics}, # {"option_name": "Manage Organization", "operation": organization_selectors.manage_organization}, { "option_name": "Log Out", "operation": lambda: user.delete() }, { "option_name": "Exit", "operation": exit } ] title = "Select" menu.select_operation(title, options)
def manage_instance(workspace, segment_name, environment): while True: segment = get_instance(workspace, segment_name, environment) if segment == None: segments_api.activate_segment(segment_name, environment['name']) else: title = "Managing " + segment["trafficType"][ "name"] + " segment \"" + segment_name + "\" in " + environment[ "name"] options = [] # options.append({"option_name": "Show keys", "operation": lambda: show_keys(segment_name, environment)}) # options.append({"option_name": "Add keys", "operation": lambda: add_keys(segment_name, environment)}) # options.append({"option_name": "Remove keys", "operation": lambda: remove_keys(segment_name, environment)}) # options.append({"option_name": "Upload CSV", "operation": lambda: upload_csv(segment_name, environment)}) options.append({"option_name": "Go back", "go_back": True}) _, go_back = menu.select_operation(title, options) if go_back: return
def manage_definition(workspace, split, environment): while True: definition = get_definition_operator(workspace["id"], environment["name"], split["name"]) if definition == None: (treatments, baseline) = select_treatments() create_definition_operator(workspace["id"], environment["name"], split["name"], treatments, baseline) else: title = "Managing " + split["name"] + " in " + environment["name"] options = [] options.append({ "option_name": "Show full definition JSON", "operation": lambda: show_definition_json(definition) }) options.append({ "option_name": "Target keys", "operation": lambda: target_keys(workspace, split, environment, definition) }) options.append({ "option_name": "Target segments", "operation": lambda: target_segments(workspace, split, environment, definition) }) options.append({ "option_name": "Ramp split", "operation": lambda: ramp_split(workspace, split, environment, definition) }) if definition.get("killed", False): options.append({ "option_name": "Restore", "operation": lambda: restore_definition(workspace, split, environment) }) else: options.append({ "option_name": "Kill", "operation": lambda: kill_definition(workspace, split, environment) }) options.append({ "option_name": "Delete definition", "go_back": True, "operation": lambda: delete_definition(workspace, split, environment) }) options.append({"option_name": "Go back", "go_back": True}) show_definition(definition) _, go_back = menu.select_operation(title, options) if go_back: return