client

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAuthTokenTransport

func NewAuthTokenTransport(t http.RoundTripper, token string) http.RoundTripper

func NewAuthUserTransport

func NewAuthUserTransport(t http.RoundTripper, user string) http.RoundTripper

Types

type AssetsAPI added in v0.0.6

type AssetsAPI struct {
	// contains filtered or unexported fields
}

func (*AssetsAPI) DeviceByID added in v0.0.8

func (a *AssetsAPI) DeviceByID(
	ctx context.Context, query DeviceByIDQuery,
) (DeviceByIDResponse, error)

func (*AssetsAPI) Devices added in v0.0.6

func (a *AssetsAPI) Devices(
	ctx context.Context, query DevicesQuery,
) (DevicesResponse, error)

type AuthTokenTransport

type AuthTokenTransport struct {
	// contains filtered or unexported fields
}

func (*AuthTokenTransport) RoundTrip

func (t *AuthTokenTransport) RoundTrip(req *http.Request) (*http.Response, error)

type AuthUserTransport

type AuthUserTransport struct {
	// contains filtered or unexported fields
}

func (*AuthUserTransport) RoundTrip

func (t *AuthUserTransport) RoundTrip(req *http.Request) (*http.Response, error)

type BlueprintsAPI added in v0.0.4

type BlueprintsAPI struct {
	// contains filtered or unexported fields
}

func (*BlueprintsAPI) Download added in v0.0.4

func (b *BlueprintsAPI) Download(
	ctx context.Context, blueprintID string,
) ([]byte, error)

type Client

type Client struct {

	// Services used for talking to different parts of the Enapter API.
	Commands   CommandsAPI
	Blueprints BlueprintsAPI
	Assets     AssetsAPI
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient *http.Client) *Client

func NewClientWithURL

func NewClientWithURL(httpClient *http.Client, baseURL string) (*Client, error)

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

func (*Client) NewRequest

func (c *Client) NewRequest(method, path string, body io.Reader) (*http.Request, error)

func (*Client) NewRequestWithContext

func (c *Client) NewRequestWithContext(
	ctx context.Context, method, path string, body io.Reader,
) (*http.Request, error)

type CommandProgress

type CommandProgress struct {
	CommandResponse
	Error error
}

type CommandQuery

type CommandQuery struct {
	DeviceID    string                 `json:"device_id,omitempty"`
	HardwareID  string                 `json:"hardware_id,omitempty"`
	CommandName string                 `json:"command_name"`
	Arguments   map[string]interface{} `json:"arguments,omitempty"`
}

type CommandResponse

type CommandResponse struct {
	State   CommandState           `json:"state"`
	Payload map[string]interface{} `json:"payload,omitempty"`
}

type CommandState

type CommandState string
const (
	CommandSucceeded     CommandState = "succeeded"
	CommandError         CommandState = "error"
	CommandPlatformError CommandState = "platform_error"
	CommandStarted       CommandState = "started"
	CommandInProgress    CommandState = "device_in_progress"
)

type CommandsAPI

type CommandsAPI struct {
	// contains filtered or unexported fields
}

func (*CommandsAPI) Execute

func (c *CommandsAPI) Execute(
	ctx context.Context, query CommandQuery,
) (CommandResponse, error)

func (*CommandsAPI) ExecuteWithProgress

func (c *CommandsAPI) ExecuteWithProgress(
	ctx context.Context, query CommandQuery,
) (<-chan CommandProgress, error)

type Device added in v0.0.6

type Device struct {
	DeviceID     string                 `json:"device_id"`
	Type         DeviceType             `json:"type"`
	UpdatedAt    time.Time              `json:"updated_at"`
	Properties   map[string]interface{} `json:"properties,omitempty"`
	Connectivity *DeviceConnectivity    `json:"connectivity,omitempty"`
	Manifest     json.RawMessage        `json:"manifest,omitempty"`
}

type DeviceByIDQuery added in v0.0.8

type DeviceByIDQuery struct {
	ID     string
	Expand ExpandDeviceParams
}

type DeviceByIDResponse added in v0.0.8

type DeviceByIDResponse struct {
	Device Device  `json:"device"`
	Errors []Error `json:"errors"`
}

type DeviceConnectivity added in v0.0.6

type DeviceConnectivity struct {
	Online bool `json:"online"`
}

type DeviceType added in v0.0.6

type DeviceType string
const (
	DeviceTypeEndpoint DeviceType = "endpoint"
	DeviceTypeUCM      DeviceType = "ucm"
	DeviceTypeGateway  DeviceType = "gateway"
)

type DevicesQuery added in v0.0.6

type DevicesQuery struct {
	PageToken    string
	PageSize     int
	FilterTypeIn []DeviceType
	Expand       ExpandDeviceParams
}

type DevicesResponse added in v0.0.6

type DevicesResponse struct {
	Devices       []Device `json:"devices"`
	Errors        []Error  `json:"errors"`
	NextPageToken string   `json:"next_page_token"`
}

type Error

type Error struct {
	Code    string                 `json:"code"`
	Message string                 `json:"message"`
	Details map[string]interface{} `json:"details,omitempty"`
}

type ExpandDeviceParams added in v0.0.8

type ExpandDeviceParams struct {
	Manifest     bool
	Properties   bool
	Connectivity bool
}

type ResponseError

type ResponseError struct {
	Errors     []Error       `json:"errors"`
	StatusCode int           `json:"-"`
	RetryAfter time.Duration `json:"-"`
}

func (ResponseError) Error

func (r ResponseError) Error() string

Jump to

Keyboard shortcuts

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