Documentation
¶
Overview ¶
Package "usecases" addresses system actions in given use cases such as configuration, registration, authentication, orchestration, ...
Index ¶
- Variables
- func ACServices(w http.ResponseWriter, r *http.Request, ua *components.UnitAsset, ...)
- func Configure(sys *components.System) ([]json.RawMessage, error)
- func ExtractDiscoveryForm(bodyBytes []byte) (sLoc forms.ServicePoint_v1, err error)
- func ExtractQuestForm(bodyBytes []byte) (rec forms.ServiceQuest_v1, err error)
- func FCServices(w http.ResponseWriter, r *http.Request, ua *components.UnitAsset, ...)
- func FillDiscoveredServices(dsList []forms.ServiceRecord_v1, version string) (f forms.Form, err error)
- func FillQuestForm(sys *components.System, res components.UnitAsset, sDef, protocol string) forms.ServiceQuest_v1
- func GetActivitiesCarbon(serv *components.Service) (payload []byte, err error)
- func GetActivitiesCost(serv *components.Service) (payload []byte, err error)
- func GetState(cer *components.Cervice, sys *components.System) (f forms.Form, err error)
- func GetStates(cer *components.Cervice, sys *components.System) (f []forms.Form, err []error)
- func HTTPProcessGetRequest(w http.ResponseWriter, r *http.Request, f forms.Form)
- func HTTPProcessSetRequest(w http.ResponseWriter, req *http.Request) (sig forms.SignalA_v1a, err error)
- func IsCamelCase(s string) bool
- func IsFirstLetterLower(s string) bool
- func IsFirstLetterUpper(s string) bool
- func IsPascalCase(s string) bool
- func KGraphing(w http.ResponseWriter, req *http.Request, sys *components.System)
- func Log(sys *components.System, lvl forms.MessageLevel, msg string, args ...any)
- func LogDebug(sys *components.System, msg string, args ...any)
- func LogError(sys *components.System, msg string, args ...any)
- func LogInfo(sys *components.System, msg string, args ...any)
- func LogWarn(sys *components.System, msg string, args ...any)
- func MakeServiceMap(services []components.Service) map[string]*components.Service
- func Pack(f forms.Form, contentType string) (data []byte, err error)
- func RegisterMessenger(resp http.ResponseWriter, req *http.Request, sys *components.System)
- func RegisterServices(sys *components.System)
- func RequestCertificate(sys *components.System)
- func ResHateoas(w http.ResponseWriter, req *http.Request, ua components.UnitAsset, ...)
- func ResourceHandler(sys *components.System, w http.ResponseWriter, r *http.Request)
- func SModeling(w http.ResponseWriter, req *http.Request, sys *components.System)
- func Search4MultipleServices(cer *components.Cervice, sys *components.System) (err error)
- func Search4Service(qf forms.ServiceQuest_v1, sys *components.System) (servLocation forms.ServicePoint_v1, err error)
- func Search4Services(cer *components.Cervice, sys *components.System) (err error)
- func ServQuestForms() []string
- func ServiceHateoas(w http.ResponseWriter, req *http.Request, serv components.Service, ...)
- func ServiceRegistrationFormsList() []string
- func SetActivitiesCarbon(serv *components.Service, bodyBytes []byte) (err error)
- func SetActivitiesCost(serv *components.Service, bodyBytes []byte) (err error)
- func SetState(cer *components.Cervice, sys *components.System, bodyBytes []byte) (f forms.Form, err error)
- func SetoutServers(sys *components.System) error
- func SysHateoas(w http.ResponseWriter, req *http.Request, sys components.System)
- func ToCamel(s string) string
- func ToPascal(s string) string
- func Unpack(data []byte, contentType string) (forms.Form, error)
- type ConfigurableAsset
Constants ¶
This section is empty.
Variables ¶
var ErrNewConfig = errors.New("new config file was created")
Functions ¶
func ACServices ¶
func ACServices(w http.ResponseWriter, r *http.Request, ua *components.UnitAsset, serviceP string)
ACServices handles the http request for the cost of a service
func Configure ¶
func Configure(sys *components.System) ([]json.RawMessage, error)
Configure reads the system configuration JSON file to get the deployment details. If the file is missing, it generates a default systemconfig.json file and shuts down the system
func ExtractDiscoveryForm ¶
func ExtractDiscoveryForm(bodyBytes []byte) (sLoc forms.ServicePoint_v1, err error)
ExtractDiscoveryForm is used by the Orchestrator and the authorized consumer system
func ExtractQuestForm ¶
func ExtractQuestForm(bodyBytes []byte) (rec forms.ServiceQuest_v1, err error)
ExtractQuestForm is used by the Service Registrar and Orchestrator when they receive a service query from a consumer system
func FCServices ¶
func FCServices(w http.ResponseWriter, r *http.Request, ua *components.UnitAsset, serviceP string)
FCServices handles the carbon footprint service requests
func FillDiscoveredServices ¶
func FillDiscoveredServices(dsList []forms.ServiceRecord_v1, version string) (f forms.Form, err error)
FillDiscoveredServices returns a json data byte array with a slice of matching services (e.g., Service Registrar)
func FillQuestForm ¶
func FillQuestForm(sys *components.System, res components.UnitAsset, sDef, protocol string) forms.ServiceQuest_v1
FillQuestForm described the sought service (e.g., RemoteSignal)
func GetActivitiesCarbon ¶
func GetActivitiesCarbon(serv *components.Service) (payload []byte, err error)
GetActivitiesCarbon retrieves the service carbon footprint
func GetActivitiesCost ¶
func GetActivitiesCost(serv *components.Service) (payload []byte, err error)
func GetState ¶
func GetState(cer *components.Cervice, sys *components.System) (f forms.Form, err error)
GetState request the current state of a unit asset (via the asset's service)
func GetStates ¶
func GetStates(cer *components.Cervice, sys *components.System) (f []forms.Form, err []error)
GetStates requests the current state of certain services of a unit asset depending on requested definition and/or details
func HTTPProcessGetRequest ¶
HTTPProcessSetRequest processes a Get request TODO: this function should really return an error too and behave like everyone else. And causing http.Errors is an ugly side effect.
func HTTPProcessSetRequest ¶
func HTTPProcessSetRequest(w http.ResponseWriter, req *http.Request) (sig forms.SignalA_v1a, err error)
HTTPProcessSetRequest processes a SET request
func IsCamelCase ¶
IsCamelCase returns true if the string starts with a lowercase letter.
func IsFirstLetterLower ¶
IsFirstLetterLower returns true if the first rune is lowercase.
func IsFirstLetterUpper ¶
IsFirstLetterUpper returns true if the first rune is uppercase.
func IsPascalCase ¶
IsPascalCase returns true if the string starts with an uppercase letter.
func KGraphing ¶
func KGraphing(w http.ResponseWriter, req *http.Request, sys *components.System)
function KGraphing provides a semantic model of a system running on a host and exposing the functionality of asset
func Log ¶
func Log(sys *components.System, lvl forms.MessageLevel, msg string, args ...any)
func MakeServiceMap ¶
func MakeServiceMap(services []components.Service) map[string]*components.Service
MakeServiceMap() creates a map of services from a slice of services The map is indexed by the service subpath
func Pack ¶
Pack serializes a form to a byte array for payload shipment with serialization format (sf) request
func RegisterMessenger ¶
func RegisterMessenger(resp http.ResponseWriter, req *http.Request, sys *components.System)
func RegisterServices ¶
func RegisterServices(sys *components.System)
RegisterServices keeps track of the leading Service Registrar and keeps all services registered
func RequestCertificate ¶
func RequestCertificate(sys *components.System)
RequestCertificate generates the system's public key and a certificate signing request to be sent to the CA
func ResHateoas ¶
func ResHateoas(w http.ResponseWriter, req *http.Request, ua components.UnitAsset, sys components.System)
ResHateoas provides information about the unit asset(s) and each service and is accessed via the system's web server
func ResourceHandler ¶
func ResourceHandler(sys *components.System, w http.ResponseWriter, r *http.Request)
ResourceHandler break up the request in parts and finds out what is requested as in http://192.168.1.4:8700/photographer/picam/files/image_20240325-211555.jpg where photographer is part[1], picam is part[2](with len==3), files is part[3] (with len==4)
func SModeling ¶
func SModeling(w http.ResponseWriter, req *http.Request, sys *components.System)
SModeling writes a SysML v2 textual model of the system to the HTTP response.
func Search4MultipleServices ¶
func Search4MultipleServices(cer *components.Cervice, sys *components.System) (err error)
func Search4Service ¶
func Search4Service(qf forms.ServiceQuest_v1, sys *components.System) (servLocation forms.ServicePoint_v1, err error)
Search4Service requests from the core systems the address of resources's services that meet the need
func Search4Services ¶
func Search4Services(cer *components.Cervice, sys *components.System) (err error)
Search4Services requests from the core systems the address of resources' services that meet the need
func ServQuestForms ¶
func ServQuestForms() []string
ServRegForms returns the list of forms that the service registration handles
func ServiceHateoas ¶
func ServiceHateoas(w http.ResponseWriter, req *http.Request, serv components.Service, sys components.System)
ServiceHateoas provides information about the service and is accessed via the system's web server
func ServiceRegistrationFormsList ¶
func ServiceRegistrationFormsList() []string
ServiceRegistrationFormsList returns the list of forms that the service registration handles
func SetActivitiesCarbon ¶
func SetActivitiesCarbon(serv *components.Service, bodyBytes []byte) (err error)
SetActivitiesCarbon sets the service carbon footprint from the request body
func SetActivitiesCost ¶
func SetActivitiesCost(serv *components.Service, bodyBytes []byte) (err error)
SetActivitiesCost updates the service cost
func SetState ¶
func SetState(cer *components.Cervice, sys *components.System, bodyBytes []byte) (f forms.Form, err error)
SetState puts a request to change the state of a unit asset (via the asset's service)
func SetoutServers ¶
func SetoutServers(sys *components.System) error
SetoutServers setups the http and https servers and starts them
func SysHateoas ¶
func SysHateoas(w http.ResponseWriter, req *http.Request, sys components.System)
System Documentation (based on HATEOAS) provides an initial documentation on the system's web server of with hyperlinks to the services for browsers HATEOAS is the acronym for Hypermedia as the Engine of Application State, using hyperlinks to navigate the API
Types ¶
type ConfigurableAsset ¶
type ConfigurableAsset struct {
Name string `json:"name"`
Mission string `json:"mission,omitempty"`
Details map[string][]string `json:"details"`
Services []components.Service `json:"services"`
Traits []json.RawMessage `json:"traits"`
}
configurableAsset is a struct that contains the name of the asset and its configurable details and services