mirror of
https://github.com/rocky-linux/peridot.git
synced 2024-11-18 03:11:24 +00:00
381 lines
11 KiB
Go
381 lines
11 KiB
Go
/*
|
|
* Red Hat Security Data API
|
|
*
|
|
* Unofficial OpenAPI definitions for Red Hat Security Data API
|
|
*
|
|
* API version: 1.0
|
|
* Contact: mustafa@ctrliq.com
|
|
*/
|
|
|
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
|
|
package rhsecurity
|
|
|
|
import (
|
|
"bytes"
|
|
_context "context"
|
|
_ioutil "io/ioutil"
|
|
_nethttp "net/http"
|
|
_neturl "net/url"
|
|
"strings"
|
|
)
|
|
|
|
// Linger please
|
|
var (
|
|
_ _context.Context
|
|
)
|
|
|
|
type DefaultApi interface {
|
|
|
|
/*
|
|
* GetCve Get specific CVE
|
|
* Retrieve full CVE details
|
|
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param cVE
|
|
* @return ApiGetCveRequest
|
|
*/
|
|
GetCve(ctx _context.Context, cVE string) ApiGetCveRequest
|
|
|
|
/*
|
|
* GetCveExecute executes the request
|
|
* @return CVEDetailed
|
|
*/
|
|
GetCveExecute(r ApiGetCveRequest) (CVEDetailed, *_nethttp.Response, error)
|
|
|
|
/*
|
|
* GetCves Get CVEs
|
|
* List all the recent CVEs when no parameter is passed. Returns a convenience object as response with very minimum attributes.
|
|
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @return ApiGetCvesRequest
|
|
*/
|
|
GetCves(ctx _context.Context) ApiGetCvesRequest
|
|
|
|
/*
|
|
* GetCvesExecute executes the request
|
|
* @return []CVE
|
|
*/
|
|
GetCvesExecute(r ApiGetCvesRequest) ([]CVE, *_nethttp.Response, error)
|
|
}
|
|
|
|
// DefaultApiService DefaultApi service
|
|
type DefaultApiService service
|
|
|
|
type ApiGetCveRequest struct {
|
|
ctx _context.Context
|
|
ApiService DefaultApi
|
|
cVE string
|
|
}
|
|
|
|
func (r ApiGetCveRequest) Execute() (CVEDetailed, *_nethttp.Response, error) {
|
|
return r.ApiService.GetCveExecute(r)
|
|
}
|
|
|
|
/*
|
|
* GetCve Get specific CVE
|
|
* Retrieve full CVE details
|
|
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param cVE
|
|
* @return ApiGetCveRequest
|
|
*/
|
|
func (a *DefaultApiService) GetCve(ctx _context.Context, cVE string) ApiGetCveRequest {
|
|
return ApiGetCveRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
cVE: cVE,
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Execute executes the request
|
|
* @return CVEDetailed
|
|
*/
|
|
func (a *DefaultApiService) GetCveExecute(r ApiGetCveRequest) (CVEDetailed, *_nethttp.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = _nethttp.MethodGet
|
|
localVarPostBody interface{}
|
|
localVarFormFileName string
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue CVEDetailed
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetCve")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/cve/{CVE}.json"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"CVE"+"}", _neturl.PathEscape(parameterToString(r.cVE, "")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := _neturl.Values{}
|
|
localVarFormParams := _neturl.Values{}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = _ioutil.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type ApiGetCvesRequest struct {
|
|
ctx _context.Context
|
|
ApiService DefaultApi
|
|
before *string
|
|
after *string
|
|
ids *string
|
|
bug *string
|
|
advisory *string
|
|
severity *string
|
|
package_ *string
|
|
product *string
|
|
cwe *string
|
|
cvssScore *float32
|
|
cvss3Score *string
|
|
page *float32
|
|
perPage *float32
|
|
createdDaysAgo *float32
|
|
}
|
|
|
|
func (r ApiGetCvesRequest) Before(before string) ApiGetCvesRequest {
|
|
r.before = &before
|
|
return r
|
|
}
|
|
func (r ApiGetCvesRequest) After(after string) ApiGetCvesRequest {
|
|
r.after = &after
|
|
return r
|
|
}
|
|
func (r ApiGetCvesRequest) Ids(ids string) ApiGetCvesRequest {
|
|
r.ids = &ids
|
|
return r
|
|
}
|
|
func (r ApiGetCvesRequest) Bug(bug string) ApiGetCvesRequest {
|
|
r.bug = &bug
|
|
return r
|
|
}
|
|
func (r ApiGetCvesRequest) Advisory(advisory string) ApiGetCvesRequest {
|
|
r.advisory = &advisory
|
|
return r
|
|
}
|
|
func (r ApiGetCvesRequest) Severity(severity string) ApiGetCvesRequest {
|
|
r.severity = &severity
|
|
return r
|
|
}
|
|
func (r ApiGetCvesRequest) Package_(package_ string) ApiGetCvesRequest {
|
|
r.package_ = &package_
|
|
return r
|
|
}
|
|
func (r ApiGetCvesRequest) Product(product string) ApiGetCvesRequest {
|
|
r.product = &product
|
|
return r
|
|
}
|
|
func (r ApiGetCvesRequest) Cwe(cwe string) ApiGetCvesRequest {
|
|
r.cwe = &cwe
|
|
return r
|
|
}
|
|
func (r ApiGetCvesRequest) CvssScore(cvssScore float32) ApiGetCvesRequest {
|
|
r.cvssScore = &cvssScore
|
|
return r
|
|
}
|
|
func (r ApiGetCvesRequest) Cvss3Score(cvss3Score string) ApiGetCvesRequest {
|
|
r.cvss3Score = &cvss3Score
|
|
return r
|
|
}
|
|
func (r ApiGetCvesRequest) Page(page float32) ApiGetCvesRequest {
|
|
r.page = &page
|
|
return r
|
|
}
|
|
func (r ApiGetCvesRequest) PerPage(perPage float32) ApiGetCvesRequest {
|
|
r.perPage = &perPage
|
|
return r
|
|
}
|
|
func (r ApiGetCvesRequest) CreatedDaysAgo(createdDaysAgo float32) ApiGetCvesRequest {
|
|
r.createdDaysAgo = &createdDaysAgo
|
|
return r
|
|
}
|
|
|
|
func (r ApiGetCvesRequest) Execute() ([]CVE, *_nethttp.Response, error) {
|
|
return r.ApiService.GetCvesExecute(r)
|
|
}
|
|
|
|
/*
|
|
* GetCves Get CVEs
|
|
* List all the recent CVEs when no parameter is passed. Returns a convenience object as response with very minimum attributes.
|
|
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @return ApiGetCvesRequest
|
|
*/
|
|
func (a *DefaultApiService) GetCves(ctx _context.Context) ApiGetCvesRequest {
|
|
return ApiGetCvesRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Execute executes the request
|
|
* @return []CVE
|
|
*/
|
|
func (a *DefaultApiService) GetCvesExecute(r ApiGetCvesRequest) ([]CVE, *_nethttp.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = _nethttp.MethodGet
|
|
localVarPostBody interface{}
|
|
localVarFormFileName string
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue []CVE
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetCves")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/cve.json"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := _neturl.Values{}
|
|
localVarFormParams := _neturl.Values{}
|
|
|
|
if r.before != nil {
|
|
localVarQueryParams.Add("before", parameterToString(*r.before, ""))
|
|
}
|
|
if r.after != nil {
|
|
localVarQueryParams.Add("after", parameterToString(*r.after, ""))
|
|
}
|
|
if r.ids != nil {
|
|
localVarQueryParams.Add("ids", parameterToString(*r.ids, ""))
|
|
}
|
|
if r.bug != nil {
|
|
localVarQueryParams.Add("bug", parameterToString(*r.bug, ""))
|
|
}
|
|
if r.advisory != nil {
|
|
localVarQueryParams.Add("advisory", parameterToString(*r.advisory, ""))
|
|
}
|
|
if r.severity != nil {
|
|
localVarQueryParams.Add("severity", parameterToString(*r.severity, ""))
|
|
}
|
|
if r.package_ != nil {
|
|
localVarQueryParams.Add("package", parameterToString(*r.package_, ""))
|
|
}
|
|
if r.product != nil {
|
|
localVarQueryParams.Add("product", parameterToString(*r.product, ""))
|
|
}
|
|
if r.cwe != nil {
|
|
localVarQueryParams.Add("cwe", parameterToString(*r.cwe, ""))
|
|
}
|
|
if r.cvssScore != nil {
|
|
localVarQueryParams.Add("cvss_score", parameterToString(*r.cvssScore, ""))
|
|
}
|
|
if r.cvss3Score != nil {
|
|
localVarQueryParams.Add("cvss3_score", parameterToString(*r.cvss3Score, ""))
|
|
}
|
|
if r.page != nil {
|
|
localVarQueryParams.Add("page", parameterToString(*r.page, ""))
|
|
}
|
|
if r.perPage != nil {
|
|
localVarQueryParams.Add("per_page", parameterToString(*r.perPage, ""))
|
|
}
|
|
if r.createdDaysAgo != nil {
|
|
localVarQueryParams.Add("created_days_ago", parameterToString(*r.createdDaysAgo, ""))
|
|
}
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = _ioutil.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|