github.com/khulnasoft/codebase@v0.0.0-20231214144635-a707781cbb24/go-bitbucket/api_reports.go (about) 1 /* 2 * Bitbucket API 3 * 4 * Code against the Bitbucket API to automate simple tasks, embed Bitbucket data into your own site, build mobile or desktop apps, or even add custom UI add-ons into Bitbucket itself using the Connect framework. 5 * 6 * API version: 2.0 7 * Contact: support@bitbucket.org 8 */ 9 10 // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 11 12 package bitbucket 13 14 import ( 15 _context "context" 16 _ioutil "io/ioutil" 17 _nethttp "net/http" 18 _neturl "net/url" 19 "strings" 20 ) 21 22 // Linger please 23 var ( 24 _ _context.Context 25 ) 26 27 // ReportsApiService ReportsApi service 28 type ReportsApiService service 29 30 type ApiBulkCreateOrUpdateAnnotationsRequest struct { 31 ctx _context.Context 32 ApiService *ReportsApiService 33 username string 34 repoSlug string 35 commit string 36 reportId string 37 body *[]ReportAnnotation 38 } 39 40 func (r ApiBulkCreateOrUpdateAnnotationsRequest) Body(body []ReportAnnotation) ApiBulkCreateOrUpdateAnnotationsRequest { 41 r.body = &body 42 return r 43 } 44 45 func (r ApiBulkCreateOrUpdateAnnotationsRequest) Execute() ([]ReportAnnotation, *_nethttp.Response, error) { 46 return r.ApiService.BulkCreateOrUpdateAnnotationsExecute(r) 47 } 48 49 /* 50 * BulkCreateOrUpdateAnnotations Method for BulkCreateOrUpdateAnnotations 51 * Bulk upload of annotations. 52 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. 53 54 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](https://developer.atlassian.com/bitbucket/api/2/reference/meta/uri-uuid#uuid). You can upload up to 100 annotations per POST request. 55 56 ### Sample cURL request: 57 ``` 58 curl --location 'https://api.bitbucket.org/2.0/repositories/<username>/<reposity-name>/commit/<commit-hash>/reports/mysystem-001/annotations' \ 59 --header 'Content-Type: application/json' \ 60 --data-raw '[ 61 { 62 "external_id": "mysystem-annotation001", 63 "title": "Security scan report", 64 "annotation_type": "VULNERABILITY", 65 "summary": "This line represents a security threat.", 66 "severity": "HIGH", 67 "path": "my-service/src/main/java/com/myCompany/mysystem/logic/Main.java", 68 "line": 42 69 }, 70 { 71 "external_id": "mySystem-annotation002", 72 "title": "Bug report", 73 "annotation_type": "BUG", 74 "result": "FAILED", 75 "summary": "This line might introduce a bug.", 76 "severity": "MEDIUM", 77 "path": "my-service/src/main/java/com/myCompany/mysystem/logic/Helper.java", 78 "line": 13 79 } 80 ]' 81 ``` 82 83 ### Possible field values: 84 annotation_type: VULNERABILITY, CODE_SMELL, BUG 85 result: PASSED, FAILED, IGNORED, SKIPPED 86 severity: HIGH, MEDIUM, LOW, CRITICAL 87 88 Please refer to the [Code Insights documentation](https://confluence.atlassian.com/bitbucket/code-insights-994316785.html) for more information. 89 90 * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 91 * @param username The account. 92 * @param repoSlug The repository. 93 * @param commit The commit for which to retrieve reports. 94 * @param reportId Uuid or external-if of the report for which to get annotations for. 95 * @return ApiBulkCreateOrUpdateAnnotationsRequest 96 */ 97 func (a *ReportsApiService) BulkCreateOrUpdateAnnotations(ctx _context.Context, username string, repoSlug string, commit string, reportId string) ApiBulkCreateOrUpdateAnnotationsRequest { 98 return ApiBulkCreateOrUpdateAnnotationsRequest{ 99 ApiService: a, 100 ctx: ctx, 101 username: username, 102 repoSlug: repoSlug, 103 commit: commit, 104 reportId: reportId, 105 } 106 } 107 108 /* 109 * Execute executes the request 110 * @return []ReportAnnotation 111 */ 112 func (a *ReportsApiService) BulkCreateOrUpdateAnnotationsExecute(r ApiBulkCreateOrUpdateAnnotationsRequest) ([]ReportAnnotation, *_nethttp.Response, error) { 113 var ( 114 localVarHTTPMethod = _nethttp.MethodPost 115 localVarPostBody interface{} 116 localVarFormFileName string 117 localVarFileName string 118 localVarFileBytes []byte 119 localVarReturnValue []ReportAnnotation 120 ) 121 122 localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ReportsApiService.BulkCreateOrUpdateAnnotations") 123 if err != nil { 124 return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} 125 } 126 127 localVarPath := localBasePath + "/repositories/{username}/{repo_slug}/commit/{commit}/reports/{reportId}/annotations" 128 localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", _neturl.PathEscape(parameterToString(r.username, "")), -1) 129 localVarPath = strings.Replace(localVarPath, "{"+"repo_slug"+"}", _neturl.PathEscape(parameterToString(r.repoSlug, "")), -1) 130 localVarPath = strings.Replace(localVarPath, "{"+"commit"+"}", _neturl.PathEscape(parameterToString(r.commit, "")), -1) 131 localVarPath = strings.Replace(localVarPath, "{"+"reportId"+"}", _neturl.PathEscape(parameterToString(r.reportId, "")), -1) 132 133 localVarHeaderParams := make(map[string]string) 134 localVarQueryParams := _neturl.Values{} 135 localVarFormParams := _neturl.Values{} 136 if r.body == nil { 137 return localVarReturnValue, nil, reportError("body is required and must be specified") 138 } 139 if len(*r.body) < 1 { 140 return localVarReturnValue, nil, reportError("body must have at least 1 elements") 141 } 142 if len(*r.body) > 100 { 143 return localVarReturnValue, nil, reportError("body must have less than 100 elements") 144 } 145 146 // to determine the Content-Type header 147 localVarHTTPContentTypes := []string{"application/json"} 148 149 // set Content-Type header 150 localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) 151 if localVarHTTPContentType != "" { 152 localVarHeaderParams["Content-Type"] = localVarHTTPContentType 153 } 154 155 // to determine the Accept header 156 localVarHTTPHeaderAccepts := []string{"application/json"} 157 158 // set Accept header 159 localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) 160 if localVarHTTPHeaderAccept != "" { 161 localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept 162 } 163 // body params 164 localVarPostBody = r.body 165 req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) 166 if err != nil { 167 return localVarReturnValue, nil, err 168 } 169 170 localVarHTTPResponse, err := a.client.callAPI(req) 171 if err != nil || localVarHTTPResponse == nil { 172 return localVarReturnValue, localVarHTTPResponse, err 173 } 174 175 localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) 176 localVarHTTPResponse.Body.Close() 177 if err != nil { 178 return localVarReturnValue, localVarHTTPResponse, err 179 } 180 181 if localVarHTTPResponse.StatusCode >= 300 { 182 newErr := GenericOpenAPIError{ 183 body: localVarBody, 184 error: localVarHTTPResponse.Status, 185 } 186 return localVarReturnValue, localVarHTTPResponse, newErr 187 } 188 189 err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) 190 if err != nil { 191 newErr := GenericOpenAPIError{ 192 body: localVarBody, 193 error: err.Error(), 194 } 195 return localVarReturnValue, localVarHTTPResponse, newErr 196 } 197 198 return localVarReturnValue, localVarHTTPResponse, nil 199 } 200 201 type ApiCreateOrUpdateAnnotationRequest struct { 202 ctx _context.Context 203 ApiService *ReportsApiService 204 username string 205 repoSlug string 206 commit string 207 reportId string 208 annotationId string 209 body *ReportAnnotation 210 } 211 212 func (r ApiCreateOrUpdateAnnotationRequest) Body(body ReportAnnotation) ApiCreateOrUpdateAnnotationRequest { 213 r.body = &body 214 return r 215 } 216 217 func (r ApiCreateOrUpdateAnnotationRequest) Execute() (ReportAnnotation, *_nethttp.Response, error) { 218 return r.ApiService.CreateOrUpdateAnnotationExecute(r) 219 } 220 221 /* 222 * CreateOrUpdateAnnotation Method for CreateOrUpdateAnnotation 223 * Creates or updates an individual annotation for the specified report. 224 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. 225 226 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](https://developer.atlassian.com/bitbucket/api/2/reference/meta/uri-uuid#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. 227 228 ### Sample cURL request: 229 ``` 230 curl --request PUT 'https://api.bitbucket.org/2.0/repositories/<username>/<reposity-name>/commit/<commit-hash>/reports/mySystem-001/annotations/mysystem-annotation001' \ 231 --header 'Content-Type: application/json' \ 232 --data-raw '{ 233 "title": "Security scan report", 234 "annotation_type": "VULNERABILITY", 235 "summary": "This line represents a security thread.", 236 "severity": "HIGH", 237 "path": "my-service/src/main/java/com/myCompany/mysystem/logic/Main.java", 238 "line": 42 239 }' 240 ``` 241 242 ### Possible field values: 243 annotation_type: VULNERABILITY, CODE_SMELL, BUG 244 result: PASSED, FAILED, IGNORED, SKIPPED 245 severity: HIGH, MEDIUM, LOW, CRITICAL 246 247 Please refer to the [Code Insights documentation](https://confluence.atlassian.com/bitbucket/code-insights-994316785.html) for more information. 248 249 * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 250 * @param username The account. 251 * @param repoSlug The repository. 252 * @param commit The commit the report belongs to. 253 * @param reportId Either the uuid or external-id of the report. 254 * @param annotationId Either the uuid or external-id of the annotation. 255 * @return ApiCreateOrUpdateAnnotationRequest 256 */ 257 func (a *ReportsApiService) CreateOrUpdateAnnotation(ctx _context.Context, username string, repoSlug string, commit string, reportId string, annotationId string) ApiCreateOrUpdateAnnotationRequest { 258 return ApiCreateOrUpdateAnnotationRequest{ 259 ApiService: a, 260 ctx: ctx, 261 username: username, 262 repoSlug: repoSlug, 263 commit: commit, 264 reportId: reportId, 265 annotationId: annotationId, 266 } 267 } 268 269 /* 270 * Execute executes the request 271 * @return ReportAnnotation 272 */ 273 func (a *ReportsApiService) CreateOrUpdateAnnotationExecute(r ApiCreateOrUpdateAnnotationRequest) (ReportAnnotation, *_nethttp.Response, error) { 274 var ( 275 localVarHTTPMethod = _nethttp.MethodPut 276 localVarPostBody interface{} 277 localVarFormFileName string 278 localVarFileName string 279 localVarFileBytes []byte 280 localVarReturnValue ReportAnnotation 281 ) 282 283 localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ReportsApiService.CreateOrUpdateAnnotation") 284 if err != nil { 285 return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} 286 } 287 288 localVarPath := localBasePath + "/repositories/{username}/{repo_slug}/commit/{commit}/reports/{reportId}/annotations/{annotationId}" 289 localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", _neturl.PathEscape(parameterToString(r.username, "")), -1) 290 localVarPath = strings.Replace(localVarPath, "{"+"repo_slug"+"}", _neturl.PathEscape(parameterToString(r.repoSlug, "")), -1) 291 localVarPath = strings.Replace(localVarPath, "{"+"commit"+"}", _neturl.PathEscape(parameterToString(r.commit, "")), -1) 292 localVarPath = strings.Replace(localVarPath, "{"+"reportId"+"}", _neturl.PathEscape(parameterToString(r.reportId, "")), -1) 293 localVarPath = strings.Replace(localVarPath, "{"+"annotationId"+"}", _neturl.PathEscape(parameterToString(r.annotationId, "")), -1) 294 295 localVarHeaderParams := make(map[string]string) 296 localVarQueryParams := _neturl.Values{} 297 localVarFormParams := _neturl.Values{} 298 if r.body == nil { 299 return localVarReturnValue, nil, reportError("body is required and must be specified") 300 } 301 302 // to determine the Content-Type header 303 localVarHTTPContentTypes := []string{"application/json"} 304 305 // set Content-Type header 306 localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) 307 if localVarHTTPContentType != "" { 308 localVarHeaderParams["Content-Type"] = localVarHTTPContentType 309 } 310 311 // to determine the Accept header 312 localVarHTTPHeaderAccepts := []string{"application/json"} 313 314 // set Accept header 315 localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) 316 if localVarHTTPHeaderAccept != "" { 317 localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept 318 } 319 // body params 320 localVarPostBody = r.body 321 req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) 322 if err != nil { 323 return localVarReturnValue, nil, err 324 } 325 326 localVarHTTPResponse, err := a.client.callAPI(req) 327 if err != nil || localVarHTTPResponse == nil { 328 return localVarReturnValue, localVarHTTPResponse, err 329 } 330 331 localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) 332 localVarHTTPResponse.Body.Close() 333 if err != nil { 334 return localVarReturnValue, localVarHTTPResponse, err 335 } 336 337 if localVarHTTPResponse.StatusCode >= 300 { 338 newErr := GenericOpenAPIError{ 339 body: localVarBody, 340 error: localVarHTTPResponse.Status, 341 } 342 if localVarHTTPResponse.StatusCode == 400 { 343 var v ModelError 344 err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) 345 if err != nil { 346 newErr.error = err.Error() 347 return localVarReturnValue, localVarHTTPResponse, newErr 348 } 349 newErr.model = v 350 } 351 return localVarReturnValue, localVarHTTPResponse, newErr 352 } 353 354 err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) 355 if err != nil { 356 newErr := GenericOpenAPIError{ 357 body: localVarBody, 358 error: err.Error(), 359 } 360 return localVarReturnValue, localVarHTTPResponse, newErr 361 } 362 363 return localVarReturnValue, localVarHTTPResponse, nil 364 } 365 366 type ApiCreateOrUpdateReportRequest struct { 367 ctx _context.Context 368 ApiService *ReportsApiService 369 username string 370 repoSlug string 371 commit string 372 reportId string 373 body *Report 374 } 375 376 func (r ApiCreateOrUpdateReportRequest) Body(body Report) ApiCreateOrUpdateReportRequest { 377 r.body = &body 378 return r 379 } 380 381 func (r ApiCreateOrUpdateReportRequest) Execute() (Report, *_nethttp.Response, error) { 382 return r.ApiService.CreateOrUpdateReportExecute(r) 383 } 384 385 /* 386 * CreateOrUpdateReport Method for CreateOrUpdateReport 387 * Creates or updates a report for the specified commit. 388 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. 389 390 ### Sample cURL request: 391 ``` 392 curl --request PUT 'https://api.bitbucket.org/2.0/repositories/<username>/<reposity-name>/commit/<commit-hash>/reports/mysystem-001' \ 393 --header 'Content-Type: application/json' \ 394 --data-raw '{ 395 "title": "Security scan report", 396 "details": "This pull request introduces 10 new dependency vulnerabilities.", 397 "report_type": "SECURITY", 398 "reporter": "mySystem", 399 "link": "http://www.mysystem.com/reports/001", 400 "result": "FAILED", 401 "data": [ 402 { 403 "title": "Duration (seconds)", 404 "type": "DURATION", 405 "value": 14 406 }, 407 { 408 "title": "Safe to merge?", 409 "type": "BOOLEAN", 410 "value": false 411 } 412 ] 413 }' 414 ``` 415 416 ### Possible field values: 417 report_type: SECURITY, COVERAGE, TEST, BUG 418 result: PASSED, FAILED, PENDING 419 data.type: BOOLEAN, DATE, DURATION, LINK, NUMBER, PERCENTAGE, TEXT 420 421 Please refer to the [Code Insights documentation](https://confluence.atlassian.com/bitbucket/code-insights-994316785.html) for more information. 422 423 * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 424 * @param username The account. 425 * @param repoSlug The repository. 426 * @param commit The commit the report belongs to. 427 * @param reportId Either the uuid or external-id of the report. 428 * @return ApiCreateOrUpdateReportRequest 429 */ 430 func (a *ReportsApiService) CreateOrUpdateReport(ctx _context.Context, username string, repoSlug string, commit string, reportId string) ApiCreateOrUpdateReportRequest { 431 return ApiCreateOrUpdateReportRequest{ 432 ApiService: a, 433 ctx: ctx, 434 username: username, 435 repoSlug: repoSlug, 436 commit: commit, 437 reportId: reportId, 438 } 439 } 440 441 /* 442 * Execute executes the request 443 * @return Report 444 */ 445 func (a *ReportsApiService) CreateOrUpdateReportExecute(r ApiCreateOrUpdateReportRequest) (Report, *_nethttp.Response, error) { 446 var ( 447 localVarHTTPMethod = _nethttp.MethodPut 448 localVarPostBody interface{} 449 localVarFormFileName string 450 localVarFileName string 451 localVarFileBytes []byte 452 localVarReturnValue Report 453 ) 454 455 localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ReportsApiService.CreateOrUpdateReport") 456 if err != nil { 457 return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} 458 } 459 460 localVarPath := localBasePath + "/repositories/{username}/{repo_slug}/commit/{commit}/reports/{reportId}" 461 localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", _neturl.PathEscape(parameterToString(r.username, "")), -1) 462 localVarPath = strings.Replace(localVarPath, "{"+"repo_slug"+"}", _neturl.PathEscape(parameterToString(r.repoSlug, "")), -1) 463 localVarPath = strings.Replace(localVarPath, "{"+"commit"+"}", _neturl.PathEscape(parameterToString(r.commit, "")), -1) 464 localVarPath = strings.Replace(localVarPath, "{"+"reportId"+"}", _neturl.PathEscape(parameterToString(r.reportId, "")), -1) 465 466 localVarHeaderParams := make(map[string]string) 467 localVarQueryParams := _neturl.Values{} 468 localVarFormParams := _neturl.Values{} 469 if r.body == nil { 470 return localVarReturnValue, nil, reportError("body is required and must be specified") 471 } 472 473 // to determine the Content-Type header 474 localVarHTTPContentTypes := []string{"application/json"} 475 476 // set Content-Type header 477 localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) 478 if localVarHTTPContentType != "" { 479 localVarHeaderParams["Content-Type"] = localVarHTTPContentType 480 } 481 482 // to determine the Accept header 483 localVarHTTPHeaderAccepts := []string{"application/json"} 484 485 // set Accept header 486 localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) 487 if localVarHTTPHeaderAccept != "" { 488 localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept 489 } 490 // body params 491 localVarPostBody = r.body 492 req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) 493 if err != nil { 494 return localVarReturnValue, nil, err 495 } 496 497 localVarHTTPResponse, err := a.client.callAPI(req) 498 if err != nil || localVarHTTPResponse == nil { 499 return localVarReturnValue, localVarHTTPResponse, err 500 } 501 502 localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) 503 localVarHTTPResponse.Body.Close() 504 if err != nil { 505 return localVarReturnValue, localVarHTTPResponse, err 506 } 507 508 if localVarHTTPResponse.StatusCode >= 300 { 509 newErr := GenericOpenAPIError{ 510 body: localVarBody, 511 error: localVarHTTPResponse.Status, 512 } 513 if localVarHTTPResponse.StatusCode == 400 { 514 var v ModelError 515 err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) 516 if err != nil { 517 newErr.error = err.Error() 518 return localVarReturnValue, localVarHTTPResponse, newErr 519 } 520 newErr.model = v 521 } 522 return localVarReturnValue, localVarHTTPResponse, newErr 523 } 524 525 err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) 526 if err != nil { 527 newErr := GenericOpenAPIError{ 528 body: localVarBody, 529 error: err.Error(), 530 } 531 return localVarReturnValue, localVarHTTPResponse, newErr 532 } 533 534 return localVarReturnValue, localVarHTTPResponse, nil 535 } 536 537 type ApiDeleteAnnotationRequest struct { 538 ctx _context.Context 539 ApiService *ReportsApiService 540 username string 541 repoSlug string 542 commit string 543 reportId string 544 annotationId string 545 } 546 547 func (r ApiDeleteAnnotationRequest) Execute() (*_nethttp.Response, error) { 548 return r.ApiService.DeleteAnnotationExecute(r) 549 } 550 551 /* 552 * DeleteAnnotation Method for DeleteAnnotation 553 * Deletes a single Annotation matching the provided ID. 554 * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 555 * @param username The account. 556 * @param repoSlug The repository. 557 * @param commit The commit the annotation belongs to. 558 * @param reportId Either the uuid or external-id of the annotation. 559 * @param annotationId Either the uuid or external-id of the annotation. 560 * @return ApiDeleteAnnotationRequest 561 */ 562 func (a *ReportsApiService) DeleteAnnotation(ctx _context.Context, username string, repoSlug string, commit string, reportId string, annotationId string) ApiDeleteAnnotationRequest { 563 return ApiDeleteAnnotationRequest{ 564 ApiService: a, 565 ctx: ctx, 566 username: username, 567 repoSlug: repoSlug, 568 commit: commit, 569 reportId: reportId, 570 annotationId: annotationId, 571 } 572 } 573 574 /* 575 * Execute executes the request 576 */ 577 func (a *ReportsApiService) DeleteAnnotationExecute(r ApiDeleteAnnotationRequest) (*_nethttp.Response, error) { 578 var ( 579 localVarHTTPMethod = _nethttp.MethodDelete 580 localVarPostBody interface{} 581 localVarFormFileName string 582 localVarFileName string 583 localVarFileBytes []byte 584 ) 585 586 localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ReportsApiService.DeleteAnnotation") 587 if err != nil { 588 return nil, GenericOpenAPIError{error: err.Error()} 589 } 590 591 localVarPath := localBasePath + "/repositories/{username}/{repo_slug}/commit/{commit}/reports/{reportId}/annotations/{annotationId}" 592 localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", _neturl.PathEscape(parameterToString(r.username, "")), -1) 593 localVarPath = strings.Replace(localVarPath, "{"+"repo_slug"+"}", _neturl.PathEscape(parameterToString(r.repoSlug, "")), -1) 594 localVarPath = strings.Replace(localVarPath, "{"+"commit"+"}", _neturl.PathEscape(parameterToString(r.commit, "")), -1) 595 localVarPath = strings.Replace(localVarPath, "{"+"reportId"+"}", _neturl.PathEscape(parameterToString(r.reportId, "")), -1) 596 localVarPath = strings.Replace(localVarPath, "{"+"annotationId"+"}", _neturl.PathEscape(parameterToString(r.annotationId, "")), -1) 597 598 localVarHeaderParams := make(map[string]string) 599 localVarQueryParams := _neturl.Values{} 600 localVarFormParams := _neturl.Values{} 601 602 // to determine the Content-Type header 603 localVarHTTPContentTypes := []string{} 604 605 // set Content-Type header 606 localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) 607 if localVarHTTPContentType != "" { 608 localVarHeaderParams["Content-Type"] = localVarHTTPContentType 609 } 610 611 // to determine the Accept header 612 localVarHTTPHeaderAccepts := []string{} 613 614 // set Accept header 615 localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) 616 if localVarHTTPHeaderAccept != "" { 617 localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept 618 } 619 req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) 620 if err != nil { 621 return nil, err 622 } 623 624 localVarHTTPResponse, err := a.client.callAPI(req) 625 if err != nil || localVarHTTPResponse == nil { 626 return localVarHTTPResponse, err 627 } 628 629 localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) 630 localVarHTTPResponse.Body.Close() 631 if err != nil { 632 return localVarHTTPResponse, err 633 } 634 635 if localVarHTTPResponse.StatusCode >= 300 { 636 newErr := GenericOpenAPIError{ 637 body: localVarBody, 638 error: localVarHTTPResponse.Status, 639 } 640 return localVarHTTPResponse, newErr 641 } 642 643 return localVarHTTPResponse, nil 644 } 645 646 type ApiDeleteReportRequest struct { 647 ctx _context.Context 648 ApiService *ReportsApiService 649 username string 650 repoSlug string 651 commit string 652 reportId string 653 } 654 655 func (r ApiDeleteReportRequest) Execute() (*_nethttp.Response, error) { 656 return r.ApiService.DeleteReportExecute(r) 657 } 658 659 /* 660 * DeleteReport Method for DeleteReport 661 * Deletes a single Report matching the provided ID. 662 * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 663 * @param username The account. 664 * @param repoSlug The repository. 665 * @param commit The commit the report belongs to. 666 * @param reportId Either the uuid or external-id of the report. 667 * @return ApiDeleteReportRequest 668 */ 669 func (a *ReportsApiService) DeleteReport(ctx _context.Context, username string, repoSlug string, commit string, reportId string) ApiDeleteReportRequest { 670 return ApiDeleteReportRequest{ 671 ApiService: a, 672 ctx: ctx, 673 username: username, 674 repoSlug: repoSlug, 675 commit: commit, 676 reportId: reportId, 677 } 678 } 679 680 /* 681 * Execute executes the request 682 */ 683 func (a *ReportsApiService) DeleteReportExecute(r ApiDeleteReportRequest) (*_nethttp.Response, error) { 684 var ( 685 localVarHTTPMethod = _nethttp.MethodDelete 686 localVarPostBody interface{} 687 localVarFormFileName string 688 localVarFileName string 689 localVarFileBytes []byte 690 ) 691 692 localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ReportsApiService.DeleteReport") 693 if err != nil { 694 return nil, GenericOpenAPIError{error: err.Error()} 695 } 696 697 localVarPath := localBasePath + "/repositories/{username}/{repo_slug}/commit/{commit}/reports/{reportId}" 698 localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", _neturl.PathEscape(parameterToString(r.username, "")), -1) 699 localVarPath = strings.Replace(localVarPath, "{"+"repo_slug"+"}", _neturl.PathEscape(parameterToString(r.repoSlug, "")), -1) 700 localVarPath = strings.Replace(localVarPath, "{"+"commit"+"}", _neturl.PathEscape(parameterToString(r.commit, "")), -1) 701 localVarPath = strings.Replace(localVarPath, "{"+"reportId"+"}", _neturl.PathEscape(parameterToString(r.reportId, "")), -1) 702 703 localVarHeaderParams := make(map[string]string) 704 localVarQueryParams := _neturl.Values{} 705 localVarFormParams := _neturl.Values{} 706 707 // to determine the Content-Type header 708 localVarHTTPContentTypes := []string{} 709 710 // set Content-Type header 711 localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) 712 if localVarHTTPContentType != "" { 713 localVarHeaderParams["Content-Type"] = localVarHTTPContentType 714 } 715 716 // to determine the Accept header 717 localVarHTTPHeaderAccepts := []string{} 718 719 // set Accept header 720 localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) 721 if localVarHTTPHeaderAccept != "" { 722 localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept 723 } 724 req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) 725 if err != nil { 726 return nil, err 727 } 728 729 localVarHTTPResponse, err := a.client.callAPI(req) 730 if err != nil || localVarHTTPResponse == nil { 731 return localVarHTTPResponse, err 732 } 733 734 localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) 735 localVarHTTPResponse.Body.Close() 736 if err != nil { 737 return localVarHTTPResponse, err 738 } 739 740 if localVarHTTPResponse.StatusCode >= 300 { 741 newErr := GenericOpenAPIError{ 742 body: localVarBody, 743 error: localVarHTTPResponse.Status, 744 } 745 return localVarHTTPResponse, newErr 746 } 747 748 return localVarHTTPResponse, nil 749 } 750 751 type ApiGetAnnotationRequest struct { 752 ctx _context.Context 753 ApiService *ReportsApiService 754 username string 755 repoSlug string 756 commit string 757 reportId string 758 annotationId string 759 } 760 761 func (r ApiGetAnnotationRequest) Execute() (ReportAnnotation, *_nethttp.Response, error) { 762 return r.ApiService.GetAnnotationExecute(r) 763 } 764 765 /* 766 * GetAnnotation Method for GetAnnotation 767 * Returns a single Annotation matching the provided ID. 768 * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 769 * @param username The account. 770 * @param repoSlug The repository. 771 * @param commit The commit the report belongs to. 772 * @param reportId Either the uuid or external-id of the report. 773 * @param annotationId Either the uuid or external-id of the annotation. 774 * @return ApiGetAnnotationRequest 775 */ 776 func (a *ReportsApiService) GetAnnotation(ctx _context.Context, username string, repoSlug string, commit string, reportId string, annotationId string) ApiGetAnnotationRequest { 777 return ApiGetAnnotationRequest{ 778 ApiService: a, 779 ctx: ctx, 780 username: username, 781 repoSlug: repoSlug, 782 commit: commit, 783 reportId: reportId, 784 annotationId: annotationId, 785 } 786 } 787 788 /* 789 * Execute executes the request 790 * @return ReportAnnotation 791 */ 792 func (a *ReportsApiService) GetAnnotationExecute(r ApiGetAnnotationRequest) (ReportAnnotation, *_nethttp.Response, error) { 793 var ( 794 localVarHTTPMethod = _nethttp.MethodGet 795 localVarPostBody interface{} 796 localVarFormFileName string 797 localVarFileName string 798 localVarFileBytes []byte 799 localVarReturnValue ReportAnnotation 800 ) 801 802 localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ReportsApiService.GetAnnotation") 803 if err != nil { 804 return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} 805 } 806 807 localVarPath := localBasePath + "/repositories/{username}/{repo_slug}/commit/{commit}/reports/{reportId}/annotations/{annotationId}" 808 localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", _neturl.PathEscape(parameterToString(r.username, "")), -1) 809 localVarPath = strings.Replace(localVarPath, "{"+"repo_slug"+"}", _neturl.PathEscape(parameterToString(r.repoSlug, "")), -1) 810 localVarPath = strings.Replace(localVarPath, "{"+"commit"+"}", _neturl.PathEscape(parameterToString(r.commit, "")), -1) 811 localVarPath = strings.Replace(localVarPath, "{"+"reportId"+"}", _neturl.PathEscape(parameterToString(r.reportId, "")), -1) 812 localVarPath = strings.Replace(localVarPath, "{"+"annotationId"+"}", _neturl.PathEscape(parameterToString(r.annotationId, "")), -1) 813 814 localVarHeaderParams := make(map[string]string) 815 localVarQueryParams := _neturl.Values{} 816 localVarFormParams := _neturl.Values{} 817 818 // to determine the Content-Type header 819 localVarHTTPContentTypes := []string{} 820 821 // set Content-Type header 822 localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) 823 if localVarHTTPContentType != "" { 824 localVarHeaderParams["Content-Type"] = localVarHTTPContentType 825 } 826 827 // to determine the Accept header 828 localVarHTTPHeaderAccepts := []string{"application/json"} 829 830 // set Accept header 831 localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) 832 if localVarHTTPHeaderAccept != "" { 833 localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept 834 } 835 req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) 836 if err != nil { 837 return localVarReturnValue, nil, err 838 } 839 840 localVarHTTPResponse, err := a.client.callAPI(req) 841 if err != nil || localVarHTTPResponse == nil { 842 return localVarReturnValue, localVarHTTPResponse, err 843 } 844 845 localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) 846 localVarHTTPResponse.Body.Close() 847 if err != nil { 848 return localVarReturnValue, localVarHTTPResponse, err 849 } 850 851 if localVarHTTPResponse.StatusCode >= 300 { 852 newErr := GenericOpenAPIError{ 853 body: localVarBody, 854 error: localVarHTTPResponse.Status, 855 } 856 if localVarHTTPResponse.StatusCode == 404 { 857 var v ModelError 858 err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) 859 if err != nil { 860 newErr.error = err.Error() 861 return localVarReturnValue, localVarHTTPResponse, newErr 862 } 863 newErr.model = v 864 } 865 return localVarReturnValue, localVarHTTPResponse, newErr 866 } 867 868 err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) 869 if err != nil { 870 newErr := GenericOpenAPIError{ 871 body: localVarBody, 872 error: err.Error(), 873 } 874 return localVarReturnValue, localVarHTTPResponse, newErr 875 } 876 877 return localVarReturnValue, localVarHTTPResponse, nil 878 } 879 880 type ApiGetAnnotationsForReportRequest struct { 881 ctx _context.Context 882 ApiService *ReportsApiService 883 username string 884 repoSlug string 885 commit string 886 reportId string 887 } 888 889 func (r ApiGetAnnotationsForReportRequest) Execute() (PaginatedAnnotations, *_nethttp.Response, error) { 890 return r.ApiService.GetAnnotationsForReportExecute(r) 891 } 892 893 /* 894 * GetAnnotationsForReport Method for GetAnnotationsForReport 895 * Returns a paginated list of Annotations for a specified report. 896 * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 897 * @param username The account. 898 * @param repoSlug The repository. 899 * @param commit The commit for which to retrieve reports. 900 * @param reportId Uuid or external-if of the report for which to get annotations for. 901 * @return ApiGetAnnotationsForReportRequest 902 */ 903 func (a *ReportsApiService) GetAnnotationsForReport(ctx _context.Context, username string, repoSlug string, commit string, reportId string) ApiGetAnnotationsForReportRequest { 904 return ApiGetAnnotationsForReportRequest{ 905 ApiService: a, 906 ctx: ctx, 907 username: username, 908 repoSlug: repoSlug, 909 commit: commit, 910 reportId: reportId, 911 } 912 } 913 914 /* 915 * Execute executes the request 916 * @return PaginatedAnnotations 917 */ 918 func (a *ReportsApiService) GetAnnotationsForReportExecute(r ApiGetAnnotationsForReportRequest) (PaginatedAnnotations, *_nethttp.Response, error) { 919 var ( 920 localVarHTTPMethod = _nethttp.MethodGet 921 localVarPostBody interface{} 922 localVarFormFileName string 923 localVarFileName string 924 localVarFileBytes []byte 925 localVarReturnValue PaginatedAnnotations 926 ) 927 928 localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ReportsApiService.GetAnnotationsForReport") 929 if err != nil { 930 return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} 931 } 932 933 localVarPath := localBasePath + "/repositories/{username}/{repo_slug}/commit/{commit}/reports/{reportId}/annotations" 934 localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", _neturl.PathEscape(parameterToString(r.username, "")), -1) 935 localVarPath = strings.Replace(localVarPath, "{"+"repo_slug"+"}", _neturl.PathEscape(parameterToString(r.repoSlug, "")), -1) 936 localVarPath = strings.Replace(localVarPath, "{"+"commit"+"}", _neturl.PathEscape(parameterToString(r.commit, "")), -1) 937 localVarPath = strings.Replace(localVarPath, "{"+"reportId"+"}", _neturl.PathEscape(parameterToString(r.reportId, "")), -1) 938 939 localVarHeaderParams := make(map[string]string) 940 localVarQueryParams := _neturl.Values{} 941 localVarFormParams := _neturl.Values{} 942 943 // to determine the Content-Type header 944 localVarHTTPContentTypes := []string{} 945 946 // set Content-Type header 947 localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) 948 if localVarHTTPContentType != "" { 949 localVarHeaderParams["Content-Type"] = localVarHTTPContentType 950 } 951 952 // to determine the Accept header 953 localVarHTTPHeaderAccepts := []string{"application/json"} 954 955 // set Accept header 956 localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) 957 if localVarHTTPHeaderAccept != "" { 958 localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept 959 } 960 req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) 961 if err != nil { 962 return localVarReturnValue, nil, err 963 } 964 965 localVarHTTPResponse, err := a.client.callAPI(req) 966 if err != nil || localVarHTTPResponse == nil { 967 return localVarReturnValue, localVarHTTPResponse, err 968 } 969 970 localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) 971 localVarHTTPResponse.Body.Close() 972 if err != nil { 973 return localVarReturnValue, localVarHTTPResponse, err 974 } 975 976 if localVarHTTPResponse.StatusCode >= 300 { 977 newErr := GenericOpenAPIError{ 978 body: localVarBody, 979 error: localVarHTTPResponse.Status, 980 } 981 return localVarReturnValue, localVarHTTPResponse, newErr 982 } 983 984 err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) 985 if err != nil { 986 newErr := GenericOpenAPIError{ 987 body: localVarBody, 988 error: err.Error(), 989 } 990 return localVarReturnValue, localVarHTTPResponse, newErr 991 } 992 993 return localVarReturnValue, localVarHTTPResponse, nil 994 } 995 996 type ApiGetReportRequest struct { 997 ctx _context.Context 998 ApiService *ReportsApiService 999 username string 1000 repoSlug string 1001 commit string 1002 reportId string 1003 } 1004 1005 func (r ApiGetReportRequest) Execute() (Report, *_nethttp.Response, error) { 1006 return r.ApiService.GetReportExecute(r) 1007 } 1008 1009 /* 1010 * GetReport Method for GetReport 1011 * Returns a single Report matching the provided ID. 1012 * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 1013 * @param username The account. 1014 * @param repoSlug The repository. 1015 * @param commit The commit the report belongs to. 1016 * @param reportId Either the uuid or external-id of the report. 1017 * @return ApiGetReportRequest 1018 */ 1019 func (a *ReportsApiService) GetReport(ctx _context.Context, username string, repoSlug string, commit string, reportId string) ApiGetReportRequest { 1020 return ApiGetReportRequest{ 1021 ApiService: a, 1022 ctx: ctx, 1023 username: username, 1024 repoSlug: repoSlug, 1025 commit: commit, 1026 reportId: reportId, 1027 } 1028 } 1029 1030 /* 1031 * Execute executes the request 1032 * @return Report 1033 */ 1034 func (a *ReportsApiService) GetReportExecute(r ApiGetReportRequest) (Report, *_nethttp.Response, error) { 1035 var ( 1036 localVarHTTPMethod = _nethttp.MethodGet 1037 localVarPostBody interface{} 1038 localVarFormFileName string 1039 localVarFileName string 1040 localVarFileBytes []byte 1041 localVarReturnValue Report 1042 ) 1043 1044 localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ReportsApiService.GetReport") 1045 if err != nil { 1046 return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} 1047 } 1048 1049 localVarPath := localBasePath + "/repositories/{username}/{repo_slug}/commit/{commit}/reports/{reportId}" 1050 localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", _neturl.PathEscape(parameterToString(r.username, "")), -1) 1051 localVarPath = strings.Replace(localVarPath, "{"+"repo_slug"+"}", _neturl.PathEscape(parameterToString(r.repoSlug, "")), -1) 1052 localVarPath = strings.Replace(localVarPath, "{"+"commit"+"}", _neturl.PathEscape(parameterToString(r.commit, "")), -1) 1053 localVarPath = strings.Replace(localVarPath, "{"+"reportId"+"}", _neturl.PathEscape(parameterToString(r.reportId, "")), -1) 1054 1055 localVarHeaderParams := make(map[string]string) 1056 localVarQueryParams := _neturl.Values{} 1057 localVarFormParams := _neturl.Values{} 1058 1059 // to determine the Content-Type header 1060 localVarHTTPContentTypes := []string{} 1061 1062 // set Content-Type header 1063 localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) 1064 if localVarHTTPContentType != "" { 1065 localVarHeaderParams["Content-Type"] = localVarHTTPContentType 1066 } 1067 1068 // to determine the Accept header 1069 localVarHTTPHeaderAccepts := []string{"application/json"} 1070 1071 // set Accept header 1072 localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) 1073 if localVarHTTPHeaderAccept != "" { 1074 localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept 1075 } 1076 req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) 1077 if err != nil { 1078 return localVarReturnValue, nil, err 1079 } 1080 1081 localVarHTTPResponse, err := a.client.callAPI(req) 1082 if err != nil || localVarHTTPResponse == nil { 1083 return localVarReturnValue, localVarHTTPResponse, err 1084 } 1085 1086 localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) 1087 localVarHTTPResponse.Body.Close() 1088 if err != nil { 1089 return localVarReturnValue, localVarHTTPResponse, err 1090 } 1091 1092 if localVarHTTPResponse.StatusCode >= 300 { 1093 newErr := GenericOpenAPIError{ 1094 body: localVarBody, 1095 error: localVarHTTPResponse.Status, 1096 } 1097 if localVarHTTPResponse.StatusCode == 404 { 1098 var v ModelError 1099 err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) 1100 if err != nil { 1101 newErr.error = err.Error() 1102 return localVarReturnValue, localVarHTTPResponse, newErr 1103 } 1104 newErr.model = v 1105 } 1106 return localVarReturnValue, localVarHTTPResponse, newErr 1107 } 1108 1109 err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) 1110 if err != nil { 1111 newErr := GenericOpenAPIError{ 1112 body: localVarBody, 1113 error: err.Error(), 1114 } 1115 return localVarReturnValue, localVarHTTPResponse, newErr 1116 } 1117 1118 return localVarReturnValue, localVarHTTPResponse, nil 1119 } 1120 1121 type ApiGetReportsForCommitRequest struct { 1122 ctx _context.Context 1123 ApiService *ReportsApiService 1124 username string 1125 repoSlug string 1126 commit string 1127 } 1128 1129 func (r ApiGetReportsForCommitRequest) Execute() (PaginatedReports, *_nethttp.Response, error) { 1130 return r.ApiService.GetReportsForCommitExecute(r) 1131 } 1132 1133 /* 1134 * GetReportsForCommit Method for GetReportsForCommit 1135 * Returns a paginated list of Reports linked to this commit. 1136 * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 1137 * @param username The account. 1138 * @param repoSlug The repository. 1139 * @param commit The commit for which to retrieve reports. 1140 * @return ApiGetReportsForCommitRequest 1141 */ 1142 func (a *ReportsApiService) GetReportsForCommit(ctx _context.Context, username string, repoSlug string, commit string) ApiGetReportsForCommitRequest { 1143 return ApiGetReportsForCommitRequest{ 1144 ApiService: a, 1145 ctx: ctx, 1146 username: username, 1147 repoSlug: repoSlug, 1148 commit: commit, 1149 } 1150 } 1151 1152 /* 1153 * Execute executes the request 1154 * @return PaginatedReports 1155 */ 1156 func (a *ReportsApiService) GetReportsForCommitExecute(r ApiGetReportsForCommitRequest) (PaginatedReports, *_nethttp.Response, error) { 1157 var ( 1158 localVarHTTPMethod = _nethttp.MethodGet 1159 localVarPostBody interface{} 1160 localVarFormFileName string 1161 localVarFileName string 1162 localVarFileBytes []byte 1163 localVarReturnValue PaginatedReports 1164 ) 1165 1166 localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ReportsApiService.GetReportsForCommit") 1167 if err != nil { 1168 return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} 1169 } 1170 1171 localVarPath := localBasePath + "/repositories/{username}/{repo_slug}/commit/{commit}/reports" 1172 localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", _neturl.PathEscape(parameterToString(r.username, "")), -1) 1173 localVarPath = strings.Replace(localVarPath, "{"+"repo_slug"+"}", _neturl.PathEscape(parameterToString(r.repoSlug, "")), -1) 1174 localVarPath = strings.Replace(localVarPath, "{"+"commit"+"}", _neturl.PathEscape(parameterToString(r.commit, "")), -1) 1175 1176 localVarHeaderParams := make(map[string]string) 1177 localVarQueryParams := _neturl.Values{} 1178 localVarFormParams := _neturl.Values{} 1179 1180 // to determine the Content-Type header 1181 localVarHTTPContentTypes := []string{} 1182 1183 // set Content-Type header 1184 localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) 1185 if localVarHTTPContentType != "" { 1186 localVarHeaderParams["Content-Type"] = localVarHTTPContentType 1187 } 1188 1189 // to determine the Accept header 1190 localVarHTTPHeaderAccepts := []string{"application/json"} 1191 1192 // set Accept header 1193 localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) 1194 if localVarHTTPHeaderAccept != "" { 1195 localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept 1196 } 1197 req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) 1198 if err != nil { 1199 return localVarReturnValue, nil, err 1200 } 1201 1202 localVarHTTPResponse, err := a.client.callAPI(req) 1203 if err != nil || localVarHTTPResponse == nil { 1204 return localVarReturnValue, localVarHTTPResponse, err 1205 } 1206 1207 localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) 1208 localVarHTTPResponse.Body.Close() 1209 if err != nil { 1210 return localVarReturnValue, localVarHTTPResponse, err 1211 } 1212 1213 if localVarHTTPResponse.StatusCode >= 300 { 1214 newErr := GenericOpenAPIError{ 1215 body: localVarBody, 1216 error: localVarHTTPResponse.Status, 1217 } 1218 return localVarReturnValue, localVarHTTPResponse, newErr 1219 } 1220 1221 err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) 1222 if err != nil { 1223 newErr := GenericOpenAPIError{ 1224 body: localVarBody, 1225 error: err.Error(), 1226 } 1227 return localVarReturnValue, localVarHTTPResponse, newErr 1228 } 1229 1230 return localVarReturnValue, localVarHTTPResponse, nil 1231 }