UNPKG

alfresco-js-api

Version:

JavaScript client library for the Alfresco REST API

345 lines (287 loc) 13.5 kB
(function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define(['../ApiClient', '../model/RenditionBody', '../model/Error', '../model/RenditionEntry', '../model/RenditionPaging'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. module.exports = factory(require('../ApiClient'), require('../model/RenditionBody'), require('../model/Error'), require('../model/RenditionEntry'), require('../model/RenditionPaging')); } else { // Browser globals (root is window) if (!root.AlfrescoCoreRestApi) { root.AlfrescoCoreRestApi = {}; } root.AlfrescoCoreRestApi.RenditionsApi = factory(root.AlfrescoCoreRestApi.ApiClient, root.AlfrescoCoreRestApi.RenditionBody, root.AlfrescoCoreRestApi.Error, root.AlfrescoCoreRestApi.RenditionEntry, root.AlfrescoCoreRestApi.RenditionPaging); } }(this, function(ApiClient, RenditionBody, Error, RenditionEntry, RenditionPaging) { 'use strict'; /** * Renditions service. * @module api/RenditionsApi * @version 0.1.0 */ /** * Constructs a new RenditionsApi. * @alias module:api/RenditionsApi * @class * @param {module:ApiClient} apiClient Optional API client implementation to use, default to {@link module:ApiClient#instance} * if unspecified. */ var exports = function(apiClient) { this.apiClient = apiClient || ApiClient.instance; /** * Create rendition * Async request to create a rendition for file with identifier\n**nodeId**. The rendition is specified by name \"id\" in the request body:\n```JSON\n{\n \"id\":\"doclib\"\n}\n```\n * @param {String} nodeId The identifier of a node. You can also use one of these well-known aliases:\n* -my-\n* -shared-\n* -root-\n * @param {module:model/RenditionBody} renditionBody The rendition \"id\". */ this.createRendition = function(nodeId, renditionBody) { var postBody = renditionBody; // verify the required parameter 'nodeId' is set if (nodeId == undefined || nodeId == null) { throw "Missing the required parameter 'nodeId' when calling createRendition"; } // verify the required parameter 'renditionBody' is set if (renditionBody == undefined || renditionBody == null) { throw "Missing the required parameter 'renditionBody' when calling createRendition"; } var pathParams = { 'nodeId': nodeId }; var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = ['basicAuth']; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = null; return this.apiClient.callApi( '/nodes/{nodeId}/renditions', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * Get rendition information * Returns the rendition information for file node with identifier **nodeId**. * @param {String} nodeId The identifier of a node. * @param {String} renditionId The name of a thumbnail rendition, for example *doclib*, or *pdf*. * data is of type: {module:model/RenditionEntry} */ this.getRendition = function(nodeId, renditionId) { var postBody = null; // verify the required parameter 'nodeId' is set if (nodeId == undefined || nodeId == null) { throw "Missing the required parameter 'nodeId' when calling getRendition"; } // verify the required parameter 'renditionId' is set if (renditionId == undefined || renditionId == null) { throw "Missing the required parameter 'renditionId' when calling getRendition"; } var pathParams = { 'nodeId': nodeId, 'renditionId': renditionId }; var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = ['basicAuth']; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = RenditionEntry; return this.apiClient.callApi( '/nodes/{nodeId}/renditions/{renditionId}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * Get rendition content * Returns the rendition content for file node with identifier **nodeId**. * @param {String} nodeId The identifier of a node. * @param {String} renditionId The name of a thumbnail rendition, for example *doclib*, or *pdf*. * @param {Object} opts Optional parameters * @param {Boolean} opts.attachment **true** enables a web browser to download the file as an attachment.\n**false** means a web browser may preview the file in a new tab or window, but not\ndownload the file.\n\nYou can only set this parameter to **false** if the content type of the file is in the supported list;\nfor example, certain image files and PDF files.\n\nIf the content type is not supported for preview, then a value of **false** is ignored, and\nthe attachment will be returned in the response.\n (default to true) * @param {Date} opts.ifModifiedSince Only returns the content if it has been modified since the date provided.\nUse the date format defined by HTTP. For example, `Wed, 09 Mar 2016 16:56:34 GMT`.\n */ this.getRenditionContent = function(nodeId, renditionId, opts) { opts = opts || {}; var postBody = null; // verify the required parameter 'nodeId' is set if (nodeId == undefined || nodeId == null) { throw "Missing the required parameter 'nodeId' when calling getRenditionContent"; } // verify the required parameter 'renditionId' is set if (renditionId == undefined || renditionId == null) { throw "Missing the required parameter 'renditionId' when calling getRenditionContent"; } var pathParams = { 'nodeId': nodeId, 'renditionId': renditionId }; var queryParams = { 'attachment': opts['attachment'] }; var headerParams = { 'If-Modified-Since': opts['ifModifiedSince'] }; var formParams = { }; var authNames = ['basicAuth']; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = null; return this.apiClient.callApi( '/nodes/{nodeId}/renditions/{renditionId}/content', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * List information for renditions * Returns the rendition information for the file node with identifier **nodeId**.\nThis will return rendition information, including the rendition id, for each rendition. The\u00A0rendition status is CREATED (ie. available\u00A0to view/download) or NOT_CREATED (ie. rendition can be requested). * @param {String} nodeId The identifier of a node. * data is of type: {module:model/RenditionPaging} */ this.getRenditions = function(nodeId) { var postBody = null; // verify the required parameter 'nodeId' is set if (nodeId == undefined || nodeId == null) { throw "Missing the required parameter 'nodeId' when calling getRenditions"; } var pathParams = { 'nodeId': nodeId }; var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = ['basicAuth']; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = RenditionPaging; return this.apiClient.callApi( '/nodes/{nodeId}/renditions', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * Get shared link rendition content * Returns the rendition content for file with shared link identifier **sharedId**.\n\n**Note:** No authentication is required to call this endpoint.\n * @param {String} sharedId The identifier of a shared link to a file. * @param {String} renditionId The name of a thumbnail rendition, for example *doclib*, or *pdf*. * @param {Object} opts Optional parameters * @param {Boolean} opts.attachment **true** enables a web browser to download the file as an attachment.\n**false** means a web browser may preview the file in a new tab or window, but not\ndownload the file.\n\nYou can only set this parameter to **false** if the content type of the file is in the supported list;\nfor example, certain image files and PDF files.\n\nIf the content type is not supported for preview, then a value of **false** is ignored, and\nthe attachment will be returned in the response.\n (default to true) * @param {Date} opts.ifModifiedSince Only returns the content if it has been modified since the date provided.\nUse the date format defined by HTTP. For example, `Wed, 09 Mar 2016 16:56:34 GMT`.\n */ this.getSharedLinkRenditionContent = function(sharedId, renditionId, opts) { opts = opts || {}; var postBody = null; // verify the required parameter 'sharedId' is set if (sharedId == undefined || sharedId == null) { throw "Missing the required parameter 'sharedId' when calling getSharedLinkRenditionContent"; } // verify the required parameter 'renditionId' is set if (renditionId == undefined || renditionId == null) { throw "Missing the required parameter 'renditionId' when calling getSharedLinkRenditionContent"; } var pathParams = { 'sharedId': sharedId, 'renditionId': renditionId }; var queryParams = { 'attachment': opts['attachment'] }; var headerParams = { 'If-Modified-Since': opts['ifModifiedSince'] }; var formParams = { }; var authNames = ['basicAuth']; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = null; return this.apiClient.callApi( '/shared-links/{sharedId}/renditions/{renditionId}/content', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * List information for created renditions * Returns the rendition information for the file with shared link identifier **sharedId**.\n\nThis will only return rendition information, including the rendition id, for each rendition\nwhere the rendition status is CREATED (ie. available\u00A0to view/download).\n\n**Note:** No authentication is required to call this endpoint. \n * @param {String} sharedId The identifier of a shared link to a file. * data is of type: {module:model/RenditionPaging} */ this.getSharedLinkRenditions = function(sharedId) { var postBody = null; // verify the required parameter 'sharedId' is set if (sharedId == undefined || sharedId == null) { throw "Missing the required parameter 'sharedId' when calling getSharedLinkRenditions"; } var pathParams = { 'sharedId': sharedId }; var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = ['basicAuth']; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = RenditionPaging; return this.apiClient.callApi( '/shared-links/{sharedId}/renditions', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * Gets rendition information for the file with shared link identifier sharedId. * @param {String} sharedId The identifier of a shared link to a file. * @param {String} renditionId The name of a thumbnail rendition, for example *doclib*, or *pdf*. * data is of type: {module:model/RenditionEntry} */ this.getSharedLinkRendition = function(sharedId, renditionId) { var postBody = null; // verify the required parameter 'sharedId' is set if (sharedId == undefined || sharedId == null) { throw "Missing the required parameter 'sharedId' when calling getRendition"; } // verify the required parameter 'renditionId' is set if (renditionId == undefined || renditionId == null) { throw "Missing the required parameter 'renditionId' when calling getRendition"; } var pathParams = { 'sharedId': sharedId, 'renditionId': renditionId }; var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = ['basicAuth']; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = RenditionEntry; return this.apiClient.callApi( '/shared-links/{sharedId}/renditions/{renditionId}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } }; return exports; }));