/** * Handles DELETE action * * @return array * @throws NotImplementedException */ protected function handleDELETE() { if (empty($this->resource)) { \Cache::flush(); } else { $service = ServiceHandler::getService($this->resource); if ($service instanceof CachedInterface) { $service->flush(); } else { throw new NotImplementedException('Service does not implement API controlled cache.'); } } return ['success' => true]; }
/** * @return array */ public function getApiDocInfo() { $path = '/' . $this->getServiceName() . '/' . $this->getFullPathName(); $eventPath = $this->getServiceName() . '.' . $this->getFullPathName('.'); $name = Inflector::camelize($this->name); // use the cached copy, don't try to create it here, infinite loop! $results = \Cache::get(static::EVENT_CACHE_KEY, []); $allEvents = []; foreach ($results as $services) { foreach ($services as $apis) { foreach ($apis as $operations) { foreach ($operations['verb'] as $events) { foreach ($events as $event) { $allEvents[] = $event; } } } } } $apis = [['path' => $path, 'operations' => [['method' => 'GET', 'summary' => 'getEventList() - Retrieve list of events.', 'nickname' => 'getEventList', 'notes' => 'A list of event names are returned.<br>' . 'The list can be limited by service and/or by type.', 'type' => 'ResourceList', 'event_name' => $eventPath . '.list', 'consumes' => ['application/json', 'application/xml', 'text/csv'], 'produces' => ['application/json', 'application/xml', 'text/csv'], 'parameters' => [ApiOptions::documentOption(ApiOptions::AS_LIST, true, true), ['name' => 'service', 'description' => 'Get the events for only this service.', 'allowMultiple' => false, 'type' => 'string', 'paramType' => 'query', 'required' => false], ['name' => 'type', 'description' => 'Get the events for only this type - process or broadcast.', 'allowMultiple' => false, 'type' => 'string', 'paramType' => 'query', 'required' => false, 'enum' => ['process', 'broadcast']], ['name' => 'only_scripted', 'description' => 'Get only the events that have associated scripts.', 'allowMultiple' => false, 'type' => 'boolean', 'paramType' => 'query', 'required' => false, 'default' => false]], 'responseMessages' => ApiDocUtilities::getCommonResponses([400, 401, 500])], ['method' => 'GET', 'summary' => 'getEventMap() - Retrieve full map of events.', 'nickname' => 'getEventMap', 'notes' => 'This returns a service to verb to event mapping.<br>' . 'The list can be limited by service and/or by type.', 'type' => 'EventMap', 'event_name' => $eventPath . '.list', 'consumes' => ['application/json', 'application/xml', 'text/csv'], 'produces' => ['application/json', 'application/xml', 'text/csv'], 'parameters' => [['name' => 'service', 'description' => 'Get the events for only this service.', 'allowMultiple' => false, 'type' => 'string', 'paramType' => 'query', 'required' => false], ['name' => 'type', 'description' => 'Get the events for only this type - process or broadcast.', 'allowMultiple' => false, 'type' => 'string', 'paramType' => 'query', 'required' => false, 'enum' => ['process', 'broadcast']], ['name' => 'only_scripted', 'description' => 'Get only the events that have associated scripts.', 'allowMultiple' => false, 'type' => 'boolean', 'paramType' => 'query', 'required' => false, 'default' => false]], 'responseMessages' => ApiDocUtilities::getCommonResponses([400, 401, 500])]], 'description' => 'Operations for retrieving events.'], ['path' => $path . '/{event_name}', 'operations' => [['method' => 'GET', 'summary' => 'getEventScript() - Retrieve the script for an event.', 'nickname' => 'getEventScript', 'notes' => 'Use the \'fields\' and \'related\' parameters to limit properties returned for each record. ' . 'By default, all fields and no relations are returned for each record.', 'type' => 'EventScriptResponse', 'event_name' => $eventPath . '.{event_name}.read', 'parameters' => [['name' => 'event_name', 'description' => 'Identifier of the event to retrieve.', 'allowMultiple' => false, 'type' => 'string', 'paramType' => 'path', 'required' => true, 'enum' => $allEvents], ApiOptions::documentOption(ApiOptions::FIELDS), ApiOptions::documentOption(ApiOptions::RELATED), ApiOptions::documentOption(ApiOptions::INCLUDE_SCHEMA), ApiOptions::documentOption(ApiOptions::FILE)], 'responseMessages' => ApiDocUtilities::getCommonResponses([400, 401, 500])], ['method' => 'POST', 'summary' => 'createEventScript() - Create a script for an event.', 'nickname' => 'createEventScript', 'notes' => 'Post data should be a single record containing required fields for a script. ' . 'By default, only the event name of the record affected is returned on success, ' . 'use \'fields\' and \'related\' to return more info.', 'type' => 'EventScriptResponse', 'event_name' => $eventPath . '.{event_name}.create', 'consumes' => ['application/json', 'application/xml', 'text/csv'], 'produces' => ['application/json', 'application/xml', 'text/csv'], 'parameters' => [['name' => 'event_name', 'description' => 'Identifier of the event to retrieve.', 'allowMultiple' => false, 'type' => 'string', 'paramType' => 'path', 'required' => true, 'enum' => $allEvents], ['name' => 'body', 'description' => 'Data containing name-value pairs of records to create.', 'allowMultiple' => false, 'type' => 'EventScriptRequest', 'paramType' => 'body', 'required' => true], ApiOptions::documentOption(ApiOptions::FIELDS), ApiOptions::documentOption(ApiOptions::RELATED)], 'responseMessages' => ApiDocUtilities::getCommonResponses([400, 401, 500])], ['method' => 'DELETE', 'summary' => 'delete' . $name . 'EventScript() - Delete an event scripts.', 'nickname' => 'delete' . $name . 'EventScript', 'notes' => 'By default, only the event name of the record deleted is returned on success. ' . 'Use \'fields\' and \'related\' to return more properties of the deleted record.', 'type' => 'EventScriptResponse', 'event_name' => $eventPath . '.{event_name}.delete', 'parameters' => [['name' => 'event_name', 'description' => 'Identifier of the event to retrieve.', 'allowMultiple' => false, 'type' => 'string', 'paramType' => 'path', 'required' => true, 'enum' => $allEvents], ApiOptions::documentOption(ApiOptions::FIELDS), ApiOptions::documentOption(ApiOptions::RELATED)], 'responseMessages' => ApiDocUtilities::getCommonResponses([400, 401, 500])]], 'description' => 'Operations for scripts on individual events.']]; $models = []; $model = new EventScript(); $temp = $model->toApiDocsModel('EventScript'); if ($temp) { $models = array_merge($models, $temp); } return ['apis' => $apis, 'models' => $models]; }