AgileApps Support Wiki Pre Release

Difference between revisions of "REST API:class Resource"

From AgileApps Support Wiki
imported>Aeric
imported>Aeric
Line 2: Line 2:


===Access Permissions===
===Access Permissions===
:* [[Develop Tools]] permission must be enabled for the tenant.
{{permissions|Manage Develop Features|use the <tt>class</tt> resource.}}
{{permissions|Manage Develop Features|use the <tt>class</tt> resource.}}



Revision as of 20:33, 15 February 2012

Access and update platform-extension classes.

Access Permissions

Lock-tiny.gif

Users that have the Manage Develop Features permission can use the class resource. 

Get a Class

Method
GET
URI
https://{domain}/networking/rest/class/{recordId}
Response
<syntaxhighlight lang="xml" enclose="div">

<platform>

   <class>
       <id>741be7784a314c54befb0724a0b97cc8</id>
       <name>Test4</name>
       public class Test4{ }
       <package_name>com.platform.namespace1.test.javatest</package_name>
       <is_global_class>false</is_global_class>
       <date_created>2010-11-12T13:14:15Z</date_created>
       <created_id type="USER"
         uri="https://{domain}/networking/rest/user/17331c7c353a4b72b956fcf2cd9c828f" 

displayValue="John Doe">17331c7c353a4b72b956fcf2cd9c828f</created_id>

       <date_modified>2010-11-12T13:14:15Z</date_modified>
       <modified_id type="USER"

uri="https://{domain}/networking/rest/user/17331c7c353a4b72b956fcf2cd9c828f" displayValue="John Doe">17331c7c353a4b72b956fcf2cd9c828f</modified_id>

   </class>
   <message>
       0
       <description>Success</description>
   </message>

</platform> </syntaxhighlight>

See also: REST API:Error Codes

Add a Class

Add a class to the test package in the dev namespace.

Method
POST
URI
https://{domain}/networking/rest/class
Request
<syntaxhighlight lang="xml" enclose="div">

<platform>

   <class>      
       <name>ClassTest</name>
       <is_global_class>false</is_global_class>
       <![CDATA[package com.platform.dev.test;
       public class ClassTest
       {
           public static void test(String[] args)
           {
              // ...        
           }          
       }]]>         
   </class>  

</platform> </syntaxhighlight>

Response
<syntaxhighlight lang="xml" enclose="div">

<platform>

   <message>
       0
       <description>Success</description>
       <id>18184374</id>      --ID of the added class
   </message>

</platform> </syntaxhighlight>

See also: REST API:Error Codes

Update a Class

Update a class in the test package, in the dev namespace.

Method
PUT
URI
https://{domain}/networking/rest/class/{recordId}
Request
<syntaxhighlight lang="xml" enclose="div">

<platform>

   <class>      
       <name>ClassTest</name>
        <is_global_class>false</is_global_class>
       <![CDATA[package com.platform.dev.test;
       public class ClassTest
       {
           public static void test(String[] args)
           {
               // ...             
           }          
       }]]>         
   </class>  

</platform> </syntaxhighlight>

Response
<syntaxhighlight lang="xml" enclose="div">

<platform>

   <message>
       0
       <description>Success</description>
       <id>18184374</id>
   </message>

</platform> </syntaxhighlight>

See also: REST API:Error Codes

Delete a Class

Method
DELETE
URI
https://{domain}/networking/rest/class/{recordId}
Response
<syntaxhighlight lang="xml" enclose="div">

<platform>

   <message>
       0
       <description>Success</description>
   </message>

</platform> </syntaxhighlight>

See also: REST API:Error Codes

Dynamic Search

Search for class records.

Method
GET
URI
https://{domain}/networking/rest/class?{query_parameters}
Sample Search
?fieldList=name,id & filter=name contains 'smith' & sortby='id'
(Field names are in the Fields section.)
Query Parameters
  • fieldList - A comma-separated list of field names to retrieve
  • The asterisk (*) wildcard specifies all fields
  • {fieldname} specifies an individual field (e.g. name)
(Use the REST API:field Resource to get a complete list of fields.)
  • For a Composite Object, specify {alias}.{fieldname} to select a related-record field, where the alias is defined in the Object Relationships.
  • For a Database View, specify {alias}.{fieldname}, where the object alias is defined in the Database View.
  • alias.* specifies all fields in the aliased object.
  • filter - Filtering criteria to filter the records
  • pageSize - Number of records to retrieve from the result set in order to make a "page".
  • page - Number of the logical page in a database result set. The first page is page "zero" (0).
Page zero is returned by default, so appending &pageSize=1 to your query returns a single record.
  • getTotalRecordCount returns the number of total records.
    Causes the following structure to be returned, where N is the total number of records:
<syntaxhighlight lang="xml" enclose="div">

<platform>

  <status>
  <packageDeploy>
  ...
  </packageDeploy>
  </status>
  <message>
     0
     <description>Success</description>
  </message>
  <totalRecordCount>N</totalRecordCount> 

</platform> </syntaxhighlight>

  • sortBy - Field name for primary sort
    Ex: &sortBy=name
  • sortOrder - Sort order of the primary field, either asc or desc (ascending or descending)
    Ex: &sortOrder=desc
  • sortBy2 - Field name for secondary sort
  • sortOrder2 - Sort order of the second field, either asc or desc (ascending or descending)
For more information, see: Specifying Query Parameters in REST APIs
Response
<syntaxhighlight lang="xml" enclose="div">

<platform>

   <class>
       <id>741be7784a314c54befb0724a0b97cc8</id>
       <name>Test4</name>
       public class Test4{}
       <is_global_class>false</is_global_class>
       <package_name>com.platform.namespace1.test.javatest</package_name>
       <date_created>2010-11-12T13:14:15Z</date_created>
       <created_id type="USER" uri="https://{domain}/networking/rest/user/17331c7c353a4b72b956fcf2cd9c828f" displayValue="John Doe">17331c7c353a4b72b956fcf2cd9c828f</created_id>
       <date_modified>2010-11-12T13:14:15Z</date_modified>
       <modified_id type="USER" uri="https://{domain}/networking/rest/user/17331c7c353a4b72b956fcf2cd9c828f" displayValue="John Doe">17331c7c353a4b72b956fcf2cd9c828f</modified_id>
   </class>
   <class>
       <id>9d5cff9f10494ce7b7b3df87999bb870</id>
       <name>Test</name>
       public class Test  {  }
       <is_global_class>false</is_global_class>
       <package_name>com.platform.namespace1.test.javatest</package_name>
       <date_created>2010-11-12T13:14:15Z</date_created>
       <created_id type="USER" uri="https://{domain}/networking/rest/user/17331c7c353a4b72b956fcf2cd9c828f" displayValue="John Doe">17331c7c353a4b72b956fcf2cd9c828f</created_id>
       <date_modified>2010-11-12T13:14:15Z</date_modified>
       <modified_id type="USER" uri="https://{domain}/networking/rest/user/17331c7c353a4b72b956fcf2cd9c828f" displayValue="John Doe">17331c7c353a4b72b956fcf2cd9c828f</modified_id>
   </class>
   <message>
       0
       <description>Success</description>
   </message>
   <recordCount>2</recordCount>

</platform> </syntaxhighlight>

See also: REST API:Error Codes

Fields

Name Type Attribute Required During Add Description Additional Information
id String Read Only Record Id
name String Read Only Checkmark.gif Class name Must consist of alphanumeric characters (a-z,A-Z,0-9) or underscores (_). Must start with an alphabetic character (a-z,A-Z) or underscore (_).
package_name String The fully qualified name of the package that contains the class. Not required. Supported only for backward compatibility.
Example: com.platform.{namespace}.{package}
is_global_class Boolean True if the class is a Global Class
code String Class definition
date_created Data Read Only
created_id Lookup Read Only
date_modified Date Read Only
modified_id Lookup Read Only