Create, Sync and Publish a Repository

One of the most common workflows is a fetching content from a remote source and making it available for users.

Create an RPM repository foo

$ http POST http://localhost:24817/pulp/api/v3/repositories/rpm/rpm/ name=foo

{
    "pulp_href": "/pulp/api/v3/repositories/rpm/rpm/5eeabc0b-3b86-4264-bb3a-5889530a6f5b/",
}

$ export REPO_HREF=$(http :24817/pulp/api/v3/repositories/rpm/rpm/ | jq -r '.results[] | select( .name == "foo") | .pulp_href')

Create a new remote bar

By default policy='immediate which means that all the content is downloaded right away. Specify policy='on_demand' to make synchronization of a repository faster and only to download RPMs whenever they are requested by clients.

$ http POST http://localhost:24817/pulp/api/v3/remotes/rpm/rpm/ name='bar' url='https://repos.fedorapeople.org/pulp/pulp/fixtures/rpm-unsigned/' policy='on_demand'

{
    "pulp_href": "/pulp/api/v3/remotes/rpm/rpm/378711cd-1bee-4adc-8d9b-fe3bceaba39f/",
}

$ export REMOTE_HREF=$(http :24817/pulp/api/v3/remotes/rpm/rpm/ | jq -r '.results[] | select(.name == "bar") | .pulp_href')

Sync repository foo using remote bar

$ http POST :24817${REPO_HREF}sync/ remote=$REMOTE_HREF

Look at the new Repository Version created

$ http GET :24817${REPO_HREF}versions/1/

{
    "_added_href": "/pulp/api/v3/repositories/rpm/rpm/5eeabc0b-3b86-4264-bb3a-5889530a6f5b/versions/1/added_content/",
    "_content_href": "/pulp/api/v3/repositories/5eeabc0b-3b86-4264-bb3a-5889530a6f5b/rpm/rpm/versions/1/content/",
    "pulp_href": "/pulp/api/v3/repositories/5eeabc0b-3b86-4264-bb3a-5889530a6f5b/rpm/rpm/versions/1/",
    "_removed_href": "/pulp/api/v3/repositories/5eeabc0b-3b86-4264-bb3a-5889530a6f5b/rpm/rpm/versions/1/removed_content/",
    "content_summary": {
        "package": 35,
        "advisory": 4
    },
    "created": "2018-02-23T20:29:54.499055Z",
    "number": 1
}

Create a Publication

$ http POST :24817/pulp/api/v3/publications/rpm/rpm/ repository=$REPO_HREF

[
    {
        "pulp_href": "/pulp/api/v3/tasks/fd4cbecd-6c6a-4197-9cbe-4e45b0516309/",
        "task_id": "fd4cbecd-6c6a-4197-9cbe-4e45b0516309"
    }
]

$ export PUBLICATION_HREF=$(http :24817/pulp/api/v3/publications/rpm/rpm/ | jq -r '.results[] | select(.repository_version|test("'$REPO_HREF'.")) | .pulp_href')

Create a Distribution for the Publication

$ http POST http://localhost:24817/pulp/api/v3/distributions/rpm/rpm/ name='baz' base_path='foo' publication=$PUBLICATION_HREF

{
    "pulp_href": "/pulp/api/v3/distributions/8f394d20-f6fb-49dd-af0e-778225d79442/",
}