Skip to content

Latest commit

 

History

History
321 lines (210 loc) · 19.9 KB

ReportsApi.md

File metadata and controls

321 lines (210 loc) · 19.9 KB

{{classname}}

All URIs are relative to https://api.bitbucket.org/2.0

Method HTTP request Description
BulkCreateOrUpdateAnnotations Post /repositories/{workspace}/{repo_slug}/commit/{commit}/reports/{reportId}/annotations Bulk create or update annotations
CreateOrUpdateAnnotation Put /repositories/{workspace}/{repo_slug}/commit/{commit}/reports/{reportId}/annotations/{annotationId} Create or update an annotation
CreateOrUpdateReport Put /repositories/{workspace}/{repo_slug}/commit/{commit}/reports/{reportId} Create or update a report
DeleteAnnotation Delete /repositories/{workspace}/{repo_slug}/commit/{commit}/reports/{reportId}/annotations/{annotationId} Delete an annotation
DeleteReport Delete /repositories/{workspace}/{repo_slug}/commit/{commit}/reports/{reportId} Delete a report
GetAnnotation Get /repositories/{workspace}/{repo_slug}/commit/{commit}/reports/{reportId}/annotations/{annotationId} Get an annotation
GetAnnotationsForReport Get /repositories/{workspace}/{repo_slug}/commit/{commit}/reports/{reportId}/annotations List annotations
GetReport Get /repositories/{workspace}/{repo_slug}/commit/{commit}/reports/{reportId} Get a report
GetReportsForCommit Get /repositories/{workspace}/{repo_slug}/commit/{commit}/reports List reports

BulkCreateOrUpdateAnnotations

[]ReportAnnotation BulkCreateOrUpdateAnnotations(ctx, body, workspace, repoSlug, commit, reportId) Bulk create or update annotations

Bulk upload of annotations. Annotations are individual findings that have been identified as part of a report, for example, a line of code that represents a vulnerability. These annotations can be attached to a specific file and even a specific line in that file, however, that is optional. Annotations are not mandatory and a report can contain up to 1000 annotations. Add the annotations you want to upload as objects in a JSON array and make sure each annotation has the external_id field set to a unique value. If you want to use an existing id from your own system, we recommend prefixing it with your system's name to avoid collisions, for example, mySystem-annotation001. The external id can later be used to identify the report as an alternative to the generated UUID. You can upload up to 100 annotations per POST request. ### Sample cURL request: curl --location 'https://api.bitbucket.org/2.0/repositories/<username>/<reposity-name>/commit/<commit-hash>/reports/mysystem-001/annotations' \\ --header 'Content-Type: application/json' \\ --data-raw '[ { \"external_id\": \"mysystem-annotation001\", \"title\": \"Security scan report\", \"annotation_type\": \"VULNERABILITY\", \"summary\": \"This line represents a security threat.\", \"severity\": \"HIGH\", \"path\": \"my-service/src/main/java/com/myCompany/mysystem/logic/Main.java\", \"line\": 42 }, { \"external_id\": \"mySystem-annotation002\", \"title\": \"Bug report\", \"annotation_type\": \"BUG\", \"result\": \"FAILED\", \"summary\": \"This line might introduce a bug.\", \"severity\": \"MEDIUM\", \"path\": \"my-service/src/main/java/com/myCompany/mysystem/logic/Helper.java\", \"line\": 13 } ]' ### Possible field values: annotation_type: VULNERABILITY, CODE_SMELL, BUG result: PASSED, FAILED, IGNORED, SKIPPED severity: HIGH, MEDIUM, LOW, CRITICAL Please refer to the Code Insights documentation for more information.

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
body []ReportAnnotation The annotations to create or update
workspace string This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example `{workspace UUID}`.
repoSlug string The repository.
commit string The commit for which to retrieve reports.
reportId string Uuid or external-if of the report for which to get annotations for.

Return type

[]ReportAnnotation

Authorization

api_key, basic, oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

CreateOrUpdateAnnotation

ReportAnnotation CreateOrUpdateAnnotation(ctx, body, workspace, repoSlug, commit, reportId, annotationId) Create or update an annotation

Creates or updates an individual annotation for the specified report. Annotations are individual findings that have been identified as part of a report, for example, a line of code that represents a vulnerability. These annotations can be attached to a specific file and even a specific line in that file, however, that is optional. Annotations are not mandatory and a report can contain up to 1000 annotations. Just as reports, annotation needs to be uploaded with a unique ID that can later be used to identify the report as an alternative to the generated UUID. If you want to use an existing id from your own system, we recommend prefixing it with your system's name to avoid collisions, for example, mySystem-annotation001. ### Sample cURL request: curl --request PUT 'https://api.bitbucket.org/2.0/repositories/<username>/<reposity-name>/commit/<commit-hash>/reports/mySystem-001/annotations/mysystem-annotation001' \\ --header 'Content-Type: application/json' \\ --data-raw '{ \"title\": \"Security scan report\", \"annotation_type\": \"VULNERABILITY\", \"summary\": \"This line represents a security thread.\", \"severity\": \"HIGH\", \"path\": \"my-service/src/main/java/com/myCompany/mysystem/logic/Main.java\", \"line\": 42 }' ### Possible field values: annotation_type: VULNERABILITY, CODE_SMELL, BUG result: PASSED, FAILED, IGNORED, SKIPPED severity: HIGH, MEDIUM, LOW, CRITICAL Please refer to the Code Insights documentation for more information.

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
body ReportAnnotation The annotation to create or update
workspace string This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example `{workspace UUID}`.
repoSlug string The repository.
commit string The commit the report belongs to.
reportId string Either the uuid or external-id of the report.
annotationId string Either the uuid or external-id of the annotation.

Return type

ReportAnnotation

Authorization

api_key, basic, oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

CreateOrUpdateReport

Report CreateOrUpdateReport(ctx, body, workspace, repoSlug, commit, reportId) Create or update a report

Creates or updates a report for the specified commit. To upload a report, make sure to generate an ID that is unique across all reports for that commit. If you want to use an existing id from your own system, we recommend prefixing it with your system's name to avoid collisions, for example, mySystem-001. ### Sample cURL request: curl --request PUT 'https://api.bitbucket.org/2.0/repositories/<username>/<reposity-name>/commit/<commit-hash>/reports/mysystem-001' \\ --header 'Content-Type: application/json' \\ --data-raw '{ \"title\": \"Security scan report\", \"details\": \"This pull request introduces 10 new dependency vulnerabilities.\", \"report_type\": \"SECURITY\", \"reporter\": \"mySystem\", \"link\": \"http://www.mysystem.com/reports/001\", \"result\": \"FAILED\", \"data\": [ { \"title\": \"Duration (seconds)\", \"type\": \"DURATION\", \"value\": 14 }, { \"title\": \"Safe to merge?\", \"type\": \"BOOLEAN\", \"value\": false } ] }' ### Possible field values: report_type: SECURITY, COVERAGE, TEST, BUG result: PASSED, FAILED, PENDING data.type: BOOLEAN, DATE, DURATION, LINK, NUMBER, PERCENTAGE, TEXT #### Data field formats | Type Field | Value Field Type | Value Field Display | |:--------------|:------------------|:--------------------| | None/ Omitted | Number, String or Boolean (not an array or object) | Plain text | | BOOLEAN | Boolean | The value will be read as a JSON boolean and displayed as 'Yes' or 'No'. | | DATE | Number | The value will be read as a JSON number in the form of a Unix timestamp (milliseconds) and will be displayed as a relative date if the date is less than one week ago, otherwise it will be displayed as an absolute date. | | DURATION | Number | The value will be read as a JSON number in milliseconds and will be displayed in a human readable duration format. | | LINK | Object: {\"text\": \"Link text here\", \"href\": \"https://link.to.annotation/in/external/tool\"} | The value will be read as a JSON object containing the fields "text" and "href" and will be displayed as a clickable link on the report. | | NUMBER | Number | The value will be read as a JSON number and large numbers will be displayed in a human readable format (e.g. 14.3k). | | PERCENTAGE | Number (between 0 and 100) | The value will be read as a JSON number between 0 and 100 and will be displayed with a percentage sign. | | TEXT | String | The value will be read as a JSON string and will be displayed as-is | Please refer to the Code Insights documentation for more information.

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
body Report The report to create or update
workspace string This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example `{workspace UUID}`.
repoSlug string The repository.
commit string The commit the report belongs to.
reportId string Either the uuid or external-id of the report.

Return type

Report

Authorization

api_key, basic, oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

DeleteAnnotation

DeleteAnnotation(ctx, workspace, repoSlug, commit, reportId, annotationId) Delete an annotation

Deletes a single Annotation matching the provided ID.

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
workspace string This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example `{workspace UUID}`.
repoSlug string The repository.
commit string The commit the annotation belongs to.
reportId string Either the uuid or external-id of the annotation.
annotationId string Either the uuid or external-id of the annotation.

Return type

(empty response body)

Authorization

api_key, basic, oauth2

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

[Back to top] [Back to API list] [Back to Model list] [Back to README]

DeleteReport

DeleteReport(ctx, workspace, repoSlug, commit, reportId) Delete a report

Deletes a single Report matching the provided ID.

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
workspace string This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example `{workspace UUID}`.
repoSlug string The repository.
commit string The commit the report belongs to.
reportId string Either the uuid or external-id of the report.

Return type

(empty response body)

Authorization

api_key, basic, oauth2

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetAnnotation

ReportAnnotation GetAnnotation(ctx, workspace, repoSlug, commit, reportId, annotationId) Get an annotation

Returns a single Annotation matching the provided ID.

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
workspace string This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example `{workspace UUID}`.
repoSlug string The repository.
commit string The commit the report belongs to.
reportId string Either the uuid or external-id of the report.
annotationId string Either the uuid or external-id of the annotation.

Return type

ReportAnnotation

Authorization

api_key, basic, oauth2

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetAnnotationsForReport

PaginatedAnnotations GetAnnotationsForReport(ctx, workspace, repoSlug, commit, reportId, optional) List annotations

Returns a paginated list of Annotations for a specified report.

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
workspace string This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example `{workspace UUID}`.
repoSlug string The repository.
commit string The commit for which to retrieve reports.
reportId string Uuid or external-if of the report for which to get annotations for.
optional *ReportsApiGetAnnotationsForReportOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a ReportsApiGetAnnotationsForReportOpts struct

Name Type Description Notes

page | optional.Int32| page |

Return type

PaginatedAnnotations

Authorization

api_key, basic, oauth2

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetReport

Report GetReport(ctx, workspace, repoSlug, commit, reportId) Get a report

Returns a single Report matching the provided ID.

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
workspace string This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example `{workspace UUID}`.
repoSlug string The repository.
commit string The commit the report belongs to.
reportId string Either the uuid or external-id of the report.

Return type

Report

Authorization

api_key, basic, oauth2

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetReportsForCommit

PaginatedReports GetReportsForCommit(ctx, workspace, repoSlug, commit, optional) List reports

Returns a paginated list of Reports linked to this commit.

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
workspace string This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example `{workspace UUID}`.
repoSlug string The repository.
commit string The commit for which to retrieve reports.
optional *ReportsApiGetReportsForCommitOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a ReportsApiGetReportsForCommitOpts struct

Name Type Description Notes

page | optional.Int32| page |

Return type

PaginatedReports

Authorization

api_key, basic, oauth2

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]