Source
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
class API {
/**
* API wrapper that all of the calls will go through.
*
* @var CApiWrapper
*/
private static $wrapper;
/**
* Factory for creating API services.
*
* @var CRegistryFactory
*/
private static $apiServiceFactory;
/**
* Sets the API wrapper.
*
* @param CApiWrapper|null $wrapper
*/
public static function setWrapper(?CApiWrapper $wrapper = null) {
self::$wrapper = $wrapper;
}
/**
* Set the service factory.
*
* @param CRegistryFactory $factory
*/
public static function setApiServiceFactory(CRegistryFactory $factory) {
self::$apiServiceFactory = $factory;
}
/**
* Returns the API wrapper.
*
* @return CApiWrapper|null
*/
public static function getWrapper() {
return self::$wrapper;
}
/**
* Returns an object that can be used for making API calls. If a wrapper is used, returns a CApiWrapper,
* otherwise - returns a CApiService object.
*