The document provides information about performing web requests on an Update Center to manage software components. It includes documentation on the available API endpoints for plugins, agents, servers and describes how to get the latest versions, view details, or make changes to entries. Sample code is also provided to demonstrate making requests using the RestClient gem to interact with the Update Center API.
1. Update Center Developer’s Guide
Overview
This document is intended to provide information about the various web requests
that can be performed on the Snap Creator Update Center. Each entry details the
format, parameters, and return values. Return values can be formatted in JSON,
XML, or HTML.
Sample codefrom Plugin Controller:
def show
@plugin = Plugin.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render xml: @plugin }
format.json { render json: @plugin }
end
end
Depending on which format the get request is sent, the Update Center will respond
with the same format. Plugins, Agents, and Servers are able to be created, updated,
shown, and deleted through web APIs using json or xml.
rest-client gem
Examples on how to use Rest Client:
These examples and more information are located at https://github.com/rest-
3. :file => File.new(path, 'rb')
}
})
Demo Server
As an example, we create a demo server that can be run by using rails server just like the
normal Update Center. It should be run on a separate port and assumes that update center is
running on localhost:3000
Update Center Web API Documentation
Overview
The formatting for these web requests will consist of basic text appended to the Update
Center url plus additional parameters. For example:
4. <update_center_url>/plugins/getlatestversion?name=CoolPlugin
Plugins
GET /plugins/getlatestversion
Parameters: name - an identifier name for the plugin to get the latest version of
Description: Returns the latest version of a type of plugin based on a given
name.
Return: name (string) - the identifying name
major (int) - major version number
minor (int)- minor version number
revision (int)- revision version number
build (int)- build version number
OS (int)- compatible operating system
GET /plugins/getplugins
Parameters: Id?Id - identifies the ID for the plugins to check compatibility with
Description: Returns true or false
Return: compatible (boolean)- true if plugins are compatible, otherwise false
GET /plugins/[id](.format)
Description: Returns the object information
Return: name (string) - the identifying name
major (int) - major version number
minor (int)- minor version number
revision (int)- revision version number
build (int)- build version number
created_at (string)- Timestamp of creation
updated_at (string)- Timestamp of last updated
5. OS (int)- compatible operating system
POST /plugins
Description: Returns the information of object created
Body: name, major, minor, revision, and build
Return: name (string) - the identifying name
major (int) - major version number
minor (int)- minor version number
revision (int)- revision version number
build (int)- build version number
created_at (string)- Timestamp of creation
updated_at (string)- Timestamp of last updated
OS (int)- compatible operating system
PUT /plugins/[id](.format)
Description: Returns the information of object updated
Body: name, major, minor, revision, and build
Return: name (string) - the identifying name
major (int) - major version number
minor (int)- minor version number
revision (int)- revision version number
build (int)- build version number
created_at (string)- Timestamp of creation
updated_at (string)- Timestamp of last updated
OS (int)- compatible operating system
DELETE /plugins/[id](.format)
Description: Returns the information of object deleted
Return: name (string) - the identifying name
major (int) - major version number
minor (int)- minor version number
revision (int)- revision version number
build (int)- build version number
created_at (string)- Timestamp of creation
updated_at (string)- Timestamp of last updated
OS (int)- compatible operating system
6. Agents
/getlatestversion
Parameters: name - an identifier name for the agent to get the latest version of
Description: Returns the latest version of a type of agent based on a given
name.
Return: name (string)- the identifying name
major (int)- major version number
minor (int)- minor version number
revision (int)- revision version number
build (int)- build version number
OS (int)- compatible operating system
/getlatestplugins
Parameters: name - an identifier name for the agent to get the latest compatible
plugins for
Description: Returns multiple lines for the latest versions of compatible plugins
for a type of agent based on a given name.
Return: name (string)- the identifying name
major (int)- major version number o
minor (int)- minor version number
revision (int)- revision version number
build (int)- build version number
OS (int)- compatible operating system
GET /agents/[id](.format)
Description: Returns the object information
Return: name (string) - the identifying name
major (int) - major version number
minor (int)- minor version number
revision (int)- revision version number
build (int)- build version number
created_at (string)- Timestamp of creation
updated_at (string)- Timestamp of last updated
OS (int)- compatible operating system
7. POST /agents
Description: Returns the information of object created
Body: name, major, minor, revision, and build
Return: name (string) - the identifying name
major (int) - major version number
minor (int)- minor version number
revision (int)- revision version number
build (int)- build version number
created_at (string)- Timestamp of creation
updated_at (string)- Timestamp of last updated
OS (int)- compatible operating system
PUT /agents/[id](.format)
Description: Returns the information of object updated
Body: name, major, minor, revision, and build
Return: name (string) - the identifying name
major (int) - major version number
minor (int)- minor version number
revision (int)- revision version number
build (int)- build version number
created_at (string)- Timestamp of creation
updated_at (string)- Timestamp of last updated
OS (int)- compatible operating system
DELETE /agents/[id](.format)
Description: Returns the information of object deleted
Return: name (string) - the identifying name
major (int) - major version number
minor (int)- minor version number
revision (int)- revision version number
build (int)- build version number
created_at (string)- Timestamp of creation
updated_at (string)- Timestamp of last updated
OS (int)- compatible operating system
8. Servers
/getlatestversion
Parameters: name - an identifier name for the server to get the latest version of
Description: Returns the latest version of a type of server based on a given
name.
Return: name (int)- the identifying name
major (int)- major version number
minor (int)- minor version number
revision (int)- revision version number
build (int)- build version number
OS (int)- compatible operating system
/getlatestagents
Parameters: name - an identifier name for the server to get the latest compatible
agents for
Description: Returns multiple lines for the latest versions of compatible agents
for a type of server based on a given name.
Return: Agent name (string)- the identifying name
Agent major (int)- major version number o
Agent minor (int)- minor version number
Agent revision (int)- revision version number
Agent build (int)- build version number
Agent OS (int)- compatible operating system
GET /servers/[id](.format)
Description: Returns the object information
Return: name (string) - the identifying name
major (int) - major version number
minor (int)- minor version number
revision (int)- revision version number
build (int)- build version number
created_at (string)- Timestamp of creation
updated_at (string)- Timestamp of last updated
OS (int)- compatible operating system
9. POST /servers
Description: Returns the information of object created
Body: name, major, minor, revision, and build
Return: name (string) - the identifying name
major (int) - major version number
minor (int)- minor version number
revision (int)- revision version number
build (int)- build version number
created_at (string)- Timestamp of creation
updated_at (string)- Timestamp of last updated
OS (int)- compatible operating system
PUT /servers/[id](.format)
Description: Returns the information of object updated
Body: name, major, minor, revision, and build
Return: name (string) - the identifying name
major (int) - major version number
minor (int)- minor version number
revision (int)- revision version number
build (int)- build version number
created_at (string)- Timestamp of creation
updated_at (string)- Timestamp of last updated
OS (int)- compatible operating system
DELETE /servers/[id](.format)
Description: Returns the information of object deleted
Return: name (string) - the identifying name
major (int) - major version number
minor (int)- minor version number
revision (int)- revision version number
build (int)- build version number
created_at (string)- Timestamp of creation
updated_at (string)- Timestamp of last updated
OS (int)- compatible operating system
10. Database Schema
Overview
The Update Center is a tool to help ensure compatibilities between various components
of the Snap Creator Framework, such as agents, plugins, and servers. This requires a
database to keep track of what versions of each component exist and what their
compatibilities are.
Users
This table keeps track of the users in the system. It uses names and emails to help
identify users and has encrypted password and remember tokens to support password-
secure sessions.
ID int
Name string
Email string
Password string (encrypted)
Remember token string (encrypted)
Timestamp datetime
Plugins/Agents/Servers
Plugins/Agents/Servers need to be conscious of their name and enough information to
know which version they are. They also need to know what operating system they are to
disambiguate between the same version for different OSes.
ID int
Name string
Major int
Minor int
11. Revision int
Build int
OS int
Timestamp datetime
Operating System index table
In order to support multiple operating systems dynamically, we decided to make a table
of all operating systems and use the ID associated with it to reference each operating
system in plugins, agents, and servers tables.
ID int
Name string
Architectural int
Agent-Server Compatibility
The compatibility matrices will simply show which agents are compatibility with which
servers, given as IDs into their respective tables. These tables are implemented as a
white list to show what is compatible with what. Similar tables are constructed for
Plugin-Agent and Plugin-Server.
Agent-ServerCompatibility
Agent ID int
Server ID int
12. Plugin-Agent Compatibility
Plugin ID int
Agent ID int
Plugin-Server Compatibility
Plugin ID int
Server ID int
Seeding Database Tables
Overview
Ruby on rails allows an admin to create static table entries that persist through
database resets. We thought it was important to have a set of foundational data
preloaded into the database tables.
Locating the Seed File
The seed file can be found in the project directory under dbseeds.rb
Editing the Seed File
Open the seed file in any text editor.
The first thing you may note is that line comments are generated by a '#'. Anything
follow the pound sign will be commented.
13. In order to make a new entry in a table, simply type the table name, followed by create,
and then enter a value for each column of the table.
Each column must be given a value.
Auto generated values like ID or Timestamp do not need to be given a value here.
Example
Here is an example of adding a row to the Plugins table that contains the columns:
name, major, minor, revision, build, and os
Plugin.create(name: "Cool Plugin", major: "1", minor:"2", revision: "3", build:"4", OS:"1")