You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 14 Next »

Resources

get
URL/api/v1/api.php?target=resource&action=get
DescriptionGet a resource or resources
ReturnsExamples:
SUCCESSFUL: {"success":1,"message":"Search successful","data":[{"id":"57","name":"2nd Email","slug":"6c-contact-email2","type":"field","parent_id":"1","category_id":null,"attr":[]}]}
ERROR: {"success":0,"message":"Search failed"}
Optional Parameters
NameTypeNotes/Example
nameSTRINGName of the resource. Example: 6Connect, Inc.
slugSTRINGThe unique URL friendly name of the resource. Example: 6connect-inc
typeSTRINGType of resource (eg. entry, field, category)

 

At most, one of the following:

NameTypeNotes/Example
idINTEGERGet the resource which has this ID
resource__inARRAYGet any resource which has any of these IDs
resource__not_inARRAYGet all the resources which do not have any of these IDs

 

At most, one of the following:

NameTypeNotes/Example
parent_idINTEGERGet the resources whose parent has this ID
parent__inARRAYGet any resource whose parents have any of these IDs
parent__not_inARRAYGet all resources whose parents do not have any of these IDs

 

At most, one of the following:

NameTypeNotes/Example
category_idINTEGERGet the resources of the category that has this ID
category__inARRAYGet the resources of the categories that have any of these IDs
category__not_inARRAYGet the resources of all the categories that do not have any of these IDs


You can set the order of the results by setting the STRING value of the parameter orderby to one of the following :

  • none
  • id
  • name (default)
  • slug
  • type
  • parent_id
  • date
  • resource__in (preserve order given in the resource__in array)

 

You can set the direction of the ordering of the results by setting the STRING value of the parameter order to one of the following :

  • ASC (default)
  • DESC

 

You can further limit the results based on attributes the resources may have:

NameTypeNotes/Example
attr_keySTRINGThe name of the attribute. Example: network-fqdn
attr_valueSTRINGThe value of any attribute, or if attr_key is specified, the value of the attribute defined in attr_key.
attr_compareSTRING

If both attr_key and attr_value are given, the results are by default compared based on the value given as attr_value being equal to the value stored in the database. You can optionally change this by setting the STRING value of attr_compare to one of the following:

  • = (default)
  • !=
  • ﹥=
  • ﹤=
  • LIKE
  • NOT LIKE
  • IN
  • NOT IN
  • BETWEEN
  • NOT BETWEEN
  • NOT EXISTS
Example URL/api/v1/api.php?target=resource&action=get&id=7
delete
URL/api/v1/api.php?target=resource&action=delete
DescriptionDelete an resource holder.
ReturnsExamples:
SUCCESSFUL: {"success":1,"message":"Resource deleted."}
ERROR: {"success":0,"message":"No resource found with ID: 57"}
Required Parameters
NameTypeNotes/Example
idINTEGERID of the resource
Example URL/api/v1/api.php?target=resource&action=delete&id=57
add
URL/api/v1/api.php?target=resource&action=add
DescriptionDelete an resource holder.
Returns

Examples:

/api/v1/api.php?target=resource&action=add&meta[name]=apitest&meta[type]=entry&meta[section]=firewall&fields[network-fqdn][]=www.example.com

SUCCESSFUL: {"success":1,"message":"Resource added","data":{"id":1077,"name":"apitest","slug":"apitest","type":"entry","parent_id":1,"category_id":"NULL","attr":{"_section":"70","network-fqdn":"www.example.com"},"section":{"id":"70","name":"Firewall","slug":"firewall","type":"section","parent_id":"1","category_id":null,"attr":{}}}}

/api/v1/api.php?target=resource&action=add&meta[name]=apitest&meta[type]=entry&fields[network-fqdn][]=www.example.com

ERROR:{"success":0,"message":"Entries must be assigned to a section"}

Required Parameters
NameTypeNotes/Example
meta[name]STRINGName of the resource
meta[type]STRINGType of resource (entry, section, field, ect)
Optional Parameters
NameTypeNotes/Example
parent_idINTEGERID of the parent resource
category_idINTEGERID of the category

Required Parameters

(meta[type] = entry)


One of the following:

NameTypeNotes/Example
meta[section_id]INTEGERID of the section that the entry will be assigned to
meta[section]STRINGSlug of the section that the entry will be assigned to

Optional Parameters

(meta[type] = entry)

NameTypeNotes/Example
fields[]ARRAY

Entry field values (for fields that have already been assigned to the section) can be populated when the entry is created.

The format is field[field-slug][field-instance]. If the field instance is left blank, it will simply be the next value in the instance array. For example:

fields[network-fqdn][]=example.com&fields[network-fqdn][]=test.com

translates to

fields = array(
     network-fqdn =﹥ array(
          0 =﹥ 'example.com',
          1 =﹥ 'test.com',
     )
)

A field can be added to a section multiple times. The field instance is used to keep track of which field occurrence we are referring. In this example, the network-fqdn field had been added twice to the section so we were able to store two values for it.

Required Parameters

(meta[type] = field)

NameTypeNotes/Example
meta[field_type]STRING

Type of field

  • text
  • textarea
  • radios
  • checkboxes
  • choicebox

Optional Parameters

(meta[type] = field)

NameTypeNotes/Example
meta[help_block]STRINGFields can have a line of text under them with instructions
meta[options]ARRAY

Fields of type radios, checkboxes, or choicebox can have multiple options. This could be multiple radio buttons or a choicebox (dropdown) with several options. For example:

meta[type]=field&meta[name]=Colors&meta[field_type]=choicebox&meta[options][]=Blue&meta[options][]=Green

Will create a choicebox with dropdown options of Blue and Green.

  • No labels