balena

package module
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: MIT Imports: 13 Imported by: 1

README

Balena Go

PkgGoDev




Balena Go is a library for accessing the Balena API

Balena API docs can be found here



Install

go get go.einride.tech/balena

Usage

import "go.einride.tech/balena"
Authentication

An Authentication Token can be used to authenticate with the API

You can then use your token to create a new client:

package main

import (
	"context"
	"go.einride.tech/balena"
)

const (
	token = "mytoken"
)

func main() {
	// We supply a nil http client to make use of http.DefaultClient
	client := balena.New(nil, token)
}

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplicationService

type ApplicationService service

ApplicationService handles communication with the application related methods of the Balena Cloud API.

func (*ApplicationService) DisableTrackLatestRelease

func (s *ApplicationService) DisableTrackLatestRelease(ctx context.Context, applicationID int64) ([]byte, error)

DisableTrackLatestRelease sets all devices owned by the application to NOT track the latest available release.

func (*ApplicationService) EnableTrackLatestRelease

func (s *ApplicationService) EnableTrackLatestRelease(ctx context.Context, applicationID int64) ([]byte, error)

EnableTrackLatestRelease sets all devices owned by the application to track the latest available release.

func (*ApplicationService) Get

func (s *ApplicationService) Get(ctx context.Context, applicationID int64) (*ApplicationsResponse, error)

Get returns information on a single application given its ID. If the application does not exist, both the response and error are nil.

func (*ApplicationService) GetByName

func (s *ApplicationService) GetByName(ctx context.Context, applicationName string) (*ApplicationsResponse, error)

GetByName returns information on a single application given its Name If the application does not exist, both the response and error are nil.

func (*ApplicationService) GetWithQuery

func (s *ApplicationService) GetWithQuery(ctx context.Context, query string) ([]*ApplicationsResponse, error)

GetWithQuery allows querying for devices using a custom open data protocol query. The query should be a valid, escaped OData query such as `%24filter=uuid+eq+'12333422'`.

Forward slash in filter keys should not be escaped (So `device/uuid` should not be escaped).

func (*ApplicationService) List

type ApplicationState

type ApplicationState struct {
	Services map[string]ServiceState `json:"services,omitempty"`
}

type ApplicationsResponse

type ApplicationsResponse struct {
	ID                             int64         `json:"id,omitempty"`
	ShouldTrackLatestRelease       bool          `json:"should_track_latest_release,omitempty"`
	IsPublic                       bool          `json:"is_public,omitempty"`
	IsHost                         bool          `json:"is_host,omitempty"`
	IsArchived                     bool          `json:"is_archived,omitempty"`
	IsDiscoverable                 bool          `json:"is_discoverable,omitempty"`
	UUID                           string        `json:"uuid,omitempty"`
	IsStoredAtRepositoryURL        string        `json:"is_stored_at__repository_url,omitempty"`
	CreatedAt                      string        `json:"created_at,omitempty"`
	AppName                        string        `json:"app_name,omitempty"`
	Actor                          int64         `json:"actor,omitempty"`
	Slug                           string        `json:"slug,omitempty"`
	IsOfClass                      string        `json:"is_of__class,omitempty"`
	Organization                   *odata.Object `json:"organization,omitempty"`
	ShouldBeRunningRelease         *odata.Object `json:"should_be_running__release,omitempty"`
	IsForDeviceType                *odata.Object `json:"is_for__device_type,omitempty"`
	DependsOnApplication           interface{}   `json:"depends_on__application,omitempty"`
	IsAccessibleBySupportUntilDate interface{}   `json:"is_accessible_by_support_until__date,omitempty"`
}

type Client

type Client struct {

	// Base URL for API requests. Defaults to the public Balena Cloud API
	// BaseURL should always be specified with a trailing slash.
	BaseURL   *url.URL
	UserAgent string

	// Services used for talking to different parts of the Balena API
	Application    *ApplicationService
	Device         *DeviceService
	Release        *ReleaseService
	ReleaseTag     *ReleaseTagService
	DeviceEnvVar   *DeviceEnvVarService
	DeviceServVar  *DeviceServVarService
	DeviceConfVar  *DeviceConfVarService
	DeviceTag      *DeviceTagService
	ServiceInstall *ServiceInstallService
	DeviceType     *DeviceTypeService
	// contains filtered or unexported fields
}

func New

func New(httpClient *http.Client, authToken string) *Client

New returns a new Balena API client.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) error

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response will be written to v, without attempting to decode it.

func (*Client) NewRequest

func (c *Client) NewRequest(
	ctx context.Context,
	method string,
	urlStr string,
	rawQuery string,
	body interface{},
) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, which will be resolved to the BaseURL of the Client. Relative URLS should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included in as the request body. A raw query string can be specified by rawQuery.

func (*Client) SupervisorV1

func (c *Client) SupervisorV1(applicationID int64, deviceUUID string) *SupervisorV1Service

SupervisorV1 returns a SupervisorV1Service to be used with balena cloud.Supervisor For local supervisor communication use balena.NewSupervisorV1() instead.

func (*Client) SupervisorV2

func (c *Client) SupervisorV2(applicationID int64, deviceUUID string) *SupervisorV2Service

SupervisorV2 returns a SupervisorV2Service to be used with balena cloud.Supervisor For local supervisor communication use balena.NewSupervisorV2() instead.

type CloudRequest

type CloudRequest struct {
	UUID   string      `json:"uuid,omitempty"`
	Method string      `json:"method,omitempty"`
	Data   interface{} `json:"data,omitempty"`
}

type DeviceConfVarResponse added in v0.4.0

type DeviceConfVarResponse struct {
	ID        int64        `json:"id,omitempty"`
	CreatedAt string       `json:"created_at,omitempty"`
	Device    odata.Object `json:"device,omitempty"`
	Name      string       `json:"name,omitempty"`
	Value     string       `json:"value,omitempty"`
}

type DeviceConfVarService added in v0.4.0

type DeviceConfVarService service

func (*DeviceConfVarService) Create added in v0.4.0

func (s *DeviceConfVarService) Create(
	ctx context.Context,
	deviceID IDOrUUID,
	name string,
	value string,
) (*DeviceConfVarResponse, error)

Create creates an environment variable with name=value given a device ID/UUID.

func (*DeviceConfVarService) DeleteWithName added in v0.4.0

func (s *DeviceConfVarService) DeleteWithName(ctx context.Context, deviceID IDOrUUID, name string) error

DeleteWithName deletes a variable with the given name from the device with given ID/UUID. No error is returned if no variable with such name exists.

func (*DeviceConfVarService) List added in v0.4.0

List lists all environment variables given a specific device ID/UUID.

type DeviceEnvVarResponse

type DeviceEnvVarResponse struct {
	ID        int64        `json:"id,omitempty"`
	CreatedAt string       `json:"created_at,omitempty"`
	Device    odata.Object `json:"device,omitempty"`
	Name      string       `json:"name,omitempty"`
	Value     string       `json:"value,omitempty"`
}

type DeviceEnvVarService

type DeviceEnvVarService service

func (*DeviceEnvVarService) Create

func (s *DeviceEnvVarService) Create(
	ctx context.Context,
	deviceID IDOrUUID,
	name string,
	value string,
) (*DeviceEnvVarResponse, error)

Create creates an environment variable with name=value given a device ID/UUID.

func (*DeviceEnvVarService) DeleteWithName

func (s *DeviceEnvVarService) DeleteWithName(ctx context.Context, deviceID IDOrUUID, name string) error

DeleteWithName deletes a variable with the given name from the device with given ID/UUID. No error is returned if no variable with such name exists.

func (*DeviceEnvVarService) List

List lists all environment variables given a specific device ID/UUID.

func (*DeviceEnvVarService) Update added in v0.5.0

func (s *DeviceEnvVarService) Update(ctx context.Context, deviceID IDOrUUID, name, newValue string) error

Update a variable with the given name from the device with given ID/UUID to the specified new value. No error is returned if no variable with such name exists.

type DeviceResponse

type DeviceResponse struct {
	ID               int64  `json:"id,omitempty"`
	Actor            int64  `json:"actor,omitempty"`
	MemoryUsage      int64  `json:"memory_usage,omitempty"`
	MemoryTotal      int64  `json:"memory_total,omitempty"`
	StorageUsage     int64  `json:"storage_usage,omitempty"`
	StorageTotal     int64  `json:"storage_total,omitempty"`
	CPUTemp          int64  `json:"cpu_temp,omitempty"`
	CPUUsage         int64  `json:"cpu_usage,omitempty"`
	IsOnline         bool   `json:"is_online,omitempty"`
	IsConnectedToVPN bool   `json:"is_connected_to_vpn,omitempty"`
	IsWebAccessible  bool   `json:"is_web_accessible,omitempty"`
	IsActive         bool   `json:"is_active,omitempty"`
	IsUndervolted    bool   `json:"is_undervolted,omitempty"`
	DeviceName       string `json:"device_name,omitempty"`
	UUID             string `json:"uuid,omitempty"`
	// TODO: Change to time.Time maybe?
	LastConnectivityEvent string `json:"last_connectivity_event,omitempty"`
	Status                string `json:"status,omitempty"`
	LastVPNEvent          string `json:"last_vpn_event,omitempty"`
	// TODO: Should we change to net.IP maybe?
	IPAddress string `json:"ip_address,omitempty"`
	// TODO: Should we change to net.IP maybe?
	VPNAddress string `json:"vpn_address,omitempty"`
	// TODO: Should we change to net.IP maybe?
	CPUID                              string        `json:"cpu_id,omitempty"`
	StorageBlockDevice                 string        `json:"storage_block_device,omitempty"`
	PublicAddress                      string        `json:"public_address,omitempty"`
	MACAddress                         string        `json:"mac_address,omitempty"`
	APIHeartbeatState                  string        `json:"api_heartbeat_state,omitempty"`
	OSVersion                          string        `json:"os_version,omitempty"`
	OSVariant                          string        `json:"os_variant,omitempty"`
	SupervisorVersion                  string        `json:"supervisor_version,omitempty"`
	ProvisioningState                  string        `json:"provisioning_state,omitempty"`
	Longitude                          string        `json:"longitude,omitempty"`
	Latitude                           string        `json:"latitude,omitempty"`
	Location                           string        `json:"location,omitempty"`
	CustomLongitude                    string        `json:"custom_longitude,omitempty"`
	CustomLatitude                     string        `json:"custom_latitude,omitempty"`
	CreatedAt                          string        `json:"created_at,omitempty"`
	DeviceType                         *odata.Object `json:"device_type,omitempty"`
	BelongsToApplication               *odata.Object `json:"belongs_to__application,omitempty"`
	BelongsToUser                      *odata.Object `json:"belongs_to__user,omitempty"`
	IsManagedByServiceInstance         *odata.Object `json:"is_managed_by__service_instance,omitempty"`
	IsManagedByDevice                  interface{}   `json:"is_managed_by__device,omitempty"`
	IsRunningRelease                   *odata.Object `json:"is_running__release,omitempty"`
	ShouldBeRunningRelease             *odata.Object `json:"should_be_running__release,omitempty"`
	ShouldBeManagedBySupervisorRelease *odata.Object `json:"should_be_managed_by__supervisor_release,omitempty"`
	Note                               interface{}   `json:"note,omitempty"`
	LocalID                            interface{}   `json:"local_id,omitempty"`
	ProvisioningProgress               interface{}   `json:"provisioning_progress,omitempty"`
	DownloadProgress                   interface{}   `json:"download_progress,omitempty"`
	LogsChannel                        interface{}   `json:"logs_channel,omitempty"`
	IsLockedUntil                      interface{}   `json:"is_locked_until__date,omitempty"`
	IsAccessibleBySupportUntil         interface{}   `json:"is_accessible_by_support_until__date,omitempty"`
	// OverallStatus will only be populated when explicitly selected through a query parameter: `$select=overall_status`.
	OverallStatus string `json:"overall_status,omitempty"`
}

type DeviceServVarCreateResponse added in v0.5.0

type DeviceServVarCreateResponse struct {
	ID             int64        `json:"id,omitempty"`
	CreatedAt      string       `json:"created_at,omitempty"`
	Name           string       `json:"name,omitempty"`
	Value          string       `json:"value,omitempty"`
	ServiceInstall odata.Object `json:"service_install,omitempty"`
}

type DeviceServVarResponse added in v0.4.0

type DeviceServVarResponse struct {
	ID             int64           `json:"id,omitempty"`
	CreatedAt      string          `json:"created_at,omitempty"`
	Name           string          `json:"name,omitempty"`
	Value          string          `json:"value,omitempty"`
	ServiceInstall ServiceInstalls `json:"service_install,omitempty"`
}

type DeviceServVarService added in v0.4.0

type DeviceServVarService service

func (*DeviceServVarService) Create added in v0.4.0

func (s *DeviceServVarService) Create(
	ctx context.Context,
	serviceInstallID int64,
	name string,
	value string,
) (*DeviceServVarCreateResponse, error)

Create creates an environment variable with name=value given a ServiceInstall ID (see ServiceInstallService).

func (*DeviceServVarService) DeleteWithName added in v0.4.0

func (s *DeviceServVarService) DeleteWithName(ctx context.Context, deviceID IDOrUUID, name string) error

DeleteWithName deletes a variable with the given name from the device with given ID/UUID. No error is returned if no variable with such name exists.

func (*DeviceServVarService) List added in v0.4.0

List lists all environment variables given a specific device ID/UUID.

func (*DeviceServVarService) Update added in v0.5.0

func (s *DeviceServVarService) Update(ctx context.Context, deviceID IDOrUUID, name, newValue string) error

Update a variable with the given name from the device with given ID/UUID to a new value. No error is returned if no variable with such name exists.

type DeviceService

type DeviceService service

DeviceService handles communication with the device related methods of the Balena Cloud API.

func (*DeviceService) Get

func (s *DeviceService) Get(ctx context.Context, deviceID IDOrUUID) (*DeviceResponse, error)

Get returns information on a single device given its ID or UUID. If the device does not exist, both the response and error are nil.

Example
package main

import (
	"context"

	"go.einride.tech/balena"
)

func main() {
	token := "mytoken"
	// We supply a nil http client to make use of http.DefaultClient
	client := balena.New(nil, token)

	// We want a device with a given uuid
	deviceUUID := "00a859f211585e9417a676e09434cc55"

	_, _ = client.Device.Get(context.Background(), balena.DeviceUUID(deviceUUID))
}
Output:

func (*DeviceService) GetWithQuery

func (s *DeviceService) GetWithQuery(ctx context.Context, query string) ([]*DeviceResponse, error)

GetWithQuery allows querying for devices using a custom open data protocol query. The query should be a valid, escaped OData query such as `%24filter=uuid+eq+'12333422'`

Forward slash in filter keys should not be escaped (So `device/uuid` should not be escaped).

Example
package main

import (
	"context"

	"go.einride.tech/balena"
)

func main() {
	token := "mytoken"
	// We supply a nil http client to make use of http.DefaultClient
	client := balena.New(nil, token)

	// We want a device with a given name
	query := "%24filter=device_name+eq+%27mydevice%27"

	_, _ = client.Device.GetWithQuery(context.Background(), query)
}
Output:

func (*DeviceService) List

func (s *DeviceService) List(ctx context.Context) ([]*DeviceResponse, error)

List returns a list of all devices.

func (*DeviceService) ListByApplication

func (s *DeviceService) ListByApplication(ctx context.Context, applicationID int64) ([]*DeviceResponse, error)

ListByApplication returns a list of all devices owned by the single application given its ID.

func (*DeviceService) MoveToApplication added in v0.9.0

func (s *DeviceService) MoveToApplication(ctx context.Context, deviceID IDOrUUID, applicationID int64) ([]byte, error)

MoveToApplication changes which application a device belongs to. If the update is successful, "OK" is returned and error is nil. If either the specified device or application doesn't exist, the returned error will contain "404".

func (*DeviceService) PinRelease

func (s *DeviceService) PinRelease(ctx context.Context, deviceID IDOrUUID, releaseID int64) ([]byte, error)

PinRelease pins a device to a specific release.

func (*DeviceService) TrackLatestRelease

func (s *DeviceService) TrackLatestRelease(ctx context.Context, deviceID IDOrUUID) ([]byte, error)

TrackLatestRelease sets a device to track the latest available release.

type DeviceTagResponse

type DeviceTagResponse struct {
	ID     int64        `json:"id,omitempty"`
	Device odata.Object `json:"device,omitempty"`
	TagKey string       `json:"tag_key,omitempty"`
	Value  string       `json:"value,omitempty"`
}

type DeviceTagService

type DeviceTagService service

DeviceTagService handles communication with the device tag related methods of the Balena Cloud API.

func (*DeviceTagService) Create

func (s *DeviceTagService) Create(
	ctx context.Context,
	deviceID IDOrUUID,
	key string,
	value string,
) (*DeviceTagResponse, error)

Create creates a device tag with key=value given a device ID/UUID. An error is returned if the key already exists.

func (*DeviceTagService) DeleteWithKey

func (s *DeviceTagService) DeleteWithKey(ctx context.Context, deviceID IDOrUUID, key string) error

DeleteWithKey deletes a device tag from a given device ID/UUID and key. No error is returned if the tag does not exist.

func (*DeviceTagService) GetWithKey

func (s *DeviceTagService) GetWithKey(ctx context.Context, deviceID IDOrUUID, key string) (*DeviceTagResponse, error)

GetWithKey retrieves a tag with the given key from the given device ID/UUID. If no key is found both the response and error returned are nil.

func (*DeviceTagService) GetWithQuery

func (s *DeviceTagService) GetWithQuery(ctx context.Context, query string) ([]*DeviceTagResponse, error)

GetWithQuery allows querying for device tags using a custom Open Data Protocol query. The query should be a valid, escaped OData query such as `%24filter=uuid+eq+%2712333422%27`.

Forward slash in filter keys should not be escaped (So `device/uuid` should not be escaped).

func (*DeviceTagService) List

func (s *DeviceTagService) List(ctx context.Context, deviceID IDOrUUID) ([]*DeviceTagResponse, error)

List lists all device tags for a given device ID/UUID.

func (*DeviceTagService) UpdateWithKey

func (s *DeviceTagService) UpdateWithKey(ctx context.Context, deviceID IDOrUUID, key, value string) error

UpdateWithKey updates the value of a device tag matching the given key and device ID/UUID. No error is returned if the key or device does not exist.

type DeviceTypeResponse added in v0.8.0

type DeviceTypeResponse struct {
	ID        uint64 `json:"id"`
	Name      string `json:"name"`
	Slug      string `json:"slug"`
	IsPrivate bool   `json:"is_private"`
	// Logo will only be populated when explicitly selected through a query parameter: `$select=logo`.
	IsOfCPUArchitecture odata.Object `json:"is_of__cpu_architecture"`
}

type DeviceTypeService added in v0.8.0

type DeviceTypeService service

DeviceTypeService handles communication with the device type related methods of the Balena Cloud API.

func (*DeviceTypeService) Get added in v0.8.0

Get returns information on a single device type given its ID. If the device type does not exist, both the response and error are nil.

func (*DeviceTypeService) GetWithQuery added in v0.8.0

func (s *DeviceTypeService) GetWithQuery(ctx context.Context, query string) ([]*DeviceTypeResponse, error)

GetWithQuery allows querying for device types using a custom open data protocol query. The query should be a valid, escaped OData query such as `%24filter=slug+eq+'jetson-tx2'`

Forward slash in filter keys should not be escaped (So `device_type/slug` should not be escaped).

type ErrorResponse

type ErrorResponse struct {
	// HTTP response that caused this error
	Response *http.Response
}

An ErrorResponse reports the error caused by an API request.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type IDOrUUID

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

IDOrUUID represents an ID which can be an Entity ID or an UUID.

func DeviceID

func DeviceID(id int64) IDOrUUID

func DeviceUUID

func DeviceUUID(uuid string) IDOrUUID

type Image added in v0.7.0

type Image struct {
	CreatedAt               string       `json:"created_at,omitempty"`
	ModifiedAt              string       `json:"modified_at,omitempty"`
	ID                      int64        `json:"id,omitempty"`
	StartTimestamp          string       `json:"start_timestamp,omitempty"`
	EndTimestamp            string       `json:"end_timestamp,omitempty"`
	Dockerfile              string       `json:"dockerfile,omitempty"`
	IsABuildOfService       odata.Object `json:"is_a_build_of__service,omitempty"`
	ImageSize               int64        `json:"image_size,omitempty"`
	IsStoredAtImageLocation string       `json:"is_stored_at__image_location,omitempty"`
	ProjectType             string       `json:"project_type,omitempty"`
	ErrorMessage            string       `json:"error_message,omitempty"`
	BuildLog                string       `json:"build_log,omitempty"`
	PushTimestamp           string       `json:"push_timestamp,omitempty"`
	Status                  string       `json:"status,omitempty"`
	ContentHash             string       `json:"content_hash,omitempty"`
	Contract                string       `json:"contract,omitempty"`
}

type ImageResponse added in v0.7.0

type ImageResponse struct {
	CreatedAt       string       `json:"created_at,omitempty"`
	ID              int64        `json:"id,omitempty"`
	IsPartOfRelease odata.Object `json:"is_part_of__release,omitempty"`
	Image           []*Image     `json:"image,omitempty"`
}

type InstallsService added in v0.5.0

type InstallsService struct {
	ID          int64        `json:"id"`
	ServiceName string       `json:"service_name"`
	Application odata.Object `json:"application"`
	CreatedAt   time.Time    `json:"created_at"`
}

type ReleaseResponse

type ReleaseResponse struct {
	ID                   int64           `json:"id,omitempty"`
	IsInvalidated        bool            `json:"is_invalidated,omitempty"`
	IsPassingTests       bool            `json:"is_passing_tests,omitempty"`
	ReleaseType          string          `json:"release_type,omitempty"`
	Contract             string          `json:"contract,omitempty"`
	CreatedAt            string          `json:"created_at,omitempty"`
	Commit               string          `json:"commit,omitempty"`
	Status               string          `json:"status,omitempty"`
	Source               string          `json:"source,omitempty"`
	StartTimestamp       string          `json:"start_timestamp,omitempty"`
	EndTimestamp         string          `json:"end_timestamp,omitempty"`
	UpdateTimestamp      string          `json:"update_timestamp,omitempty"`
	BuildLog             string          `json:"build_log,omitempty"`
	BelongsToApplication *odata.Object   `json:"belongs_to__application,omitempty"`
	CreatedByUser        *odata.Object   `json:"is_created_by__user,omitempty"`
	ReleaseVersion       interface{}     `json:"release_version,omitempty"`
	Composition          json.RawMessage `json:"composition,omitempty"`
	// ReleaseImage will only be populated when explicitly selected through a query parameter: `$select=release_image`.
	ReleaseImage []*ImageResponse `json:"release_image,omitempty"`
}

type ReleaseService

type ReleaseService service

ReleaseService handles communication with the release related methods of the Balena Cloud API.

func (*ReleaseService) Get

Get returns a release given a release ID. If no such release exists, both the response and error returned are nil.

func (*ReleaseService) GetWithQuery

func (s *ReleaseService) GetWithQuery(ctx context.Context, query string) ([]*ReleaseResponse, error)

GetWithQuery allows querying releases using a custom open data protocol query. The query should be a valid, escaped OData query such as `%24filter=uuid+eq+'12333422'`.

Forward slash in filter keys should not be escaped (So `device/uuid` should not be escaped).

func (*ReleaseService) List

func (s *ReleaseService) List(ctx context.Context) ([]*ReleaseResponse, error)

List lists all releases.

type ReleaseTagResponse

type ReleaseTagResponse struct {
	ID      int64        `json:"id,omitempty"`
	Release odata.Object `json:"release,omitempty"`
	TagKey  string       `json:"tag_key,omitempty"`
	Value   string       `json:"value,omitempty"`
}

type ReleaseTagService

type ReleaseTagService service

ReleaseTag handles communication with the release tag related methods of the Balena Cloud API.

func (*ReleaseTagService) GetWithQuery

func (s *ReleaseTagService) GetWithQuery(ctx context.Context, query string) ([]*ReleaseTagResponse, error)

GetWithQuery allows querying for release tags using a custom Open Data Protocol query. The query should be a valid, escaped OData query such as `%24filter=uuid+eq+%2712333422%27`.

Forward slash in filter keys should not be escaped (So `device/uuid` should not be escaped).

func (*ReleaseTagService) List

func (s *ReleaseTagService) List(ctx context.Context, releaseID int64) ([]*ReleaseTagResponse, error)

List lists all release tags for a given release ID.

func (*ReleaseTagService) ListByCommit

func (s *ReleaseTagService) ListByCommit(ctx context.Context, commit string) ([]*ReleaseTagResponse, error)

ListByCommit lists all release tags for a given release commit.

type ServiceInstallResponse added in v0.5.0

type ServiceInstallResponse struct {
	InstallsService []InstallsService `json:"installs__service"`
	ID              int64             `json:"id"`
	CreatedAt       time.Time         `json:"created_at"`
	Device          odata.Object      `json:"device"`
}

type ServiceInstallService added in v0.5.0

type ServiceInstallService service

func (*ServiceInstallService) List added in v0.5.0

List all service installs for a particular device.

type ServiceInstalls added in v0.5.0

type ServiceInstalls []*ServiceInstallResponse

func (ServiceInstalls) FindByServiceName added in v0.5.0

func (i ServiceInstalls) FindByServiceName(serviceName string) (InstallsService, bool)

FindByServiceName returns the InstallService that contains the given ServiceName. Returns true if found, else false.

func (ServiceInstalls) ServiceNames added in v0.5.0

func (i ServiceInstalls) ServiceNames() []string

ServiceNames returns a slice of all service names contained in the ServiceInstallResponse(s).

type ServiceState

type ServiceState struct {
	Status           string      `json:"status,omitempty"`
	ReleaseID        int64       `json:"releaseId,omitempty"`
	DownloadProgress interface{} `json:"download_progress,omitempty"`
}

type SupervisorV1Service

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

SupervisorV1Service handles communication with the supervisor v1 related methods of the Balena API.

func NewSupervisorV1

func NewSupervisorV1(httpClient *http.Client) (*SupervisorV1Service, error)

NewSupervisorV1 returns a new supervisor v1 API client. This is only meant to be used within balena where the application can talk to the supervisor directly. For talking to the supervisor through balene cloud use the balena API client through the client.SupervisorV1() method.

func (*SupervisorV1Service) Reboot

func (s *SupervisorV1Service) Reboot(ctx context.Context, force bool) error

type SupervisorV2Service

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

SupervisorService handles communication with the supervisor related methods of the Balena API.

func NewSupervisorV2

func NewSupervisorV2(httpClient *http.Client) (*SupervisorV2Service, error)

NewSupervisorV2 returns a new supervisor v2 API client. This is only meant to be used within balena where the application can talk to the supervisor directly. For talking to the supervisor through balene cloud use the balena API client through the client.SupervisorV2() method.

func (*SupervisorV2Service) ApplicationState

func (s *SupervisorV2Service) ApplicationState(ctx context.Context) (*SvAppStateResp, error)

func (*SupervisorV2Service) RestartServiceByName

func (s *SupervisorV2Service) RestartServiceByName(ctx context.Context, name string) error

func (*SupervisorV2Service) StopServiceByName

func (s *SupervisorV2Service) StopServiceByName(ctx context.Context, name string) error

type SvAppStateResp

type SvAppStateResp struct {
	// Local likely always contains only one single entry where the key is the
	// Application ID
	Local     map[string]ApplicationState `json:"local,omitempty"`
	Dependent interface{}                 `json:"dependent,omitempty"`
	Commit    string                      `json:"commit,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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