autogits/bots-common/gitea-generated/client/user/user_create_token_parameters.go

173 lines
4.8 KiB
Go
Raw Normal View History

2024-07-07 21:08:41 +02:00
// Code generated by go-swagger; DO NOT EDIT.
package user
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
"src.opensuse.org/autogits/common/gitea-generated/models"
)
// NewUserCreateTokenParams creates a new UserCreateTokenParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewUserCreateTokenParams() *UserCreateTokenParams {
return &UserCreateTokenParams{
timeout: cr.DefaultTimeout,
}
}
// NewUserCreateTokenParamsWithTimeout creates a new UserCreateTokenParams object
// with the ability to set a timeout on a request.
func NewUserCreateTokenParamsWithTimeout(timeout time.Duration) *UserCreateTokenParams {
return &UserCreateTokenParams{
timeout: timeout,
}
}
// NewUserCreateTokenParamsWithContext creates a new UserCreateTokenParams object
// with the ability to set a context for a request.
func NewUserCreateTokenParamsWithContext(ctx context.Context) *UserCreateTokenParams {
return &UserCreateTokenParams{
Context: ctx,
}
}
// NewUserCreateTokenParamsWithHTTPClient creates a new UserCreateTokenParams object
// with the ability to set a custom HTTPClient for a request.
func NewUserCreateTokenParamsWithHTTPClient(client *http.Client) *UserCreateTokenParams {
return &UserCreateTokenParams{
HTTPClient: client,
}
}
/*
UserCreateTokenParams contains all the parameters to send to the API endpoint
for the user create token operation.
Typically these are written to a http.Request.
*/
type UserCreateTokenParams struct {
// Body.
Body *models.CreateAccessTokenOption
/* Username.
username of user
*/
Username string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the user create token params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *UserCreateTokenParams) WithDefaults() *UserCreateTokenParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the user create token params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *UserCreateTokenParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the user create token params
func (o *UserCreateTokenParams) WithTimeout(timeout time.Duration) *UserCreateTokenParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the user create token params
func (o *UserCreateTokenParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the user create token params
func (o *UserCreateTokenParams) WithContext(ctx context.Context) *UserCreateTokenParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the user create token params
func (o *UserCreateTokenParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the user create token params
func (o *UserCreateTokenParams) WithHTTPClient(client *http.Client) *UserCreateTokenParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the user create token params
func (o *UserCreateTokenParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the user create token params
func (o *UserCreateTokenParams) WithBody(body *models.CreateAccessTokenOption) *UserCreateTokenParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the user create token params
func (o *UserCreateTokenParams) SetBody(body *models.CreateAccessTokenOption) {
o.Body = body
}
// WithUsername adds the username to the user create token params
func (o *UserCreateTokenParams) WithUsername(username string) *UserCreateTokenParams {
o.SetUsername(username)
return o
}
// SetUsername adds the username to the user create token params
func (o *UserCreateTokenParams) SetUsername(username string) {
o.Username = username
}
// WriteToRequest writes these params to a swagger request
func (o *UserCreateTokenParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if o.Body != nil {
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
}
// path param username
if err := r.SetPathParam("username", o.Username); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}