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

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package member
     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  // NewCreateProjectMemberParams creates a new CreateProjectMemberParams 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 NewCreateProjectMemberParams() *CreateProjectMemberParams {
    29  	return &CreateProjectMemberParams{
    30  		timeout: cr.DefaultTimeout,
    31  	}
    32  }
    33  
    34  // NewCreateProjectMemberParamsWithTimeout creates a new CreateProjectMemberParams object
    35  // with the ability to set a timeout on a request.
    36  func NewCreateProjectMemberParamsWithTimeout(timeout time.Duration) *CreateProjectMemberParams {
    37  	return &CreateProjectMemberParams{
    38  		timeout: timeout,
    39  	}
    40  }
    41  
    42  // NewCreateProjectMemberParamsWithContext creates a new CreateProjectMemberParams object
    43  // with the ability to set a context for a request.
    44  func NewCreateProjectMemberParamsWithContext(ctx context.Context) *CreateProjectMemberParams {
    45  	return &CreateProjectMemberParams{
    46  		Context: ctx,
    47  	}
    48  }
    49  
    50  // NewCreateProjectMemberParamsWithHTTPClient creates a new CreateProjectMemberParams object
    51  // with the ability to set a custom HTTPClient for a request.
    52  func NewCreateProjectMemberParamsWithHTTPClient(client *http.Client) *CreateProjectMemberParams {
    53  	return &CreateProjectMemberParams{
    54  		HTTPClient: client,
    55  	}
    56  }
    57  
    58  /*
    59  CreateProjectMemberParams contains all the parameters to send to the API endpoint
    60  
    61  	for the create project member operation.
    62  
    63  	Typically these are written to a http.Request.
    64  */
    65  type CreateProjectMemberParams 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  	// ProjectMember.
    80  	ProjectMember *models.ProjectMember
    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 project member params (not the query body).
    94  //
    95  // All values with no default are reset to their zero value.
    96  func (o *CreateProjectMemberParams) WithDefaults() *CreateProjectMemberParams {
    97  	o.SetDefaults()
    98  	return o
    99  }
   100  
   101  // SetDefaults hydrates default values in the create project member params (not the query body).
   102  //
   103  // All values with no default are reset to their zero value.
   104  func (o *CreateProjectMemberParams) SetDefaults() {
   105  	var (
   106  		xIsResourceNameDefault = bool(false)
   107  	)
   108  
   109  	val := CreateProjectMemberParams{
   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 project member params
   120  func (o *CreateProjectMemberParams) WithTimeout(timeout time.Duration) *CreateProjectMemberParams {
   121  	o.SetTimeout(timeout)
   122  	return o
   123  }
   124  
   125  // SetTimeout adds the timeout to the create project member params
   126  func (o *CreateProjectMemberParams) SetTimeout(timeout time.Duration) {
   127  	o.timeout = timeout
   128  }
   129  
   130  // WithContext adds the context to the create project member params
   131  func (o *CreateProjectMemberParams) WithContext(ctx context.Context) *CreateProjectMemberParams {
   132  	o.SetContext(ctx)
   133  	return o
   134  }
   135  
   136  // SetContext adds the context to the create project member params
   137  func (o *CreateProjectMemberParams) SetContext(ctx context.Context) {
   138  	o.Context = ctx
   139  }
   140  
   141  // WithHTTPClient adds the HTTPClient to the create project member params
   142  func (o *CreateProjectMemberParams) WithHTTPClient(client *http.Client) *CreateProjectMemberParams {
   143  	o.SetHTTPClient(client)
   144  	return o
   145  }
   146  
   147  // SetHTTPClient adds the HTTPClient to the create project member params
   148  func (o *CreateProjectMemberParams) SetHTTPClient(client *http.Client) {
   149  	o.HTTPClient = client
   150  }
   151  
   152  // WithXIsResourceName adds the xIsResourceName to the create project member params
   153  func (o *CreateProjectMemberParams) WithXIsResourceName(xIsResourceName *bool) *CreateProjectMemberParams {
   154  	o.SetXIsResourceName(xIsResourceName)
   155  	return o
   156  }
   157  
   158  // SetXIsResourceName adds the xIsResourceName to the create project member params
   159  func (o *CreateProjectMemberParams) SetXIsResourceName(xIsResourceName *bool) {
   160  	o.XIsResourceName = xIsResourceName
   161  }
   162  
   163  // WithXRequestID adds the xRequestID to the create project member params
   164  func (o *CreateProjectMemberParams) WithXRequestID(xRequestID *string) *CreateProjectMemberParams {
   165  	o.SetXRequestID(xRequestID)
   166  	return o
   167  }
   168  
   169  // SetXRequestID adds the xRequestId to the create project member params
   170  func (o *CreateProjectMemberParams) SetXRequestID(xRequestID *string) {
   171  	o.XRequestID = xRequestID
   172  }
   173  
   174  // WithProjectMember adds the projectMember to the create project member params
   175  func (o *CreateProjectMemberParams) WithProjectMember(projectMember *models.ProjectMember) *CreateProjectMemberParams {
   176  	o.SetProjectMember(projectMember)
   177  	return o
   178  }
   179  
   180  // SetProjectMember adds the projectMember to the create project member params
   181  func (o *CreateProjectMemberParams) SetProjectMember(projectMember *models.ProjectMember) {
   182  	o.ProjectMember = projectMember
   183  }
   184  
   185  // WithProjectNameOrID adds the projectNameOrID to the create project member params
   186  func (o *CreateProjectMemberParams) WithProjectNameOrID(projectNameOrID string) *CreateProjectMemberParams {
   187  	o.SetProjectNameOrID(projectNameOrID)
   188  	return o
   189  }
   190  
   191  // SetProjectNameOrID adds the projectNameOrId to the create project member params
   192  func (o *CreateProjectMemberParams) SetProjectNameOrID(projectNameOrID string) {
   193  	o.ProjectNameOrID = projectNameOrID
   194  }
   195  
   196  // WriteToRequest writes these params to a swagger request
   197  func (o *CreateProjectMemberParams) 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  
   204  	if o.XIsResourceName != nil {
   205  
   206  		// header param X-Is-Resource-Name
   207  		if err := r.SetHeaderParam("X-Is-Resource-Name", swag.FormatBool(*o.XIsResourceName)); err != nil {
   208  			return err
   209  		}
   210  	}
   211  
   212  	if o.XRequestID != nil {
   213  
   214  		// header param X-Request-Id
   215  		if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil {
   216  			return err
   217  		}
   218  	}
   219  	if o.ProjectMember != nil {
   220  		if err := r.SetBodyParam(o.ProjectMember); 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  }