Overview

This page shows the usage of the Global Component API, please see the following for more details.

Test tools

You can use curl in terminal, with -X method (GET|POST|PUT|DELETE), -d data (a json string). or GUI plugins for browsers, such as RESTClient, RESTConsole.

Documents & examples

Method: GET

URL: /rest_api/v1/global-components/

Query Params:

  • dist_git_path (string)
  • label (string)
  • name (string)
  • upstream_homepage (string)
  • upstream_scm_type (string)
  • upstream_scm_url (string)
  • ordering (string) Comma separated list of fields for ordering results.
    • To sort by a field in descending order, prefix its name with minus (e.g. -name).
    • Use double underscores for nested field names (e.g. parent__child for {"parent": {"child": ...}}).

Following filters can be used to show only specific fields. This can make response time faster. Format is list or single value (JSON: {"fields": ["a","b"]} or {"fields": "a"}, in URL: ?fields=a&fields=b).

  • fields (list | string) Fields to display (other fields will be hidden).
  • exclude_fields: (list | string) Fields NOT to display (overrules fields).

Response:

# paged lists
{
    "count": int,
    "next": url,
    "previous": url,
    "results": [
        {
            "id": int,
            "name": string,
            "dist_git_path": <string|null>,
            "dist_git_web_url": string,
            "labels": [
                string, ......
            ],
            "upstream": null | {
                            "homepage": string,
                            "scm_type": string,
                            "scm_url": string
                        }
        },
        ...
}

Method: GET

URL: /rest_api/v1/global-components/{instance_pk}/

Response:

{
    "id": int,
    "name": string,
    "dist_git_path": <string|null>,
    "dist_git_web_url": string,
    "labels": [
        string, ......
    ],
    "upstream": null | {
                "homepage": string,
                "scm_type": string,
                "scm_url": string
            }
}

Method: POST

URL: /rest_api/v1/global-components/

Data:

{
    'name':                string,         # required
    'dist_git_path':       string,         # optional
    'upstream':            dict,           # optional
}

Response:

{
    "id": int,
    "name": string,
    "dist_git_path": string,
    "dist_git_web_url": string,
    "labels": array,
    "upstream": dict
}

Example:

curl -X POST -H "Content-Type: application/json" https://pdc.fedoraproject.org/rest_api/v1/global-components/ \
        -d '{ "name": "Demo", "dist_git_path": "rpm/Demo"}'
# output
{
    "id": 4181,
    "name": "Demo",
    "dist_git_path": "rpm/Demo",
    "dist_git_web_url": "http://pkgs.example.com/cgit/rpms/rpm/Demo"
    "labels": [],
    "upstream": null | {
                    "homepage": string,
                    "scm_type": string,
                    "scm_url": string
                }
}

It is possible to create this resource in bulk. To do so, use the same procedure as when creating a single instance, only the request body should contain a list of JSON objects. The response you get back will also contain a list of values which you would obtain by submitting the request data separately.

Method:

PUT/PATCH: for update

Data:

# accept any field(s) from 'name', 'dist_git_path' and 'upstream'
{'name': 'new_name',
 'dist_git_path': 'new_dist_git_path',
 'upstream': {'homepage': 'homepage',
              'scm_type': 'scm-type',
              'scm_url': 'url'}
}

URL: /rest_api/v1/global-components/{instance_pk}/

Response:

{
    "id": int,
    "name": string,
    "dist_git_path": string,
    "dist_git_web_url": string,
    "labels": array,
    "upstream": null | {
                    "homepage": string,
                    "scm_type": string,
                    "scm_url": string
                }
}

Example:

PUT:

curl -X PUT -H "Content-Type: application/json" https://pdc.fedoraproject.org/rest_api/v1/global-components/4181/ \
        -d '{"name": "Demo1", "dist_git_path": "rpm/Demo1"}'
# output
{
    "id": 4181,
    "name": "Demo",
    "dist_git_path": "rpm/Demo1",
    "dist_git_web_url": "http://pkgs.example.com/cgit/rpms/rpm/Demo1"
    "labels": [],
    "upstream": null
}

PATCH:

curl -X PATCH -H "Content-Type: application/json" https://pdc.fedoraproject.org/rest_api/v1/global-components/4181/ -d '{"dist_git_path": "rpm/Demo1"}'
# output
{
    "id": 4181,
    "name": "Demo",
    "dist_git_path": "rpm/Demo1",
    "dist_git_web_url": "http://pkgs.example.com/cgit/rpms/rpm/Demo1"
    "labels": [],
    "upstream": null
}

Method: DELETE

URL: /rest_api/v1/global-components/{instance_pk}/

Response:

STATUS: 204 NO CONTENT

Example:

curl -X DELETE -H "Content-Type: application/json" https://pdc.fedoraproject.org/rest_api/v1/global-components/4181/

It is possible to delete multiple items in one request. Use the DELETE method with the same url as for listing/creating objects. The request body should contain a list with identifiers for objects to be deleted. The identifier is usually the last part of the URL for deleting a single object.

It is possible to update multiple objects in one request. Use the PUT or PATCH method with the same url as for listing/creating objects. The request body should contain an object, where keys are identifiers of objects to be modified and their values use the same format as normal update.

Browsable GET

GET /rest_api/v1/global-components/
HTTP 200 OK
Allow: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "count": 37878,
    "next": "https://pdc.fedoraproject.org/rest_api/v1/global-components/?page=2",
    "previous": null,
    "results": [
        {
            "id": 1,
            "name": "atomic",
            "dist_git_path": null,
            "dist_git_web_url": "https://src.fedoraproject.org/cgit/rpms/atomic.git",
            "labels": [],
            "upstream": null
        },
        {
            "id": 2,
            "name": "glibc",
            "dist_git_path": null,
            "dist_git_web_url": "https://src.fedoraproject.org/cgit/rpms/glibc.git",
            "labels": [],
            "upstream": null
        },
        {
            "id": 3,
            "name": "nss-altfiles",
            "dist_git_path": null,
            "dist_git_web_url": "https://src.fedoraproject.org/cgit/rpms/nss-altfiles.git",
            "labels": [],
            "upstream": null
        },
        {
            "id": 4,
            "name": "shadow-utils",
            "dist_git_path": null,
            "dist_git_web_url": "https://src.fedoraproject.org/cgit/rpms/shadow-utils.git",
            "labels": [],
            "upstream": null
        },
        {
            "id": 5,
            "name": "sssd",
            "dist_git_path": null,
            "dist_git_web_url": "https://src.fedoraproject.org/cgit/rpms/sssd.git",
            "labels": [],
            "upstream": null
        },
        {
            "id": 6,
            "name": "fedora-release",
            "dist_git_path": null,
            "dist_git_web_url": "https://src.fedoraproject.org/cgit/rpms/fedora-release.git",
            "labels": [],
            "upstream": null
        },
        {
            "id": 7,
            "name": "dracut",
            "dist_git_path": null,
            "dist_git_web_url": "https://src.fedoraproject.org/cgit/rpms/dracut.git",
            "labels": [],
            "upstream": null
        },
        {
            "id": 8,
            "name": "kernel",
            "dist_git_path": null,
            "dist_git_web_url": "https://src.fedoraproject.org/cgit/rpms/kernel.git",
            "labels": [],
            "upstream": null
        },
        {
            "id": 9,
            "name": "rpm-ostree",
            "dist_git_path": null,
            "dist_git_web_url": "https://src.fedoraproject.org/cgit/rpms/rpm-ostree.git",
            "labels": [],
            "upstream": null
        },
        {
            "id": 10,
            "name": "lvm2",
            "dist_git_path": null,
            "dist_git_web_url": "https://src.fedoraproject.org/cgit/rpms/lvm2.git",
            "labels": [],
            "upstream": null
        },
        {
            "id": 11,
            "name": "cryptsetup",
            "dist_git_path": null,
            "dist_git_web_url": "https://src.fedoraproject.org/cgit/rpms/cryptsetup.git",
            "labels": [],
            "upstream": null
        },
        {
            "id": 12,
            "name": "authconfig",
            "dist_git_path": null,
            "dist_git_web_url": "https://src.fedoraproject.org/cgit/rpms/authconfig.git",
            "labels": [],
            "upstream": null
        },
        {
            "id": 13,
            "name": "btrfs-progs",
            "dist_git_path": null,
            "dist_git_web_url": "https://src.fedoraproject.org/cgit/rpms/btrfs-progs.git",
            "labels": [],
            "upstream": null
        },
        {
            "id": 14,
            "name": "e2fsprogs",
            "dist_git_path": null,
            "dist_git_web_url": "https://src.fedoraproject.org/cgit/rpms/e2fsprogs.git",
            "labels": [],
            "upstream": null
        },
        {
            "id": 15,
            "name": "xfsprogs",
            "dist_git_path": null,
            "dist_git_web_url": "https://src.fedoraproject.org/cgit/rpms/xfsprogs.git",
            "labels": [],
            "upstream": null
        },
        {
            "id": 16,
            "name": "grub2",
            "dist_git_path": null,
            "dist_git_web_url": "https://src.fedoraproject.org/cgit/rpms/grub2.git",
            "labels": [],
            "upstream": null
        },
        {
            "id": 17,
            "name": "ostree",
            "dist_git_path": null,
            "dist_git_web_url": "https://src.fedoraproject.org/cgit/rpms/ostree.git",
            "labels": [],
            "upstream": null
        },
        {
            "id": 18,
            "name": "efibootmgr",
            "dist_git_path": null,
            "dist_git_web_url": "https://src.fedoraproject.org/cgit/rpms/efibootmgr.git",
            "labels": [],
            "upstream": null
        },
        {
            "id": 19,
            "name": "shim-signed",
            "dist_git_path": null,
            "dist_git_web_url": "https://src.fedoraproject.org/cgit/rpms/shim-signed.git",
            "labels": [],
            "upstream": null
        },
        {
            "id": 20,
            "name": "gnupg2",
            "dist_git_path": null,
            "dist_git_web_url": "https://src.fedoraproject.org/cgit/rpms/gnupg2.git",
            "labels": [],
            "upstream": null
        }
    ]
}