Esempio n. 1
0
def update_product_version(id, **kwargs):
    """
    Update the ProductVersion with ID id with new values.
    """
    content = update_product_version_raw(id, **kwargs)
    if content:
        return utils.format_json(content)
Esempio n. 2
0
def push_build_status(id):
    """
    Get status of Brew push.
    """
    response = utils.checked_api_call(pnc_api.build_push, 'status', build_record_id=id)
    if response:
        return utils.format_json(response)
Esempio n. 3
0
def update_release(id, **kwargs):
    """
    Update an existing ProductRelease with new information
    """
    data = update_release_raw(id, **kwargs)
    if data:
        return utils.format_json(data)
Esempio n. 4
0
def create_milestone(**kwargs):
    """
    Create a new ProductMilestone
    """
    data = create_milestone_raw(**kwargs)
    if data:
        return utils.format_json(data)
Esempio n. 5
0
def get_environment(id=None, name=None):
    """
    Get a specific Environment by name or ID
    """
    data = get_environment_raw(id, name)
    if data:
        return utils.format_json(data)
Esempio n. 6
0
def get_product_version(id):
    """
    Retrieve a specific ProductVersion by ProductVersion ID
    """
    content = get_product_version_raw(id)
    if content:
        return utils.format_json(content)
Esempio n. 7
0
def cancel_running_build(id):
    """
    Cancel running build with ID
    """
    data = cancel_running_build_raw(id)
    if data:
        return utils.format_json(data)
Esempio n. 8
0
def get_audited_configuration_for_record(id):
    """
    Get the BuildConfigurationAudited for a given BuildRecord
    """
    data = get_audited_configuration_for_record_raw(id)
    if data:
        return utils.format_json(data)
Esempio n. 9
0
def get_running_build(id):
    """
    Get info about a specific RunningBuild
    """
    content = get_running_build_raw(id)
    if content:
        return utils.format_json(content)
Esempio n. 10
0
def get_build_configuration(id=None, name=None):
    """
    Retrieve a specific BuildConfiguration
    """
    data = get_build_configuration_raw(id, name)
    if data:
        return utils.format_json(data)
Esempio n. 11
0
def get_build_record(id):
    """
    Get a specific BuildRecord by ID
    """
    data = get_build_record_raw(id)
    if data:
        return utils.format_json(data)
Esempio n. 12
0
def get_release(id):
    """
    Retrieve a specific ProductRelease
    """
    data = get_release_raw(id)
    if data:
        return utils.format_json(data)
Esempio n. 13
0
def update_milestone(id, **kwargs):
    """
    Update a ProductMilestone
    """
    data = update_milestone_raw(id, **kwargs)
    if data:
        return utils.format_json(data)
def get_build_configuration_set(id=None, name=None):
    """
    Get a specific BuildConfigurationSet by name or ID
    """
    content = get_build_configuration_set_raw(id, name)
    if content:
        return utils.format_json(content)
def create_build_configuration_set(**kwargs):
    """
    Create a new BuildConfigurationSet.
    """
    content = create_build_configuration_set_raw(**kwargs)
    if content:
        return utils.format_json(content)
def update_build_configuration_set(id, **kwargs):
    """
    Update a BuildConfigurationSet
    """
    data = update_build_configuration_set_raw(id, **kwargs)
    if data:
        return utils.format_json(data)
Esempio n. 17
0
def get_build_configuration_set_record(id):
    """
    Get a specific BuildConfigSetRecord
    """
    data = get_build_configuration_set_record_raw(id)
    if data:
        return utils.format_json(data)
Esempio n. 18
0
def delete_project(id=None, name=None):
    """
    Delete a Project by ID or name.
    """
    content = delete_project_raw(id, name)
    if content:
        return utils.format_json(content)
Esempio n. 19
0
def get_project(id=None, name=None):
    """
    Get a specific Project by ID or name
    """
    content = get_project_raw(id, name)
    if content:
        return utils.format_json(content)
Esempio n. 20
0
def update_project(id, **kwargs):
    """
    Update an existing Project with new information
    """
    content = update_project_raw(id, **kwargs)
    if content:
        return utils.format_json(content)
Esempio n. 21
0
def create_project(**kwargs):
    """
    Create a new Project. Typically, a Project represents a single source code repository, as well as the information related to development of those sources.
    """
    content = create_project_raw(**kwargs)
    if content:
        return utils.format_json(content)
Esempio n. 22
0
def create_build_configuration(**kwargs):
    """
    Create a new BuildConfiguration. BuildConfigurations represent the settings and configuration required to run a build of a specific version of the associated Project's source code.
    If a ProductVersion ID is provided, the BuildConfiguration will have access to artifacts which were produced for that version, but may not have been released yet.
    """
    data = create_build_configuration_raw(**kwargs)
    if data:
        return utils.format_json(data)
Esempio n. 23
0
def create_license(**kwargs):
    """
    Create a new License
    """
    License = create_license_object(**kwargs)
    response = utils.checked_api_call(pnc_api.licenses, 'create_new', body=License)
    if response:
        return utils.format_json(response.content)
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
    """
    content = add_build_configuration_to_set_raw(set_id, set_name, config_id, config_name)
    if content:
        return utils.format_json(content)
Esempio n. 25
0
def delete_license(license_id):
    """
    Delete a License by ID
    """

    response = utils.checked_api_call(pnc_api.licenses, 'delete', id=license_id)
    if response:
        return utils.format_json(response.content)
Esempio n. 26
0
def get_license(id):
    """
    Get a specific License by either ID or fullname
    """
    response = utils.checked_api_call(
        pnc_api.licenses, 'get_specific', id= id)
    if response:
        return utils.format_json(response.content)
def build_set(id=None, name=None, temporary_build=False, timestamp_alignment=False,
              force=False, rebuild_mode=common.REBUILD_MODES_DEFAULT, **kwargs):
    """
    Start a build of the given BuildConfigurationSet
    """
    content = build_set_raw(id, name,
                            temporary_build, timestamp_alignment, force, rebuild_mode, **kwargs)
    if content:
        return utils.format_json(content)
Esempio n. 28
0
def delete_build_configuration(id=None, name=None):
    """
    Delete an existing BuildConfiguration
    :param id:
    :param name:
    :return:
    """
    data = delete_build_configuration_raw(id, name)
    if data:
        return utils.format_json(data)
Esempio n. 29
0
def update_build_configuration(id, **kwargs):
    """
    Update an existing BuildConfiguration with new information

    :param id: ID of BuildConfiguration to update
    :param name: Name of BuildConfiguration to update
    :return:
    """
    data = update_build_configuration_raw(id, **kwargs)
    if data:
        return utils.format_json(data)
Esempio n. 30
0
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)
Esempio n. 31
0
def update_build_configuration(id, **kwargs):
    """
    Update an existing BuildConfiguration with new information

    :param id: ID of BuildConfiguration to update
    :param name: Name of BuildConfiguration to update
    :return:
    """
    data = update_build_configuration_raw(id, **kwargs)
    if data:
        return utils.format_json(data)
Esempio n. 32
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)
Esempio n. 33
0
def update_release(id, **kwargs):
    """
    Update an existing ProductRelease with new information
    """
    to_update = utils.checked_api_call(releases_api, 'get_specific', id=id).content
    for key, value in iteritems(kwargs):
        if value is not None:
            setattr(to_update, key, value)

    response = utils.checked_api_call(
        releases_api, 'update', id=id, body=to_update)
    if response:
        return utils.format_json(response.content)
Esempio n. 34
0
def list_build_configurations_for_product(id=None,
                                          name=None,
                                          page_size=200,
                                          page_index=0,
                                          sort="",
                                          q=""):
    """
    List all BuildConfigurations associated with the given Product.
    """
    data = list_build_configurations_for_product_raw(id, name, page_size,
                                                     page_index, sort, q)
    if data:
        return utils.format_json(data)
Esempio n. 35
0
def create_product_version(product_id, version, **kwargs):
    """
    Create a new ProductVersion.
    Each ProductVersion represents a supported product release stream, which includes milestones and releases typically associated with a single major.minor version of a Product.
    Follows the Red Hat product support cycle, and typically includes Alpha, Beta, GA, and CP releases with the same major.minor version.

    Example:
    ProductVersion 1.0 includes the following releases:
    1.0.Beta1, 1.0.GA, 1.0.1, etc.
    """
    data = create_product_version_raw(product_id, version, **kwargs)
    if data:
        return utils.format_json(data)
Esempio n. 36
0
def create_product_version(product_id, version, **kwargs):
    """
    Create a new ProductVersion.
    Each ProductVersion represents a supported product release stream, which includes milestones and releases typically associated with a single major.minor version of a Product.
    Follows the Red Hat product support cycle, and typically includes Alpha, Beta, GA, and CP releases with the same major.minor version.

    Example:
    ProductVersion 1.0 includes the following releases:
    1.0.Beta1, 1.0.GA, 1.0.1, etc.
    """
    data = create_product_version_raw(product_id, version, **kwargs)
    if data:
        return utils.format_json(data)
Esempio n. 37
0
def remove_product_version_from_build_configuration(id=None,
                                                    name=None,
                                                    product_version_id=None):
    """
    Remove a ProductVersion from association with a BuildConfiguration
    """
    found_id = common.set_id(configs_api, id, name)
    response = utils.checked_api_call(configs_api,
                                      'remove_product_version',
                                      id=found_id,
                                      product_version_id=product_version_id)
    if response:
        return utils.format_json(response.content)
Esempio n. 38
0
def update_build_configuration_set(id, **kwargs):
    """
    Update a BuildConfigurationSet
    """
    set_to_update = utils.checked_api_call(sets_api, 'get_specific', id=id).content

    for key, value in kwargs.items():
        if value is not None:
            setattr(set_to_update, key, value)

    response = utils.checked_api_call(sets_api, 'update', id=id, body=set_to_update)
    if response:
        return utils.format_json(response.content)
Esempio n. 39
0
def build_set(id=None,
              name=None,
              temporary_build=False,
              timestamp_alignment=False,
              force=False,
              **kwargs):
    """
    Start a build of the given BuildConfigurationSet
    """
    content = build_set_raw(id, name, temporary_build, timestamp_alignment,
                            force, **kwargs)
    if content:
        return utils.format_json(content)
Esempio n. 40
0
def update_product(product_id, **kwargs):
    """
    Update a Product with new information
    """
    to_update = products_api.get_specific(id=product_id).content

    for key, value in iteritems(kwargs):
        if value is not None:
            setattr(to_update, key, value)

    response = utils.checked_api_call(
        products_api, 'update', id=product_id, body=to_update)
    if response:
        return utils.format_json(response.content)
Esempio n. 41
0
def create_release(**kwargs):
    """
    Create a new ProductRelease.
    A ProductRelease represents a build / set of builds that is ready for release to the public.
    Each ProductRelease is associated with exactly one ProductMilestone and exactly one ProductVersion.

    Example:
    ProductVersion: 1.0
    ProductMilestone: 1.0.0.CR2
    ProductRelease: 1.0.0.GA
    """
    data = create_release_raw(**kwargs)
    if data:
        return utils.format_json(data)
Esempio n. 42
0
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
    """
    data = build_raw(id, name, temporary_build, timestamp_alignment,
                     no_build_dependencies, keep_pod_on_failure, force_rebuild)
    if data:
        return utils.format_json(data)
Esempio n. 43
0
def update_project(id, **kwargs):
    """
    Update an existing Project with new information
    """
    if utils.contains_only_none_values(kwargs):
        raise argh.exceptions.CommandError(
            "Updating a Project requires at least one modified field.")

    to_update = utils.checked_api_call(projects_api, 'get_specific',
                                       id=id).content
    for key, value in iteritems(kwargs):
        if value is not None:
            setattr(to_update, key, value)
    response = utils.checked_api_call(projects_api,
                                      'update',
                                      id=id,
                                      body=to_update)
    if response:
        return utils.format_json(response.content)
    else:
        return utils.format_json(
            utils.checked_api_call(projects_api, 'get_specific',
                                   id=id).content)
Esempio n. 44
0
def close_milestone(id, **kwargs):
    """
    Close a milestone. This triggers its release process.

    The user can optionally specify the release-date, otherwise today's date is
    used.

    If the wait parameter is specified and set to True, upon closing the milestone,
    we'll periodically check that the release being processed is done.

    Required:
    - id: int

    Optional:
    - release_date: string in format '<yyyy>-<mm>-<dd>'
    - wait key: bool
    """
    release_date = kwargs.get('release_date')
    if not release_date:
        release_date = datetime.datetime.now()

    existing_milestone = utils.checked_api_call(milestones_api,
                                                'get_specific',
                                                id=id).content
    setattr(existing_milestone, 'end_date', release_date)

    response = utils.checked_api_call(milestones_api,
                                      'update',
                                      id=id,
                                      body=existing_milestone)

    latest_release = utils.checked_api_call(milestones_api,
                                            'get_latest_release',
                                            id=id).content

    if kwargs.get('wait') == True:
        while latest_release.status == 'IN_PROGRESS':
            print(
                "Latest release for milestone is in progress, waiting till it finishes..."
            )
            time.sleep(60)
            latest_release = utils.checked_api_call(milestones_api,
                                                    'get_latest_release',
                                                    id=id).content

        print("Status of release for milestone: " + latest_release.status)

    if response:
        return utils.format_json(response.content)
Esempio n. 45
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)
Esempio n. 46
0
def add_product_version_to_build_configuration(id=None,
                                               name=None,
                                               product_version_id=None):
    """
    Associate an existing ProductVersion with a BuildConfiguration
    """
    found_id = common.set_id(configs_api, id, name)

    to_add = common.get_entity(versions_api, product_version_id)
    response = utils.checked_api_call(configs_api,
                                      'add_product_version',
                                      id=found_id,
                                      body=to_add)
    if response:
        return utils.format_json(response.content)
Esempio n. 47
0
def update_license(license_id, **kwargs):
    """
    Replace the License with given ID with a new License
    """
    updated_license = pnc_api.licenses.get_specific(id=license_id).content

    for key, value in iteritems(kwargs):
        if value:
            setattr(updated_license, key, value)

    response = utils.checked_api_call(pnc_api.licenses,
                                      'update',
                                      id=int(license_id),
                                      body=updated_license)
    if response:
        return utils.format_json(response.content)
Esempio n. 48
0
def update_environment(id, **kwargs):
    """
    Update a BuildEnvironment with new information
    """
    to_update = envs_api.get_specific(id=id).content

    for key, value in iteritems(kwargs):
        if value:
            setattr(to_update, key, value)

    response = utils.checked_api_call(envs_api,
                                      'update',
                                      id=id,
                                      body=to_update)
    if response:
        return utils.format_json(response.content)
Esempio n. 49
0
def create_build_configuration(**kwargs):
    """
    Create a new BuildConfiguration. BuildConfigurations represent the settings and configuration required to run a build of a specific version of the associated Project's source code.
    If a ProductVersion ID is provided, the BuildConfiguration will have access to artifacts which were produced for that version, but may not have been released yet.
    """
    project_id = kwargs.get('project')
    project_rest = common.get_entity(projects_api, project_id)
    kwargs['project'] = project_rest
    env_id = kwargs.get('environment')
    env_rest = common.get_entity(envs_api, env_id)
    kwargs['environment'] = env_rest

    build_configuration = create_build_conf_object(**kwargs)
    response = utils.checked_api_call(
        configs_api, 'create_new', body=build_configuration)
    if response:
        return utils.format_json(response.content)
Esempio n. 50
0
def build(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):
    """
    Trigger a BuildConfiguration by name or ID
    """
    data = build_raw(id, name, revision, temporary_build, timestamp_alignment,
                     no_build_dependencies, keep_pod_on_failure, force_rebuild,
                     rebuild_mode)
    if data:
        return utils.format_json(data)
Esempio n. 51
0
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)
Esempio n. 52
0
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)
Esempio n. 53
0
def create_milestone(**kwargs):
    """
    Create a new ProductMilestone
    """
    check_date_order(kwargs.get('starting_date'), kwargs.get('planned_end_date'))

    base_version = str(productversions_api.get_specific(
        id=kwargs.get('product_version_id')).content.version)
    kwargs['version'] = base_version + "." + kwargs.get('version')

    unique_version_value(kwargs.get('product_version_id'), kwargs['version'])

    created_milestone = create_milestone_object(**kwargs)
    response = utils.checked_api_call(
        milestones_api,
        'create_new',
        body=created_milestone)
    if response:
        return utils.format_json(response.content)
Esempio n. 54
0
def close_milestone(id, **kwargs):
    """
    Close a milestone. This triggers its release process.

    The user can optionally specify the release-date, otherwise today's date is
    used.

    If the wait parameter is specified and set to True, upon closing the milestone,
    we'll periodically check that the release being processed is done.

    Required:
    - id: int

    Optional:
    - wait key: bool
    """
    data = close_milestone_raw(id, **kwargs)
    if data:
        return utils.format_json(data)
Esempio n. 55
0
def create_release(**kwargs):
    """
    Create a new ProductRelease.
    A ProductRelease represents a build / set of builds that is ready for release to the public.
    Each ProductRelease is associated with exactly one ProductMilestone and exactly one ProductVersion.

    Example:
    ProductVersion: 1.0
    ProductMilestone: 1.0.0.CR2
    ProductRelease: 1.0.0.GA
    """
    # gotta find a way to avoid this situation
    product_version = str(productmilestones.get_product_version_from_milestone(kwargs.get('product_milestone_id')))
    base_version = productversions_api.get_specific(
        id=product_version).content.version
    kwargs['version'] = base_version + '.' + kwargs.get('version')
    created_release = create_product_release_object(**kwargs)
    response = utils.checked_api_call(
        releases_api, 'create_new', body=created_release)
    if response:
        return utils.format_json(response.content)
def create_product_version(product_id, version, **kwargs):
    """
    Create a new ProductVersion.
    Each ProductVersion represents a supported product release stream, which includes milestones and releases typically associated with a single major.minor version of a Product.
    Follows the Red Hat product support cycle, and typically includes Alpha, Beta, GA, and CP releases with the same major.minor version.

    Example:
    ProductVersion 1.0 includes the following releases:
    1.0.Beta1, 1.0.GA, 1.0.1, etc.
    """
    if version_exists_for_product(product_id, version):
        raise argparse.ArgumentTypeError("Version {} already exists for product: {}".format(
            version, products_api.get_specific(id=product_id).content.name))

    kwargs['product_id'] = product_id
    kwargs['version'] = version
    product_version = create_product_version_object(**kwargs)
    response = utils.checked_api_call(versions_api, 'create_new_product_version',
                                      body=product_version)
    if response:
        return utils.format_json(response.content)
def update_product_version(id, **kwargs):
    """
    Update the ProductVersion with ID id with new values.
    """
    product_id = kwargs.get('product_id')
    if product_id is None:
        product_id = get_product_version_raw(id).product_id

    version = kwargs.get('version')
    if version is not None:
        if version_exists_for_product(product_id, version):
            raise argparse.ArgumentTypeError("Version {} already exists for product: {}".format(
                version, products_api.get_specific(id=product_id).content.name))

    to_update = versions_api.get_specific(id=id).content
    for key, value in kwargs.items():
        if value is not None:
            setattr(to_update, key, value)
    response = utils.checked_api_call(versions_api, 'update',
                                      id=id,
                                      body=to_update)
    if response:
        return utils.format_json(response.content)
Esempio n. 58
0
def create_repository_configuration(repository, external_repository=None, prebuild_sync=None):
    """
    Create a new RepositoryConfiguration.
    """

    print("s: %s", prebuild_sync)

    if external_repository is None and prebuild_sync:
        logging.error("You cannot enable prebuild sync without external repository")
        return

    repository_configuration = swagger_client.RepositoryConfigurationRest()
    repository_configuration.internal_url = repository

    if external_repository is not None:
        repository_configuration.external_url = external_repository
    
    if prebuild_sync is not None:
        repository_configuration.pre_build_sync_enabled = prebuild_sync

    response = utils.checked_api_call(
        pnc_api.repositories, 'create_new', body=repository_configuration)
    if response:
        return utils.format_json(response.content)
Esempio n. 59
0
def get_logged_user():
    response = utils.checked_api_call(pnc_api.users, 'get_logged_user')
    if response:
        return utils.format_json(response.content)
Esempio n. 60
0
def delete_build_configuration_set(id=None, name=None):
    set_id = common.set_id(sets_api, id, name)
    response = utils.checked_api_call(sets_api, 'delete_specific', id=set_id)
    if response:
        return utils.format_json(response.content)