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

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package preheat
     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  // NewListPoliciesParams creates a new ListPoliciesParams 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 NewListPoliciesParams() *ListPoliciesParams {
    27  	return &ListPoliciesParams{
    28  		timeout: cr.DefaultTimeout,
    29  	}
    30  }
    31  
    32  // NewListPoliciesParamsWithTimeout creates a new ListPoliciesParams object
    33  // with the ability to set a timeout on a request.
    34  func NewListPoliciesParamsWithTimeout(timeout time.Duration) *ListPoliciesParams {
    35  	return &ListPoliciesParams{
    36  		timeout: timeout,
    37  	}
    38  }
    39  
    40  // NewListPoliciesParamsWithContext creates a new ListPoliciesParams object
    41  // with the ability to set a context for a request.
    42  func NewListPoliciesParamsWithContext(ctx context.Context) *ListPoliciesParams {
    43  	return &ListPoliciesParams{
    44  		Context: ctx,
    45  	}
    46  }
    47  
    48  // NewListPoliciesParamsWithHTTPClient creates a new ListPoliciesParams object
    49  // with the ability to set a custom HTTPClient for a request.
    50  func NewListPoliciesParamsWithHTTPClient(client *http.Client) *ListPoliciesParams {
    51  	return &ListPoliciesParams{
    52  		HTTPClient: client,
    53  	}
    54  }
    55  
    56  /*
    57  ListPoliciesParams contains all the parameters to send to the API endpoint
    58  
    59  	for the list policies operation.
    60  
    61  	Typically these are written to a http.Request.
    62  */
    63  type ListPoliciesParams struct {
    64  
    65  	/* XRequestID.
    66  
    67  	   An unique ID for the request
    68  	*/
    69  	XRequestID *string
    70  
    71  	/* Page.
    72  
    73  	   The page number
    74  
    75  	   Format: int64
    76  	   Default: 1
    77  	*/
    78  	Page *int64
    79  
    80  	/* PageSize.
    81  
    82  	   The size of per page
    83  
    84  	   Format: int64
    85  	   Default: 10
    86  	*/
    87  	PageSize *int64
    88  
    89  	/* ProjectName.
    90  
    91  	   The name of the project
    92  	*/
    93  	ProjectName string
    94  
    95  	/* Q.
    96  
    97  	   Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max]
    98  	*/
    99  	Q *string
   100  
   101  	/* Sort.
   102  
   103  	   Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2"
   104  	*/
   105  	Sort *string
   106  
   107  	timeout    time.Duration
   108  	Context    context.Context
   109  	HTTPClient *http.Client
   110  }
   111  
   112  // WithDefaults hydrates default values in the list policies params (not the query body).
   113  //
   114  // All values with no default are reset to their zero value.
   115  func (o *ListPoliciesParams) WithDefaults() *ListPoliciesParams {
   116  	o.SetDefaults()
   117  	return o
   118  }
   119  
   120  // SetDefaults hydrates default values in the list policies params (not the query body).
   121  //
   122  // All values with no default are reset to their zero value.
   123  func (o *ListPoliciesParams) SetDefaults() {
   124  	var (
   125  		pageDefault = int64(1)
   126  
   127  		pageSizeDefault = int64(10)
   128  	)
   129  
   130  	val := ListPoliciesParams{
   131  		Page:     &pageDefault,
   132  		PageSize: &pageSizeDefault,
   133  	}
   134  
   135  	val.timeout = o.timeout
   136  	val.Context = o.Context
   137  	val.HTTPClient = o.HTTPClient
   138  	*o = val
   139  }
   140  
   141  // WithTimeout adds the timeout to the list policies params
   142  func (o *ListPoliciesParams) WithTimeout(timeout time.Duration) *ListPoliciesParams {
   143  	o.SetTimeout(timeout)
   144  	return o
   145  }
   146  
   147  // SetTimeout adds the timeout to the list policies params
   148  func (o *ListPoliciesParams) SetTimeout(timeout time.Duration) {
   149  	o.timeout = timeout
   150  }
   151  
   152  // WithContext adds the context to the list policies params
   153  func (o *ListPoliciesParams) WithContext(ctx context.Context) *ListPoliciesParams {
   154  	o.SetContext(ctx)
   155  	return o
   156  }
   157  
   158  // SetContext adds the context to the list policies params
   159  func (o *ListPoliciesParams) SetContext(ctx context.Context) {
   160  	o.Context = ctx
   161  }
   162  
   163  // WithHTTPClient adds the HTTPClient to the list policies params
   164  func (o *ListPoliciesParams) WithHTTPClient(client *http.Client) *ListPoliciesParams {
   165  	o.SetHTTPClient(client)
   166  	return o
   167  }
   168  
   169  // SetHTTPClient adds the HTTPClient to the list policies params
   170  func (o *ListPoliciesParams) SetHTTPClient(client *http.Client) {
   171  	o.HTTPClient = client
   172  }
   173  
   174  // WithXRequestID adds the xRequestID to the list policies params
   175  func (o *ListPoliciesParams) WithXRequestID(xRequestID *string) *ListPoliciesParams {
   176  	o.SetXRequestID(xRequestID)
   177  	return o
   178  }
   179  
   180  // SetXRequestID adds the xRequestId to the list policies params
   181  func (o *ListPoliciesParams) SetXRequestID(xRequestID *string) {
   182  	o.XRequestID = xRequestID
   183  }
   184  
   185  // WithPage adds the page to the list policies params
   186  func (o *ListPoliciesParams) WithPage(page *int64) *ListPoliciesParams {
   187  	o.SetPage(page)
   188  	return o
   189  }
   190  
   191  // SetPage adds the page to the list policies params
   192  func (o *ListPoliciesParams) SetPage(page *int64) {
   193  	o.Page = page
   194  }
   195  
   196  // WithPageSize adds the pageSize to the list policies params
   197  func (o *ListPoliciesParams) WithPageSize(pageSize *int64) *ListPoliciesParams {
   198  	o.SetPageSize(pageSize)
   199  	return o
   200  }
   201  
   202  // SetPageSize adds the pageSize to the list policies params
   203  func (o *ListPoliciesParams) SetPageSize(pageSize *int64) {
   204  	o.PageSize = pageSize
   205  }
   206  
   207  // WithProjectName adds the projectName to the list policies params
   208  func (o *ListPoliciesParams) WithProjectName(projectName string) *ListPoliciesParams {
   209  	o.SetProjectName(projectName)
   210  	return o
   211  }
   212  
   213  // SetProjectName adds the projectName to the list policies params
   214  func (o *ListPoliciesParams) SetProjectName(projectName string) {
   215  	o.ProjectName = projectName
   216  }
   217  
   218  // WithQ adds the q to the list policies params
   219  func (o *ListPoliciesParams) WithQ(q *string) *ListPoliciesParams {
   220  	o.SetQ(q)
   221  	return o
   222  }
   223  
   224  // SetQ adds the q to the list policies params
   225  func (o *ListPoliciesParams) SetQ(q *string) {
   226  	o.Q = q
   227  }
   228  
   229  // WithSort adds the sort to the list policies params
   230  func (o *ListPoliciesParams) WithSort(sort *string) *ListPoliciesParams {
   231  	o.SetSort(sort)
   232  	return o
   233  }
   234  
   235  // SetSort adds the sort to the list policies params
   236  func (o *ListPoliciesParams) SetSort(sort *string) {
   237  	o.Sort = sort
   238  }
   239  
   240  // WriteToRequest writes these params to a swagger request
   241  func (o *ListPoliciesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   242  
   243  	if err := r.SetTimeout(o.timeout); err != nil {
   244  		return err
   245  	}
   246  	var res []error
   247  
   248  	if o.XRequestID != nil {
   249  
   250  		// header param X-Request-Id
   251  		if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil {
   252  			return err
   253  		}
   254  	}
   255  
   256  	if o.Page != nil {
   257  
   258  		// query param page
   259  		var qrPage int64
   260  
   261  		if o.Page != nil {
   262  			qrPage = *o.Page
   263  		}
   264  		qPage := swag.FormatInt64(qrPage)
   265  		if qPage != "" {
   266  
   267  			if err := r.SetQueryParam("page", qPage); err != nil {
   268  				return err
   269  			}
   270  		}
   271  	}
   272  
   273  	if o.PageSize != nil {
   274  
   275  		// query param page_size
   276  		var qrPageSize int64
   277  
   278  		if o.PageSize != nil {
   279  			qrPageSize = *o.PageSize
   280  		}
   281  		qPageSize := swag.FormatInt64(qrPageSize)
   282  		if qPageSize != "" {
   283  
   284  			if err := r.SetQueryParam("page_size", qPageSize); err != nil {
   285  				return err
   286  			}
   287  		}
   288  	}
   289  
   290  	// path param project_name
   291  	if err := r.SetPathParam("project_name", o.ProjectName); err != nil {
   292  		return err
   293  	}
   294  
   295  	if o.Q != nil {
   296  
   297  		// query param q
   298  		var qrQ string
   299  
   300  		if o.Q != nil {
   301  			qrQ = *o.Q
   302  		}
   303  		qQ := qrQ
   304  		if qQ != "" {
   305  
   306  			if err := r.SetQueryParam("q", qQ); err != nil {
   307  				return err
   308  			}
   309  		}
   310  	}
   311  
   312  	if o.Sort != nil {
   313  
   314  		// query param sort
   315  		var qrSort string
   316  
   317  		if o.Sort != nil {
   318  			qrSort = *o.Sort
   319  		}
   320  		qSort := qrSort
   321  		if qSort != "" {
   322  
   323  			if err := r.SetQueryParam("sort", qSort); err != nil {
   324  				return err
   325  			}
   326  		}
   327  	}
   328  
   329  	if len(res) > 0 {
   330  		return errors.CompositeValidationError(res...)
   331  	}
   332  	return nil
   333  }