repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
nezamy/view | system/Views/View.php | View.setCacheCompiler | private function setCacheCompiler($f, $layout=false)
{
$viewCompiler = new viewCompiler($this);
$viewCompiler->content = file_get_contents($f);
if($layout === true) {
return $viewCompiler->runCompiler([
'renderCompiler',
'startLayoutSectionCompiler',
'echoCompiler'
]);
} else {
return $viewCompiler->runCompiler(['startLayoutSectionCompiler'], true);
}
} | php | private function setCacheCompiler($f, $layout=false)
{
$viewCompiler = new viewCompiler($this);
$viewCompiler->content = file_get_contents($f);
if($layout === true) {
return $viewCompiler->runCompiler([
'renderCompiler',
'startLayoutSectionCompiler',
'echoCompiler'
]);
} else {
return $viewCompiler->runCompiler(['startLayoutSectionCompiler'], true);
}
} | [
"private",
"function",
"setCacheCompiler",
"(",
"$",
"f",
",",
"$",
"layout",
"=",
"false",
")",
"{",
"$",
"viewCompiler",
"=",
"new",
"viewCompiler",
"(",
"$",
"this",
")",
";",
"$",
"viewCompiler",
"->",
"content",
"=",
"file_get_contents",
"(",
"$",
"... | Set Cache Compiler
@param string $f
@param bool $layout
@return string | [
"Set",
"Cache",
"Compiler"
] | e19d3ad2c276a1e2588204a52fd0c3783c340440 | https://github.com/nezamy/view/blob/e19d3ad2c276a1e2588204a52fd0c3783c340440/system/Views/View.php#L175-L189 | train |
emartech/magento2-extension | dev/Magento/Identifier.php | Identifier.markSections | public function markSections(array $sectionsData, $sectionNames = null, $updateIds = false)
{
if (!$sectionNames) {
$sectionNames = array_keys($sectionsData);
}
$markId = $this->initMark($updateIds);
foreach ($sectionNames as $name) {
if ($updateIds || !array_key_exists(self::SECTION_KEY, $sectionsData[$name])) {
$sectionsData[$name][self::SECTION_KEY] = $markId;
}
if(!isset($sectionsData[$name])){
$sectionsData[$name] = [];
}
}
return $sectionsData;
} | php | public function markSections(array $sectionsData, $sectionNames = null, $updateIds = false)
{
if (!$sectionNames) {
$sectionNames = array_keys($sectionsData);
}
$markId = $this->initMark($updateIds);
foreach ($sectionNames as $name) {
if ($updateIds || !array_key_exists(self::SECTION_KEY, $sectionsData[$name])) {
$sectionsData[$name][self::SECTION_KEY] = $markId;
}
if(!isset($sectionsData[$name])){
$sectionsData[$name] = [];
}
}
return $sectionsData;
} | [
"public",
"function",
"markSections",
"(",
"array",
"$",
"sectionsData",
",",
"$",
"sectionNames",
"=",
"null",
",",
"$",
"updateIds",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"sectionNames",
")",
"{",
"$",
"sectionNames",
"=",
"array_keys",
"(",
"$"... | Mark sections with data id
@param array $sectionsData
@param null $sectionNames
@param bool $updateIds
@return array | [
"Mark",
"sections",
"with",
"data",
"id"
] | 6e3167fcc24894e3caa45cd2567cadd8d0005e17 | https://github.com/emartech/magento2-extension/blob/6e3167fcc24894e3caa45cd2567cadd8d0005e17/dev/Magento/Identifier.php#L74-L90 | train |
emartech/magento2-extension | Block/Snippets.php | Snippets.getTrackingData | public function getTrackingData()
{
return [
'product' => $this->getCurrentProduct(),
'category' => $this->getCategory(),
'store' => $this->getStoreData(),
'search' => $this->getSearchData(),
'exchangeRate' => $this->getExchangeRate(),
'slug' => $this->getStoreSlug(),
];
} | php | public function getTrackingData()
{
return [
'product' => $this->getCurrentProduct(),
'category' => $this->getCategory(),
'store' => $this->getStoreData(),
'search' => $this->getSearchData(),
'exchangeRate' => $this->getExchangeRate(),
'slug' => $this->getStoreSlug(),
];
} | [
"public",
"function",
"getTrackingData",
"(",
")",
"{",
"return",
"[",
"'product'",
"=>",
"$",
"this",
"->",
"getCurrentProduct",
"(",
")",
",",
"'category'",
"=>",
"$",
"this",
"->",
"getCategory",
"(",
")",
",",
"'store'",
"=>",
"$",
"this",
"->",
"get... | Get Tracking Data
@return mixed
@throws \Exception | [
"Get",
"Tracking",
"Data"
] | 6e3167fcc24894e3caa45cd2567cadd8d0005e17 | https://github.com/emartech/magento2-extension/blob/6e3167fcc24894e3caa45cd2567cadd8d0005e17/Block/Snippets.php#L117-L127 | train |
emartech/magento2-extension | Block/Snippets.php | Snippets.getExchangeRate | public function getExchangeRate()
{
try {
$currentCurrency = $this->storeManager->getStore()->getCurrentCurrency()->getCode();
$baseCurrency = $this->storeManager->getStore()->getBaseCurrency()->getCode();
return (float)$this->currencyFactory->create()->load($baseCurrency)->getAnyRate($currentCurrency);
} catch (\Exception $e) {
throw $e;
}
} | php | public function getExchangeRate()
{
try {
$currentCurrency = $this->storeManager->getStore()->getCurrentCurrency()->getCode();
$baseCurrency = $this->storeManager->getStore()->getBaseCurrency()->getCode();
return (float)$this->currencyFactory->create()->load($baseCurrency)->getAnyRate($currentCurrency);
} catch (\Exception $e) {
throw $e;
}
} | [
"public",
"function",
"getExchangeRate",
"(",
")",
"{",
"try",
"{",
"$",
"currentCurrency",
"=",
"$",
"this",
"->",
"storeManager",
"->",
"getStore",
"(",
")",
"->",
"getCurrentCurrency",
"(",
")",
"->",
"getCode",
"(",
")",
";",
"$",
"baseCurrency",
"=",
... | Get Exchange Rate
@return bool|float
@throws \Exception | [
"Get",
"Exchange",
"Rate"
] | 6e3167fcc24894e3caa45cd2567cadd8d0005e17 | https://github.com/emartech/magento2-extension/blob/6e3167fcc24894e3caa45cd2567cadd8d0005e17/Block/Snippets.php#L152-L161 | train |
emartech/magento2-extension | Block/Snippets.php | Snippets.getCurrentProduct | public function getCurrentProduct()
{
try {
$product = $this->coreRegistry->registry('current_product');
if ($product instanceof Product) {
return [
'sku' => $product->getSku(),
'id' => $product->getId(),
];
}
} catch (\Exception $e) {
throw $e;
}
return false;
} | php | public function getCurrentProduct()
{
try {
$product = $this->coreRegistry->registry('current_product');
if ($product instanceof Product) {
return [
'sku' => $product->getSku(),
'id' => $product->getId(),
];
}
} catch (\Exception $e) {
throw $e;
}
return false;
} | [
"public",
"function",
"getCurrentProduct",
"(",
")",
"{",
"try",
"{",
"$",
"product",
"=",
"$",
"this",
"->",
"coreRegistry",
"->",
"registry",
"(",
"'current_product'",
")",
";",
"if",
"(",
"$",
"product",
"instanceof",
"Product",
")",
"{",
"return",
"[",... | Get Current Product
@return bool|mixed
@throws \Exception | [
"Get",
"Current",
"Product"
] | 6e3167fcc24894e3caa45cd2567cadd8d0005e17 | https://github.com/emartech/magento2-extension/blob/6e3167fcc24894e3caa45cd2567cadd8d0005e17/Block/Snippets.php#L186-L201 | train |
emartech/magento2-extension | Block/Snippets.php | Snippets.getSearchData | public function getSearchData()
{
try {
$q = $this->_request->getParam('q');
if ($q != '') {
return [
'term' => $q,
];
}
} catch (\Exception $e) {
throw $e;
}
return false;
} | php | public function getSearchData()
{
try {
$q = $this->_request->getParam('q');
if ($q != '') {
return [
'term' => $q,
];
}
} catch (\Exception $e) {
throw $e;
}
return false;
} | [
"public",
"function",
"getSearchData",
"(",
")",
"{",
"try",
"{",
"$",
"q",
"=",
"$",
"this",
"->",
"_request",
"->",
"getParam",
"(",
"'q'",
")",
";",
"if",
"(",
"$",
"q",
"!=",
"''",
")",
"{",
"return",
"[",
"'term'",
"=>",
"$",
"q",
",",
"]"... | Get Search Data
@return bool|mixed
@throws \Exception | [
"Get",
"Search",
"Data"
] | 6e3167fcc24894e3caa45cd2567cadd8d0005e17 | https://github.com/emartech/magento2-extension/blob/6e3167fcc24894e3caa45cd2567cadd8d0005e17/Block/Snippets.php#L209-L222 | train |
bheisig/i-doit-api-client-php | src/CMDBObjectTypeCategories.php | CMDBObjectTypeCategories.batchReadByID | public function batchReadByID(array $objectTypeIDs) {
$requests = [];
foreach ($objectTypeIDs as $objectTypeID) {
$requests[] = [
'method' => 'cmdb.object_type_categories.read',
'params' => [
'type' => $objectTypeID
]
];
}
return $this->api->batchRequest($requests);
} | php | public function batchReadByID(array $objectTypeIDs) {
$requests = [];
foreach ($objectTypeIDs as $objectTypeID) {
$requests[] = [
'method' => 'cmdb.object_type_categories.read',
'params' => [
'type' => $objectTypeID
]
];
}
return $this->api->batchRequest($requests);
} | [
"public",
"function",
"batchReadByID",
"(",
"array",
"$",
"objectTypeIDs",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objectTypeIDs",
"as",
"$",
"objectTypeID",
")",
"{",
"$",
"requests",
"[",
"]",
"=",
"[",
"'method'",
"=>",
... | Fetches assigned categories for one or more objects types at once identified by their identifiers
@param array $objectTypeIDs List of object types identifiers as integers
@return array
@throws Exception on error | [
"Fetches",
"assigned",
"categories",
"for",
"one",
"or",
"more",
"objects",
"types",
"at",
"once",
"identified",
"by",
"their",
"identifiers"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObjectTypeCategories.php#L79-L92 | train |
bheisig/i-doit-api-client-php | src/CMDBObjectTypeCategories.php | CMDBObjectTypeCategories.batchReadByConst | public function batchReadByConst(array $objectTypeConsts) {
$requests = [];
foreach ($objectTypeConsts as $objectTypeConst) {
$requests[] = [
'method' => 'cmdb.object_type_categories.read',
'params' => [
'type' => $objectTypeConst
]
];
}
return $this->api->batchRequest($requests);
} | php | public function batchReadByConst(array $objectTypeConsts) {
$requests = [];
foreach ($objectTypeConsts as $objectTypeConst) {
$requests[] = [
'method' => 'cmdb.object_type_categories.read',
'params' => [
'type' => $objectTypeConst
]
];
}
return $this->api->batchRequest($requests);
} | [
"public",
"function",
"batchReadByConst",
"(",
"array",
"$",
"objectTypeConsts",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objectTypeConsts",
"as",
"$",
"objectTypeConst",
")",
"{",
"$",
"requests",
"[",
"]",
"=",
"[",
"'method'"... | Fetches assigned categories for one or more objects types at once identified by their constants
@param array $objectTypeConsts List of object types constants as strings
@return array Result
@throws Exception on error | [
"Fetches",
"assigned",
"categories",
"for",
"one",
"or",
"more",
"objects",
"types",
"at",
"once",
"identified",
"by",
"their",
"constants"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObjectTypeCategories.php#L103-L116 | train |
bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.save | public function save($objectID, $categoryConstant, array $attributes, $entryID = null) {
$params = [
'object' => $objectID,
'data' => $attributes,
'category' => $categoryConstant
];
if (isset($entryID)) {
$params['entry'] = $entryID;
}
$result = $this->api->request(
'cmdb.category.save',
$params
);
if (!array_key_exists('entry', $result) ||
!is_int($result['entry']) ||
!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $result['entry'];
} | php | public function save($objectID, $categoryConstant, array $attributes, $entryID = null) {
$params = [
'object' => $objectID,
'data' => $attributes,
'category' => $categoryConstant
];
if (isset($entryID)) {
$params['entry'] = $entryID;
}
$result = $this->api->request(
'cmdb.category.save',
$params
);
if (!array_key_exists('entry', $result) ||
!is_int($result['entry']) ||
!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $result['entry'];
} | [
"public",
"function",
"save",
"(",
"$",
"objectID",
",",
"$",
"categoryConstant",
",",
"array",
"$",
"attributes",
",",
"$",
"entryID",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"[",
"'object'",
"=>",
"$",
"objectID",
",",
"'data'",
"=>",
"$",
"attrib... | Create new or update existing category entry for a specific object
Suitable for single- and multi-value categories
@param int $objectID Object identifier
@param string $categoryConstant Category constant
@param array $attributes Attributes as key-value pairs
@param int $entryID Entry identifier (only needed for multi-valued categories)
@return int Entry identifier
@throws Exception on error | [
"Create",
"new",
"or",
"update",
"existing",
"category",
"entry",
"for",
"a",
"specific",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L49-L77 | train |
bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.create | public function create($objectID, $categoryConst, array $attributes) {
$params = [
'objID' => $objectID,
'data' => $attributes,
'category' => $categoryConst
];
$result = $this->api->request(
'cmdb.category.create',
$params
);
if (!array_key_exists('id', $result) ||
!is_numeric($result['id']) ||
!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return (int) $result['id'];
} | php | public function create($objectID, $categoryConst, array $attributes) {
$params = [
'objID' => $objectID,
'data' => $attributes,
'category' => $categoryConst
];
$result = $this->api->request(
'cmdb.category.create',
$params
);
if (!array_key_exists('id', $result) ||
!is_numeric($result['id']) ||
!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return (int) $result['id'];
} | [
"public",
"function",
"create",
"(",
"$",
"objectID",
",",
"$",
"categoryConst",
",",
"array",
"$",
"attributes",
")",
"{",
"$",
"params",
"=",
"[",
"'objID'",
"=>",
"$",
"objectID",
",",
"'data'",
"=>",
"$",
"attributes",
",",
"'category'",
"=>",
"$",
... | Create new category entry for a specific object
@param int $objectID Object identifier
@param string $categoryConst Category constant
@param array $attributes Attributes as key-value pairs
@return int Entry identifier
@throws Exception on error | [
"Create",
"new",
"category",
"entry",
"for",
"a",
"specific",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L90-L114 | train |
bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.update | public function update($objectID, $categoryConst, array $attributes, $entryID = null) {
if (isset($entryID)) {
$attributes['category_id'] = $entryID;
}
$result = $this->api->request(
'cmdb.category.update',
[
'objID' => $objectID,
'category' => $categoryConst,
'data' => $attributes
]
);
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $this;
} | php | public function update($objectID, $categoryConst, array $attributes, $entryID = null) {
if (isset($entryID)) {
$attributes['category_id'] = $entryID;
}
$result = $this->api->request(
'cmdb.category.update',
[
'objID' => $objectID,
'category' => $categoryConst,
'data' => $attributes
]
);
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $this;
} | [
"public",
"function",
"update",
"(",
"$",
"objectID",
",",
"$",
"categoryConst",
",",
"array",
"$",
"attributes",
",",
"$",
"entryID",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"entryID",
")",
")",
"{",
"$",
"attributes",
"[",
"'category_id'... | Update category entry for a specific object
@param int $objectID Object identifier
@param string $categoryConst Category constant
@param array $attributes Attributes as key-value pairs
@param int $entryID Entry identifier (only needed for multi-value categories)
@return self Returns itself
@throws Exception on error | [
"Update",
"category",
"entry",
"for",
"a",
"specific",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L220-L244 | train |
bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.archive | public function archive($objectID, $categoryConst, $entryID) {
$this->api->request(
'cmdb.category.archive',
[
'object' => $objectID,
'category' => $categoryConst,
'entry' => $entryID
]
);
return $this;
} | php | public function archive($objectID, $categoryConst, $entryID) {
$this->api->request(
'cmdb.category.archive',
[
'object' => $objectID,
'category' => $categoryConst,
'entry' => $entryID
]
);
return $this;
} | [
"public",
"function",
"archive",
"(",
"$",
"objectID",
",",
"$",
"categoryConst",
",",
"$",
"entryID",
")",
"{",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'cmdb.category.archive'",
",",
"[",
"'object'",
"=>",
"$",
"objectID",
",",
"'category'",
"=>"... | Archive entry in a multi-value category for a specific object
@param int $objectID Object identifier
@param string $categoryConst Category constant
@param int $entryID Entry identifier
@return self Returns itself
@throws Exception on error | [
"Archive",
"entry",
"in",
"a",
"multi",
"-",
"value",
"category",
"for",
"a",
"specific",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L257-L268 | train |
bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.delete | public function delete($objectID, $categoryConst, $entryID) {
$this->api->request(
'cmdb.category.delete',
[
'object' => $objectID,
'category' => $categoryConst,
'entry' => $entryID
]
);
return $this;
} | php | public function delete($objectID, $categoryConst, $entryID) {
$this->api->request(
'cmdb.category.delete',
[
'object' => $objectID,
'category' => $categoryConst,
'entry' => $entryID
]
);
return $this;
} | [
"public",
"function",
"delete",
"(",
"$",
"objectID",
",",
"$",
"categoryConst",
",",
"$",
"entryID",
")",
"{",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'cmdb.category.delete'",
",",
"[",
"'object'",
"=>",
"$",
"objectID",
",",
"'category'",
"=>",
... | Marks entry in a multi-value category for a specific object as deleted
@param int $objectID Object identifier
@param string $categoryConst Category constant
@param int $entryID Entry identifier
@return self Returns itself
@throws Exception on error | [
"Marks",
"entry",
"in",
"a",
"multi",
"-",
"value",
"category",
"for",
"a",
"specific",
"object",
"as",
"deleted"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L281-L292 | train |
bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.purge | public function purge($objectID, $categoryConst, $entryID = null) {
$params = [
'object' => $objectID,
'category' => $categoryConst
];
if (isset($entryID)) {
$params['entry'] = $entryID;
}
$this->api->request(
'cmdb.category.purge',
$params
);
return $this;
} | php | public function purge($objectID, $categoryConst, $entryID = null) {
$params = [
'object' => $objectID,
'category' => $categoryConst
];
if (isset($entryID)) {
$params['entry'] = $entryID;
}
$this->api->request(
'cmdb.category.purge',
$params
);
return $this;
} | [
"public",
"function",
"purge",
"(",
"$",
"objectID",
",",
"$",
"categoryConst",
",",
"$",
"entryID",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"[",
"'object'",
"=>",
"$",
"objectID",
",",
"'category'",
"=>",
"$",
"categoryConst",
"]",
";",
"if",
"(",
... | Purge entry in a single- or multi-value category for a specific object
@param int $objectID Object identifier
@param string $categoryConst Category constant
@param int $entryID Entry identifier (only needed for multi-value categories)
@return self Returns itself
@throws Exception on error | [
"Purge",
"entry",
"in",
"a",
"single",
"-",
"or",
"multi",
"-",
"value",
"category",
"for",
"a",
"specific",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L305-L321 | train |
bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.recycle | public function recycle($objectID, $categoryConst, $entryID) {
$this->api->request(
'cmdb.category.recycle',
[
'object' => $objectID,
'category' => $categoryConst,
'entry' => $entryID
]
);
return $this;
} | php | public function recycle($objectID, $categoryConst, $entryID) {
$this->api->request(
'cmdb.category.recycle',
[
'object' => $objectID,
'category' => $categoryConst,
'entry' => $entryID
]
);
return $this;
} | [
"public",
"function",
"recycle",
"(",
"$",
"objectID",
",",
"$",
"categoryConst",
",",
"$",
"entryID",
")",
"{",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'cmdb.category.recycle'",
",",
"[",
"'object'",
"=>",
"$",
"objectID",
",",
"'category'",
"=>"... | Restore entry in a multi-value category for a specific object to "normal" state
@param int $objectID Object identifier
@param string $categoryConst Category constant
@param int $entryID Entry identifier
@return self Returns itself
@throws Exception on error | [
"Restore",
"entry",
"in",
"a",
"multi",
"-",
"value",
"category",
"for",
"a",
"specific",
"object",
"to",
"normal",
"state"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L334-L345 | train |
bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.quickPurge | public function quickPurge($objectID, $categoryConst, $entryID) {
$result = $this->api->request(
'cmdb.category.quickpurge',
[
'objID' => $objectID,
'category' => $categoryConst,
'cateID' => $entryID
]
);
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $this;
} | php | public function quickPurge($objectID, $categoryConst, $entryID) {
$result = $this->api->request(
'cmdb.category.quickpurge',
[
'objID' => $objectID,
'category' => $categoryConst,
'cateID' => $entryID
]
);
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $this;
} | [
"public",
"function",
"quickPurge",
"(",
"$",
"objectID",
",",
"$",
"categoryConst",
",",
"$",
"entryID",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'cmdb.category.quickpurge'",
",",
"[",
"'objID'",
"=>",
"$",
"objectID"... | Purge entry in a multi-value category for a specific object
@param int $objectID Object identifier
@param string $categoryConst Category constant
@param int $entryID Entry identifier
@return self Returns itself
@throws Exception on error | [
"Purge",
"entry",
"in",
"a",
"multi",
"-",
"value",
"category",
"for",
"a",
"specific",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L358-L378 | train |
bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.batchCreate | public function batchCreate(array $objectIDs, $categoryConst, array $attributes) {
$entryIDs = [];
$requests = [];
foreach ($objectIDs as $objectID) {
foreach ($attributes as $data) {
$params = [
'objID' => $objectID,
'data' => $data,
'category' => $categoryConst
];
$requests[] = [
'method' => 'cmdb.category.create',
'params' => $params
];
}
}
$result = $this->api->batchRequest($requests);
foreach ($result as $entry) {
// Do not check 'id' because in a batch request it is always NULL:
if (!array_key_exists('success', $entry) ||
$entry['success'] !== true) {
if (array_key_exists('message', $entry)) {
throw new RuntimeException(sprintf('Bad result: %s', $entry['message']));
} else {
throw new RuntimeException('Bad result');
}
}
$entryIDs[] = (int) $entry['id'];
}
return $entryIDs;
} | php | public function batchCreate(array $objectIDs, $categoryConst, array $attributes) {
$entryIDs = [];
$requests = [];
foreach ($objectIDs as $objectID) {
foreach ($attributes as $data) {
$params = [
'objID' => $objectID,
'data' => $data,
'category' => $categoryConst
];
$requests[] = [
'method' => 'cmdb.category.create',
'params' => $params
];
}
}
$result = $this->api->batchRequest($requests);
foreach ($result as $entry) {
// Do not check 'id' because in a batch request it is always NULL:
if (!array_key_exists('success', $entry) ||
$entry['success'] !== true) {
if (array_key_exists('message', $entry)) {
throw new RuntimeException(sprintf('Bad result: %s', $entry['message']));
} else {
throw new RuntimeException('Bad result');
}
}
$entryIDs[] = (int) $entry['id'];
}
return $entryIDs;
} | [
"public",
"function",
"batchCreate",
"(",
"array",
"$",
"objectIDs",
",",
"$",
"categoryConst",
",",
"array",
"$",
"attributes",
")",
"{",
"$",
"entryIDs",
"=",
"[",
"]",
";",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objectIDs",
"as",... | Create multiple entries for a specific category and one or more objects
@param array $objectIDs List of object identifiers as integers
@param string $categoryConst Category constant
@param array $attributes Indexed array of attributes as key-value pairs
@return array List of entry identifiers as integers
@throws Exception on error | [
"Create",
"multiple",
"entries",
"for",
"a",
"specific",
"category",
"and",
"one",
"or",
"more",
"objects"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L391-L428 | train |
bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.batchRead | public function batchRead(array $objectIDs, array $categoryConsts, $status = 2) {
$requests = [];
foreach ($objectIDs as $objectID) {
foreach ($categoryConsts as $categoryConst) {
$requests[] = [
'method' => 'cmdb.category.read',
'params' => [
'objID' => $objectID,
'category' => $categoryConst,
'status' => $status
]
];
}
}
return $this->api->batchRequest($requests);
} | php | public function batchRead(array $objectIDs, array $categoryConsts, $status = 2) {
$requests = [];
foreach ($objectIDs as $objectID) {
foreach ($categoryConsts as $categoryConst) {
$requests[] = [
'method' => 'cmdb.category.read',
'params' => [
'objID' => $objectID,
'category' => $categoryConst,
'status' => $status
]
];
}
}
return $this->api->batchRequest($requests);
} | [
"public",
"function",
"batchRead",
"(",
"array",
"$",
"objectIDs",
",",
"array",
"$",
"categoryConsts",
",",
"$",
"status",
"=",
"2",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objectIDs",
"as",
"$",
"objectID",
")",
"{",
"f... | Read one or more category entries for one or more objects
@param array $objectIDs List of object identifiers as integers
@param array $categoryConsts List of category constants as strings
@param int $status Filter entries by status:
2 = normal;
3 = archived;
4 = deleted,
-1 = combination of all;
defaults to: 2 = normal;
note: a status != 2 is only suitable for multi-value categories
@return array Indexed array of result sets (for both single- and multi-valued categories)
@throws Exception on error | [
"Read",
"one",
"or",
"more",
"category",
"entries",
"for",
"one",
"or",
"more",
"objects"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L447-L464 | train |
bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.batchUpdate | public function batchUpdate(array $objectIDs, $categoryConst, array $attributes) {
$requests = [];
foreach ($objectIDs as $objectID) {
$requests[] = [
'method' => 'cmdb.category.update',
'params' => [
'objID' => $objectID,
'category' => $categoryConst,
'data' => $attributes
]
];
}
$results = $this->api->batchRequest($requests);
foreach ($results as $result) {
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
}
return $this;
} | php | public function batchUpdate(array $objectIDs, $categoryConst, array $attributes) {
$requests = [];
foreach ($objectIDs as $objectID) {
$requests[] = [
'method' => 'cmdb.category.update',
'params' => [
'objID' => $objectID,
'category' => $categoryConst,
'data' => $attributes
]
];
}
$results = $this->api->batchRequest($requests);
foreach ($results as $result) {
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
}
return $this;
} | [
"public",
"function",
"batchUpdate",
"(",
"array",
"$",
"objectIDs",
",",
"$",
"categoryConst",
",",
"array",
"$",
"attributes",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objectIDs",
"as",
"$",
"objectID",
")",
"{",
"$",
"req... | Update single-value category for one or more objects
@param array $objectIDs List of object identifiers as integers
@param string $categoryConst Category constant
@param array $attributes Attributes as key-value pairs
@return self Returns itself
@throws Exception on error | [
"Update",
"single",
"-",
"value",
"category",
"for",
"one",
"or",
"more",
"objects"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L477-L505 | train |
bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.clear | public function clear($objectID, array $categoryConsts) {
$batch = $this->batchRead([$objectID], $categoryConsts);
$requests = [];
$counter = 0;
$index = 0;
foreach ($batch as $entries) {
$categoryConst = $categoryConsts[$index];
foreach ($entries as $entry) {
$requests[] = [
'method' => 'cmdb.category.archive',
'params' => [
'object' => $objectID,
'category' => $categoryConst,
'entry' => (int) $entry['id']
]
];
$counter++;
}
$index++;
}
if ($counter === 0) {
return 0;
}
$results = $this->api->batchRequest($requests);
foreach ($results as $result) {
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
}
return $counter;
} | php | public function clear($objectID, array $categoryConsts) {
$batch = $this->batchRead([$objectID], $categoryConsts);
$requests = [];
$counter = 0;
$index = 0;
foreach ($batch as $entries) {
$categoryConst = $categoryConsts[$index];
foreach ($entries as $entry) {
$requests[] = [
'method' => 'cmdb.category.archive',
'params' => [
'object' => $objectID,
'category' => $categoryConst,
'entry' => (int) $entry['id']
]
];
$counter++;
}
$index++;
}
if ($counter === 0) {
return 0;
}
$results = $this->api->batchRequest($requests);
foreach ($results as $result) {
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
}
return $counter;
} | [
"public",
"function",
"clear",
"(",
"$",
"objectID",
",",
"array",
"$",
"categoryConsts",
")",
"{",
"$",
"batch",
"=",
"$",
"this",
"->",
"batchRead",
"(",
"[",
"$",
"objectID",
"]",
",",
"$",
"categoryConsts",
")",
";",
"$",
"requests",
"=",
"[",
"]... | Archive category entries for a specific object
@param int $objectID Object identifier
@param array $categoryConsts List of category constants as strings
@return int Number of purged category entries
@throws Exception on error | [
"Archive",
"category",
"entries",
"for",
"a",
"specific",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L517-L561 | train |
bheisig/i-doit-api-client-php | src/CMDBImpact.php | CMDBImpact.readByID | public function readByID($objectID, $relationType, $status = null) {
$params = [
'id' => $objectID,
'relation_type' => $relationType
];
if (isset($status)) {
$params['status'] = $status;
}
return $this->api->request(
'cmdb.impact.read',
$params
);
} | php | public function readByID($objectID, $relationType, $status = null) {
$params = [
'id' => $objectID,
'relation_type' => $relationType
];
if (isset($status)) {
$params['status'] = $status;
}
return $this->api->request(
'cmdb.impact.read',
$params
);
} | [
"public",
"function",
"readByID",
"(",
"$",
"objectID",
",",
"$",
"relationType",
",",
"$",
"status",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"[",
"'id'",
"=>",
"$",
"objectID",
",",
"'relation_type'",
"=>",
"$",
"relationType",
"]",
";",
"if",
"(",... | Perform an impact analysis for a specific object by its relation type identifier
@param int $objectID Object identifier
@param int $relationType Relation type identifier
@param int $status Filter relations by status: 2 = normal, 3 = archived, 4 = deleted
@return array
@throws Exception on error | [
"Perform",
"an",
"impact",
"analysis",
"for",
"a",
"specific",
"object",
"by",
"its",
"relation",
"type",
"identifier"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBImpact.php#L45-L59 | train |
bheisig/i-doit-api-client-php | src/CMDBImpact.php | CMDBImpact.readByTypes | public function readByTypes($objectID, array $relationTypes, $status = null) {
$params = [
'id' => $objectID,
'relation_type' => $relationTypes
];
if (isset($status)) {
$params['status'] = $status;
}
return $this->api->request(
'cmdb.impact.read',
$params
);
} | php | public function readByTypes($objectID, array $relationTypes, $status = null) {
$params = [
'id' => $objectID,
'relation_type' => $relationTypes
];
if (isset($status)) {
$params['status'] = $status;
}
return $this->api->request(
'cmdb.impact.read',
$params
);
} | [
"public",
"function",
"readByTypes",
"(",
"$",
"objectID",
",",
"array",
"$",
"relationTypes",
",",
"$",
"status",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"[",
"'id'",
"=>",
"$",
"objectID",
",",
"'relation_type'",
"=>",
"$",
"relationTypes",
"]",
";"... | Perform an impact analysis for a specific object by one ore more relation type constant or identifiers
@param int $objectID Object identifier
@param array $relationTypes List of relation type constants as strings or identifiers as integers
@param int $status Filter relations by status: 2 = normal, 3 = archived, 4 = deleted
@return array
@throws Exception on error | [
"Perform",
"an",
"impact",
"analysis",
"for",
"a",
"specific",
"object",
"by",
"one",
"ore",
"more",
"relation",
"type",
"constant",
"or",
"identifiers"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBImpact.php#L99-L113 | train |
bheisig/i-doit-api-client-php | src/Select.php | Select.find | public function find($category, $attribute, $value) {
$cmdbObjects = new CMDBObjects($this->api);
$limit = 100;
$offset = 0;
$objectIDs = [];
while (true) {
$objects = $cmdbObjects->read([], $limit, $offset);
$count = count($objects);
if ($count === 0) {
break;
}
foreach ($objects as $object) {
$objectIDs[] = (int)$object['id'];
}
unset($objects);
$cmdbCategory = new CMDBCategory($this->api);
$result = $cmdbCategory->batchRead(
$objectIDs,
[$category]
);
$objectIDs = [];
foreach ($result as $categoryEntries) {
foreach ($categoryEntries as $categoryEntry) {
if (!array_key_exists($attribute, $categoryEntry)) {
continue;
}
$found = false;
if (is_array($categoryEntry[$attribute]) &&
array_key_exists('ref_title', $categoryEntry[$attribute]) &&
$categoryEntry[$attribute]['ref_title'] === $value
) {
$found = true;
} elseif (is_array($categoryEntry[$attribute]) &&
array_key_exists('title', $categoryEntry[$attribute]) &&
$categoryEntry[$attribute]['title'] === $value
) {
$found = true;
} elseif (is_numeric($categoryEntry[$attribute]) &&
is_int($value) &&
(int)$categoryEntry[$attribute] === $value
) {
$found = true;
} elseif (is_string($categoryEntry[$attribute]) &&
is_string($value) &&
$categoryEntry[$attribute] === $value
) {
$found = true;
}
if ($found === false) {
continue;
}
if (!array_key_exists('objID', $categoryEntry)) {
throw new RuntimeException('Found attribute for unknown object');
}
$objectIDs[] = (int)$categoryEntry['objID'];
}
}
if ($count < $limit) {
break;
}
$offset += $limit;
}
return $objectIDs;
} | php | public function find($category, $attribute, $value) {
$cmdbObjects = new CMDBObjects($this->api);
$limit = 100;
$offset = 0;
$objectIDs = [];
while (true) {
$objects = $cmdbObjects->read([], $limit, $offset);
$count = count($objects);
if ($count === 0) {
break;
}
foreach ($objects as $object) {
$objectIDs[] = (int)$object['id'];
}
unset($objects);
$cmdbCategory = new CMDBCategory($this->api);
$result = $cmdbCategory->batchRead(
$objectIDs,
[$category]
);
$objectIDs = [];
foreach ($result as $categoryEntries) {
foreach ($categoryEntries as $categoryEntry) {
if (!array_key_exists($attribute, $categoryEntry)) {
continue;
}
$found = false;
if (is_array($categoryEntry[$attribute]) &&
array_key_exists('ref_title', $categoryEntry[$attribute]) &&
$categoryEntry[$attribute]['ref_title'] === $value
) {
$found = true;
} elseif (is_array($categoryEntry[$attribute]) &&
array_key_exists('title', $categoryEntry[$attribute]) &&
$categoryEntry[$attribute]['title'] === $value
) {
$found = true;
} elseif (is_numeric($categoryEntry[$attribute]) &&
is_int($value) &&
(int)$categoryEntry[$attribute] === $value
) {
$found = true;
} elseif (is_string($categoryEntry[$attribute]) &&
is_string($value) &&
$categoryEntry[$attribute] === $value
) {
$found = true;
}
if ($found === false) {
continue;
}
if (!array_key_exists('objID', $categoryEntry)) {
throw new RuntimeException('Found attribute for unknown object');
}
$objectIDs[] = (int)$categoryEntry['objID'];
}
}
if ($count < $limit) {
break;
}
$offset += $limit;
}
return $objectIDs;
} | [
"public",
"function",
"find",
"(",
"$",
"category",
",",
"$",
"attribute",
",",
"$",
"value",
")",
"{",
"$",
"cmdbObjects",
"=",
"new",
"CMDBObjects",
"(",
"$",
"this",
"->",
"api",
")",
";",
"$",
"limit",
"=",
"100",
";",
"$",
"offset",
"=",
"0",
... | Find objects by attribute
@param string $category
@param string $attribute
@param mixed $value
@return array List of object identifiers as integers
@throws Exception on error | [
"Find",
"objects",
"by",
"attribute"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/Select.php#L46-L128 | train |
bheisig/i-doit-api-client-php | src/MonitoringLivestatus.php | MonitoringLivestatus.createUNIXSocketConnection | public function createUNIXSocketConnection($title, $path, $active = true) {
$result = $this->api->request(
'monitoring.livestatus.create',
[
'data' => [
'connection' => 'unix',
'title' => $title,
'path' => $path,
'active' => $active
]
]
);
if (!array_key_exists('id', $result) ||
!is_numeric($result['id']) ||
!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return (int) $result['id'];
} | php | public function createUNIXSocketConnection($title, $path, $active = true) {
$result = $this->api->request(
'monitoring.livestatus.create',
[
'data' => [
'connection' => 'unix',
'title' => $title,
'path' => $path,
'active' => $active
]
]
);
if (!array_key_exists('id', $result) ||
!is_numeric($result['id']) ||
!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return (int) $result['id'];
} | [
"public",
"function",
"createUNIXSocketConnection",
"(",
"$",
"title",
",",
"$",
"path",
",",
"$",
"active",
"=",
"true",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'monitoring.livestatus.create'",
",",
"[",
"'data'",
"=... | Add a new monitoring instance listening on a UNIX socket
@param string $title Title
@param string $path Path to UNIX socket
@param bool $active Enable this instance? Defaults to true
@return int Identifier
@throws Exception on error | [
"Add",
"a",
"new",
"monitoring",
"instance",
"listening",
"on",
"a",
"UNIX",
"socket"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/MonitoringLivestatus.php#L86-L111 | train |
bheisig/i-doit-api-client-php | src/MonitoringLivestatus.php | MonitoringLivestatus.update | public function update($id, array $attributes) {
$result = $this->api->request(
'monitoring.livestatus.update',
[
'id' => $id,
'data' => $attributes
]
);
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $this;
} | php | public function update($id, array $attributes) {
$result = $this->api->request(
'monitoring.livestatus.update',
[
'id' => $id,
'data' => $attributes
]
);
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $this;
} | [
"public",
"function",
"update",
"(",
"$",
"id",
",",
"array",
"$",
"attributes",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'monitoring.livestatus.update'",
",",
"[",
"'id'",
"=>",
"$",
"id",
",",
"'data'",
"=>",
"$"... | Update a monitoring instance by its identifier
@param int $id Identifier
@param array $attributes Attributes which can be altered:
"title", "connection", "address", "port", "path" and "active"
@return self Returns itself
@throws Exception on error | [
"Update",
"a",
"monitoring",
"instance",
"by",
"its",
"identifier"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/MonitoringLivestatus.php#L191-L210 | train |
bheisig/i-doit-api-client-php | src/MonitoringLivestatus.php | MonitoringLivestatus.deleteByID | public function deleteByID($id) {
$result = $this->api->request(
'monitoring.livestatus.delete',
[
'id' => $id
]
);
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $this;
} | php | public function deleteByID($id) {
$result = $this->api->request(
'monitoring.livestatus.delete',
[
'id' => $id
]
);
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $this;
} | [
"public",
"function",
"deleteByID",
"(",
"$",
"id",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'monitoring.livestatus.delete'",
",",
"[",
"'id'",
"=>",
"$",
"id",
"]",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(... | Delete a monitoring instance by its identifier
@param int $id Identifier
@return self Returns itself
@throws Exception on error | [
"Delete",
"a",
"monitoring",
"instance",
"by",
"its",
"identifier"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/MonitoringLivestatus.php#L221-L239 | train |
bheisig/i-doit-api-client-php | src/MonitoringLivestatus.php | MonitoringLivestatus.deleteByTitle | public function deleteByTitle($title) {
$result = $this->api->request(
'monitoring.livestatus.delete',
[
'title' => $title
]
);
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $this;
} | php | public function deleteByTitle($title) {
$result = $this->api->request(
'monitoring.livestatus.delete',
[
'title' => $title
]
);
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $this;
} | [
"public",
"function",
"deleteByTitle",
"(",
"$",
"title",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'monitoring.livestatus.delete'",
",",
"[",
"'title'",
"=>",
"$",
"title",
"]",
")",
";",
"if",
"(",
"!",
"array_key_e... | Delete a monitoring instance by its title
@param string $title Title
@return self Returns itself
@throws Exception on error | [
"Delete",
"a",
"monitoring",
"instance",
"by",
"its",
"title"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/MonitoringLivestatus.php#L250-L268 | train |
bheisig/i-doit-api-client-php | src/MonitoringLivestatus.php | MonitoringLivestatus.batchDelete | public function batchDelete($ids) {
$requests = [];
foreach ($ids as $id) {
$requests[] = [
'method' => 'monitoring.livestatus.delete',
'params' => [
'id' => $id
]
];
}
$result = $this->api->batchRequest($requests);
foreach ($result as $tag) {
// Do not check 'id' because in a batch request it is always NULL:
if (!array_key_exists('success', $tag) ||
$tag['success'] !== true) {
if (array_key_exists('message', $tag)) {
throw new RuntimeException(sprintf('Bad result: %s', $tag['message']));
} else {
throw new RuntimeException('Bad result');
}
}
}
return $this;
} | php | public function batchDelete($ids) {
$requests = [];
foreach ($ids as $id) {
$requests[] = [
'method' => 'monitoring.livestatus.delete',
'params' => [
'id' => $id
]
];
}
$result = $this->api->batchRequest($requests);
foreach ($result as $tag) {
// Do not check 'id' because in a batch request it is always NULL:
if (!array_key_exists('success', $tag) ||
$tag['success'] !== true) {
if (array_key_exists('message', $tag)) {
throw new RuntimeException(sprintf('Bad result: %s', $tag['message']));
} else {
throw new RuntimeException('Bad result');
}
}
}
return $this;
} | [
"public",
"function",
"batchDelete",
"(",
"$",
"ids",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"ids",
"as",
"$",
"id",
")",
"{",
"$",
"requests",
"[",
"]",
"=",
"[",
"'method'",
"=>",
"'monitoring.livestatus.delete'",
",",
... | Delete one or more monitoring instances be their identifiers
@param array $ids List of identifiers as integers
@return self Returns itself
@throws Exception on error | [
"Delete",
"one",
"or",
"more",
"monitoring",
"instances",
"be",
"their",
"identifiers"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/MonitoringLivestatus.php#L279-L306 | train |
bheisig/i-doit-api-client-php | src/MonitoringLivestatus.php | MonitoringLivestatus.deleteAll | public function deleteAll() {
$instances = $this->read();
$ids = [];
foreach ($instances as $instance) {
$ids[] = $instance['id'];
}
if (count($ids) > 0) {
$this->batchDelete($ids);
}
return $this;
} | php | public function deleteAll() {
$instances = $this->read();
$ids = [];
foreach ($instances as $instance) {
$ids[] = $instance['id'];
}
if (count($ids) > 0) {
$this->batchDelete($ids);
}
return $this;
} | [
"public",
"function",
"deleteAll",
"(",
")",
"{",
"$",
"instances",
"=",
"$",
"this",
"->",
"read",
"(",
")",
";",
"$",
"ids",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"instances",
"as",
"$",
"instance",
")",
"{",
"$",
"ids",
"[",
"]",
"=",
"$"... | Delete all monitoring instances
@return self Returns itself
@throws Exception on error | [
"Delete",
"all",
"monitoring",
"instances"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/MonitoringLivestatus.php#L315-L329 | train |
bheisig/i-doit-api-client-php | src/Subnet.php | Subnet.load | public function load($objectID) {
$category = new CMDBCategory($this->api);
$netInfo = $category->read($objectID, 'C__CATS__NET');
if (count($netInfo) !== 1 ||
!array_key_exists(0, $netInfo) ||
!is_array($netInfo[0])) {
throw new RuntimeException(sprintf(
'Nothing found for object identifier %s',
$objectID
));
}
if (!array_key_exists('type', $netInfo[0]) ||
!is_array($netInfo[0]['type']) ||
!array_key_exists('const', $netInfo[0]['type']) ||
!is_string($netInfo[0]['type']['const']) ||
$netInfo[0]['type']['const'] !== 'C__CATS_NET_TYPE__IPV4') {
throw new RuntimeException('Works only for IPv4');
}
if (!array_key_exists('range_from', $netInfo[0]) ||
!is_string($netInfo[0]['range_from']) ||
!array_key_exists('range_to', $netInfo[0]) ||
!is_string($netInfo[0]['range_to'])) {
throw new RuntimeException(sprintf(
'Subnet #%s has no IP address range',
$objectID
));
}
$this->first = $this->convertIPv4Address($netInfo[0]['range_from']);
$this->last = $this->convertIPv4Address($netInfo[0]['range_to']);
$takenIPAddresses = $category->read($objectID, 'C__CATS__NET_IP_ADDRESSES');
foreach ($takenIPAddresses as $takenIPAddress) {
$this->taken[] = $takenIPAddress['title'];
}
$this->current = $this->first;
return $this;
} | php | public function load($objectID) {
$category = new CMDBCategory($this->api);
$netInfo = $category->read($objectID, 'C__CATS__NET');
if (count($netInfo) !== 1 ||
!array_key_exists(0, $netInfo) ||
!is_array($netInfo[0])) {
throw new RuntimeException(sprintf(
'Nothing found for object identifier %s',
$objectID
));
}
if (!array_key_exists('type', $netInfo[0]) ||
!is_array($netInfo[0]['type']) ||
!array_key_exists('const', $netInfo[0]['type']) ||
!is_string($netInfo[0]['type']['const']) ||
$netInfo[0]['type']['const'] !== 'C__CATS_NET_TYPE__IPV4') {
throw new RuntimeException('Works only for IPv4');
}
if (!array_key_exists('range_from', $netInfo[0]) ||
!is_string($netInfo[0]['range_from']) ||
!array_key_exists('range_to', $netInfo[0]) ||
!is_string($netInfo[0]['range_to'])) {
throw new RuntimeException(sprintf(
'Subnet #%s has no IP address range',
$objectID
));
}
$this->first = $this->convertIPv4Address($netInfo[0]['range_from']);
$this->last = $this->convertIPv4Address($netInfo[0]['range_to']);
$takenIPAddresses = $category->read($objectID, 'C__CATS__NET_IP_ADDRESSES');
foreach ($takenIPAddresses as $takenIPAddress) {
$this->taken[] = $takenIPAddress['title'];
}
$this->current = $this->first;
return $this;
} | [
"public",
"function",
"load",
"(",
"$",
"objectID",
")",
"{",
"$",
"category",
"=",
"new",
"CMDBCategory",
"(",
"$",
"this",
"->",
"api",
")",
";",
"$",
"netInfo",
"=",
"$",
"category",
"->",
"read",
"(",
"$",
"objectID",
",",
"'C__CATS__NET'",
")",
... | Fetches some information about subnet object
@param int $objectID Object identifier
@return self Returns itself
@throws Exception on error | [
"Fetches",
"some",
"information",
"about",
"subnet",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/Subnet.php#L73-L116 | train |
bheisig/i-doit-api-client-php | src/Subnet.php | Subnet.hasNext | public function hasNext() {
if (!isset($this->current)) {
throw new BadMethodCallException('You need to call method "load()" first.');
}
for ($ipLong = $this->current; $ipLong <= $this->last; $ipLong++) {
if ($this->isUsed($ipLong) === false) {
return true;
}
}
return false;
} | php | public function hasNext() {
if (!isset($this->current)) {
throw new BadMethodCallException('You need to call method "load()" first.');
}
for ($ipLong = $this->current; $ipLong <= $this->last; $ipLong++) {
if ($this->isUsed($ipLong) === false) {
return true;
}
}
return false;
} | [
"public",
"function",
"hasNext",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"current",
")",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'You need to call method \"load()\" first.'",
")",
";",
"}",
"for",
"(",
"$",
"ipLong",... | Is there a free IP address?
@return bool
@throws Exception on error | [
"Is",
"there",
"a",
"free",
"IP",
"address?"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/Subnet.php#L125-L137 | train |
bheisig/i-doit-api-client-php | src/Subnet.php | Subnet.next | public function next() {
if (!isset($this->current)) {
throw new BadMethodCallException('You need to call method "load()" first.');
}
for ($ipLong = $this->current; $ipLong <= $this->last; $ipLong++) {
$this->current = $ipLong;
if ($this->isUsed($ipLong) === false) {
return long2ip($ipLong);
}
}
throw new RuntimeException('No free IP addresses left');
} | php | public function next() {
if (!isset($this->current)) {
throw new BadMethodCallException('You need to call method "load()" first.');
}
for ($ipLong = $this->current; $ipLong <= $this->last; $ipLong++) {
$this->current = $ipLong;
if ($this->isUsed($ipLong) === false) {
return long2ip($ipLong);
}
}
throw new RuntimeException('No free IP addresses left');
} | [
"public",
"function",
"next",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"current",
")",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'You need to call method \"load()\" first.'",
")",
";",
"}",
"for",
"(",
"$",
"ipLong",
... | Fetches next free IP address
@return string IPv4 address
@throws Exception on error | [
"Fetches",
"next",
"free",
"IP",
"address"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/Subnet.php#L146-L160 | train |
bheisig/i-doit-api-client-php | src/Subnet.php | Subnet.isFree | public function isFree($ipAddress) {
if (!isset($this->current)) {
throw new BadMethodCallException('You need to call method "load()" first.');
}
$longIP = $this->convertIPv4Address($ipAddress);
return ! $this->isUsed($longIP);
} | php | public function isFree($ipAddress) {
if (!isset($this->current)) {
throw new BadMethodCallException('You need to call method "load()" first.');
}
$longIP = $this->convertIPv4Address($ipAddress);
return ! $this->isUsed($longIP);
} | [
"public",
"function",
"isFree",
"(",
"$",
"ipAddress",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"current",
")",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'You need to call method \"load()\" first.'",
")",
";",
"}",
"$",
"lon... | Is IP address currently unused in subnet?
@param string $ipAddress IPv4 address
@return bool
@throws Exception on error | [
"Is",
"IP",
"address",
"currently",
"unused",
"in",
"subnet?"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/Subnet.php#L171-L179 | train |
bheisig/i-doit-api-client-php | src/Subnet.php | Subnet.isUsed | protected function isUsed($longIP) {
foreach ($this->taken as $taken) {
$takenIPLong = $this->convertIPv4Address($taken);
if ($takenIPLong === $longIP) {
return true;
}
}
return false;
} | php | protected function isUsed($longIP) {
foreach ($this->taken as $taken) {
$takenIPLong = $this->convertIPv4Address($taken);
if ($takenIPLong === $longIP) {
return true;
}
}
return false;
} | [
"protected",
"function",
"isUsed",
"(",
"$",
"longIP",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"taken",
"as",
"$",
"taken",
")",
"{",
"$",
"takenIPLong",
"=",
"$",
"this",
"->",
"convertIPv4Address",
"(",
"$",
"taken",
")",
";",
"if",
"(",
"$",
... | Is IP address already taken in subnet?
@param int $longIP IPv4 address converted to long integer
@return bool
@throws Exception on error | [
"Is",
"IP",
"address",
"already",
"taken",
"in",
"subnet?"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/Subnet.php#L190-L200 | train |
bheisig/i-doit-api-client-php | src/Subnet.php | Subnet.convertIPv4Address | protected function convertIPv4Address($ipv4Address) {
$longIP = ip2long($ipv4Address);
if (!is_int($longIP)) {
throw new RuntimeException(sprintf(
'Unable to convert IP address "%s"',
$ipv4Address
));
}
return $longIP;
} | php | protected function convertIPv4Address($ipv4Address) {
$longIP = ip2long($ipv4Address);
if (!is_int($longIP)) {
throw new RuntimeException(sprintf(
'Unable to convert IP address "%s"',
$ipv4Address
));
}
return $longIP;
} | [
"protected",
"function",
"convertIPv4Address",
"(",
"$",
"ipv4Address",
")",
"{",
"$",
"longIP",
"=",
"ip2long",
"(",
"$",
"ipv4Address",
")",
";",
"if",
"(",
"!",
"is_int",
"(",
"$",
"longIP",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"spr... | Convert IPv4 address to integer
@param string $ipv4Address IPv4 address
@return int
@throws Exception on error | [
"Convert",
"IPv4",
"address",
"to",
"integer"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/Subnet.php#L211-L222 | train |
bheisig/i-doit-api-client-php | src/Image.php | Image.add | public function add($objectID, $filePath, $caption = '') {
$imageAsString = $this->encode($filePath);
$cmdbCategory = new CMDBCategory($this->api);
$cmdbCategory->create(
$objectID,
'C__CATG__IMAGES',
[
'name' => $caption,
'content' => $imageAsString
]
);
return $this;
} | php | public function add($objectID, $filePath, $caption = '') {
$imageAsString = $this->encode($filePath);
$cmdbCategory = new CMDBCategory($this->api);
$cmdbCategory->create(
$objectID,
'C__CATG__IMAGES',
[
'name' => $caption,
'content' => $imageAsString
]
);
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"objectID",
",",
"$",
"filePath",
",",
"$",
"caption",
"=",
"''",
")",
"{",
"$",
"imageAsString",
"=",
"$",
"this",
"->",
"encode",
"(",
"$",
"filePath",
")",
";",
"$",
"cmdbCategory",
"=",
"new",
"CMDBCategory",
... | Add a new file to the image gallery.
@param int $objectID Object identifier
@param string $filePath Path to image file
@param string $caption (Optional) caption
@return self Returns itself
@throws Exception on error | [
"Add",
"a",
"new",
"file",
"to",
"the",
"image",
"gallery",
"."
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/Image.php#L47-L62 | train |
bheisig/i-doit-api-client-php | src/Image.php | Image.batchAdd | public function batchAdd($objectID, array $images) {
$objectIDs = [$objectID];
$categoryConst = 'C__CATG__IMAGES';
$attributes = [];
foreach ($images as $filePath => $caption) {
$imageAsString = $this->encode($filePath);
$attributes[] = [
'name' => $caption,
'content' => $imageAsString
];
}
$cmdbCategory = new CMDBCategory($this->api);
$cmdbCategory->batchCreate($objectIDs, $categoryConst, $attributes);
return $this;
} | php | public function batchAdd($objectID, array $images) {
$objectIDs = [$objectID];
$categoryConst = 'C__CATG__IMAGES';
$attributes = [];
foreach ($images as $filePath => $caption) {
$imageAsString = $this->encode($filePath);
$attributes[] = [
'name' => $caption,
'content' => $imageAsString
];
}
$cmdbCategory = new CMDBCategory($this->api);
$cmdbCategory->batchCreate($objectIDs, $categoryConst, $attributes);
return $this;
} | [
"public",
"function",
"batchAdd",
"(",
"$",
"objectID",
",",
"array",
"$",
"images",
")",
"{",
"$",
"objectIDs",
"=",
"[",
"$",
"objectID",
"]",
";",
"$",
"categoryConst",
"=",
"'C__CATG__IMAGES'",
";",
"$",
"attributes",
"=",
"[",
"]",
";",
"foreach",
... | Add new files to the image gallery.
@param int $objectID Object identifier
@param array $images Associative array (key: path to image file; value: caption)
@return self Returns itself
@throws Exception on error | [
"Add",
"new",
"files",
"to",
"the",
"image",
"gallery",
"."
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/Image.php#L74-L93 | train |
bheisig/i-doit-api-client-php | src/File.php | File.add | public function add($objectID, $filePath, $description = '') {
$fileAsString = $this->encode($filePath);
$cmdbObject = new CMDBObject($this->api);
$fileObjectID = $cmdbObject->create(
'C__OBJTYPE__FILE',
$description
);
$cmdbCategory = new CMDBCategory($this->api);
$cmdbCategory->create(
$fileObjectID,
'C__CATS__FILE_VERSIONS',
[
'file_content' => $fileAsString,
'file_physical' => basename($filePath),
'file_title' => $description,
'version_description' => $description
]
);
$cmdbCategory->create(
$objectID,
'C__CATG__FILE',
[
'file' => $fileObjectID
]
);
return $this;
} | php | public function add($objectID, $filePath, $description = '') {
$fileAsString = $this->encode($filePath);
$cmdbObject = new CMDBObject($this->api);
$fileObjectID = $cmdbObject->create(
'C__OBJTYPE__FILE',
$description
);
$cmdbCategory = new CMDBCategory($this->api);
$cmdbCategory->create(
$fileObjectID,
'C__CATS__FILE_VERSIONS',
[
'file_content' => $fileAsString,
'file_physical' => basename($filePath),
'file_title' => $description,
'version_description' => $description
]
);
$cmdbCategory->create(
$objectID,
'C__CATG__FILE',
[
'file' => $fileObjectID
]
);
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"objectID",
",",
"$",
"filePath",
",",
"$",
"description",
"=",
"''",
")",
"{",
"$",
"fileAsString",
"=",
"$",
"this",
"->",
"encode",
"(",
"$",
"filePath",
")",
";",
"$",
"cmdbObject",
"=",
"new",
"CMDBObject",
... | Add a new file to a specific object. A new file object will be created and assigned to the specific object.
@param int $objectID Object identifier
@param string $filePath Path to file
@param string $description (Optional) description
@return self Returns itself
@throws Exception on error | [
"Add",
"a",
"new",
"file",
"to",
"a",
"specific",
"object",
".",
"A",
"new",
"file",
"object",
"will",
"be",
"created",
"and",
"assigned",
"to",
"the",
"specific",
"object",
"."
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/File.php#L47-L79 | train |
bheisig/i-doit-api-client-php | src/File.php | File.batchAdd | public function batchAdd($objectID, array $files) {
$objects = [];
foreach ($files as $description) {
$objects[] = [
'type' => 'C__OBJTYPE__FILE',
'title' => $description
];
}
$cmdbObjects = new CMDBObjects($this->api);
$fileObjectIDs = $cmdbObjects->create($objects);
if (count($fileObjectIDs) !== count($files)) {
throw new RuntimeException(sprintf(
'Wanted to create %s file object(s) but got %s object identifiers',
count($files),
count($fileObjectIDs)
));
}
$requests = [];
$counter = 0;
foreach ($files as $filePath => $description) {
$fileAsString = $this->encode($filePath);
$requests[] = [
'method' => 'cmdb.category.create',
'params' => [
'objID' => $fileObjectIDs[$counter],
'catsID' => 'C__CATS__FILE_VERSIONS',
'data' => [
'file_content' => $fileAsString,
'file_physical' => basename($filePath),
'file_title' => $description,
'version_description' => $description
]
]
];
$requests[] = [
'method' => 'cmdb.category.create',
'params' => [
'objID' => $objectID,
'catgID' => 'C__CATG__FILE',
'data' => [
'file' => $fileObjectIDs[$counter]
]
]
];
$counter++;
}
$this->api->batchRequest($requests);
return $this;
} | php | public function batchAdd($objectID, array $files) {
$objects = [];
foreach ($files as $description) {
$objects[] = [
'type' => 'C__OBJTYPE__FILE',
'title' => $description
];
}
$cmdbObjects = new CMDBObjects($this->api);
$fileObjectIDs = $cmdbObjects->create($objects);
if (count($fileObjectIDs) !== count($files)) {
throw new RuntimeException(sprintf(
'Wanted to create %s file object(s) but got %s object identifiers',
count($files),
count($fileObjectIDs)
));
}
$requests = [];
$counter = 0;
foreach ($files as $filePath => $description) {
$fileAsString = $this->encode($filePath);
$requests[] = [
'method' => 'cmdb.category.create',
'params' => [
'objID' => $fileObjectIDs[$counter],
'catsID' => 'C__CATS__FILE_VERSIONS',
'data' => [
'file_content' => $fileAsString,
'file_physical' => basename($filePath),
'file_title' => $description,
'version_description' => $description
]
]
];
$requests[] = [
'method' => 'cmdb.category.create',
'params' => [
'objID' => $objectID,
'catgID' => 'C__CATG__FILE',
'data' => [
'file' => $fileObjectIDs[$counter]
]
]
];
$counter++;
}
$this->api->batchRequest($requests);
return $this;
} | [
"public",
"function",
"batchAdd",
"(",
"$",
"objectID",
",",
"array",
"$",
"files",
")",
"{",
"$",
"objects",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"description",
")",
"{",
"$",
"objects",
"[",
"]",
"=",
"[",
"'type'",
"=>",
... | Add multiple new files to a specific object.
New file objects will be created and assigned to the specific object.
@param int $objectID Object identifier
@param array $files Associative array (key: path to file; value: description)
@return self Returns itself
@throws Exception on error | [
"Add",
"multiple",
"new",
"files",
"to",
"a",
"specific",
"object",
".",
"New",
"file",
"objects",
"will",
"be",
"created",
"and",
"assigned",
"to",
"the",
"specific",
"object",
"."
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/File.php#L92-L152 | train |
bheisig/i-doit-api-client-php | src/File.php | File.encode | public function encode($filePath) {
if (!file_exists($filePath) ||
!is_readable($filePath)) {
throw new BadMethodCallException(sprintf(
'File "%s" not found or not readable',
$filePath
));
}
$fileContent = file_get_contents($filePath);
if (!is_string($fileContent)) {
throw new RuntimeException(sprintf(
'Unable to read from file "%s"',
$filePath
));
}
$fileAsString = base64_encode($fileContent);
return $fileAsString;
} | php | public function encode($filePath) {
if (!file_exists($filePath) ||
!is_readable($filePath)) {
throw new BadMethodCallException(sprintf(
'File "%s" not found or not readable',
$filePath
));
}
$fileContent = file_get_contents($filePath);
if (!is_string($fileContent)) {
throw new RuntimeException(sprintf(
'Unable to read from file "%s"',
$filePath
));
}
$fileAsString = base64_encode($fileContent);
return $fileAsString;
} | [
"public",
"function",
"encode",
"(",
"$",
"filePath",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filePath",
")",
"||",
"!",
"is_readable",
"(",
"$",
"filePath",
")",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"sprintf",
"(",
"'File... | Encode an file to base64
@param string $filePath Path to file
@return string Base64 encoded string
@throws Exception on error | [
"Encode",
"an",
"file",
"to",
"base64"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/File.php#L163-L184 | train |
bheisig/i-doit-api-client-php | src/CMDBObject.php | CMDBObject.create | public function create($type, $title, array $attributes = []) {
$attributes['type'] = $type;
$attributes['title'] = $title;
$result = $this->api->request(
'cmdb.object.create',
$attributes
);
if (array_key_exists('id', $result)) {
return $result['id'];
} else {
throw new RuntimeException('Unable to create object');
}
} | php | public function create($type, $title, array $attributes = []) {
$attributes['type'] = $type;
$attributes['title'] = $title;
$result = $this->api->request(
'cmdb.object.create',
$attributes
);
if (array_key_exists('id', $result)) {
return $result['id'];
} else {
throw new RuntimeException('Unable to create object');
}
} | [
"public",
"function",
"create",
"(",
"$",
"type",
",",
"$",
"title",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"attributes",
"[",
"'type'",
"]",
"=",
"$",
"type",
";",
"$",
"attributes",
"[",
"'title'",
"]",
"=",
"$",
"title",
... | Create new object
@param int|string $type Object type identifier or its constant
@param string $title Object title
@param array $attributes (Optional) additional common attributes:
string|int "category",
string|int "cmdb_status",
0|1 "defaultTemplate",
string "description",
string|int "purpose",
int "status",
string "sysid"
@return int Object identifier
@throws Exception on error | [
"Create",
"new",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObject.php#L53-L67 | train |
bheisig/i-doit-api-client-php | src/CMDBObject.php | CMDBObject.createWithCategories | public function createWithCategories($type, $title, array $categories = [], array $attributes = []) {
$attributes['type'] = $type;
$attributes['title'] = $title;
if (count($categories) > 0) {
$attributes['categories'] = $categories;
}
return $this->api->request(
'cmdb.object.create',
$attributes
);
} | php | public function createWithCategories($type, $title, array $categories = [], array $attributes = []) {
$attributes['type'] = $type;
$attributes['title'] = $title;
if (count($categories) > 0) {
$attributes['categories'] = $categories;
}
return $this->api->request(
'cmdb.object.create',
$attributes
);
} | [
"public",
"function",
"createWithCategories",
"(",
"$",
"type",
",",
"$",
"title",
",",
"array",
"$",
"categories",
"=",
"[",
"]",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"attributes",
"[",
"'type'",
"]",
"=",
"$",
"type",
";",... | Create new object with category entries
@param int|string $type Object type identifier or its constant
@param string $title Object title
@param array $categories Also create category entries;
set category constant (string) as key and
one (array of attributes) entry or even several entries (array of arrays) as value
@param array $attributes (Optional) additional common attributes:
string|int "category",
string|int "cmdb_status",
0|1 "defaultTemplate",
string "description",
string|int "purpose",
int "status",
string "sysid"
@return array Result with object identifier ('id') and
key-value pairs of category constants and array of category entry identifiers as integers
@throws Exception on error | [
"Create",
"new",
"object",
"with",
"category",
"entries"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObject.php#L91-L103 | train |
bheisig/i-doit-api-client-php | src/CMDBObject.php | CMDBObject.update | public function update($objectID, array $attributes = []) {
$params = [
'id' => $objectID
];
$supportedAttributes = [
'title'
];
foreach ($supportedAttributes as $supportedAttribute) {
if (array_key_exists($supportedAttribute, $attributes)) {
$params[$supportedAttribute] = $attributes[$supportedAttribute];
}
}
$result = $this->api->request(
'cmdb.object.update',
$params
);
if (!is_array($result) ||
!array_key_exists('success', $result) ||
$result['success'] === false) {
throw new RuntimeException(sprintf(
'Unable to archive object %s',
$objectID
));
}
return $this;
} | php | public function update($objectID, array $attributes = []) {
$params = [
'id' => $objectID
];
$supportedAttributes = [
'title'
];
foreach ($supportedAttributes as $supportedAttribute) {
if (array_key_exists($supportedAttribute, $attributes)) {
$params[$supportedAttribute] = $attributes[$supportedAttribute];
}
}
$result = $this->api->request(
'cmdb.object.update',
$params
);
if (!is_array($result) ||
!array_key_exists('success', $result) ||
$result['success'] === false) {
throw new RuntimeException(sprintf(
'Unable to archive object %s',
$objectID
));
}
return $this;
} | [
"public",
"function",
"update",
"(",
"$",
"objectID",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"=",
"[",
"'id'",
"=>",
"$",
"objectID",
"]",
";",
"$",
"supportedAttributes",
"=",
"[",
"'title'",
"]",
";",
"foreach",
"(... | Update existing object
@param int $objectID Object identifier
@param array $attributes (Optional) common attributes (only 'title' is supported at the moment)
@return self Returns itself
@throws Exception on error | [
"Update",
"existing",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObject.php#L130-L160 | train |
bheisig/i-doit-api-client-php | src/CMDBObject.php | CMDBObject.load | public function load($objectID) {
$object = $this->read($objectID);
if (count($object) === 0) {
throw new RuntimeException('Object not found');
}
if (!array_key_exists('objecttype', $object)) {
throw new RuntimeException(sprintf(
'Object %s has no type',
$objectID
));
}
$cmdbObjectTypeCategories = new CMDBObjectTypeCategories($this->api);
$object += $cmdbObjectTypeCategories->readByID(
$object['objecttype']
);
$cmdbCategory = new CMDBCategory($this->api);
$categoryTypes = ['catg', 'cats', 'custom'];
$cmdbCategoryInfo = new CMDBCategoryInfo($this->api);
$blacklistedCategoryConstants = $cmdbCategoryInfo->getVirtualCategoryConstants();
foreach ($categoryTypes as $categoryType) {
if (!array_key_exists($categoryType, $object)) {
continue;
}
$categoryConstants = [];
for ($i = 0; $i < count($object[$categoryType]); $i++) {
if (!array_key_exists('const', $object[$categoryType][$i])) {
throw new RuntimeException(
'Information about categories is broken. Constant is missing.'
);
}
$categoryConstant = $object[$categoryType][$i]['const'];
if (in_array($categoryConstant, $blacklistedCategoryConstants)) {
continue;
}
$object[$categoryType][$i]['entries'] = [];
$categoryConstants[] = $categoryConstant;
}
$categoryEntries = $cmdbCategory->batchRead([$objectID], $categoryConstants);
for ($i = 0; $i < count($categoryConstants); $i++) {
$index = -1;
$entries = [];
foreach ($object[$categoryType] as $key => $category) {
if ($category['const'] === $categoryConstants[$i]) {
$index = $key;
$entries = $categoryEntries[$i];
break;
}
}
$object[$categoryType][$index]['entries'] = $entries;
}
}
return $object;
} | php | public function load($objectID) {
$object = $this->read($objectID);
if (count($object) === 0) {
throw new RuntimeException('Object not found');
}
if (!array_key_exists('objecttype', $object)) {
throw new RuntimeException(sprintf(
'Object %s has no type',
$objectID
));
}
$cmdbObjectTypeCategories = new CMDBObjectTypeCategories($this->api);
$object += $cmdbObjectTypeCategories->readByID(
$object['objecttype']
);
$cmdbCategory = new CMDBCategory($this->api);
$categoryTypes = ['catg', 'cats', 'custom'];
$cmdbCategoryInfo = new CMDBCategoryInfo($this->api);
$blacklistedCategoryConstants = $cmdbCategoryInfo->getVirtualCategoryConstants();
foreach ($categoryTypes as $categoryType) {
if (!array_key_exists($categoryType, $object)) {
continue;
}
$categoryConstants = [];
for ($i = 0; $i < count($object[$categoryType]); $i++) {
if (!array_key_exists('const', $object[$categoryType][$i])) {
throw new RuntimeException(
'Information about categories is broken. Constant is missing.'
);
}
$categoryConstant = $object[$categoryType][$i]['const'];
if (in_array($categoryConstant, $blacklistedCategoryConstants)) {
continue;
}
$object[$categoryType][$i]['entries'] = [];
$categoryConstants[] = $categoryConstant;
}
$categoryEntries = $cmdbCategory->batchRead([$objectID], $categoryConstants);
for ($i = 0; $i < count($categoryConstants); $i++) {
$index = -1;
$entries = [];
foreach ($object[$categoryType] as $key => $category) {
if ($category['const'] === $categoryConstants[$i]) {
$index = $key;
$entries = $categoryEntries[$i];
break;
}
}
$object[$categoryType][$index]['entries'] = $entries;
}
}
return $object;
} | [
"public",
"function",
"load",
"(",
"$",
"objectID",
")",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"read",
"(",
"$",
"objectID",
")",
";",
"if",
"(",
"count",
"(",
"$",
"object",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",... | Load all data about object
@param int $objectID Object identifier
@return array Multi-dimensional array
@throws Exception on error
@deprecated This method is pretty slow. Use readAll() instead! | [
"Load",
"all",
"data",
"about",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObject.php#L299-L370 | train |
bheisig/i-doit-api-client-php | src/CMDBObject.php | CMDBObject.readAll | public function readAll($objectID) {
$objects = (new CMDBObjects($this->api))
->read(['ids' => [$objectID]], null, null, null, null, true);
switch (count($objects)) {
case 0:
throw new RuntimeException(sprintf(
'Object not found by identifier %s',
$objectID
));
case 1:
return end($objects);
default:
throw new RuntimeException(sprintf(
'Found multiple objects by identifier %s',
$objectID
));
}
} | php | public function readAll($objectID) {
$objects = (new CMDBObjects($this->api))
->read(['ids' => [$objectID]], null, null, null, null, true);
switch (count($objects)) {
case 0:
throw new RuntimeException(sprintf(
'Object not found by identifier %s',
$objectID
));
case 1:
return end($objects);
default:
throw new RuntimeException(sprintf(
'Found multiple objects by identifier %s',
$objectID
));
}
} | [
"public",
"function",
"readAll",
"(",
"$",
"objectID",
")",
"{",
"$",
"objects",
"=",
"(",
"new",
"CMDBObjects",
"(",
"$",
"this",
"->",
"api",
")",
")",
"->",
"read",
"(",
"[",
"'ids'",
"=>",
"[",
"$",
"objectID",
"]",
"]",
",",
"null",
",",
"nu... | Read all information about object including category entries
@param int $objectID Object identifier
@return array Multi-dimensional array
@throws Exception on error | [
"Read",
"all",
"information",
"about",
"object",
"including",
"category",
"entries"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObject.php#L381-L399 | train |
bheisig/i-doit-api-client-php | src/CMDBObject.php | CMDBObject.upsert | public function upsert($type, $title, array $attributes = []) {
$cmdbObjects = new CMDBObjects($this->api);
$filter = [
'title' => $title,
'type' => $type
];
$result = $cmdbObjects->read($filter);
switch (count($result)) {
case 0:
return $this->create($type, $title, $attributes);
case 1:
if (!array_key_exists(0, $result) ||
!array_key_exists('id', $result[0])) {
throw new RuntimeException('Bad result');
}
return $result[0]['id'];
default:
throw new RuntimeException(sprintf(
'Found %s objects',
count($result)
));
}
} | php | public function upsert($type, $title, array $attributes = []) {
$cmdbObjects = new CMDBObjects($this->api);
$filter = [
'title' => $title,
'type' => $type
];
$result = $cmdbObjects->read($filter);
switch (count($result)) {
case 0:
return $this->create($type, $title, $attributes);
case 1:
if (!array_key_exists(0, $result) ||
!array_key_exists('id', $result[0])) {
throw new RuntimeException('Bad result');
}
return $result[0]['id'];
default:
throw new RuntimeException(sprintf(
'Found %s objects',
count($result)
));
}
} | [
"public",
"function",
"upsert",
"(",
"$",
"type",
",",
"$",
"title",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"cmdbObjects",
"=",
"new",
"CMDBObjects",
"(",
"$",
"this",
"->",
"api",
")",
";",
"$",
"filter",
"=",
"[",
"'title'... | Create new object or fetch existing one based on its title and type
@param int|string $type Object type identifier or its constant
@param string $title Object title
@param array $attributes (Optional) additional common attributes
('category', 'purpose', 'cmdb_status', 'description')
@return int Object identifier
@throws Exception on error | [
"Create",
"new",
"object",
"or",
"fetch",
"existing",
"one",
"based",
"on",
"its",
"title",
"and",
"type"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObject.php#L413-L439 | train |
bheisig/i-doit-api-client-php | src/CheckMKTags.php | CheckMKTags.batchRead | public function batchRead(array $objectIDs) {
$requests = [];
foreach ($objectIDs as $objectID) {
if (!is_int($objectID) || $objectID <= 0) {
throw new BadMethodCallException('Invalid object identifiers');
}
$requests[] = [
'method' => 'checkmk.tags.read',
'params' => [
'objID' => $objectID
]
];
}
return $this->api->batchRequest($requests);
} | php | public function batchRead(array $objectIDs) {
$requests = [];
foreach ($objectIDs as $objectID) {
if (!is_int($objectID) || $objectID <= 0) {
throw new BadMethodCallException('Invalid object identifiers');
}
$requests[] = [
'method' => 'checkmk.tags.read',
'params' => [
'objID' => $objectID
]
];
}
return $this->api->batchRequest($requests);
} | [
"public",
"function",
"batchRead",
"(",
"array",
"$",
"objectIDs",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objectIDs",
"as",
"$",
"objectID",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"objectID",
")",
"||",
"$",
"ob... | Read host tags for one or more objects
@param array $objectIDs List of object identifiers as integers
@return array
@throws Exception on error | [
"Read",
"host",
"tags",
"for",
"one",
"or",
"more",
"objects"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CheckMKTags.php#L62-L79 | train |
bheisig/i-doit-api-client-php | src/CMDBReports.php | CMDBReports.read | public function read($reportID) {
$result = $this->api->request(
'cmdb.reports',
[
'id' => $reportID
]
);
if (!is_array($result)) {
return [];
}
return $result;
} | php | public function read($reportID) {
$result = $this->api->request(
'cmdb.reports',
[
'id' => $reportID
]
);
if (!is_array($result)) {
return [];
}
return $result;
} | [
"public",
"function",
"read",
"(",
"$",
"reportID",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'cmdb.reports'",
",",
"[",
"'id'",
"=>",
"$",
"reportID",
"]",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"resul... | Fetches the result of a report
@param int $reportID Report identifier
@return array
@throws Exception on error | [
"Fetches",
"the",
"result",
"of",
"a",
"report"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBReports.php#L56-L69 | train |
bheisig/i-doit-api-client-php | src/CMDBReports.php | CMDBReports.batchRead | public function batchRead(array $reportIDs) {
$requests = [];
foreach ($reportIDs as $reportID) {
$requests[] = [
'method' => 'cmdb.reports',
'params' => [
'id' => $reportID
]
];
}
$batchResults = $this->api->batchRequest($requests);
$results = [];
foreach ($batchResults as $result) {
if (is_array($result)) {
$results[] = $result;
} else {
$results[] = [];
}
}
return $results;
} | php | public function batchRead(array $reportIDs) {
$requests = [];
foreach ($reportIDs as $reportID) {
$requests[] = [
'method' => 'cmdb.reports',
'params' => [
'id' => $reportID
]
];
}
$batchResults = $this->api->batchRequest($requests);
$results = [];
foreach ($batchResults as $result) {
if (is_array($result)) {
$results[] = $result;
} else {
$results[] = [];
}
}
return $results;
} | [
"public",
"function",
"batchRead",
"(",
"array",
"$",
"reportIDs",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"reportIDs",
"as",
"$",
"reportID",
")",
"{",
"$",
"requests",
"[",
"]",
"=",
"[",
"'method'",
"=>",
"'cmdb.reports'"... | Fetches the result of one or more reports
@param array $reportIDs List of report identifiers as integers
@return array Indexed array of arrays
@throws Exception on error | [
"Fetches",
"the",
"result",
"of",
"one",
"or",
"more",
"reports"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBReports.php#L80-L104 | train |
PrestaShop/welcome | OnBoarding/Configuration.php | Configuration.generateSfBaseUrl | protected function generateSfBaseUrl(Router $router, $controller, $fakeParameters = [])
{
$url = $router->getGenerator()->generate($controller, $fakeParameters);
$url = substr($url, strlen(basename(__PS_BASE_URI__)) + 1);
$url = str_replace('/' . basename(_PS_ADMIN_DIR_) . '/', '', $url);
$url = str_replace(array_values($fakeParameters), '.+', $url);
return $url;
} | php | protected function generateSfBaseUrl(Router $router, $controller, $fakeParameters = [])
{
$url = $router->getGenerator()->generate($controller, $fakeParameters);
$url = substr($url, strlen(basename(__PS_BASE_URI__)) + 1);
$url = str_replace('/' . basename(_PS_ADMIN_DIR_) . '/', '', $url);
$url = str_replace(array_values($fakeParameters), '.+', $url);
return $url;
} | [
"protected",
"function",
"generateSfBaseUrl",
"(",
"Router",
"$",
"router",
",",
"$",
"controller",
",",
"$",
"fakeParameters",
"=",
"[",
"]",
")",
"{",
"$",
"url",
"=",
"$",
"router",
"->",
"getGenerator",
"(",
")",
"->",
"generate",
"(",
"$",
"controll... | generate url pattern to recognize the route as the current step url
here we replace the route specific parameters with wildcard to allow regexp matching
@param \PrestaShopBundle\Service\Routing\Router $router
@param $controller
@param array $fakeParameters
@return mixed|string | [
"generate",
"url",
"pattern",
"to",
"recognize",
"the",
"route",
"as",
"the",
"current",
"step",
"url",
"here",
"we",
"replace",
"the",
"route",
"specific",
"parameters",
"with",
"wildcard",
"to",
"allow",
"regexp",
"matching"
] | a0ad26a5fdeb0311e1aea1a42be3d9c74e889a50 | https://github.com/PrestaShop/welcome/blob/a0ad26a5fdeb0311e1aea1a42be3d9c74e889a50/OnBoarding/Configuration.php#L285-L294 | train |
bheisig/i-doit-api-client-php | src/API.php | API.login | public function login() {
if ($this->isLoggedIn()) {
throw new BadMethodCallException('Client is already logged-in.');
}
// Auto-connect:
if ($this->isConnected() === false) {
$this->connect();
}
$response = $this->request(
'idoit.login'
);
if (!array_key_exists('session-id', $response)) {
throw new RuntimeException('Failed to login because i-doit responded without a session ID');
}
$this->session = $response['session-id'];
return $this;
} | php | public function login() {
if ($this->isLoggedIn()) {
throw new BadMethodCallException('Client is already logged-in.');
}
// Auto-connect:
if ($this->isConnected() === false) {
$this->connect();
}
$response = $this->request(
'idoit.login'
);
if (!array_key_exists('session-id', $response)) {
throw new RuntimeException('Failed to login because i-doit responded without a session ID');
}
$this->session = $response['session-id'];
return $this;
} | [
"public",
"function",
"login",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isLoggedIn",
"(",
")",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'Client is already logged-in.'",
")",
";",
"}",
"// Auto-connect:",
"if",
"(",
"$",
"this",
"->",
... | Logins to API
@return self Returns itself
@throws Exception on error | [
"Logins",
"to",
"API"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/API.php#L365-L386 | train |
bheisig/i-doit-api-client-php | src/API.php | API.logout | public function logout() {
if ($this->isLoggedIn() === false) {
throw new BadMethodCallException('Client is not logged-in.');
}
$this->request(
'idoit.logout'
);
$this->session = null;
return $this;
} | php | public function logout() {
if ($this->isLoggedIn() === false) {
throw new BadMethodCallException('Client is not logged-in.');
}
$this->request(
'idoit.logout'
);
$this->session = null;
return $this;
} | [
"public",
"function",
"logout",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isLoggedIn",
"(",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'Client is not logged-in.'",
")",
";",
"}",
"$",
"this",
"->",
"request",
"(",
... | Logouts from API
@return self Returns itself
@throws Exception on error | [
"Logouts",
"from",
"API"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/API.php#L395-L407 | train |
bheisig/i-doit-api-client-php | src/API.php | API.request | public function request($method, array $params = []) {
$data = [
'version' => '2.0',
'method' => $method,
'params' => $params,
'id' => $this->genID()
];
$data['params']['apikey'] = $this->config[self::KEY];
if (array_key_exists(self::LANGUAGE, $this->config) &&
!array_key_exists(self::LANGUAGE, $params)) {
$data['params'][self::LANGUAGE] = $this->config[self::LANGUAGE];
}
$response = $this->execute($data);
$this->evaluateResponse($response);
return $response['result'];
} | php | public function request($method, array $params = []) {
$data = [
'version' => '2.0',
'method' => $method,
'params' => $params,
'id' => $this->genID()
];
$data['params']['apikey'] = $this->config[self::KEY];
if (array_key_exists(self::LANGUAGE, $this->config) &&
!array_key_exists(self::LANGUAGE, $params)) {
$data['params'][self::LANGUAGE] = $this->config[self::LANGUAGE];
}
$response = $this->execute($data);
$this->evaluateResponse($response);
return $response['result'];
} | [
"public",
"function",
"request",
"(",
"$",
"method",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"[",
"'version'",
"=>",
"'2.0'",
",",
"'method'",
"=>",
"$",
"method",
",",
"'params'",
"=>",
"$",
"params",
",",
"'id'",
"... | Sends request to API
@param string $method JSON-RPC method
@param array $params Optional parameters
@return array Result of request
@throws Exception on error | [
"Sends",
"request",
"to",
"API"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/API.php#L439-L459 | train |
bheisig/i-doit-api-client-php | src/API.php | API.batchRequest | public function batchRequest(array $requests) {
$data = [];
foreach ($requests as $request) {
if (!array_key_exists('method', $request)) {
throw new BadMethodCallException(
'Missing method in one of the sub-requests of this batch request'
);
}
$params = [];
if (array_key_exists('params', $request)) {
$params = $request['params'];
}
$params['apikey'] = $this->config[self::KEY];
if (array_key_exists(self::LANGUAGE, $this->config)) {
$params[self::LANGUAGE] = $this->config[self::LANGUAGE];
}
$data[] = [
'version' => '2.0',
'method' => $request['method'],
'params' => $params,
'id' => $this->genID()
];
}
$responses = $this->execute($data);
$results = [];
foreach ($responses as $response) {
if (!is_array($response)) {
throw new RuntimeException(sprintf(
'Found invalid result for request in batch: %s',
$response
));
}
$this->evaluateResponse($response);
$results[] = $response['result'];
}
return $results;
} | php | public function batchRequest(array $requests) {
$data = [];
foreach ($requests as $request) {
if (!array_key_exists('method', $request)) {
throw new BadMethodCallException(
'Missing method in one of the sub-requests of this batch request'
);
}
$params = [];
if (array_key_exists('params', $request)) {
$params = $request['params'];
}
$params['apikey'] = $this->config[self::KEY];
if (array_key_exists(self::LANGUAGE, $this->config)) {
$params[self::LANGUAGE] = $this->config[self::LANGUAGE];
}
$data[] = [
'version' => '2.0',
'method' => $request['method'],
'params' => $params,
'id' => $this->genID()
];
}
$responses = $this->execute($data);
$results = [];
foreach ($responses as $response) {
if (!is_array($response)) {
throw new RuntimeException(sprintf(
'Found invalid result for request in batch: %s',
$response
));
}
$this->evaluateResponse($response);
$results[] = $response['result'];
}
return $results;
} | [
"public",
"function",
"batchRequest",
"(",
"array",
"$",
"requests",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"requests",
"as",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"'method'",
",",
"$",
"request",
... | Performs multiple requests to API at once
@param array $requests Batch requests with 'method' and optional 'params'
@return array Result of request
@throws Exception on error | [
"Performs",
"multiple",
"requests",
"to",
"API",
"at",
"once"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/API.php#L470-L518 | train |
bheisig/i-doit-api-client-php | src/API.php | API.execute | protected function execute(array $data) {
// Auto-connect:
if ($this->isConnected() === false) {
$this->connect();
}
$this->lastRequestContent = $data;
$dataAsString = json_encode($data);
$options = $this->options;
$options[CURLOPT_POSTFIELDS] = $dataAsString;
if (isset($this->session)) {
$options[CURLOPT_HTTPHEADER][] = 'X-RPC-Auth-Session: ' . $this->session;
} elseif (array_key_exists(self::USERNAME, $this->config) &&
is_string($this->config[self::USERNAME]) &&
!empty($this->config[self::USERNAME]) &&
array_key_exists(self::PASSWORD, $this->config) &&
is_string($this->config[self::PASSWORD]) &&
!empty($this->config[self::PASSWORD])) {
$options[CURLOPT_HTTPHEADER][] = 'X-RPC-Auth-Username: ' . $this->config[self::USERNAME];
$options[CURLOPT_HTTPHEADER][] = 'X-RPC-Auth-Password: ' . $this->config[self::PASSWORD];
}
curl_setopt_array($this->resource, $options);
$responseString = curl_exec($this->resource);
$this->lastInfo = curl_getinfo($this->resource);
if ($responseString === false) {
switch ($this->lastInfo['http_code']) {
case 0:
$message = curl_error($this->resource);
if (strlen($message) === 0) {
$message = 'Connection to Web server failed';
}
throw new RuntimeException($message);
default:
throw new RuntimeException(sprintf(
'Web server responded with HTTP status code "%s"',
$this->lastInfo['http_code']
));
}
} elseif (!is_string($responseString)) {
throw new RuntimeException('No content from Web server');
}
$headerLength = curl_getinfo($this->resource, CURLINFO_HEADER_SIZE);
$this->lastResponseHeaders = substr($responseString, 0, $headerLength);
$body = substr($responseString, $headerLength);
$lastResponse = json_decode(trim($body), true);
if (!is_array($lastResponse)) {
if (is_string($body) && strlen($body) > 0) {
throw new RuntimeException(sprintf(
'i-doit responded with an unknown message: %s',
$body
));
} else {
throw new RuntimeException('i-doit responded with an invalid JSON string.');
}
}
$this->lastResponse = $lastResponse;
return $this->lastResponse;
} | php | protected function execute(array $data) {
// Auto-connect:
if ($this->isConnected() === false) {
$this->connect();
}
$this->lastRequestContent = $data;
$dataAsString = json_encode($data);
$options = $this->options;
$options[CURLOPT_POSTFIELDS] = $dataAsString;
if (isset($this->session)) {
$options[CURLOPT_HTTPHEADER][] = 'X-RPC-Auth-Session: ' . $this->session;
} elseif (array_key_exists(self::USERNAME, $this->config) &&
is_string($this->config[self::USERNAME]) &&
!empty($this->config[self::USERNAME]) &&
array_key_exists(self::PASSWORD, $this->config) &&
is_string($this->config[self::PASSWORD]) &&
!empty($this->config[self::PASSWORD])) {
$options[CURLOPT_HTTPHEADER][] = 'X-RPC-Auth-Username: ' . $this->config[self::USERNAME];
$options[CURLOPT_HTTPHEADER][] = 'X-RPC-Auth-Password: ' . $this->config[self::PASSWORD];
}
curl_setopt_array($this->resource, $options);
$responseString = curl_exec($this->resource);
$this->lastInfo = curl_getinfo($this->resource);
if ($responseString === false) {
switch ($this->lastInfo['http_code']) {
case 0:
$message = curl_error($this->resource);
if (strlen($message) === 0) {
$message = 'Connection to Web server failed';
}
throw new RuntimeException($message);
default:
throw new RuntimeException(sprintf(
'Web server responded with HTTP status code "%s"',
$this->lastInfo['http_code']
));
}
} elseif (!is_string($responseString)) {
throw new RuntimeException('No content from Web server');
}
$headerLength = curl_getinfo($this->resource, CURLINFO_HEADER_SIZE);
$this->lastResponseHeaders = substr($responseString, 0, $headerLength);
$body = substr($responseString, $headerLength);
$lastResponse = json_decode(trim($body), true);
if (!is_array($lastResponse)) {
if (is_string($body) && strlen($body) > 0) {
throw new RuntimeException(sprintf(
'i-doit responded with an unknown message: %s',
$body
));
} else {
throw new RuntimeException('i-doit responded with an invalid JSON string.');
}
}
$this->lastResponse = $lastResponse;
return $this->lastResponse;
} | [
"protected",
"function",
"execute",
"(",
"array",
"$",
"data",
")",
"{",
"// Auto-connect:",
"if",
"(",
"$",
"this",
"->",
"isConnected",
"(",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"}",
"$",
"this",
"->",
"lastRe... | Sends request to API with headers and receives response
@param array $data Payload
@return array Result of request
@throws Exception on error | [
"Sends",
"request",
"to",
"API",
"with",
"headers",
"and",
"receives",
"response"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/API.php#L529-L602 | train |
bheisig/i-doit-api-client-php | src/API.php | API.evaluateResponse | protected function evaluateResponse(array $response) {
if (array_key_exists('error', $response) &&
$response['error'] !== null) {
// Validate error object:
if (!is_array($response['error'])) {
throw new RuntimeException('Invalid error object');
}
if (!array_key_exists('code', $response['error']) ||
!is_int($response['error']['code']) ||
$response['error']['code'] >= 0) {
throw new RuntimeException('Invalid error code');
}
if (!array_key_exists('message', $response['error']) ||
!is_string($response['error']['message']) ||
strlen($response['error']['message']) === 0) {
throw new RuntimeException('Invalid error message');
}
$details = [];
if (array_key_exists('data', $response['error']) &&
is_array($response['error']['data'])) {
foreach ($response['error']['data'] as $topic => $description) {
$text = 'unknown';
switch (gettype($description)) {
case 'array':
$text = implode('; ', $description);
break;
case 'string':
$text = $description;
break;
}
$details[] = sprintf(
'%s: %s',
$topic,
$text
);
}
}
if (count($details) > 0) {
$message = sprintf(
'i-doit responded with an error: %s [%s]',
$response['error']['message'],
implode('; ', $details)
);
} else {
$message = sprintf(
'i-doit responded with an error: %s',
$response['error']['message']
);
}
throw new RuntimeException(
$message,
$response['error']['code']
);
}
if (!array_key_exists('result', $response)) {
throw new RuntimeException('i-doit forgot to add a result to its response.');
}
return $this;
} | php | protected function evaluateResponse(array $response) {
if (array_key_exists('error', $response) &&
$response['error'] !== null) {
// Validate error object:
if (!is_array($response['error'])) {
throw new RuntimeException('Invalid error object');
}
if (!array_key_exists('code', $response['error']) ||
!is_int($response['error']['code']) ||
$response['error']['code'] >= 0) {
throw new RuntimeException('Invalid error code');
}
if (!array_key_exists('message', $response['error']) ||
!is_string($response['error']['message']) ||
strlen($response['error']['message']) === 0) {
throw new RuntimeException('Invalid error message');
}
$details = [];
if (array_key_exists('data', $response['error']) &&
is_array($response['error']['data'])) {
foreach ($response['error']['data'] as $topic => $description) {
$text = 'unknown';
switch (gettype($description)) {
case 'array':
$text = implode('; ', $description);
break;
case 'string':
$text = $description;
break;
}
$details[] = sprintf(
'%s: %s',
$topic,
$text
);
}
}
if (count($details) > 0) {
$message = sprintf(
'i-doit responded with an error: %s [%s]',
$response['error']['message'],
implode('; ', $details)
);
} else {
$message = sprintf(
'i-doit responded with an error: %s',
$response['error']['message']
);
}
throw new RuntimeException(
$message,
$response['error']['code']
);
}
if (!array_key_exists('result', $response)) {
throw new RuntimeException('i-doit forgot to add a result to its response.');
}
return $this;
} | [
"protected",
"function",
"evaluateResponse",
"(",
"array",
"$",
"response",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'error'",
",",
"$",
"response",
")",
"&&",
"$",
"response",
"[",
"'error'",
"]",
"!==",
"null",
")",
"{",
"// Validate error object:",
... | Evaluates server response
@param array $response Server response
@return self Returns itself
@throws Exception on error | [
"Evaluates",
"server",
"response"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/API.php#L613-L681 | train |
bheisig/i-doit-api-client-php | src/API.php | API.rawRequest | public function rawRequest(array $data = [], array $headers = []) {
foreach ($headers as $header => $value) {
$this->options[CURLOPT_HTTPHEADER][] = $header . ': ' . $value;
}
return $this->execute($data);
} | php | public function rawRequest(array $data = [], array $headers = []) {
foreach ($headers as $header => $value) {
$this->options[CURLOPT_HTTPHEADER][] = $header . ': ' . $value;
}
return $this->execute($data);
} | [
"public",
"function",
"rawRequest",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"header",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"options",
... | Perform a low level API request
@param array $data JSON-RPC compatible payload
@param array $headers Additional headers as key-value pairs
@return array Raw response from
@throws Exception on error | [
"Perform",
"a",
"low",
"level",
"API",
"request"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/API.php#L692-L698 | train |
bheisig/i-doit-api-client-php | src/CMDBLocationTree.php | CMDBLocationTree.read | public function read($objectID, $status = null) {
$params = [
'id' => $objectID
];
if (isset($status)) {
$params['status'] = $status;
}
return $this->api->request(
'cmdb.location_tree.read',
$params
);
} | php | public function read($objectID, $status = null) {
$params = [
'id' => $objectID
];
if (isset($status)) {
$params['status'] = $status;
}
return $this->api->request(
'cmdb.location_tree.read',
$params
);
} | [
"public",
"function",
"read",
"(",
"$",
"objectID",
",",
"$",
"status",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"[",
"'id'",
"=>",
"$",
"objectID",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"status",
")",
")",
"{",
"$",
"params",
"[",
"'status'"... | Reads objects located directly under an object
This method does not run recursively. Use readRecursively() instead.
@param int $objectID Object identifier
@param int $status Filter relations by status: 2 = normal, 3 = archived, 4 = deleted
@return array
@throws Exception on error | [
"Reads",
"objects",
"located",
"directly",
"under",
"an",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBLocationTree.php#L47-L60 | train |
bheisig/i-doit-api-client-php | src/CMDBLocationTree.php | CMDBLocationTree.readRecursively | public function readRecursively($objectID, $status = null) {
$children = $this->read($objectID, $status);
$tree = [];
foreach ($children as $child) {
if (!array_key_exists('id', $child)) {
throw new RuntimeException('Broken result');
}
$node = $child;
$childChildren = $this->read((int) $child['id'], $status);
if (count($childChildren) > 0) {
$node['children'] = $childChildren;
}
$tree[] = $node;
}
return $tree;
} | php | public function readRecursively($objectID, $status = null) {
$children = $this->read($objectID, $status);
$tree = [];
foreach ($children as $child) {
if (!array_key_exists('id', $child)) {
throw new RuntimeException('Broken result');
}
$node = $child;
$childChildren = $this->read((int) $child['id'], $status);
if (count($childChildren) > 0) {
$node['children'] = $childChildren;
}
$tree[] = $node;
}
return $tree;
} | [
"public",
"function",
"readRecursively",
"(",
"$",
"objectID",
",",
"$",
"status",
"=",
"null",
")",
"{",
"$",
"children",
"=",
"$",
"this",
"->",
"read",
"(",
"$",
"objectID",
",",
"$",
"status",
")",
";",
"$",
"tree",
"=",
"[",
"]",
";",
"foreach... | Reads recursively objects located under an object
@param int $objectID Object identifier
@param int $status Filter relations by status: 2 = normal, 3 = archived, 4 = deleted
@return array
@throws Exception on error | [
"Reads",
"recursively",
"objects",
"located",
"under",
"an",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBLocationTree.php#L72-L94 | train |
bheisig/i-doit-api-client-php | src/CMDBCategoryInfo.php | CMDBCategoryInfo.batchRead | public function batchRead(array $categories) {
$requests = [];
foreach ($categories as $category) {
$requests[] = [
'method' => 'cmdb.category_info',
'params' => array(
'category' => $category
)
];
}
return $this->api->batchRequest($requests);
} | php | public function batchRead(array $categories) {
$requests = [];
foreach ($categories as $category) {
$requests[] = [
'method' => 'cmdb.category_info',
'params' => array(
'category' => $category
)
];
}
return $this->api->batchRequest($requests);
} | [
"public",
"function",
"batchRead",
"(",
"array",
"$",
"categories",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"categories",
"as",
"$",
"category",
")",
"{",
"$",
"requests",
"[",
"]",
"=",
"[",
"'method'",
"=>",
"'cmdb.categor... | Fetches information about one or more categories
@param array $categories List of category constants as strings
@return array Indexed array of associative arrays
@throws Exception on error | [
"Fetches",
"information",
"about",
"one",
"or",
"more",
"categories"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategoryInfo.php#L62-L75 | train |
bheisig/i-doit-api-client-php | src/CMDBCategoryInfo.php | CMDBCategoryInfo.readAll | public function readAll() {
$cmdbObjectTypes = new CMDBObjectTypes($this->api);
$cmdbObjectTypeCategories = new CMDBObjectTypeCategories($this->api);
$categoryConsts = [];
$objectTypes = $cmdbObjectTypes->read();
$objectTypeIDs = array_map(function ($objectType) {
return (int) $objectType['id'];
}, $objectTypes);
$objectTypeCategoriesBatch = $cmdbObjectTypeCategories->batchReadByID($objectTypeIDs);
$catTypes = ['catg', 'cats'];
foreach ($objectTypeCategoriesBatch as $objectTypeCategories) {
foreach ($catTypes as $catType) {
if (!array_key_exists($catType, $objectTypeCategories)) {
continue;
}
$more = array_map(function ($category) {
return $category['const'];
}, $objectTypeCategories[$catType]);
$categoryConsts = array_merge($categoryConsts, $more);
}
}
$categoryConsts = array_unique($categoryConsts);
$blacklistedCategoryConsts = $this->getVirtualCategoryConstants();
$cleanCategoryConstants = [];
foreach ($categoryConsts as $categoryConstant) {
if (!in_array($categoryConstant, $blacklistedCategoryConsts)) {
$cleanCategoryConstants[] = $categoryConstant;
}
}
sort($cleanCategoryConstants);
$categories = $this->batchRead($cleanCategoryConstants);
$combinedArray = array_combine($cleanCategoryConstants, $categories);
if (!is_array($combinedArray)) {
throw new RuntimeException('Unable to restructure result');
}
return $combinedArray;
} | php | public function readAll() {
$cmdbObjectTypes = new CMDBObjectTypes($this->api);
$cmdbObjectTypeCategories = new CMDBObjectTypeCategories($this->api);
$categoryConsts = [];
$objectTypes = $cmdbObjectTypes->read();
$objectTypeIDs = array_map(function ($objectType) {
return (int) $objectType['id'];
}, $objectTypes);
$objectTypeCategoriesBatch = $cmdbObjectTypeCategories->batchReadByID($objectTypeIDs);
$catTypes = ['catg', 'cats'];
foreach ($objectTypeCategoriesBatch as $objectTypeCategories) {
foreach ($catTypes as $catType) {
if (!array_key_exists($catType, $objectTypeCategories)) {
continue;
}
$more = array_map(function ($category) {
return $category['const'];
}, $objectTypeCategories[$catType]);
$categoryConsts = array_merge($categoryConsts, $more);
}
}
$categoryConsts = array_unique($categoryConsts);
$blacklistedCategoryConsts = $this->getVirtualCategoryConstants();
$cleanCategoryConstants = [];
foreach ($categoryConsts as $categoryConstant) {
if (!in_array($categoryConstant, $blacklistedCategoryConsts)) {
$cleanCategoryConstants[] = $categoryConstant;
}
}
sort($cleanCategoryConstants);
$categories = $this->batchRead($cleanCategoryConstants);
$combinedArray = array_combine($cleanCategoryConstants, $categories);
if (!is_array($combinedArray)) {
throw new RuntimeException('Unable to restructure result');
}
return $combinedArray;
} | [
"public",
"function",
"readAll",
"(",
")",
"{",
"$",
"cmdbObjectTypes",
"=",
"new",
"CMDBObjectTypes",
"(",
"$",
"this",
"->",
"api",
")",
";",
"$",
"cmdbObjectTypeCategories",
"=",
"new",
"CMDBObjectTypeCategories",
"(",
"$",
"this",
"->",
"api",
")",
";",
... | Try to fetch information about all available categories
Ignored:
* Custom categories
* Categories which are not assigned to any object types
Notice: This method causes 3 API calls.
@return array Indexed array of associative arrays
@throws Exception on error | [
"Try",
"to",
"fetch",
"information",
"about",
"all",
"available",
"categories"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategoryInfo.php#L90-L137 | train |
bheisig/i-doit-api-client-php | src/CMDBObjectTypeGroups.php | CMDBObjectTypeGroups.read | public function read($orderBy = null, $sortDirection = null, $limit = null) {
$params = [];
if (isset($orderBy)) {
$params['order_by'] = $orderBy;
}
if (isset($sortDirection)) {
$params['sort'] = $sortDirection;
}
if (isset($limit)) {
$params['limit'] = $limit;
}
return $this->api->request(
'cmdb.object_type_groups.read',
$params
);
} | php | public function read($orderBy = null, $sortDirection = null, $limit = null) {
$params = [];
if (isset($orderBy)) {
$params['order_by'] = $orderBy;
}
if (isset($sortDirection)) {
$params['sort'] = $sortDirection;
}
if (isset($limit)) {
$params['limit'] = $limit;
}
return $this->api->request(
'cmdb.object_type_groups.read',
$params
);
} | [
"public",
"function",
"read",
"(",
"$",
"orderBy",
"=",
"null",
",",
"$",
"sortDirection",
"=",
"null",
",",
"$",
"limit",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"orderBy",
")",
")",
"{",
"$",
"p... | Fetches object type groups
@param string $orderBy Order by 'title', 'status', 'constant' or 'id' optionally; use class constants ORDER_*
@param string $sortDirection Sort ascending or descending optionally; use class constants SORT_*
@param int $limit Limit result set optionally
@return array
@throws Exception on error | [
"Fetches",
"object",
"type",
"groups"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObjectTypeGroups.php#L53-L72 | train |
bheisig/i-doit-api-client-php | src/Idoit.php | Idoit.getAddOns | public function getAddOns() {
$response = $this->api->request('idoit.addons.read');
if (!array_key_exists('result', $response) || !is_array($response['result'])) {
throw new RuntimeException('Bad result');
}
return $response['result'];
} | php | public function getAddOns() {
$response = $this->api->request('idoit.addons.read');
if (!array_key_exists('result', $response) || !is_array($response['result'])) {
throw new RuntimeException('Bad result');
}
return $response['result'];
} | [
"public",
"function",
"getAddOns",
"(",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'idoit.addons.read'",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"'result'",
",",
"$",
"response",
")",
"||",
"!",
"is_array"... | Read information about installed add-ons
@return array Associative array
@throws Exception on error | [
"Read",
"information",
"about",
"installed",
"add",
"-",
"ons"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/Idoit.php#L53-L61 | train |
bheisig/i-doit-api-client-php | src/Idoit.php | Idoit.batchSearch | public function batchSearch(array $queries) {
$requests = [];
foreach ($queries as $query) {
$requests[] = [
'method' => 'idoit.search',
'params' => [
'q' => $query
]
];
}
return $this->api->batchRequest($requests);
} | php | public function batchSearch(array $queries) {
$requests = [];
foreach ($queries as $query) {
$requests[] = [
'method' => 'idoit.search',
'params' => [
'q' => $query
]
];
}
return $this->api->batchRequest($requests);
} | [
"public",
"function",
"batchSearch",
"(",
"array",
"$",
"queries",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"queries",
"as",
"$",
"query",
")",
"{",
"$",
"requests",
"[",
"]",
"=",
"[",
"'method'",
"=>",
"'idoit.search'",
"... | Perform one or more searches at once
@param array $queries Queries as strings
@return array Search results
@throws Exception on error | [
"Perform",
"one",
"or",
"more",
"searches",
"at",
"once"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/Idoit.php#L110-L123 | train |
bheisig/i-doit-api-client-php | src/CMDBObjects.php | CMDBObjects.create | public function create(array $objects) {
$requests = [];
foreach ($objects as $object) {
$requests[] = [
'method' => 'cmdb.object.create',
'params' => $object
];
}
$result = $this->api->batchRequest($requests);
$objectIDs = [];
foreach ($result as $object) {
$objectIDs[] = $object['id'];
}
return $objectIDs;
} | php | public function create(array $objects) {
$requests = [];
foreach ($objects as $object) {
$requests[] = [
'method' => 'cmdb.object.create',
'params' => $object
];
}
$result = $this->api->batchRequest($requests);
$objectIDs = [];
foreach ($result as $object) {
$objectIDs[] = $object['id'];
}
return $objectIDs;
} | [
"public",
"function",
"create",
"(",
"array",
"$",
"objects",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"object",
")",
"{",
"$",
"requests",
"[",
"]",
"=",
"[",
"'method'",
"=>",
"'cmdb.object.create'",
... | Create one or more objects
@param array $objects Mandatory attributes ('type', 'title') and optional attributes
('category', 'purpose', 'cmdb_status', 'description')
@return array List of object identifiers
@throws Exception on error | [
"Create",
"one",
"or",
"more",
"objects"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObjects.php#L59-L78 | train |
bheisig/i-doit-api-client-php | src/CMDBObjects.php | CMDBObjects.readByIDs | public function readByIDs(array $objectIDs, $categories = false) {
$params = [
'filter' => [
'ids' => $objectIDs
]
];
if ($categories !== false) {
$params['categories'] = $categories;
}
return $this->api->request(
'cmdb.objects.read',
$params
);
} | php | public function readByIDs(array $objectIDs, $categories = false) {
$params = [
'filter' => [
'ids' => $objectIDs
]
];
if ($categories !== false) {
$params['categories'] = $categories;
}
return $this->api->request(
'cmdb.objects.read',
$params
);
} | [
"public",
"function",
"readByIDs",
"(",
"array",
"$",
"objectIDs",
",",
"$",
"categories",
"=",
"false",
")",
"{",
"$",
"params",
"=",
"[",
"'filter'",
"=>",
"[",
"'ids'",
"=>",
"$",
"objectIDs",
"]",
"]",
";",
"if",
"(",
"$",
"categories",
"!==",
"f... | Fetch objects by their identifiers
@param array $objectIDs List of object identifiers as integers
@param bool|array $categories Also fetch category entries; add a list of category constants as array of strings
or true for all assigned categories, otherwise false for none; defaults to false
@return array Indexed array of associative arrays
@throws Exception on error | [
"Fetch",
"objects",
"by",
"their",
"identifiers"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObjects.php#L146-L161 | train |
bheisig/i-doit-api-client-php | src/CMDBObjects.php | CMDBObjects.readByType | public function readByType($objectType, $categories = false) {
$params = [
'filter' => [
'type' => $objectType
]
];
if ($categories !== false) {
$params['categories'] = $categories;
}
return $this->api->request(
'cmdb.objects.read',
$params
);
} | php | public function readByType($objectType, $categories = false) {
$params = [
'filter' => [
'type' => $objectType
]
];
if ($categories !== false) {
$params['categories'] = $categories;
}
return $this->api->request(
'cmdb.objects.read',
$params
);
} | [
"public",
"function",
"readByType",
"(",
"$",
"objectType",
",",
"$",
"categories",
"=",
"false",
")",
"{",
"$",
"params",
"=",
"[",
"'filter'",
"=>",
"[",
"'type'",
"=>",
"$",
"objectType",
"]",
"]",
";",
"if",
"(",
"$",
"categories",
"!==",
"false",
... | Fetch objects by their object type
@param string $objectType Object type constant
@param bool|array $categories Also fetch category entries; add a list of category constants as array of strings
or true for all assigned categories, otherwise false for none; defaults to false
@return array Indexed array of associative arrays
@throws Exception on error | [
"Fetch",
"objects",
"by",
"their",
"object",
"type"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObjects.php#L174-L189 | train |
bheisig/i-doit-api-client-php | src/CMDBObjects.php | CMDBObjects.update | public function update(array $objects) {
$requests = [];
foreach ($objects as $object) {
$requests[] = [
'method' => 'cmdb.object.update',
'params' => $object
];
}
$this->api->batchRequest($requests);
return $this;
} | php | public function update(array $objects) {
$requests = [];
foreach ($objects as $object) {
$requests[] = [
'method' => 'cmdb.object.update',
'params' => $object
];
}
$this->api->batchRequest($requests);
return $this;
} | [
"public",
"function",
"update",
"(",
"array",
"$",
"objects",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"object",
")",
"{",
"$",
"requests",
"[",
"]",
"=",
"[",
"'method'",
"=>",
"'cmdb.object.update'",
... | Update one or more existing objects
@param array $objects Indexed array of object attributes ('id' and 'title')
@return self Returns itself
@throws Exception on error | [
"Update",
"one",
"or",
"more",
"existing",
"objects"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObjects.php#L300-L313 | train |
bheisig/i-doit-api-client-php | src/CMDBObjects.php | CMDBObjects.archive | public function archive(array $objectIDs) {
$requests = [];
foreach ($objectIDs as $objectID) {
$requests[] = [
'method' => 'cmdb.object.archive',
'params' => [
'object' => $objectID
]
];
}
$this->api->batchRequest($requests);
return $this;
} | php | public function archive(array $objectIDs) {
$requests = [];
foreach ($objectIDs as $objectID) {
$requests[] = [
'method' => 'cmdb.object.archive',
'params' => [
'object' => $objectID
]
];
}
$this->api->batchRequest($requests);
return $this;
} | [
"public",
"function",
"archive",
"(",
"array",
"$",
"objectIDs",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objectIDs",
"as",
"$",
"objectID",
")",
"{",
"$",
"requests",
"[",
"]",
"=",
"[",
"'method'",
"=>",
"'cmdb.object.arch... | Archive one or more objects
@param array $objectIDs List of object identifiers as integers
@return self Returns itself
@throws Exception on error | [
"Archive",
"one",
"or",
"more",
"objects"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObjects.php#L324-L339 | train |
bheisig/i-doit-api-client-php | src/CMDBObjects.php | CMDBObjects.delete | public function delete(array $objectIDs) {
$requests = [];
foreach ($objectIDs as $objectID) {
$requests[] = [
'method' => 'cmdb.object.delete',
'params' => [
'object' => $objectID
]
];
}
$this->api->batchRequest($requests);
return $this;
} | php | public function delete(array $objectIDs) {
$requests = [];
foreach ($objectIDs as $objectID) {
$requests[] = [
'method' => 'cmdb.object.delete',
'params' => [
'object' => $objectID
]
];
}
$this->api->batchRequest($requests);
return $this;
} | [
"public",
"function",
"delete",
"(",
"array",
"$",
"objectIDs",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objectIDs",
"as",
"$",
"objectID",
")",
"{",
"$",
"requests",
"[",
"]",
"=",
"[",
"'method'",
"=>",
"'cmdb.object.delet... | Delete one or more objects
@param array $objectIDs List of object identifiers as integers
@return self Returns itself
@throws Exception on error | [
"Delete",
"one",
"or",
"more",
"objects"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObjects.php#L350-L365 | train |
bheisig/i-doit-api-client-php | src/CMDBObjects.php | CMDBObjects.purge | public function purge(array $objectIDs) {
$requests = [];
foreach ($objectIDs as $objectID) {
$requests[] = [
'method' => 'cmdb.object.purge',
'params' => [
'object' => $objectID
]
];
}
$this->api->batchRequest($requests);
return $this;
} | php | public function purge(array $objectIDs) {
$requests = [];
foreach ($objectIDs as $objectID) {
$requests[] = [
'method' => 'cmdb.object.purge',
'params' => [
'object' => $objectID
]
];
}
$this->api->batchRequest($requests);
return $this;
} | [
"public",
"function",
"purge",
"(",
"array",
"$",
"objectIDs",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objectIDs",
"as",
"$",
"objectID",
")",
"{",
"$",
"requests",
"[",
"]",
"=",
"[",
"'method'",
"=>",
"'cmdb.object.purge'... | Purge one or more objects
@param array $objectIDs List of object identifiers as integers
@return self Returns itself
@throws Exception on error | [
"Purge",
"one",
"or",
"more",
"objects"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObjects.php#L376-L391 | train |
bheisig/i-doit-api-client-php | src/CMDBObjects.php | CMDBObjects.recycle | public function recycle(array $objectIDs) {
$requests = [];
foreach ($objectIDs as $objectID) {
$requests[] = [
'method' => 'cmdb.object.recycle',
'params' => [
'object' => $objectID
]
];
}
$this->api->batchRequest($requests);
return $this;
} | php | public function recycle(array $objectIDs) {
$requests = [];
foreach ($objectIDs as $objectID) {
$requests[] = [
'method' => 'cmdb.object.recycle',
'params' => [
'object' => $objectID
]
];
}
$this->api->batchRequest($requests);
return $this;
} | [
"public",
"function",
"recycle",
"(",
"array",
"$",
"objectIDs",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objectIDs",
"as",
"$",
"objectID",
")",
"{",
"$",
"requests",
"[",
"]",
"=",
"[",
"'method'",
"=>",
"'cmdb.object.recy... | Restore objects to "normal" status
@param array $objectIDs List of object identifiers as integers
@return self Returns itself
@throws Exception on error | [
"Restore",
"objects",
"to",
"normal",
"status"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObjects.php#L402-L417 | train |
bheisig/i-doit-api-client-php | src/CMDBDialog.php | CMDBDialog.create | public function create($category, $attribute, $value, $parent = null) {
$params = [
'category' => $category,
'property' => $attribute,
'value' => $value
];
if (isset($parent)) {
$params['parent'] = $parent;
}
$result = $this->api->request(
'cmdb.dialog.create',
$params
);
if (!array_key_exists('entry_id', $result) ||
!is_numeric($result['entry_id'])) {
throw new RuntimeException('Bad result');
}
return (int) $result['entry_id'];
} | php | public function create($category, $attribute, $value, $parent = null) {
$params = [
'category' => $category,
'property' => $attribute,
'value' => $value
];
if (isset($parent)) {
$params['parent'] = $parent;
}
$result = $this->api->request(
'cmdb.dialog.create',
$params
);
if (!array_key_exists('entry_id', $result) ||
!is_numeric($result['entry_id'])) {
throw new RuntimeException('Bad result');
}
return (int) $result['entry_id'];
} | [
"public",
"function",
"create",
"(",
"$",
"category",
",",
"$",
"attribute",
",",
"$",
"value",
",",
"$",
"parent",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"[",
"'category'",
"=>",
"$",
"category",
",",
"'property'",
"=>",
"$",
"attribute",
",",
"... | Create a new entry for a drop-down menu
@param string $category Category constant
@param string $attribute Attribute
@param mixed $value Value
@param string|integer $parent Reference parent entry by its title (string) or by its identifier (integer)
@return int Entry identifier
@throws Exception on error | [
"Create",
"a",
"new",
"entry",
"for",
"a",
"drop",
"-",
"down",
"menu"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBDialog.php#L47-L69 | train |
bheisig/i-doit-api-client-php | src/CMDBDialog.php | CMDBDialog.batchCreate | public function batchCreate(array $values) {
$requests = [];
foreach ($values as $category => $keyValuePair) {
foreach ($keyValuePair as $attribute => $mixed) {
$values = [];
if (is_array($mixed)) {
$values = $mixed;
} else {
$values[] = $mixed;
}
foreach ($values as $value) {
$requests[] = [
'method' => 'cmdb.dialog.create',
'params' => [
'category' => $category,
'property' => $attribute,
'value' => $value
]
];
}
}
}
$entryIDs = [];
$entries = $this->api->batchRequest($requests);
foreach ($entries as $entry) {
if (!array_key_exists('entry_id', $entry) ||
!is_numeric($entry['entry_id'])) {
throw new RuntimeException('Bad result');
}
$entryIDs[] = (int) $entry['entry_id'];
}
return $entryIDs;
} | php | public function batchCreate(array $values) {
$requests = [];
foreach ($values as $category => $keyValuePair) {
foreach ($keyValuePair as $attribute => $mixed) {
$values = [];
if (is_array($mixed)) {
$values = $mixed;
} else {
$values[] = $mixed;
}
foreach ($values as $value) {
$requests[] = [
'method' => 'cmdb.dialog.create',
'params' => [
'category' => $category,
'property' => $attribute,
'value' => $value
]
];
}
}
}
$entryIDs = [];
$entries = $this->api->batchRequest($requests);
foreach ($entries as $entry) {
if (!array_key_exists('entry_id', $entry) ||
!is_numeric($entry['entry_id'])) {
throw new RuntimeException('Bad result');
}
$entryIDs[] = (int) $entry['entry_id'];
}
return $entryIDs;
} | [
"public",
"function",
"batchCreate",
"(",
"array",
"$",
"values",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"category",
"=>",
"$",
"keyValuePair",
")",
"{",
"foreach",
"(",
"$",
"keyValuePair",
"as",
"$",
... | Create one or more entries for a drow-down menu
@param array $values Values:
[
'cat' => [
'attr' => 'value', 'attr' => 'value'
],
'cat' => [
'attr' => ['value 1', 'value 2']
]
]
@return array List of entry identifiers
@throws Exception on error
@todo Add support for parameter "parent"! | [
"Create",
"one",
"or",
"more",
"entries",
"for",
"a",
"drow",
"-",
"down",
"menu"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBDialog.php#L90-L130 | train |
bheisig/i-doit-api-client-php | src/CMDBDialog.php | CMDBDialog.batchRead | public function batchRead(array $attributes) {
$requests = [];
foreach ($attributes as $category => $mixed) {
$attributes = [];
if (is_array($mixed)) {
$attributes = $mixed;
} else {
$attributes[] = $mixed;
}
foreach ($attributes as $attribute) {
$requests[] = [
'method' => 'cmdb.dialog.read',
'params' => [
'category' => $category,
'property' => $attribute
]
];
}
}
return $this->api->batchRequest($requests);
} | php | public function batchRead(array $attributes) {
$requests = [];
foreach ($attributes as $category => $mixed) {
$attributes = [];
if (is_array($mixed)) {
$attributes = $mixed;
} else {
$attributes[] = $mixed;
}
foreach ($attributes as $attribute) {
$requests[] = [
'method' => 'cmdb.dialog.read',
'params' => [
'category' => $category,
'property' => $attribute
]
];
}
}
return $this->api->batchRequest($requests);
} | [
"public",
"function",
"batchRead",
"(",
"array",
"$",
"attributes",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"category",
"=>",
"$",
"mixed",
")",
"{",
"$",
"attributes",
"=",
"[",
"]",
";",
"if",
... | Fetch values from one or more drop-down menus
@param array $attributes Attributes: ['cat' => 'attr', 'cat' => ['attr 1', 'attr 2']]
@return array Indexed array of associative arrays
@throws Exception on error | [
"Fetch",
"values",
"from",
"one",
"or",
"more",
"drop",
"-",
"down",
"menus"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBDialog.php#L161-L185 | train |
bheisig/i-doit-api-client-php | src/CMDBDialog.php | CMDBDialog.delete | public function delete($category, $attribute, $entryID) {
$this->api->request(
'cmdb.dialog.delete',
[
'category' => $category,
'property' => $attribute,
'entry_id' => $entryID
]
);
return $this;
} | php | public function delete($category, $attribute, $entryID) {
$this->api->request(
'cmdb.dialog.delete',
[
'category' => $category,
'property' => $attribute,
'entry_id' => $entryID
]
);
return $this;
} | [
"public",
"function",
"delete",
"(",
"$",
"category",
",",
"$",
"attribute",
",",
"$",
"entryID",
")",
"{",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'cmdb.dialog.delete'",
",",
"[",
"'category'",
"=>",
"$",
"category",
",",
"'property'",
"=>",
"$... | Purge value from drop-down menu
@param string $category Category constant
@param string $attribute Attribute
@param int $entryID Entry identifier
@return self Returns itself
@throws Exception on error | [
"Purge",
"value",
"from",
"drop",
"-",
"down",
"menu"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBDialog.php#L198-L209 | train |
bheisig/i-doit-api-client-php | src/CheckMKStaticTag.php | CheckMKStaticTag.create | public function create($title, $tag = null, $group = null, $description = null) {
$params = [
'data' => [
'title' => $title
]
];
if (isset($tag)) {
$params['data']['tag'] = $tag;
}
if (isset($group)) {
$params['data']['group'] = $group;
}
if (isset($group)) {
$params['data']['description'] = $description;
}
$result = $this->api->request(
'checkmk.statictag.create',
$params
);
if (!array_key_exists('id', $result) ||
!is_numeric($result['id']) ||
!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return (int) $result['id'];
} | php | public function create($title, $tag = null, $group = null, $description = null) {
$params = [
'data' => [
'title' => $title
]
];
if (isset($tag)) {
$params['data']['tag'] = $tag;
}
if (isset($group)) {
$params['data']['group'] = $group;
}
if (isset($group)) {
$params['data']['description'] = $description;
}
$result = $this->api->request(
'checkmk.statictag.create',
$params
);
if (!array_key_exists('id', $result) ||
!is_numeric($result['id']) ||
!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return (int) $result['id'];
} | [
"public",
"function",
"create",
"(",
"$",
"title",
",",
"$",
"tag",
"=",
"null",
",",
"$",
"group",
"=",
"null",
",",
"$",
"description",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"[",
"'data'",
"=>",
"[",
"'title'",
"=>",
"$",
"title",
"]",
"]"... | Create a new static host tag
@param string $title Name
@param string $tag Tag ID
@param string $group Optional associated host group
@param string $description Optional description
@return int Identifier
@throws Exception on error | [
"Create",
"a",
"new",
"static",
"host",
"tag"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CheckMKStaticTag.php#L48-L84 | train |
bheisig/i-doit-api-client-php | src/CheckMKStaticTag.php | CheckMKStaticTag.batchCreate | public function batchCreate(array $tags) {
$requests = [];
$required = ['title'];
foreach ($tags as $data) {
foreach ($required as $attribute) {
if (!array_key_exists($attribute, $data)) {
throw new BadMethodCallException(sprintf(
'Missing attribute "%s"',
$attribute
));
}
}
$requests[] = [
'method' => 'checkmk.statictag.create',
'params' => [
'data' => $data
]
];
}
$result = $this->api->batchRequest($requests);
$tagIDs = [];
foreach ($result as $tag) {
// Do not check 'id' because in a batch request it is always NULL:
if (!array_key_exists('success', $tag) ||
$tag['success'] !== true) {
if (array_key_exists('message', $tag)) {
throw new RuntimeException(sprintf('Bad result: %s', $tag['message']));
} else {
throw new RuntimeException('Bad result');
}
}
$tagIDs[] = $tag['id'];
}
return $tagIDs;
} | php | public function batchCreate(array $tags) {
$requests = [];
$required = ['title'];
foreach ($tags as $data) {
foreach ($required as $attribute) {
if (!array_key_exists($attribute, $data)) {
throw new BadMethodCallException(sprintf(
'Missing attribute "%s"',
$attribute
));
}
}
$requests[] = [
'method' => 'checkmk.statictag.create',
'params' => [
'data' => $data
]
];
}
$result = $this->api->batchRequest($requests);
$tagIDs = [];
foreach ($result as $tag) {
// Do not check 'id' because in a batch request it is always NULL:
if (!array_key_exists('success', $tag) ||
$tag['success'] !== true) {
if (array_key_exists('message', $tag)) {
throw new RuntimeException(sprintf('Bad result: %s', $tag['message']));
} else {
throw new RuntimeException('Bad result');
}
}
$tagIDs[] = $tag['id'];
}
return $tagIDs;
} | [
"public",
"function",
"batchCreate",
"(",
"array",
"$",
"tags",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"$",
"required",
"=",
"[",
"'title'",
"]",
";",
"foreach",
"(",
"$",
"tags",
"as",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"required"... | Create one or more static host tags
@param array $tags List of tags;
required attributes per tag: "title";
optional attributes per tag: "tag" (tag ID), "group", "description"
@return array List of identifiers as integers
@throws Exception on error | [
"Create",
"one",
"or",
"more",
"static",
"host",
"tags"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CheckMKStaticTag.php#L97-L139 | train |
bheisig/i-doit-api-client-php | src/CheckMKStaticTag.php | CheckMKStaticTag.deleteAll | public function deleteAll() {
$tags = $this->read();
$ids = [];
foreach ($tags as $tag) {
$ids[] = $tag['id'];
}
if (count($ids) > 0) {
$this->batchDelete($ids);
}
return $this;
} | php | public function deleteAll() {
$tags = $this->read();
$ids = [];
foreach ($tags as $tag) {
$ids[] = $tag['id'];
}
if (count($ids) > 0) {
$this->batchDelete($ids);
}
return $this;
} | [
"public",
"function",
"deleteAll",
"(",
")",
"{",
"$",
"tags",
"=",
"$",
"this",
"->",
"read",
"(",
")",
";",
"$",
"ids",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"tags",
"as",
"$",
"tag",
")",
"{",
"$",
"ids",
"[",
"]",
"=",
"$",
"tag",
"[... | Delete all static host tags
@return self Returns itself
@throws Exception on error | [
"Delete",
"all",
"static",
"host",
"tags"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CheckMKStaticTag.php#L314-L328 | train |
bheisig/i-doit-api-client-php | src/CMDBObjectTypes.php | CMDBObjectTypes.readOne | public function readOne($objectType) {
$result = $this->api->request(
'cmdb.object_types',
[
'filter' => [
'id' => $objectType
],
'countobjects' => true
]
);
return end($result);
} | php | public function readOne($objectType) {
$result = $this->api->request(
'cmdb.object_types',
[
'filter' => [
'id' => $objectType
],
'countobjects' => true
]
);
return end($result);
} | [
"public",
"function",
"readOne",
"(",
"$",
"objectType",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'cmdb.object_types'",
",",
"[",
"'filter'",
"=>",
"[",
"'id'",
"=>",
"$",
"objectType",
"]",
",",
"'countobjects'",
"=... | Fetches information about an object type by its constant
@param string $objectType Object type constant
@return array Associative array
@throws Exception on error | [
"Fetches",
"information",
"about",
"an",
"object",
"type",
"by",
"its",
"constant"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObjectTypes.php#L59-L71 | train |
PrestaShop/welcome | welcome.php | Welcome.install | public function install()
{
return parent::install()
&& $this->installTab()
&& $this->registerHook('displayAdminNavBarBeforeEnd')
&& $this->registerHook('displayAdminAfterHeader')
&& $this->registerHook('displayBackOfficeHeader');
} | php | public function install()
{
return parent::install()
&& $this->installTab()
&& $this->registerHook('displayAdminNavBarBeforeEnd')
&& $this->registerHook('displayAdminAfterHeader')
&& $this->registerHook('displayBackOfficeHeader');
} | [
"public",
"function",
"install",
"(",
")",
"{",
"return",
"parent",
"::",
"install",
"(",
")",
"&&",
"$",
"this",
"->",
"installTab",
"(",
")",
"&&",
"$",
"this",
"->",
"registerHook",
"(",
"'displayAdminNavBarBeforeEnd'",
")",
"&&",
"$",
"this",
"->",
"... | Module installation.
@return bool Success of the installation | [
"Module",
"installation",
"."
] | a0ad26a5fdeb0311e1aea1a42be3d9c74e889a50 | https://github.com/PrestaShop/welcome/blob/a0ad26a5fdeb0311e1aea1a42be3d9c74e889a50/welcome.php#L90-L97 | train |
PrestaShop/welcome | welcome.php | Welcome.hookDisplayBackOfficeHeader | public function hookDisplayBackOfficeHeader()
{
if (!$this->onBoarding->isFinished()) {
$this->context->controller->addCSS($this->_path.'public/module.css', 'all');
$this->context->controller->addJS($this->_path.'public/module.js', 'all');
}
} | php | public function hookDisplayBackOfficeHeader()
{
if (!$this->onBoarding->isFinished()) {
$this->context->controller->addCSS($this->_path.'public/module.css', 'all');
$this->context->controller->addJS($this->_path.'public/module.js', 'all');
}
} | [
"public",
"function",
"hookDisplayBackOfficeHeader",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"onBoarding",
"->",
"isFinished",
"(",
")",
")",
"{",
"$",
"this",
"->",
"context",
"->",
"controller",
"->",
"addCSS",
"(",
"$",
"this",
"->",
"_path"... | Hook called when the backoffice header is displayed. | [
"Hook",
"called",
"when",
"the",
"backoffice",
"header",
"is",
"displayed",
"."
] | a0ad26a5fdeb0311e1aea1a42be3d9c74e889a50 | https://github.com/PrestaShop/welcome/blob/a0ad26a5fdeb0311e1aea1a42be3d9c74e889a50/welcome.php#L140-L146 | train |
PrestaShop/welcome | welcome.php | Welcome.hookDisplayAdminNavBarBeforeEnd | public function hookDisplayAdminNavBarBeforeEnd()
{
if (!$this->onBoarding->isFinished()) {
$this->onBoarding->showModuleContentForNavBar($this->context->link);
}
} | php | public function hookDisplayAdminNavBarBeforeEnd()
{
if (!$this->onBoarding->isFinished()) {
$this->onBoarding->showModuleContentForNavBar($this->context->link);
}
} | [
"public",
"function",
"hookDisplayAdminNavBarBeforeEnd",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"onBoarding",
"->",
"isFinished",
"(",
")",
")",
"{",
"$",
"this",
"->",
"onBoarding",
"->",
"showModuleContentForNavBar",
"(",
"$",
"this",
"->",
"con... | Hook called before the end of the nav bar. | [
"Hook",
"called",
"before",
"the",
"end",
"of",
"the",
"nav",
"bar",
"."
] | a0ad26a5fdeb0311e1aea1a42be3d9c74e889a50 | https://github.com/PrestaShop/welcome/blob/a0ad26a5fdeb0311e1aea1a42be3d9c74e889a50/welcome.php#L161-L166 | train |
PrestaShop/welcome | welcome.php | Welcome.apiCall | public function apiCall($action, $value)
{
switch ($action) {
case 'setCurrentStep':
if (!$this->onBoarding->setCurrentStep($value)) {
throw new Exception('The current step cannot be saved.');
}
break;
case 'setShutDown':
if (!$this->onBoarding->setShutDown($value)) {
throw new Exception('The shut down status cannot be saved.');
}
break;
}
} | php | public function apiCall($action, $value)
{
switch ($action) {
case 'setCurrentStep':
if (!$this->onBoarding->setCurrentStep($value)) {
throw new Exception('The current step cannot be saved.');
}
break;
case 'setShutDown':
if (!$this->onBoarding->setShutDown($value)) {
throw new Exception('The shut down status cannot be saved.');
}
break;
}
} | [
"public",
"function",
"apiCall",
"(",
"$",
"action",
",",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"action",
")",
"{",
"case",
"'setCurrentStep'",
":",
"if",
"(",
"!",
"$",
"this",
"->",
"onBoarding",
"->",
"setCurrentStep",
"(",
"$",
"value",
")",
... | Execute an API like action for the OnBoarding.
@param string $action Action to perform
@param mixed $value Value to assign to the action
@throws Exception | [
"Execute",
"an",
"API",
"like",
"action",
"for",
"the",
"OnBoarding",
"."
] | a0ad26a5fdeb0311e1aea1a42be3d9c74e889a50 | https://github.com/PrestaShop/welcome/blob/a0ad26a5fdeb0311e1aea1a42be3d9c74e889a50/welcome.php#L176-L190 | train |
PrestaShop/welcome | OnBoarding/OnBoarding.php | OnBoarding.showModuleContent | public function showModuleContent()
{
$templates = array();
foreach ($this->configuration['templates'] as $template) {
$templates[] = array(
'name' => $template,
'content' => str_replace(array("\n", "\r", "\t"), "", $this->getTemplateContent("templates/$template")),
);
}
echo $this->getTemplateContent('content', array(
'currentStep' => $this->getCurrentStep(),
'totalSteps' => $this->getTotalSteps(),
'percent_real' => ($this->getCurrentStep() / $this->getTotalSteps()) * 100,
'percent_rounded' => round(($this->getCurrentStep() / $this->getTotalSteps())*100),
'isShutDown' => $this->isShutDown(),
'steps' => $this->configuration['steps'],
'jsonSteps' => json_encode($this->configuration['steps']),
'templates' => $templates,
));
} | php | public function showModuleContent()
{
$templates = array();
foreach ($this->configuration['templates'] as $template) {
$templates[] = array(
'name' => $template,
'content' => str_replace(array("\n", "\r", "\t"), "", $this->getTemplateContent("templates/$template")),
);
}
echo $this->getTemplateContent('content', array(
'currentStep' => $this->getCurrentStep(),
'totalSteps' => $this->getTotalSteps(),
'percent_real' => ($this->getCurrentStep() / $this->getTotalSteps()) * 100,
'percent_rounded' => round(($this->getCurrentStep() / $this->getTotalSteps())*100),
'isShutDown' => $this->isShutDown(),
'steps' => $this->configuration['steps'],
'jsonSteps' => json_encode($this->configuration['steps']),
'templates' => $templates,
));
} | [
"public",
"function",
"showModuleContent",
"(",
")",
"{",
"$",
"templates",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"configuration",
"[",
"'templates'",
"]",
"as",
"$",
"template",
")",
"{",
"$",
"templates",
"[",
"]",
"=",
"arr... | Show the OnBoarding module content. | [
"Show",
"the",
"OnBoarding",
"module",
"content",
"."
] | a0ad26a5fdeb0311e1aea1a42be3d9c74e889a50 | https://github.com/PrestaShop/welcome/blob/a0ad26a5fdeb0311e1aea1a42be3d9c74e889a50/OnBoarding/OnBoarding.php#L63-L83 | train |
PrestaShop/welcome | OnBoarding/OnBoarding.php | OnBoarding.showModuleContentForNavBar | public function showModuleContentForNavBar($link)
{
echo $this->getTemplateContent('navbar', array(
'currentStep' => $this->getCurrentStep(),
'totalSteps' => $this->getTotalSteps(),
'percent_real' => ($this->getCurrentStep() / $this->getTotalSteps()) * 100,
'percent_rounded' => round(($this->getCurrentStep() / $this->getTotalSteps())*100),
'link' => $link->getAdminLink('AdminWelcome'),
));
} | php | public function showModuleContentForNavBar($link)
{
echo $this->getTemplateContent('navbar', array(
'currentStep' => $this->getCurrentStep(),
'totalSteps' => $this->getTotalSteps(),
'percent_real' => ($this->getCurrentStep() / $this->getTotalSteps()) * 100,
'percent_rounded' => round(($this->getCurrentStep() / $this->getTotalSteps())*100),
'link' => $link->getAdminLink('AdminWelcome'),
));
} | [
"public",
"function",
"showModuleContentForNavBar",
"(",
"$",
"link",
")",
"{",
"echo",
"$",
"this",
"->",
"getTemplateContent",
"(",
"'navbar'",
",",
"array",
"(",
"'currentStep'",
"=>",
"$",
"this",
"->",
"getCurrentStep",
"(",
")",
",",
"'totalSteps'",
"=>"... | Show the OnBoarding content for the nav bar. | [
"Show",
"the",
"OnBoarding",
"content",
"for",
"the",
"nav",
"bar",
"."
] | a0ad26a5fdeb0311e1aea1a42be3d9c74e889a50 | https://github.com/PrestaShop/welcome/blob/a0ad26a5fdeb0311e1aea1a42be3d9c74e889a50/OnBoarding/OnBoarding.php#L88-L97 | train |
PrestaShop/welcome | OnBoarding/OnBoarding.php | OnBoarding.loadConfiguration | private function loadConfiguration(Router $router)
{
$configuration = new Configuration($this->translator);
$configuration = $configuration->getConfiguration($router);
foreach ($configuration['steps']['groups'] as &$currentGroup) {
if (isset($currentGroup['title'])) {
$currentGroup['title'] = $this->getTextFromSettings($currentGroup['title']);
}
if (isset($currentGroup['subtitle'])) {
foreach ($currentGroup['subtitle'] as &$subtitle) {
$subtitle = $this->getTextFromSettings($subtitle);
}
}
foreach ($currentGroup['steps'] as &$currentStep) {
$currentStep['text'] = $this->getTextFromSettings($currentStep['text']);
}
}
$this->configuration = $configuration;
} | php | private function loadConfiguration(Router $router)
{
$configuration = new Configuration($this->translator);
$configuration = $configuration->getConfiguration($router);
foreach ($configuration['steps']['groups'] as &$currentGroup) {
if (isset($currentGroup['title'])) {
$currentGroup['title'] = $this->getTextFromSettings($currentGroup['title']);
}
if (isset($currentGroup['subtitle'])) {
foreach ($currentGroup['subtitle'] as &$subtitle) {
$subtitle = $this->getTextFromSettings($subtitle);
}
}
foreach ($currentGroup['steps'] as &$currentStep) {
$currentStep['text'] = $this->getTextFromSettings($currentStep['text']);
}
}
$this->configuration = $configuration;
} | [
"private",
"function",
"loadConfiguration",
"(",
"Router",
"$",
"router",
")",
"{",
"$",
"configuration",
"=",
"new",
"Configuration",
"(",
"$",
"this",
"->",
"translator",
")",
";",
"$",
"configuration",
"=",
"$",
"configuration",
"->",
"getConfiguration",
"(... | Load all the steps with the localized texts.
@param string $configPath Path where the configuration can be loaded | [
"Load",
"all",
"the",
"steps",
"with",
"the",
"localized",
"texts",
"."
] | a0ad26a5fdeb0311e1aea1a42be3d9c74e889a50 | https://github.com/PrestaShop/welcome/blob/a0ad26a5fdeb0311e1aea1a42be3d9c74e889a50/OnBoarding/OnBoarding.php#L138-L158 | train |
PrestaShop/welcome | OnBoarding/OnBoarding.php | OnBoarding.getTemplateContent | private function getTemplateContent($templateName, $additionnalParameters = array())
{
$this->smarty->assign($additionnalParameters);
return $this->module->fetch(__DIR__.'/../views/'.$templateName.'.tpl');
} | php | private function getTemplateContent($templateName, $additionnalParameters = array())
{
$this->smarty->assign($additionnalParameters);
return $this->module->fetch(__DIR__.'/../views/'.$templateName.'.tpl');
} | [
"private",
"function",
"getTemplateContent",
"(",
"$",
"templateName",
",",
"$",
"additionnalParameters",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"smarty",
"->",
"assign",
"(",
"$",
"additionnalParameters",
")",
";",
"return",
"$",
"this",
"->",... | Return a template.
@param string $templateName Template name
@param array $additionnalParameters Additionnal parameters to inject on the Twig template
@return string Parsed template | [
"Return",
"a",
"template",
"."
] | a0ad26a5fdeb0311e1aea1a42be3d9c74e889a50 | https://github.com/PrestaShop/welcome/blob/a0ad26a5fdeb0311e1aea1a42be3d9c74e889a50/OnBoarding/OnBoarding.php#L197-L201 | train |
PrestaShop/welcome | OnBoarding/OnBoarding.php | OnBoarding.getTotalSteps | private function getTotalSteps()
{
$total = 0;
if (null != $this->configuration) {
foreach ($this->configuration['steps']['groups'] as &$group) {
$total += count($group['steps']);
}
}
return $total;
} | php | private function getTotalSteps()
{
$total = 0;
if (null != $this->configuration) {
foreach ($this->configuration['steps']['groups'] as &$group) {
$total += count($group['steps']);
}
}
return $total;
} | [
"private",
"function",
"getTotalSteps",
"(",
")",
"{",
"$",
"total",
"=",
"0",
";",
"if",
"(",
"null",
"!=",
"$",
"this",
"->",
"configuration",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"configuration",
"[",
"'steps'",
"]",
"[",
"'groups'",
"]",
... | Return the steps count.
@return int Steps count | [
"Return",
"the",
"steps",
"count",
"."
] | a0ad26a5fdeb0311e1aea1a42be3d9c74e889a50 | https://github.com/PrestaShop/welcome/blob/a0ad26a5fdeb0311e1aea1a42be3d9c74e889a50/OnBoarding/OnBoarding.php#L218-L229 | train |
bheisig/i-doit-api-client-php | src/CMDBLogbook.php | CMDBLogbook.create | public function create($objectID, $message, $description = null) {
$params = [
'object_id' => $objectID,
'message' => $message
];
if (isset($description)) {
$params['description'] = $description;
}
$result = $this->api->request(
'cmdb.logbook.create',
$params
);
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $this;
} | php | public function create($objectID, $message, $description = null) {
$params = [
'object_id' => $objectID,
'message' => $message
];
if (isset($description)) {
$params['description'] = $description;
}
$result = $this->api->request(
'cmdb.logbook.create',
$params
);
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $this;
} | [
"public",
"function",
"create",
"(",
"$",
"objectID",
",",
"$",
"message",
",",
"$",
"description",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"[",
"'object_id'",
"=>",
"$",
"objectID",
",",
"'message'",
"=>",
"$",
"message",
"]",
";",
"if",
"(",
"is... | Create a new logbook entry
@param int $objectID Object identifier
@param string $message Message
@param string $description (optional) Description
@return self Returns itself
@throws Exception on error | [
"Create",
"a",
"new",
"logbook",
"entry"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBLogbook.php#L46-L71 | train |
bheisig/i-doit-api-client-php | src/CMDBLogbook.php | CMDBLogbook.batchCreate | public function batchCreate($objectID, array $messages) {
$requests = [];
foreach ($messages as $message) {
$requests[] = [
'method' => 'cmdb.logbook.create',
'params' => [
'object_id' => $objectID,
'message' => $message
]
];
}
$this->api->batchRequest($requests);
return $this;
} | php | public function batchCreate($objectID, array $messages) {
$requests = [];
foreach ($messages as $message) {
$requests[] = [
'method' => 'cmdb.logbook.create',
'params' => [
'object_id' => $objectID,
'message' => $message
]
];
}
$this->api->batchRequest($requests);
return $this;
} | [
"public",
"function",
"batchCreate",
"(",
"$",
"objectID",
",",
"array",
"$",
"messages",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"message",
")",
"{",
"$",
"requests",
"[",
"]",
"=",
"[",
"'method'",... | Create one or more logbook entries for a specific object
@param int $objectID Object identifier
@param array $messages List of messages as strings
@return self Returns itself
@throws Exception on error | [
"Create",
"one",
"or",
"more",
"logbook",
"entries",
"for",
"a",
"specific",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBLogbook.php#L83-L99 | train |
bheisig/i-doit-api-client-php | src/CMDBLogbook.php | CMDBLogbook.read | public function read($since = null, $limit = 1000) {
$params = [
'limit' => $limit
];
if (isset($since)) {
$params['since'] = $since;
}
return $this->api->request(
'cmdb.logbook.read',
$params
);
} | php | public function read($since = null, $limit = 1000) {
$params = [
'limit' => $limit
];
if (isset($since)) {
$params['since'] = $since;
}
return $this->api->request(
'cmdb.logbook.read',
$params
);
} | [
"public",
"function",
"read",
"(",
"$",
"since",
"=",
"null",
",",
"$",
"limit",
"=",
"1000",
")",
"{",
"$",
"params",
"=",
"[",
"'limit'",
"=>",
"$",
"limit",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"since",
")",
")",
"{",
"$",
"params",
"[",
... | Fetch all logbook entries
@param string $since Optional list only entries since a specific date; supports everything which can be parsed
by strtotime()
@param int $limit Limit number of entries; defaults to 1000
@return array Indexed array of associative arrays
@throws Exception on error | [
"Fetch",
"all",
"logbook",
"entries"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBLogbook.php#L112-L125 | train |
bheisig/i-doit-api-client-php | src/CMDBLogbook.php | CMDBLogbook.readByObject | public function readByObject($objectID, $since = null, $limit = 1000) {
$params = [
'object_id' => $objectID,
'limit' => $limit
];
if (isset($since)) {
$params['since'] = $since;
}
return $this->api->request(
'cmdb.logbook.read',
$params
);
} | php | public function readByObject($objectID, $since = null, $limit = 1000) {
$params = [
'object_id' => $objectID,
'limit' => $limit
];
if (isset($since)) {
$params['since'] = $since;
}
return $this->api->request(
'cmdb.logbook.read',
$params
);
} | [
"public",
"function",
"readByObject",
"(",
"$",
"objectID",
",",
"$",
"since",
"=",
"null",
",",
"$",
"limit",
"=",
"1000",
")",
"{",
"$",
"params",
"=",
"[",
"'object_id'",
"=>",
"$",
"objectID",
",",
"'limit'",
"=>",
"$",
"limit",
"]",
";",
"if",
... | Fetch all logbook entries for a specific object
@param int $objectID Object identifier
@param string $since Optional list only entries since a specific date; supports everything which can be parsed by
strtotime()
@param int $limit Limit number of entries; defaults to 1000
@return array Indexed array of associative arrays
@throws Exception on error | [
"Fetch",
"all",
"logbook",
"entries",
"for",
"a",
"specific",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBLogbook.php#L139-L153 | train |
mhirdes/go_maps_ext | Classes/Domain/Model/Map.php | Map.getTravelModes | public function getTravelModes()
{
$travelModes = [];
for ($i = 0; $i <= 4; $i++) {
$travelModes[$i] = LocalizationUtility::translate(
'tx_gomapsext_domain_model_map.travel_mode.' . $i,
'go_maps_ext'
);
}
return $travelModes;
} | php | public function getTravelModes()
{
$travelModes = [];
for ($i = 0; $i <= 4; $i++) {
$travelModes[$i] = LocalizationUtility::translate(
'tx_gomapsext_domain_model_map.travel_mode.' . $i,
'go_maps_ext'
);
}
return $travelModes;
} | [
"public",
"function",
"getTravelModes",
"(",
")",
"{",
"$",
"travelModes",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<=",
"4",
";",
"$",
"i",
"++",
")",
"{",
"$",
"travelModes",
"[",
"$",
"i",
"]",
"=",
"LocalizationUt... | Returns the travelModes
@return \array $travelModes | [
"Returns",
"the",
"travelModes"
] | fc464d2ec4838add7748b4273e7f8b2a458aad79 | https://github.com/mhirdes/go_maps_ext/blob/fc464d2ec4838add7748b4273e7f8b2a458aad79/Classes/Domain/Model/Map.php#L1208-L1219 | train |
mhirdes/go_maps_ext | Classes/Domain/Model/Map.php | Map.getUnitSystems | public function getUnitSystems()
{
for ($i = 2; $i <= 3; $i++) {
$unitSystems[$i] = LocalizationUtility::translate(
'tx_gomapsext_domain_model_map.unit_system.' . $i,
'go_maps_ext'
);
}
return $unitSystems;
} | php | public function getUnitSystems()
{
for ($i = 2; $i <= 3; $i++) {
$unitSystems[$i] = LocalizationUtility::translate(
'tx_gomapsext_domain_model_map.unit_system.' . $i,
'go_maps_ext'
);
}
return $unitSystems;
} | [
"public",
"function",
"getUnitSystems",
"(",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"2",
";",
"$",
"i",
"<=",
"3",
";",
"$",
"i",
"++",
")",
"{",
"$",
"unitSystems",
"[",
"$",
"i",
"]",
"=",
"LocalizationUtility",
"::",
"translate",
"(",
"'tx_gomapse... | Returns the unitSystems
@return \array $unitSystems | [
"Returns",
"the",
"unitSystems"
] | fc464d2ec4838add7748b4273e7f8b2a458aad79 | https://github.com/mhirdes/go_maps_ext/blob/fc464d2ec4838add7748b4273e7f8b2a458aad79/Classes/Domain/Model/Map.php#L1226-L1236 | train |
mhirdes/go_maps_ext | Classes/Domain/Model/Address.php | Address.initStorageObjects | protected function initStorageObjects()
{
/**
* Do not modify this method!
* It will be rewritten on each save in the extension builder
* You may modify the constructor of this class instead
*/
$this->infoWindowImages = new ObjectStorage();
$this->categories = new ObjectStorage();
$this->map = new ObjectStorage();
} | php | protected function initStorageObjects()
{
/**
* Do not modify this method!
* It will be rewritten on each save in the extension builder
* You may modify the constructor of this class instead
*/
$this->infoWindowImages = new ObjectStorage();
$this->categories = new ObjectStorage();
$this->map = new ObjectStorage();
} | [
"protected",
"function",
"initStorageObjects",
"(",
")",
"{",
"/**\n * Do not modify this method!\n * It will be rewritten on each save in the extension builder\n * You may modify the constructor of this class instead\n */",
"$",
"this",
"->",
"infoWindowImages",
... | Initializes all \TYPO3\CMS\Extbase\Persistence\ObjectStorage properties.
@return void | [
"Initializes",
"all",
"\\",
"TYPO3",
"\\",
"CMS",
"\\",
"Extbase",
"\\",
"Persistence",
"\\",
"ObjectStorage",
"properties",
"."
] | fc464d2ec4838add7748b4273e7f8b2a458aad79 | https://github.com/mhirdes/go_maps_ext/blob/fc464d2ec4838add7748b4273e7f8b2a458aad79/Classes/Domain/Model/Address.php#L180-L190 | train |
mhirdes/go_maps_ext | Classes/Domain/Repository/AddressRepository.php | AddressRepository.findAllAddresses | public function findAllAddresses(Map $map, $pid)
{
$query = $this->createQuery();
$query->getQuerySettings()->setRespectStoragePage(false);
$query->getQuerySettings()->setRespectSysLanguage(false);
$or = [];
$and = [];
foreach (explode(',', $pid) as $p) {
$or[] = $query->equals('pid', $p);
}
if ($map) {
$or[] = $query->contains('map', $map);
}
$and[] = $query->logicalOr($or);
return $query->matching(
$query->logicalAnd(
$and
)
)
->execute();
} | php | public function findAllAddresses(Map $map, $pid)
{
$query = $this->createQuery();
$query->getQuerySettings()->setRespectStoragePage(false);
$query->getQuerySettings()->setRespectSysLanguage(false);
$or = [];
$and = [];
foreach (explode(',', $pid) as $p) {
$or[] = $query->equals('pid', $p);
}
if ($map) {
$or[] = $query->contains('map', $map);
}
$and[] = $query->logicalOr($or);
return $query->matching(
$query->logicalAnd(
$and
)
)
->execute();
} | [
"public",
"function",
"findAllAddresses",
"(",
"Map",
"$",
"map",
",",
"$",
"pid",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"createQuery",
"(",
")",
";",
"$",
"query",
"->",
"getQuerySettings",
"(",
")",
"->",
"setRespectStoragePage",
"(",
"false"... | Finds all addresses by the specified map or the storage pid
@param \Clickstorm\GoMapsExt\Domain\Model\Map $map The map
@param int $pid The Storage Pid
@return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface The addresses
@throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException | [
"Finds",
"all",
"addresses",
"by",
"the",
"specified",
"map",
"or",
"the",
"storage",
"pid"
] | fc464d2ec4838add7748b4273e7f8b2a458aad79 | https://github.com/mhirdes/go_maps_ext/blob/fc464d2ec4838add7748b4273e7f8b2a458aad79/Classes/Domain/Repository/AddressRepository.php#L47-L70 | train |
zencoder/zencoder-php | Services/Zencoder/Jobs.php | Services_Zencoder_Jobs.index | public function index($args = array(), $params = array()) {
$jobs = $this->proxy->retrieveData("jobs.json", $args, $params);
$results = array();
foreach($jobs as $job) $results[] = new Services_Zencoder_Job($job);
return $results;
} | php | public function index($args = array(), $params = array()) {
$jobs = $this->proxy->retrieveData("jobs.json", $args, $params);
$results = array();
foreach($jobs as $job) $results[] = new Services_Zencoder_Job($job);
return $results;
} | [
"public",
"function",
"index",
"(",
"$",
"args",
"=",
"array",
"(",
")",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"jobs",
"=",
"$",
"this",
"->",
"proxy",
"->",
"retrieveData",
"(",
"\"jobs.json\"",
",",
"$",
"args",
",",
"$",
"... | List all jobs on your account
@param array $args Array of filters to use when loading index
@param array $params Optional overrides
@return array An array of Services_Zencoder_Job objects | [
"List",
"all",
"jobs",
"on",
"your",
"account"
] | a945431352da25357dc3f82b0dc13625a142d2e1 | https://github.com/zencoder/zencoder-php/blob/a945431352da25357dc3f82b0dc13625a142d2e1/Services/Zencoder/Jobs.php#L47-L52 | train |
zencoder/zencoder-php | Services/Zencoder/Accounts.php | Services_Zencoder_Accounts.create | public function create($account = NULL, $params = array()) {
if(is_string($account)) {
$json = trim($account);
} else if(is_array($account)) {
$json = json_encode($account);
} else {
throw new Services_Zencoder_Exception(
'Account parameters required to create account.');
}
return new Services_Zencoder_Account($this->proxy->createData("account", $json, $params));
} | php | public function create($account = NULL, $params = array()) {
if(is_string($account)) {
$json = trim($account);
} else if(is_array($account)) {
$json = json_encode($account);
} else {
throw new Services_Zencoder_Exception(
'Account parameters required to create account.');
}
return new Services_Zencoder_Account($this->proxy->createData("account", $json, $params));
} | [
"public",
"function",
"create",
"(",
"$",
"account",
"=",
"NULL",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"account",
")",
")",
"{",
"$",
"json",
"=",
"trim",
"(",
"$",
"account",
")",
";",
"}",
"e... | Create a Zencoder account
@param array $account Array of attributes to use when creating the account
@param array $params Optional overrides
@return Services_Zencoder_Account The object representation of the resource | [
"Create",
"a",
"Zencoder",
"account"
] | a945431352da25357dc3f82b0dc13625a142d2e1 | https://github.com/zencoder/zencoder-php/blob/a945431352da25357dc3f82b0dc13625a142d2e1/Services/Zencoder/Accounts.php#L23-L33 | train |
zencoder/zencoder-php | Services/Zencoder/Notifications.php | Services_Zencoder_Notifications.parseIncoming | public function parseIncoming()
{
$incoming_data = json_decode(trim(file_get_contents('php://input')));
if (!$incoming_data) {
throw new Services_Zencoder_Exception(
'Unable to parse notification data: ' . file_get_contents('php://input'));
}
return new Services_Zencoder_Notification($incoming_data);
} | php | public function parseIncoming()
{
$incoming_data = json_decode(trim(file_get_contents('php://input')));
if (!$incoming_data) {
throw new Services_Zencoder_Exception(
'Unable to parse notification data: ' . file_get_contents('php://input'));
}
return new Services_Zencoder_Notification($incoming_data);
} | [
"public",
"function",
"parseIncoming",
"(",
")",
"{",
"$",
"incoming_data",
"=",
"json_decode",
"(",
"trim",
"(",
"file_get_contents",
"(",
"'php://input'",
")",
")",
")",
";",
"if",
"(",
"!",
"$",
"incoming_data",
")",
"{",
"throw",
"new",
"Services_Zencode... | Parse and process incoming notifications from Zencoder
@return Services_Zencoder_Notification Parsed notification data | [
"Parse",
"and",
"process",
"incoming",
"notifications",
"from",
"Zencoder"
] | a945431352da25357dc3f82b0dc13625a142d2e1 | https://github.com/zencoder/zencoder-php/blob/a945431352da25357dc3f82b0dc13625a142d2e1/Services/Zencoder/Notifications.php#L20-L28 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.