From 1c7d8bc56749023e61d31d9bbe53d31ed38d6d3f Mon Sep 17 00:00:00 2001 From: Tetrergeru Date: Fri, 20 Sep 2024 12:26:50 +0200 Subject: [PATCH] v0.1.2 (#9) --- README.md | 2 +- .../get_contact_events_by_id_parameters.go | 77 ++++++++ .../event/get_events_list_parameters.go | 164 +++++++++++++++++- 3 files changed, 241 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 83dd61c..bfeaa0f 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ import ( func main() { config := client.DefaultTransportConfig(). WithBasePath("api"). - WithHost("moira.skbkontur.ru"). + WithHost("moira.example.com"). WithSchemes([]string{"https"}) transport := httptransport.New(config.Host, config.BasePath, config.Schemes) diff --git a/pkg/client/contact/get_contact_events_by_id_parameters.go b/pkg/client/contact/get_contact_events_by_id_parameters.go index 4a182f8..e37ea5a 100644 --- a/pkg/client/contact/get_contact_events_by_id_parameters.go +++ b/pkg/client/contact/get_contact_events_by_id_parameters.go @@ -14,6 +14,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" ) // NewGetContactEventsByIDParams creates a new GetContactEventsByIDParams object, @@ -77,6 +78,20 @@ type GetContactEventsByIDParams struct { */ From *string + /* P. + + Defines the index of data portion (combined with size). E.g, p=2, size=100 will return records from 200 (including), to 300 (not including) + */ + P *int64 + + /* Size. + + Number of items to return or all items if size == -1 (if size == -1 p should be zero for correct work) + + Default: 100 + */ + Size *int64 + /* To. End time of the time range @@ -107,12 +122,18 @@ func (o *GetContactEventsByIDParams) SetDefaults() { fromDefault = string("-3hour") + pDefault = int64(0) + + sizeDefault = int64(100) + toDefault = string("now") ) val := GetContactEventsByIDParams{ ContactID: contactIDDefault, From: &fromDefault, + P: &pDefault, + Size: &sizeDefault, To: &toDefault, } @@ -177,6 +198,28 @@ func (o *GetContactEventsByIDParams) SetFrom(from *string) { o.From = from } +// WithP adds the p to the get contact events by id params +func (o *GetContactEventsByIDParams) WithP(p *int64) *GetContactEventsByIDParams { + o.SetP(p) + return o +} + +// SetP adds the p to the get contact events by id params +func (o *GetContactEventsByIDParams) SetP(p *int64) { + o.P = p +} + +// WithSize adds the size to the get contact events by id params +func (o *GetContactEventsByIDParams) WithSize(size *int64) *GetContactEventsByIDParams { + o.SetSize(size) + return o +} + +// SetSize adds the size to the get contact events by id params +func (o *GetContactEventsByIDParams) SetSize(size *int64) { + o.Size = size +} + // WithTo adds the to to the get contact events by id params func (o *GetContactEventsByIDParams) WithTo(to *string) *GetContactEventsByIDParams { o.SetTo(to) @@ -218,6 +261,40 @@ func (o *GetContactEventsByIDParams) WriteToRequest(r runtime.ClientRequest, reg } } + if o.P != nil { + + // query param p + var qrP int64 + + if o.P != nil { + qrP = *o.P + } + qP := swag.FormatInt64(qrP) + if qP != "" { + + if err := r.SetQueryParam("p", qP); err != nil { + return err + } + } + } + + if o.Size != nil { + + // query param size + var qrSize int64 + + if o.Size != nil { + qrSize = *o.Size + } + qSize := swag.FormatInt64(qrSize) + if qSize != "" { + + if err := r.SetQueryParam("size", qSize); err != nil { + return err + } + } + } + if o.To != nil { // query param to diff --git a/pkg/client/event/get_events_list_parameters.go b/pkg/client/event/get_events_list_parameters.go index 20db878..e1af842 100644 --- a/pkg/client/event/get_events_list_parameters.go +++ b/pkg/client/event/get_events_list_parameters.go @@ -62,6 +62,22 @@ GetEventsListParams contains all the parameters to send to the API endpoint */ type GetEventsListParams struct { + /* From. + + Start time of the time range + + Default: "-3hours" + */ + From *string + + /* Metric. + + Regular expression that will be used to filter events + + Default: ".*" + */ + Metric *string + /* P. Defines the number of the displayed page. E.g, p=2 would display the 2nd page @@ -70,12 +86,26 @@ type GetEventsListParams struct { /* Size. - Number of items to be displayed on one page + Number of items to be displayed on one page. if size = -1 then all events returned Default: 100 */ Size *int64 + /* States. + + String of ',' separated state names. If empty then all states will be used. + */ + States []string + + /* To. + + End time of the time range + + Default: "now" + */ + To *string + /* TriggerID. The ID of updated trigger @@ -102,16 +132,25 @@ func (o *GetEventsListParams) WithDefaults() *GetEventsListParams { // All values with no default are reset to their zero value. func (o *GetEventsListParams) SetDefaults() { var ( + fromDefault = string("-3hours") + + metricDefault = string(".*") + pDefault = int64(0) sizeDefault = int64(100) + toDefault = string("now") + triggerIDDefault = string("bcba82f5-48cf-44c0-b7d6-e1d32c64a88c") ) val := GetEventsListParams{ + From: &fromDefault, + Metric: &metricDefault, P: &pDefault, Size: &sizeDefault, + To: &toDefault, TriggerID: triggerIDDefault, } @@ -154,6 +193,28 @@ func (o *GetEventsListParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithFrom adds the from to the get events list params +func (o *GetEventsListParams) WithFrom(from *string) *GetEventsListParams { + o.SetFrom(from) + return o +} + +// SetFrom adds the from to the get events list params +func (o *GetEventsListParams) SetFrom(from *string) { + o.From = from +} + +// WithMetric adds the metric to the get events list params +func (o *GetEventsListParams) WithMetric(metric *string) *GetEventsListParams { + o.SetMetric(metric) + return o +} + +// SetMetric adds the metric to the get events list params +func (o *GetEventsListParams) SetMetric(metric *string) { + o.Metric = metric +} + // WithP adds the p to the get events list params func (o *GetEventsListParams) WithP(p *int64) *GetEventsListParams { o.SetP(p) @@ -176,6 +237,28 @@ func (o *GetEventsListParams) SetSize(size *int64) { o.Size = size } +// WithStates adds the states to the get events list params +func (o *GetEventsListParams) WithStates(states []string) *GetEventsListParams { + o.SetStates(states) + return o +} + +// SetStates adds the states to the get events list params +func (o *GetEventsListParams) SetStates(states []string) { + o.States = states +} + +// WithTo adds the to to the get events list params +func (o *GetEventsListParams) WithTo(to *string) *GetEventsListParams { + o.SetTo(to) + return o +} + +// SetTo adds the to to the get events list params +func (o *GetEventsListParams) SetTo(to *string) { + o.To = to +} + // WithTriggerID adds the triggerID to the get events list params func (o *GetEventsListParams) WithTriggerID(triggerID string) *GetEventsListParams { o.SetTriggerID(triggerID) @@ -195,6 +278,40 @@ func (o *GetEventsListParams) WriteToRequest(r runtime.ClientRequest, reg strfmt } var res []error + if o.From != nil { + + // query param from + var qrFrom string + + if o.From != nil { + qrFrom = *o.From + } + qFrom := qrFrom + if qFrom != "" { + + if err := r.SetQueryParam("from", qFrom); err != nil { + return err + } + } + } + + if o.Metric != nil { + + // query param metric + var qrMetric string + + if o.Metric != nil { + qrMetric = *o.Metric + } + qMetric := qrMetric + if qMetric != "" { + + if err := r.SetQueryParam("metric", qMetric); err != nil { + return err + } + } + } + if o.P != nil { // query param p @@ -229,6 +346,34 @@ func (o *GetEventsListParams) WriteToRequest(r runtime.ClientRequest, reg strfmt } } + if o.States != nil { + + // binding items for states + joinedStates := o.bindParamStates(reg) + + // query array param states + if err := r.SetQueryParam("states", joinedStates...); err != nil { + return err + } + } + + if o.To != nil { + + // query param to + var qrTo string + + if o.To != nil { + qrTo = *o.To + } + qTo := qrTo + if qTo != "" { + + if err := r.SetQueryParam("to", qTo); err != nil { + return err + } + } + } + // path param triggerID if err := r.SetPathParam("triggerID", o.TriggerID); err != nil { return err @@ -239,3 +384,20 @@ func (o *GetEventsListParams) WriteToRequest(r runtime.ClientRequest, reg strfmt } return nil } + +// bindParamGetEventsList binds the parameter states +func (o *GetEventsListParams) bindParamStates(formats strfmt.Registry) []string { + statesIR := o.States + + var statesIC []string + for _, statesIIR := range statesIR { // explode []string + + statesIIV := statesIIR // string as string + statesIC = append(statesIC, statesIIV) + } + + // items.CollectionFormat: "csv" + statesIS := swag.JoinByFormat(statesIC, "csv") + + return statesIS +}