Recover an application from the Trash
-
If application id is unknown, use the application name to retrieve the
application record.
Information in the application record is needed for the next step.
Request:
curl --location --request GET "https://domain.cop.blackduck.com/api/common/v0/applications?filter[application][name][$eq]=docs-application-two-7.22.2021&filter[application][in-trash][$eq]=true&page[limit]=25&page[offset]=0" --header "accept: application/vnd.api+json" --header "Authorization: Bearer {JWT}"The example above searches for the app named "docs-application-two-7.22.2021," which is in the trash.
- The first parameter appended to the URL is the one that filters by name for the string "docs-application-two-7.22.2021" (filter[application][name][$eq]=docs-application-two-7.22.2021).
- Because the search is for a string, Coverity on Polaris might return a list if more than one application name matches. For best results, use the exact name and
- The second parameter filters for being in the trash (filter[application][in-trash][$eq]=true). Applications in the trash are not returned in results unless this parameter is used.
Response:
{ "data": [ { "type": "application", "id": "6a6fe013-fec4-48e7-8b52-85acdb214826", "attributes": { "name": "docs-application-two-7.22.2021", "description": "Another application created by the docs team" }, "relationships": { "projects": { "links": { "self": "https://subdomain.cop.blackduck.com/api/common/v0/applications/6a6fe013-fec4-48e7-8b52-85acdb214826/relationships/projects", "related": "https://subdomain.cop.blackduck.com/api/common/v0/applications/6a6fe013-fec4-48e7-8b52-85acdb214826/related/projects" }, "data": [] } }, "links": { "self": { "href": "https://subdomain.cop.blackduck.com/api/common/v0/applications/6a6fe013-fec4-48e7-8b52-85acdb214826", "meta": { "durable": "urn:x-swip:applications:6a6fe013-fec4-48e7-8b52-85acdb214826" } } }, "meta": { "etag": "W/\"cf98e2jip0q1ap9r7othju3obh6pr5a4keisf3q\ ljfcb49pqh4qruedt07mtvip83pkao3irs7gj4i5ut07vrcg8n2f2ok72a5t2nv\ rs35rdqbp9muvkl3veggz23jt7vmuo8b9q2l0k0l0ch2rmk\"", "organization-id": "fl1v7rb3ol7gj9l4hh9lntmpfc", "in-trash": true, "project-count": 0 } } ], "included": [], "meta": { "offset": null, "limit": 1, "total": 1 }, "links": { "next": null, "prev": null, "first": "https://subdomain.cop.blackduck.com/api/common/v0/applications?page%5Blimit%5D=1&filter%5Bapplication%5D%5Bname%5D%5B%24isubstr%5D=docs-application-two-7.22.2021&tenant-id=fl1v7rb3ol7gj9l4hh9lntmpfc&page%5Boffset%5D=0", "last": "https://subdomain.cop.blackduck.com/api/common/v0/applications?page%5Blimit%5D=1&filter%5Bapplication%5D%5Bname%5D%5B%24isubstr%5D=docs-application-two-7.22.2021&tenant-id=fl1v7rb3ol7gj9l4hh9lntmpfc&page%5Boffset%5D=0" } }In this response, the in-trash property is true, because the application has been moved to the trash by someone using the UI. To remove it from the trash, that value must be changed to
false.Copy the application id and the etag from the application record.
-
Use the application id and etag to update the application record.
It's necessary to change the in-trash value to
false, to make the application usable again in the web UI.Request:
curl --location --request PATCH 'HTTPS://domain.cop.blackduck.com/api/common/v0/applications/6a6fe013-fec4-48e7-8b52-85acdb214826' \ --header 'Accept: application/vnd.api+json' \ --header 'Content-Type: application/vnd.api+json' \ --header 'If-Match: jebfa2948gu3sv4cpcgt6541rcv2rldvr1jm4e1ap9tl87tvkngbq\ su83abu5vtbfrl30ga0rv5u6hp67vtca6sqsi2jurvab4532inqe05djl\ 503gpfgmk6c0zm3ehm98s2s9ug908movb1tc8r4' \ --header "Authorization: Bearer {JWT}" --data-raw { "data": { "type": "application", "id": "6a6fe013-fec4-48e7-8b52-85acdb214826", "attributes": { "name": "docs-application-two-7.22.2021", "description": "Another application created by the docs team" }, "relationships": { "projects": { "data": [ ] } }, "meta": { "etag": "W/\"jebfa2948gu3sv4cpcgt6541rcv2rldvr\ 1jm4e1ap9tl87tvkngbqsu83abu5vtbfrl30ga0rv5u6hp67vtca6sq\ si2jurvab4532inqe05djl503gpfgmk6c0zm3ehm98s2s9ug908movb1tc8r4\"", "organization-id": "fl1v7rb3ol7gj9l4hh9lntmpfc", "in-trash": false, "project-count": 0 } } }About this request:
- In the request body, in-trash is changed to false.
- The If-Match header uses the latest etag, copied from the response body in the previous step. This header is required when sending a PATCH request to Coverity on Polaris.
- The final part of the URL, after the last slash, is the application id.
- Most properties named meta, links, and included are removed. (Except for the meta that contains the in-trash property.) These aren't required for POST and PATCH operations.
Response:
{ "data": { "type": "application", "id": "6a6fe013-fec4-48e7-8b52-85acdb214826", "attributes": { "name": "docs-application-two-7.22.2021", "description": "Another application created by the docs team" }, "relationships": { "projects": { "links": { "self": "https://subdomain.cop.blackduck.com/api/common/v0/applications/6a6fe013-fec4-48e7-8b52-85acdb214826/relationships/projects", "related": "https://subdomain.cop.blackduck.com/api/common/v0/applications/6a6fe013-fec4-48e7-8b52-85acdb214826/related/projects" }, "data": [] } }, "links": { "self": { "href": "https://subdomain.cop.blackduck.com/api/common/v0/applications/6a6fe013-fec4-48e7-8b52-85acdb214826", "meta": { "durable": "urn:x-swip:applications:6a6fe013-fec4-48e7-8b52-85acdb214826" } } }, "meta": { "etag": "W/\"f949am9ecob4ola5tqf13e4oibpp406delia943oi31ared3it1enc4oo0\ son4v3mqq591jacjq6ngo6cr0k3f7al2bf097a9to58settv\ 0sms5qkt3rj650tgzfq9b2mspm4dfpsmb273n7okerk\"", "organization-id": "fl1v7rb3ol7gj9l4hh9lntmpfc", "in-trash": false, "project-count": 0 } }, "included": [], "meta": { "offset": 0, "limit": 1, "total": 1 }, "links": { "next": null, "prev": null, "first": "https://subdomain.cop.blackduck.com/api/common/v0/applications/6a6fe013-fec4-48e7-8b52-85acdb214826?tenant-id=fl1v7rb3ol7gj9l4hh9lntmpfc&page%5Boffset%5D=0", "last": "https://subdomain.cop.blackduck.com/api/common/v0/applications/6a6fe013-fec4-48e7-8b52-85acdb214826?tenant-id=fl1v7rb3ol7gj9l4hh9lntmpfc&page%5Boffset%5D=0" } }In this response, the in-trash value has been changed to
false, and this application can be accessed in the UI once again.
Recover a Project from the Trash
-
Use project name to retrieve the project record
Information in the record is necessary for a subsequent step.
Request:
curl --location -g --request GET 'HTTPS://subdomain.cop.blackduck.com/api/common/v0/projects?filter[project][name][$isubstr]=docs-webgoat&filter[project][in-trash][$eq]=true&page[limit]=1&page[offset]=0' \ --header 'Accept: application/vnd.api+json' \ --header 'Authorization: Bearer {JWT}The example above searches for the app named "docs-webgoat," which is in the trash.
About this request:
- The first parameter appended to the URL is the one that filters by
name for the string docs-webgoat
(
filter[project][name][$isubstr]=docs-webgoat). - The second parameter filters for being in the trash
(
filter[project][in-trash][$eq]=true). Projects in the trash are not returned in results unless this parameter is used. - The final parameter limits the results to one record. The request
shouldn't be able to return more than one, but a page limit is
required when performing this operation
(GET
/V0/projects).
Response:
{ "data": [ { "type": "project", "id": "3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b", "attributes": { "type": "REPOSITORY", "properties": {}, "name": "docs-webgoat", "description": null }, "relationships": { "runs": { "links": { "self": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/relationships/runs", "related": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/related/runs" } }, "user-default-branch": { "links": { "self": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/relationships/user-default-branch", "related": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/related/user-default-branch" }, "data": { "type": "branch", "id": "313d3b4a-f0f7-42bc-be5c-5f946f4163db" } }, "project-preference": { "links": { "self": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/relationships/project-preference", "related": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/related/project-preference" }, "data": { "type": "project-preference", "id": "c48529d9-835b-4a09-a5ea-f50a084f3435" } }, "branches": { "links": { "self": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/relationships/branches", "related": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/related/branches" } } }, "links": { "self": { "href": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b", "meta": { "durable": "urn:x-swip:projects:3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b" } } }, "meta": { "etag": "W/\"riofnqvn937c5moh3bha37dqk7in78cs6abq177c0\ 3om9rd3qjal19ibpvr3kack1i19af58mi5dea5gispg7curd0jdasi1e6p\ 269eo5rc0lsn3ln90ze29t2pht2q8fh0l55otb9q1joo\"", "organization-id": "fl1v7rb3ol7gj9l4hh9lntmpfc", "in-trash": true } } ], "included": [], "meta": { "offset": 0, "limit": 1, "total": 1 }, "links": { "next": null, "prev": null, "first": "https://subdomain.cop.blackduck.com/api/common/v0/projects?page%5Blimit%5D=1&filter%5Bproject%5D%5Bin-trash%5D%5B%24eq%5D=true&page%5Boffset%5D=0&filter%5Bproject%5D%5Bname%5D%5B%24isubstr%5D=docs-webgoat&tenant-id=fl1v7rb3ol7gj9l4hh9lntmpfc", "last": "https://subdomain.cop.blackduck.com/api/common/v0/projects?page%5Blimit%5D=1&filter%5Bproject%5D%5Bin-trash%5D%5B%24eq%5D=true&page%5Boffset%5D=0&filter%5Bproject%5D%5Bname%5D%5B%24isubstr%5D=docs-webgoat&tenant-id=fl1v7rb3ol7gj9l4hh9lntmpfc" } }The response is the complete record for the project in question.
- The first parameter appended to the URL is the one that filters by
name for the string docs-webgoat
(
-
Use the project id and etag to update the project record.
It's necessary to change the in-trash value to false, to make the project usable again in the web UI.
Request:
curl --location --request PATCH 'HTTPS://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b' \ --header 'Accept: application/vnd.api+json' \ --header 'Content-Type: application/vnd.api+json' \ --header 'If-Match: riofnqvn937c5moh3bha37dqk7in78cs6abq177c03om9rd3qjal19ibpv\ r3kack1i19af58mi5dea5gispg7curd0jdasi1e6p269eo5rc0lsn3l\ n90ze29t2pht2q8fh0l55otb9q1joo' \ --header 'Authorization: Bearer {JWT} --data-raw{ "data": { "type": "project", "id": "3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b", "attributes": { "type": "REPOSITORY", "properties": {}, "name": "docs-webgoat", "description": null }, "relationships": { "runs": { }, "user-default-branch": { "data": { "type": "branch", "id": "313d3b4a-f0f7-42bc-be5c-5f946f4163db" } }, "project-preference": { "data": { "type": "project-preference", "id": "c48529d9-835b-4a09-a5ea-f50a084f3435" } }, "branches": { } }, "meta": { "etag": "W/\"riofnqvn937c5moh3bha37dqk7in78cs6abq177c03om\ 9rd3qjal19ibpvr3kack1i19af58mi5dea5gispg7curd0jdas\ i1e6p269eo5rc0lsn3ln90ze29t2pht2q8fh0l55otb9q1joo\"", "organization-id": "fl1v7rb3ol7gj9l4hh9lntmpfc", "in-trash": false } }, }About this request:
- In the request body, in-trash is changed to false.
- The If-Match header uses the latest etag, copied from the response body in the previous step. This header is required when sending a PATCH request to Coverity on Polaris.
- In the first line, the final part of the URL, after the last slash, is the project id.
- Most properties named meta, links, and included are removed. (Except for the meta that contains the in-trash property.) These aren't required for POST and PATCH operations.
Response:
{ "data": { "type": "project", "id": "3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b", "attributes": { "type": "REPOSITORY", "properties": {}, "name": "docs-webgoat", "description": null }, "relationships": { "runs": { "links": { "self": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/relationships/runs", "related": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/related/runs" } }, "user-default-branch": { "links": { "self": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/relationships/user-default-branch", "related": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/related/user-default-branch" }, "data": { "type": "branch", "id": "313d3b4a-f0f7-42bc-be5c-5f946f4163db" } }, "project-preference": { "links": { "self": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/relationships/project-preference", "related": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/related/project-preference" }, "data": { "type": "project-preference", "id": "c48529d9-835b-4a09-a5ea-f50a084f3435" } }, "branches": { "links": { "self": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/relationships/branches", "related": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/related/branches" } } }, "links": { "self": { "href": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b", "meta": { "durable": "urn:x-swip:projects:3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b" } } }, "meta": { "etag": "W/\"pf0jch77sqmgf7in14a2ajvhp2krf3eet8vuuvurf\ ikkmuvoa5lmp607uo2o1ejiofqve8ko1a0pkaq74k6tm1tj6ebdb79ugm1q\ bghdjqfsbo2mpte0zkteolp8omn6ej5av6p8gh7u870\"", "organization-id": "fl1v7rb3ol7gj9l4hh9lntmpfc", "in-trash": false } }, "included": [], "meta": { "offset": null, "limit": null, "total": 0 }, "links": { "next": null, "prev": null, "first": null, "last": null } }In this response, the in-trash value has been changed to
false, and this project can be accessed in the UI once again.