示例#1
0
def component_types_csv(client):
    csv = []
    Helpers.append_line(csv, 'Component Type, attributes')

    all_components = VaultService.get_component_types(client)
    for defn in all_components:
        type = defn["type"]
        if len(defn["names"]) > 0:
            instance = defn["names"][0]
        else:
            instance = None

        attributes = get_attributes(client, 'configuration/{0}'.format(type))

        Helpers.append_line(csv, '{0},{1}'.format(type, attributes))

        if not instance:
            instance = "NONE"
            instance_attributes = ""
        else:
            instance_attributes = get_attributes(
                client, 'configuration/{0}.{1}'.format(type, instance))

        Helpers.append_line(
            csv, '{0}.{1},{2}'.format(type, instance, instance_attributes))

    return csv
示例#2
0
def get_component_type_names(client):
    component_types_json = VaultService.get_component_types(client)

    component_type_names = []
    for item in component_types_json:
        component_type_names.append(item["type"])

    return component_type_names
示例#3
0
def output_components(path, client, includeWorkflow):

    comps = VaultService.get_component_types(client)

    i = 0
    l = 0

    # build list of names first
    for component_json in comps:
        l += len(component_json["names"])

    printProgress.printProgress(i,
                                l,
                                prefix='Progress:',
                                suffix='Complete',
                                barLength=50)

    for component_json in comps:
        component_type = component_json["type"]
        type_folder = (path + "/%s") % (component_type)

        for component_name in component_json["names"]:

            if not os.path.exists(type_folder):
                os.makedirs(type_folder)

            name = component_type + "." + component_name
            if includeWorkflow and component_type == "Workflow":
                wf = VaultService.get_workflow(client, component_name)
                Helpers.dump_json_file(component_name, wf, type_folder + "/")
            else:
                with open(type_folder + "/" + component_name + ".mdl",
                          "w") as f:
                    mdl = VaultService.get_component(client, name)
                    f.write(mdl.encode('utf-8'))

            i += 1
            printProgress.printProgress(i,
                                        l,
                                        prefix='Progress:',
                                        suffix='Complete' + " - " + name,
                                        barLength=50)
示例#4
0
def main():
    print("------- data or collection? -------------")

    client = VaultService.get_client()
    instance_name = datetime.datetime.now()

    path = "../output/json_describe/"
    if not os.path.exists(path):
        os.makedirs(path)

    csv = component_types_csv(client)
    Helpers.save_as_file('{0}_{1}'.format(client.domain, instance_name),
                         ''.join(csv), path, 'csv')

    print("-----------DONE----------------------------")
示例#5
0
def main():
    print("""
 ______    _______  ___      _______  _______  ___   _______  __    _  _______  __   __  ___   _______  _______ 
|    _ |  |       ||   |    |   _   ||       ||   | |       ||  |  | ||       ||  | |  ||   | |       ||       |
|   | ||  |    ___||   |    |  |_|  ||_     _||   | |   _   ||   |_| ||  _____||  |_|  ||   | |    _  ||  _____|
|   |_||_ |   |___ |   |    |       |  |   |  |   | |  | |  ||       || |_____ |       ||   | |   |_| || |_____ 
|    __  ||    ___||   |___ |       |  |   |  |   | |  |_|  ||  _    ||_____  ||       ||   | |    ___||_____  |
|   |  | ||   |___ |       ||   _   |  |   |  |   | |       || | |   | _____| ||   _   ||   | |   |     _____| |
|___|  |_||_______||_______||__| |__|  |___|  |___| |_______||_|  |__||_______||__| |__||___| |___|    |_______|
    """)

    client = VaultService.get_client()

    components = mdl.get_component_definitions(client)

    create_files(components)
示例#6
0
文件: VCF.py 项目: defaultbob/Vault
def main():
    print """
    VCFVCFVCFVCFVCFVCFVCFVCFVCFVCFVCFVCF                                                     
    """

    client = VaultService.get_client()
    instance_name = datetime.datetime.now()

    path = "../output/VCF/%s/%s/" % (client.domain, instance_name)
    if not os.path.exists(path):
        os.makedirs(path)

    components = mdl.get_vcf_definitions(client)
    Helpers.dump_json_files(components, path)

    subprocess.Popen(["open", path])
示例#7
0
def main():

    print """
     ______                                             __      
    / ____/___  ____ ___  ____  ____  ____  ___  ____  / /______
    / /   / __ \/ __ `__ \/ __ \/ __ \/ __ \/ _ \/ __ \/ __/ ___/
    / /___/ /_/ / / / / / / /_/ / /_/ / / / /  __/ / / / /_(__  ) 
    \____/\____/_/ /_/ /_/ .___/\____/_/ /_/\___/_/ /_/\__/____/  
                                                                                    
    """

    client = VaultService.get_client()
    instance_name = datetime.datetime.now()
    path = "../output/MDL API/%s/%s" % (client.domain, instance_name)

    includeWorkflow = True
    output_components(path, client, includeWorkflow)
    print "Done"
示例#8
0
def main():
    print """
     _    ______    __       ______                                             __      
    | |  / / __ \  / /      / ____/___  ____ ___  ____  ____  ____  ___  ____  / /______
    | | / / / / / / /      / /   / __ \/ __ `__ \/ __ \/ __ \/ __ \/ _ \/ __ \/ __/ ___/
    | |/ / /_/ / / /___   / /___/ /_/ / / / / / / /_/ / /_/ / / / /  __/ / / / /_(__  ) 
    |___/\___\_\/_____/   \____/\____/_/ /_/ /_/ .___/\____/_/ /_/\___/_/ /_/\__/____/  
                                            /_/                                        
    """

    client = VaultService.get_client()
    instance_name = datetime.datetime.now()
    path = "../output/VQL/%s/%s" % (client.domain, instance_name)

    csv = output_components(path, client)
    Helpers.save_as_file('{0}_{1}'.format(client.domain, instance_name),
                         ''.join(csv), path, 'csv')

    print "Done"
示例#9
0
def main():
    print("""
  __ ___ ___ ___   ___ __  __ __ ___  __  __  _ ___ __  _ _____  
/' _| _,| __/ _/  / _//__\|  V  | _,\/__\|  \| | __|  \| |_   _| 
`._`| v_| _| \__ | \_| \/ | \_/ | v_| \/ | | ' | _|| | ' | | |   
|___|_| |___\__/  \__/\__/|_| |_|_|  \__/|_|\__|___|_|\__| |_|   
    """)

    client = VaultService.get_client()
    instance_name = datetime.datetime.now()

    picklist_mapping = get_picklist_value_mapping(client, 'data_type__c')

    component = 'Doclifecycle'
    component_id = ''
    components_resp = client.get_json('vobjects/component__c')
    for comp in components_resp["data"]:
        if comp["name__v"] == component:
            component_id = comp["id"]

    data_attributes = []

    attributes_response = client.get_json('vobjects/attribute__c')
    for attribute in attributes_response["data"]:
        id = attribute["id"]
        attr_resp = client.get_json('vobjects/attribute__c/' + id)
        attribute_data = attr_resp["data"]
        if attribute_data["component__c"] == component_id:
            attribute_json = build_attribute_metadata(attribute_data,
                                                      picklist_mapping)
            data_attributes.append(attribute_json)

    metadata = collections.OrderedDict()
    metadata["responseStatus"] = "SUCCESS"
    data = collections.OrderedDict()
    data["name"] = component
    data["attributes"] = data_attributes
    metadata["data"] = data

    Helpers.dump_json_file(component, metadata, '../output/')
    print(json.dumps(metadata, indent=4))
示例#10
0
def main():
    print("""
 _______ _______ _______ _______ _______ _______ _______ _______ 
|\     /|\     /|\     /|\     /|\     /|\     /|\     /|\     /|
| +---+ | +---+ | +---+ | +---+ | +---+ | +---+ | +---+ | +---+ |
| |   | | |   | | |   | | |   | | |   | | |   | | |   | | |   | |
| |M  | | |A  | | |R  | | |K  | | |D  | | |O  | | |W  | | |N  | |
| +---+ | +---+ | +---+ | +---+ | +---+ | +---+ | +---+ | +---+ |
|/_____\|/_____\|/_____\|/_____\|/_____\|/_____\|/_____\|/_____\|
    """)
    
    client = VaultService.get_client()
    instance_name = datetime.datetime.now()

    components = mdl.get_component_definitions(client)
    components2 = copy.deepcopy(components)
    components3 = copy.deepcopy(components)

    dump_files(components)
    generate_component_string_files(components2)
    generate_component_pages(components3)
示例#11
0
def main():
    print """
     ___ ___    ___ ______   ____  ___     ____  ______   ____ 
    |   |   |  /  _]      | /    ||   \   /    ||      | /    |
    | _   _ | /  [_|      ||  o  ||    \ |  o  ||      ||  o  |
    |  \_/  ||    _]_|  |_||     ||  D  ||     ||_|  |_||     |
    |   |   ||   [_  |  |  |  _  ||     ||  _  |  |  |  |  _  |
    |   |   ||     | |  |  |  |  ||     ||  |  |  |  |  |  |  |
    |___|___||_____| |__|  |__|__||_____||__|__|  |__|  |__|__|                                                       
    """

    client = VaultService.get_client()
    instance_name = datetime.datetime.now()

    path = "../output/Metadata/%s/%s/" % (client.domain, instance_name)
    if not os.path.exists(path):
        os.makedirs(path)

    components = mdl.get_component_definitions(client)
    Helpers.dump_json_files(components, path)

    subprocess.Popen(["open", path])
示例#12
0
import VqlComponents
import VaultService
import datetime
import Components
#import subprocess
import os

print """
       __           __   __         __        __   ___ 
 |\/| |  \ |       /  ` /  \  |\/| |__)  /\  |__) |__  
 |  | |__/ |___    \__, \__/  |  | |    /~~\ |  \ |___ 
                                                       
"""

client = VaultService.get_client()
instance_name = datetime.datetime.now()

path = "../output/MDL Compare/%s/%s/" % (client.domain, instance_name)

path_mdl = path + "MDL"
Components.output_components(path_mdl, client)

path_vql = path + "VQL"
VqlComponents.output_components(path_vql, client)

# subprocess.Popen(["open", path])
os.system('bcomp "%s" "%s"' % (path_mdl, path_vql))
示例#13
0
def main():
    print("""
▓█████  ██▀███   ██▀███   ▒█████   ██▀███    ██████ 
▓█   ▀ ▓██ ▒ ██▒▓██ ▒ ██▒▒██▒  ██▒▓██ ▒ ██▒▒██    ▒ 
▒███   ▓██ ░▄█ ▒▓██ ░▄█ ▒▒██░  ██▒▓██ ░▄█ ▒░ ▓██▄   
▒▓█  ▄ ▒██▀▀█▄  ▒██▀▀█▄  ▒██   ██░▒██▀▀█▄    ▒   ██▒
░▒████▒░██▓ ▒██▒░██▓ ▒██▒░ ████▓▒░░██▓ ▒██▒▒██████▒▒
░░ ▒░ ░░ ▒▓ ░▒▓░░ ▒▓ ░▒▓░░ ▒░▒░▒░ ░ ▒▓ ░▒▓░▒ ▒▓▒ ▒ ░
 ░ ░  ░  ░▒ ░ ▒░  ░▒ ░ ▒░  ░ ▒ ▒░   ░▒ ░ ▒░░ ░▒  ░ ░
   ░     ░░   ░   ░░   ░ ░ ░ ░ ▒    ░░   ░ ░  ░  ░  
   ░  ░   ░        ░         ░ ░     ░           ░  
                                                    
    """)

    i = 0
    l = 0

    use_cache = True

    client = VaultService.get_client()
    instance_name = datetime.datetime.now()

    components = mdl.get_component_type_names(client, use_cache)
    l = len(components)
    printProgress.printProgress(i,
                                l,
                                prefix='Progress:',
                                suffix='Complete',
                                barLength=50)

    first = True
    for component_type in components:

        error_url = 'configuration/{0}/errors'.format(component_type)
        try:
            errors_resp = client.get_json(error_url)

            if first:

                create_markdown_file('common-errors', errors_resp, True)

                header = [
                    'Type', 'Code', 'Reason', 'Type', 'Developer message',
                    'End user message\n'
                ]
                Helpers.save_as_file('errors', ','.join(header),
                                     'output/errors/csv2', 'csv')

                #export_csv('errors', errors_resp, True)

                i += 1
                first = False

            create_markdown_file('{0}-errors'.format(component_type),
                                 errors_resp)
            #export_csv('errors', errors_resp)

            printProgress.printProgress(i,
                                        l,
                                        prefix='Progress:',
                                        suffix='Complete' + " - " +
                                        component_type,
                                        barLength=50)

        except ApiClient.ApiException:
            print('Failed to get errors for {0} from the API'.format(
                component_type))

        i += 1

    print('Done!')