Repository Binding

Bind a Consumer to a Repository

Bind a consumer to a repository’s distributor for the purpose of consuming published content. Binding the consumer is performed in the following steps:

  1. Create the binding on server.
  2. Optionally send a request to the consumer to create the binding.

The distributor may support configuration options that it may use for that particular binding. These options would be used when generating the payload that is sent to consumers so they may access the repository. See the individual distributor’s documentation for more information on the format.

Method: POST
Path: /pulp/api/v2/consumers/<consumer_id>/bindings/
Permission: create
Request Body Contents:
  • repo_id (string) - unique identifier for the repository
  • distributor_id (string) - identifier for the distributor
  • options (object) - (optional) options passed to the handler on the consumer
  • notify_agent (boolean) - (optional) indicates if the consumer should be sent a message about the new binding; defaults to true if unspecified
  • binding_config (object) - (optional) options to be used by the distributor for this binding
Response Codes:
  • 200 - if the bind request was fully processed on the server
  • 202 - if an additional task was created to update consumer agents
  • 400 - if one or more of the parameters is invalid
  • 404 - if the consumer does not exist
Return: a Call Report if any tasks were spawned. In the event of a 200 response the body will be be the binding that was created.

Sample Request:

{
  "repo_id": "test-repo",
  "distributor_id": "dist-1"
}

Tags: Each task created to add the binding to a consumer will be created with the following tags: "pulp:repository:<repo_id>", "pulp:consumer:<consumer_id>" "pulp:repository_distributor:<distributor-id>" "pulp:action:bind"

Unbind a Consumer

Remove a binding between a consumer and a repository’s distributor.

Unbinding the consumer is performed in the following steps:

  1. Mark the binding as deleted on the server.
  2. Send a request to the consumer to remove the binding.
  3. Once the consumer has confirmed that the binding has been removed, it is permanently deleted on the server.

The steps for a forced unbind are as follows:

  1. The binding is deleted on the server. This happens synchronously with the call.
  2. Send a request to the consumer to remove the binding. The ID of the request to the consumer is returned via the spawned_tasks field of the Call Report.

If the notify_agent parameter was set to false when the binding was created, no request is sent to the consumer to remove the binding, so the binding is immediately deleted.

Method: DELETE
Path: /pulp/api/v2/consumers/<consumer_id>/bindings/<repo_id>/<distributor_id>
Permission: delete
Query Parameters: The consumer ID, repository ID and distributor ID are included in the URL itself.
  • force (boolean) - (optional) delete the binding immediately and discontinue tracking consumer actions
  • options (object) - (optional) options passed to the handler on the consumer
Response Codes:
  • 200 - if notify_agent was set to false for the binding and it was immediately deleted
  • 202 - the unbind request was accepted
  • 400 - if one or more of the parameters is invalid
  • 404 - if the consumer, repo, or distributor IDs don’t exist, or if the binding does not exist
Return: a Call Report if any tasks were spawned.

Tags: Each task created to delete the binding from a consumer will be created with the following tags: "pulp:repository:<repo_id>", "pulp:consumer:<consumer_id>" "pulp:repository_distributor:<distributor-id>" "pulp:action:unbind"

Retrieve a Single Binding

Retrieves information on a single binding between a consumer and a repository.

Method: GET
Path: /pulp/api/v2/consumers/<consumer_id>/bindings/<repo_id>/<distributor_id>
Permission: read
Query Parameters: None; the consumer ID, repository ID and distributor ID are included in the URL itself. There are no supported query parameters.
Response Codes:
  • 200 - if the bind exists
  • 404 - if the given IDs don’t exist, or if no bind exists with the given IDs
Return: database representation of the matching bind

Sample 200 Response Body:

{
   "_href": "/pulp/api/v2/consumers/test-consumer/bindings/test-repo/yum_distributor/",
   "_id": {
       "$oid": "55097a6045ef4829b243f102"
   },
   "_ns": "consumer_bindings",
   "binding_config": {},
   "consumer_actions": [
       {
           "action": "bind",
           "id": "d991aef8-cd50-402e-9e1b-84a2729b34a3",
           "status": "pending",
           "timestamp": 1426684512.37454
       }
   ],
   "consumer_id": "test-consumer",
   "deleted": false,
   "details": {
       "ca_cert": null,
       "client_cert": null,
       "gpg_keys": [],
       "protocols": [
           "https"
       ],
       "relative_path": "/pulp/repos/test-repo",
       "repo_name": "test-repo",
       "server_name": "example.com"
   },
   "distributor_id": "yum_distributor",
   "id": "55097a6045ef4829b243f102",
   "notify_agent": true,
   "repo_id": "test-repo",
   "type_id": "yum_distributor"
}

Retrieve All Bindings

Retrieves information on all bindings for the specified consumer.

Method: GET
Path: /pulp/api/v2/consumers/<consumer_id>/bindings/
Permission: read
Query Parameters: None; the consumer ID is included in the URL itself. There are no supported query parameters.
Response Codes:
  • 200 - if the consumer exists
  • 404 - if the given consumer does not exist
Return: an array of database representations of the matching binds

Sample 200 Response Body:

[
   {
       "_href": "/pulp/api/v2/consumers/test-consumer/bindings/test-repo/yum_distributor/",
       "_id": {
           "$oid": "55097cd045ef4829b081fd28"
       },
       "_ns": "consumer_bindings",
       "binding_config": {},
       "consumer_actions": [
           {
               "action": "bind",
               "id": "99613d18-1cff-424f-a5dd-9c4357a3f194",
               "status": "pending",
               "timestamp": 1426685136.733399
           }
       ],
       "consumer_id": "test-consumer",
       "deleted": false,
       "details": {
           "ca_cert": null,
           "client_cert": null,
           "gpg_keys": [],
           "protocols": [
               "https"
           ],
           "relative_path": "/pulp/repos/test-repo",
           "repo_name": "test-repo",
           "server_name": "example.com"
       },
       "distributor_id": "yum_distributor",
       "id": "55097cd045ef4829b081fd28",
       "notify_agent": true,
       "repo_id": "test-repo",
       "type_id": "yum_distributor"
   },
   {
       "_href": "/pulp/api/v2/consumers/test-consumer/bindings/repo1/yum_distributor/",
       "_id": {
           "$oid": "55097a6045ef4829b243f102"
       },
       "_ns": "consumer_bindings",
       "binding_config": {},
       "consumer_actions": [
           {
               "action": "bind",
               "id": "d991aef8-cd50-402e-9e1b-84a2729b34a3",
               "status": "pending",
               "timestamp": 1426684512.37454
           }
       ],
       "consumer_id": "test-consumer",
       "deleted": false,
       "details": {
           "ca_cert": null,
           "client_cert": null,
           "gpg_keys": [],
           "protocols": [
               "https"
           ],
           "relative_path": "/pulp/repos/repo1",
           "repo_name": "repo1",
           "server_name": "example.com"
       },
       "distributor_id": "yum_distributor",
       "id": "55097a6045ef4829b243f102",
       "notify_agent": true,
       "repo_id": "repo1",
       "type_id": "yum_distributor"
   }
]

Retrieve Binding By Consumer And Repository

Retrieves information on all bindings between a consumer and a repository.

Method: GET
Path: /pulp/api/v2/consumers/<consumer_id>/bindings/<repo_id>/
Permission: read
Query Parameters: None; the consumer and repository IDs are included in the URL itself. There are no supported query parameters.
Response Codes:
  • 200 - if both the consumer and repository IDs are valid
  • 404 - if one or both of the given ids are not valid
Return: an array of objects, where each object represents a binding

Sample 200 Response Body:

[
 {
   "notify_agent": true,
   "repo_id": "test_repo",
   "_href": "/pulp/api/v2/consumers/test_consumer/bindings/test_repo/test_distributor/",
   "type_id": "test_distributor",
   "consumer_actions": [
     {
       "status": "pending",
       "action": "bind",
       "id": "3a8713bb-6902-4f11-a725-17c7f1f6586a",
       "timestamp": 1402688658.785708
     }
   ],
   "_ns": "consumer_bindings",
   "distributor_id": "test_distributor",
   "consumer_id": "test_consumer",
   "deleted": false,
   "binding_config": {},
   "details": {
     "server_name": "pulp.example.com",
     "ca_cert": null,
     "relative_path": "/pulp/repos/test_repo",
     "gpg_keys": [],
     "client_cert": null,
     "protocols": [
       "https"
     ],
     "repo_name": "test_repo"
   },
   "_id": {
     "$oid": "539b54927bc8f6388640871d"
   },
   "id": "539b54927bc8f6388640871d"
 }
]