github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/client/usergroup/search_user_groups_parameters.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package usergroup
     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  // NewSearchUserGroupsParams creates a new SearchUserGroupsParams 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 NewSearchUserGroupsParams() *SearchUserGroupsParams {
    27  	return &SearchUserGroupsParams{
    28  		timeout: cr.DefaultTimeout,
    29  	}
    30  }
    31  
    32  // NewSearchUserGroupsParamsWithTimeout creates a new SearchUserGroupsParams object
    33  // with the ability to set a timeout on a request.
    34  func NewSearchUserGroupsParamsWithTimeout(timeout time.Duration) *SearchUserGroupsParams {
    35  	return &SearchUserGroupsParams{
    36  		timeout: timeout,
    37  	}
    38  }
    39  
    40  // NewSearchUserGroupsParamsWithContext creates a new SearchUserGroupsParams object
    41  // with the ability to set a context for a request.
    42  func NewSearchUserGroupsParamsWithContext(ctx context.Context) *SearchUserGroupsParams {
    43  	return &SearchUserGroupsParams{
    44  		Context: ctx,
    45  	}
    46  }
    47  
    48  // NewSearchUserGroupsParamsWithHTTPClient creates a new SearchUserGroupsParams object
    49  // with the ability to set a custom HTTPClient for a request.
    50  func NewSearchUserGroupsParamsWithHTTPClient(client *http.Client) *SearchUserGroupsParams {
    51  	return &SearchUserGroupsParams{
    52  		HTTPClient: client,
    53  	}
    54  }
    55  
    56  /*
    57  SearchUserGroupsParams contains all the parameters to send to the API endpoint
    58  
    59  	for the search user groups operation.
    60  
    61  	Typically these are written to a http.Request.
    62  */
    63  type SearchUserGroupsParams struct {
    64  
    65  	/* XRequestID.
    66  
    67  	   An unique ID for the request
    68  	*/
    69  	XRequestID *string
    70  
    71  	/* Groupname.
    72  
    73  	   Group name for filtering results.
    74  	*/
    75  	Groupname string
    76  
    77  	/* Page.
    78  
    79  	   The page number
    80  
    81  	   Format: int64
    82  	   Default: 1
    83  	*/
    84  	Page *int64
    85  
    86  	/* PageSize.
    87  
    88  	   The size of per page
    89  
    90  	   Format: int64
    91  	   Default: 10
    92  	*/
    93  	PageSize *int64
    94  
    95  	timeout    time.Duration
    96  	Context    context.Context
    97  	HTTPClient *http.Client
    98  }
    99  
   100  // WithDefaults hydrates default values in the search user groups params (not the query body).
   101  //
   102  // All values with no default are reset to their zero value.
   103  func (o *SearchUserGroupsParams) WithDefaults() *SearchUserGroupsParams {
   104  	o.SetDefaults()
   105  	return o
   106  }
   107  
   108  // SetDefaults hydrates default values in the search user groups params (not the query body).
   109  //
   110  // All values with no default are reset to their zero value.
   111  func (o *SearchUserGroupsParams) SetDefaults() {
   112  	var (
   113  		pageDefault = int64(1)
   114  
   115  		pageSizeDefault = int64(10)
   116  	)
   117  
   118  	val := SearchUserGroupsParams{
   119  		Page:     &pageDefault,
   120  		PageSize: &pageSizeDefault,
   121  	}
   122  
   123  	val.timeout = o.timeout
   124  	val.Context = o.Context
   125  	val.HTTPClient = o.HTTPClient
   126  	*o = val
   127  }
   128  
   129  // WithTimeout adds the timeout to the search user groups params
   130  func (o *SearchUserGroupsParams) WithTimeout(timeout time.Duration) *SearchUserGroupsParams {
   131  	o.SetTimeout(timeout)
   132  	return o
   133  }
   134  
   135  // SetTimeout adds the timeout to the search user groups params
   136  func (o *SearchUserGroupsParams) SetTimeout(timeout time.Duration) {
   137  	o.timeout = timeout
   138  }
   139  
   140  // WithContext adds the context to the search user groups params
   141  func (o *SearchUserGroupsParams) WithContext(ctx context.Context) *SearchUserGroupsParams {
   142  	o.SetContext(ctx)
   143  	return o
   144  }
   145  
   146  // SetContext adds the context to the search user groups params
   147  func (o *SearchUserGroupsParams) SetContext(ctx context.Context) {
   148  	o.Context = ctx
   149  }
   150  
   151  // WithHTTPClient adds the HTTPClient to the search user groups params
   152  func (o *SearchUserGroupsParams) WithHTTPClient(client *http.Client) *SearchUserGroupsParams {
   153  	o.SetHTTPClient(client)
   154  	return o
   155  }
   156  
   157  // SetHTTPClient adds the HTTPClient to the search user groups params
   158  func (o *SearchUserGroupsParams) SetHTTPClient(client *http.Client) {
   159  	o.HTTPClient = client
   160  }
   161  
   162  // WithXRequestID adds the xRequestID to the search user groups params
   163  func (o *SearchUserGroupsParams) WithXRequestID(xRequestID *string) *SearchUserGroupsParams {
   164  	o.SetXRequestID(xRequestID)
   165  	return o
   166  }
   167  
   168  // SetXRequestID adds the xRequestId to the search user groups params
   169  func (o *SearchUserGroupsParams) SetXRequestID(xRequestID *string) {
   170  	o.XRequestID = xRequestID
   171  }
   172  
   173  // WithGroupname adds the groupname to the search user groups params
   174  func (o *SearchUserGroupsParams) WithGroupname(groupname string) *SearchUserGroupsParams {
   175  	o.SetGroupname(groupname)
   176  	return o
   177  }
   178  
   179  // SetGroupname adds the groupname to the search user groups params
   180  func (o *SearchUserGroupsParams) SetGroupname(groupname string) {
   181  	o.Groupname = groupname
   182  }
   183  
   184  // WithPage adds the page to the search user groups params
   185  func (o *SearchUserGroupsParams) WithPage(page *int64) *SearchUserGroupsParams {
   186  	o.SetPage(page)
   187  	return o
   188  }
   189  
   190  // SetPage adds the page to the search user groups params
   191  func (o *SearchUserGroupsParams) SetPage(page *int64) {
   192  	o.Page = page
   193  }
   194  
   195  // WithPageSize adds the pageSize to the search user groups params
   196  func (o *SearchUserGroupsParams) WithPageSize(pageSize *int64) *SearchUserGroupsParams {
   197  	o.SetPageSize(pageSize)
   198  	return o
   199  }
   200  
   201  // SetPageSize adds the pageSize to the search user groups params
   202  func (o *SearchUserGroupsParams) SetPageSize(pageSize *int64) {
   203  	o.PageSize = pageSize
   204  }
   205  
   206  // WriteToRequest writes these params to a swagger request
   207  func (o *SearchUserGroupsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   208  
   209  	if err := r.SetTimeout(o.timeout); err != nil {
   210  		return err
   211  	}
   212  	var res []error
   213  
   214  	if o.XRequestID != nil {
   215  
   216  		// header param X-Request-Id
   217  		if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil {
   218  			return err
   219  		}
   220  	}
   221  
   222  	// query param groupname
   223  	qrGroupname := o.Groupname
   224  	qGroupname := qrGroupname
   225  	if qGroupname != "" {
   226  
   227  		if err := r.SetQueryParam("groupname", qGroupname); err != nil {
   228  			return err
   229  		}
   230  	}
   231  
   232  	if o.Page != nil {
   233  
   234  		// query param page
   235  		var qrPage int64
   236  
   237  		if o.Page != nil {
   238  			qrPage = *o.Page
   239  		}
   240  		qPage := swag.FormatInt64(qrPage)
   241  		if qPage != "" {
   242  
   243  			if err := r.SetQueryParam("page", qPage); err != nil {
   244  				return err
   245  			}
   246  		}
   247  	}
   248  
   249  	if o.PageSize != nil {
   250  
   251  		// query param page_size
   252  		var qrPageSize int64
   253  
   254  		if o.PageSize != nil {
   255  			qrPageSize = *o.PageSize
   256  		}
   257  		qPageSize := swag.FormatInt64(qrPageSize)
   258  		if qPageSize != "" {
   259  
   260  			if err := r.SetQueryParam("page_size", qPageSize); err != nil {
   261  				return err
   262  			}
   263  		}
   264  	}
   265  
   266  	if len(res) > 0 {
   267  		return errors.CompositeValidationError(res...)
   268  	}
   269  	return nil
   270  }