You are here

function _file_resource_definition in Services 7.3

Same name and namespace in other branches
  1. 6.3 resources/file_resource.inc \_file_resource_definition()

THERE SHOULD BE NO UPDATE!!! Drupal doesn't allow updating or replacing a file in the files table. If you need to, create a new file and remove the old file.

1 call to _file_resource_definition()
_services_core_resources in includes/services.resource_build.inc
Supplies the resource definitions for Drupal core data

File

resources/file_resource.inc, line 13
File resource.

Code

function _file_resource_definition() {
  return array(
    'file' => array(
      'operations' => array(
        'create' => array(
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/file_resource',
          ),
          'help' => 'Create a file with base64 encoded data',
          'callback' => '_file_resource_create',
          'access callback' => '_file_resource_access',
          'access arguments' => array(
            'create',
          ),
          'access arguments append' => TRUE,
          'args' => array(
            array(
              'name' => 'file',
              'type' => 'array',
              'description' => t('An array representing a file.'),
              'source' => 'data',
              'optional' => FALSE,
            ),
          ),
        ),
        'retrieve' => array(
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/file_resource',
          ),
          'help' => 'Retrieve a file',
          'callback' => '_file_resource_retrieve',
          'access callback' => '_file_resource_access',
          'access arguments' => array(
            'view',
          ),
          'access arguments append' => TRUE,
          'args' => array(
            array(
              'name' => 'fid',
              'type' => 'int',
              'description' => 'The fid of the file to retrieve.',
              'source' => array(
                'path' => '0',
              ),
              'optional' => FALSE,
            ),
            array(
              'name' => 'file_contents',
              'type' => 'int',
              'description' => t('To return file contents or not.'),
              'source' => array(
                'param' => 'file_contents',
              ),
              'default value' => TRUE,
              'optional' => TRUE,
            ),
            array(
              'name' => 'image_styles',
              'type' => 'int',
              'description' => t('To return image styles or not.'),
              'source' => array(
                'param' => 'image_styles',
              ),
              'default value' => FALSE,
              'optional' => TRUE,
            ),
          ),
        ),
        'delete' => array(
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/file_resource',
          ),
          'help' => 'Delete a file',
          'callback' => '_file_resource_delete',
          'access callback' => '_file_resource_access',
          'access arguments' => array(
            'delete',
          ),
          'access arguments append' => TRUE,
          'args' => array(
            array(
              'name' => 'fid',
              'type' => 'int',
              'description' => 'The id of the file to delete',
              'source' => array(
                'path' => '0',
              ),
              'optional' => FALSE,
            ),
          ),
        ),
        'index' => array(
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/file_resource',
          ),
          'callback' => '_file_resource_index',
          'help' => 'List all files',
          'args' => array(
            array(
              'name' => 'page',
              'optional' => TRUE,
              'type' => 'int',
              'description' => 'The zero-based index of the page to get, defaults to 0.',
              'default value' => 0,
              'source' => array(
                'param' => 'page',
              ),
            ),
            array(
              'name' => 'fields',
              'optional' => TRUE,
              'type' => 'string',
              'description' => 'The fields to get.',
              'default value' => '*',
              'source' => array(
                'param' => 'fields',
              ),
            ),
            array(
              'name' => 'parameters',
              'optional' => TRUE,
              'type' => 'array',
              'description' => 'Parameters',
              'default value' => array(),
              'source' => array(
                'param' => 'parameters',
              ),
            ),
            array(
              'name' => 'pagesize',
              'optional' => TRUE,
              'type' => 'int',
              'description' => 'Number of records to get per page.',
              'default value' => variable_get('services_file_index_page_size', 20),
              'source' => array(
                'param' => 'pagesize',
              ),
            ),
            array(
              'name' => 'options',
              'optional' => TRUE,
              'type' => 'array',
              'description' => 'Additional query options.',
              'default value' => array(
                'orderby' => array(
                  'timestamp' => 'DESC',
                ),
              ),
              'source' => array(
                'param' => 'options',
              ),
            ),
          ),
          'access callback' => '_file_resource_access',
          'access arguments' => array(
            'index',
          ),
          'access arguments append' => TRUE,
        ),
      ),
      'actions' => array(
        'create_raw' => array(
          'help' => 'Create a file with raw data.',
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/file_resource',
          ),
          'callback' => '_file_resource_create_raw',
          'access callback' => '_file_resource_access',
          'access arguments' => array(
            'create_raw',
          ),
          'access arguments append' => TRUE,
        ),
      ),
    ),
  );
}