-
Copy an application resource.
You need a copy of the application data object to create a new application. You can copy another application or start with this slightly modified object from the Swagger docs service:
Request:
{ "data": [ { "type": "string", "attributes": { "name": "string", "description": "string" }, "relationships": { "projects": { "data": [ ] } }, } ], }The object above is retrieved by using 'GET
. . ./v0/applications'. The following changes were made after retrieving the object:- The application id property is not included in the request when creating an application. Coverity on Polaris will generate an id for the new application. (See the response in Step 2.)
- The relationships object is minimized, so that it doesn't include any projects or links.
- Properties named meta, links, and included are removed. These aren't required for POST and PATCH operations.
When you create a new application, the following fields are normally edited:
- The application name is required.
- An application description is optional, although providing a description is always best.
- When creating a new application, the application id (data.id) attribute must be omitted. If you provide an id or set the value to null, the result will be an error.
- You can add projects when creating the application, but this is
optional. For each project, add the following within data[
]:
{ "type": "project", "id": <project-id> }
-
Create the Application by Posting the Resource.
Request:
curl -X POST "https://subdomain.cop.blackduck.com/api/common/v0/applications" \ --header "accept: application/vnd.api+json" \ --header "Content-Type: application/vnd.api+json" \ --header Authorization: Bearer {JWT} \ --data \ { "data": { "type": "application", "attributes": { "name": "docs-application-7.22.2021", "description": "Application created by the docs team" }, "relationships": { "projects": { "data": [ { "type": "project", "id": "3038d1a4-2124-49e5-9aed-02570a3e400d" }, { "type": "project", "id": "aa545462-2eda-4bc6-8c5e-e996fa822bf8" } ] } } } }The object has been modified with the following changes:
- The type is application (this is required)
- Application name added
- Application description added
- Two projects added, by including project id
Response:
{ "data": { "type": "application", "id": "a66178cc-2fc0-4c2e-ad7b-d0292955e806", "attributes": { "name": "SIG-docs-application-7.22.2021", "description": "Application created by the docs team" }, "relationships": { "projects": { "links": { "self": "https://subdomain.cop.blackduck.com/api/common/v0/applications/a66178cc-2fc0-4c2e-ad7b-d0292955e806/relationships/projects", "related": "https://subdomain.cop.blackduck.com/api/common/v0/applications/a66178cc-2fc0-4c2e-ad7b-d0292955e806/related/projects" }, "data": [ { "type": "project", "id": "3038d1a4-2124-49e5-9aed-02570a3e400d" }, { "type": "project", "id": "aa545462-2eda-4bc6-8c5e-e996fa822bf8" } ] } }, "links": { "self": { "href": "https://subdomain.cop.blackduck.com/api/common/v0/applications/a66178cc-2fc0-4c2e-ad7b-d0292955e806", "meta": { "durable": "urn:x-swip:applications:a66178cc-2fc0-4c2e-ad7b-d0292955e806" } } }, "meta": { "etag": "W/\"u2fnb2guhb749rbo2kt6aut62vdvme6cpbrfk0de86cefrj4f0j\ kh1munv3d99trpv2r62j6iulblod5flrhfdfq9anmh9s4urc3q5tbehj63okg0gatujfagk\ zpb80eapvj2819j4m1j2plvbblg\"", "organization-id": "fl1v7rb3ol7gj9l4hh9lntmpfc", "in-trash": false, "project-count": 2 } }, "included": [], "meta": { "offset": null, "limit": null, "total": 0 }, "links": { "next": null, "prev": null, "first": null, "last": null } }In this response, Coverity on Polaris has updated the object with additional information. In addition to the attributes assigned in the request, the record now contains the following:
- An application id generated by Coverity on Polaris
- Links that return data about this application and related projects
- An etag, necessary for making PATCH requests
- Organization id
Only Organization Administrators can perform this step.