REST

From Dreamtsoft Wiki
Jump to: navigation, search

Overview

Dreamtsoft maintains a full REST interface for manipulating and/or searching for data within platform. This interface includes both bucket specific functions and a "metadata" API that allows you to get data about the platform's bucket and slot definitions

Bucket

The most common usage of the REST interface will be for searching, updating, inserting, deleting, exporting, and importing records to/from a specified bucket

Search

The search function allows you to search for records within a specified bucket, with an optional search query to narrow what is returned using the following syntax: https://username:password@sitename.dreamtsoft.com/io/bucket/search/bucketname?q=searchquery

Parameters

  • q=<searchQuery> -- search query string
  • s=<slotName> -- slot to sort by
  • d=<true/false> -- sort descending if true

Example

{
 "retcode": 1,
 "data": [
   {
     "active": "1",
     "created": "1430849922755",
     "group_id": "accounting",
     "group_number": "1000",
     "id": "3c9b7e60e7d84abaa44b112d1966f7e8",
     "name": "Accounting",
     "owner": "00000000000000000000000000000000",
     "updated": "1430849941392"
   },
   {
     "active": "1",
     "created": "1430849341196",
     "group_id": "admins",
     "group_number": "0",
     "id": "cf0093e70fe64d6491c38be42278a5a5",
     "name": "Administrators",
     "owner": "",
     "updated": "1430849341196"
   }
 ],
 "rows_returned": 2,
 "comments": "io for group"
}

Insert

The insert function allows you to add records to a specified bucket using the following syntax: https://username:password@sitename.dreamtsoft.com/io/bucket/insert/bucketname

{
   "data":  [
      { "first_name": "Jerrod", "last_name": "Bennett", "gender": "Male", "user_id": "jerrod.bennett" },
      { "first_name": "Bow", "last_name": "Ruggeri", "gender": "Male", "user_id": "bow.ruggeri" }
   ]
}

Update

The update function allows you to modify existing records in a specified bucket using the following syntax: https://username:password@sitename.dreamtsoft.com/io/bucket/update/bucketname. Note that you'll need to provide the "id" value in the http post body for each record that you want to update.

{
   "data":  [
      { "id": "c42e70f978124166845be7815f6d0f80", "gender": "Other"}
   ]
}

Delete

The delete function allows you to delete existing records in a specified bucket using the following syntax: https://username:password@sitename.dreamtsoft.com/io/bucket/delete/bucketname. Note that you'll need to provide the "id" value in the http post body for each record that you want to delete.

{
   "data":  [
      { "id": "c42e70f978124166845be7815f6d0f80"},
      { "id": "8a44b0fd2f3f4635b272421b00f0af31"}
   ]
}

Count

The count function allows you to count the records within a specified bucket, with an optional search query to narrow what is returned using the following syntax: https://username:password@sitename.dreamtsoft.com/io/bucket/count/bucketname?q=searchquery

{

 "retcode": 1,
 "data": [
   {
     "count": 2,
     "bucket": "group"
   }
 ],
 "comments": "io count for group"

}


Export

Import

  • https://username:password@sitename.dreamtsoft.com/io/bucket/import

{
   "bucket_data": {
      "user": {
         "be138b7ae82a49dd81b054a6b42a8e49": {
            "id": "be138b7ae82a49dd81b054a6b42a8e49",
            "first_name": "Jerrod",
            "last_name": "Bennett"
         }
      }
   }
}

Metadata

You can also use the REST interface to get metadata about the platform's buckets and slots

Get (without bucket)

The get function will return ALL metadata for the platform if no bucket is specified

  • https://username:password@sitename.dreamtsoft.com/io/metadata/get

Get (with bucket)

The get function will return the metadata for a single bucket

{
 "retcode": 1,
 "data": {
   "user": {
     "name": "",
     "bucket": "user",
     "slot": "",
     "label": "User",
     "labels": {
       "en": {
         "labelp": "Users",
         "label": "User"
       }
     },
     "type": "records",
     "id": "user",
     "bundle": "ds.base_user",
     "attributes": {
       "display": "name",
       "collection": "person"
     },
     "updated": "1441739039258",
     "system_updated": null,
     "dataservice": "ce5f6e0cbfdd4ca79867d1022eafb6ed",
     "slots": [
       {
         "name": "birthday",
         "bucket": "user",
         "slot": "birthday",
         "label": "Birthday",
         "labels": {
           "en": {
             "labelp": "Birthday",
             "label": "Birthday"
           }
         },
         "type": "date_time",
         "id": null,
         "bundle": "ds.base_user",
         "attributes": { },
         "updated": "1441739005038",
         "system_updated": null
       },
       {
         "name": "auth_type",
         "bucket": "user",
         "slot": "auth_type",
         "label": "Auth type",
         "labels": {
           "en": {
             "labelp": "Auth types",
             "label": "Auth type"
           }
         },
         "type": "choice",
         "id": null,
         "bundle": "ds.base_user",
         "attributes": {
           "choice_type": "dropdown",
           "choices": [
             {
               "label": "Local",
               "value": "local"
             },
             {
               "label": "LDAP",
               "value": "ldap"
             }
           ],
           "default": "local"
         },
         "updated": "1446228553523",
         "system_updated": "0"
       },
       {
         "name": "middle_name",
         "bucket": "user",
         "slot": "middle_name",
         "label": "Middle name",
         "labels": {
           "en": {
             "labelp": "Middle names",
             "label": "Middle name"
           }
         },
         "type": "string",
         "id": null,
         "bundle": "ds.base_user",
         "attributes": { },
         "updated": "1441739005064",
         "system_updated": null
       },
       {
         "name": "image",
         "bucket": "user",
         "slot": "image",
         "label": "Image",
         "labels": {
           "en": {
             "labelp": "Images",
             "label": "Image"
           }
         },
         "type": "image",
         "id": null,
         "bundle": "ds.base_user",
         "attributes": {
           "default_icon": "child"
         },
         "updated": "1456170351822",
         "system_updated": "0"
       },
       {
         "name": "suffix",
         "bucket": "user",
         "slot": "suffix",
         "label": "Suffix",
         "labels": {
           "en": {
             "labelp": "Suffixes",
             "label": "Suffix"
           }
         },
         "type": "choice",
         "id": null,
         "bundle": "ds.base_user",
         "attributes": {
           "choice_type": "dropdown",
           "choices": [
             {
               "label": "Mr",
               "value": "mr"
             },
             {
               "label": "Mrs",
               "value": "mrs"
             },
             {
               "label": "Ms",
               "value": "ms"
             },
             {
               "label": "Dr",
               "value": "dr"
             },
             {
               "label": "Prof",
               "value": "prof"
             }
           ]
         },
         "updated": "1441739005061",
         "system_updated": null
       },
       {
         "name": "password",
         "bucket": "user",
         "slot": "password",
         "label": "Password",
         "labels": {
           "en": {
             "labelp": "Password",
             "label": "Password"
           }
         },
         "type": "password",
         "id": null,
         "bundle": "ds.base_user",
         "attributes": { },
         "updated": "1441739039280",
         "system_updated": null
       },
       {
         "name": "first_name",
         "bucket": "user",
         "slot": "first_name",
         "label": "First name",
         "labels": {
           "en": {
             "labelp": "First names",
             "label": "First name"
           }
         },
         "type": "string",
         "id": null,
         "bundle": "ds.base_user",
         "attributes": { },
         "updated": "1441739005086",
         "system_updated": null
       },
       {
         "name": "name",
         "bucket": "user",
         "slot": "name",
         "label": "Name",
         "labels": {
           "en": {
             "labelp": "Name",
             "label": "Name"
           }
         },
         "type": "virtual_string",
         "id": null,
         "bundle": "ds.base_user",
         "attributes": {
           "virtual_type": "concat",
           "virtual_slots": [
             "first_name",
             "last_name"
           ],
           "virtual_delimiter": " "
         },
         "updated": "1441739005067",
         "system_updated": null
       },
       {
         "name": "last_name",
         "bucket": "user",
         "slot": "last_name",
         "label": "Last name",
         "labels": {
           "en": {
             "labelp": "Last names",
             "label": "Last name"
           }
         },
         "type": "string",
         "id": null,
         "bundle": "ds.base_user",
         "attributes": { },
         "updated": "1441739005053",
         "system_updated": null
       },
       {
         "name": "gender",
         "bucket": "user",
         "slot": "gender",
         "label": "Gender",
         "labels": {
           "en": {
             "labelp": "Gender",
             "label": "Gender"
           }
         },
         "type": "choice",
         "id": null,
         "bundle": "ds.base_user",
         "attributes": {
           "choice_type": "dropdown",
           "choices": [
             {
               "label": "Male",
               "value": "male"
             },
             {
               "label": "Female",
               "value": "female"
             },
             {
               "label": "Other",
               "value": "other"
             }
           ]
         },
         "updated": "1441739005045",
         "system_updated": null
       },
       {
         "name": "active",
         "bucket": "user",
         "slot": "active",
         "label": "Active",
         "labels": {
           "en": {
             "labelp": "Active",
             "label": "Active"
           }
         },
         "type": "boolean",
         "id": null,
         "bundle": "ds.base_user",
         "attributes": {
           "default": "true"
         },
         "updated": "1441739005057",
         "system_updated": null
       },
       {
         "name": "user_id",
         "bucket": "user",
         "slot": "user_id",
         "label": "User ID",
         "labels": {
           "en": {
             "labelp": "User ID",
             "label": "User ID"
           }
         },
         "type": "string",
         "id": null,
         "bundle": "ds.base_user",
         "attributes": { },
         "updated": "1441739039283",
         "system_updated": null
       },
       {
         "name": "user_dn",
         "bucket": "user",
         "slot": "user_dn",
         "label": "User DN",
         "labels": {
           "en": {
             "labelp": "User DNs",
             "label": "User DN"
           }
         },
         "type": "string",
         "id": null,
         "bundle": "ds.base_user",
         "attributes": { },
         "updated": "1446228901932",
         "system_updated": "0"
       },
       {
         "name": "ldap_directory",
         "bucket": "user",
         "slot": "ldap_directory",
         "label": "LDAP Directory",
         "labels": {
           "en": {
             "labelp": "LDAP Directories",
             "label": "LDAP Directory"
           }
         },
         "type": "choice",
         "id": null,
         "bundle": "ds.base_user",
         "attributes": {
           "choice_type": "typeahead",
           "bucket_name": "ldap_directory"
         },
         "updated": "1446228578132",
         "system_updated": "0"
       }
     ]
   }
 },
 "rows_returned": 1,
 "comments": "metadata"
}