<?php

/**
 * @file
 * Installation file and schema for services_client_connection module
 */

/**
 * Implementation of hook_schema().
 */
function services_client_connection_schema() {
  $schema = array();

  $schema['services_client_connection'] = array(
    'description' => 'Stores configuration for different services clients',
    'export' => array(
      'key' => 'name',
      'key name' => 'Name',
      'primary key' => 'cid',
      'identifier' => 'connection',
      'default hook' => 'services_client_connection_default_connections',
      'api' => array(
        'owner' => 'services_client_connection',
        'api' => 'default_services_client_connection',
        'minimum_version' => 1,
        'current_version' => 1,
      ),
      'save callback' => 'services_client_connection_save',
      'load callback' => 'services_client_connection_load',
    ),
    'fields' => array(
      'cid' => array(
        'type'        => 'serial',
        'unsigned'    => TRUE,
        'not null'    => TRUE,
        'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
        'no export'   => TRUE, // Do not export database-only keys.
      ),
      'name' => array(
        'type'        => 'varchar',
        'length'      => '255',
        'description' => 'Unique ID for this object. Used to identify it programmatically.',
      ),
      'admin_title' => array(
        'type'        => 'varchar',
        'length'      => '255',
        'description' => 'Administration title used in UI',
      ),
      'admin_description' => array(
        'type'        => 'text',
        'description' => 'Administration description of connection',
      ),
      'version' => array(
        'type'        => 'int',
        'unsigned'    => TRUE,
        'not null'    => TRUE,
        'description' => 'Version of remote Services API',
      ),
      'endpoint' => array(
        'description' => 'The path to the endpoint for this connection.',
        'type'        => 'varchar',
        'length'      => 255,
        'not null'    => TRUE,
      ),
      'config' => array(
        'type'        => 'text',
        'serialize'   => TRUE,
        'description' => 'Services client plugins configuration',
        'object default' => array(
          'auth' => array(
            'plugin' => '',
            'config' => array(),
          ),
          'server' => array(
            'plugin' => '',
            'config' => array()
          ),
          'request' => array(
            'plugin' => '',
            'config' => array()
          ),
        ),
      ),
      'debug' => array(
         'description' => 'Set the endpoint in debug mode.',
         'type'        => 'int',
         'length'      => 2,
         'not null'    => TRUE,
         'default'     => 0
      ),
    ),
    'primary key' => array('cid'),
    'unique keys' => array(
      'name' => array('name')
    ),
  );

  return $schema;
}
