feat: init

This commit is contained in:
decentral1se
2023-01-14 15:14:06 +01:00
commit f44e2acbaf
245 changed files with 44079 additions and 0 deletions

View File

@ -0,0 +1,152 @@
// 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"
"github.com/go-openapi/swag"
)
// NewGetAPIUsersIDParams creates a new GetAPIUsersIDParams 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 NewGetAPIUsersIDParams() *GetAPIUsersIDParams {
return &GetAPIUsersIDParams{
timeout: cr.DefaultTimeout,
}
}
// NewGetAPIUsersIDParamsWithTimeout creates a new GetAPIUsersIDParams object
// with the ability to set a timeout on a request.
func NewGetAPIUsersIDParamsWithTimeout(timeout time.Duration) *GetAPIUsersIDParams {
return &GetAPIUsersIDParams{
timeout: timeout,
}
}
// NewGetAPIUsersIDParamsWithContext creates a new GetAPIUsersIDParams object
// with the ability to set a context for a request.
func NewGetAPIUsersIDParamsWithContext(ctx context.Context) *GetAPIUsersIDParams {
return &GetAPIUsersIDParams{
Context: ctx,
}
}
// NewGetAPIUsersIDParamsWithHTTPClient creates a new GetAPIUsersIDParams object
// with the ability to set a custom HTTPClient for a request.
func NewGetAPIUsersIDParamsWithHTTPClient(client *http.Client) *GetAPIUsersIDParams {
return &GetAPIUsersIDParams{
HTTPClient: client,
}
}
/*
GetAPIUsersIDParams contains all the parameters to send to the API endpoint
for the get API users ID operation.
Typically these are written to a http.Request.
*/
type GetAPIUsersIDParams struct {
/* ID.
User ID to fetch
*/
ID int64
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the get API users ID params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetAPIUsersIDParams) WithDefaults() *GetAPIUsersIDParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the get API users ID params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetAPIUsersIDParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the get API users ID params
func (o *GetAPIUsersIDParams) WithTimeout(timeout time.Duration) *GetAPIUsersIDParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the get API users ID params
func (o *GetAPIUsersIDParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the get API users ID params
func (o *GetAPIUsersIDParams) WithContext(ctx context.Context) *GetAPIUsersIDParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the get API users ID params
func (o *GetAPIUsersIDParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the get API users ID params
func (o *GetAPIUsersIDParams) WithHTTPClient(client *http.Client) *GetAPIUsersIDParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the get API users ID params
func (o *GetAPIUsersIDParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithID adds the id to the get API users ID params
func (o *GetAPIUsersIDParams) WithID(id int64) *GetAPIUsersIDParams {
o.SetID(id)
return o
}
// SetID adds the id to the get API users ID params
func (o *GetAPIUsersIDParams) SetID(id int64) {
o.ID = id
}
// WriteToRequest writes these params to a swagger request
func (o *GetAPIUsersIDParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param id
if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,98 @@
// 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 (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
"decentral1se/go-kimai/models"
)
// GetAPIUsersIDReader is a Reader for the GetAPIUsersID structure.
type GetAPIUsersIDReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *GetAPIUsersIDReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewGetAPIUsersIDOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
}
}
// NewGetAPIUsersIDOK creates a GetAPIUsersIDOK with default headers values
func NewGetAPIUsersIDOK() *GetAPIUsersIDOK {
return &GetAPIUsersIDOK{}
}
/*
GetAPIUsersIDOK describes a response with status code 200, with default header values.
Return one user entity.
*/
type GetAPIUsersIDOK struct {
Payload *models.UserEntity
}
// IsSuccess returns true when this get Api users Id o k response has a 2xx status code
func (o *GetAPIUsersIDOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this get Api users Id o k response has a 3xx status code
func (o *GetAPIUsersIDOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this get Api users Id o k response has a 4xx status code
func (o *GetAPIUsersIDOK) IsClientError() bool {
return false
}
// IsServerError returns true when this get Api users Id o k response has a 5xx status code
func (o *GetAPIUsersIDOK) IsServerError() bool {
return false
}
// IsCode returns true when this get Api users Id o k response a status code equal to that given
func (o *GetAPIUsersIDOK) IsCode(code int) bool {
return code == 200
}
func (o *GetAPIUsersIDOK) Error() string {
return fmt.Sprintf("[GET /api/users/{id}][%d] getApiUsersIdOK %+v", 200, o.Payload)
}
func (o *GetAPIUsersIDOK) String() string {
return fmt.Sprintf("[GET /api/users/{id}][%d] getApiUsersIdOK %+v", 200, o.Payload)
}
func (o *GetAPIUsersIDOK) GetPayload() *models.UserEntity {
return o.Payload
}
func (o *GetAPIUsersIDOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.UserEntity)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View File

@ -0,0 +1,128 @@
// 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"
)
// NewGetAPIUsersMeParams creates a new GetAPIUsersMeParams 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 NewGetAPIUsersMeParams() *GetAPIUsersMeParams {
return &GetAPIUsersMeParams{
timeout: cr.DefaultTimeout,
}
}
// NewGetAPIUsersMeParamsWithTimeout creates a new GetAPIUsersMeParams object
// with the ability to set a timeout on a request.
func NewGetAPIUsersMeParamsWithTimeout(timeout time.Duration) *GetAPIUsersMeParams {
return &GetAPIUsersMeParams{
timeout: timeout,
}
}
// NewGetAPIUsersMeParamsWithContext creates a new GetAPIUsersMeParams object
// with the ability to set a context for a request.
func NewGetAPIUsersMeParamsWithContext(ctx context.Context) *GetAPIUsersMeParams {
return &GetAPIUsersMeParams{
Context: ctx,
}
}
// NewGetAPIUsersMeParamsWithHTTPClient creates a new GetAPIUsersMeParams object
// with the ability to set a custom HTTPClient for a request.
func NewGetAPIUsersMeParamsWithHTTPClient(client *http.Client) *GetAPIUsersMeParams {
return &GetAPIUsersMeParams{
HTTPClient: client,
}
}
/*
GetAPIUsersMeParams contains all the parameters to send to the API endpoint
for the get API users me operation.
Typically these are written to a http.Request.
*/
type GetAPIUsersMeParams struct {
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the get API users me params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetAPIUsersMeParams) WithDefaults() *GetAPIUsersMeParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the get API users me params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetAPIUsersMeParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the get API users me params
func (o *GetAPIUsersMeParams) WithTimeout(timeout time.Duration) *GetAPIUsersMeParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the get API users me params
func (o *GetAPIUsersMeParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the get API users me params
func (o *GetAPIUsersMeParams) WithContext(ctx context.Context) *GetAPIUsersMeParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the get API users me params
func (o *GetAPIUsersMeParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the get API users me params
func (o *GetAPIUsersMeParams) WithHTTPClient(client *http.Client) *GetAPIUsersMeParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the get API users me params
func (o *GetAPIUsersMeParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WriteToRequest writes these params to a swagger request
func (o *GetAPIUsersMeParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,98 @@
// 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 (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
"decentral1se/go-kimai/models"
)
// GetAPIUsersMeReader is a Reader for the GetAPIUsersMe structure.
type GetAPIUsersMeReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *GetAPIUsersMeReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewGetAPIUsersMeOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
}
}
// NewGetAPIUsersMeOK creates a GetAPIUsersMeOK with default headers values
func NewGetAPIUsersMeOK() *GetAPIUsersMeOK {
return &GetAPIUsersMeOK{}
}
/*
GetAPIUsersMeOK describes a response with status code 200, with default header values.
Return the current user entity.
*/
type GetAPIUsersMeOK struct {
Payload *models.UserEntity
}
// IsSuccess returns true when this get Api users me o k response has a 2xx status code
func (o *GetAPIUsersMeOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this get Api users me o k response has a 3xx status code
func (o *GetAPIUsersMeOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this get Api users me o k response has a 4xx status code
func (o *GetAPIUsersMeOK) IsClientError() bool {
return false
}
// IsServerError returns true when this get Api users me o k response has a 5xx status code
func (o *GetAPIUsersMeOK) IsServerError() bool {
return false
}
// IsCode returns true when this get Api users me o k response a status code equal to that given
func (o *GetAPIUsersMeOK) IsCode(code int) bool {
return code == 200
}
func (o *GetAPIUsersMeOK) Error() string {
return fmt.Sprintf("[GET /api/users/me][%d] getApiUsersMeOK %+v", 200, o.Payload)
}
func (o *GetAPIUsersMeOK) String() string {
return fmt.Sprintf("[GET /api/users/me][%d] getApiUsersMeOK %+v", 200, o.Payload)
}
func (o *GetAPIUsersMeOK) GetPayload() *models.UserEntity {
return o.Payload
}
func (o *GetAPIUsersMeOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.UserEntity)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View File

@ -0,0 +1,238 @@
// 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"
)
// NewGetAPIUsersParams creates a new GetAPIUsersParams 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 NewGetAPIUsersParams() *GetAPIUsersParams {
return &GetAPIUsersParams{
timeout: cr.DefaultTimeout,
}
}
// NewGetAPIUsersParamsWithTimeout creates a new GetAPIUsersParams object
// with the ability to set a timeout on a request.
func NewGetAPIUsersParamsWithTimeout(timeout time.Duration) *GetAPIUsersParams {
return &GetAPIUsersParams{
timeout: timeout,
}
}
// NewGetAPIUsersParamsWithContext creates a new GetAPIUsersParams object
// with the ability to set a context for a request.
func NewGetAPIUsersParamsWithContext(ctx context.Context) *GetAPIUsersParams {
return &GetAPIUsersParams{
Context: ctx,
}
}
// NewGetAPIUsersParamsWithHTTPClient creates a new GetAPIUsersParams object
// with the ability to set a custom HTTPClient for a request.
func NewGetAPIUsersParamsWithHTTPClient(client *http.Client) *GetAPIUsersParams {
return &GetAPIUsersParams{
HTTPClient: client,
}
}
/*
GetAPIUsersParams contains all the parameters to send to the API endpoint
for the get API users operation.
Typically these are written to a http.Request.
*/
type GetAPIUsersParams struct {
/* Order.
The result order. Allowed values: ASC, DESC (default: ASC)
*/
Order string
/* OrderBy.
The field by which results will be ordered. Allowed values: id, username, alias, email (default: username)
*/
OrderBy string
/* Term.
Free search term
*/
Term *string
/* Visible.
Visibility status to filter users. Allowed values: 1=visible, 2=hidden, 3=all (default: 1)
*/
Visible string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the get API users params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetAPIUsersParams) WithDefaults() *GetAPIUsersParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the get API users params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetAPIUsersParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the get API users params
func (o *GetAPIUsersParams) WithTimeout(timeout time.Duration) *GetAPIUsersParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the get API users params
func (o *GetAPIUsersParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the get API users params
func (o *GetAPIUsersParams) WithContext(ctx context.Context) *GetAPIUsersParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the get API users params
func (o *GetAPIUsersParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the get API users params
func (o *GetAPIUsersParams) WithHTTPClient(client *http.Client) *GetAPIUsersParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the get API users params
func (o *GetAPIUsersParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithOrder adds the order to the get API users params
func (o *GetAPIUsersParams) WithOrder(order string) *GetAPIUsersParams {
o.SetOrder(order)
return o
}
// SetOrder adds the order to the get API users params
func (o *GetAPIUsersParams) SetOrder(order string) {
o.Order = order
}
// WithOrderBy adds the orderBy to the get API users params
func (o *GetAPIUsersParams) WithOrderBy(orderBy string) *GetAPIUsersParams {
o.SetOrderBy(orderBy)
return o
}
// SetOrderBy adds the orderBy to the get API users params
func (o *GetAPIUsersParams) SetOrderBy(orderBy string) {
o.OrderBy = orderBy
}
// WithTerm adds the term to the get API users params
func (o *GetAPIUsersParams) WithTerm(term *string) *GetAPIUsersParams {
o.SetTerm(term)
return o
}
// SetTerm adds the term to the get API users params
func (o *GetAPIUsersParams) SetTerm(term *string) {
o.Term = term
}
// WithVisible adds the visible to the get API users params
func (o *GetAPIUsersParams) WithVisible(visible string) *GetAPIUsersParams {
o.SetVisible(visible)
return o
}
// SetVisible adds the visible to the get API users params
func (o *GetAPIUsersParams) SetVisible(visible string) {
o.Visible = visible
}
// WriteToRequest writes these params to a swagger request
func (o *GetAPIUsersParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// query param order
qrOrder := o.Order
qOrder := qrOrder
if err := r.SetQueryParam("order", qOrder); err != nil {
return err
}
// query param orderBy
qrOrderBy := o.OrderBy
qOrderBy := qrOrderBy
if err := r.SetQueryParam("orderBy", qOrderBy); err != nil {
return err
}
if o.Term != nil {
// query param term
var qrTerm string
if o.Term != nil {
qrTerm = *o.Term
}
qTerm := qrTerm
if qTerm != "" {
if err := r.SetQueryParam("term", qTerm); err != nil {
return err
}
}
}
// query param visible
qrVisible := o.Visible
qVisible := qrVisible
if err := r.SetQueryParam("visible", qVisible); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,96 @@
// 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 (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
"decentral1se/go-kimai/models"
)
// GetAPIUsersReader is a Reader for the GetAPIUsers structure.
type GetAPIUsersReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *GetAPIUsersReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewGetAPIUsersOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
}
}
// NewGetAPIUsersOK creates a GetAPIUsersOK with default headers values
func NewGetAPIUsersOK() *GetAPIUsersOK {
return &GetAPIUsersOK{}
}
/*
GetAPIUsersOK describes a response with status code 200, with default header values.
Returns the collection of all registered users. Required permission: view_user
*/
type GetAPIUsersOK struct {
Payload []*models.UserCollection
}
// IsSuccess returns true when this get Api users o k response has a 2xx status code
func (o *GetAPIUsersOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this get Api users o k response has a 3xx status code
func (o *GetAPIUsersOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this get Api users o k response has a 4xx status code
func (o *GetAPIUsersOK) IsClientError() bool {
return false
}
// IsServerError returns true when this get Api users o k response has a 5xx status code
func (o *GetAPIUsersOK) IsServerError() bool {
return false
}
// IsCode returns true when this get Api users o k response a status code equal to that given
func (o *GetAPIUsersOK) IsCode(code int) bool {
return code == 200
}
func (o *GetAPIUsersOK) Error() string {
return fmt.Sprintf("[GET /api/users][%d] getApiUsersOK %+v", 200, o.Payload)
}
func (o *GetAPIUsersOK) String() string {
return fmt.Sprintf("[GET /api/users][%d] getApiUsersOK %+v", 200, o.Payload)
}
func (o *GetAPIUsersOK) GetPayload() []*models.UserCollection {
return o.Payload
}
func (o *GetAPIUsersOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View File

@ -0,0 +1,173 @@
// 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"
"github.com/go-openapi/swag"
"decentral1se/go-kimai/models"
)
// NewPatchAPIUsersIDParams creates a new PatchAPIUsersIDParams 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 NewPatchAPIUsersIDParams() *PatchAPIUsersIDParams {
return &PatchAPIUsersIDParams{
timeout: cr.DefaultTimeout,
}
}
// NewPatchAPIUsersIDParamsWithTimeout creates a new PatchAPIUsersIDParams object
// with the ability to set a timeout on a request.
func NewPatchAPIUsersIDParamsWithTimeout(timeout time.Duration) *PatchAPIUsersIDParams {
return &PatchAPIUsersIDParams{
timeout: timeout,
}
}
// NewPatchAPIUsersIDParamsWithContext creates a new PatchAPIUsersIDParams object
// with the ability to set a context for a request.
func NewPatchAPIUsersIDParamsWithContext(ctx context.Context) *PatchAPIUsersIDParams {
return &PatchAPIUsersIDParams{
Context: ctx,
}
}
// NewPatchAPIUsersIDParamsWithHTTPClient creates a new PatchAPIUsersIDParams object
// with the ability to set a custom HTTPClient for a request.
func NewPatchAPIUsersIDParamsWithHTTPClient(client *http.Client) *PatchAPIUsersIDParams {
return &PatchAPIUsersIDParams{
HTTPClient: client,
}
}
/*
PatchAPIUsersIDParams contains all the parameters to send to the API endpoint
for the patch API users ID operation.
Typically these are written to a http.Request.
*/
type PatchAPIUsersIDParams struct {
// Body.
Body *models.UserEditForm
/* ID.
User ID to update
*/
ID int64
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the patch API users ID params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *PatchAPIUsersIDParams) WithDefaults() *PatchAPIUsersIDParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the patch API users ID params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *PatchAPIUsersIDParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the patch API users ID params
func (o *PatchAPIUsersIDParams) WithTimeout(timeout time.Duration) *PatchAPIUsersIDParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the patch API users ID params
func (o *PatchAPIUsersIDParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the patch API users ID params
func (o *PatchAPIUsersIDParams) WithContext(ctx context.Context) *PatchAPIUsersIDParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the patch API users ID params
func (o *PatchAPIUsersIDParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the patch API users ID params
func (o *PatchAPIUsersIDParams) WithHTTPClient(client *http.Client) *PatchAPIUsersIDParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the patch API users ID params
func (o *PatchAPIUsersIDParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the patch API users ID params
func (o *PatchAPIUsersIDParams) WithBody(body *models.UserEditForm) *PatchAPIUsersIDParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the patch API users ID params
func (o *PatchAPIUsersIDParams) SetBody(body *models.UserEditForm) {
o.Body = body
}
// WithID adds the id to the patch API users ID params
func (o *PatchAPIUsersIDParams) WithID(id int64) *PatchAPIUsersIDParams {
o.SetID(id)
return o
}
// SetID adds the id to the patch API users ID params
func (o *PatchAPIUsersIDParams) SetID(id int64) {
o.ID = id
}
// WriteToRequest writes these params to a swagger request
func (o *PatchAPIUsersIDParams) 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 id
if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,98 @@
// 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 (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
"decentral1se/go-kimai/models"
)
// PatchAPIUsersIDReader is a Reader for the PatchAPIUsersID structure.
type PatchAPIUsersIDReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *PatchAPIUsersIDReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewPatchAPIUsersIDOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
}
}
// NewPatchAPIUsersIDOK creates a PatchAPIUsersIDOK with default headers values
func NewPatchAPIUsersIDOK() *PatchAPIUsersIDOK {
return &PatchAPIUsersIDOK{}
}
/*
PatchAPIUsersIDOK describes a response with status code 200, with default header values.
Returns the updated user
*/
type PatchAPIUsersIDOK struct {
Payload *models.UserEntity
}
// IsSuccess returns true when this patch Api users Id o k response has a 2xx status code
func (o *PatchAPIUsersIDOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this patch Api users Id o k response has a 3xx status code
func (o *PatchAPIUsersIDOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this patch Api users Id o k response has a 4xx status code
func (o *PatchAPIUsersIDOK) IsClientError() bool {
return false
}
// IsServerError returns true when this patch Api users Id o k response has a 5xx status code
func (o *PatchAPIUsersIDOK) IsServerError() bool {
return false
}
// IsCode returns true when this patch Api users Id o k response a status code equal to that given
func (o *PatchAPIUsersIDOK) IsCode(code int) bool {
return code == 200
}
func (o *PatchAPIUsersIDOK) Error() string {
return fmt.Sprintf("[PATCH /api/users/{id}][%d] patchApiUsersIdOK %+v", 200, o.Payload)
}
func (o *PatchAPIUsersIDOK) String() string {
return fmt.Sprintf("[PATCH /api/users/{id}][%d] patchApiUsersIdOK %+v", 200, o.Payload)
}
func (o *PatchAPIUsersIDOK) GetPayload() *models.UserEntity {
return o.Payload
}
func (o *PatchAPIUsersIDOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.UserEntity)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View File

@ -0,0 +1,150 @@
// 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"
"decentral1se/go-kimai/models"
)
// NewPostAPIUsersParams creates a new PostAPIUsersParams 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 NewPostAPIUsersParams() *PostAPIUsersParams {
return &PostAPIUsersParams{
timeout: cr.DefaultTimeout,
}
}
// NewPostAPIUsersParamsWithTimeout creates a new PostAPIUsersParams object
// with the ability to set a timeout on a request.
func NewPostAPIUsersParamsWithTimeout(timeout time.Duration) *PostAPIUsersParams {
return &PostAPIUsersParams{
timeout: timeout,
}
}
// NewPostAPIUsersParamsWithContext creates a new PostAPIUsersParams object
// with the ability to set a context for a request.
func NewPostAPIUsersParamsWithContext(ctx context.Context) *PostAPIUsersParams {
return &PostAPIUsersParams{
Context: ctx,
}
}
// NewPostAPIUsersParamsWithHTTPClient creates a new PostAPIUsersParams object
// with the ability to set a custom HTTPClient for a request.
func NewPostAPIUsersParamsWithHTTPClient(client *http.Client) *PostAPIUsersParams {
return &PostAPIUsersParams{
HTTPClient: client,
}
}
/*
PostAPIUsersParams contains all the parameters to send to the API endpoint
for the post API users operation.
Typically these are written to a http.Request.
*/
type PostAPIUsersParams struct {
// Body.
Body *models.UserCreateForm
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the post API users params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *PostAPIUsersParams) WithDefaults() *PostAPIUsersParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the post API users params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *PostAPIUsersParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the post API users params
func (o *PostAPIUsersParams) WithTimeout(timeout time.Duration) *PostAPIUsersParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the post API users params
func (o *PostAPIUsersParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the post API users params
func (o *PostAPIUsersParams) WithContext(ctx context.Context) *PostAPIUsersParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the post API users params
func (o *PostAPIUsersParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the post API users params
func (o *PostAPIUsersParams) WithHTTPClient(client *http.Client) *PostAPIUsersParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the post API users params
func (o *PostAPIUsersParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the post API users params
func (o *PostAPIUsersParams) WithBody(body *models.UserCreateForm) *PostAPIUsersParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the post API users params
func (o *PostAPIUsersParams) SetBody(body *models.UserCreateForm) {
o.Body = body
}
// WriteToRequest writes these params to a swagger request
func (o *PostAPIUsersParams) 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
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,98 @@
// 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 (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
"decentral1se/go-kimai/models"
)
// PostAPIUsersReader is a Reader for the PostAPIUsers structure.
type PostAPIUsersReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *PostAPIUsersReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewPostAPIUsersOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
}
}
// NewPostAPIUsersOK creates a PostAPIUsersOK with default headers values
func NewPostAPIUsersOK() *PostAPIUsersOK {
return &PostAPIUsersOK{}
}
/*
PostAPIUsersOK describes a response with status code 200, with default header values.
Returns the new created user
*/
type PostAPIUsersOK struct {
Payload *models.UserEntity
}
// IsSuccess returns true when this post Api users o k response has a 2xx status code
func (o *PostAPIUsersOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this post Api users o k response has a 3xx status code
func (o *PostAPIUsersOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this post Api users o k response has a 4xx status code
func (o *PostAPIUsersOK) IsClientError() bool {
return false
}
// IsServerError returns true when this post Api users o k response has a 5xx status code
func (o *PostAPIUsersOK) IsServerError() bool {
return false
}
// IsCode returns true when this post Api users o k response a status code equal to that given
func (o *PostAPIUsersOK) IsCode(code int) bool {
return code == 200
}
func (o *PostAPIUsersOK) Error() string {
return fmt.Sprintf("[POST /api/users][%d] postApiUsersOK %+v", 200, o.Payload)
}
func (o *PostAPIUsersOK) String() string {
return fmt.Sprintf("[POST /api/users][%d] postApiUsersOK %+v", 200, o.Payload)
}
func (o *PostAPIUsersOK) GetPayload() *models.UserEntity {
return o.Payload
}
func (o *PostAPIUsersOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.UserEntity)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

248
client/user/user_client.go Normal file
View File

@ -0,0 +1,248 @@
// 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 (
"fmt"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
)
// New creates a new user API client.
func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
return &Client{transport: transport, formats: formats}
}
/*
Client for user API
*/
type Client struct {
transport runtime.ClientTransport
formats strfmt.Registry
}
// ClientOption is the option for Client methods
type ClientOption func(*runtime.ClientOperation)
// ClientService is the interface for Client methods
type ClientService interface {
GetAPIUsers(params *GetAPIUsersParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAPIUsersOK, error)
GetAPIUsersID(params *GetAPIUsersIDParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAPIUsersIDOK, error)
GetAPIUsersMe(params *GetAPIUsersMeParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAPIUsersMeOK, error)
PatchAPIUsersID(params *PatchAPIUsersIDParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PatchAPIUsersIDOK, error)
PostAPIUsers(params *PostAPIUsersParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostAPIUsersOK, error)
SetTransport(transport runtime.ClientTransport)
}
/*
GetAPIUsers returns the collection of all registered users
*/
func (a *Client) GetAPIUsers(params *GetAPIUsersParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAPIUsersOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewGetAPIUsersParams()
}
op := &runtime.ClientOperation{
ID: "GetAPIUsers",
Method: "GET",
PathPattern: "/api/users",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &GetAPIUsersReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*GetAPIUsersOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for GetAPIUsers: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
GetAPIUsersID returns one user entity
*/
func (a *Client) GetAPIUsersID(params *GetAPIUsersIDParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAPIUsersIDOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewGetAPIUsersIDParams()
}
op := &runtime.ClientOperation{
ID: "GetAPIUsersID",
Method: "GET",
PathPattern: "/api/users/{id}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &GetAPIUsersIDReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*GetAPIUsersIDOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for GetAPIUsersID: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
GetAPIUsersMe returns the current user entity
*/
func (a *Client) GetAPIUsersMe(params *GetAPIUsersMeParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAPIUsersMeOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewGetAPIUsersMeParams()
}
op := &runtime.ClientOperation{
ID: "GetAPIUsersMe",
Method: "GET",
PathPattern: "/api/users/me",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &GetAPIUsersMeReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*GetAPIUsersMeOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for GetAPIUsersMe: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
PatchAPIUsersID updates an existing user
Update an existing user, you can pass all or just a subset of all attributes (passing roles will replace all existing ones)
*/
func (a *Client) PatchAPIUsersID(params *PatchAPIUsersIDParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PatchAPIUsersIDOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewPatchAPIUsersIDParams()
}
op := &runtime.ClientOperation{
ID: "PatchAPIUsersID",
Method: "PATCH",
PathPattern: "/api/users/{id}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &PatchAPIUsersIDReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*PatchAPIUsersIDOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for PatchAPIUsersID: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
PostAPIUsers creates a new user
Creates a new user and returns it afterwards
*/
func (a *Client) PostAPIUsers(params *PostAPIUsersParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostAPIUsersOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewPostAPIUsersParams()
}
op := &runtime.ClientOperation{
ID: "PostAPIUsers",
Method: "POST",
PathPattern: "/api/users",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &PostAPIUsersReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*PostAPIUsersOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for PostAPIUsers: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
// SetTransport changes the transport on the client
func (a *Client) SetTransport(transport runtime.ClientTransport) {
a.transport = transport
}