Change or Remove a Project-Webhook Association

Coverity on Polaris

Version
latest
After you associate webhooks with a project, you can remove one or more webhooks if you decide to stop using them. You can also remove all the webhooks associated with the project if necessary.

  1. Request the current project webhooks.

    Request:

    
    // GET https://subdomain.cop.blackduck.com/api/notifications/v0/project-webhooks/150cd9f0-ef40-434b-b862-2a97cd884a1e
                        

    This request submits a project id to get the webhooks associated with the project.

    
           {
             "data": [
                 {
                 "type": "project-webhook",
                 "id": "150cd9f0-ef40-434b-b862-2a97cd884a1e",
                   "attributes": {
                      "webhook-ids": [
                      "c605f908-dfe4-11e9-8a34-2a2ae2dbcce4",
                      "c282254d-0881-413d-a314-c91c592d391f",
                      "f8441c8f-f399-45d5-a680-536ecc6375aa"
                      ]
                   }
                 }
             ],
         "included": [],
         }
       }
                      
                            
                        

    The array stored in webhook-ids contains three ids. On the next step, you can remove or add ids if there are additional webhooks you'd like to use.

  2. Update the preceding project-webhook association by removing one or more webhooks.
    • Remove or add webhooks.
    • Remove the project-webhook association .

    This step includes multiple examples, but you only need one.

    Request: Add or Remove Webhooks

                           
      PATCH /project-webhooks/150cd9f0-ef40-434b-b862-2a97cd884a1e
       {
           "data": {
           "type": "project-webhook",       
           "id": "150cd9f0-ef40-434b-b862-2a97cd884a1e",
             "attributes": {
                "webhook-ids": [ 
                 "c605f908-dfe4-11e9-8a34-2a2ae2dbcce4",
                 "c282254d-0881-413d-a314-c91c592d391f",                          
                 ]
             }
           }
       }
                          

    This request sends a patch that changes the database record by removing the last webhook-id ("f844..." in the first code example). That webhook is no longer associated with the project. You can add or remove as many webhooks as necessary in a single request.

    Request: Remove All Existing Webhooks

    
                            
    PATCH /project-webhooks/150cd9f0-ef40-434b-b862-2a97cd884a1e
    
    {
        "data": {
        "type": "project-webhook",       
        "id": "150cd9f0-ef40-434b-b862-2a97cd884a1e",
             "attributes": {
             "webhook-ids": [ ]
             }
        }
    }
                            

    This example sends a request with an empty array for the webhooks-id value, removing all the existing webhooks from the project.

    Request: Delete Project Webhook Association

        DELETE /project-webhooks/150cd9f0-ef40-434b-b862-2a97cd884a1e
                            

    This example accepts the project id, removing all the existing webhooks from the project.

    Note: Deleting a project-webhook object removes the relationships but not the object. If a project-webhook is queried after it is deleted, it returns the project-webhook with an empty list of webhook ids.