client

package
v0.0.0-...-3946914 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApiKeyAuthScopes = "ApiKeyAuth.Scopes"
)

Variables

This section is empty.

Functions

func NewGetPeakRecordsRequest

func NewGetPeakRecordsRequest(server string, params *GetPeakRecordsParams) (*http.Request, error)

NewGetPeakRecordsRequest generates requests for GetPeakRecords

func NewListSensorsRequest

func NewListSensorsRequest(server string) (*http.Request, error)

NewListSensorsRequest generates requests for ListSensors

Types

type Client

type Client struct {
	// The endpoint of the server conforming to this interface, with scheme,
	// https://api.deepmap.com for example. This can contain a path relative
	// to the server, such as https://api.deepmap.com/dev-test, and all the
	// paths in the swagger spec will be appended to the server.
	Server string

	// Doer for performing requests, typically a *http.Client with any
	// customized settings, such as certificate chains.
	Client HttpRequestDoer

	// A list of callbacks for modifying requests which are generated before sending over
	// the network.
	RequestEditors []RequestEditorFn
}

Client which conforms to the OpenAPI3 specification for this service.

func NewClient

func NewClient(server string, opts ...ClientOption) (*Client, error)

Creates a new Client, with reasonable defaults

func (*Client) GetPeakRecords

func (c *Client) GetPeakRecords(ctx context.Context, params *GetPeakRecordsParams, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) ListSensors

func (c *Client) ListSensors(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)

type ClientInterface

type ClientInterface interface {
	// GetPeakRecords request
	GetPeakRecords(ctx context.Context, params *GetPeakRecordsParams, reqEditors ...RequestEditorFn) (*http.Response, error)

	// ListSensors request
	ListSensors(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
}

The interface specification for the client above.

type ClientOption

type ClientOption func(*Client) error

ClientOption allows setting custom parameters during construction

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the baseURL.

func WithHTTPClient

func WithHTTPClient(doer HttpRequestDoer) ClientOption

WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.

func WithRequestEditorFn

func WithRequestEditorFn(fn RequestEditorFn) ClientOption

WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.

type ClientWithResponses

type ClientWithResponses struct {
	ClientInterface
}

ClientWithResponses builds on ClientInterface to offer response payloads

func NewClientWithResponses

func NewClientWithResponses(server string, token string, opts ...ClientOption) (*ClientWithResponses, error)

NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling

func (*ClientWithResponses) GetPeakRecordsWithResponse

func (c *ClientWithResponses) GetPeakRecordsWithResponse(ctx context.Context, params *GetPeakRecordsParams, reqEditors ...RequestEditorFn) (*GetPeakRecordsResponse, error)

GetPeakRecordsWithResponse request returning *GetPeakRecordsResponse

func (*ClientWithResponses) ListSensorsWithResponse

func (c *ClientWithResponses) ListSensorsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListSensorsResponse, error)

ListSensorsWithResponse request returning *ListSensorsResponse

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {
	// GetPeakRecordsWithResponse request
	GetPeakRecordsWithResponse(ctx context.Context, params *GetPeakRecordsParams, reqEditors ...RequestEditorFn) (*GetPeakRecordsResponse, error)

	// ListSensorsWithResponse request
	ListSensorsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListSensorsResponse, error)
}

ClientWithResponsesInterface is the interface specification for the client with responses above.

type ErrorResponse

type ErrorResponse struct {
	Help    *string `json:"help,omitempty"`
	Message *string `json:"message,omitempty"`
	Ok      bool    `json:"ok"`
}

ErrorResponse defines model for ErrorResponse.

type GetPeakRecordsParams

type GetPeakRecordsParams struct {
	// MeasuringPointId ID of the measuring point
	MeasuringPointId int `form:"measuring_point_id" json:"measuring_point_id"`

	// StartTime Start time in milliseconds since epoch
	StartTime int `form:"start_time" json:"start_time"`

	// EndTime End time in milliseconds since epoch (optional)
	EndTime *int `form:"end_time,omitempty" json:"end_time,omitempty"`
}

GetPeakRecordsParams defines parameters for GetPeakRecords.

type GetPeakRecordsResponse

type GetPeakRecordsResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *PeakRecordsResponse
	JSON400      *ErrorResponse
	JSON500      *ErrorResponse
}

func ParseGetPeakRecordsResponse

func ParseGetPeakRecordsResponse(rsp *http.Response) (*GetPeakRecordsResponse, error)

ParseGetPeakRecordsResponse parses an HTTP response from a GetPeakRecordsWithResponse call

func (GetPeakRecordsResponse) Status

func (r GetPeakRecordsResponse) Status() string

Status returns HTTPResponse.Status

func (GetPeakRecordsResponse) StatusCode

func (r GetPeakRecordsResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type HttpRequestDoer

type HttpRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer performs HTTP requests.

The standard http.Client implements this interface.

type ListSensorsResponse

type ListSensorsResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *SuccessResponse
	JSON400      *ErrorResponse
	JSON500      *ErrorResponse
}

func ParseListSensorsResponse

func ParseListSensorsResponse(rsp *http.Response) (*ListSensorsResponse, error)

ParseListSensorsResponse parses an HTTP response from a ListSensorsWithResponse call

func (ListSensorsResponse) Status

func (r ListSensorsResponse) Status() string

Status returns HTTPResponse.Status

func (ListSensorsResponse) StatusCode

func (r ListSensorsResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type Location

type Location struct {
	Latitude  *float64 `json:"latitude,omitempty"`
	Longitude *float64 `json:"longitude,omitempty"`
}

Location defines model for Location.

type MeasuringPoint

type MeasuringPoint struct {
	Active              *bool    `json:"active,omitempty"`
	AlarmPercentage     *int     `json:"alarm_percentage,omitempty"`
	Category            *string  `json:"category,omitempty"`
	DataSaveLevel       *float32 `json:"data_save_level,omitempty"`
	DisableLed          *bool    `json:"disable_led,omitempty"`
	GuideLine           *string  `json:"guide_line,omitempty"`
	Id                  *int     `json:"id,omitempty"`
	MeasurementDuration *int     `json:"measurement_duration,omitempty"`
	MeasuringType       *string  `json:"measuring_type,omitempty"`
	Name                *string  `json:"name,omitempty"`
	TracePostTrigger    *float64 `json:"trace_post_trigger,omitempty"`
	TracePreTrigger     *float64 `json:"trace_pre_trigger,omitempty"`
	TraceSaveLevel      *float64 `json:"trace_save_level,omitempty"`
	// UserLocation        *Location `json:"user_location,omitempty"`
	VibrationType *string `json:"vibration_type,omitempty"`
}

MeasuringPoint defines model for MeasuringPoint.

type PeakRecord

type PeakRecord struct {
	Category      *string `json:"category,omitempty"`
	GuideLine     *string `json:"guide_line,omitempty"`
	MeasuringType *string `json:"measuring_type,omitempty"`
	Timestamp     *int64  `json:"timestamp,omitempty"`
	VibrationType *string `json:"vibration_type,omitempty"`
}

PeakRecord defines model for PeakRecord.

type PeakRecordsResponse

type PeakRecordsResponse struct {
	Ok      bool         `json:"ok"`
	Samples []PeakRecord `json:"samples"`
}

PeakRecordsResponse defines model for PeakRecordsResponse.

type RequestEditorFn

type RequestEditorFn func(ctx context.Context, req *http.Request) error

RequestEditorFn is the function signature for the RequestEditor callback function

type Sensor

type Sensor struct {
	ConnectedUsing *string         `json:"connected_using,omitempty"`
	Lastseen       *time.Time      `json:"lastseen,omitempty"`
	Location       *Location       `json:"location,omitempty"`
	MeasuringPoint *MeasuringPoint `json:"measuring_point,omitempty"`
	Name           *string         `json:"name,omitempty"`
}

Sensor defines model for Sensor.

type SuccessResponse

type SuccessResponse struct {
	Ok      bool      `json:"ok"`
	Sensors *[]Sensor `json:"sensors,omitempty"`
}

SuccessResponse defines model for SuccessResponse.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL