Documentation ¶
Overview ¶
Package rex provides a library for accessing the REX API. REX is a cloud-based operating system for building augmented reality applications.
The first thing you have to do is to register at https://rex.robotic-eyes.com for a free REX account. Once you activated your account, you can simply create an API access token with a `ClientId` and a `ClientSecret`.
This that information in your pocket, you can start building your REX-enabled application. An example application is called rx (https://github.com/breiting/rx) which is a command line tool accessing the REX system.
Index ¶
- Variables
- func CreateProject(e Executor, userID, name string, address *ProjectAddress, ...) error
- func DownloadFile(e Executor, link string) error
- func GetTotalNumberOfUsers(e Executor) (uint64, error)
- func UploadProjectFile(e Executor, projectID string, name string, fileName string, ...) error
- type Client
- type Executor
- type FileTransformation
- type Project
- type ProjectAddress
- type ProjectSimple
- type ProjectSimpleList
- type ProjectTransformation
- type Reference
- type User
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var (
RexBaseURL = "https://rex.robotic-eyes.com" // hostname for accessing REX cloud services
)
Global variables
Functions ¶
func CreateProject ¶
func CreateProject(e Executor, userID, name string, address *ProjectAddress, absoluteTransformation *ProjectTransformation) error
CreateProject creates a new project for the current user.
The name is used as project name
func DownloadFile ¶
DownloadFile downloads a given link (e.g. project file link).
The file name is anticipated by the provided information from the server using the content-disposition
func GetTotalNumberOfUsers ¶
GetTotalNumberOfUsers returns the number of registered users.
Requires admin permissions!
func UploadProjectFile ¶
func UploadProjectFile(e Executor, projectID string, name string, fileName string, transform *FileTransformation, r io.Reader) error
UploadProjectFile uploads a new project file.
The project is identified by the projectID (e.g. 1020). The file requires a name, which is displayed, but also a fileName which includes the suffix. The fileName is used for detecting the mimetype. The content of the file will be read from the io.Reader r.
Types ¶
type Client ¶
type Client struct { User *User // Stores the user information Token oauth2.Token // Contains the authentication token // contains filtered or unexported fields }
Client stores all user relevant information. The client holds the authentication token but also the user information such as username, email, and some more.
To create a new client you simply use the following code
client := NewClient(nil) err := client.Login("<ClientId>", "<ClientSecret>")
func NewClient ¶
NewClient creates a new client instance
Example ¶
package main import ( "log" "github.com/breiting/rex" ) func main() { clientID := "855889020987285jklj2345j" // generated by REX, this is only an example clientSecret := "Aasjdji09948jr4j3hllkj" // generated by REX, this is only an example client := rex.NewClient(nil) err := client.Login(clientID, clientSecret) if err != nil { log.Fatal(err) } _ = client }
Output: client for subsequent calls
func NewClientWithToken ¶
NewClientWithToken takes token and reads the user information. If the token is not valid anymore, an error will be returned, else a new client will be provided.
type Executor ¶
Executor is an interface which is used to perform the actual REX request. This interface should be used for any REX API call. The Client structure is implementing this interface and performs the actual call.
type FileTransformation ¶
type FileTransformation struct { Rotation struct { X float64 `json:"x"` Y float64 `json:"y"` Z float64 `json:"z"` } `json:"rotation"` Position struct { Type string `json:"type"` Coordinates []float64 `json:"coordinates"` } `json:"position"` Scale float64 `json:"scale"` }
FileTransformation is used for defining the relationship between the RexReference and the actual file.
type Project ¶
type Project struct { DateCreated string `json:"dateCreated"` CreatedBy string `json:"createdBy"` LastUpdated string `json:"lastUpdated"` UpdatedBy string `json:"updatedBy"` Name string `json:"name"` Owner string `json:"owner"` TagLine string `json:"tagLine"` Type string `json:"type"` Description string `json:"description"` Embedded struct { RootRexReference struct { RootReference bool `json:"rootReference"` Key string `json:"key"` Links struct { Self struct { Href string `json:"href"` Templated bool `json:"templated"` } `json:"self"` Project struct { Href string `json:"href"` Templated bool `json:"templated"` } `json:"project"` ParentReference struct { Href string `json:"href"` Templated bool `json:"templated"` } `json:"parentReference"` ChildReferences struct { Href string `json:"href"` Templated bool `json:"templated"` } `json:"childReferences"` ProjectFiles struct { Href string `json:"href"` Templated bool `json:"templated"` } `json:"projectFiles"` } `json:"_links"` } `json:"rootRexReference"` ProjectFiles []struct { LastModified string `json:"lastModified"` FileSize int `json:"fileSize"` Name string `json:"name"` Type string `json:"type"` Links struct { Self struct { Href string `json:"href"` Templated bool `json:"templated"` } `json:"self"` RexReference struct { Href string `json:"href"` Templated bool `json:"templated"` } `json:"rexReference"` Project struct { Href string `json:"href"` Templated bool `json:"templated"` } `json:"project"` FileDownload struct { Href string `json:"href"` } `json:"file.download"` } `json:"_links"` } `json:"projectFiles"` RexReferences []struct { RootReference bool `json:"rootReference"` Key string `json:"key"` Links struct { Self struct { Href string `json:"href"` Templated bool `json:"templated"` } `json:"self"` Project struct { Href string `json:"href"` Templated bool `json:"templated"` } `json:"project"` ParentReference struct { Href string `json:"href"` Templated bool `json:"templated"` } `json:"parentReference"` ChildReferences struct { Href string `json:"href"` Templated bool `json:"templated"` } `json:"childReferences"` ProjectFiles struct { Href string `json:"href"` Templated bool `json:"templated"` } `json:"projectFiles"` } `json:"_links"` } `json:"rexReferences"` } `json:"_embedded"` Links struct { Self struct { Href string `json:"href"` } `json:"self"` Project struct { Href string `json:"href"` Templated bool `json:"templated"` } `json:"project"` ThumbnailUpload struct { Href string `json:"href"` } `json:"thumbnail.upload"` ThumbnailDownload struct { Href string `json:"href"` } `json:"thumbnail.download"` ProjectFavorite struct { Href string `json:"href"` } `json:"projectFavorite"` RootRexReference struct { Href string `json:"href"` Templated bool `json:"templated"` } `json:"rootRexReference"` ProjectFiles struct { Href string `json:"href"` Templated bool `json:"templated"` } `json:"projectFiles"` ProjectAcls struct { Href string `json:"href"` Templated bool `json:"templated"` } `json:"projectAcls"` RexReferences struct { Href string `json:"href"` Templated bool `json:"templated"` } `json:"rexReferences"` } `json:"_links"` }
Project is the full structure of a REX project.
func GetProject ¶
GetProject retrieves the full project specified by the projectID (e.g. 1020)
type ProjectAddress ¶
type ProjectAddress struct { AddressLine1 string `json:"addressLine1"` AddressLine2 string `json:"addressLine2"` AddressLine3 string `json:"addressLine3"` AddressLine4 string `json:"addressLine4"` PostCode string `json:"postcode"` City string `json:"city"` Region string `json:"region"` Country string `json:"country"` }
ProjectAddress defines the address information for a project
type ProjectSimple ¶
type ProjectSimple struct { ID string // auto-generated after getting the list of projects Name string `json:"name"` Owner string `json:"owner"` Links struct { Self struct { Href string `json:"href"` } `json:"self"` } `json:"_links"` }
ProjectSimple is the basic structure representing a simple RexProject
type ProjectSimpleList ¶
type ProjectSimpleList struct { Embedded struct { Projects []ProjectSimple `json:"projects"` } `json:"_embedded"` }
ProjectSimpleList is a list ProjectSimple objects.
Mainly required for JSON encoding/decoding
func GetProjects ¶
func GetProjects(e Executor, userID string) (*ProjectSimpleList, error)
GetProjects gets all projects for the current user.
This call only fetches the project list, but not the content of every project. Please use GetProject for getting the detailed project information.
func (ProjectSimpleList) String ¶
func (p ProjectSimpleList) String() string
String nicely prints a list of projects.
type ProjectTransformation ¶
type ProjectTransformation struct { Rotation struct { X float64 `json:"x"` Y float64 `json:"y"` Z float64 `json:"z"` } `json:"rotation"` Position struct { Type string `json:"type"` Coordinates []float64 `json:"coordinates"` } `json:"position"` }
ProjectTransformation is used for the absoluteTransformation as well as for the relativeTransformation of a RexReference
type Reference ¶
type Reference struct { Key string `json:"key"` Project string `json:"project"` ParentReference string `json:"parentReference"` RootReference bool `json:"rootReference"` Address *ProjectAddress `json:"address"` AbsTransform *ProjectTransformation `json:"absoluteTransformation"` RelTransform *ProjectTransformation `json:"relativeTransformation"` FileTransform *FileTransformation `json:"fileTransformation"` }
Reference is a spatial anchor which can be attached to a project or a project file.
type User ¶
type User struct { UserID string `json:"userId"` Username string `json:"username,omitempty"` Email string `json:"email,omitempty"` FirstName string `json:"firstName,omitempty"` LastName string `json:"lastName,omitempty"` LastLogin string `json:"lastLogin,omitempty"` SelfLink string Roles []string `json:"roles,omitempty"` Links struct { User struct { Href string `json:"href"` } `json:"user"` } `json:"_links,omitempty"` }
User stores information of the current user.
The user can either contain the currentUser information, but also information from a user query. The SelfLink can be used to directly access the data, but is also often required for other operations (e.g. insert a project).
func GetCurrentUser ¶
GetCurrentUser gets the user details of the current user.
The current user is the one which has been identified by the authentication token. When a new client is created by NewClient, this function will already be called implicitly.
func GetUserByEmail ¶
GetUserByEmail retrieves the user information based on a given email address