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

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package immutable
     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  	"github.com/goharbor/go-client/pkg/sdk/v2.0/models"
    20  )
    21  
    22  // NewUpdateImmuRuleParams creates a new UpdateImmuRuleParams object,
    23  // with the default timeout for this client.
    24  //
    25  // Default values are not hydrated, since defaults are normally applied by the API server side.
    26  //
    27  // To enforce default values in parameter, use SetDefaults or WithDefaults.
    28  func NewUpdateImmuRuleParams() *UpdateImmuRuleParams {
    29  	return &UpdateImmuRuleParams{
    30  		timeout: cr.DefaultTimeout,
    31  	}
    32  }
    33  
    34  // NewUpdateImmuRuleParamsWithTimeout creates a new UpdateImmuRuleParams object
    35  // with the ability to set a timeout on a request.
    36  func NewUpdateImmuRuleParamsWithTimeout(timeout time.Duration) *UpdateImmuRuleParams {
    37  	return &UpdateImmuRuleParams{
    38  		timeout: timeout,
    39  	}
    40  }
    41  
    42  // NewUpdateImmuRuleParamsWithContext creates a new UpdateImmuRuleParams object
    43  // with the ability to set a context for a request.
    44  func NewUpdateImmuRuleParamsWithContext(ctx context.Context) *UpdateImmuRuleParams {
    45  	return &UpdateImmuRuleParams{
    46  		Context: ctx,
    47  	}
    48  }
    49  
    50  // NewUpdateImmuRuleParamsWithHTTPClient creates a new UpdateImmuRuleParams object
    51  // with the ability to set a custom HTTPClient for a request.
    52  func NewUpdateImmuRuleParamsWithHTTPClient(client *http.Client) *UpdateImmuRuleParams {
    53  	return &UpdateImmuRuleParams{
    54  		HTTPClient: client,
    55  	}
    56  }
    57  
    58  /*
    59  UpdateImmuRuleParams contains all the parameters to send to the API endpoint
    60  
    61  	for the update immu rule operation.
    62  
    63  	Typically these are written to a http.Request.
    64  */
    65  type UpdateImmuRuleParams struct {
    66  
    67  	// ImmutableRule.
    68  	ImmutableRule *models.ImmutableRule
    69  
    70  	/* XIsResourceName.
    71  
    72  	   The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.
    73  	*/
    74  	XIsResourceName *bool
    75  
    76  	/* XRequestID.
    77  
    78  	   An unique ID for the request
    79  	*/
    80  	XRequestID *string
    81  
    82  	/* ImmutableRuleID.
    83  
    84  	   The ID of the immutable rule
    85  
    86  	   Format: int64
    87  	*/
    88  	ImmutableRuleID int64
    89  
    90  	/* ProjectNameOrID.
    91  
    92  	   The name or id of the project
    93  	*/
    94  	ProjectNameOrID string
    95  
    96  	timeout    time.Duration
    97  	Context    context.Context
    98  	HTTPClient *http.Client
    99  }
   100  
   101  // WithDefaults hydrates default values in the update immu rule params (not the query body).
   102  //
   103  // All values with no default are reset to their zero value.
   104  func (o *UpdateImmuRuleParams) WithDefaults() *UpdateImmuRuleParams {
   105  	o.SetDefaults()
   106  	return o
   107  }
   108  
   109  // SetDefaults hydrates default values in the update immu rule params (not the query body).
   110  //
   111  // All values with no default are reset to their zero value.
   112  func (o *UpdateImmuRuleParams) SetDefaults() {
   113  	var (
   114  		xIsResourceNameDefault = bool(false)
   115  	)
   116  
   117  	val := UpdateImmuRuleParams{
   118  		XIsResourceName: &xIsResourceNameDefault,
   119  	}
   120  
   121  	val.timeout = o.timeout
   122  	val.Context = o.Context
   123  	val.HTTPClient = o.HTTPClient
   124  	*o = val
   125  }
   126  
   127  // WithTimeout adds the timeout to the update immu rule params
   128  func (o *UpdateImmuRuleParams) WithTimeout(timeout time.Duration) *UpdateImmuRuleParams {
   129  	o.SetTimeout(timeout)
   130  	return o
   131  }
   132  
   133  // SetTimeout adds the timeout to the update immu rule params
   134  func (o *UpdateImmuRuleParams) SetTimeout(timeout time.Duration) {
   135  	o.timeout = timeout
   136  }
   137  
   138  // WithContext adds the context to the update immu rule params
   139  func (o *UpdateImmuRuleParams) WithContext(ctx context.Context) *UpdateImmuRuleParams {
   140  	o.SetContext(ctx)
   141  	return o
   142  }
   143  
   144  // SetContext adds the context to the update immu rule params
   145  func (o *UpdateImmuRuleParams) SetContext(ctx context.Context) {
   146  	o.Context = ctx
   147  }
   148  
   149  // WithHTTPClient adds the HTTPClient to the update immu rule params
   150  func (o *UpdateImmuRuleParams) WithHTTPClient(client *http.Client) *UpdateImmuRuleParams {
   151  	o.SetHTTPClient(client)
   152  	return o
   153  }
   154  
   155  // SetHTTPClient adds the HTTPClient to the update immu rule params
   156  func (o *UpdateImmuRuleParams) SetHTTPClient(client *http.Client) {
   157  	o.HTTPClient = client
   158  }
   159  
   160  // WithImmutableRule adds the immutableRule to the update immu rule params
   161  func (o *UpdateImmuRuleParams) WithImmutableRule(immutableRule *models.ImmutableRule) *UpdateImmuRuleParams {
   162  	o.SetImmutableRule(immutableRule)
   163  	return o
   164  }
   165  
   166  // SetImmutableRule adds the immutableRule to the update immu rule params
   167  func (o *UpdateImmuRuleParams) SetImmutableRule(immutableRule *models.ImmutableRule) {
   168  	o.ImmutableRule = immutableRule
   169  }
   170  
   171  // WithXIsResourceName adds the xIsResourceName to the update immu rule params
   172  func (o *UpdateImmuRuleParams) WithXIsResourceName(xIsResourceName *bool) *UpdateImmuRuleParams {
   173  	o.SetXIsResourceName(xIsResourceName)
   174  	return o
   175  }
   176  
   177  // SetXIsResourceName adds the xIsResourceName to the update immu rule params
   178  func (o *UpdateImmuRuleParams) SetXIsResourceName(xIsResourceName *bool) {
   179  	o.XIsResourceName = xIsResourceName
   180  }
   181  
   182  // WithXRequestID adds the xRequestID to the update immu rule params
   183  func (o *UpdateImmuRuleParams) WithXRequestID(xRequestID *string) *UpdateImmuRuleParams {
   184  	o.SetXRequestID(xRequestID)
   185  	return o
   186  }
   187  
   188  // SetXRequestID adds the xRequestId to the update immu rule params
   189  func (o *UpdateImmuRuleParams) SetXRequestID(xRequestID *string) {
   190  	o.XRequestID = xRequestID
   191  }
   192  
   193  // WithImmutableRuleID adds the immutableRuleID to the update immu rule params
   194  func (o *UpdateImmuRuleParams) WithImmutableRuleID(immutableRuleID int64) *UpdateImmuRuleParams {
   195  	o.SetImmutableRuleID(immutableRuleID)
   196  	return o
   197  }
   198  
   199  // SetImmutableRuleID adds the immutableRuleId to the update immu rule params
   200  func (o *UpdateImmuRuleParams) SetImmutableRuleID(immutableRuleID int64) {
   201  	o.ImmutableRuleID = immutableRuleID
   202  }
   203  
   204  // WithProjectNameOrID adds the projectNameOrID to the update immu rule params
   205  func (o *UpdateImmuRuleParams) WithProjectNameOrID(projectNameOrID string) *UpdateImmuRuleParams {
   206  	o.SetProjectNameOrID(projectNameOrID)
   207  	return o
   208  }
   209  
   210  // SetProjectNameOrID adds the projectNameOrId to the update immu rule params
   211  func (o *UpdateImmuRuleParams) SetProjectNameOrID(projectNameOrID string) {
   212  	o.ProjectNameOrID = projectNameOrID
   213  }
   214  
   215  // WriteToRequest writes these params to a swagger request
   216  func (o *UpdateImmuRuleParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   217  
   218  	if err := r.SetTimeout(o.timeout); err != nil {
   219  		return err
   220  	}
   221  	var res []error
   222  	if o.ImmutableRule != nil {
   223  		if err := r.SetBodyParam(o.ImmutableRule); err != nil {
   224  			return err
   225  		}
   226  	}
   227  
   228  	if o.XIsResourceName != nil {
   229  
   230  		// header param X-Is-Resource-Name
   231  		if err := r.SetHeaderParam("X-Is-Resource-Name", swag.FormatBool(*o.XIsResourceName)); err != nil {
   232  			return err
   233  		}
   234  	}
   235  
   236  	if o.XRequestID != nil {
   237  
   238  		// header param X-Request-Id
   239  		if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil {
   240  			return err
   241  		}
   242  	}
   243  
   244  	// path param immutable_rule_id
   245  	if err := r.SetPathParam("immutable_rule_id", swag.FormatInt64(o.ImmutableRuleID)); err != nil {
   246  		return err
   247  	}
   248  
   249  	// path param project_name_or_id
   250  	if err := r.SetPathParam("project_name_or_id", o.ProjectNameOrID); err != nil {
   251  		return err
   252  	}
   253  
   254  	if len(res) > 0 {
   255  		return errors.CompositeValidationError(res...)
   256  	}
   257  	return nil
   258  }