Ejemplo n.º 1
0
 public function getApiDocInfo()
 {
     $base = parent::getApiDocInfo();
     $name = Inflector::camelize($this->name);
     $lower = Inflector::camelize($this->name, null, false, true);
     $commonProperties = ['id' => ['type' => 'integer', 'format' => 'int32', 'description' => 'Identifier of this ' . $lower . '.'], 'name' => ['type' => 'string', 'description' => 'Displayable name of this ' . $lower . '.'], 'description' => ['type' => 'string', 'description' => 'Description of this ' . $lower . '.'], 'to' => ['type' => 'array', 'description' => 'Single or multiple receiver addresses.', 'items' => ['$ref' => 'EmailAddress']], 'cc' => ['type' => 'array', 'description' => 'Optional CC receiver addresses.', 'items' => ['$ref' => 'EmailAddress']], 'bcc' => ['type' => 'array', 'description' => 'Optional BCC receiver addresses.', 'items' => ['$ref' => 'EmailAddress']], 'subject' => ['type' => 'string', 'description' => 'Text only subject line.'], 'body_text' => ['type' => 'string', 'description' => 'Text only version of the body.'], 'body_html' => ['type' => 'string', 'description' => 'Escaped HTML version of the body.'], 'from' => ['type' => 'EmailAddress', 'description' => 'Required sender name and email.'], 'reply_to' => ['type' => 'EmailAddress', 'description' => 'Optional reply to name and email.'], 'defaults' => ['type' => 'array', 'description' => 'Array of default name value pairs for template replacement.', 'items' => ['type' => 'string']]];
     $stampProperties = ['created_date' => ['type' => 'string', 'description' => 'Date this record was created.', 'readOnly' => true], 'last_modified_date' => ['type' => 'string', 'description' => 'Date this record was last modified.', 'readOnly' => true]];
     $models = [$name . 'Request' => ['id' => $name . 'Request', 'properties' => $commonProperties], $name . 'Response' => ['id' => $name . 'Response', 'properties' => array_merge($commonProperties, $stampProperties)], 'EmailAddress' => ['id' => 'EmailAddress', 'properties' => ['name' => ['type' => 'string', 'description' => 'Optional name displayed along with the email address.'], 'email' => ['type' => 'string', 'description' => 'Required email address.']]]];
     $base['models'] = array_merge($base['models'], $models);
     return $base;
 }
Ejemplo n.º 2
0
 public function getApiDocInfo()
 {
     $path = '/' . $this->getServiceName() . '/' . $this->getFullPathName();
     $eventPath = $this->getServiceName() . '.' . $this->getFullPathName('.');
     $name = Inflector::camelize($this->name);
     $plural = Inflector::pluralize($name);
     $words = str_replace('_', ' ', $this->name);
     $pluralWords = Inflector::pluralize($words);
     $wrapper = ResourcesWrapper::getWrapper();
     $apis = [['path' => $path, 'description' => "Operations for {$words} administration.", 'operations' => [['method' => 'GET', 'summary' => 'get' . $plural . '() - Retrieve one or more ' . $pluralWords . '.', 'nickname' => 'get' . $plural, 'type' => $plural . 'Response', 'event_name' => [$eventPath . '.list'], 'consumes' => ['application/json', 'application/xml', 'text/csv'], 'produces' => ['application/json', 'application/xml', 'text/csv'], 'parameters' => [ApiOptions::documentOption(ApiOptions::FIELDS)], 'responseMessages' => ApiDocUtilities::getCommonResponses([400, 401, 500]), 'notes' => 'List Active Directory ' . strtolower($pluralWords)]]], ['path' => $path . '/{' . strtolower($name) . '_name}', 'operations' => [['method' => 'GET', 'summary' => 'get' . $name . '() - Retrieve one ' . $words . '.', 'nickname' => 'get' . $name, 'type' => $name . 'Response', 'event_name' => $eventPath . '.read', 'parameters' => [['name' => strtolower($name) . '_name', 'description' => 'Identifier of the record to retrieve.', 'allowMultiple' => false, 'type' => 'string', 'paramType' => 'path', 'required' => true], ApiOptions::documentOption(ApiOptions::FIELDS)], 'responseMessages' => ApiDocUtilities::getCommonResponses([400, 401, 500]), 'notes' => 'Use the \'fields\' parameter to limit properties that are returned. By default, all fields are returned.']], 'description' => "Operations for individual {$words} administration."]];
     $models = [$plural . 'Response' => ['id' => $plural . 'Response', 'properties' => [$wrapper => ['type' => 'array', 'description' => 'Array of records.', 'items' => ['$ref' => $name . 'Response']]]], $name . 'Response' => ['id' => $name . 'Response', 'properties' => ['objectclass' => ['type' => 'array', 'description' => 'This property identifies the class of which the object is an instance, as well as all structural or abstract superclasses from which that class is derived.'], 'cn' => ['type' => 'string', 'description' => 'Common name of the object'], 'dn' => ['type' => 'string', 'description' => 'Distinguished name of the object'], 'distinguishedname' => ['type' => 'string', 'description' => 'Distinguished name of the object'], 'whencreated' => ['type' => 'string', 'description' => 'Date/Time when object was created'], 'whenchanged' => ['type' => 'string', 'description' => 'Date/Time when object was changed'], 'objectcategory' => ['type' => 'string', 'description' => 'Shows objectCagetory attribute.']]]];
     return ['apis' => $apis, 'models' => $models];
 }
Ejemplo n.º 3
0
 public function getApiDocInfo()
 {
     $path = '/' . $this->getServiceName() . '/' . $this->getFullPathName();
     $eventPath = $this->getServiceName() . '.' . $this->getFullPathName('.');
     $name = Inflector::camelize($this->name);
     $plural = Inflector::pluralize($name);
     $words = str_replace('_', ' ', $this->name);
     $pluralWords = Inflector::pluralize($words);
     $wrapper = ResourcesWrapper::getWrapper();
     $apis = [['path' => $path, 'description' => "Operations for retrieving system environment.", 'operations' => [['method' => 'GET', 'summary' => 'getEnvironment() - Retrieve system environment.', 'nickname' => 'getEnvironment', 'type' => 'EnvironmentResponse', 'event_name' => $eventPath . '.list', 'consumes' => ['application/json', 'application/xml', 'text/csv'], 'produces' => ['application/json', 'application/xml', 'text/csv'], 'parameters' => [], 'responseMessages' => [], 'notes' => 'Minimum environment information given without a valid user session.' . ' More information given based on user privileges.']]]];
     $models = ['EnvironmentResponse' => ['id' => 'EnvironmentResponse', 'properties' => ['platform' => ['type' => 'array', 'description' => 'Array of system records.', 'items' => ['$ref' => $name . 'Response']], 'authentication' => ['type' => 'Metadata', 'description' => 'Array of metadata returned for GET requests.'], 'app_group' => ['type' => 'array', 'description' => 'Array of system records.', 'items' => ['$ref' => $name . 'Response']], 'no_app_group' => ['type' => 'array', 'description' => 'Array of system records.', 'items' => ['$ref' => $name . 'Response']], 'config' => ['type' => 'Metadata', 'description' => 'Array of metadata returned for GET requests.'], 'server' => ['type' => 'Metadata', 'description' => 'Array of metadata returned for GET requests.']]]];
     return ['apis' => $apis, 'models' => $models];
 }
Ejemplo n.º 4
0
 /**
  * Show the application dashboard to the user.
  *
  * @param Request $request
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $_message = isset($messages) ? $messages : null;
     $_defaultDomain = '.' . trim(config('dashboard.default-domain'), '. ');
     /** @type User $_user */
     $_user = \Auth::user();
     /** @noinspection PhpUndefinedFieldInspection */
     $_coreData = ['panelContext' => config('panels.default.context', DashboardDefaults::PANEL_CONTEXT), 'panelType' => PanelTypes::SINGLE, 'defaultDomain' => $_defaultDomain, 'message' => $_message, 'isAdmin' => $_user->admin_ind, 'displayName' => $_user->nickname_text, 'defaultInstanceName' => (1 != $_user->admin_ind ? config('dfe.instance-prefix') : null) . Inflector::neutralize(str_replace(' ', '-', \Auth::user()->nickname_text))];
     $_create = Dashboard::renderPanel('create', array_merge($_coreData, ['instanceName' => PanelTypes::CREATE, 'panelType' => PanelTypes::CREATE, 'importables' => $this->getUserImportables()]));
     $_instances = Dashboard::userInstanceTable(null, true);
     /** @type WebsitePartner $_partner */
     //  The name of the site partner, if any.
     $_partner = null;
     if (!empty($_partnerId = config('dfe.partner'))) {
         $_partner = Partner::resolve($_partnerId);
     }
     return view('app.home', array_merge($_coreData, ['instanceCreator' => $_create, 'instances' => $_instances, 'partner' => $_partner ?: null, 'partnerContent' => $_partner ? $_partner->getWebsiteContent() : null]));
 }
Ejemplo n.º 5
0
    /**
     * Creates an export of a instance
     *
     * @param Instance   $instance    The instance of the exports
     * @param array      $exports     Array of files to include in the snapshot
     * @param Filesystem $destination The destination upon which to place the export. Currently unused
     *                                If null, the instance's snapshot storage area is used.
     * @param int        $keepDays    The number of days to keep the snapshot
     *
     * @return array|boolean The snapshot metadata array or false on failure.
     */
    public function createFromExports(Instance $instance, array $exports, Filesystem $destination = null, $keepDays = EnterpriseDefaults::SNAPSHOT_DAYS_TO_KEEP)
    {
        //  Build our "mise en place", as it were...
        $_success = false;
        $_stamp = date('YmdHis');
        //  Create the snapshot ID
        $_snapshotId = $_stamp . '.' . Inflector::neutralize($instance->instance_name_text);
        $_snapshotName = str_replace('{id}', $_snapshotId, config('snapshot.templates.snapshot-file-name'));
        //  Set up the temp dir
        $this->setWorkPath($instance->getSnapshotPath());
        //  Create the snapshot archive and stuff it full of goodies
        /** @var SnapshotManifest $_manifest */
        list($_fsSnapshot, $_manifest, $_routeHash, $_routeLink) = $this->createExportArchive($_snapshotId, $_snapshotName, ['timestamp' => $_stamp, 'guest-location' => $instance->guest_location_nbr, 'instance-id' => $instance->instance_id_text, 'cluster-id' => (int) $instance->cluster_id, 'db-server-id' => (int) $instance->db_server_id, 'web-server-id' => (int) $instance->web_server_id, 'app-server-id' => (int) $instance->app_server_id, 'owner-id' => (int) $instance->user->id, 'owner-email-address' => $instance->user->email_addr_text, 'owner-storage-key' => $instance->user->storage_id_text, 'storage-key' => $instance->storage_id_text], $keepDays);
        try {
            $this->addFilesToArchive($exports, $_fsSnapshot);
            try {
                //  Write our snapshot manifesto
                $_manifest->write();
                //  Close up the files
                /** @noinspection PhpUndefinedMethodInspection */
                $this->flushZipArchive($_fsSnapshot);
                //  Look up the hash entry
                if (null === ($_routeHash = RouteHash::byHash($_routeHash)->first())) {
                    throw new \LogicException('Previously created route hash not found.');
                }
                //  Create our snapshot record
                Snapshot::create(['user_id' => $instance->user_id, 'instance_id' => $instance->id, 'route_hash_id' => $_routeHash->id, 'snapshot_id_text' => $_snapshotId, 'public_ind' => true, 'public_url_text' => $_routeLink, 'expire_date' => $_routeHash->expire_date]);
                //  Copy to $destination if requested
                if ($destination) {
                    if (false === ($_fd = fopen($this->workPath . $_snapshotName, 'r'))) {
                        throw new FileSystemException('Unable to open export file "' . $this->workPath . $_snapshotName . '".');
                    }
                    $destination->putStream($_snapshotName, $_fd);
                    fclose($_fd);
                }
                //  Let the user know...
                $this->notifyInstanceOwner($instance, 'Export successful', ['firstName' => $instance->user->first_name_text, 'headTitle' => 'Export Complete', 'contentHeader' => 'Your export has completed', 'emailBody' => <<<HTML
<p>Your export is complete. It may be downloaded it for up to {$keepDays} days, from the following link:<br/>
<br/>
<strong><a href="{$_routeLink}" target="_blank">{$_routeLink}</a></strong>
</p>
HTML
]);
                $_success = true;
            } catch (\Exception $_ex) {
                $this->error('exception building snapshot archive: ' . $_ex->getMessage());
                throw $_ex;
            }
        } catch (\Exception $_ex) {
            $this->error('exception during sub-provisioner export call: ' . $_ex->getMessage());
            $this->notifyInstanceOwner($instance, 'Export failure', ['firstName' => $instance->user->first_name_text, 'headTitle' => 'Export Failure', 'contentHeader' => 'Your export was not created', 'emailBody' => <<<HTML
<p>The export requested did not complete properly. Please make sure your instance is up and running, then try again. If the issue persists, please contact support.</p>
HTML
]);
            $_success = false;
        } finally {
            //  Cleanup
            $_fsSnapshot = null;
        }
        return $_success ? $_manifest->toArray() : false;
    }
Ejemplo n.º 6
0
 /**
  * @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];
 }
Ejemplo n.º 7
0
 public function getPlural()
 {
     return empty($this->plural) ? Inflector::pluralize($this->getLabel()) : $this->plural;
 }
Ejemplo n.º 8
0
 public function getApiDocInfo()
 {
     $path = '/' . $this->name;
     $eventPath = $this->name;
     $name = Inflector::camelize($this->name);
     $plural = Inflector::pluralize($name);
     return ['resourcePath' => $path, 'produces' => ['application/json', 'application/xml'], 'consumes' => ['application/json', 'application/xml'], 'apis' => [['path' => $path, 'description' => "Operations available for the {$this->label} service.", 'operations' => [['method' => 'GET', 'summary' => 'getResourceList() - List all resource names.', 'nickname' => 'getResourceList', 'notes' => 'Return only a list of the resource identifiers.', 'type' => 'ResourceList', 'event_name' => [$eventPath . '.list'], 'parameters' => [ApiOptions::documentOption(ApiOptions::AS_LIST, true, true), ApiOptions::documentOption(ApiOptions::AS_ACCESS_LIST), ApiOptions::documentOption(ApiOptions::ID_FIELD), ApiOptions::documentOption(ApiOptions::ID_TYPE), ApiOptions::documentOption(ApiOptions::REFRESH)], 'responseMessages' => ApiDocUtilities::getCommonResponses([400, 401, 500])], ['method' => 'GET', 'summary' => 'getResources() - List all resources.', 'nickname' => 'getResources', 'notes' => 'List the resources available on this service. ', 'type' => $plural . 'Response', 'event_name' => [$eventPath . '.list'], 'parameters' => [ApiOptions::documentOption(ApiOptions::FIELDS), ApiOptions::documentOption(ApiOptions::REFRESH)], 'responseMessages' => ApiDocUtilities::getCommonResponses([400, 401, 500])]]]], 'models' => $this->getApiDocModels()];
 }
Ejemplo n.º 9
0
 public function getLabel()
 {
     $name = str_replace('.', ' ', $this->getName(true));
     return empty($this->label) ? Inflector::camelize($name, '_', true) : $this->label;
 }
Ejemplo n.º 10
0
 /**
  * Returns the constant name as a string
  *
  * @param string|int $constant The CONSTANT's value that you want the name of
  * @param bool       $flipped  If false, $constant should be the CONSTANT's name. The CONSTANT's value will be
  *                             returned instead.
  * @param bool       $pretty   If true, returned value is prettified (acme.before_event becomes "Acme Before
  *                             Event")
  *
  * @throws \InvalidArgumentException
  * @return string|int
  */
 public static function nameOf($constant, $flipped = true, $pretty = true)
 {
     $_result = null;
     foreach (static::getDefinedConstants() as $_name => $_value) {
         if ($flipped) {
             if ($_name == $constant) {
                 $_result = $_value;
                 break;
             }
         } else {
             if ($_value == $constant) {
                 $_result = $_name;
                 break;
             }
         }
     }
     if (!$_result) {
         throw new \InvalidArgumentException('A constant with the value of "' . $constant . '" does not exist.');
     }
     return !$flipped && $pretty ? Inflector::display(Inflector::neutralize($_result)) : $_result;
 }
Ejemplo n.º 11
0
 public function getLabel()
 {
     return empty($this->label) ? Inflector::camelize($this->getName(true), '_', true) : $this->label;
 }
Ejemplo n.º 12
0
 public function getApiDocInfo()
 {
     $path = '/' . $this->getServiceName() . '/' . $this->getFullPathName();
     $eventPath = $this->getServiceName() . '.' . $this->getFullPathName('.');
     $name = Inflector::camelize($this->name);
     $plural = Inflector::pluralize($name);
     $words = str_replace('_', ' ', $this->name);
     $pluralWords = Inflector::pluralize($words);
     $wrapper = ResourcesWrapper::getWrapper();
     $apis = [['path' => $path, 'description' => "Operations for {$words} administration.", 'operations' => [['method' => 'GET', 'summary' => 'get' . $plural . '() - Retrieve one or more ' . $pluralWords . '.', 'nickname' => 'get' . $plural, 'type' => $plural . 'Response', 'event_name' => [$eventPath . '.list'], 'consumes' => ['application/json', 'application/xml', 'text/csv'], 'produces' => ['application/json', 'application/xml', 'text/csv'], 'parameters' => [ApiOptions::documentOption(ApiOptions::IDS), ApiOptions::documentOption(ApiOptions::FILTER), ApiOptions::documentOption(ApiOptions::LIMIT), ApiOptions::documentOption(ApiOptions::ORDER), ApiOptions::documentOption(ApiOptions::GROUP), ApiOptions::documentOption(ApiOptions::OFFSET), ApiOptions::documentOption(ApiOptions::FIELDS), ApiOptions::documentOption(ApiOptions::RELATED), ApiOptions::documentOption(ApiOptions::INCLUDE_COUNT), ApiOptions::documentOption(ApiOptions::INCLUDE_SCHEMA), ApiOptions::documentOption(ApiOptions::FILE)], 'responseMessages' => ApiDocUtilities::getCommonResponses([400, 401, 500]), 'notes' => 'Use the \'ids\' or \'filter\' parameter to limit records that are returned. ' . 'By default, all records up to the maximum are returned. <br>' . '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. <br>' . 'Alternatively, to retrieve by record, a large list of ids, or a complicated filter, ' . 'use the POST request with X-HTTP-METHOD = GET header and post records or ids.'], ['method' => 'POST', 'summary' => 'create' . $plural . '() - Create one or more ' . $pluralWords . '.', 'nickname' => 'create' . $plural, 'type' => $plural . 'Response', 'event_name' => $eventPath . '.create', 'consumes' => ['application/json', 'application/xml', 'text/csv'], 'produces' => ['application/json', 'application/xml', 'text/csv'], 'parameters' => [['name' => 'body', 'description' => 'Data containing name-value pairs of records to create.', 'allowMultiple' => false, 'type' => $plural . 'Request', 'paramType' => 'body', 'required' => true], ApiOptions::documentOption(ApiOptions::FIELDS), ApiOptions::documentOption(ApiOptions::RELATED), ['name' => 'X-HTTP-METHOD', 'description' => 'Override request using POST to tunnel other http request, such as DELETE.', 'enum' => ['GET', 'PUT', 'PATCH', 'DELETE'], 'allowMultiple' => false, 'type' => 'string', 'paramType' => 'header', 'required' => false]], 'responseMessages' => ApiDocUtilities::getCommonResponses([400, 401, 500]), 'notes' => 'Post data should be a single record or an array of records (shown). ' . 'By default, only the id property of the record affected is returned on success, ' . 'use \'fields\' and \'related\' to return more info.'], ['method' => 'PATCH', 'summary' => 'update' . $plural . '() - Update one or more ' . $pluralWords . '.', 'nickname' => 'update' . $plural, 'type' => $plural . 'Response', 'event_name' => $eventPath . '.update', 'consumes' => ['application/json', 'application/xml', 'text/csv'], 'produces' => ['application/json', 'application/xml', 'text/csv'], 'parameters' => [['name' => 'body', 'description' => 'Data containing name-value pairs of records to update.', 'allowMultiple' => false, 'type' => $plural . 'Request', 'paramType' => 'body', 'required' => true], ApiOptions::documentOption(ApiOptions::IDS), ApiOptions::documentOption(ApiOptions::FIELDS), ApiOptions::documentOption(ApiOptions::RELATED)], 'responseMessages' => ApiDocUtilities::getCommonResponses([400, 401, 500]), 'notes' => 'Post data should be a single record or an array of records (shown). ' . 'By default, only the id property of the record is returned on success, ' . 'use \'fields\' and \'related\' to return more info.'], ['method' => 'DELETE', 'summary' => 'delete' . $plural . '() - Delete one or more ' . $pluralWords . '.', 'nickname' => 'delete' . $plural, 'type' => $plural . 'Response', 'event_name' => $eventPath . '.delete', 'parameters' => [['name' => 'force', 'description' => 'Set force to true to delete all records in this table, otherwise \'ids\' parameter is required.', 'allowMultiple' => false, 'type' => 'boolean', 'paramType' => 'query', 'required' => false, 'default' => false], ApiOptions::documentOption(ApiOptions::IDS), ApiOptions::documentOption(ApiOptions::FIELDS), ApiOptions::documentOption(ApiOptions::RELATED)], 'responseMessages' => ApiDocUtilities::getCommonResponses([400, 401, 500]), 'notes' => 'By default, only the id property of the record deleted is returned on success. ' . 'Use \'fields\' and \'related\' to return more properties of the deleted records. <br>' . 'Alternatively, to delete by record or a large list of ids, ' . 'use the POST request with X-HTTP-METHOD = DELETE header and post records or ids.']]], ['path' => $path . '/{id}', 'operations' => [['method' => 'GET', 'summary' => 'get' . $name . '() - Retrieve one ' . $words . '.', 'nickname' => 'get' . $name, 'type' => $name . 'Response', 'event_name' => $eventPath . '.read', 'parameters' => [['name' => 'id', 'description' => 'Identifier of the record to retrieve.', 'allowMultiple' => false, 'type' => 'string', 'paramType' => 'path', 'required' => true], ApiOptions::documentOption(ApiOptions::FIELDS), ApiOptions::documentOption(ApiOptions::RELATED)], 'responseMessages' => ApiDocUtilities::getCommonResponses([400, 401, 500]), 'notes' => 'Use the \'fields\' and/or \'related\' parameter to limit properties that are returned. By default, all fields and no relations are returned.'], ['method' => 'PATCH', 'summary' => 'update' . $name . '() - Update one ' . $words . '.', 'nickname' => 'update' . $name, 'type' => $name . 'Response', 'event_name' => $eventPath . '.update', 'parameters' => [['name' => 'id', 'description' => 'Identifier of the record to update.', 'allowMultiple' => false, 'type' => 'string', 'paramType' => 'path', 'required' => true], ['name' => 'body', 'description' => 'Data containing name-value pairs of fields to update.', 'allowMultiple' => false, 'type' => $name . 'Request', 'paramType' => 'body', 'required' => true], ApiOptions::documentOption(ApiOptions::FIELDS), ApiOptions::documentOption(ApiOptions::RELATED)], 'responseMessages' => ApiDocUtilities::getCommonResponses([400, 401, 500]), 'notes' => 'Post data should be an array of fields to update for a single record. <br>' . 'By default, only the id is returned. Use the \'fields\' and/or \'related\' parameter to return more properties.'], ['method' => 'DELETE', 'summary' => 'delete' . $name . '() - Delete one ' . $words . '.', 'nickname' => 'delete' . $name, 'type' => $name . 'Response', 'event_name' => $eventPath . '.delete', 'parameters' => [['name' => 'id', 'description' => 'Identifier of the record to delete.', 'allowMultiple' => false, 'type' => 'string', 'paramType' => 'path', 'required' => true], ApiOptions::documentOption(ApiOptions::FIELDS), ApiOptions::documentOption(ApiOptions::RELATED)], 'responseMessages' => ApiDocUtilities::getCommonResponses([400, 401, 500]), 'notes' => 'By default, only the id is returned. Use the \'fields\' and/or \'related\' parameter to return deleted properties.']], 'description' => "Operations for individual {$words} administration."]];
     $models = [$plural . 'Request' => ['id' => $plural . 'Request', 'properties' => [$wrapper => ['type' => 'array', 'description' => 'Array of system records.', 'items' => ['$ref' => $name . 'Request']], ApiOptions::IDS => ['type' => 'array', 'description' => 'Array of system record identifiers, used for batch GET, PUT, PATCH, and DELETE.', 'items' => ['type' => 'integer', 'format' => 'int32']]]], $plural . 'Response' => ['id' => $plural . 'Response', 'properties' => [$wrapper => ['type' => 'array', 'description' => 'Array of system records.', 'items' => ['$ref' => $name . 'Response']], 'meta' => ['type' => 'Metadata', 'description' => 'Array of metadata returned for GET requests.']]], 'Metadata' => ['id' => 'Metadata', 'properties' => ['schema' => ['type' => 'array', 'description' => 'Array of table schema.', 'items' => ['type' => 'string']], 'count' => ['type' => 'integer', 'format' => 'int32', 'description' => 'Record count returned for GET requests.']]]];
     $model = $this->getModel();
     if ($model) {
         $temp = $model->toApiDocsModel($name);
         if ($temp) {
             $models = array_merge($models, $temp);
         }
     }
     return ['apis' => $apis, 'models' => $models];
 }
Ejemplo n.º 13
0
 /**
  * @param array $appInfo
  *
  * @return array
  * @throws \DreamFactory\Core\Exceptions\ForbiddenException
  * @throws \DreamFactory\Core\Exceptions\InternalServerErrorException
  * @throws \DreamFactory\Core\Exceptions\NotFoundException
  */
 private function storeApplicationFiles($appInfo)
 {
     if (ArrayUtils::get($appInfo, 'type', AppTypes::NONE) === AppTypes::STORAGE_SERVICE) {
         $appName = Inflector::camelize(ArrayUtils::get($appInfo, 'name'));
         $storageServiceId = ArrayUtils::get($appInfo, 'storage_service_id', $this->getDefaultStorageServiceId());
         $storageFolder = ArrayUtils::get($appInfo, 'storage_container', $appName);
         /** @var $service BaseFileService */
         $service = ServiceHandler::getServiceById($storageServiceId);
         if (empty($service)) {
             throw new InternalServerErrorException("App record created, but failed to import files due to unknown storage service with id '{$storageServiceId}'.");
         }
         $info = $service->extractZipFile($storageFolder, '', $this->zip);
         return $info;
     } else {
         return [];
     }
 }
Ejemplo n.º 14
0
 public function getApiDocInfo()
 {
     $path = '/' . $this->getServiceName() . '/' . $this->getFullPathName();
     $eventPath = $this->getServiceName() . '.' . $this->getFullPathName('.');
     $name = Inflector::camelize($this->name);
     $plural = Inflector::pluralize($name);
     $words = str_replace('_', ' ', $this->name);
     $pluralWords = Inflector::pluralize($words);
     return ['apis' => [['path' => $path, 'description' => "Operations for {$words} administration.", 'operations' => [['method' => 'GET', 'summary' => 'get' . $plural . 'List() - List all ' . $pluralWords . ' identifiers.', 'nickname' => 'get' . $plural . 'List', 'notes' => 'Return only a list of the resource identifiers.', 'type' => $plural . 'List', 'event_name' => [$eventPath . '.list'], 'parameters' => [ApiOptions::documentOption(ApiOptions::AS_LIST, true, true), ApiOptions::documentOption(ApiOptions::ID_FIELD), ApiOptions::documentOption(ApiOptions::ID_TYPE), ApiOptions::documentOption(ApiOptions::REFRESH)], 'responseMessages' => ApiDocUtilities::getCommonResponses([400, 401, 500])], ['method' => 'GET', 'summary' => 'get' . $plural . '() - List all ' . $pluralWords . '.', 'nickname' => 'get' . $plural, 'notes' => 'List the resources available on this service. ', 'type' => $plural . 'Response', 'event_name' => [$eventPath . '.list'], 'parameters' => [ApiOptions::documentOption(ApiOptions::FIELDS), ApiOptions::documentOption(ApiOptions::REFRESH)], 'responseMessages' => ApiDocUtilities::getCommonResponses([400, 401, 500])]]]], 'models' => $this->getApiDocModels()];
 }
Ejemplo n.º 15
0
 /**
  * Returns the constant name as a string
  *
  * @param string|int $constant The CONSTANT's value that you want the name of
  * @param bool       $flipped  If false, $constant should be the CONSTANT's name. The CONSTANT's value will be
  *                             returned instead.
  * @param bool       $pretty   If true, returned value is prettified (acme.before_event becomes "Acme Before
  *                             Event")
  *
  * @throws \InvalidArgumentException
  * @return string|int
  */
 public static function nameOf($constant, $flipped = true, $pretty = true)
 {
     try {
         $_name = $flipped ? static::toValue($constant) : static::toConstant($constant);
     } catch (\InvalidArgumentException $_ex) {
         throw new \InvalidArgumentException('A constant with the value of "' . $constant . '" does not exist.');
     }
     return !$flipped && $pretty ? Inflector::display(Inflector::neutralize($_name)) : $_name;
 }