gorexos

package module
v0.0.0-...-bde9636 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

README

Godoc Reference Build Status Go Report Card

goREX logo

GoREXos

The gorexos library implements functionality which is useful to communicate with the REXos. Please see more information about REXos here. The library can easily be integrated into your Go project. It can help you to get started with REX as a developer.

Installation

You can install Go by following these instructions. Please note that Go >= 1.14. is required!

First, clone the repository to your local development path, and let go download all dependencies:

go mod tidy

This should download all required packages.

Usage

Make sure that you just include the gorexos library in your application:

package main

import (
    "github.com/roboticeyes/gorexos"
)

Notice

The folder coreapi is accessing the API v2 directly and requires expert knowledge. We suggest to use the composite API.

References

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetInstanceCredentials

func GetInstanceCredentials(config *Config, instanceName, userName string) (string, string, error)

GetInstanceCredentials searches through the list of instances and returns the config where the defaultValue matches one of the instance with the given username (e.g. rex-production/user1) Returns clientID, clientSecret, error

func GetSelfLinkFromHal

func GetSelfLinkFromHal(json []byte) string

GetSelfLinkFromHal returns the stripped self link of a HAL resource. The input is the JSON response as string

func StripTemplateParameter

func StripTemplateParameter(templateURL string) string

StripTemplateParameter removes the trailing template parameters of an HATEOAS URL For example: "https://rex.robotic-eyes.com/rex-gateway/api/v2/rexReferences/1000/project{?projection}"

func UserRexOSDir

func UserRexOSDir() string

UserRexOSDir is the local directory which should contain the config.yml file

Types

type Config

type Config struct {
	APIVersion string     `yaml:"api-version"`
	Instances  []Instance `yaml:"instances"`
}

Config is the general config file

func ReadConfig

func ReadConfig(r io.Reader) *Config

ReadConfig reads the config from a reader

func (Config) String

func (c Config) String() string

type Instance

type Instance struct {
	Name  string `yaml:"name"`
	URL   string `yaml:"url"`
	Users []User `yaml:"users"`
}

Instance defines one environment

type RequestHandler

type RequestHandler interface {
	Authenticate(domain, id, secret string) Session
	AuthenticateWithSession(session Session) error
	Get(path string) (*resty.Response, error)
	GetFullyQualified(path string) (*resty.Response, error)
	Post(path string, body interface{}) (*resty.Response, error)
	Patch(path string, body interface{}) (*resty.Response, error)
	Delete(path string, body interface{}) (*resty.Response, error)
	PostMultipartFile(path string, fileName string, fileData io.Reader) (*resty.Response, error)
}

RequestHandler interface

func NewRequestHandler

func NewRequestHandler() RequestHandler

NewRequestHandler creates a new handler

type Session

type Session struct {
	Domain          string    `json:"domain"`
	AccessToken     string    `json:"access_token"`
	TokenType       string    `json:"token_type"`
	ExpiresIn       int       `json:"expires_in"`
	Scope           string    `json:"scope"`
	UserID          string    `json:"user_id"`
	UserName        string    `json:"user_name"`
	UserDisplayName string    `json:"user_display_name"`
	Jti             string    `json:"jti"`
	Expires         time.Time `json:"expires"`
}

Session stores the information which gets retrieved after successful authentication. It also contains the token.

func NewSession

func NewSession(domain string, body []byte) Session

NewSession creates a new session of the authentication response

func OpenSession

func OpenSession(r io.Reader) (Session, error)

OpenSession opens a session from a given file reader

func OpenStoredSession

func OpenStoredSession() (Session, error)

OpenStoredSession tries to open up a session file which got generated by a previous login operation

func (*Session) Valid

func (s *Session) Valid() bool

Valid checks if the session has already expired

func (*Session) Write

func (s *Session) Write(w io.Writer) error

type Transformation

type Transformation struct {
	Translation Vec3f `json:"translation"` // x/y/z
	Rotation    Vec4f `json:"rotation"`    // x/y/z/w
}

Transformation is used for any transformation in the REXos system. It uses quaternions for rotation and only one scale value. Please do not use this struct directly, but use the NewTransformation() instead!

func NewTransformation

func NewTransformation() Transformation

NewTransformation generates a valid transformation where W is set properly

type TransformationWithScale

type TransformationWithScale struct {
	Transformation
	Scale float32 `json:"scale" example:"0.5"` // one scale for all axis
}

TransformationWithScale takes a normal transformation and adds the scale value to it

func NewTransformationWithScale

func NewTransformationWithScale() TransformationWithScale

NewTransformationWithScale generates a valid transformation where scale and W is set properly

type User

type User struct {
	Name         string `yaml:"name"`
	ClientID     string `yaml:"client-id"`
	ClientSecret string `yaml:"client-secret"`
}

User defines a user login

type Vec3f

type Vec3f struct {
	X float32 `json:"x" example:"0.5"`
	Y float32 `json:"y" example:"0.5"`
	Z float32 `json:"z" example:"0.5"`
}

Vec3f defines a simple 3D vector

type Vec4f

type Vec4f struct {
	X float32 `json:"x" example:"0.1"`
	Y float32 `json:"y" example:"0.1"`
	Z float32 `json:"z" example:"0.1"`
	W float32 `json:"w" example:"1.1"`
}

Vec4f defines a simple 4D vector (used for rotation)

Directories

Path Synopsis
Package admin provides ...
Package admin provides ...
Package creation provides ...
Package creation provides ...
Package detection provides ...
Package detection provides ...

Jump to

Keyboard shortcuts

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