github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/mono/mono_client/status/usage_parameters.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package status 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 "context" 10 "net/http" 11 "time" 12 13 "github.com/go-openapi/errors" 14 "github.com/go-openapi/runtime" 15 cr "github.com/go-openapi/runtime/client" 16 "github.com/go-openapi/strfmt" 17 "github.com/go-openapi/swag" 18 ) 19 20 // NewUsageParams creates a new UsageParams object, 21 // with the default timeout for this client. 22 // 23 // Default values are not hydrated, since defaults are normally applied by the API server side. 24 // 25 // To enforce default values in parameter, use SetDefaults or WithDefaults. 26 func NewUsageParams() *UsageParams { 27 return &UsageParams{ 28 timeout: cr.DefaultTimeout, 29 } 30 } 31 32 // NewUsageParamsWithTimeout creates a new UsageParams object 33 // with the ability to set a timeout on a request. 34 func NewUsageParamsWithTimeout(timeout time.Duration) *UsageParams { 35 return &UsageParams{ 36 timeout: timeout, 37 } 38 } 39 40 // NewUsageParamsWithContext creates a new UsageParams object 41 // with the ability to set a context for a request. 42 func NewUsageParamsWithContext(ctx context.Context) *UsageParams { 43 return &UsageParams{ 44 Context: ctx, 45 } 46 } 47 48 // NewUsageParamsWithHTTPClient creates a new UsageParams object 49 // with the ability to set a custom HTTPClient for a request. 50 func NewUsageParamsWithHTTPClient(client *http.Client) *UsageParams { 51 return &UsageParams{ 52 HTTPClient: client, 53 } 54 } 55 56 /* UsageParams contains all the parameters to send to the API endpoint 57 for the usage operation. 58 59 Typically these are written to a http.Request. 60 */ 61 type UsageParams struct { 62 63 /* Grouping. 64 65 Desired grouping (day, week, month, year) 66 */ 67 Grouping *string 68 69 /* IncludeActivators. 70 71 Include Activators in user counts 72 */ 73 IncludeActivators *bool 74 75 /* Limit. 76 77 Number of periods to look back 78 */ 79 Limit *int64 80 81 timeout time.Duration 82 Context context.Context 83 HTTPClient *http.Client 84 } 85 86 // WithDefaults hydrates default values in the usage params (not the query body). 87 // 88 // All values with no default are reset to their zero value. 89 func (o *UsageParams) WithDefaults() *UsageParams { 90 o.SetDefaults() 91 return o 92 } 93 94 // SetDefaults hydrates default values in the usage params (not the query body). 95 // 96 // All values with no default are reset to their zero value. 97 func (o *UsageParams) SetDefaults() { 98 // no default values defined for this parameter 99 } 100 101 // WithTimeout adds the timeout to the usage params 102 func (o *UsageParams) WithTimeout(timeout time.Duration) *UsageParams { 103 o.SetTimeout(timeout) 104 return o 105 } 106 107 // SetTimeout adds the timeout to the usage params 108 func (o *UsageParams) SetTimeout(timeout time.Duration) { 109 o.timeout = timeout 110 } 111 112 // WithContext adds the context to the usage params 113 func (o *UsageParams) WithContext(ctx context.Context) *UsageParams { 114 o.SetContext(ctx) 115 return o 116 } 117 118 // SetContext adds the context to the usage params 119 func (o *UsageParams) SetContext(ctx context.Context) { 120 o.Context = ctx 121 } 122 123 // WithHTTPClient adds the HTTPClient to the usage params 124 func (o *UsageParams) WithHTTPClient(client *http.Client) *UsageParams { 125 o.SetHTTPClient(client) 126 return o 127 } 128 129 // SetHTTPClient adds the HTTPClient to the usage params 130 func (o *UsageParams) SetHTTPClient(client *http.Client) { 131 o.HTTPClient = client 132 } 133 134 // WithGrouping adds the grouping to the usage params 135 func (o *UsageParams) WithGrouping(grouping *string) *UsageParams { 136 o.SetGrouping(grouping) 137 return o 138 } 139 140 // SetGrouping adds the grouping to the usage params 141 func (o *UsageParams) SetGrouping(grouping *string) { 142 o.Grouping = grouping 143 } 144 145 // WithIncludeActivators adds the includeActivators to the usage params 146 func (o *UsageParams) WithIncludeActivators(includeActivators *bool) *UsageParams { 147 o.SetIncludeActivators(includeActivators) 148 return o 149 } 150 151 // SetIncludeActivators adds the includeActivators to the usage params 152 func (o *UsageParams) SetIncludeActivators(includeActivators *bool) { 153 o.IncludeActivators = includeActivators 154 } 155 156 // WithLimit adds the limit to the usage params 157 func (o *UsageParams) WithLimit(limit *int64) *UsageParams { 158 o.SetLimit(limit) 159 return o 160 } 161 162 // SetLimit adds the limit to the usage params 163 func (o *UsageParams) SetLimit(limit *int64) { 164 o.Limit = limit 165 } 166 167 // WriteToRequest writes these params to a swagger request 168 func (o *UsageParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { 169 170 if err := r.SetTimeout(o.timeout); err != nil { 171 return err 172 } 173 var res []error 174 175 if o.Grouping != nil { 176 177 // query param grouping 178 var qrGrouping string 179 180 if o.Grouping != nil { 181 qrGrouping = *o.Grouping 182 } 183 qGrouping := qrGrouping 184 if qGrouping != "" { 185 186 if err := r.SetQueryParam("grouping", qGrouping); err != nil { 187 return err 188 } 189 } 190 } 191 192 if o.IncludeActivators != nil { 193 194 // query param includeActivators 195 var qrIncludeActivators bool 196 197 if o.IncludeActivators != nil { 198 qrIncludeActivators = *o.IncludeActivators 199 } 200 qIncludeActivators := swag.FormatBool(qrIncludeActivators) 201 if qIncludeActivators != "" { 202 203 if err := r.SetQueryParam("includeActivators", qIncludeActivators); err != nil { 204 return err 205 } 206 } 207 } 208 209 if o.Limit != nil { 210 211 // query param limit 212 var qrLimit int64 213 214 if o.Limit != nil { 215 qrLimit = *o.Limit 216 } 217 qLimit := swag.FormatInt64(qrLimit) 218 if qLimit != "" { 219 220 if err := r.SetQueryParam("limit", qLimit); err != nil { 221 return err 222 } 223 } 224 } 225 226 if len(res) > 0 { 227 return errors.CompositeValidationError(res...) 228 } 229 return nil 230 }