natsutils

package
v0.0.0-...-99fe3a6 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// These are unversioned, existed pre-AsyncAPI specification
	AssertionGetSubject = "snapd.v2.assertions.get"
	SnapsGetSubject     = "snapd.v2.snaps.get"
	AppsPostSubject     = "snapd.v2.apps.post"

	// These are versioned and exist in the AsyncAPI specification
	AssertionGetSubjectv1  = "v1.snapd.v2.assertions.get"
	SnapsGetSubjectv1      = "v1.snapd.v2.snaps.get"
	SnapsSnapPostSubjectv1 = "v1.snapd.v2.snaps.*.post"
	AppsPostSubjectv1      = "v1.snapd.v2.apps.post"

	IotAgentMqttBrokerConnected              = "iot.agent.mqtt.connection.status"
	IotAgentMqttBrokerCurrentConnectedStatus = "iot.agent.mqtt.connection.status.current"
)
View Source
const (
	SnapdAPIUsername              = "snapd1"
	LegacySnapdAPIUsername        = "snapd"
	LegacySnapdAPIDefaultPassword = "accept solve carbon atmosphere"
	PublishDeny                   = "snapd.>"
	SubscribeDeny                 = "snapd.>"
	Publish                       = ">"
	Subscribe                     = ">"
)

Variables

View Source
var SnapdAPIDefaultPassword string

SnapdAPIDefaultPassword is a password that is provided by CI.

Functions

This section is empty.

Types

type AppsRequest

type AppsRequest struct {
	Action string   `json:"action"`
	Names  []string `json:"names"`
}

AppsRequest is the message to act on snaps or their services Reference: https://snapcraft.io/docs/snapd-api#heading--apps

type AppsResponse

type AppsResponse struct {
	ChangeID string  `json:"changeId"`
	Error    *string `json:"error,omitempty"`
}

AppsResponse is the response to an AppsRequest, contains the change ID or an error message

type AssertionsRequest

type AssertionsRequest struct {
	Type string `json:"type"`
}

AssertionsRequest is the request for an assertions stream based on the type specified. Reference: https://snapcraft.io/docs/snapd-api#heading--assertions for types

type AssertionsResponse

type AssertionsResponse struct {
	Stream string `json:"stream"`
}

AssertionsResponse is a response containing the assertions based on the type requested as specified in the AssertionsRequest. It will be a stream of assertions, each stream is potentially multiple assertions. The are separated by double new lines. Reference: https://snapcraft.io/docs/snapd-api#heading--assertions

type NATSServer

type NATSServer interface {
	PublishConnectionStatus(status bool) error
	SetLegacy(face legacy.HandlerIFace)
}

type NatsConnInterface

type NatsConnInterface interface {
	Publish(subject string, v interface{}) error
	Subscribe(subject string, cb natsgo.Handler) (*natsgo.Subscription, error)
}

type Server

type Server struct {
	LegacyInterface legacy.HandlerIFace
	// contains filtered or unexported fields
}

func New

func New(connected chan<- struct{}, conn NatsConnInterface) *Server

func (*Server) PublishConnectionStatus

func (s *Server) PublishConnectionStatus(status bool) error

func (*Server) Serve

func (s *Server) Serve(ctx context.Context) error

func (*Server) SetLegacy

func (s *Server) SetLegacy(face legacy.HandlerIFace)

func (*Server) String

func (s *Server) String() string

type SnapsResponse

type SnapsResponse struct {
	Snaps []client.Snap `json:"snaps"`
}

SnapsResponse is the response for getting a list of snaps. A request is made with the empty message. Reference: https://snapcraft.io/docs/snapd-api#heading--snaps

Jump to

Keyboard shortcuts

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