UNPKG

@iotize/tap

Version:

IoTize Device client for Javascript

418 lines (406 loc) 10.8 kB
import { AbstractService, extendServiceContainer } from '@iotize/tap'; import { TapRequestFrame } from '@iotize/tap/client/api'; import { TapStreamReader, TapStreamWriter } from '@iotize/tap/client/impl'; import { converters } from '@iotize/tap/service/core'; /** * Generated file. Do not edit */ TapStreamReader.prototype.readReadSelectedFileParams = function () { const model = {}; model.offset = this.readUnsigned(4); model.size = this.readUnsigned(4); return model; }; // TapStreamWriter.prototype.write(model: ReadSelectedFileParams) : TapStreamWriter{ // return this.writeReadSelectedFileParams(model) // } TapStreamWriter.prototype.writeReadSelectedFileParams = function (model) { this.writeUnsigned(model.offset, 4); this.writeUnsigned(model.size, 4); return this; }; /** * Generated file. Do not edit */ class ReadSelectedFileParamsConverter { encode(model, stream = new TapStreamWriter()) { stream.writeReadSelectedFileParams(model); return stream.toBytes; } decode(data) { const stream = data instanceof TapStreamReader ? data : TapStreamReader.create(data); return stream.readReadSelectedFileParams(); } } /** * Generated file. Do not edit */ const readSelectedFileParams = new ReadSelectedFileParamsConverter(); var serviceConverters = /*#__PURE__*/Object.freeze({ __proto__: null, readSelectedFileParams: readSelectedFileParams }); /** * Generated file. Do not edit */ const allConverters = Object.assign(Object.assign({}, converters), serviceConverters); const SERVICE_CALLS = { selectFile: { method: TapRequestFrame.MethodType.POST, pathAlias: '/file-system/select-file', path: '/1032//1', bodyEncoder: allConverters.ascii, }, unselectFile: { method: TapRequestFrame.MethodType.POST, pathAlias: '/file-system/unselect-file', path: '/1032//2', }, writeSelectedFile: { method: TapRequestFrame.MethodType.POST, pathAlias: '/file-system/write-selected-file', path: '/1032//3', }, setSelectedFileBundleId: { method: TapRequestFrame.MethodType.POST, pathAlias: '/file-system/selected-file-bundle-id', path: '/1032//10', bodyEncoder: allConverters.uint16, }, setSelectedFileUserId: { method: TapRequestFrame.MethodType.POST, pathAlias: '/file-system/selected-file-user-id', path: '/1032//11', bodyEncoder: allConverters.uint16, }, readSelectedFile: { method: TapRequestFrame.MethodType.GET, pathAlias: '/file-system/read-selected-file', path: '/1032//4', bodyEncoder: allConverters.readSelectedFileParams, }, deleteSelectedFile: { method: TapRequestFrame.MethodType.POST, pathAlias: '/file-system/delete-selected-file', path: '/1032//6', }, clearAllFiles: { method: TapRequestFrame.MethodType.POST, pathAlias: '/file-system/clear-all-files', path: '/1032//7', }, getSelectedFileSize: { method: TapRequestFrame.MethodType.GET, pathAlias: '/file-system/selected-file-size', path: '/1032//5', responseBodyDecoder: allConverters.uint32, }, listFiles: { method: TapRequestFrame.MethodType.POST, pathAlias: '/file-system/list-files', path: '/1032//9', }, }; class FileSystemService extends AbstractService { constructor() { super(...arguments); this.resources = SERVICE_CALLS; } /** * select file * * LWM2M path: /1032//1 * * @tapVersion(">=2.13") * @param fileName input * @return */ selectFile( /* * name of the file to select. file name format = DOS : 8.3 (namemax8.ext) ... */ fileName) { return this.serviceCallRunner.execute(this.selectFileCall(fileName)); } /** * * * LWM2M path: /1032//1 * * @tapVersion(">=2.13") * @param fileName input * @return call options */ selectFileCall( /* * name of the file to select. file name format = DOS : 8.3 (namemax8.ext) ... */ fileName) { const callOptions = Object.assign({}, this.resources.selectFile); callOptions.body = fileName; return callOptions; } /** * unselect file * * LWM2M path: /1032//2 * * @tapVersion(">=2.13") * @return */ unselectFile() { return this.serviceCallRunner.execute(this.unselectFileCall()); } /** * * * LWM2M path: /1032//2 * * @tapVersion(">=2.13") * @return call options */ unselectFileCall() { const callOptions = Object.assign({}, this.resources.unselectFile); return callOptions; } /** * write data to file * * LWM2M path: /1032//3 * * @tapVersion(">=2.13") * @param data input * @return */ writeSelectedFile( /* * data to write in the file. binary. */ data) { return this.serviceCallRunner.execute(this.writeSelectedFileCall(data)); } /** * * * LWM2M path: /1032//3 * * @tapVersion(">=2.13") * @param data input * @return call options */ writeSelectedFileCall( /* * data to write in the file. binary. */ data) { const callOptions = Object.assign({}, this.resources.writeSelectedFile); callOptions.body = data; return callOptions; } /** * write bundle id to file * * LWM2M path: /1032//10 * * @tapVersion(">=2.13") * @param bundleId input * @return */ setSelectedFileBundleId( /* * bundle id for the file being written. binary. */ bundleId) { return this.serviceCallRunner.execute(this.setSelectedFileBundleIdCall(bundleId)); } /** * * * LWM2M path: /1032//10 * * @tapVersion(">=2.13") * @param bundleId input * @return call options */ setSelectedFileBundleIdCall( /* * bundle id for the file being written. binary. */ bundleId) { const callOptions = Object.assign({}, this.resources.setSelectedFileBundleId); callOptions.body = bundleId; return callOptions; } /** * write user id to file * * LWM2M path: /1032//11 * * @tapVersion(">=2.13") * @param userId input * @return */ setSelectedFileUserId( /* * user id for the file being written. binary. */ userId) { return this.serviceCallRunner.execute(this.setSelectedFileUserIdCall(userId)); } /** * * * LWM2M path: /1032//11 * * @tapVersion(">=2.13") * @param userId input * @return call options */ setSelectedFileUserIdCall( /* * user id for the file being written. binary. */ userId) { const callOptions = Object.assign({}, this.resources.setSelectedFileUserId); callOptions.body = userId; return callOptions; } /** * read data from the selected file * * LWM2M path: /1032//4 * * @tapVersion(">=2.13") * @param options input * @return */ readSelectedFile( /* * */ options) { return this.serviceCallRunner.execute(this.readSelectedFileCall(options)); } /** * * * LWM2M path: /1032//4 * * @tapVersion(">=2.13") * @param options input * @return call options */ readSelectedFileCall( /* * */ options) { const callOptions = Object.assign({}, this.resources.readSelectedFile); callOptions.body = options; return callOptions; } /** * delete file * * LWM2M path: /1032//6 * * @tapVersion(">=2.13") * @return */ deleteSelectedFile() { return this.serviceCallRunner.execute(this.deleteSelectedFileCall()); } /** * * * LWM2M path: /1032//6 * * @tapVersion(">=2.13") * @return call options */ deleteSelectedFileCall() { const callOptions = Object.assign({}, this.resources.deleteSelectedFile); return callOptions; } /** * clear all files * * LWM2M path: /1032//7 * * @tapVersion(">=2.13") * @return */ clearAllFiles() { return this.serviceCallRunner.execute(this.clearAllFilesCall()); } /** * * * LWM2M path: /1032//7 * * @tapVersion(">=2.13") * @return call options */ clearAllFilesCall() { const callOptions = Object.assign({}, this.resources.clearAllFiles); return callOptions; } /** * get size of the selected file * * LWM2M path: /1032//5 * * @tapVersion(">=2.13") * @return */ getSelectedFileSize() { return this.serviceCallRunner.execute(this.getSelectedFileSizeCall()); } /** * * * LWM2M path: /1032//5 * * @tapVersion(">=2.13") * @return call options */ getSelectedFileSizeCall() { const callOptions = Object.assign({}, this.resources.getSelectedFileSize); return callOptions; } /** * list files * * LWM2M path: /1032//9 * * @tapVersion(">=2.13") * @return */ listFiles() { return this.serviceCallRunner.execute(this.listFilesCall()); } /** * * * LWM2M path: /1032//9 * * @tapVersion(">=2.13") * @return call options */ listFilesCall() { const callOptions = Object.assign({}, this.resources.listFiles); return callOptions; } } const _TAP_SERVICE_EXTENSION_FILESYSTEM_ = extendServiceContainer('fileSystem', FileSystemService); /** * Generated file. Do not edit */ const ResourceMetaData = {}; // import './lib/custom/extension'; /** * Generated bundle index. Do not edit. */ export { SERVICE_CALLS as FILESYSTEM_SERVICE_CALLS, ResourceMetaData as FileSystemResourceMetaData, FileSystemService, ReadSelectedFileParamsConverter, _TAP_SERVICE_EXTENSION_FILESYSTEM_, serviceConverters as fileSystemConverters }; //# sourceMappingURL=iotize-tap-service-impl-file-system.js.map