Documentation

timeman.networkrange.set

The method sets the office network IP range.

Parameters

ParameterExampleRequiredDescription
RANGES [{"ip_range":"10.0.0.0-10.255.255.255","name":"Office network 10.x.x.x"}] Yes IP range.

The IP range can contain a range of addresses, for example 10.0.0.0-10.255.255.255 or only one address 10.10.0.1

Call example

JavaScript

BX24.callMethod('timeman.networkrange.set', {
	ranges: '[{"ip_range":"10.0.0.0-10.255.255.255","name":"Office network 10.x.x.x"},{"ip_range":"172.16.0.0-172.31.255.255","name":"Office network 172.x.x.x"},{"ip_range":"192.168.0.0-192.168.255.255","name":"Office network 192.168.x.x"}]'
}, function(result){
	if(result.error())
	{
		console.error(result.error().ex);
	}
	else
	{
		var answer = result.data();
		if (answer.result)
		{
			console.log('range saved');
		}
		else
		{
			console.warn('An error occurred while saving, the following ranges are incorrect', answer.error_ranges);
		}
	}
});

PHP

$result = restCommand('timeman.networkrange.set', Array(
	'RANGES' => Array(
		Array("ip_range" => "10.0.0.0-10.255.255.255", "name" => "Office network 10.x.x.x"),
		Array("ip_range" => "172.16.0.0-172.31.255.255", "name" => "Office network 172.x.x.x"),
		Array("ip_range" => "192.168.0.0-192.168.255.255", "name" => "Office network 192.168.x.x")
	)
), $_REQUEST["auth"]);	

Response example

On success

{    
	"result": {
		result: true
	}
} 

When range error occurs

{    
	"result": {
		result: false,
		error_range: [
			{ip_range: "a10.0.0.0-10.255.255.255", name: "Office network 10.x.x.x"}
		]
	}
}

Keys description

  • result - result when saved.
  • error_range - array of ranges with errors found:
    • ip_range - network IP range.
    • name - range name.

Example of response in case of an error

{
    "error": "ACCESS_ERROR",
    "error_description": "You don't have access to user this method"
}
  • Key error - error code.
  • Key error_description - brief error description.

Possible error codes

CodeDescription
ACCESS_ERRORSpecified method is available only for administrators.
INVALID_FORMATIncorrect format is passed in the RANGE field.


© «Bitrix24», 2001-2024