go-kimai/client/go_kimai_client.go

168 lines
4.9 KiB
Go
Raw Normal View History

2023-01-14 14:14:06 +00:00
// Code generated by go-swagger; DO NOT EDIT.
package client
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/go-openapi/runtime"
httptransport "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
2023-01-27 10:04:50 +00:00
"git.autonomic.zone/knoflook/go-kimai/client/activity"
"git.autonomic.zone/knoflook/go-kimai/client/customer"
"git.autonomic.zone/knoflook/go-kimai/client/default_operations"
"git.autonomic.zone/knoflook/go-kimai/client/expense"
"git.autonomic.zone/knoflook/go-kimai/client/kiosk"
"git.autonomic.zone/knoflook/go-kimai/client/meta_field"
"git.autonomic.zone/knoflook/go-kimai/client/project"
"git.autonomic.zone/knoflook/go-kimai/client/tag"
"git.autonomic.zone/knoflook/go-kimai/client/task"
"git.autonomic.zone/knoflook/go-kimai/client/team"
"git.autonomic.zone/knoflook/go-kimai/client/timesheet"
"git.autonomic.zone/knoflook/go-kimai/client/user"
2023-01-14 14:14:06 +00:00
)
// Default go kimai HTTP client.
var Default = NewHTTPClient(nil)
const (
// DefaultHost is the default Host
// found in Meta (info) section of spec file
DefaultHost string = "demo.kimai.org"
// DefaultBasePath is the default BasePath
// found in Meta (info) section of spec file
DefaultBasePath string = "/"
)
// DefaultSchemes are the default schemes found in Meta (info) section of spec file
var DefaultSchemes = []string{"http"}
// NewHTTPClient creates a new go kimai HTTP client.
func NewHTTPClient(formats strfmt.Registry) *GoKimai {
return NewHTTPClientWithConfig(formats, nil)
}
// NewHTTPClientWithConfig creates a new go kimai HTTP client,
// using a customizable transport config.
func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *GoKimai {
// ensure nullable parameters have default
if cfg == nil {
cfg = DefaultTransportConfig()
}
// create transport and client
transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes)
return New(transport, formats)
}
// New creates a new go kimai client
func New(transport runtime.ClientTransport, formats strfmt.Registry) *GoKimai {
// ensure nullable parameters have default
if formats == nil {
formats = strfmt.Default
}
cli := new(GoKimai)
cli.Transport = transport
cli.Activity = activity.New(transport, formats)
cli.Customer = customer.New(transport, formats)
cli.DefaultOperations = default_operations.New(transport, formats)
cli.Expense = expense.New(transport, formats)
cli.Kiosk = kiosk.New(transport, formats)
cli.MetaField = meta_field.New(transport, formats)
cli.Project = project.New(transport, formats)
cli.Tag = tag.New(transport, formats)
cli.Task = task.New(transport, formats)
cli.Team = team.New(transport, formats)
cli.Timesheet = timesheet.New(transport, formats)
cli.User = user.New(transport, formats)
return cli
}
// DefaultTransportConfig creates a TransportConfig with the
// default settings taken from the meta section of the spec file.
func DefaultTransportConfig() *TransportConfig {
return &TransportConfig{
Host: DefaultHost,
BasePath: DefaultBasePath,
Schemes: DefaultSchemes,
}
}
// TransportConfig contains the transport related info,
// found in the meta section of the spec file.
type TransportConfig struct {
Host string
BasePath string
Schemes []string
}
// WithHost overrides the default host,
// provided by the meta section of the spec file.
func (cfg *TransportConfig) WithHost(host string) *TransportConfig {
cfg.Host = host
return cfg
}
// WithBasePath overrides the default basePath,
// provided by the meta section of the spec file.
func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig {
cfg.BasePath = basePath
return cfg
}
// WithSchemes overrides the default schemes,
// provided by the meta section of the spec file.
func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig {
cfg.Schemes = schemes
return cfg
}
// GoKimai is a client for go kimai
type GoKimai struct {
Activity activity.ClientService
Customer customer.ClientService
DefaultOperations default_operations.ClientService
Expense expense.ClientService
Kiosk kiosk.ClientService
MetaField meta_field.ClientService
Project project.ClientService
Tag tag.ClientService
Task task.ClientService
Team team.ClientService
Timesheet timesheet.ClientService
User user.ClientService
Transport runtime.ClientTransport
}
// SetTransport changes the transport on the client and all its subresources
func (c *GoKimai) SetTransport(transport runtime.ClientTransport) {
c.Transport = transport
c.Activity.SetTransport(transport)
c.Customer.SetTransport(transport)
c.DefaultOperations.SetTransport(transport)
c.Expense.SetTransport(transport)
c.Kiosk.SetTransport(transport)
c.MetaField.SetTransport(transport)
c.Project.SetTransport(transport)
c.Tag.SetTransport(transport)
c.Task.SetTransport(transport)
c.Team.SetTransport(transport)
c.Timesheet.SetTransport(transport)
c.User.SetTransport(transport)
}