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

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