Sugar Network/API: Difference between revisions
| Line 179: | Line 179: | ||
== Local access == | == Local access == | ||
If [[#Sugar_Network_resources|already mentioned]] resources are being provided from a network server, it is possible to get access to localhost resources served using the same | If [[#Sugar_Network_resources|already mentioned]] resources are being provided from a network server, it is possible to get access to localhost resources served using the same API by local process launched beforehand. The reasons to provide API from local host: | ||
* Provide assess to [[#Mountpoints|local]] Sugar Network data; | * Provide assess to [[#Mountpoints|original local]] Sugar Network data; | ||
* Transparent treating of [[# | * Transparent treating of [[#Cloned_resources|offline accessible]] Sugar Network remote data; | ||
* Be a unified (with network server API) [[wikipedia:Inter-process_communication|IPC]] method | * Be a unified (with network server API) [[wikipedia:Inter-process_communication|IPC]] method to Sugar Network client process. | ||
=== Mountpoints === | === Mountpoints === | ||
| Line 189: | Line 189: | ||
To differentiate what particular Sugar Network source is needed, requests might have {{Code|mountpoint}} argument which can be one of the following values: | To differentiate what particular Sugar Network source is needed, requests might have {{Code|mountpoint}} argument which can be one of the following values: | ||
* {{Code|/}} | * {{Code|/}}<br>Default mountpoint if argument was not specified; get access to remote resources, i.e., local API provider is a kind of proxy to a network server; before proxying client requests, local API provider authenticates users on a network server (for now, it is the only way to be authenticated on remote server); | ||
* {{Code|~}}<br>Local Sugar Network content located in {{Code|~/.sugar/''PROFILE''/network}} directory; | |||
* {{Code|~}} | * {{Code|''PATH''}}<br>Absolute path in local files system to a directory with Sugar Network content, e.g., it might be content on mounted disk, {{Code|/media/DISK}}. | ||
* {{Code|''PATH''}} | |||
There are the following mountpoints related commands: | There are the following mountpoints related commands: | ||
| Line 209: | Line 203: | ||
* {{Code|private}}, boolean flag; {{Code|True}} if the mountpoint is accessible only from localhost. | * {{Code|private}}, boolean flag; {{Code|True}} if the mountpoint is accessible only from localhost. | ||
=== | === Cloned resources === | ||
{{Code|/}} mountpoint resources might be cloned to local storage to be available in offline and out of | |||
Sugar Network. | |||
Cloning is available only for the following resources: | |||
* ''Context'' with ''type'' property equals to ''activity''<br>most recent activity ''Implementation'' will be placed to {{Code|~/Activities}} directory; | |||
* ''Context'' with ''type'' property equals to ''content''<br>most recent content ''Implementation'' will be stored in Sugar Journal; | |||
* ''Artifact'' resources<br>artifact will be stored in Sugar Journal. | |||
To track what data is cloned, there are read-only resource properties (for both {{Code|/}} and {{Code|~}} mountpoints) that make sense only for API provided from the local process: | |||
* {{Code|favorite}} ''bool''<br>resources bookmarked by local user; bookmarked activities will appear in Home View in Sugar Shell; | |||
* {{Code|clone}} ''int''<br>cloning status: {{Code|0}}, not cloned; {{Code|1}}, cloning is in progress; {{Code|2}} resource is cloned. | |||
To control cloning, there are API commands: | |||
'''PUT''' /''RESOURCE''/''GUID''?cmd='''favorite''' | |||
Change favorite status. {{Code|PUT}} content should be favorite status. | |||
'''PUT''' /''RESOURCE''/''GUID''?cmd='''clone'''[&force=FORCE] | |||
Change cloning status for the specified resource. {{Code|PUT}} content should be cloning status. If {{Code|FORCE}} is passed, cloning will happen even if local copy already exists. | |||
=== Launch activities === | === Launch activities === | ||
| Line 223: | Line 233: | ||
All activities, not only from {{Code|~}} mountpoint, can be launched as-is. | All activities, not only from {{Code|~}} mountpoint, can be launched as-is. | ||
'''GET''' /context/''GUID''?cmd='''launch'''[&args=''ARG''][&activity_id=''ACTIVITY_ID | '''GET''' /context/''GUID''?cmd='''launch'''[&args=''ARG''][&activity_id=''ACTIVITY_ID''][&object_id=''OBJECT_ID''][&uri=''URI''][&color=''COLOR''][&no_spawn=''NO_SPAWN''] | ||
* {{Code|ARG}}, command line argument to pass to launched activities, repeat {{Code|ARG}} for each argument; | * {{Code|ARG}}, command line argument to pass to launched activities, repeat {{Code|ARG}} for each argument; | ||
* {{Code|ACTIVITY_ID}}, internal activity id which will be auto set if omitted; | * {{Code|ACTIVITY_ID}}, internal activity id which will be auto set if omitted; | ||
* {{Code|OBJECT_ID}}, | * {{Code|OBJECT_ID}}, Journal object id to resume; | ||
* {{Code|URI}}, URL to resume if activity supports this functionality; | * {{Code|URI}}, URL to resume if activity supports this functionality; | ||
* {{Code|COLOR}}, coma separated pair of Sugar colors to assign to activity object; | * {{Code|COLOR}}, coma separated pair of Sugar colors to assign to activity object; | ||
| Line 234: | Line 243: | ||
{{Code|~}} mountpoint activities will be launched as-is from {{Code|~/Activities}} directory. For {{Code|/}} mountpoint, activities will be downloaded from the server and kept in cache directory. It is possible that during preparing for launching will be installed activity dependencies. | {{Code|~}} mountpoint activities will be launched as-is from {{Code|~/Activities}} directory. For {{Code|/}} mountpoint, activities will be downloaded from the server and kept in cache directory. It is possible that during preparing for launching will be installed activity dependencies. | ||
=== Access to the Journal === | === Access to the Journal === | ||