GizmoAPI
Gizmo Application Management Platform API wrapper for PHP., (*1)
Installation
- Install composer
On Linux / Unix / OSX: curl -sS https://getcomposer.org/installer | php, (*2)
On Windows: https://getcomposer.org/Composer-Setup.exe, (*3)
Or follow instructions on https://getcomposer.org/doc/00-intro.md, (*4)
- Install the package
composer require pisa\gizmo-api
Usage
The full API documentation at wiki, (*5)
Quick usage
<?php
require_once 'vendor/autoload.php';
use Pisa\GizmoAPI\Gizmo;
$gizmo = new Gizmo([
'http' => [
'base_uri' => 'http://url_to_gizmo_api_here:8080',
'auth' => ['username', 'password'],
],
]);
$host = $gizmo->hosts->get(1); // Gets the host model with id 1
$user = $gizmo->users->get(1); // Gets the user model with id 1
Repositories
- HostRepository:
$gizmo->hosts
- NewsRepository:
$gizmo->news
- ServiceRepository:
$gizmo->service
- SessionRepository:
$gizmo->sessions
- UserRepository:
$gizmo->users
HostRepository methods
all([integer $limit = 30], [integer $skip = 0], [string $orderBy = NULL]): Get all model instances from repository, (*6)
findBy(array $criteria, [boolean $caseSensitive = false], [integer $limit = 30], [integer $skip = 0], [string $orderBy = NULL]): Finds model instances by parameters, (*7)
findOneBy(array $criteria, [boolean $caseSensitive = false]): Find one model entry by parameters, (*8)
get(integer $id): Get model by id, (*9)
getByNumber(integer $hostNumber): Gets hosts by number, (*10)
has(integer $id): Check if model entry exists., (*11)
NewsRepository methods
all([integer $limit = 30], [integer $skip = 0], [string $orderBy = NULL]): Get all model instances from repository, (*12)
findBy(array $criteria, [boolean $caseSensitive = false], [integer $limit = 30], [integer $skip = 0], [string $orderBy = NULL]): Finds model instances by parameters, (*13)
findOneBy(array $criteria, [boolean $caseSensitive = false]): Find one model entry by parameters, (*14)
get(integer $id): Get model by id, (*15)
has(integer $id): Check if model entry exists., (*16)
ServiceRepository methods
getTime(): Returns current system time., (*17)
stop(): Stops the service, (*18)
restart(): Restarts the service, (*19)
getStatus(): Returns status of the service, (*20)
getVersion(): Returns the service version, (*21)
getModule(): Returns the service module information, (*22)
getLicense(): Returns license information, (*23)
getHardwareId(): Returns hardware id, (*24)
getSettings(): Returns the service settings, (*25)
SessionRepository methods
all([integer $limit = 30], [integer $skip = 0], [string $orderBy = NULL]): Get all model instances from repository, (*26)
findActiveBy(array $criteria, [boolean $caseSensitive = false], [integer $limit = 30], [integer $skip = 0], [string $orderBy = NULL]): Finds active sessions by criteria, (*27)
findActiveInfosBy(array $criteria, [boolean $caseSensitive = false], [integer $limit = 30], [integer $skip = 0], [string $orderBy = NULL]): Find active sessions with additional information by criteria, (*28)
findBy(array $criteria, [boolean $caseSensitive = false], [integer $limit = 30], [integer $skip = 0], [string $orderBy = NULL]): Finds model instances by parameters, (*29)
findOneActiveBy(array $criteria, [boolean $caseSensitive = false]): Finds one active session by criteria, (*30)
findOneActiveInfosBy(array $criteria, [boolean $caseSensitive = false]): Find one active session with additional information by criteria, (*31)
findOneBy(array $criteria, [boolean $caseSensitive = false]): Find one model entry by parameters, (*32)
get(integer $id): Get model by id, (*33)
getActive(): Get all active sessions, (*34)
getActiveInfos(array $criteria, boolean $caseSensitive): Get all active sessions and additional information, (*35)
has(integer $id): Check if model entry exists., (*36)
make(array $attributes): Make a new model, (*37)
UserRepository methods
all([integer $limit = 30], [integer $skip = 0], [string $orderBy = NULL]): Get all model instances from repository, (*38)
findBy(array $criteria, [boolean $caseSensitive = false], [integer $limit = 30], [integer $skip = 0], [string $orderBy = NULL]): Finds model instances by parameters, (*39)
findOneBy(array $criteria, [boolean $caseSensitive = false]): Find one model entry by parameters, (*40)
get(integer $id): Get model by id, (*41)
has(integer $id): Check if model entry exists., (*42)
hasLoginName(string $loginName): Check if user LoginName exists., (*43)
hasUserEmail(string $userEmail): Check if user email exists., (*44)
hasUserName(string $userName): Check if user username exists., (*45)
BaseRepository methods
make(array $attributes): Make a new model, (*46)
Host methods
UINotify(string $message, [array $parameters = array ()]): Send a message dialog to host, (*47)
createProcess(array $startInfo): Create a new process, (*48)
delete(): This method cannot be used. Host is deleted via the server service, (*49)
getLastUserLoginTime(): Get the time of last user login, (*50)
getLastUserLogoutTime(): Get the time of last user logout, (*51)
getProcess(integer $processId): Get a single process by its id, (*52)
getProcesses([array $criteria = array ()], [boolean $caseSensitive = false], [integer $limit = 30], [integer $skip = 0], [string $orderBy = NULL]): Get all processes running on the host, (*53)
getProcessesByName(string $processName): Get all processes running on the host filtered by process name, (*54)
isFree(): Checks if the host is free, (*55)
isTurnedOn(): Shorthand for HasValidDispatcher attribute, (*56)
setLockState(boolean $isLocked): Set the host to locked state, (*57)
setOrderState(boolean $isInOrder): Set the host order state, (*58)
setSecurityState(boolean $isEnabled): Set the host security state, (*59)
terminateProcess(array $killInfo): Terminate processes, (*60)
userLogout(): {@inheritDoc}, (*61)
News methods
delete(): Delete the model, (*62)
User methods
delete(): Delete the model, (*63)
getLoggedInHostId(): Get the Host id where the user is logged in, (*64)
isLoggedIn(): Check if user is logged in, (*65)
lastLoginTime(): Get the time of last login to a host, (*66)
lastLogoutTime(): Get the time of last logout from a host, (*67)
login(\Pisa\GizmoAPI\Models\HostInterface $host): Log user in to a host, (*68)
logout(): Log user out from a host, (*69)
rename(\Pisa\GizmoAPI\Repositories\UserRepositoryInterface $repository, string $newUserName): Renames a user, (*70)
save([\Pisa\GizmoAPI\Repositories\UserRepositoryInterface $repository = NULL]): Create or update the model, (*71)
setEmail(\Pisa\GizmoAPI\Repositories\UserRepositoryInterface $repository, string $newEmail): Change the user email, (*72)
setPassword(string $newPassword): Set new password for the user, (*73)
setUserGroup(integer $groupId): Set user to a new user group, (*74)
BaseModel methods
exists(): Check if model exists., (*75)
getInvalid(): Return attributes that doesn't pass the validator, (*76)
getValidator(): Return the validator instance, (*77)
getRules(): Returns the current validation rules, (*78)
setRules(array $rules): Set the validation rules, (*79)
mergeRules(array $rules): Merge new rules to the current validation rules, (*80)
isSaved(): Check if model has saved all the changes, (*81)
validate():, (*82)
isValid(): Check that the model passes validation rules, (*83)
load(array $attributes): Load model attributes and mark them as saved., (*84)
save(): Create or update the model, (*85)
getPrimaryKeyValue(): Gets the value of the primary key, (*86)
getPrimaryKey(): Gets the primary key, (*87)
fill(array $attributes): Set all attributes. Use AttributeMutators if presented., (*88)
getAttribute(string $key): Get a single attribute, (*89)
getAttributes(): Get all attributes, (*90)
setAttribute(string $key, mixed $value): Set a single attribute. Use mutator if presented, (*91)
toArray(): Alias for getAttributes, (*92)
History
TODO: Write history, (*93)
Credits
Jani "Zachu" Korhonen <jani.korhonen@hel.fi>, (*94)