Documentation
¶
Index ¶
- Variables
- func CacheExpires(r *http.Response) time.Time
- type APIClient
- type APIKey
- type APIResponse
- type ApiError
- type BasicAuth
- type Channel
- type Configuration
- type Device
- type DeviceApiService
- type DeviceChannelValues
- type DeviceDataChannels
- type DeviceDataChannelsDeviceRequest
- type DeviceDataChannelsRequest
- type DevicesChannelValuesDto
- type DevicesDto
- type DevicesResponse
- type GenericRequest
- type GenericSwaggerError
- type PlantApiService
- type PlantOverview
- type PlantOverviewResponse
- type ProcessDataApiService
- func (a *ProcessDataApiService) GetProcessData(ctx context.Context, rpcbody ProcessDataRequest) (ProcessDataResponse, *http.Response, error)
- func (a *ProcessDataApiService) GetProcessDataChannels(ctx context.Context, rpcbody DeviceDataChannelsRequest) (ProcessDataChannelsResponse, *http.Response, error)
- type ProcessDataChannelsResponse
- type ProcessDataRequest
- type ProcessDataRequestDeviceObject
- type ProcessDataRequestDevicesContainer
- type ProcessDataResponse
- type WebboxClient
- func (w *WebboxClient) GetDevices() (DevicesResponse, error)
- func (w *WebboxClient) GetPlantOverview() (PlantOverviewResponse, error)
- func (w *WebboxClient) GetProcessData(deviceUid string) (ProcessDataResponse, error)
- func (w *WebboxClient) GetProcessDataChannels(deviceID string) (ProcessDataChannelsResponse, error)
- func (w *WebboxClient) GetProcessDataForDevices(devList []ProcessDataRequestDeviceObject) (ProcessDataResponse, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request. ContextOAuth2 = contextKey("token") // ContextBasicAuth takes BasicAuth as authentication for the request. ContextBasicAuth = contextKey("basic") // ContextAccessToken takes a string oauth2 access token as authentication for the request. ContextAccessToken = contextKey("accesstoken") // ContextAPIKey takes an APIKey as authentication for the request ContextAPIKey = contextKey("apikey") )
Functions ¶
Types ¶
type APIClient ¶
type APIClient struct {
DeviceApi *DeviceApiService
PlantApi *PlantApiService
ProcessDataApi *ProcessDataApiService
// contains filtered or unexported fields
}
APIClient manages communication with the SMA WebBox RPC over HTTP REST API API v1.4.0 In most cases there should be only one, shared, APIClient.
func NewAPIClient ¶
func NewAPIClient(cfg *Configuration) *APIClient
NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.
func (*APIClient) ChangeBasePath ¶
Change base path to allow switching to mocks
type APIKey ¶
APIKey provides API key based authentication to a request passed via context using ContextAPIKey
type APIResponse ¶
type APIResponse struct {
*http.Response `json:"-"`
Message string `json:"message,omitempty"`
// Operation is the name of the swagger operation.
Operation string `json:"operation,omitempty"`
// RequestURL is the request URL. This value is always available, even if the
// embedded *http.Response is nil.
RequestURL string `json:"url,omitempty"`
// Method is the HTTP method used for the request. This value is always
// available, even if the embedded *http.Response is nil.
Method string `json:"method,omitempty"`
// Payload holds the contents of the response body (which may be nil or empty).
// This is provided here as the raw response.Body() reader will have already
// been drained.
Payload []byte `json:"-"`
}
func NewAPIResponse ¶
func NewAPIResponse(r *http.Response) *APIResponse
func NewAPIResponseWithError ¶
func NewAPIResponseWithError(errorMessage string) *APIResponse
type BasicAuth ¶
type BasicAuth struct {
UserName string `json:"userName,omitempty"`
Password string `json:"password,omitempty"`
}
BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
type Channel ¶
type Channel struct {
// The meta name which uniquely defines the channel (e.g. \"ExtSolIrr\").
Meta string `json:"meta,omitempty"`
// The translated display name (e.g. \"External irradiation\"). Defining this element is optional. (optional)
Name string `json:"name,omitempty"`
// The unit of the channel (e.g. \"W/m^2\"). For channels which have no unit, an empty string must be entered. (optional)
Unit string `json:"unit,omitempty"`
// The value of the channel (e.g. \"843\"). Defining this element is optional. (optional)
Value string `json:"value,omitempty"`
}
type Configuration ¶
type Configuration struct {
BasePath string `json:"basePath,omitempty"`
Host string `json:"host,omitempty"`
Scheme string `json:"scheme,omitempty"`
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
UserAgent string `json:"userAgent,omitempty"`
HTTPClient *http.Client
}
func NewConfiguration ¶
func NewConfiguration() *Configuration
func (*Configuration) AddDefaultHeader ¶
func (c *Configuration) AddDefaultHeader(key string, value string)
type Device ¶
type Device struct {
// A unique device key (e.g. \"SB21TL06:2000106925\").
Key string `json:"key,omitempty"`
// The user-definable name of the device (e.g. \"INV left\"). Defining this element is optional. If the element is used but no name was defined, “`null“` is entered.
Name string `json:"name,omitempty"`
}
type DeviceApiService ¶
type DeviceApiService service
func (*DeviceApiService) GetDevices ¶
func (a *DeviceApiService) GetDevices(ctx context.Context, rpcbody GenericRequest) (DevicesResponse, *http.Response, error)
DeviceApiService Devices connected to SMA Webbox
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param rpcbody A JSON request which contains an encrypted JWT token and a groupId. The encrypted token is valid for a random time in the range between [5,10] seconds.
@return DevicesResponse
type DeviceChannelValues ¶
type DeviceDataChannels ¶
type DeviceDataChannelsDeviceRequest ¶
type DeviceDataChannelsDeviceRequest struct {
//
Device string `json:"device,omitempty"`
}
type DeviceDataChannelsRequest ¶
type DeviceDataChannelsRequest struct {
//
Format string `json:"format,omitempty"`
//
Proc string `json:"proc,omitempty"`
//
Version string `json:"version,omitempty"`
//
Id string `json:"id,omitempty"`
Params *DeviceDataChannelsDeviceRequest `json:"params,omitempty"`
}
type DevicesChannelValuesDto ¶
type DevicesChannelValuesDto struct {
Devices []DeviceChannelValues `json:"devices,omitempty"`
}
type DevicesDto ¶
type DevicesResponse ¶
type GenericRequest ¶
type GenericRequest struct {
//
Format string `json:"format,omitempty"`
//
Proc string `json:"proc,omitempty"`
//
Version string `json:"version,omitempty"`
//
Id string `json:"id,omitempty"`
}
Mother of all requests
type GenericSwaggerError ¶
type GenericSwaggerError struct {
// contains filtered or unexported fields
}
GenericSwaggerError Provides access to the body, error and model on returned errors.
func (GenericSwaggerError) Body ¶
func (e GenericSwaggerError) Body() []byte
Body returns the raw bytes of the response
func (GenericSwaggerError) Error ¶
func (e GenericSwaggerError) Error() string
Error returns non-empty string if there was an error.
func (GenericSwaggerError) Model ¶
func (e GenericSwaggerError) Model() interface{}
Model returns the unpacked model of the error
type PlantApiService ¶
type PlantApiService service
func (*PlantApiService) GetPlantOverview ¶
func (a *PlantApiService) GetPlantOverview(ctx context.Context, rpcbody GenericRequest) (PlantOverviewResponse, *http.Response, error)
PlantApiService Photovoltaic plant Overview values Returns an object with the following plant data:<ul><li>POWER</li><li>DAILY-YIELD</li><li>TOTAL-YIELD</li><li>STATUS</li><li>ERROR</li></ul>
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param rpcbody A JSON request which contains an encrypted JWT token and a groupId. The encrypted token is valid for a random time in the range between [5,10] seconds.
@return PlantOverviewResponse
type PlantOverview ¶
type PlantOverview struct {
Overview []Channel `json:"overview,omitempty"`
}
type PlantOverviewResponse ¶
type PlantOverviewResponse struct {
Result *PlantOverview `json:"result,omitempty"`
// Format of the response. In current implementation it always returns: JSON
Format string `json:"format"`
// Name of the RPC call. For this call it is: PlantOverview
Proc string `json:"proc"`
// Returns the API version of this response
Version string `json:"version"`
// A random
Id string `json:"id"`
//
Error_ string `json:"error,omitempty"`
}
type ProcessDataApiService ¶
type ProcessDataApiService service
func (*ProcessDataApiService) GetProcessData ¶
func (a *ProcessDataApiService) GetProcessData(ctx context.Context, rpcbody ProcessDataRequest) (ProcessDataResponse, *http.Response, error)
ProcessDataApiService Returns process data for up to 5 devices per request.
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param rpcbody A JSON request which contains an encrypted JWT token and a groupId. The encrypted token is valid for a random time in the range between [5,10] seconds.
@return ProcessDataResponse
func (*ProcessDataApiService) GetProcessDataChannels ¶
func (a *ProcessDataApiService) GetProcessDataChannels(ctx context.Context, rpcbody DeviceDataChannelsRequest) (ProcessDataChannelsResponse, *http.Response, error)
ProcessDataApiService List of the process data channels for a particular device type. Returns a list with the meta names of the available process data channels for a particular device type.
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param rpcbody A JSON request which contains an encrypted JWT token and a groupId. The encrypted token is valid for a random time in the range between [5,10] seconds.
@return ProcessDataChannelsResponse
type ProcessDataRequest ¶
type ProcessDataRequest struct {
//
Format string `json:"format,omitempty"`
//
Proc string `json:"proc,omitempty"`
//
Version string `json:"version,omitempty"`
//
Id string `json:"id,omitempty"`
Params *ProcessDataRequestDevicesContainer `json:"params,omitempty"`
}
type ProcessDataRequestDevicesContainer ¶
type ProcessDataRequestDevicesContainer struct {
//
Devices []ProcessDataRequestDeviceObject `json:"devices,omitempty"`
}
type ProcessDataResponse ¶
type WebboxClient ¶
https://stackoverflow.com/a/42872183/1411901 https://stackoverflow.com/questions/20895552/how-to-read-input-from-console-line https://stackoverflow.com/questions/19303137/golang-read-ints-from-stdin-until-eof-while-reporting-format-errors
func NewWebboxClient ¶
func NewWebboxClient(url string) WebboxClient
func (*WebboxClient) GetDevices ¶
func (w *WebboxClient) GetDevices() (DevicesResponse, error)
GetDevices returns an object which contains a list of the devices which are attached to SMA Webbox device.
func (*WebboxClient) GetPlantOverview ¶
func (w *WebboxClient) GetPlantOverview() (PlantOverviewResponse, error)
func (*WebboxClient) GetProcessData ¶
func (w *WebboxClient) GetProcessData(deviceUid string) (ProcessDataResponse, error)
func (*WebboxClient) GetProcessDataChannels ¶
func (w *WebboxClient) GetProcessDataChannels(deviceID string) (ProcessDataChannelsResponse, error)
func (*WebboxClient) GetProcessDataForDevices ¶
func (w *WebboxClient) GetProcessDataForDevices(devList []ProcessDataRequestDeviceObject) (ProcessDataResponse, error)
Source Files
¶
- api_device.go
- api_plant.go
- api_process_data.go
- client.go
- configuration.go
- model_api_error.go
- model_channel.go
- model_device.go
- model_device_channel_values.go
- model_device_data_channels.go
- model_device_data_channels_device_request.go
- model_device_data_channels_request.go
- model_devices_channel_values_dto.go
- model_devices_dto.go
- model_devices_response.go
- model_generic_request.go
- model_plant_overview.go
- model_plant_overview_response.go
- model_process_data_channels_response.go
- model_process_data_request.go
- model_process_data_request_device_object.go
- model_process_data_request_devices_container.go
- model_process_data_response.go
- response.go
- webbox_client.go