Content Units

Retrieve a Single Unit

Returns information about a single content unit.

Method: GET
Path: /pulp/api/v2/content/units/<content_type>/<unit_id>/
Permission: read
Response Codes:
  • 200 - if the unit is found

  • 404 - if there is no unit at the given id

Return: the details of the unit

Sample 200 Response Body:

{
  "_id": "046ca98d-5977-400d-b4de-a5bb57c8b7e2",
  "_content_type_id": "type-2",
  "_last_updated": "2013-09-05T17:49:41Z",
  "_storage_path": "/var/lib/pulp/content/type-2/A",
  "pulp_user_metadata": {},
  "key-2a": "A",
  "key-2b": "B",
}

Retrieve a Single Unit’s User Metadata

Returns the pulp_user_metadata field from a single content unit.

Method: GET
Path: /pulp/api/v2/content/units/<content_type>/<unit_id>/pulp_user_metadata/
Permission: read
Response Codes:
  • 200 - if the unit is found

  • 404 - if there is no unit at the given id

Return: the Unit’s pulp_user_metadata field

Sample 200 Response Body:

{
  "user_key_1": "A",
  "user_key_2": "B"
}

Set Single Unit’s User Metadata

Sets the pulp_user_metadata field on a single content unit to the provided values.

Method: PUT
Path: /pulp/api/v2/content/units/<content_type>/<unit_id>/pulp_user_metadata/
Permission: update
Response Codes:
  • 200 - if the unit is found

  • 404 - if there is no unit at the given id

Return: null

Sample Request:

{
   "user_key_1": "A",
   "user_key_2": "B"
}

Sample 200 Response Body:

null

Search for Units

Please see Search API for more details on how to perform these searches.

Returns information on content units in the Pulp server that match your search parameters. It is worth noting that this call will never return a 404; an empty array is returned in the case where there are no content units. This is even the case when the content type specified in the URL does not exist.

Method: POST
Path: /pulp/api/v2/content/units/<content_type>/search/
Permission: read
Request Body Contents:
  • criteria (object) - mapping structure as defined in Search Criteria

  • include_repos (boolean) - (optional) adds an extra per-unit attribute “repository_memberships” that lists IDs of repositories of which the unit is a member.

Response Codes:
  • 200 - containing the array of content units

Return: the same format as retrieving a single content unit, except the base of the return value is an array of them

Sample 200 Response Body:

[
  {
    "key-2a": "A",
    "_ns": "units_type-2",
    "_id": "046ca98d-5977-400d-b4de-a5bb57c8b7e2",
    "pulp_user_metadata": {},
    "key-2b": "A",
    "_content_type_id": "type-2",
    "repository_memberships": ["repo1", "repo2"]
  },
  {
    "key-2a": "B",
    "_ns": "units_type-2",
    "_id": "2cc5b44a-c5d7-4751-9505-c54ad4f43497",
    "pulp_user_metadata": {},
    "key-2b": "C",
    "_content_type_id": "type-2",
    "repository_memberships": ["repo1"]
  }
]

Returns information on content units in the Pulp server that match your search parameters. It is worth noting that this call will never return a 404; an empty array is returned in the case where there are no content units. This is even the case when the content type specified in the URL does not exist.

This method is slightly more limiting than the POST alternative, because some filter expressions may not be serializable as query parameters.

Method: GET
Path: /pulp/api/v2/content/units/<content_type>/search/
Permission: read
Query Parameters: query params should match the attributes of a Criteria object as defined in Search Criteria. For example: /v2/content/units/deb/search/?field=id&field=display_name&limit=20’
  • include_repos (boolean) - (optional) adds an extra per-unit attribute “repository_memberships” that lists IDs of repositories of which the unit is a member.

Response Codes:
  • 200 - containing the array of content units

Return: the same format as retrieving a single content unit, except the base of the return value is an array of them

Sample 200 Response Body:

[
  {
    "key-2a": "A",
    "_ns": "units_type-2",
    "_id": "046ca98d-5977-400d-b4de-a5bb57c8b7e2",
    "pulp_user_metadata": {},
    "key-2b": "A",
    "_content_type_id": "type-2",
    "repository_memberships": ["repo1", "repo2"]
  },
  {
    "key-2a": "B",
    "_ns": "units_type-2",
    "_id": "2cc5b44a-c5d7-4751-9505-c54ad4f43497",
    "pulp_user_metadata": {},
    "key-2b": "C",
    "_content_type_id": "type-2",
    "repository_memberships": ["repo1"]
  }
]