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

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