def remove_dependency_raw(id=None, name=None, dependency_id=None, dependency_name=None):
    found_id = common.set_id(pnc_api.build_configs, id, name)
    found_dep_id = common.set_id(pnc_api.build_configs, dependency_id, dependency_name)

    response = utils.checked_api_call(pnc_api.build_configs, 'remove_dependency', id=found_id, dependency_id=found_dep_id)
    if response:
        return response.content
def add_dependency_raw(id=None, name=None, dependency_id=None, dependency_name=None):
    add_to = common.set_id(pnc_api.build_configs, id, name)
    to_add = common.set_id(pnc_api.build_configs, dependency_id, dependency_name)

    dependency = pnc_api.build_configs.get_specific(id=to_add).content
    response = utils.checked_api_call(pnc_api.build_configs, 'add_dependency', id=add_to, body=dependency)
    if response:
        return response.content
def remove_build_configuration_from_set_raw(set_id=None, set_name=None, config_id=None, config_name=None):
    config_set_id = common.set_id(pnc_api.build_group_configs, set_id, set_name)
    bc_id = common.set_id(pnc_api.build_configs, config_id, config_name)
    response = utils.checked_api_call(
        pnc_api.build_group_configs,
        'remove_configuration',
        id=config_set_id,
        config_id=bc_id)
    if response:
        return response.content
Exemple #4
0
def remove_build_configuration_from_set(set_id=None, set_name=None, config_id=None, config_name=None):
    config_set_id = common.set_id(sets_api, set_id, set_name)
    bc_id = common.set_id(configs_api, config_id, config_name)
    response = utils.checked_api_call(
        sets_api,
        'remove_configuration',
        id=config_set_id,
        config_id=bc_id)
    if response:
        return utils.format_json(response.content)
def remove_build_configuration_from_set_raw(set_id=None, set_name=None, config_id=None, config_name=None):
    config_set_id = common.set_id(pnc_api.build_group_configs, set_id, set_name)
    bc_id = common.set_id(pnc_api.build_configs, config_id, config_name)
    response = utils.checked_api_call(
        pnc_api.build_group_configs,
        'remove_configuration',
        id=config_set_id,
        config_id=bc_id)
    if response:
        return response.content
def add_dependency(id=None, name=None, dependency_id=None, dependency_name=None):
    """
    Add an existing BuildConfiguration as a dependency to another BuildConfiguration.
    """
    add_to = common.set_id(configs_api, id, name)
    to_add = common.set_id(configs_api, dependency_id, dependency_name)

    dependency = configs_api.get_specific(id=to_add).content
    response = utils.checked_api_call(configs_api, 'add_dependency', id=add_to, body=dependency)
    if response:
        return utils.format_json(response.content)
def remove_dependency(id=None, name=None, dependency_id=None, dependency_name=None):
    """
    Remove a BuildConfiguration from the dependency list of another BuildConfiguration
    """

    found_id = common.set_id(configs_api, id, name)
    found_dep_id = common.set_id(configs_api, dependency_id, dependency_name)

    response = utils.checked_api_call(configs_api, 'remove_dependency', id=found_id, dependency_id=found_dep_id)
    if response:
        return utils.format_json(response.content)
def add_build_configuration_to_set_raw(
        set_id=None, set_name=None, config_id=None, config_name=None):
    config_set_id = common.set_id(pnc_api.build_group_configs, set_id, set_name)
    bc_id = common.set_id(pnc_api.build_configs, config_id, config_name)
    bc = common.get_entity(pnc_api.build_configs, bc_id)
    response = utils.checked_api_call(
        pnc_api.build_group_configs,
        'add_configuration',
        id=config_set_id,
        body=bc)
    if response:
        return response.content
def add_build_configuration_to_set_raw(
        set_id=None, set_name=None, config_id=None, config_name=None):
    config_set_id = common.set_id(sets_api, set_id, set_name)
    bc_id = common.set_id(configs_api, config_id, config_name)
    bc = common.get_entity(configs_api, bc_id)
    response = utils.checked_api_call(
        sets_api,
        'add_configuration',
        id=config_set_id,
        body=bc)
    if response:
        return response.content
Exemple #10
0
def remove_dependency_raw(id=None,
                          name=None,
                          dependency_id=None,
                          dependency_name=None):
    found_id = common.set_id(pnc_api.build_configs, id, name)
    found_dep_id = common.set_id(pnc_api.build_configs, dependency_id,
                                 dependency_name)

    response = utils.checked_api_call(pnc_api.build_configs,
                                      'remove_dependency',
                                      id=found_id,
                                      dependency_id=found_dep_id)
    if response:
        return response.content
Exemple #11
0
def add_dependency_raw(id=None,
                       name=None,
                       dependency_id=None,
                       dependency_name=None):
    add_to = common.set_id(pnc_api.build_configs, id, name)
    to_add = common.set_id(pnc_api.build_configs, dependency_id,
                           dependency_name)

    dependency = pnc_api.build_configs.get_specific(id=to_add).content
    response = utils.checked_api_call(pnc_api.build_configs,
                                      'add_dependency',
                                      id=add_to,
                                      body=dependency)
    if response:
        return response.content
Exemple #12
0
def add_build_configuration_to_set(
        set_id=None, set_name=None, config_id=None, config_name=None):
    """
    Add a build configuration to an existing BuildConfigurationSet
    """
    config_set_id = common.set_id(sets_api, set_id, set_name)
    bc_id = common.set_id(configs_api, config_id, config_name)
    bc = common.get_entity(configs_api, bc_id)
    response = utils.checked_api_call(
        sets_api,
        'add_configuration',
        id=config_set_id,
        body=bc)
    if response:
        return utils.format_json(response.content)
def add_product_version_to_build_configuration_raw(id=None, name=None, product_version_id=None):
    found_id = common.set_id(pnc_api.build_configs, id, name)

    to_add = common.get_entity(pnc_api.product_versions, product_version_id)
    response = utils.checked_api_call(pnc_api.build_configs, 'add_product_version', id=found_id, body=to_add)
    if response:
        return response.content
def build(id=None,
          name=None,
          temporary_build=False,
          timestamp_alignment=False,
          no_build_dependencies=False,
          keep_pod_on_failure=False,
          force_rebuild=False):
    """
    Trigger a BuildConfiguration by name or ID
    """
    if temporary_build is False and timestamp_alignment is True:
        print(
            "Error: You can only activate timestamp alignment with the temporary build flag!"
        )
        sys.exit(1)

    trigger_id = common.set_id(configs_api, id, name)

    response = utils.checked_api_call(
        configs_api,
        'trigger',
        id=trigger_id,
        temporary_build=temporary_build,
        timestamp_alignment=timestamp_alignment,
        build_dependencies=not no_build_dependencies,
        keep_pod_on_failure=keep_pod_on_failure,
        force_rebuild=force_rebuild)
    if response:
        return response.content
def delete_environment(id=None, name=None):
    """
    Delete an environment by name or ID
    """
    found_id = common.set_id(envs_api, id, name)
    response = utils.checked_api_call(envs_api, 'delete', id=found_id)
    return response
Exemple #16
0
def build_set_raw(id=None,
                  name=None,
                  tempbuild=False,
                  timestamp_alignment=False,
                  force=False):
    """
    Start a build of the given BuildConfigurationSet
    """
    logging.debug("temp_build: " + str(tempbuild))
    logging.debug("timestamp_alignment: " + str(timestamp_alignment))
    logging.debug("force: " + str(force))
    if tempbuild is False and timestamp_alignment is True:
        logging.error(
            "You can only activate timestamp alignment with the temporary build flag!"
        )
        sys.exit(1)

    found_id = common.set_id(pnc_api.build_group_configs, id, name)
    response = utils.checked_api_call(pnc_api.build_group_configs,
                                      'build',
                                      id=found_id,
                                      temporary_build=tempbuild,
                                      timestamp_alignment=timestamp_alignment,
                                      force_rebuild=force)
    if response:
        return response.content
Exemple #17
0
def get_environment_raw(id=None, name=None):
    search_id = common.set_id(pnc_api.environments, id, name)
    response = utils.checked_api_call(pnc_api.environments,
                                      'get_specific',
                                      id=search_id)
    if response:
        return response.content
def get_environment(id=None, name=None):
    """
    Get a specific Environment by name or ID
    """
    search_id = common.set_id(envs_api, id, name)
    response = utils.checked_api_call(envs_api, 'get_specific', id=search_id)
    return response.content
Exemple #19
0
def get_build_configuration_raw(id=None, name=None):
    found_id = common.set_id(pnc_api.build_configs, id, name)
    response = utils.checked_api_call(pnc_api.build_configs,
                                      'get_specific',
                                      id=found_id)
    if response:
        return response.content
def build_raw(id=None, name=None, revision=None,
          temporary_build=False, timestamp_alignment=False,
          no_build_dependencies=False,
          keep_pod_on_failure=False,
          force_rebuild=False,
          rebuild_mode=common.REBUILD_MODES_DEFAULT):

    if temporary_build is False and timestamp_alignment is True:
        print("Error: You can only activate timestamp alignment with the temporary build flag!")
        sys.exit(1)

    trigger_id = common.set_id(pnc_api.build_configs, id, name)

    if revision:
        response = utils.checked_api_call(pnc_api.build_configs, 'trigger_audited',
                                          id=trigger_id, rev=revision,
                                          temporary_build=temporary_build,
                                          timestamp_alignment=timestamp_alignment,
                                          build_dependencies=not no_build_dependencies,
                                          keep_pod_on_failure=keep_pod_on_failure,
                                          force_rebuild=force_rebuild,
                                          rebuild_mode=rebuild_mode)
    else:
        response = utils.checked_api_call(pnc_api.build_configs, 'trigger',
                                          id=trigger_id,
                                          temporary_build=temporary_build,
                                          timestamp_alignment=timestamp_alignment,
                                          build_dependencies=not no_build_dependencies,
                                          keep_pod_on_failure=keep_pod_on_failure,
                                          force_rebuild=force_rebuild,
                                          rebuild_mode=rebuild_mode)
    if response:
        return response.content
def delete_build_configuration_set_raw(id=None, name=None):
    set_id = common.set_id(pnc_api.build_group_configs, id, name)
    response = utils.checked_api_call(pnc_api.build_group_configs,
                                      'delete_specific',
                                      id=set_id)
    if response:
        return response.content
Exemple #22
0
def delete_project_raw(id=None, name=None):
    proj_id = common.set_id(pnc_api.projects, id, name)
    response = utils.checked_api_call(pnc_api.projects,
                                      'delete_specific',
                                      id=proj_id)
    if response:
        return response.content
Exemple #23
0
def get_product_raw(id=None, name=None):
    prod_id = common.set_id(pnc_api.products, id, name)
    if prod_id is None:
        return None
    response = utils.checked_api_call(pnc_api.products, 'get_specific', id=prod_id)
    if response:
        return response.content
def list_product_versions_for_build_configuration_raw(id=None, name=None, page_size=200, page_index=0, sort="", q=""):
    found_id = common.set_id(pnc_api.build_configs, id, name)
    response = utils.checked_api_call(pnc_api.build_configs, 'get_product_versions', id=found_id, page_size=page_size,
                                      page_index=page_index, sort=sort,
                                      q=q)
    if response:
        return response.content
def get_build_configuration_set_raw(id=None, name=None):
    """
    Get a specific BuildConfigurationSet by name or ID
    """
    found_id = common.set_id(pnc_api.build_group_configs, id, name)
    response = utils.checked_api_call(pnc_api.build_group_configs, 'get_specific', id=found_id)
    if response:
        return response.content
Exemple #26
0
def get_build_configuration_set_raw(id=None, name=None):
    """
    Get a specific BuildConfigurationSet by name or ID
    """
    found_id = common.set_id(sets_api, id, name)
    response = utils.checked_api_call(sets_api, 'get_specific', id=found_id)
    if response:
        return response.content
Exemple #27
0
def list_build_configurations_for_set(id=None, name=None, page_size=200, sort="", q=""):
    """
    List all build configurations in a given BuildConfigurationSet.
    """
    found_id = common.set_id(sets_api, id, name)
    response = utils.checked_api_call(sets_api, 'get_configurations', id=found_id, page_size=page_size, sort=sort, q=q)
    if response:
        return utils.format_json_list(response.content)
Exemple #28
0
def get_product(id=None, name=None):
    """
    Get a specific Product by name or ID
    """
    prod_id = common.set_id(products_api, id, name)
    response = utils.checked_api_call(products_api, 'get_specific', id=prod_id)
    if response:
        return utils.format_json(response.content)
Exemple #29
0
def get_revision_of_build_configuration_raw(revision_id, id=None, name=None):
    found_id = common.set_id(pnc_api.build_configs, id, name)
    response = utils.checked_api_call(pnc_api.build_configs,
                                      'get_revision',
                                      id=found_id,
                                      rev=revision_id)
    if response:
        return response.content
Exemple #30
0
def get_project_raw(id=None, name=None):
    """
    Get a specific Project by ID or name
    """
    proj_id = common.set_id(projects_api, id, name)
    response = utils.checked_api_call(projects_api, 'get_specific', id=proj_id)
    if response:
        return response.content
Exemple #31
0
def build_set_raw(id=None, name=None, force = False):
    """
    Start a build of the given BuildConfigurationSet
    """
    found_id = common.set_id(sets_api, id, name)
    response = utils.checked_api_call(sets_api, 'build', id=found_id, rebuild_all=force)
    if response:
        return response.content
def list_revisions_of_build_configuration(id=None, name=None, page_size=200, sort=""):
    """
    List audited revisions of a BuildConfiguration
    """
    found_id = common.set_id(configs_api, id, name)
    response = utils.checked_api_call(configs_api, 'get_revisions', id=found_id, page_size=page_size, sort=sort)
    if response:
        return utils.format_json_list(response.content)
Exemple #33
0
def list_build_set_records(id=None, name=None, page_size=200, page_index=0, sort="", q=""):
    """
    List all build set records for a BuildConfigurationSet
    """
    found_id = common.set_id(sets_api, id, name)
    response = utils.checked_api_call(sets_api, 'get_all_build_config_set_records', id=found_id, page_size=page_size, page_index=page_index, sort=sort, q=q)
    if response:
        return utils.format_json_list(response.content)
def get_revision_of_build_configuration(id=None, name=None, revision_id=None):
    """
    Get a specific audited revision of a BuildConfiguration
    """
    found_id = common.set_id(configs_api, id, name)
    response = utils.checked_api_call(configs_api, 'get_revision', id=found_id, rev=revision_id)
    if response:
        return utils.format_json(response.content)
def build(id=None, name=None):
    """
    Trigger a BuildConfiguration by name or ID
    """
    trigger_id = common.set_id(configs_api, id, name)

    response = utils.checked_api_call(configs_api, 'trigger', id=trigger_id)
    if response:
        return response.content
def get_build_configuration(id=None, name=None):
    """
    Retrieve a specific BuildConfiguration
    """
    found_id = common.set_id(configs_api, id, name)

    response = utils.checked_api_call(configs_api, 'get_specific', id=found_id)
    if response:
        return response.content
Exemple #37
0
def list_versions_for_product_raw(id=None, name=None, page_size=200, page_index=0, sort='', q=''):
    """
    List all ProductVersions for a given Product
    """
    prod_id = common.set_id(products_api, id, name)
    response = utils.checked_api_call(
        products_api, 'get_product_versions', id=prod_id, page_size=page_size, page_index=page_index, sort=sort, q=q)
    if response:
        return response.content
Exemple #38
0
def remove_product_version_from_build_configuration_raw(
        id=None, name=None, product_version_id=None):
    found_id = common.set_id(pnc_api.build_configs, id, name)
    response = utils.checked_api_call(pnc_api.build_configs,
                                      'remove_product_version',
                                      id=found_id,
                                      product_version_id=product_version_id)
    if response:
        return response.content
def delete_build_configuration_raw(id=None, name=None):
    to_delete_id = common.set_id(pnc_api.build_configs, id, name)
    # ensure that this build configuration is not a dependency of any other build configuration.
    # list_build_configurations is an insufficient check because eventually there will be too many entities to check them all.
    # a better REST method for dependency checking is needed
    for config in list_build_configurations_raw(page_size=1000000000):
        dep_ids = [str(val) for val in config.dependency_ids]
        if dep_ids is not None and str(to_delete_id) in dep_ids:
            raise CommandError(
                "BuildConfiguration ID {} is a dependency of BuildConfiguration {}.".format(to_delete_id, config.name))

    response = utils.checked_api_call(pnc_api.build_configs, 'delete_specific', id=to_delete_id)
    if response:
        return response.content
def build_set_raw(id=None, name=None,
                  tempbuild=False, timestamp_alignment=False,
                  force=False, rebuild_mode=common.REBUILD_MODES_DEFAULT,
                  **kwargs):
    """
    Start a build of the given BuildConfigurationSet
    """
    logging.debug("temp_build: " + str(tempbuild))
    logging.debug("timestamp_alignment: " + str(timestamp_alignment))
    logging.debug("force: " + str(force))
    if tempbuild is False and timestamp_alignment is True:
        logging.error("You can only activate timestamp alignment with the temporary build flag!")
        sys.exit(1)

    found_id = common.set_id(pnc_api.build_group_configs, id, name)

    revisions = kwargs.get("id_revisions")
    if revisions:
        id_revs = map(__parse_revision, revisions)

        bcsRest = common.get_entity(pnc_api.build_group_configs, found_id)
        body = swagger_client.BuildConfigurationSetWithAuditedBCsRest()
        body = __fill_BCSWithAuditedBCs_body(body, bcsRest, id_revs)

        response = utils.checked_api_call(pnc_api.build_group_configs, 'build_versioned', id=found_id,
                                          temporary_build=tempbuild,
                                          timestamp_alignment=timestamp_alignment,
                                          force_rebuild=force,
                                          rebuild_mode=rebuild_mode,
                                          body=body)
    else:
        response = utils.checked_api_call(pnc_api.build_group_configs, 'build', id=found_id,
                                      temporary_build=tempbuild,
                                      timestamp_alignment=timestamp_alignment,
                                      force_rebuild=force,
                                      rebuild_mode=rebuild_mode)
    if response:
        return response.content
def delete_build_configuration_set_raw(id=None, name=None):
    set_id = common.set_id(pnc_api.build_group_configs, id, name)
    response = utils.checked_api_call(pnc_api.build_group_configs, 'delete_specific', id=set_id)
    if response:
        return response.content
def remove_product_version_from_build_configuration_raw(id=None, name=None, product_version_id=None):
    found_id = common.set_id(pnc_api.build_configs, id, name)
    response = utils.checked_api_call(pnc_api.build_configs, 'remove_product_version', id=found_id,
                                      product_version_id=product_version_id)
    if response:
        return response.content
def list_build_configurations_for_product_version_raw(product_id, version_id, page_size=200, page_index=0, sort="", q=""):
    found_product_id = common.set_id(pnc_api.products, product_id, None)
    response = utils.checked_api_call(pnc_api.build_configs, 'get_all_by_product_version_id', product_id=found_product_id,
                                      version_id=version_id, page_size=page_size, page_index=page_index, sort=sort, q=q)
    if response:
        return response.content
def get_revision_of_build_configuration_raw(revision_id, id=None, name=None):
    found_id = common.set_id(pnc_api.build_configs, id, name)
    response = utils.checked_api_call(pnc_api.build_configs, 'get_revision', id=found_id, rev=revision_id)
    if response:
        return response.content
Exemple #45
0
def get_environment_raw(id=None, name=None):
    search_id = common.set_id(pnc_api.environments, id, name)
    response = utils.checked_api_call(pnc_api.environments, 'get_specific', id=search_id)
    if response:
        return response.content
Exemple #46
0
def delete_project_raw(id=None, name=None):
    proj_id = common.set_id(pnc_api.projects, id, name)
    response = utils.checked_api_call(pnc_api.projects, 'delete_specific', id=proj_id)
    if response:
        return response.content
Exemple #47
0
def test_set_id():
    result = common.set_id(None, 1, None)
    assert result == 1
Exemple #48
0
def test_set_id_name(mock):
    mock_api = create_autospec(BuildconfigurationsApi)
    result = common.set_id(mock_api, None, 'anotherone')
    mock.assert_called_once_with(mock_api, 'anotherone')
    assert result == 2
Exemple #49
0
def list_records_for_build_configuration_raw(id=None, name=None, page_size=200, page_index=0, sort="", q=""):
    config_id = common.set_id(pnc_api.build_configs, id, name)
    response = utils.checked_api_call(pnc_api.builds, 'get_all_for_build_configuration', configuration_id=config_id,
                                      page_size=page_size, page_index=page_index, sort=sort, q=q)
    if response:
        return response.content
Exemple #50
0
def list_records_for_project_raw(id=None, name=None, page_size=200, page_index=0, sort="", q=""):
    project_id = common.set_id(pnc_api.projects, id, name)
    response = utils.checked_api_call(pnc_api.builds, 'get_all_for_project_0', project_id=project_id, page_size=page_size, page_index=page_index,
                                      sort=sort, q=q)
    if response:
        return response.content
def list_build_set_records_raw(id=None, name=None, page_size=200, page_index=0, sort="", q=""):
    found_id = common.set_id(pnc_api.build_group_configs, id, name)
    response = utils.checked_api_call(pnc_api.build_group_configs, 'get_all_build_config_set_records', id=found_id, page_size=page_size, page_index=page_index, sort=sort, q=q)
    if response:
        return response.content
Exemple #52
0
def test_set_id_exception():
    with pytest.raises(argh.exceptions.CommandError):
        result = common.set_id(None, None, None)
def get_build_configuration_raw(id=None, name=None):
    found_id = common.set_id(pnc_api.build_configs, id, name)
    response = utils.checked_api_call(pnc_api.build_configs, 'get_specific', id=found_id)
    if response:
        return response.content