Giter Club home page Giter Club logo

services's People

Contributors

adam-bergstein avatar cotto avatar dww avatar eclipsegc avatar heyrocker avatar hugowetterberg avatar kylebrowning avatar marcingy avatar nerdstein avatar robloach avatar voxpelli avatar ygerasimov avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

services's Issues

Create EventSubscriber class to validate routes

All service-sponsored routes should be validated before returning a response. Perform the following tasks.

  1. Create an EventSubscriber that intercepts the dynamic routes for ServiceAPIs
  2. Extend the Service Manager service with new functions validateRequest and processArguments
  3. validateRequest should perform the following actions:
    a. call Service Manager's getServiceByEndpoint($request) to retrieve Service API
    b. call Service Manager's processArguments($request) to parse the arguments from the request
    c. validate request arguments against the Service API's arguments
    d. return a true or false if the arguments are valid

Response formats

  1. Add a series of checkboxes to the Service API entity (form, schema) to select one or more response formats
  2. Values are of type SerializationInterface (json, xml, etc)
  3. Add "Response format" row in the arguments table to define how to extract the desired response format from the Request object
  4. Alter the Response object in the controller to return the selected response format

Warning on endpoint page

Warning: Invalid argument supplied for foreach() in Drupal\Core\Render\Element\Tableselect::valueCallback() (line 70 of core/lib/Drupal/Core/Render/Element/Tableselect.php). for the service_endpoint_add_form

Create ServiceDefinition Plugin Manager

Plugin Manager should work with the ServiceDefinition entity.

  1. An interface and base class for Service Definitions
  2. Arguments object, getArguments function (in the plugin class)
  3. Translation as an annotation to the Service Definition, getTranslation function (pulls annotation from plugin class)
  4. processRequest function (in the plugin class)

Cannot add service

Clean Install drupal beta-14,

Enable Services.

Goto http://drupal-8-0-0-beta14.dd/admin/structure/service_api

And click Add Service API

Recoverable fatal error: Argument 1 passed to Drupal\services\Form\ServiceAPIForm::__construct() must be an instance of Drupal\services\Form\PluginManagerInterface, instance of Drupal\services\ServiceDefinitionPluginManager given, called in /Users/kylebrowning/Sites/devdesktop/drupal-8.0.0-beta14/modules/services/src/Form/ServiceAPIForm.php on line 28 and defined in Drupal\services\Form\ServiceAPIForm->__construct() (line 31 of /Users/kylebrowning/Sites/devdesktop/drupal-8.0.0-beta14/modules/services/src/Form/ServiceAPIForm.php).

Create request processing system for Service Instances

  1. Retrieve the endpoint from each service instance, register dynamically in dynamic router to ServiceRequest controller
  2. Return the ServiceRequest controller function that processes the request by associating the endpoint back to the ServiceInstance and it's associated ServiceProvider

Create Service Instance configuration entity

Use Drupal Console to create the Service Instance entity

  • routes
  • form
  • listing page
  • CRUD operations
  • entity schema

Add the following fields to the ServiceInstance entity / form / entity schema

  • Endpoint Route (path)
  • Authentication Provider (entity reference to available core/contrib provided authentications)
  • Response Format (entity reference to available core/contrib provided serializations - XML/JSON/etc)
  • Service Definition (entity reference to ServiceDefinitions as a dropdown)
  • Translation (yes/no, only available if selected ServiceDefinition has translation capability)

Add functions to Service Instance entity class

  • processRequest - calls the selected service definition response callback
  • getArgumentDefinition - calls the selected service definition for it's expected arguments

Create ctools form wizard for Service Endpoint workflow

  1. Add in "arguments" as a second step for the Service Endpoint form / entity
  2. Arguments should be a table with the following:

2.a. Each "row" should be one argument from the Service Definition getArguments

2.b. A checkbox to identify if argument is required

2.c. A dropdown to identify the expected location from the Request object (http://api.symfony.com/2.0/Symfony/Component/HttpFoundation/Request.html)

  1. If the Service Definition is "translatable", another argument row will exist to identify the translation argument

Versioning?

WE need to be able to support version incase things change we don't want to break clients.

These are the current docs in D7

<?php
/**
 * @file
 * Explains how to use versions
 */

/*
 * All functions that want to be considered for updates need to use a specific naming convention
 * We took the same approach as the standard Drupal hook_update methods. The pattern of update functions is
 * _{RESOURCE_NAME}_resource_{METHOD_NAME}_update_{MAJOR_VERSION}_{MINOR_VERSION}
 * @see services_get_updates() for exact regular expression used.
 *
 * For clients that want to request a specific version they need to pass a certain header
 * services_RESOURCE_METHOD_version = version
 * as an example, services_system_set_variable_version = 1.2
 * @see ServicesVersionTests for code examples
 *
 * Services by default will always use the original resource shipped
 * with services. If you wish to change this you can go to the resource page,
 * and select an api version for the specific resource. The version option will
 * only be enabled if version changes exist.
 */

function _system_resource_set_variable_update_1_1() {
  $new_set = array(
    'help' => 'Create a node with an nid test',
  );
  return $new_set;
}

function _system_resource_set_variable_update_1_2() {
  $new_set = array(
    'help' => 'Create a node with an nid optional prams.',
    'args' => array(
      array(
        'name' => 'name',
        'optional' => TRUE,
        'source' => array('data' => 'name'),
        'description' => t('The name of the variable to set.'),
        'type' => 'string',
      ),
      array(
        'name' => 'value',
        'optional' => TRUE,
        'source' => array('data' => 'value'),
        'description' => t('The value to set.'),
        'type' => 'string',
      ),
    ),
  );
  return $new_set;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.