PHP Class APIRest, glpi

Inheritance: extends API
Show file Open project: glpi-project/glpi Class Usage Examples

Protected Properties

Property Type Description
$debug
$format
$parameters
$request_uri
$url_elements
$verb

Public Methods

Method Description
call ( ) : json parse url and http body to retrieve : - HTTP VERB (GET/POST/DELETE/PUT) - Resource : Rest endpoint - Identifier - and parameters
getTypeName ( $nb )
inlineDocumentation ( $file = "apirest.md" ) Display the APIRest Documentation in Html (parsed from markdown)
parseIncomingParams ( boolean $is_inline_doc = false ) Construct this->parameters from query string and http body
returnResponse ( $response, $httpcode = 200, $aditionnalheaders = [] ) Generic function to send a message and an http code to client

Private Methods

Method Description
getId ( ) : integer Retrieve in url_element the current id. If we have a multiple id (ex /Ticket/1/TicketFollwup/2), it always find the second
getItemtype ( $index, $recursive = true, $all_assets = false ) : boolean Retrieve and check itemtype from $this->url_elements

Method Details

call() public method

And send to method corresponding identified resource
public call ( ) : json
return json with response or error

getTypeName() public static method

See also: CommonGLPI::GetTypeName()
public static getTypeName ( $nb )

inlineDocumentation() public method

Display the APIRest Documentation in Html (parsed from markdown)
public inlineDocumentation ( $file = "apirest.md" )
$file string relative path of documentation file (default 'apirest.md')

parseIncomingParams() public method

Construct this->parameters from query string and http body
public parseIncomingParams ( boolean $is_inline_doc = false )
$is_inline_doc boolean Is the current request asks to display inline documentation ? This will remove the default behavior who set content-type to application/json

returnResponse() public method

Generic function to send a message and an http code to client
public returnResponse ( $response, $httpcode = 200, $aditionnalheaders = [] )
$response string message or array of data to send
$httpcode integer http code (default 200) (see: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes)
$aditionnalheaders array headers to send with http response (must be an array(key => value))

Property Details

$debug protected property

protected $debug

$format protected property

protected $format

$parameters protected property

protected $parameters

$request_uri protected property

protected $request_uri

$url_elements protected property

protected $url_elements

$verb protected property

protected $verb