github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/client/immutable/create_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  // NewCreateImmuRuleParams creates a new CreateImmuRuleParams 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 NewCreateImmuRuleParams() *CreateImmuRuleParams {
    29  	return &CreateImmuRuleParams{
    30  		timeout: cr.DefaultTimeout,
    31  	}
    32  }
    33  
    34  // NewCreateImmuRuleParamsWithTimeout creates a new CreateImmuRuleParams object
    35  // with the ability to set a timeout on a request.
    36  func NewCreateImmuRuleParamsWithTimeout(timeout time.Duration) *CreateImmuRuleParams {
    37  	return &CreateImmuRuleParams{
    38  		timeout: timeout,
    39  	}
    40  }
    41  
    42  // NewCreateImmuRuleParamsWithContext creates a new CreateImmuRuleParams object
    43  // with the ability to set a context for a request.
    44  func NewCreateImmuRuleParamsWithContext(ctx context.Context) *CreateImmuRuleParams {
    45  	return &CreateImmuRuleParams{
    46  		Context: ctx,
    47  	}
    48  }
    49  
    50  // NewCreateImmuRuleParamsWithHTTPClient creates a new CreateImmuRuleParams object
    51  // with the ability to set a custom HTTPClient for a request.
    52  func NewCreateImmuRuleParamsWithHTTPClient(client *http.Client) *CreateImmuRuleParams {
    53  	return &CreateImmuRuleParams{
    54  		HTTPClient: client,
    55  	}
    56  }
    57  
    58  /*
    59  CreateImmuRuleParams contains all the parameters to send to the API endpoint
    60  
    61  	for the create immu rule operation.
    62  
    63  	Typically these are written to a http.Request.
    64  */
    65  type CreateImmuRuleParams 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  	/* ProjectNameOrID.
    83  
    84  	   The name or id of the project
    85  	*/
    86  	ProjectNameOrID string
    87  
    88  	timeout    time.Duration
    89  	Context    context.Context
    90  	HTTPClient *http.Client
    91  }
    92  
    93  // WithDefaults hydrates default values in the create immu rule params (not the query body).
    94  //
    95  // All values with no default are reset to their zero value.
    96  func (o *CreateImmuRuleParams) WithDefaults() *CreateImmuRuleParams {
    97  	o.SetDefaults()
    98  	return o
    99  }
   100  
   101  // SetDefaults hydrates default values in the create immu rule params (not the query body).
   102  //
   103  // All values with no default are reset to their zero value.
   104  func (o *CreateImmuRuleParams) SetDefaults() {
   105  	var (
   106  		xIsResourceNameDefault = bool(false)
   107  	)
   108  
   109  	val := CreateImmuRuleParams{
   110  		XIsResourceName: &xIsResourceNameDefault,
   111  	}
   112  
   113  	val.timeout = o.timeout
   114  	val.Context = o.Context
   115  	val.HTTPClient = o.HTTPClient
   116  	*o = val
   117  }
   118  
   119  // WithTimeout adds the timeout to the create immu rule params
   120  func (o *CreateImmuRuleParams) WithTimeout(timeout time.Duration) *CreateImmuRuleParams {
   121  	o.SetTimeout(timeout)
   122  	return o
   123  }
   124  
   125  // SetTimeout adds the timeout to the create immu rule params
   126  func (o *CreateImmuRuleParams) SetTimeout(timeout time.Duration) {
   127  	o.timeout = timeout
   128  }
   129  
   130  // WithContext adds the context to the create immu rule params
   131  func (o *CreateImmuRuleParams) WithContext(ctx context.Context) *CreateImmuRuleParams {
   132  	o.SetContext(ctx)
   133  	return o
   134  }
   135  
   136  // SetContext adds the context to the create immu rule params
   137  func (o *CreateImmuRuleParams) SetContext(ctx context.Context) {
   138  	o.Context = ctx
   139  }
   140  
   141  // WithHTTPClient adds the HTTPClient to the create immu rule params
   142  func (o *CreateImmuRuleParams) WithHTTPClient(client *http.Client) *CreateImmuRuleParams {
   143  	o.SetHTTPClient(client)
   144  	return o
   145  }
   146  
   147  // SetHTTPClient adds the HTTPClient to the create immu rule params
   148  func (o *CreateImmuRuleParams) SetHTTPClient(client *http.Client) {
   149  	o.HTTPClient = client
   150  }
   151  
   152  // WithImmutableRule adds the immutableRule to the create immu rule params
   153  func (o *CreateImmuRuleParams) WithImmutableRule(immutableRule *models.ImmutableRule) *CreateImmuRuleParams {
   154  	o.SetImmutableRule(immutableRule)
   155  	return o
   156  }
   157  
   158  // SetImmutableRule adds the immutableRule to the create immu rule params
   159  func (o *CreateImmuRuleParams) SetImmutableRule(immutableRule *models.ImmutableRule) {
   160  	o.ImmutableRule = immutableRule
   161  }
   162  
   163  // WithXIsResourceName adds the xIsResourceName to the create immu rule params
   164  func (o *CreateImmuRuleParams) WithXIsResourceName(xIsResourceName *bool) *CreateImmuRuleParams {
   165  	o.SetXIsResourceName(xIsResourceName)
   166  	return o
   167  }
   168  
   169  // SetXIsResourceName adds the xIsResourceName to the create immu rule params
   170  func (o *CreateImmuRuleParams) SetXIsResourceName(xIsResourceName *bool) {
   171  	o.XIsResourceName = xIsResourceName
   172  }
   173  
   174  // WithXRequestID adds the xRequestID to the create immu rule params
   175  func (o *CreateImmuRuleParams) WithXRequestID(xRequestID *string) *CreateImmuRuleParams {
   176  	o.SetXRequestID(xRequestID)
   177  	return o
   178  }
   179  
   180  // SetXRequestID adds the xRequestId to the create immu rule params
   181  func (o *CreateImmuRuleParams) SetXRequestID(xRequestID *string) {
   182  	o.XRequestID = xRequestID
   183  }
   184  
   185  // WithProjectNameOrID adds the projectNameOrID to the create immu rule params
   186  func (o *CreateImmuRuleParams) WithProjectNameOrID(projectNameOrID string) *CreateImmuRuleParams {
   187  	o.SetProjectNameOrID(projectNameOrID)
   188  	return o
   189  }
   190  
   191  // SetProjectNameOrID adds the projectNameOrId to the create immu rule params
   192  func (o *CreateImmuRuleParams) SetProjectNameOrID(projectNameOrID string) {
   193  	o.ProjectNameOrID = projectNameOrID
   194  }
   195  
   196  // WriteToRequest writes these params to a swagger request
   197  func (o *CreateImmuRuleParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   198  
   199  	if err := r.SetTimeout(o.timeout); err != nil {
   200  		return err
   201  	}
   202  	var res []error
   203  	if o.ImmutableRule != nil {
   204  		if err := r.SetBodyParam(o.ImmutableRule); err != nil {
   205  			return err
   206  		}
   207  	}
   208  
   209  	if o.XIsResourceName != nil {
   210  
   211  		// header param X-Is-Resource-Name
   212  		if err := r.SetHeaderParam("X-Is-Resource-Name", swag.FormatBool(*o.XIsResourceName)); err != nil {
   213  			return err
   214  		}
   215  	}
   216  
   217  	if o.XRequestID != nil {
   218  
   219  		// header param X-Request-Id
   220  		if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil {
   221  			return err
   222  		}
   223  	}
   224  
   225  	// path param project_name_or_id
   226  	if err := r.SetPathParam("project_name_or_id", o.ProjectNameOrID); err != nil {
   227  		return err
   228  	}
   229  
   230  	if len(res) > 0 {
   231  		return errors.CompositeValidationError(res...)
   232  	}
   233  	return nil
   234  }