Add a rudimentary filter option when listing entities
This change adds the ability to filter the list of entities returned by the API by entity owner, name or endpoint, depending on the entity type. Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
2fd0e720e6
commit
499fbde60c
32 changed files with 879 additions and 73 deletions
|
|
@ -60,6 +60,19 @@ ListEnterprisesParams contains all the parameters to send to the API endpoint
|
|||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type ListEnterprisesParams struct {
|
||||
|
||||
/* Endpoint.
|
||||
|
||||
Exact endpoint name to filter by
|
||||
*/
|
||||
Endpoint *string
|
||||
|
||||
/* Name.
|
||||
|
||||
Exact enterprise name to filter by
|
||||
*/
|
||||
Name *string
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
|
|
@ -113,6 +126,28 @@ func (o *ListEnterprisesParams) SetHTTPClient(client *http.Client) {
|
|||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithEndpoint adds the endpoint to the list enterprises params
|
||||
func (o *ListEnterprisesParams) WithEndpoint(endpoint *string) *ListEnterprisesParams {
|
||||
o.SetEndpoint(endpoint)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetEndpoint adds the endpoint to the list enterprises params
|
||||
func (o *ListEnterprisesParams) SetEndpoint(endpoint *string) {
|
||||
o.Endpoint = endpoint
|
||||
}
|
||||
|
||||
// WithName adds the name to the list enterprises params
|
||||
func (o *ListEnterprisesParams) WithName(name *string) *ListEnterprisesParams {
|
||||
o.SetName(name)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetName adds the name to the list enterprises params
|
||||
func (o *ListEnterprisesParams) SetName(name *string) {
|
||||
o.Name = name
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *ListEnterprisesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
|
|
@ -121,6 +156,40 @@ func (o *ListEnterprisesParams) WriteToRequest(r runtime.ClientRequest, reg strf
|
|||
}
|
||||
var res []error
|
||||
|
||||
if o.Endpoint != nil {
|
||||
|
||||
// query param endpoint
|
||||
var qrEndpoint string
|
||||
|
||||
if o.Endpoint != nil {
|
||||
qrEndpoint = *o.Endpoint
|
||||
}
|
||||
qEndpoint := qrEndpoint
|
||||
if qEndpoint != "" {
|
||||
|
||||
if err := r.SetQueryParam("endpoint", qEndpoint); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if o.Name != nil {
|
||||
|
||||
// query param name
|
||||
var qrName string
|
||||
|
||||
if o.Name != nil {
|
||||
qrName = *o.Name
|
||||
}
|
||||
qName := qrName
|
||||
if qName != "" {
|
||||
|
||||
if err := r.SetQueryParam("name", qName); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue