Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from this space and version 5.3.2

...

add

URL/api/v1/api.php?target=resource&action=add
DescriptionAdd a resource.
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, ectetc.)
Optional Parameters
NameTypeNotes/Example
meta[parent_id]INTEGERID of the parent resource
meta[category_id]INTEGERID 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

would be written in JSON as

var fields = {
     "network-fqdn": [
          "example.com",
          "test.com"
     ]
}

Please note that the Field Slug might differ from the Field Name! To find the correct slug to use in adding resources with field values go the Section of the Resource you are adding, click 'Edit', then click the name of the Fields you will be populating. An Edit Field box will pop up which displays the Field's slug.

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.

meta[custom_id]STRINGA custom ID for the entry. In the past this has been called the Resource Holder ID or Customer ID. Most recently it was implemented as a text field with the slug "6c-resourceholder-id." Now it is a fundamental part the entry type resources.

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.

Required Parameters

(meta[type] = gadgets)

NameTypeNotes/Example
gadgets[x][uuid]INTEGER

x: The nth gadget being described in the call ('0' for the first gadget, '1' for the second, and so on).

uuid: User-generated ID of the gadget to be created.

gadgets[x][code]STRING

x: The nth gadget being described in the call ('0' for the first gadget, '1' for the second, and so on).

code: Slug of the gadget code to be created.

List of valid Gadget codes:

  • Contact Info: "_contact_info"
  • Contacts: "_contacts"
  • DHCP Server: "_dhcp_server"
  • DNS: "_dns"
  • Document Storage: "_document_storage"
  • IPAM: "_ipam"
  • Peer Groups: "_peering_peer_groups"
  • Peering Sessions: "_peering_sessions"
  • VRFs: "_peering_vrfs"
  • Resource Linkage: "_resource_linkage"
  • Resource View: "_resource_view"
  • Reverse API Console: "_reverse_api"
  • Tech Info: "_tech_info"

Example - Adding the IPAM Gadget to a Section:

api.php?target=resource&action=add&meta[type]=section&meta[name]=TestSection_1&meta[parent_id]=1&gadgets[0][uuid]=uuid-586dbd260d6ef&gadgets[0][code]=_ipam

update

URL/api/v1/api.php?target=resource&action=update
DescriptionUpdate a resource.
Returns

Examples:
SUCCESSFUL: {"success":1,"message":"Resource Updated","data":{"id":"1055","name":"87-child-1","slug":"87-child-1","type":"entry","parent_id":"87","category_id":"65","attr":{"_section":"70"},"section":{"id":"70","name":"Firewall","slug":"firewall","type":"section","parent_id":"1","category_id":null,"attr":{}}}}

ERROR: {"success":0,"message":"No resource found with ID: 1079"}

Required Parameters
NameTypeNotes/Example
meta[id]INTEGERID of resource
meta[type]STRINGType of resource (entry, section, field, ect)

Optional Parameters

(meta[type] = entry)

NameTypeNotes/Example
fields[]ARRAYSee "add" documentation

Optional Parameters

(meta[type] = section)

NameTypeNotes/Example
fields[]ARRAY

The fields value should be all the fields that are assigned to the section. Giving an empty array as the fields value will remove all fields from the section.

The format is:

fields[position][key]

The position value is the position that the field will appear in (0 is first). The position value must always be included. An example field format for an existing field could be:

fields[0][id]=2
fields[0][slug]=asset-serial-number
fields[0][help_block]=something
fields[0][new]=false

  • Either the id or the slug is required, not both.
  • When the "new" parameter is not included, FALSE is assumed

If you want to create a new field and assign it to the section, use a format like this:

fields[10][name]=TextArea
fields[10][field_type]=textarea
fields[10][new]=true

 

...