UNPKG

9.37 kBJavaScriptView Raw
1"use strict";
2/*
3 * ---------------------------------------------------------
4 * Copyright(C) Microsoft Corporation. All rights reserved.
5 * ---------------------------------------------------------
6 *
7 * ---------------------------------------------------------
8 * Generated file, DO NOT EDIT
9 * ---------------------------------------------------------
10 */
11var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13 return new (P || (P = Promise))(function (resolve, reject) {
14 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17 step((generator = generator.apply(thisArg, _arguments || [])).next());
18 });
19};
20Object.defineProperty(exports, "__esModule", { value: true });
21exports.FileContainerApiBase = void 0;
22const basem = require("./ClientApiBases");
23const FileContainerInterfaces = require("./interfaces/FileContainerInterfaces");
24class FileContainerApiBase extends basem.ClientApiBase {
25 constructor(baseUrl, handlers, options) {
26 super(baseUrl, handlers, 'node-FileContainer-api', options);
27 }
28 /**
29 * Creates the specified items in the referenced container.
30 *
31 * @param {VSSInterfaces.VssJsonCollectionWrapperV<FileContainerInterfaces.FileContainerItem[]>} items
32 * @param {number} containerId
33 * @param {string} scope - A guid representing the scope of the container. This is often the project id.
34 */
35 createItems(items, containerId, scope) {
36 return __awaiter(this, void 0, void 0, function* () {
37 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
38 let routeValues = {
39 containerId: containerId
40 };
41 let queryValues = {
42 scope: scope,
43 };
44 try {
45 let verData = yield this.vsoClient.getVersioningData("7.2-preview.4", "Container", "e4f5c81e-e250-447b-9fef-bd48471bea5e", routeValues, queryValues);
46 let url = verData.requestUrl;
47 let options = this.createRequestOptions('application/json', verData.apiVersion);
48 let res;
49 res = yield this.rest.create(url, items, options);
50 let ret = this.formatResponse(res.result, FileContainerInterfaces.TypeInfo.FileContainerItem, true);
51 resolve(ret);
52 }
53 catch (err) {
54 reject(err);
55 }
56 }));
57 });
58 }
59 /**
60 * Deletes the specified items in a container.
61 *
62 * @param {number} containerId - Container Id.
63 * @param {string} itemPath - Path to delete.
64 * @param {string} scope - A guid representing the scope of the container. This is often the project id.
65 */
66 deleteItem(containerId, itemPath, scope) {
67 return __awaiter(this, void 0, void 0, function* () {
68 if (itemPath == null) {
69 throw new TypeError('itemPath can not be null or undefined');
70 }
71 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
72 let routeValues = {
73 containerId: containerId
74 };
75 let queryValues = {
76 itemPath: itemPath,
77 scope: scope,
78 };
79 try {
80 let verData = yield this.vsoClient.getVersioningData("7.2-preview.4", "Container", "e4f5c81e-e250-447b-9fef-bd48471bea5e", routeValues, queryValues);
81 let url = verData.requestUrl;
82 let options = this.createRequestOptions('application/json', verData.apiVersion);
83 let res;
84 res = yield this.rest.del(url, options);
85 let ret = this.formatResponse(res.result, null, false);
86 resolve(ret);
87 }
88 catch (err) {
89 reject(err);
90 }
91 }));
92 });
93 }
94 /**
95 * Gets containers filtered by a comma separated list of artifact uris within the same scope, if not specified returns all containers
96 *
97 * @param {string} scope - A guid representing the scope of the container. This is often the project id.
98 * @param {string} artifactUris
99 */
100 getContainers(scope, artifactUris) {
101 return __awaiter(this, void 0, void 0, function* () {
102 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
103 let routeValues = {};
104 let queryValues = {
105 scope: scope,
106 artifactUris: artifactUris,
107 };
108 try {
109 let verData = yield this.vsoClient.getVersioningData("7.2-preview.4", "Container", "e4f5c81e-e250-447b-9fef-bd48471bea5e", routeValues, queryValues);
110 let url = verData.requestUrl;
111 let options = this.createRequestOptions('application/json', verData.apiVersion);
112 let res;
113 res = yield this.rest.get(url, options);
114 let ret = this.formatResponse(res.result, FileContainerInterfaces.TypeInfo.FileContainer, true);
115 resolve(ret);
116 }
117 catch (err) {
118 reject(err);
119 }
120 }));
121 });
122 }
123 /**
124 * Gets the specified file container object in a format dependent upon the given parameters or HTTP Accept request header
125 *
126 * @param {number} containerId - The requested container Id
127 * @param {string} scope - A guid representing the scope of the container. This is often the project id.
128 * @param {string} itemPath - The path to the item of interest
129 * @param {boolean} metadata - If true, this overrides any specified format parameter or HTTP Accept request header to provide non-recursive information for the given itemPath
130 * @param {string} format - If specified, this overrides the HTTP Accept request header to return either 'json' or 'zip'. If $format is specified, then api-version should also be specified as a query parameter.
131 * @param {string} downloadFileName - If specified and returning other than JSON format, then this download name will be used (else defaults to itemPath)
132 * @param {boolean} includeDownloadTickets
133 * @param {boolean} isShallow - If true, returns only immediate children(files & folders) for the given itemPath. False will return all items recursively within itemPath.
134 * @param {boolean} ignoreRequestedMediaType - Set to true to ignore the HTTP Accept request header. Default is false.
135 * @param {boolean} includeBlobMetadata
136 * @param {boolean} saveAbsolutePath - Set to false to not save the absolute path to the specified directory of the artifact in the returned archive. Works only for artifact directories. Default is true.
137 * @param {boolean} preferRedirect - Set to true to get the redirect response which leads to the stream with content. Default is false.
138 */
139 getItems(containerId, scope, itemPath, metadata, format, downloadFileName, includeDownloadTickets, isShallow, ignoreRequestedMediaType, includeBlobMetadata, saveAbsolutePath, preferRedirect) {
140 return __awaiter(this, void 0, void 0, function* () {
141 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
142 let routeValues = {
143 containerId: containerId
144 };
145 let queryValues = {
146 scope: scope,
147 itemPath: itemPath,
148 metadata: metadata,
149 '$format': format,
150 downloadFileName: downloadFileName,
151 includeDownloadTickets: includeDownloadTickets,
152 isShallow: isShallow,
153 ignoreRequestedMediaType: ignoreRequestedMediaType,
154 includeBlobMetadata: includeBlobMetadata,
155 saveAbsolutePath: saveAbsolutePath,
156 preferRedirect: preferRedirect,
157 };
158 try {
159 let verData = yield this.vsoClient.getVersioningData("7.2-preview.4", "Container", "e4f5c81e-e250-447b-9fef-bd48471bea5e", routeValues, queryValues);
160 let url = verData.requestUrl;
161 let options = this.createRequestOptions('application/json', verData.apiVersion);
162 let res;
163 res = yield this.rest.get(url, options);
164 let ret = this.formatResponse(res.result, FileContainerInterfaces.TypeInfo.FileContainerItem, true);
165 resolve(ret);
166 }
167 catch (err) {
168 reject(err);
169 }
170 }));
171 });
172 }
173}
174exports.FileContainerApiBase = FileContainerApiBase;