diff --git a/client/test_executions/test_execution_traffic_diff_findings_parameters.go b/client/test_executions/test_execution_traffic_diff_findings_parameters.go new file mode 100644 index 0000000..097e7f1 --- /dev/null +++ b/client/test_executions/test_execution_traffic_diff_findings_parameters.go @@ -0,0 +1,297 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package test_executions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewTestExecutionTrafficDiffFindingsParams creates a new TestExecutionTrafficDiffFindingsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewTestExecutionTrafficDiffFindingsParams() *TestExecutionTrafficDiffFindingsParams { + return &TestExecutionTrafficDiffFindingsParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewTestExecutionTrafficDiffFindingsParamsWithTimeout creates a new TestExecutionTrafficDiffFindingsParams object +// with the ability to set a timeout on a request. +func NewTestExecutionTrafficDiffFindingsParamsWithTimeout(timeout time.Duration) *TestExecutionTrafficDiffFindingsParams { + return &TestExecutionTrafficDiffFindingsParams{ + timeout: timeout, + } +} + +// NewTestExecutionTrafficDiffFindingsParamsWithContext creates a new TestExecutionTrafficDiffFindingsParams object +// with the ability to set a context for a request. +func NewTestExecutionTrafficDiffFindingsParamsWithContext(ctx context.Context) *TestExecutionTrafficDiffFindingsParams { + return &TestExecutionTrafficDiffFindingsParams{ + Context: ctx, + } +} + +// NewTestExecutionTrafficDiffFindingsParamsWithHTTPClient creates a new TestExecutionTrafficDiffFindingsParams object +// with the ability to set a custom HTTPClient for a request. +func NewTestExecutionTrafficDiffFindingsParamsWithHTTPClient(client *http.Client) *TestExecutionTrafficDiffFindingsParams { + return &TestExecutionTrafficDiffFindingsParams{ + HTTPClient: client, + } +} + +/* +TestExecutionTrafficDiffFindingsParams contains all the parameters to send to the API endpoint + + for the test execution traffic diff findings operation. + + Typically these are written to a http.Request. +*/ +type TestExecutionTrafficDiffFindingsParams struct { + + /* Category. + + Category + */ + Category *string + + /* DiffContext. + + Context + */ + DiffContext *string + + /* ExecutionName. + + Test Execution Name + */ + ExecutionName string + + /* MaxFindings. + + Max Findings + */ + MaxFindings *string + + /* OrgName. + + Signadot Org Name + */ + OrgName string + + /* TestName. + + Test Name + */ + TestName string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the test execution traffic diff findings params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *TestExecutionTrafficDiffFindingsParams) WithDefaults() *TestExecutionTrafficDiffFindingsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the test execution traffic diff findings params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *TestExecutionTrafficDiffFindingsParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the test execution traffic diff findings params +func (o *TestExecutionTrafficDiffFindingsParams) WithTimeout(timeout time.Duration) *TestExecutionTrafficDiffFindingsParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the test execution traffic diff findings params +func (o *TestExecutionTrafficDiffFindingsParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the test execution traffic diff findings params +func (o *TestExecutionTrafficDiffFindingsParams) WithContext(ctx context.Context) *TestExecutionTrafficDiffFindingsParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the test execution traffic diff findings params +func (o *TestExecutionTrafficDiffFindingsParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the test execution traffic diff findings params +func (o *TestExecutionTrafficDiffFindingsParams) WithHTTPClient(client *http.Client) *TestExecutionTrafficDiffFindingsParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the test execution traffic diff findings params +func (o *TestExecutionTrafficDiffFindingsParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCategory adds the category to the test execution traffic diff findings params +func (o *TestExecutionTrafficDiffFindingsParams) WithCategory(category *string) *TestExecutionTrafficDiffFindingsParams { + o.SetCategory(category) + return o +} + +// SetCategory adds the category to the test execution traffic diff findings params +func (o *TestExecutionTrafficDiffFindingsParams) SetCategory(category *string) { + o.Category = category +} + +// WithDiffContext adds the diffContext to the test execution traffic diff findings params +func (o *TestExecutionTrafficDiffFindingsParams) WithDiffContext(diffContext *string) *TestExecutionTrafficDiffFindingsParams { + o.SetDiffContext(diffContext) + return o +} + +// SetDiffContext adds the diffContext to the test execution traffic diff findings params +func (o *TestExecutionTrafficDiffFindingsParams) SetDiffContext(diffContext *string) { + o.DiffContext = diffContext +} + +// WithExecutionName adds the executionName to the test execution traffic diff findings params +func (o *TestExecutionTrafficDiffFindingsParams) WithExecutionName(executionName string) *TestExecutionTrafficDiffFindingsParams { + o.SetExecutionName(executionName) + return o +} + +// SetExecutionName adds the executionName to the test execution traffic diff findings params +func (o *TestExecutionTrafficDiffFindingsParams) SetExecutionName(executionName string) { + o.ExecutionName = executionName +} + +// WithMaxFindings adds the maxFindings to the test execution traffic diff findings params +func (o *TestExecutionTrafficDiffFindingsParams) WithMaxFindings(maxFindings *string) *TestExecutionTrafficDiffFindingsParams { + o.SetMaxFindings(maxFindings) + return o +} + +// SetMaxFindings adds the maxFindings to the test execution traffic diff findings params +func (o *TestExecutionTrafficDiffFindingsParams) SetMaxFindings(maxFindings *string) { + o.MaxFindings = maxFindings +} + +// WithOrgName adds the orgName to the test execution traffic diff findings params +func (o *TestExecutionTrafficDiffFindingsParams) WithOrgName(orgName string) *TestExecutionTrafficDiffFindingsParams { + o.SetOrgName(orgName) + return o +} + +// SetOrgName adds the orgName to the test execution traffic diff findings params +func (o *TestExecutionTrafficDiffFindingsParams) SetOrgName(orgName string) { + o.OrgName = orgName +} + +// WithTestName adds the testName to the test execution traffic diff findings params +func (o *TestExecutionTrafficDiffFindingsParams) WithTestName(testName string) *TestExecutionTrafficDiffFindingsParams { + o.SetTestName(testName) + return o +} + +// SetTestName adds the testName to the test execution traffic diff findings params +func (o *TestExecutionTrafficDiffFindingsParams) SetTestName(testName string) { + o.TestName = testName +} + +// WriteToRequest writes these params to a swagger request +func (o *TestExecutionTrafficDiffFindingsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.Category != nil { + + // query param category + var qrCategory string + + if o.Category != nil { + qrCategory = *o.Category + } + qCategory := qrCategory + if qCategory != "" { + + if err := r.SetQueryParam("category", qCategory); err != nil { + return err + } + } + } + + if o.DiffContext != nil { + + // query param diffContext + var qrDiffContext string + + if o.DiffContext != nil { + qrDiffContext = *o.DiffContext + } + qDiffContext := qrDiffContext + if qDiffContext != "" { + + if err := r.SetQueryParam("diffContext", qDiffContext); err != nil { + return err + } + } + } + + // path param executionName + if err := r.SetPathParam("executionName", o.ExecutionName); err != nil { + return err + } + + if o.MaxFindings != nil { + + // query param maxFindings + var qrMaxFindings string + + if o.MaxFindings != nil { + qrMaxFindings = *o.MaxFindings + } + qMaxFindings := qrMaxFindings + if qMaxFindings != "" { + + if err := r.SetQueryParam("maxFindings", qMaxFindings); err != nil { + return err + } + } + } + + // path param orgName + if err := r.SetPathParam("orgName", o.OrgName); err != nil { + return err + } + + // path param testName + if err := r.SetPathParam("testName", o.TestName); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/test_executions/test_execution_traffic_diff_findings_responses.go b/client/test_executions/test_execution_traffic_diff_findings_responses.go new file mode 100644 index 0000000..6ffddc2 --- /dev/null +++ b/client/test_executions/test_execution_traffic_diff_findings_responses.go @@ -0,0 +1,334 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package test_executions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/signadot/go-sdk/models" +) + +// TestExecutionTrafficDiffFindingsReader is a Reader for the TestExecutionTrafficDiffFindings structure. +type TestExecutionTrafficDiffFindingsReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *TestExecutionTrafficDiffFindingsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewTestExecutionTrafficDiffFindingsOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewTestExecutionTrafficDiffFindingsBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewTestExecutionTrafficDiffFindingsUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 502: + result := NewTestExecutionTrafficDiffFindingsBadGateway() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /orgs/{orgName}/tests/{testName}/executions/{executionName}/traffic-diff-findings] test-execution-traffic-diff-findings", response, response.Code()) + } +} + +// NewTestExecutionTrafficDiffFindingsOK creates a TestExecutionTrafficDiffFindingsOK with default headers values +func NewTestExecutionTrafficDiffFindingsOK() *TestExecutionTrafficDiffFindingsOK { + return &TestExecutionTrafficDiffFindingsOK{} +} + +/* +TestExecutionTrafficDiffFindingsOK describes a response with status code 200, with default header values. + +OK +*/ +type TestExecutionTrafficDiffFindingsOK struct { + Payload *models.TrafficDiffResult +} + +// IsSuccess returns true when this test execution traffic diff findings o k response has a 2xx status code +func (o *TestExecutionTrafficDiffFindingsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this test execution traffic diff findings o k response has a 3xx status code +func (o *TestExecutionTrafficDiffFindingsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this test execution traffic diff findings o k response has a 4xx status code +func (o *TestExecutionTrafficDiffFindingsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this test execution traffic diff findings o k response has a 5xx status code +func (o *TestExecutionTrafficDiffFindingsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this test execution traffic diff findings o k response a status code equal to that given +func (o *TestExecutionTrafficDiffFindingsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the test execution traffic diff findings o k response +func (o *TestExecutionTrafficDiffFindingsOK) Code() int { + return 200 +} + +func (o *TestExecutionTrafficDiffFindingsOK) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /orgs/{orgName}/tests/{testName}/executions/{executionName}/traffic-diff-findings][%d] testExecutionTrafficDiffFindingsOK %s", 200, payload) +} + +func (o *TestExecutionTrafficDiffFindingsOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /orgs/{orgName}/tests/{testName}/executions/{executionName}/traffic-diff-findings][%d] testExecutionTrafficDiffFindingsOK %s", 200, payload) +} + +func (o *TestExecutionTrafficDiffFindingsOK) GetPayload() *models.TrafficDiffResult { + return o.Payload +} + +func (o *TestExecutionTrafficDiffFindingsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.TrafficDiffResult) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewTestExecutionTrafficDiffFindingsBadRequest creates a TestExecutionTrafficDiffFindingsBadRequest with default headers values +func NewTestExecutionTrafficDiffFindingsBadRequest() *TestExecutionTrafficDiffFindingsBadRequest { + return &TestExecutionTrafficDiffFindingsBadRequest{} +} + +/* +TestExecutionTrafficDiffFindingsBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type TestExecutionTrafficDiffFindingsBadRequest struct { + Payload *models.ErrorResponse +} + +// IsSuccess returns true when this test execution traffic diff findings bad request response has a 2xx status code +func (o *TestExecutionTrafficDiffFindingsBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this test execution traffic diff findings bad request response has a 3xx status code +func (o *TestExecutionTrafficDiffFindingsBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this test execution traffic diff findings bad request response has a 4xx status code +func (o *TestExecutionTrafficDiffFindingsBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this test execution traffic diff findings bad request response has a 5xx status code +func (o *TestExecutionTrafficDiffFindingsBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this test execution traffic diff findings bad request response a status code equal to that given +func (o *TestExecutionTrafficDiffFindingsBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the test execution traffic diff findings bad request response +func (o *TestExecutionTrafficDiffFindingsBadRequest) Code() int { + return 400 +} + +func (o *TestExecutionTrafficDiffFindingsBadRequest) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /orgs/{orgName}/tests/{testName}/executions/{executionName}/traffic-diff-findings][%d] testExecutionTrafficDiffFindingsBadRequest %s", 400, payload) +} + +func (o *TestExecutionTrafficDiffFindingsBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /orgs/{orgName}/tests/{testName}/executions/{executionName}/traffic-diff-findings][%d] testExecutionTrafficDiffFindingsBadRequest %s", 400, payload) +} + +func (o *TestExecutionTrafficDiffFindingsBadRequest) GetPayload() *models.ErrorResponse { + return o.Payload +} + +func (o *TestExecutionTrafficDiffFindingsBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ErrorResponse) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewTestExecutionTrafficDiffFindingsUnauthorized creates a TestExecutionTrafficDiffFindingsUnauthorized with default headers values +func NewTestExecutionTrafficDiffFindingsUnauthorized() *TestExecutionTrafficDiffFindingsUnauthorized { + return &TestExecutionTrafficDiffFindingsUnauthorized{} +} + +/* +TestExecutionTrafficDiffFindingsUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type TestExecutionTrafficDiffFindingsUnauthorized struct { + Payload *models.ErrorResponse +} + +// IsSuccess returns true when this test execution traffic diff findings unauthorized response has a 2xx status code +func (o *TestExecutionTrafficDiffFindingsUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this test execution traffic diff findings unauthorized response has a 3xx status code +func (o *TestExecutionTrafficDiffFindingsUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this test execution traffic diff findings unauthorized response has a 4xx status code +func (o *TestExecutionTrafficDiffFindingsUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this test execution traffic diff findings unauthorized response has a 5xx status code +func (o *TestExecutionTrafficDiffFindingsUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this test execution traffic diff findings unauthorized response a status code equal to that given +func (o *TestExecutionTrafficDiffFindingsUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the test execution traffic diff findings unauthorized response +func (o *TestExecutionTrafficDiffFindingsUnauthorized) Code() int { + return 401 +} + +func (o *TestExecutionTrafficDiffFindingsUnauthorized) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /orgs/{orgName}/tests/{testName}/executions/{executionName}/traffic-diff-findings][%d] testExecutionTrafficDiffFindingsUnauthorized %s", 401, payload) +} + +func (o *TestExecutionTrafficDiffFindingsUnauthorized) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /orgs/{orgName}/tests/{testName}/executions/{executionName}/traffic-diff-findings][%d] testExecutionTrafficDiffFindingsUnauthorized %s", 401, payload) +} + +func (o *TestExecutionTrafficDiffFindingsUnauthorized) GetPayload() *models.ErrorResponse { + return o.Payload +} + +func (o *TestExecutionTrafficDiffFindingsUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ErrorResponse) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewTestExecutionTrafficDiffFindingsBadGateway creates a TestExecutionTrafficDiffFindingsBadGateway with default headers values +func NewTestExecutionTrafficDiffFindingsBadGateway() *TestExecutionTrafficDiffFindingsBadGateway { + return &TestExecutionTrafficDiffFindingsBadGateway{} +} + +/* +TestExecutionTrafficDiffFindingsBadGateway describes a response with status code 502, with default header values. + +Bad Gateway +*/ +type TestExecutionTrafficDiffFindingsBadGateway struct { + Payload *models.ErrorResponse +} + +// IsSuccess returns true when this test execution traffic diff findings bad gateway response has a 2xx status code +func (o *TestExecutionTrafficDiffFindingsBadGateway) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this test execution traffic diff findings bad gateway response has a 3xx status code +func (o *TestExecutionTrafficDiffFindingsBadGateway) IsRedirect() bool { + return false +} + +// IsClientError returns true when this test execution traffic diff findings bad gateway response has a 4xx status code +func (o *TestExecutionTrafficDiffFindingsBadGateway) IsClientError() bool { + return false +} + +// IsServerError returns true when this test execution traffic diff findings bad gateway response has a 5xx status code +func (o *TestExecutionTrafficDiffFindingsBadGateway) IsServerError() bool { + return true +} + +// IsCode returns true when this test execution traffic diff findings bad gateway response a status code equal to that given +func (o *TestExecutionTrafficDiffFindingsBadGateway) IsCode(code int) bool { + return code == 502 +} + +// Code gets the status code for the test execution traffic diff findings bad gateway response +func (o *TestExecutionTrafficDiffFindingsBadGateway) Code() int { + return 502 +} + +func (o *TestExecutionTrafficDiffFindingsBadGateway) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /orgs/{orgName}/tests/{testName}/executions/{executionName}/traffic-diff-findings][%d] testExecutionTrafficDiffFindingsBadGateway %s", 502, payload) +} + +func (o *TestExecutionTrafficDiffFindingsBadGateway) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /orgs/{orgName}/tests/{testName}/executions/{executionName}/traffic-diff-findings][%d] testExecutionTrafficDiffFindingsBadGateway %s", 502, payload) +} + +func (o *TestExecutionTrafficDiffFindingsBadGateway) GetPayload() *models.ErrorResponse { + return o.Payload +} + +func (o *TestExecutionTrafficDiffFindingsBadGateway) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ErrorResponse) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/test_executions/test_executions_client.go b/client/test_executions/test_executions_client.go index f3e1481..0c7b51a 100644 --- a/client/test_executions/test_executions_client.go +++ b/client/test_executions/test_executions_client.go @@ -68,6 +68,8 @@ type ClientService interface { TestExecutionTrafficDiff(params *TestExecutionTrafficDiffParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*TestExecutionTrafficDiffOK, error) + TestExecutionTrafficDiffFindings(params *TestExecutionTrafficDiffFindingsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*TestExecutionTrafficDiffFindingsOK, error) + SetTransport(transport runtime.ClientTransport) } @@ -317,6 +319,47 @@ func (a *Client) TestExecutionTrafficDiff(params *TestExecutionTrafficDiffParams panic(msg) } +/* +TestExecutionTrafficDiffFindings gets the findings view of the traffic diff of a test execution + +Get the findings view of the traffic diff of a test execution +*/ +func (a *Client) TestExecutionTrafficDiffFindings(params *TestExecutionTrafficDiffFindingsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*TestExecutionTrafficDiffFindingsOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewTestExecutionTrafficDiffFindingsParams() + } + op := &runtime.ClientOperation{ + ID: "test-execution-traffic-diff-findings", + Method: "GET", + PathPattern: "/orgs/{orgName}/tests/{testName}/executions/{executionName}/traffic-diff-findings", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &TestExecutionTrafficDiffFindingsReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*TestExecutionTrafficDiffFindingsOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for test-execution-traffic-diff-findings: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + // SetTransport changes the transport on the client func (a *Client) SetTransport(transport runtime.ClientTransport) { a.transport = transport diff --git a/generate/swagger.json b/generate/swagger.json index c5a6a16..a1049a2 100644 --- a/generate/swagger.json +++ b/generate/swagger.json @@ -1,36 +1,6 @@ { "basePath": "/api/v2", "definitions": { - "CapturePointDiffSummary": { - "properties": { - "additions": { - "type": "integer" - }, - "capturedBy": { - "$ref": "#/definitions/trafficmodels.By" - }, - "captures": { - "type": "integer" - }, - "maxRelevance": { - "description": "MaxRelevance indicates a score in 0..1 of the maximally relevant diff\noperation, or 1.0 if either the baseline or target are missing.", - "type": "number" - }, - "removals": { - "type": "integer" - }, - "replacements": { - "type": "integer" - }, - "top": { - "items": { - "$ref": "#/definitions/TrafficDiffPairedDiff" - }, - "type": "array" - } - }, - "type": "object" - }, "Cluster": { "properties": { "createdAt": { @@ -351,6 +321,20 @@ }, "type": "object" }, + "Source": { + "properties": { + "id": { + "type": "string" + }, + "requestName": { + "type": "string" + }, + "scriptRef": { + "$ref": "#/definitions/capturemeta.ScriptRef" + } + }, + "type": "object" + }, "Test": { "properties": { "createdAt": { @@ -502,8 +486,8 @@ "sandbox": { "type": "string" }, - "triggerID": { - "type": "string" + "trigger": { + "$ref": "#/definitions/TestTrigger" } }, "type": "object" @@ -545,26 +529,22 @@ "type": "integer" }, "capturePoints": { - "type": "integer" + "items": { + "$ref": "#/definitions/trafficmodels.By" + }, + "type": "array" }, "captures": { "type": "integer" }, "green": { - "items": { - "$ref": "#/definitions/CapturePointDiffSummary" - }, - "type": "array" + "$ref": "#/definitions/TrafficDiffSummary" }, "maxRelevance": { - "description": "MaxRelevance indicates a score in 0..1 of the maximally relevant\ndiff of captures.", "type": "number" }, "red": { - "items": { - "$ref": "#/definitions/CapturePointDiffSummary" - }, - "type": "array" + "$ref": "#/definitions/TrafficDiffSummary" }, "removals": { "type": "integer" @@ -573,21 +553,24 @@ "type": "integer" }, "yellow": { - "items": { - "$ref": "#/definitions/CapturePointDiffSummary" - }, - "type": "array" + "$ref": "#/definitions/TrafficDiffSummary" } }, "type": "object" }, "TrafficDiffPairedDiff": { "properties": { + "id": { + "type": "string" + }, "request": { "$ref": "#/definitions/RequestDiff" }, "response": { "$ref": "#/definitions/ResponseDiff" + }, + "source": { + "$ref": "#/definitions/Source" } }, "type": "object" @@ -623,6 +606,26 @@ }, "type": "object" }, + "TrafficDiffSummary": { + "properties": { + "additions": { + "type": "integer" + }, + "captures": { + "type": "integer" + }, + "maxRelevance": { + "type": "number" + }, + "removals": { + "type": "integer" + }, + "replacements": { + "type": "integer" + } + }, + "type": "object" + }, "capture.Message": { "properties": { "body": {}, @@ -684,6 +687,27 @@ }, "type": "object" }, + "capturemeta.ScriptRef": { + "properties": { + "callNum": { + "description": "call number", + "type": "integer" + }, + "col": { + "description": "1-based column (rune) number; 0 if column unknown", + "type": "integer" + }, + "file": { + "description": "filename", + "type": "string" + }, + "line": { + "description": "1-based line number; 0 if line unknown", + "type": "integer" + } + }, + "type": "object" + }, "cluster.Operator": { "properties": { "version": { @@ -4877,6 +4901,95 @@ "TestExecutions" ] } + }, + "/orgs/{orgName}/tests/{testName}/executions/{executionName}/traffic-diff-findings": { + "get": { + "consumes": [ + "application/json" + ], + "description": "Get the findings view of the traffic diff of a test execution", + "operationId": "test-execution-traffic-diff-findings", + "parameters": [ + { + "description": "Signadot Org Name", + "in": "path", + "name": "orgName", + "required": true, + "type": "string", + "x-example": "my-company" + }, + { + "description": "Test Name", + "in": "path", + "name": "testName", + "required": true, + "type": "string" + }, + { + "description": "Test Execution Name", + "in": "path", + "name": "executionName", + "required": true, + "type": "string" + }, + { + "description": "Context", + "in": "query", + "name": "diffContext", + "type": "string" + }, + { + "description": "Category", + "in": "query", + "name": "category", + "type": "string" + }, + { + "description": "Max Findings", + "in": "query", + "name": "maxFindings", + "type": "string" + } + ], + "produces": [ + "application/json" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/TrafficDiffResult" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + }, + "502": { + "description": "Bad Gateway", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "security": [ + { + "ApiKeyAuth": [] + } + ], + "summary": "Get the findings view of the traffic diff of a test execution", + "tags": [ + "TestExecutions" + ] + } } }, "securityDefinitions": { @@ -4887,4 +5000,4 @@ } }, "swagger": "2.0" -} \ No newline at end of file +} diff --git a/models/capture_point_diff_summary.go b/models/capture_point_diff_summary.go deleted file mode 100644 index 21c8102..0000000 --- a/models/capture_point_diff_summary.go +++ /dev/null @@ -1,188 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "strconv" - - "github.com/go-openapi/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// CapturePointDiffSummary capture point diff summary -// -// swagger:model CapturePointDiffSummary -type CapturePointDiffSummary struct { - - // additions - Additions int64 `json:"additions,omitempty"` - - // captured by - CapturedBy *TrafficmodelsBy `json:"capturedBy,omitempty"` - - // captures - Captures int64 `json:"captures,omitempty"` - - // MaxRelevance indicates a score in 0..1 of the maximally relevant diff - // operation, or 1.0 if either the baseline or target are missing. - MaxRelevance float64 `json:"maxRelevance,omitempty"` - - // removals - Removals int64 `json:"removals,omitempty"` - - // replacements - Replacements int64 `json:"replacements,omitempty"` - - // top - Top []*TrafficDiffPairedDiff `json:"top"` -} - -// Validate validates this capture point diff summary -func (m *CapturePointDiffSummary) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateCapturedBy(formats); err != nil { - res = append(res, err) - } - - if err := m.validateTop(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *CapturePointDiffSummary) validateCapturedBy(formats strfmt.Registry) error { - if swag.IsZero(m.CapturedBy) { // not required - return nil - } - - if m.CapturedBy != nil { - if err := m.CapturedBy.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("capturedBy") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("capturedBy") - } - return err - } - } - - return nil -} - -func (m *CapturePointDiffSummary) validateTop(formats strfmt.Registry) error { - if swag.IsZero(m.Top) { // not required - return nil - } - - for i := 0; i < len(m.Top); i++ { - if swag.IsZero(m.Top[i]) { // not required - continue - } - - if m.Top[i] != nil { - if err := m.Top[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("top" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("top" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -// ContextValidate validate this capture point diff summary based on the context it is used -func (m *CapturePointDiffSummary) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidateCapturedBy(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateTop(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *CapturePointDiffSummary) contextValidateCapturedBy(ctx context.Context, formats strfmt.Registry) error { - - if m.CapturedBy != nil { - - if swag.IsZero(m.CapturedBy) { // not required - return nil - } - - if err := m.CapturedBy.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("capturedBy") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("capturedBy") - } - return err - } - } - - return nil -} - -func (m *CapturePointDiffSummary) contextValidateTop(ctx context.Context, formats strfmt.Registry) error { - - for i := 0; i < len(m.Top); i++ { - - if m.Top[i] != nil { - - if swag.IsZero(m.Top[i]) { // not required - return nil - } - - if err := m.Top[i].ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("top" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("top" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -// MarshalBinary interface implementation -func (m *CapturePointDiffSummary) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *CapturePointDiffSummary) UnmarshalBinary(b []byte) error { - var res CapturePointDiffSummary - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/models/capturemeta_script_ref.go b/models/capturemeta_script_ref.go new file mode 100644 index 0000000..b58b47a --- /dev/null +++ b/models/capturemeta_script_ref.go @@ -0,0 +1,59 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// CapturemetaScriptRef capturemeta script ref +// +// swagger:model capturemeta.ScriptRef +type CapturemetaScriptRef struct { + + // call number + CallNum int64 `json:"callNum,omitempty"` + + // 1-based column (rune) number; 0 if column unknown + Col int64 `json:"col,omitempty"` + + // filename + File string `json:"file,omitempty"` + + // 1-based line number; 0 if line unknown + Line int64 `json:"line,omitempty"` +} + +// Validate validates this capturemeta script ref +func (m *CapturemetaScriptRef) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this capturemeta script ref based on context it is used +func (m *CapturemetaScriptRef) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *CapturemetaScriptRef) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CapturemetaScriptRef) UnmarshalBinary(b []byte) error { + var res CapturemetaScriptRef + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/source.go b/models/source.go new file mode 100644 index 0000000..1f336ca --- /dev/null +++ b/models/source.go @@ -0,0 +1,115 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Source source +// +// swagger:model Source +type Source struct { + + // id + ID string `json:"id,omitempty"` + + // request name + RequestName string `json:"requestName,omitempty"` + + // script ref + ScriptRef *CapturemetaScriptRef `json:"scriptRef,omitempty"` +} + +// Validate validates this source +func (m *Source) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateScriptRef(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Source) validateScriptRef(formats strfmt.Registry) error { + if swag.IsZero(m.ScriptRef) { // not required + return nil + } + + if m.ScriptRef != nil { + if err := m.ScriptRef.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("scriptRef") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("scriptRef") + } + return err + } + } + + return nil +} + +// ContextValidate validate this source based on the context it is used +func (m *Source) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateScriptRef(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Source) contextValidateScriptRef(ctx context.Context, formats strfmt.Registry) error { + + if m.ScriptRef != nil { + + if swag.IsZero(m.ScriptRef) { // not required + return nil + } + + if err := m.ScriptRef.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("scriptRef") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("scriptRef") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Source) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Source) UnmarshalBinary(b []byte) error { + var res Source + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/test_execution_triggered_by.go b/models/test_execution_triggered_by.go index 155ee00..0023670 100644 --- a/models/test_execution_triggered_by.go +++ b/models/test_execution_triggered_by.go @@ -8,6 +8,7 @@ package models import ( "context" + "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) @@ -20,17 +21,75 @@ type TestExecutionTriggeredBy struct { // sandbox Sandbox string `json:"sandbox,omitempty"` - // trigger ID - TriggerID string `json:"triggerID,omitempty"` + // trigger + Trigger *TestTrigger `json:"trigger,omitempty"` } // Validate validates this test execution triggered by func (m *TestExecutionTriggeredBy) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateTrigger(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TestExecutionTriggeredBy) validateTrigger(formats strfmt.Registry) error { + if swag.IsZero(m.Trigger) { // not required + return nil + } + + if m.Trigger != nil { + if err := m.Trigger.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("trigger") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("trigger") + } + return err + } + } + return nil } -// ContextValidate validates this test execution triggered by based on context it is used +// ContextValidate validate this test execution triggered by based on the context it is used func (m *TestExecutionTriggeredBy) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateTrigger(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TestExecutionTriggeredBy) contextValidateTrigger(ctx context.Context, formats strfmt.Registry) error { + + if m.Trigger != nil { + + if swag.IsZero(m.Trigger) { // not required + return nil + } + + if err := m.Trigger.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("trigger") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("trigger") + } + return err + } + } + return nil } diff --git a/models/traffic_diff.go b/models/traffic_diff.go index 1b08219..b293958 100644 --- a/models/traffic_diff.go +++ b/models/traffic_diff.go @@ -23,20 +23,19 @@ type TrafficDiff struct { Additions int64 `json:"additions,omitempty"` // capture points - CapturePoints int64 `json:"capturePoints,omitempty"` + CapturePoints []*TrafficmodelsBy `json:"capturePoints"` // captures Captures int64 `json:"captures,omitempty"` // green - Green []*CapturePointDiffSummary `json:"green"` + Green *TrafficDiffSummary `json:"green,omitempty"` - // MaxRelevance indicates a score in 0..1 of the maximally relevant - // diff of captures. + // max relevance MaxRelevance float64 `json:"maxRelevance,omitempty"` // red - Red []*CapturePointDiffSummary `json:"red"` + Red *TrafficDiffSummary `json:"red,omitempty"` // removals Removals int64 `json:"removals,omitempty"` @@ -45,13 +44,17 @@ type TrafficDiff struct { Replacements int64 `json:"replacements,omitempty"` // yellow - Yellow []*CapturePointDiffSummary `json:"yellow"` + Yellow *TrafficDiffSummary `json:"yellow,omitempty"` } // Validate validates this traffic diff func (m *TrafficDiff) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateCapturePoints(formats); err != nil { + res = append(res, err) + } + if err := m.validateGreen(formats); err != nil { res = append(res, err) } @@ -70,22 +73,22 @@ func (m *TrafficDiff) Validate(formats strfmt.Registry) error { return nil } -func (m *TrafficDiff) validateGreen(formats strfmt.Registry) error { - if swag.IsZero(m.Green) { // not required +func (m *TrafficDiff) validateCapturePoints(formats strfmt.Registry) error { + if swag.IsZero(m.CapturePoints) { // not required return nil } - for i := 0; i < len(m.Green); i++ { - if swag.IsZero(m.Green[i]) { // not required + for i := 0; i < len(m.CapturePoints); i++ { + if swag.IsZero(m.CapturePoints[i]) { // not required continue } - if m.Green[i] != nil { - if err := m.Green[i].Validate(formats); err != nil { + if m.CapturePoints[i] != nil { + if err := m.CapturePoints[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("green" + "." + strconv.Itoa(i)) + return ve.ValidateName("capturePoints" + "." + strconv.Itoa(i)) } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("green" + "." + strconv.Itoa(i)) + return ce.ValidateName("capturePoints" + "." + strconv.Itoa(i)) } return err } @@ -96,27 +99,39 @@ func (m *TrafficDiff) validateGreen(formats strfmt.Registry) error { return nil } -func (m *TrafficDiff) validateRed(formats strfmt.Registry) error { - if swag.IsZero(m.Red) { // not required +func (m *TrafficDiff) validateGreen(formats strfmt.Registry) error { + if swag.IsZero(m.Green) { // not required return nil } - for i := 0; i < len(m.Red); i++ { - if swag.IsZero(m.Red[i]) { // not required - continue + if m.Green != nil { + if err := m.Green.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("green") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("green") + } + return err } + } - if m.Red[i] != nil { - if err := m.Red[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("red" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("red" + "." + strconv.Itoa(i)) - } - return err + return nil +} + +func (m *TrafficDiff) validateRed(formats strfmt.Registry) error { + if swag.IsZero(m.Red) { // not required + return nil + } + + if m.Red != nil { + if err := m.Red.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("red") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("red") } + return err } - } return nil @@ -127,22 +142,15 @@ func (m *TrafficDiff) validateYellow(formats strfmt.Registry) error { return nil } - for i := 0; i < len(m.Yellow); i++ { - if swag.IsZero(m.Yellow[i]) { // not required - continue - } - - if m.Yellow[i] != nil { - if err := m.Yellow[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("yellow" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("yellow" + "." + strconv.Itoa(i)) - } - return err + if m.Yellow != nil { + if err := m.Yellow.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("yellow") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("yellow") } + return err } - } return nil @@ -152,6 +160,10 @@ func (m *TrafficDiff) validateYellow(formats strfmt.Registry) error { func (m *TrafficDiff) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error + if err := m.contextValidateCapturePoints(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidateGreen(ctx, formats); err != nil { res = append(res, err) } @@ -170,21 +182,21 @@ func (m *TrafficDiff) ContextValidate(ctx context.Context, formats strfmt.Regist return nil } -func (m *TrafficDiff) contextValidateGreen(ctx context.Context, formats strfmt.Registry) error { +func (m *TrafficDiff) contextValidateCapturePoints(ctx context.Context, formats strfmt.Registry) error { - for i := 0; i < len(m.Green); i++ { + for i := 0; i < len(m.CapturePoints); i++ { - if m.Green[i] != nil { + if m.CapturePoints[i] != nil { - if swag.IsZero(m.Green[i]) { // not required + if swag.IsZero(m.CapturePoints[i]) { // not required return nil } - if err := m.Green[i].ContextValidate(ctx, formats); err != nil { + if err := m.CapturePoints[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("green" + "." + strconv.Itoa(i)) + return ve.ValidateName("capturePoints" + "." + strconv.Itoa(i)) } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("green" + "." + strconv.Itoa(i)) + return ce.ValidateName("capturePoints" + "." + strconv.Itoa(i)) } return err } @@ -195,26 +207,43 @@ func (m *TrafficDiff) contextValidateGreen(ctx context.Context, formats strfmt.R return nil } -func (m *TrafficDiff) contextValidateRed(ctx context.Context, formats strfmt.Registry) error { +func (m *TrafficDiff) contextValidateGreen(ctx context.Context, formats strfmt.Registry) error { - for i := 0; i < len(m.Red); i++ { + if m.Green != nil { - if m.Red[i] != nil { + if swag.IsZero(m.Green) { // not required + return nil + } - if swag.IsZero(m.Red[i]) { // not required - return nil + if err := m.Green.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("green") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("green") } + return err + } + } - if err := m.Red[i].ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("red" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("red" + "." + strconv.Itoa(i)) - } - return err - } + return nil +} + +func (m *TrafficDiff) contextValidateRed(ctx context.Context, formats strfmt.Registry) error { + + if m.Red != nil { + + if swag.IsZero(m.Red) { // not required + return nil } + if err := m.Red.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("red") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("red") + } + return err + } } return nil @@ -222,24 +251,20 @@ func (m *TrafficDiff) contextValidateRed(ctx context.Context, formats strfmt.Reg func (m *TrafficDiff) contextValidateYellow(ctx context.Context, formats strfmt.Registry) error { - for i := 0; i < len(m.Yellow); i++ { - - if m.Yellow[i] != nil { + if m.Yellow != nil { - if swag.IsZero(m.Yellow[i]) { // not required - return nil - } + if swag.IsZero(m.Yellow) { // not required + return nil + } - if err := m.Yellow[i].ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("yellow" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("yellow" + "." + strconv.Itoa(i)) - } - return err + if err := m.Yellow.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("yellow") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("yellow") } + return err } - } return nil diff --git a/models/traffic_diff_paired_diff.go b/models/traffic_diff_paired_diff.go index bf494d4..6e8279a 100644 --- a/models/traffic_diff_paired_diff.go +++ b/models/traffic_diff_paired_diff.go @@ -18,11 +18,17 @@ import ( // swagger:model TrafficDiffPairedDiff type TrafficDiffPairedDiff struct { + // id + ID string `json:"id,omitempty"` + // request Request *RequestDiff `json:"request,omitempty"` // response Response *ResponseDiff `json:"response,omitempty"` + + // source + Source *Source `json:"source,omitempty"` } // Validate validates this traffic diff paired diff @@ -37,6 +43,10 @@ func (m *TrafficDiffPairedDiff) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateSource(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -81,6 +91,25 @@ func (m *TrafficDiffPairedDiff) validateResponse(formats strfmt.Registry) error return nil } +func (m *TrafficDiffPairedDiff) validateSource(formats strfmt.Registry) error { + if swag.IsZero(m.Source) { // not required + return nil + } + + if m.Source != nil { + if err := m.Source.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("source") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("source") + } + return err + } + } + + return nil +} + // ContextValidate validate this traffic diff paired diff based on the context it is used func (m *TrafficDiffPairedDiff) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error @@ -93,6 +122,10 @@ func (m *TrafficDiffPairedDiff) ContextValidate(ctx context.Context, formats str res = append(res, err) } + if err := m.contextValidateSource(ctx, formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -141,6 +174,27 @@ func (m *TrafficDiffPairedDiff) contextValidateResponse(ctx context.Context, for return nil } +func (m *TrafficDiffPairedDiff) contextValidateSource(ctx context.Context, formats strfmt.Registry) error { + + if m.Source != nil { + + if swag.IsZero(m.Source) { // not required + return nil + } + + if err := m.Source.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("source") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("source") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *TrafficDiffPairedDiff) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/models/traffic_diff_summary.go b/models/traffic_diff_summary.go new file mode 100644 index 0000000..409add7 --- /dev/null +++ b/models/traffic_diff_summary.go @@ -0,0 +1,62 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// TrafficDiffSummary traffic diff summary +// +// swagger:model TrafficDiffSummary +type TrafficDiffSummary struct { + + // additions + Additions int64 `json:"additions,omitempty"` + + // captures + Captures int64 `json:"captures,omitempty"` + + // max relevance + MaxRelevance float64 `json:"maxRelevance,omitempty"` + + // removals + Removals int64 `json:"removals,omitempty"` + + // replacements + Replacements int64 `json:"replacements,omitempty"` +} + +// Validate validates this traffic diff summary +func (m *TrafficDiffSummary) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this traffic diff summary based on context it is used +func (m *TrafficDiffSummary) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *TrafficDiffSummary) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *TrafficDiffSummary) UnmarshalBinary(b []byte) error { + var res TrafficDiffSummary + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +}