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

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package gc
     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  // NewGetGCHistoryParams creates a new GetGCHistoryParams 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 NewGetGCHistoryParams() *GetGCHistoryParams {
    27  	return &GetGCHistoryParams{
    28  		timeout: cr.DefaultTimeout,
    29  	}
    30  }
    31  
    32  // NewGetGCHistoryParamsWithTimeout creates a new GetGCHistoryParams object
    33  // with the ability to set a timeout on a request.
    34  func NewGetGCHistoryParamsWithTimeout(timeout time.Duration) *GetGCHistoryParams {
    35  	return &GetGCHistoryParams{
    36  		timeout: timeout,
    37  	}
    38  }
    39  
    40  // NewGetGCHistoryParamsWithContext creates a new GetGCHistoryParams object
    41  // with the ability to set a context for a request.
    42  func NewGetGCHistoryParamsWithContext(ctx context.Context) *GetGCHistoryParams {
    43  	return &GetGCHistoryParams{
    44  		Context: ctx,
    45  	}
    46  }
    47  
    48  // NewGetGCHistoryParamsWithHTTPClient creates a new GetGCHistoryParams object
    49  // with the ability to set a custom HTTPClient for a request.
    50  func NewGetGCHistoryParamsWithHTTPClient(client *http.Client) *GetGCHistoryParams {
    51  	return &GetGCHistoryParams{
    52  		HTTPClient: client,
    53  	}
    54  }
    55  
    56  /*
    57  GetGCHistoryParams contains all the parameters to send to the API endpoint
    58  
    59  	for the get GC history operation.
    60  
    61  	Typically these are written to a http.Request.
    62  */
    63  type GetGCHistoryParams 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  	/* Q.
    90  
    91  	   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]
    92  	*/
    93  	Q *string
    94  
    95  	/* Sort.
    96  
    97  	   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"
    98  	*/
    99  	Sort *string
   100  
   101  	timeout    time.Duration
   102  	Context    context.Context
   103  	HTTPClient *http.Client
   104  }
   105  
   106  // WithDefaults hydrates default values in the get GC history params (not the query body).
   107  //
   108  // All values with no default are reset to their zero value.
   109  func (o *GetGCHistoryParams) WithDefaults() *GetGCHistoryParams {
   110  	o.SetDefaults()
   111  	return o
   112  }
   113  
   114  // SetDefaults hydrates default values in the get GC history params (not the query body).
   115  //
   116  // All values with no default are reset to their zero value.
   117  func (o *GetGCHistoryParams) SetDefaults() {
   118  	var (
   119  		pageDefault = int64(1)
   120  
   121  		pageSizeDefault = int64(10)
   122  	)
   123  
   124  	val := GetGCHistoryParams{
   125  		Page:     &pageDefault,
   126  		PageSize: &pageSizeDefault,
   127  	}
   128  
   129  	val.timeout = o.timeout
   130  	val.Context = o.Context
   131  	val.HTTPClient = o.HTTPClient
   132  	*o = val
   133  }
   134  
   135  // WithTimeout adds the timeout to the get GC history params
   136  func (o *GetGCHistoryParams) WithTimeout(timeout time.Duration) *GetGCHistoryParams {
   137  	o.SetTimeout(timeout)
   138  	return o
   139  }
   140  
   141  // SetTimeout adds the timeout to the get GC history params
   142  func (o *GetGCHistoryParams) SetTimeout(timeout time.Duration) {
   143  	o.timeout = timeout
   144  }
   145  
   146  // WithContext adds the context to the get GC history params
   147  func (o *GetGCHistoryParams) WithContext(ctx context.Context) *GetGCHistoryParams {
   148  	o.SetContext(ctx)
   149  	return o
   150  }
   151  
   152  // SetContext adds the context to the get GC history params
   153  func (o *GetGCHistoryParams) SetContext(ctx context.Context) {
   154  	o.Context = ctx
   155  }
   156  
   157  // WithHTTPClient adds the HTTPClient to the get GC history params
   158  func (o *GetGCHistoryParams) WithHTTPClient(client *http.Client) *GetGCHistoryParams {
   159  	o.SetHTTPClient(client)
   160  	return o
   161  }
   162  
   163  // SetHTTPClient adds the HTTPClient to the get GC history params
   164  func (o *GetGCHistoryParams) SetHTTPClient(client *http.Client) {
   165  	o.HTTPClient = client
   166  }
   167  
   168  // WithXRequestID adds the xRequestID to the get GC history params
   169  func (o *GetGCHistoryParams) WithXRequestID(xRequestID *string) *GetGCHistoryParams {
   170  	o.SetXRequestID(xRequestID)
   171  	return o
   172  }
   173  
   174  // SetXRequestID adds the xRequestId to the get GC history params
   175  func (o *GetGCHistoryParams) SetXRequestID(xRequestID *string) {
   176  	o.XRequestID = xRequestID
   177  }
   178  
   179  // WithPage adds the page to the get GC history params
   180  func (o *GetGCHistoryParams) WithPage(page *int64) *GetGCHistoryParams {
   181  	o.SetPage(page)
   182  	return o
   183  }
   184  
   185  // SetPage adds the page to the get GC history params
   186  func (o *GetGCHistoryParams) SetPage(page *int64) {
   187  	o.Page = page
   188  }
   189  
   190  // WithPageSize adds the pageSize to the get GC history params
   191  func (o *GetGCHistoryParams) WithPageSize(pageSize *int64) *GetGCHistoryParams {
   192  	o.SetPageSize(pageSize)
   193  	return o
   194  }
   195  
   196  // SetPageSize adds the pageSize to the get GC history params
   197  func (o *GetGCHistoryParams) SetPageSize(pageSize *int64) {
   198  	o.PageSize = pageSize
   199  }
   200  
   201  // WithQ adds the q to the get GC history params
   202  func (o *GetGCHistoryParams) WithQ(q *string) *GetGCHistoryParams {
   203  	o.SetQ(q)
   204  	return o
   205  }
   206  
   207  // SetQ adds the q to the get GC history params
   208  func (o *GetGCHistoryParams) SetQ(q *string) {
   209  	o.Q = q
   210  }
   211  
   212  // WithSort adds the sort to the get GC history params
   213  func (o *GetGCHistoryParams) WithSort(sort *string) *GetGCHistoryParams {
   214  	o.SetSort(sort)
   215  	return o
   216  }
   217  
   218  // SetSort adds the sort to the get GC history params
   219  func (o *GetGCHistoryParams) SetSort(sort *string) {
   220  	o.Sort = sort
   221  }
   222  
   223  // WriteToRequest writes these params to a swagger request
   224  func (o *GetGCHistoryParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   225  
   226  	if err := r.SetTimeout(o.timeout); err != nil {
   227  		return err
   228  	}
   229  	var res []error
   230  
   231  	if o.XRequestID != nil {
   232  
   233  		// header param X-Request-Id
   234  		if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil {
   235  			return err
   236  		}
   237  	}
   238  
   239  	if o.Page != nil {
   240  
   241  		// query param page
   242  		var qrPage int64
   243  
   244  		if o.Page != nil {
   245  			qrPage = *o.Page
   246  		}
   247  		qPage := swag.FormatInt64(qrPage)
   248  		if qPage != "" {
   249  
   250  			if err := r.SetQueryParam("page", qPage); err != nil {
   251  				return err
   252  			}
   253  		}
   254  	}
   255  
   256  	if o.PageSize != nil {
   257  
   258  		// query param page_size
   259  		var qrPageSize int64
   260  
   261  		if o.PageSize != nil {
   262  			qrPageSize = *o.PageSize
   263  		}
   264  		qPageSize := swag.FormatInt64(qrPageSize)
   265  		if qPageSize != "" {
   266  
   267  			if err := r.SetQueryParam("page_size", qPageSize); err != nil {
   268  				return err
   269  			}
   270  		}
   271  	}
   272  
   273  	if o.Q != nil {
   274  
   275  		// query param q
   276  		var qrQ string
   277  
   278  		if o.Q != nil {
   279  			qrQ = *o.Q
   280  		}
   281  		qQ := qrQ
   282  		if qQ != "" {
   283  
   284  			if err := r.SetQueryParam("q", qQ); err != nil {
   285  				return err
   286  			}
   287  		}
   288  	}
   289  
   290  	if o.Sort != nil {
   291  
   292  		// query param sort
   293  		var qrSort string
   294  
   295  		if o.Sort != nil {
   296  			qrSort = *o.Sort
   297  		}
   298  		qSort := qrSort
   299  		if qSort != "" {
   300  
   301  			if err := r.SetQueryParam("sort", qSort); err != nil {
   302  				return err
   303  			}
   304  		}
   305  	}
   306  
   307  	if len(res) > 0 {
   308  		return errors.CompositeValidationError(res...)
   309  	}
   310  	return nil
   311  }