microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
lib/app-center-node-client/src/crash/operations/crashGroups.js
1149lines · modecode
| 1 | /* |
| 2 | * Code generated by Microsoft (R) AutoRest Code Generator. |
| 3 | * Changes may cause incorrect behavior and will be lost if the code is |
| 4 | * regenerated. |
| 5 | */ |
| 6 | |
| 7 | 'use strict'; |
| 8 | |
| 9 | const msRest = require('ms-rest'); |
| 10 | const WebResource = msRest.WebResource; |
| 11 | |
| 12 | /** |
| 13 | * @summary Gets a list of crash groups and whether the list contains all |
| 14 | * available groups. |
| 15 | * |
| 16 | * Gets a list of crash groups and whether the list contains all available |
| 17 | * groups. |
| 18 | * |
| 19 | * @param {string} appName The name of the application |
| 20 | * |
| 21 | * @param {string} ownerName The name of the owner |
| 22 | * |
| 23 | * @param {object} [options] Optional Parameters. |
| 24 | * |
| 25 | * @param {string} [options.orderby] the OData-like $orderby argument. Possible |
| 26 | * values include: 'last_occurrence asc', 'last_occurrence desc', 'count asc', |
| 27 | * 'count desc', 'display_id asc', 'display_id desc', 'impacted_users asc', |
| 28 | * 'impacted_users desc' |
| 29 | * |
| 30 | * @param {string} [options.appVersion] version |
| 31 | * |
| 32 | * @param {string} [options.continuationToken] Cassandra request continuation |
| 33 | * token. The token is used for pagination. |
| 34 | * |
| 35 | * @param {string} [options.groupStatus] Possible values include: 'open', |
| 36 | * 'closed', 'ignored' |
| 37 | * |
| 38 | * @param {string} [options.groupTextSearch] A freetext search that matches in |
| 39 | * crash, crash types, crash stack_traces and crash user |
| 40 | * |
| 41 | * @param {string} [options.groupType] Possible values include: 'GroupType1', |
| 42 | * 'GroupType2' |
| 43 | * |
| 44 | * @param {boolean} [options.includeUserCounts] if true include impacted user |
| 45 | * counts in crash group results |
| 46 | * |
| 47 | * @param {date} [options.lastOccurrenceFrom] Earliest date when the last time |
| 48 | * a crash occured in a crash group |
| 49 | * |
| 50 | * @param {date} [options.lastOccurrenceTo] Latest date when the last time a |
| 51 | * crash occured in a crash group |
| 52 | * |
| 53 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 54 | * request |
| 55 | * |
| 56 | * @param {function} callback - The callback. |
| 57 | * |
| 58 | * @returns {function} callback(err, result, request, response) |
| 59 | * |
| 60 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 61 | * |
| 62 | * {object} [result] - The deserialized result object if an error did not occur. |
| 63 | * See {@link CrashGroupsContainer} for more information. |
| 64 | * |
| 65 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 66 | * |
| 67 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 68 | */ |
| 69 | function _list(appName, ownerName, options, callback) { |
| 70 | /* jshint validthis: true */ |
| 71 | let client = this.client; |
| 72 | if(!callback && typeof options === 'function') { |
| 73 | callback = options; |
| 74 | options = null; |
| 75 | } |
| 76 | if (!callback) { |
| 77 | throw new Error('callback cannot be null.'); |
| 78 | } |
| 79 | let orderby = (options && options.orderby !== undefined) ? options.orderby : 'last_occurrence desc'; |
| 80 | let appVersion = (options && options.appVersion !== undefined) ? options.appVersion : undefined; |
| 81 | let continuationToken = (options && options.continuationToken !== undefined) ? options.continuationToken : undefined; |
| 82 | let groupStatus = (options && options.groupStatus !== undefined) ? options.groupStatus : undefined; |
| 83 | let groupTextSearch = (options && options.groupTextSearch !== undefined) ? options.groupTextSearch : undefined; |
| 84 | let groupType = (options && options.groupType !== undefined) ? options.groupType : undefined; |
| 85 | let includeUserCounts = (options && options.includeUserCounts !== undefined) ? options.includeUserCounts : false; |
| 86 | let lastOccurrenceFrom = (options && options.lastOccurrenceFrom !== undefined) ? options.lastOccurrenceFrom : undefined; |
| 87 | let lastOccurrenceTo = (options && options.lastOccurrenceTo !== undefined) ? options.lastOccurrenceTo : undefined; |
| 88 | // Validate |
| 89 | try { |
| 90 | if (orderby !== null && orderby !== undefined && typeof orderby.valueOf() !== 'string') { |
| 91 | throw new Error('orderby must be of type string.'); |
| 92 | } |
| 93 | if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') { |
| 94 | throw new Error('appName cannot be null or undefined and it must be of type string.'); |
| 95 | } |
| 96 | if (appVersion !== null && appVersion !== undefined && typeof appVersion.valueOf() !== 'string') { |
| 97 | throw new Error('appVersion must be of type string.'); |
| 98 | } |
| 99 | if (continuationToken !== null && continuationToken !== undefined && typeof continuationToken.valueOf() !== 'string') { |
| 100 | throw new Error('continuationToken must be of type string.'); |
| 101 | } |
| 102 | if (groupStatus !== null && groupStatus !== undefined && typeof groupStatus.valueOf() !== 'string') { |
| 103 | throw new Error('groupStatus must be of type string.'); |
| 104 | } |
| 105 | if (groupTextSearch !== null && groupTextSearch !== undefined && typeof groupTextSearch.valueOf() !== 'string') { |
| 106 | throw new Error('groupTextSearch must be of type string.'); |
| 107 | } |
| 108 | if (groupType !== null && groupType !== undefined && typeof groupType.valueOf() !== 'string') { |
| 109 | throw new Error('groupType must be of type string.'); |
| 110 | } |
| 111 | if (includeUserCounts !== null && includeUserCounts !== undefined && typeof includeUserCounts !== 'boolean') { |
| 112 | throw new Error('includeUserCounts must be of type boolean.'); |
| 113 | } |
| 114 | if (lastOccurrenceFrom && !(lastOccurrenceFrom instanceof Date || |
| 115 | (typeof lastOccurrenceFrom.valueOf() === 'string' && !isNaN(Date.parse(lastOccurrenceFrom))))) { |
| 116 | throw new Error('lastOccurrenceFrom must be of type date.'); |
| 117 | } |
| 118 | if (lastOccurrenceTo && !(lastOccurrenceTo instanceof Date || |
| 119 | (typeof lastOccurrenceTo.valueOf() === 'string' && !isNaN(Date.parse(lastOccurrenceTo))))) { |
| 120 | throw new Error('lastOccurrenceTo must be of type date.'); |
| 121 | } |
| 122 | if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') { |
| 123 | throw new Error('ownerName cannot be null or undefined and it must be of type string.'); |
| 124 | } |
| 125 | } catch (error) { |
| 126 | return callback(error); |
| 127 | } |
| 128 | |
| 129 | // Construct URL |
| 130 | let baseUrl = this.client.baseUri; |
| 131 | let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}/crash_groups'; |
| 132 | requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName)); |
| 133 | requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName)); |
| 134 | let queryParameters = []; |
| 135 | if (orderby !== null && orderby !== undefined) { |
| 136 | queryParameters.push('$orderby=' + encodeURIComponent(orderby)); |
| 137 | } |
| 138 | if (appVersion !== null && appVersion !== undefined) { |
| 139 | queryParameters.push('app_version=' + encodeURIComponent(appVersion)); |
| 140 | } |
| 141 | if (continuationToken !== null && continuationToken !== undefined) { |
| 142 | queryParameters.push('continuation_token=' + encodeURIComponent(continuationToken)); |
| 143 | } |
| 144 | if (groupStatus !== null && groupStatus !== undefined) { |
| 145 | queryParameters.push('group_status=' + encodeURIComponent(groupStatus)); |
| 146 | } |
| 147 | if (groupTextSearch !== null && groupTextSearch !== undefined) { |
| 148 | queryParameters.push('group_text_search=' + encodeURIComponent(groupTextSearch)); |
| 149 | } |
| 150 | if (groupType !== null && groupType !== undefined) { |
| 151 | queryParameters.push('group_type=' + encodeURIComponent(groupType)); |
| 152 | } |
| 153 | if (includeUserCounts !== null && includeUserCounts !== undefined) { |
| 154 | queryParameters.push('include_user_counts=' + encodeURIComponent(includeUserCounts.toString())); |
| 155 | } |
| 156 | if (lastOccurrenceFrom !== null && lastOccurrenceFrom !== undefined) { |
| 157 | queryParameters.push('last_occurrence_from=' + encodeURIComponent(client.serializeObject(lastOccurrenceFrom))); |
| 158 | } |
| 159 | if (lastOccurrenceTo !== null && lastOccurrenceTo !== undefined) { |
| 160 | queryParameters.push('last_occurrence_to=' + encodeURIComponent(client.serializeObject(lastOccurrenceTo))); |
| 161 | } |
| 162 | if (queryParameters.length > 0) { |
| 163 | requestUrl += '?' + queryParameters.join('&'); |
| 164 | } |
| 165 | |
| 166 | // Create HTTP transport objects |
| 167 | let httpRequest = new WebResource(); |
| 168 | httpRequest.method = 'GET'; |
| 169 | httpRequest.url = requestUrl; |
| 170 | httpRequest.headers = {}; |
| 171 | // Set Headers |
| 172 | httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; |
| 173 | if(options) { |
| 174 | for(let headerName in options['customHeaders']) { |
| 175 | if (options['customHeaders'].hasOwnProperty(headerName)) { |
| 176 | httpRequest.headers[headerName] = options['customHeaders'][headerName]; |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | httpRequest.body = null; |
| 181 | // Send Request |
| 182 | return client.pipeline(httpRequest, (err, response, responseBody) => { |
| 183 | if (err) { |
| 184 | return callback(err); |
| 185 | } |
| 186 | let statusCode = response.statusCode; |
| 187 | if (statusCode !== 200) { |
| 188 | let error = new Error(responseBody); |
| 189 | error.statusCode = response.statusCode; |
| 190 | error.request = msRest.stripRequest(httpRequest); |
| 191 | error.response = msRest.stripResponse(response); |
| 192 | if (responseBody === '') responseBody = null; |
| 193 | let parsedErrorResponse; |
| 194 | try { |
| 195 | parsedErrorResponse = JSON.parse(responseBody); |
| 196 | if (parsedErrorResponse) { |
| 197 | let internalError = null; |
| 198 | if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; |
| 199 | error.code = internalError ? internalError.code : parsedErrorResponse.code; |
| 200 | error.message = internalError ? internalError.message : parsedErrorResponse.message; |
| 201 | } |
| 202 | } catch (defaultError) { |
| 203 | error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + |
| 204 | `- "${responseBody}" for the default response.`; |
| 205 | return callback(error); |
| 206 | } |
| 207 | return callback(error); |
| 208 | } |
| 209 | // Create Result |
| 210 | let result = null; |
| 211 | if (responseBody === '') responseBody = null; |
| 212 | // Deserialize Response |
| 213 | if (statusCode === 200) { |
| 214 | let parsedResponse = null; |
| 215 | try { |
| 216 | parsedResponse = JSON.parse(responseBody); |
| 217 | result = JSON.parse(responseBody); |
| 218 | if (parsedResponse !== null && parsedResponse !== undefined) { |
| 219 | let resultMapper = new client.models['CrashGroupsContainer']().mapper(); |
| 220 | result = client.deserialize(resultMapper, parsedResponse, 'result'); |
| 221 | } |
| 222 | } catch (error) { |
| 223 | let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); |
| 224 | deserializationError.request = msRest.stripRequest(httpRequest); |
| 225 | deserializationError.response = msRest.stripResponse(response); |
| 226 | return callback(deserializationError); |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | return callback(null, result, httpRequest, response); |
| 231 | }); |
| 232 | } |
| 233 | |
| 234 | /** |
| 235 | * Gets a specific group |
| 236 | * |
| 237 | * @param {string} appName The name of the application |
| 238 | * |
| 239 | * @param {string} crashGroupId id of a specific group |
| 240 | * |
| 241 | * @param {string} ownerName The name of the owner |
| 242 | * |
| 243 | * @param {object} [options] Optional Parameters. |
| 244 | * |
| 245 | * @param {boolean} [options.includeUserCounts] if true include impacted user |
| 246 | * counts in crash group results |
| 247 | * |
| 248 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 249 | * request |
| 250 | * |
| 251 | * @param {function} callback - The callback. |
| 252 | * |
| 253 | * @returns {function} callback(err, result, request, response) |
| 254 | * |
| 255 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 256 | * |
| 257 | * {object} [result] - The deserialized result object if an error did not occur. |
| 258 | * See {@link CrashGroup} for more information. |
| 259 | * |
| 260 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 261 | * |
| 262 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 263 | */ |
| 264 | function _get(appName, crashGroupId, ownerName, options, callback) { |
| 265 | /* jshint validthis: true */ |
| 266 | let client = this.client; |
| 267 | if(!callback && typeof options === 'function') { |
| 268 | callback = options; |
| 269 | options = null; |
| 270 | } |
| 271 | if (!callback) { |
| 272 | throw new Error('callback cannot be null.'); |
| 273 | } |
| 274 | let includeUserCounts = (options && options.includeUserCounts !== undefined) ? options.includeUserCounts : false; |
| 275 | // Validate |
| 276 | try { |
| 277 | if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') { |
| 278 | throw new Error('appName cannot be null or undefined and it must be of type string.'); |
| 279 | } |
| 280 | if (crashGroupId === null || crashGroupId === undefined || typeof crashGroupId.valueOf() !== 'string') { |
| 281 | throw new Error('crashGroupId cannot be null or undefined and it must be of type string.'); |
| 282 | } |
| 283 | if (includeUserCounts !== null && includeUserCounts !== undefined && typeof includeUserCounts !== 'boolean') { |
| 284 | throw new Error('includeUserCounts must be of type boolean.'); |
| 285 | } |
| 286 | if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') { |
| 287 | throw new Error('ownerName cannot be null or undefined and it must be of type string.'); |
| 288 | } |
| 289 | } catch (error) { |
| 290 | return callback(error); |
| 291 | } |
| 292 | |
| 293 | // Construct URL |
| 294 | let baseUrl = this.client.baseUri; |
| 295 | let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}/crash_groups/{crash_group_id}'; |
| 296 | requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName)); |
| 297 | requestUrl = requestUrl.replace('{crash_group_id}', encodeURIComponent(crashGroupId)); |
| 298 | requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName)); |
| 299 | let queryParameters = []; |
| 300 | if (includeUserCounts !== null && includeUserCounts !== undefined) { |
| 301 | queryParameters.push('include_user_counts=' + encodeURIComponent(includeUserCounts.toString())); |
| 302 | } |
| 303 | if (queryParameters.length > 0) { |
| 304 | requestUrl += '?' + queryParameters.join('&'); |
| 305 | } |
| 306 | |
| 307 | // Create HTTP transport objects |
| 308 | let httpRequest = new WebResource(); |
| 309 | httpRequest.method = 'GET'; |
| 310 | httpRequest.url = requestUrl; |
| 311 | httpRequest.headers = {}; |
| 312 | // Set Headers |
| 313 | httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; |
| 314 | if(options) { |
| 315 | for(let headerName in options['customHeaders']) { |
| 316 | if (options['customHeaders'].hasOwnProperty(headerName)) { |
| 317 | httpRequest.headers[headerName] = options['customHeaders'][headerName]; |
| 318 | } |
| 319 | } |
| 320 | } |
| 321 | httpRequest.body = null; |
| 322 | // Send Request |
| 323 | return client.pipeline(httpRequest, (err, response, responseBody) => { |
| 324 | if (err) { |
| 325 | return callback(err); |
| 326 | } |
| 327 | let statusCode = response.statusCode; |
| 328 | if (statusCode !== 200) { |
| 329 | let error = new Error(responseBody); |
| 330 | error.statusCode = response.statusCode; |
| 331 | error.request = msRest.stripRequest(httpRequest); |
| 332 | error.response = msRest.stripResponse(response); |
| 333 | if (responseBody === '') responseBody = null; |
| 334 | let parsedErrorResponse; |
| 335 | try { |
| 336 | parsedErrorResponse = JSON.parse(responseBody); |
| 337 | if (parsedErrorResponse) { |
| 338 | let internalError = null; |
| 339 | if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; |
| 340 | error.code = internalError ? internalError.code : parsedErrorResponse.code; |
| 341 | error.message = internalError ? internalError.message : parsedErrorResponse.message; |
| 342 | } |
| 343 | } catch (defaultError) { |
| 344 | error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + |
| 345 | `- "${responseBody}" for the default response.`; |
| 346 | return callback(error); |
| 347 | } |
| 348 | return callback(error); |
| 349 | } |
| 350 | // Create Result |
| 351 | let result = null; |
| 352 | if (responseBody === '') responseBody = null; |
| 353 | // Deserialize Response |
| 354 | if (statusCode === 200) { |
| 355 | let parsedResponse = null; |
| 356 | try { |
| 357 | parsedResponse = JSON.parse(responseBody); |
| 358 | result = JSON.parse(responseBody); |
| 359 | if (parsedResponse !== null && parsedResponse !== undefined) { |
| 360 | let resultMapper = new client.models['CrashGroup']().mapper(); |
| 361 | result = client.deserialize(resultMapper, parsedResponse, 'result'); |
| 362 | } |
| 363 | } catch (error) { |
| 364 | let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); |
| 365 | deserializationError.request = msRest.stripRequest(httpRequest); |
| 366 | deserializationError.response = msRest.stripResponse(response); |
| 367 | return callback(deserializationError); |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | return callback(null, result, httpRequest, response); |
| 372 | }); |
| 373 | } |
| 374 | |
| 375 | /** |
| 376 | * Updates a group |
| 377 | * |
| 378 | * @param {string} appName The name of the application |
| 379 | * |
| 380 | * @param {string} crashGroupId id of a specific group |
| 381 | * |
| 382 | * @param {object} group Group change object. All fields are optional and only |
| 383 | * provided fields will get updated. |
| 384 | * |
| 385 | * @param {object} [group.status] |
| 386 | * |
| 387 | * @param {string} [group.annotation] |
| 388 | * |
| 389 | * @param {string} ownerName The name of the owner |
| 390 | * |
| 391 | * @param {object} [options] Optional Parameters. |
| 392 | * |
| 393 | * @param {boolean} [options.includeUserCounts] if true include impacted user |
| 394 | * counts in crash group results |
| 395 | * |
| 396 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 397 | * request |
| 398 | * |
| 399 | * @param {function} callback - The callback. |
| 400 | * |
| 401 | * @returns {function} callback(err, result, request, response) |
| 402 | * |
| 403 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 404 | * |
| 405 | * {object} [result] - The deserialized result object if an error did not occur. |
| 406 | * See {@link CrashGroup} for more information. |
| 407 | * |
| 408 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 409 | * |
| 410 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 411 | */ |
| 412 | function _update(appName, crashGroupId, group, ownerName, options, callback) { |
| 413 | /* jshint validthis: true */ |
| 414 | let client = this.client; |
| 415 | if(!callback && typeof options === 'function') { |
| 416 | callback = options; |
| 417 | options = null; |
| 418 | } |
| 419 | if (!callback) { |
| 420 | throw new Error('callback cannot be null.'); |
| 421 | } |
| 422 | let includeUserCounts = (options && options.includeUserCounts !== undefined) ? options.includeUserCounts : false; |
| 423 | // Validate |
| 424 | try { |
| 425 | if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') { |
| 426 | throw new Error('appName cannot be null or undefined and it must be of type string.'); |
| 427 | } |
| 428 | if (crashGroupId === null || crashGroupId === undefined || typeof crashGroupId.valueOf() !== 'string') { |
| 429 | throw new Error('crashGroupId cannot be null or undefined and it must be of type string.'); |
| 430 | } |
| 431 | if (group === null || group === undefined) { |
| 432 | throw new Error('group cannot be null or undefined.'); |
| 433 | } |
| 434 | if (includeUserCounts !== null && includeUserCounts !== undefined && typeof includeUserCounts !== 'boolean') { |
| 435 | throw new Error('includeUserCounts must be of type boolean.'); |
| 436 | } |
| 437 | if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') { |
| 438 | throw new Error('ownerName cannot be null or undefined and it must be of type string.'); |
| 439 | } |
| 440 | } catch (error) { |
| 441 | return callback(error); |
| 442 | } |
| 443 | |
| 444 | // Construct URL |
| 445 | let baseUrl = this.client.baseUri; |
| 446 | let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}/crash_groups/{crash_group_id}'; |
| 447 | requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName)); |
| 448 | requestUrl = requestUrl.replace('{crash_group_id}', encodeURIComponent(crashGroupId)); |
| 449 | requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName)); |
| 450 | let queryParameters = []; |
| 451 | if (includeUserCounts !== null && includeUserCounts !== undefined) { |
| 452 | queryParameters.push('include_user_counts=' + encodeURIComponent(includeUserCounts.toString())); |
| 453 | } |
| 454 | if (queryParameters.length > 0) { |
| 455 | requestUrl += '?' + queryParameters.join('&'); |
| 456 | } |
| 457 | |
| 458 | // Create HTTP transport objects |
| 459 | let httpRequest = new WebResource(); |
| 460 | httpRequest.method = 'PATCH'; |
| 461 | httpRequest.url = requestUrl; |
| 462 | httpRequest.headers = {}; |
| 463 | // Set Headers |
| 464 | httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; |
| 465 | if(options) { |
| 466 | for(let headerName in options['customHeaders']) { |
| 467 | if (options['customHeaders'].hasOwnProperty(headerName)) { |
| 468 | httpRequest.headers[headerName] = options['customHeaders'][headerName]; |
| 469 | } |
| 470 | } |
| 471 | } |
| 472 | // Serialize Request |
| 473 | let requestContent = null; |
| 474 | let requestModel = null; |
| 475 | try { |
| 476 | if (group !== null && group !== undefined) { |
| 477 | let requestModelMapper = new client.models['CrashGroupChange']().mapper(); |
| 478 | requestModel = client.serialize(requestModelMapper, group, 'group'); |
| 479 | requestContent = JSON.stringify(requestModel); |
| 480 | } |
| 481 | } catch (error) { |
| 482 | let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + |
| 483 | `payload - ${JSON.stringify(group, null, 2)}.`); |
| 484 | return callback(serializationError); |
| 485 | } |
| 486 | httpRequest.body = requestContent; |
| 487 | // Send Request |
| 488 | return client.pipeline(httpRequest, (err, response, responseBody) => { |
| 489 | if (err) { |
| 490 | return callback(err); |
| 491 | } |
| 492 | let statusCode = response.statusCode; |
| 493 | if (statusCode !== 200) { |
| 494 | let error = new Error(responseBody); |
| 495 | error.statusCode = response.statusCode; |
| 496 | error.request = msRest.stripRequest(httpRequest); |
| 497 | error.response = msRest.stripResponse(response); |
| 498 | if (responseBody === '') responseBody = null; |
| 499 | let parsedErrorResponse; |
| 500 | try { |
| 501 | parsedErrorResponse = JSON.parse(responseBody); |
| 502 | if (parsedErrorResponse) { |
| 503 | let internalError = null; |
| 504 | if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; |
| 505 | error.code = internalError ? internalError.code : parsedErrorResponse.code; |
| 506 | error.message = internalError ? internalError.message : parsedErrorResponse.message; |
| 507 | } |
| 508 | } catch (defaultError) { |
| 509 | error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + |
| 510 | `- "${responseBody}" for the default response.`; |
| 511 | return callback(error); |
| 512 | } |
| 513 | return callback(error); |
| 514 | } |
| 515 | // Create Result |
| 516 | let result = null; |
| 517 | if (responseBody === '') responseBody = null; |
| 518 | // Deserialize Response |
| 519 | if (statusCode === 200) { |
| 520 | let parsedResponse = null; |
| 521 | try { |
| 522 | parsedResponse = JSON.parse(responseBody); |
| 523 | result = JSON.parse(responseBody); |
| 524 | if (parsedResponse !== null && parsedResponse !== undefined) { |
| 525 | let resultMapper = new client.models['CrashGroup']().mapper(); |
| 526 | result = client.deserialize(resultMapper, parsedResponse, 'result'); |
| 527 | } |
| 528 | } catch (error) { |
| 529 | let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); |
| 530 | deserializationError.request = msRest.stripRequest(httpRequest); |
| 531 | deserializationError.response = msRest.stripResponse(response); |
| 532 | return callback(deserializationError); |
| 533 | } |
| 534 | } |
| 535 | |
| 536 | return callback(null, result, httpRequest, response); |
| 537 | }); |
| 538 | } |
| 539 | |
| 540 | /** |
| 541 | * Gets a stacktrace for a specific crash |
| 542 | * |
| 543 | * @param {string} appName The name of the application |
| 544 | * |
| 545 | * @param {string} crashGroupId id of a specific group |
| 546 | * |
| 547 | * @param {string} ownerName The name of the owner |
| 548 | * |
| 549 | * @param {object} [options] Optional Parameters. |
| 550 | * |
| 551 | * @param {boolean} [options.groupingOnly] true if the stacktrace should be |
| 552 | * only the relevant thread / exception. Default is false |
| 553 | * |
| 554 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 555 | * request |
| 556 | * |
| 557 | * @param {function} callback - The callback. |
| 558 | * |
| 559 | * @returns {function} callback(err, result, request, response) |
| 560 | * |
| 561 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 562 | * |
| 563 | * {object} [result] - The deserialized result object if an error did not occur. |
| 564 | * See {@link Stacktrace} for more information. |
| 565 | * |
| 566 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 567 | * |
| 568 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 569 | */ |
| 570 | function _getStacktrace(appName, crashGroupId, ownerName, options, callback) { |
| 571 | /* jshint validthis: true */ |
| 572 | let client = this.client; |
| 573 | if(!callback && typeof options === 'function') { |
| 574 | callback = options; |
| 575 | options = null; |
| 576 | } |
| 577 | if (!callback) { |
| 578 | throw new Error('callback cannot be null.'); |
| 579 | } |
| 580 | let groupingOnly = (options && options.groupingOnly !== undefined) ? options.groupingOnly : false; |
| 581 | // Validate |
| 582 | try { |
| 583 | if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') { |
| 584 | throw new Error('appName cannot be null or undefined and it must be of type string.'); |
| 585 | } |
| 586 | if (crashGroupId === null || crashGroupId === undefined || typeof crashGroupId.valueOf() !== 'string') { |
| 587 | throw new Error('crashGroupId cannot be null or undefined and it must be of type string.'); |
| 588 | } |
| 589 | if (groupingOnly !== null && groupingOnly !== undefined && typeof groupingOnly !== 'boolean') { |
| 590 | throw new Error('groupingOnly must be of type boolean.'); |
| 591 | } |
| 592 | if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') { |
| 593 | throw new Error('ownerName cannot be null or undefined and it must be of type string.'); |
| 594 | } |
| 595 | } catch (error) { |
| 596 | return callback(error); |
| 597 | } |
| 598 | |
| 599 | // Construct URL |
| 600 | let baseUrl = this.client.baseUri; |
| 601 | let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}/crash_groups/{crash_group_id}/stacktrace'; |
| 602 | requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName)); |
| 603 | requestUrl = requestUrl.replace('{crash_group_id}', encodeURIComponent(crashGroupId)); |
| 604 | requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName)); |
| 605 | let queryParameters = []; |
| 606 | if (groupingOnly !== null && groupingOnly !== undefined) { |
| 607 | queryParameters.push('grouping_only=' + encodeURIComponent(groupingOnly.toString())); |
| 608 | } |
| 609 | if (queryParameters.length > 0) { |
| 610 | requestUrl += '?' + queryParameters.join('&'); |
| 611 | } |
| 612 | |
| 613 | // Create HTTP transport objects |
| 614 | let httpRequest = new WebResource(); |
| 615 | httpRequest.method = 'GET'; |
| 616 | httpRequest.url = requestUrl; |
| 617 | httpRequest.headers = {}; |
| 618 | // Set Headers |
| 619 | httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; |
| 620 | if(options) { |
| 621 | for(let headerName in options['customHeaders']) { |
| 622 | if (options['customHeaders'].hasOwnProperty(headerName)) { |
| 623 | httpRequest.headers[headerName] = options['customHeaders'][headerName]; |
| 624 | } |
| 625 | } |
| 626 | } |
| 627 | httpRequest.body = null; |
| 628 | // Send Request |
| 629 | return client.pipeline(httpRequest, (err, response, responseBody) => { |
| 630 | if (err) { |
| 631 | return callback(err); |
| 632 | } |
| 633 | let statusCode = response.statusCode; |
| 634 | if (statusCode !== 200) { |
| 635 | let error = new Error(responseBody); |
| 636 | error.statusCode = response.statusCode; |
| 637 | error.request = msRest.stripRequest(httpRequest); |
| 638 | error.response = msRest.stripResponse(response); |
| 639 | if (responseBody === '') responseBody = null; |
| 640 | let parsedErrorResponse; |
| 641 | try { |
| 642 | parsedErrorResponse = JSON.parse(responseBody); |
| 643 | if (parsedErrorResponse) { |
| 644 | let internalError = null; |
| 645 | if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; |
| 646 | error.code = internalError ? internalError.code : parsedErrorResponse.code; |
| 647 | error.message = internalError ? internalError.message : parsedErrorResponse.message; |
| 648 | } |
| 649 | } catch (defaultError) { |
| 650 | error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + |
| 651 | `- "${responseBody}" for the default response.`; |
| 652 | return callback(error); |
| 653 | } |
| 654 | return callback(error); |
| 655 | } |
| 656 | // Create Result |
| 657 | let result = null; |
| 658 | if (responseBody === '') responseBody = null; |
| 659 | // Deserialize Response |
| 660 | if (statusCode === 200) { |
| 661 | let parsedResponse = null; |
| 662 | try { |
| 663 | parsedResponse = JSON.parse(responseBody); |
| 664 | result = JSON.parse(responseBody); |
| 665 | if (parsedResponse !== null && parsedResponse !== undefined) { |
| 666 | let resultMapper = new client.models['Stacktrace']().mapper(); |
| 667 | result = client.deserialize(resultMapper, parsedResponse, 'result'); |
| 668 | } |
| 669 | } catch (error) { |
| 670 | let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); |
| 671 | deserializationError.request = msRest.stripRequest(httpRequest); |
| 672 | deserializationError.response = msRest.stripResponse(response); |
| 673 | return callback(deserializationError); |
| 674 | } |
| 675 | } |
| 676 | |
| 677 | return callback(null, result, httpRequest, response); |
| 678 | }); |
| 679 | } |
| 680 | |
| 681 | /** Class representing a CrashGroups. */ |
| 682 | class CrashGroups { |
| 683 | /** |
| 684 | * Create a CrashGroups. |
| 685 | * @param {CrashClient} client Reference to the service client. |
| 686 | */ |
| 687 | constructor(client) { |
| 688 | this.client = client; |
| 689 | this._list = _list; |
| 690 | this._get = _get; |
| 691 | this._update = _update; |
| 692 | this._getStacktrace = _getStacktrace; |
| 693 | } |
| 694 | |
| 695 | /** |
| 696 | * @summary Gets a list of crash groups and whether the list contains all |
| 697 | * available groups. |
| 698 | * |
| 699 | * Gets a list of crash groups and whether the list contains all available |
| 700 | * groups. |
| 701 | * |
| 702 | * @param {string} appName The name of the application |
| 703 | * |
| 704 | * @param {string} ownerName The name of the owner |
| 705 | * |
| 706 | * @param {object} [options] Optional Parameters. |
| 707 | * |
| 708 | * @param {string} [options.orderby] the OData-like $orderby argument. Possible |
| 709 | * values include: 'last_occurrence asc', 'last_occurrence desc', 'count asc', |
| 710 | * 'count desc', 'display_id asc', 'display_id desc', 'impacted_users asc', |
| 711 | * 'impacted_users desc' |
| 712 | * |
| 713 | * @param {string} [options.appVersion] version |
| 714 | * |
| 715 | * @param {string} [options.continuationToken] Cassandra request continuation |
| 716 | * token. The token is used for pagination. |
| 717 | * |
| 718 | * @param {string} [options.groupStatus] Possible values include: 'open', |
| 719 | * 'closed', 'ignored' |
| 720 | * |
| 721 | * @param {string} [options.groupTextSearch] A freetext search that matches in |
| 722 | * crash, crash types, crash stack_traces and crash user |
| 723 | * |
| 724 | * @param {string} [options.groupType] Possible values include: 'GroupType1', |
| 725 | * 'GroupType2' |
| 726 | * |
| 727 | * @param {boolean} [options.includeUserCounts] if true include impacted user |
| 728 | * counts in crash group results |
| 729 | * |
| 730 | * @param {date} [options.lastOccurrenceFrom] Earliest date when the last time |
| 731 | * a crash occured in a crash group |
| 732 | * |
| 733 | * @param {date} [options.lastOccurrenceTo] Latest date when the last time a |
| 734 | * crash occured in a crash group |
| 735 | * |
| 736 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 737 | * request |
| 738 | * |
| 739 | * @returns {Promise} A promise is returned |
| 740 | * |
| 741 | * @resolve {HttpOperationResponse<CrashGroupsContainer>} - The deserialized result object. |
| 742 | * |
| 743 | * @reject {Error} - The error object. |
| 744 | */ |
| 745 | listWithHttpOperationResponse(appName, ownerName, options) { |
| 746 | let client = this.client; |
| 747 | let self = this; |
| 748 | return new Promise((resolve, reject) => { |
| 749 | self._list(appName, ownerName, options, (err, result, request, response) => { |
| 750 | let httpOperationResponse = new msRest.HttpOperationResponse(request, response); |
| 751 | httpOperationResponse.body = result; |
| 752 | if (err) { reject(err); } |
| 753 | else { resolve(httpOperationResponse); } |
| 754 | return; |
| 755 | }); |
| 756 | }); |
| 757 | } |
| 758 | |
| 759 | /** |
| 760 | * @summary Gets a list of crash groups and whether the list contains all |
| 761 | * available groups. |
| 762 | * |
| 763 | * Gets a list of crash groups and whether the list contains all available |
| 764 | * groups. |
| 765 | * |
| 766 | * @param {string} appName The name of the application |
| 767 | * |
| 768 | * @param {string} ownerName The name of the owner |
| 769 | * |
| 770 | * @param {object} [options] Optional Parameters. |
| 771 | * |
| 772 | * @param {string} [options.orderby] the OData-like $orderby argument. Possible |
| 773 | * values include: 'last_occurrence asc', 'last_occurrence desc', 'count asc', |
| 774 | * 'count desc', 'display_id asc', 'display_id desc', 'impacted_users asc', |
| 775 | * 'impacted_users desc' |
| 776 | * |
| 777 | * @param {string} [options.appVersion] version |
| 778 | * |
| 779 | * @param {string} [options.continuationToken] Cassandra request continuation |
| 780 | * token. The token is used for pagination. |
| 781 | * |
| 782 | * @param {string} [options.groupStatus] Possible values include: 'open', |
| 783 | * 'closed', 'ignored' |
| 784 | * |
| 785 | * @param {string} [options.groupTextSearch] A freetext search that matches in |
| 786 | * crash, crash types, crash stack_traces and crash user |
| 787 | * |
| 788 | * @param {string} [options.groupType] Possible values include: 'GroupType1', |
| 789 | * 'GroupType2' |
| 790 | * |
| 791 | * @param {boolean} [options.includeUserCounts] if true include impacted user |
| 792 | * counts in crash group results |
| 793 | * |
| 794 | * @param {date} [options.lastOccurrenceFrom] Earliest date when the last time |
| 795 | * a crash occured in a crash group |
| 796 | * |
| 797 | * @param {date} [options.lastOccurrenceTo] Latest date when the last time a |
| 798 | * crash occured in a crash group |
| 799 | * |
| 800 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 801 | * request |
| 802 | * |
| 803 | * @param {function} [optionalCallback] - The optional callback. |
| 804 | * |
| 805 | * @returns {function|Promise} If a callback was passed as the last parameter |
| 806 | * then it returns the callback else returns a Promise. |
| 807 | * |
| 808 | * {Promise} A promise is returned |
| 809 | * |
| 810 | * @resolve {CrashGroupsContainer} - The deserialized result object. |
| 811 | * |
| 812 | * @reject {Error} - The error object. |
| 813 | * |
| 814 | * {function} optionalCallback(err, result, request, response) |
| 815 | * |
| 816 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 817 | * |
| 818 | * {object} [result] - The deserialized result object if an error did not occur. |
| 819 | * See {@link CrashGroupsContainer} for more information. |
| 820 | * |
| 821 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 822 | * |
| 823 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 824 | */ |
| 825 | list(appName, ownerName, options, optionalCallback) { |
| 826 | let client = this.client; |
| 827 | let self = this; |
| 828 | if (!optionalCallback && typeof options === 'function') { |
| 829 | optionalCallback = options; |
| 830 | options = null; |
| 831 | } |
| 832 | if (!optionalCallback) { |
| 833 | return new Promise((resolve, reject) => { |
| 834 | self._list(appName, ownerName, options, (err, result, request, response) => { |
| 835 | if (err) { reject(err); } |
| 836 | else { resolve(result); } |
| 837 | return; |
| 838 | }); |
| 839 | }); |
| 840 | } else { |
| 841 | return self._list(appName, ownerName, options, optionalCallback); |
| 842 | } |
| 843 | } |
| 844 | |
| 845 | /** |
| 846 | * Gets a specific group |
| 847 | * |
| 848 | * @param {string} appName The name of the application |
| 849 | * |
| 850 | * @param {string} crashGroupId id of a specific group |
| 851 | * |
| 852 | * @param {string} ownerName The name of the owner |
| 853 | * |
| 854 | * @param {object} [options] Optional Parameters. |
| 855 | * |
| 856 | * @param {boolean} [options.includeUserCounts] if true include impacted user |
| 857 | * counts in crash group results |
| 858 | * |
| 859 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 860 | * request |
| 861 | * |
| 862 | * @returns {Promise} A promise is returned |
| 863 | * |
| 864 | * @resolve {HttpOperationResponse<CrashGroup>} - The deserialized result object. |
| 865 | * |
| 866 | * @reject {Error} - The error object. |
| 867 | */ |
| 868 | getWithHttpOperationResponse(appName, crashGroupId, ownerName, options) { |
| 869 | let client = this.client; |
| 870 | let self = this; |
| 871 | return new Promise((resolve, reject) => { |
| 872 | self._get(appName, crashGroupId, ownerName, options, (err, result, request, response) => { |
| 873 | let httpOperationResponse = new msRest.HttpOperationResponse(request, response); |
| 874 | httpOperationResponse.body = result; |
| 875 | if (err) { reject(err); } |
| 876 | else { resolve(httpOperationResponse); } |
| 877 | return; |
| 878 | }); |
| 879 | }); |
| 880 | } |
| 881 | |
| 882 | /** |
| 883 | * Gets a specific group |
| 884 | * |
| 885 | * @param {string} appName The name of the application |
| 886 | * |
| 887 | * @param {string} crashGroupId id of a specific group |
| 888 | * |
| 889 | * @param {string} ownerName The name of the owner |
| 890 | * |
| 891 | * @param {object} [options] Optional Parameters. |
| 892 | * |
| 893 | * @param {boolean} [options.includeUserCounts] if true include impacted user |
| 894 | * counts in crash group results |
| 895 | * |
| 896 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 897 | * request |
| 898 | * |
| 899 | * @param {function} [optionalCallback] - The optional callback. |
| 900 | * |
| 901 | * @returns {function|Promise} If a callback was passed as the last parameter |
| 902 | * then it returns the callback else returns a Promise. |
| 903 | * |
| 904 | * {Promise} A promise is returned |
| 905 | * |
| 906 | * @resolve {CrashGroup} - The deserialized result object. |
| 907 | * |
| 908 | * @reject {Error} - The error object. |
| 909 | * |
| 910 | * {function} optionalCallback(err, result, request, response) |
| 911 | * |
| 912 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 913 | * |
| 914 | * {object} [result] - The deserialized result object if an error did not occur. |
| 915 | * See {@link CrashGroup} for more information. |
| 916 | * |
| 917 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 918 | * |
| 919 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 920 | */ |
| 921 | get(appName, crashGroupId, ownerName, options, optionalCallback) { |
| 922 | let client = this.client; |
| 923 | let self = this; |
| 924 | if (!optionalCallback && typeof options === 'function') { |
| 925 | optionalCallback = options; |
| 926 | options = null; |
| 927 | } |
| 928 | if (!optionalCallback) { |
| 929 | return new Promise((resolve, reject) => { |
| 930 | self._get(appName, crashGroupId, ownerName, options, (err, result, request, response) => { |
| 931 | if (err) { reject(err); } |
| 932 | else { resolve(result); } |
| 933 | return; |
| 934 | }); |
| 935 | }); |
| 936 | } else { |
| 937 | return self._get(appName, crashGroupId, ownerName, options, optionalCallback); |
| 938 | } |
| 939 | } |
| 940 | |
| 941 | /** |
| 942 | * Updates a group |
| 943 | * |
| 944 | * @param {string} appName The name of the application |
| 945 | * |
| 946 | * @param {string} crashGroupId id of a specific group |
| 947 | * |
| 948 | * @param {object} group Group change object. All fields are optional and only |
| 949 | * provided fields will get updated. |
| 950 | * |
| 951 | * @param {object} [group.status] |
| 952 | * |
| 953 | * @param {string} [group.annotation] |
| 954 | * |
| 955 | * @param {string} ownerName The name of the owner |
| 956 | * |
| 957 | * @param {object} [options] Optional Parameters. |
| 958 | * |
| 959 | * @param {boolean} [options.includeUserCounts] if true include impacted user |
| 960 | * counts in crash group results |
| 961 | * |
| 962 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 963 | * request |
| 964 | * |
| 965 | * @returns {Promise} A promise is returned |
| 966 | * |
| 967 | * @resolve {HttpOperationResponse<CrashGroup>} - The deserialized result object. |
| 968 | * |
| 969 | * @reject {Error} - The error object. |
| 970 | */ |
| 971 | updateWithHttpOperationResponse(appName, crashGroupId, group, ownerName, options) { |
| 972 | let client = this.client; |
| 973 | let self = this; |
| 974 | return new Promise((resolve, reject) => { |
| 975 | self._update(appName, crashGroupId, group, ownerName, options, (err, result, request, response) => { |
| 976 | let httpOperationResponse = new msRest.HttpOperationResponse(request, response); |
| 977 | httpOperationResponse.body = result; |
| 978 | if (err) { reject(err); } |
| 979 | else { resolve(httpOperationResponse); } |
| 980 | return; |
| 981 | }); |
| 982 | }); |
| 983 | } |
| 984 | |
| 985 | /** |
| 986 | * Updates a group |
| 987 | * |
| 988 | * @param {string} appName The name of the application |
| 989 | * |
| 990 | * @param {string} crashGroupId id of a specific group |
| 991 | * |
| 992 | * @param {object} group Group change object. All fields are optional and only |
| 993 | * provided fields will get updated. |
| 994 | * |
| 995 | * @param {object} [group.status] |
| 996 | * |
| 997 | * @param {string} [group.annotation] |
| 998 | * |
| 999 | * @param {string} ownerName The name of the owner |
| 1000 | * |
| 1001 | * @param {object} [options] Optional Parameters. |
| 1002 | * |
| 1003 | * @param {boolean} [options.includeUserCounts] if true include impacted user |
| 1004 | * counts in crash group results |
| 1005 | * |
| 1006 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 1007 | * request |
| 1008 | * |
| 1009 | * @param {function} [optionalCallback] - The optional callback. |
| 1010 | * |
| 1011 | * @returns {function|Promise} If a callback was passed as the last parameter |
| 1012 | * then it returns the callback else returns a Promise. |
| 1013 | * |
| 1014 | * {Promise} A promise is returned |
| 1015 | * |
| 1016 | * @resolve {CrashGroup} - The deserialized result object. |
| 1017 | * |
| 1018 | * @reject {Error} - The error object. |
| 1019 | * |
| 1020 | * {function} optionalCallback(err, result, request, response) |
| 1021 | * |
| 1022 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 1023 | * |
| 1024 | * {object} [result] - The deserialized result object if an error did not occur. |
| 1025 | * See {@link CrashGroup} for more information. |
| 1026 | * |
| 1027 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 1028 | * |
| 1029 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 1030 | */ |
| 1031 | update(appName, crashGroupId, group, ownerName, options, optionalCallback) { |
| 1032 | let client = this.client; |
| 1033 | let self = this; |
| 1034 | if (!optionalCallback && typeof options === 'function') { |
| 1035 | optionalCallback = options; |
| 1036 | options = null; |
| 1037 | } |
| 1038 | if (!optionalCallback) { |
| 1039 | return new Promise((resolve, reject) => { |
| 1040 | self._update(appName, crashGroupId, group, ownerName, options, (err, result, request, response) => { |
| 1041 | if (err) { reject(err); } |
| 1042 | else { resolve(result); } |
| 1043 | return; |
| 1044 | }); |
| 1045 | }); |
| 1046 | } else { |
| 1047 | return self._update(appName, crashGroupId, group, ownerName, options, optionalCallback); |
| 1048 | } |
| 1049 | } |
| 1050 | |
| 1051 | /** |
| 1052 | * Gets a stacktrace for a specific crash |
| 1053 | * |
| 1054 | * @param {string} appName The name of the application |
| 1055 | * |
| 1056 | * @param {string} crashGroupId id of a specific group |
| 1057 | * |
| 1058 | * @param {string} ownerName The name of the owner |
| 1059 | * |
| 1060 | * @param {object} [options] Optional Parameters. |
| 1061 | * |
| 1062 | * @param {boolean} [options.groupingOnly] true if the stacktrace should be |
| 1063 | * only the relevant thread / exception. Default is false |
| 1064 | * |
| 1065 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 1066 | * request |
| 1067 | * |
| 1068 | * @returns {Promise} A promise is returned |
| 1069 | * |
| 1070 | * @resolve {HttpOperationResponse<Stacktrace>} - The deserialized result object. |
| 1071 | * |
| 1072 | * @reject {Error} - The error object. |
| 1073 | */ |
| 1074 | getStacktraceWithHttpOperationResponse(appName, crashGroupId, ownerName, options) { |
| 1075 | let client = this.client; |
| 1076 | let self = this; |
| 1077 | return new Promise((resolve, reject) => { |
| 1078 | self._getStacktrace(appName, crashGroupId, ownerName, options, (err, result, request, response) => { |
| 1079 | let httpOperationResponse = new msRest.HttpOperationResponse(request, response); |
| 1080 | httpOperationResponse.body = result; |
| 1081 | if (err) { reject(err); } |
| 1082 | else { resolve(httpOperationResponse); } |
| 1083 | return; |
| 1084 | }); |
| 1085 | }); |
| 1086 | } |
| 1087 | |
| 1088 | /** |
| 1089 | * Gets a stacktrace for a specific crash |
| 1090 | * |
| 1091 | * @param {string} appName The name of the application |
| 1092 | * |
| 1093 | * @param {string} crashGroupId id of a specific group |
| 1094 | * |
| 1095 | * @param {string} ownerName The name of the owner |
| 1096 | * |
| 1097 | * @param {object} [options] Optional Parameters. |
| 1098 | * |
| 1099 | * @param {boolean} [options.groupingOnly] true if the stacktrace should be |
| 1100 | * only the relevant thread / exception. Default is false |
| 1101 | * |
| 1102 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 1103 | * request |
| 1104 | * |
| 1105 | * @param {function} [optionalCallback] - The optional callback. |
| 1106 | * |
| 1107 | * @returns {function|Promise} If a callback was passed as the last parameter |
| 1108 | * then it returns the callback else returns a Promise. |
| 1109 | * |
| 1110 | * {Promise} A promise is returned |
| 1111 | * |
| 1112 | * @resolve {Stacktrace} - The deserialized result object. |
| 1113 | * |
| 1114 | * @reject {Error} - The error object. |
| 1115 | * |
| 1116 | * {function} optionalCallback(err, result, request, response) |
| 1117 | * |
| 1118 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 1119 | * |
| 1120 | * {object} [result] - The deserialized result object if an error did not occur. |
| 1121 | * See {@link Stacktrace} for more information. |
| 1122 | * |
| 1123 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 1124 | * |
| 1125 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 1126 | */ |
| 1127 | getStacktrace(appName, crashGroupId, ownerName, options, optionalCallback) { |
| 1128 | let client = this.client; |
| 1129 | let self = this; |
| 1130 | if (!optionalCallback && typeof options === 'function') { |
| 1131 | optionalCallback = options; |
| 1132 | options = null; |
| 1133 | } |
| 1134 | if (!optionalCallback) { |
| 1135 | return new Promise((resolve, reject) => { |
| 1136 | self._getStacktrace(appName, crashGroupId, ownerName, options, (err, result, request, response) => { |
| 1137 | if (err) { reject(err); } |
| 1138 | else { resolve(result); } |
| 1139 | return; |
| 1140 | }); |
| 1141 | }); |
| 1142 | } else { |
| 1143 | return self._getStacktrace(appName, crashGroupId, ownerName, options, optionalCallback); |
| 1144 | } |
| 1145 | } |
| 1146 | |
| 1147 | } |
| 1148 | |
| 1149 | module.exports = CrashGroups; |
| 1150 | |