From 358724abaa7d78ea0b44de75f084a536789347e8 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 3 Apr 2018 23:11:53 +0000 Subject: [PATCH] Generated from 15622320814a0839c12b7d8e99c35db9a5adb662 Issues Resource added to version 2018-01-01 --- lib/services/apimanagement/README.md | 7 +- .../lib/apiManagementClient.d.ts | 8 + .../apimanagement/lib/apiManagementClient.js | 8 + .../apimanagement/lib/models/apiCollection.js | 2 + .../lib/models/apiReleaseCollection.js | 2 + .../lib/models/apiRevisionCollection.js | 2 + .../apimanagement/lib/models/index.d.ts | 106 +- .../apimanagement/lib/models/index.js | 6 + .../lib/models/issueAttachmentCollection.js | 69 + .../lib/models/issueAttachmentContract.js | 98 ++ .../lib/models/issueCollection.js | 69 + .../lib/models/issueCommentCollection.js | 69 + .../lib/models/issueCommentContract.js | 97 + .../apimanagement/lib/models/issueContract.js | 123 ++ .../lib/models/operationCollection.js | 2 + .../lib/models/schemaCollection.js | 2 + .../lib/operations/apiIssuAttachment.js | 341 ++++ .../lib/operations/apiIssuComment.js | 341 ++++ .../apimanagement/lib/operations/apiIssue.js | 1323 ++++++++++++++ .../lib/operations/apiIssueAttachment.js | 1108 ++++++++++++ .../lib/operations/apiIssueAttachments.js | 613 +++++++ .../lib/operations/apiIssueComment.js | 1098 ++++++++++++ .../lib/operations/apiIssueComments.js | 613 +++++++ .../apimanagement/lib/operations/apiIssues.js | 588 +++++++ .../apimanagement/lib/operations/index.d.ts | 1558 +++++++++++++++++ .../apimanagement/lib/operations/index.js | 8 + lib/services/apimanagement/package.json | 2 +- 27 files changed, 8256 insertions(+), 7 deletions(-) create mode 100644 lib/services/apimanagement/lib/models/issueAttachmentCollection.js create mode 100644 lib/services/apimanagement/lib/models/issueAttachmentContract.js create mode 100644 lib/services/apimanagement/lib/models/issueCollection.js create mode 100644 lib/services/apimanagement/lib/models/issueCommentCollection.js create mode 100644 lib/services/apimanagement/lib/models/issueCommentContract.js create mode 100644 lib/services/apimanagement/lib/models/issueContract.js create mode 100644 lib/services/apimanagement/lib/operations/apiIssuAttachment.js create mode 100644 lib/services/apimanagement/lib/operations/apiIssuComment.js create mode 100644 lib/services/apimanagement/lib/operations/apiIssue.js create mode 100644 lib/services/apimanagement/lib/operations/apiIssueAttachment.js create mode 100644 lib/services/apimanagement/lib/operations/apiIssueAttachments.js create mode 100644 lib/services/apimanagement/lib/operations/apiIssueComment.js create mode 100644 lib/services/apimanagement/lib/operations/apiIssueComments.js create mode 100644 lib/services/apimanagement/lib/operations/apiIssues.js diff --git a/lib/services/apimanagement/README.md b/lib/services/apimanagement/README.md index 33a2a09333..41fea6aa20 100644 --- a/lib/services/apimanagement/README.md +++ b/lib/services/apimanagement/README.md @@ -1,3 +1,8 @@ +--- +uid: azure-arm-apimanagement +summary: *content + +--- # Microsoft Azure SDK for Node.js - ApiManagementClient This project provides a Node.js package for accessing Azure. Right now it supports: - **Node.js version 6.x.x or higher** @@ -29,7 +34,7 @@ msRestAzure.interactiveLogin().then((creds) => { console.log(result); }); }).catch((err) => { - console.log('An error ocurred:'); + console.log('An error occurred:'); console.dir(err, {depth: null, colors: true}); }); diff --git a/lib/services/apimanagement/lib/apiManagementClient.d.ts b/lib/services/apimanagement/lib/apiManagementClient.d.ts index ef9d37e2fa..1bd5a82d4f 100644 --- a/lib/services/apimanagement/lib/apiManagementClient.d.ts +++ b/lib/services/apimanagement/lib/apiManagementClient.d.ts @@ -69,6 +69,14 @@ export default class ApiManagementClient extends AzureServiceClient { apiSchema: operations.ApiSchema; apiDiagnostic: operations.ApiDiagnostic; apiDiagnosticLogger: operations.ApiDiagnosticLogger; + apiIssues: operations.ApiIssues; + apiIssue: operations.ApiIssue; + apiIssueComments: operations.ApiIssueComments; + apiIssuComment: operations.ApiIssuComment; + apiIssueComment: operations.ApiIssueComment; + apiIssueAttachments: operations.ApiIssueAttachments; + apiIssuAttachment: operations.ApiIssuAttachment; + apiIssueAttachment: operations.ApiIssueAttachment; authorizationServer: operations.AuthorizationServer; backend: operations.Backend; certificate: operations.Certificate; diff --git a/lib/services/apimanagement/lib/apiManagementClient.js b/lib/services/apimanagement/lib/apiManagementClient.js index d7fd96798d..b764c25f9c 100644 --- a/lib/services/apimanagement/lib/apiManagementClient.js +++ b/lib/services/apimanagement/lib/apiManagementClient.js @@ -85,6 +85,14 @@ class ApiManagementClient extends ServiceClient { this.apiSchema = new operations.ApiSchema(this); this.apiDiagnostic = new operations.ApiDiagnostic(this); this.apiDiagnosticLogger = new operations.ApiDiagnosticLogger(this); + this.apiIssues = new operations.ApiIssues(this); + this.apiIssue = new operations.ApiIssue(this); + this.apiIssueComments = new operations.ApiIssueComments(this); + this.apiIssuComment = new operations.ApiIssuComment(this); + this.apiIssueComment = new operations.ApiIssueComment(this); + this.apiIssueAttachments = new operations.ApiIssueAttachments(this); + this.apiIssuAttachment = new operations.ApiIssuAttachment(this); + this.apiIssueAttachment = new operations.ApiIssueAttachment(this); this.authorizationServer = new operations.AuthorizationServer(this); this.backend = new operations.Backend(this); this.certificate = new operations.Certificate(this); diff --git a/lib/services/apimanagement/lib/models/apiCollection.js b/lib/services/apimanagement/lib/models/apiCollection.js index f1e0318825..e789516b70 100644 --- a/lib/services/apimanagement/lib/models/apiCollection.js +++ b/lib/services/apimanagement/lib/models/apiCollection.js @@ -38,6 +38,7 @@ class ApiCollection extends Array { modelProperties: { value: { required: false, + readOnly: true, serializedName: '', type: { name: 'Sequence', @@ -53,6 +54,7 @@ class ApiCollection extends Array { }, nextLink: { required: false, + readOnly: true, serializedName: 'nextLink', type: { name: 'String' diff --git a/lib/services/apimanagement/lib/models/apiReleaseCollection.js b/lib/services/apimanagement/lib/models/apiReleaseCollection.js index f77534cadd..9e6cbd257e 100644 --- a/lib/services/apimanagement/lib/models/apiReleaseCollection.js +++ b/lib/services/apimanagement/lib/models/apiReleaseCollection.js @@ -38,6 +38,7 @@ class ApiReleaseCollection extends Array { modelProperties: { value: { required: false, + readOnly: true, serializedName: '', type: { name: 'Sequence', @@ -53,6 +54,7 @@ class ApiReleaseCollection extends Array { }, nextLink: { required: false, + readOnly: true, serializedName: 'nextLink', type: { name: 'String' diff --git a/lib/services/apimanagement/lib/models/apiRevisionCollection.js b/lib/services/apimanagement/lib/models/apiRevisionCollection.js index 69e70b1378..f49de7b0c2 100644 --- a/lib/services/apimanagement/lib/models/apiRevisionCollection.js +++ b/lib/services/apimanagement/lib/models/apiRevisionCollection.js @@ -38,6 +38,7 @@ class ApiRevisionCollection extends Array { modelProperties: { value: { required: false, + readOnly: true, serializedName: '', type: { name: 'Sequence', @@ -53,6 +54,7 @@ class ApiRevisionCollection extends Array { }, nextLink: { required: false, + readOnly: true, serializedName: 'nextLink', type: { name: 'String' diff --git a/lib/services/apimanagement/lib/models/index.d.ts b/lib/services/apimanagement/lib/models/index.d.ts index 4d9a030f90..31a6ed6b68 100644 --- a/lib/services/apimanagement/lib/models/index.d.ts +++ b/lib/services/apimanagement/lib/models/index.d.ts @@ -834,6 +834,66 @@ export interface SchemaContract extends Resource { value?: string; } +/** + * @class + * Initializes a new instance of the IssueContract class. + * @constructor + * Issue Contract details. + * + * @member {string} title The issue title. + * @member {string} description Text describing the issue. + * @member {date} [createdDate] Date and time when the issue was created. + * @member {string} [state] Status of the issue. Possible values include: + * 'proposed', 'open', 'removed', 'resolved', 'closed' + * @member {string} userId A resource identifier for the user created the + * issue. + * @member {string} [apiId] A resource identifier for the API the issue was + * created for. + */ +export interface IssueContract extends Resource { + title: string; + description: string; + createdDate?: Date; + state?: string; + userId: string; + apiId?: string; +} + +/** + * @class + * Initializes a new instance of the IssueCommentContract class. + * @constructor + * Issue Comment Contract details. + * + * @member {string} text Comment text. + * @member {date} [createdDate] Date and time when the comment was created. + * @member {string} userId A resource identifier for the user who left the + * comment. + */ +export interface IssueCommentContract extends Resource { + text: string; + createdDate?: Date; + userId: string; +} + +/** + * @class + * Initializes a new instance of the IssueAttachmentContract class. + * @constructor + * Issue Attachment Contract details. + * + * @member {string} title Filename by which the binary data will be saved. + * @member {string} contentFormat Either 'link' if content is provided via an + * HTTP link or the MIME type of the Base64-encoded binary data provided in the + * 'content' property. + * @member {string} content An HTTP link or Base64-encoded binary data. + */ +export interface IssueAttachmentContract extends Resource { + title: string; + contentFormat: string; + content: string; +} + /** * @class * Initializes a new instance of the LoggerContract class. @@ -3820,7 +3880,7 @@ export interface RegionListResult extends Array { * @member {string} [nextLink] Next page link if any. */ export interface ApiCollection extends Array { - nextLink?: string; + readonly nextLink?: string; } /** @@ -3845,7 +3905,7 @@ export interface TagResourceCollection extends Array { * @member {string} [nextLink] Next page link if any. */ export interface ApiRevisionCollection extends Array { - nextLink?: string; + readonly nextLink?: string; } /** @@ -3857,7 +3917,7 @@ export interface ApiRevisionCollection extends Array { * @member {string} [nextLink] Next page link if any. */ export interface ApiReleaseCollection extends Array { - nextLink?: string; + readonly nextLink?: string; } /** @@ -3869,7 +3929,7 @@ export interface ApiReleaseCollection extends Array { * @member {string} [nextLink] Next page link if any. */ export interface OperationCollection extends Array { - nextLink?: string; + readonly nextLink?: string; } /** @@ -3893,7 +3953,7 @@ export interface ProductCollection extends Array { * @member {string} [nextLink] Next page link if any. */ export interface SchemaCollection extends Array { - nextLink?: string; + readonly nextLink?: string; } /** @@ -3921,6 +3981,42 @@ export interface LoggerCollection extends Array { nextLink?: string; } +/** + * @class + * Initializes a new instance of the IssueCollection class. + * @constructor + * Paged Issue list representation. + * + * @member {string} [nextLink] Next page link if any. + */ +export interface IssueCollection extends Array { + readonly nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the IssueCommentCollection class. + * @constructor + * Paged Issue Comment list representation. + * + * @member {string} [nextLink] Next page link if any. + */ +export interface IssueCommentCollection extends Array { + readonly nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the IssueAttachmentCollection class. + * @constructor + * Paged Issue Attachment list representation. + * + * @member {string} [nextLink] Next page link if any. + */ +export interface IssueAttachmentCollection extends Array { + readonly nextLink?: string; +} + /** * @class * Initializes a new instance of the AuthorizationServerCollection class. diff --git a/lib/services/apimanagement/lib/models/index.js b/lib/services/apimanagement/lib/models/index.js index 44f0b8313c..b9fcf111c0 100644 --- a/lib/services/apimanagement/lib/models/index.js +++ b/lib/services/apimanagement/lib/models/index.js @@ -48,6 +48,9 @@ exports.ResponseContract = require('./responseContract'); exports.OperationEntityBaseContract = require('./operationEntityBaseContract'); exports.OperationUpdateContract = require('./operationUpdateContract'); exports.SchemaContract = require('./schemaContract'); +exports.IssueContract = require('./issueContract'); +exports.IssueCommentContract = require('./issueCommentContract'); +exports.IssueAttachmentContract = require('./issueAttachmentContract'); exports.LoggerContract = require('./loggerContract'); exports.DiagnosticContract = require('./diagnosticContract'); exports.ProductEntityBaseParameters = require('./productEntityBaseParameters'); @@ -168,6 +171,9 @@ exports.ProductCollection = require('./productCollection'); exports.SchemaCollection = require('./schemaCollection'); exports.DiagnosticCollection = require('./diagnosticCollection'); exports.LoggerCollection = require('./loggerCollection'); +exports.IssueCollection = require('./issueCollection'); +exports.IssueCommentCollection = require('./issueCommentCollection'); +exports.IssueAttachmentCollection = require('./issueAttachmentCollection'); exports.AuthorizationServerCollection = require('./authorizationServerCollection'); exports.BackendCollection = require('./backendCollection'); exports.CertificateCollection = require('./certificateCollection'); diff --git a/lib/services/apimanagement/lib/models/issueAttachmentCollection.js b/lib/services/apimanagement/lib/models/issueAttachmentCollection.js new file mode 100644 index 0000000000..c8f40f0ca4 --- /dev/null +++ b/lib/services/apimanagement/lib/models/issueAttachmentCollection.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Paged Issue Attachment list representation. + */ +class IssueAttachmentCollection extends Array { + /** + * Create a IssueAttachmentCollection. + * @member {string} [nextLink] Next page link if any. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of IssueAttachmentCollection + * + * @returns {object} metadata of IssueAttachmentCollection + * + */ + mapper() { + return { + required: false, + serializedName: 'IssueAttachmentCollection', + type: { + name: 'Composite', + className: 'IssueAttachmentCollection', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'IssueAttachmentContractElementType', + type: { + name: 'Composite', + className: 'IssueAttachmentContract' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = IssueAttachmentCollection; diff --git a/lib/services/apimanagement/lib/models/issueAttachmentContract.js b/lib/services/apimanagement/lib/models/issueAttachmentContract.js new file mode 100644 index 0000000000..6f40e9dac1 --- /dev/null +++ b/lib/services/apimanagement/lib/models/issueAttachmentContract.js @@ -0,0 +1,98 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Issue Attachment Contract details. + * + * @extends models['Resource'] + */ +class IssueAttachmentContract extends models['Resource'] { + /** + * Create a IssueAttachmentContract. + * @member {string} title Filename by which the binary data will be saved. + * @member {string} contentFormat Either 'link' if content is provided via an + * HTTP link or the MIME type of the Base64-encoded binary data provided in + * the 'content' property. + * @member {string} content An HTTP link or Base64-encoded binary data. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of IssueAttachmentContract + * + * @returns {object} metadata of IssueAttachmentContract + * + */ + mapper() { + return { + required: false, + serializedName: 'IssueAttachmentContract', + type: { + name: 'Composite', + className: 'IssueAttachmentContract', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + title: { + required: true, + serializedName: 'properties.title', + type: { + name: 'String' + } + }, + contentFormat: { + required: true, + serializedName: 'properties.contentFormat', + type: { + name: 'String' + } + }, + content: { + required: true, + serializedName: 'properties.content', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = IssueAttachmentContract; diff --git a/lib/services/apimanagement/lib/models/issueCollection.js b/lib/services/apimanagement/lib/models/issueCollection.js new file mode 100644 index 0000000000..8d64da129c --- /dev/null +++ b/lib/services/apimanagement/lib/models/issueCollection.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Paged Issue list representation. + */ +class IssueCollection extends Array { + /** + * Create a IssueCollection. + * @member {string} [nextLink] Next page link if any. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of IssueCollection + * + * @returns {object} metadata of IssueCollection + * + */ + mapper() { + return { + required: false, + serializedName: 'IssueCollection', + type: { + name: 'Composite', + className: 'IssueCollection', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'IssueContractElementType', + type: { + name: 'Composite', + className: 'IssueContract' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = IssueCollection; diff --git a/lib/services/apimanagement/lib/models/issueCommentCollection.js b/lib/services/apimanagement/lib/models/issueCommentCollection.js new file mode 100644 index 0000000000..1932382295 --- /dev/null +++ b/lib/services/apimanagement/lib/models/issueCommentCollection.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Paged Issue Comment list representation. + */ +class IssueCommentCollection extends Array { + /** + * Create a IssueCommentCollection. + * @member {string} [nextLink] Next page link if any. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of IssueCommentCollection + * + * @returns {object} metadata of IssueCommentCollection + * + */ + mapper() { + return { + required: false, + serializedName: 'IssueCommentCollection', + type: { + name: 'Composite', + className: 'IssueCommentCollection', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'IssueCommentContractElementType', + type: { + name: 'Composite', + className: 'IssueCommentContract' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = IssueCommentCollection; diff --git a/lib/services/apimanagement/lib/models/issueCommentContract.js b/lib/services/apimanagement/lib/models/issueCommentContract.js new file mode 100644 index 0000000000..e232b81067 --- /dev/null +++ b/lib/services/apimanagement/lib/models/issueCommentContract.js @@ -0,0 +1,97 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Issue Comment Contract details. + * + * @extends models['Resource'] + */ +class IssueCommentContract extends models['Resource'] { + /** + * Create a IssueCommentContract. + * @member {string} text Comment text. + * @member {date} [createdDate] Date and time when the comment was created. + * @member {string} userId A resource identifier for the user who left the + * comment. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of IssueCommentContract + * + * @returns {object} metadata of IssueCommentContract + * + */ + mapper() { + return { + required: false, + serializedName: 'IssueCommentContract', + type: { + name: 'Composite', + className: 'IssueCommentContract', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + text: { + required: true, + serializedName: 'properties.text', + type: { + name: 'String' + } + }, + createdDate: { + required: false, + serializedName: 'properties.createdDate', + type: { + name: 'DateTime' + } + }, + userId: { + required: true, + serializedName: 'properties.userId', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = IssueCommentContract; diff --git a/lib/services/apimanagement/lib/models/issueContract.js b/lib/services/apimanagement/lib/models/issueContract.js new file mode 100644 index 0000000000..a6aed2c2c8 --- /dev/null +++ b/lib/services/apimanagement/lib/models/issueContract.js @@ -0,0 +1,123 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Issue Contract details. + * + * @extends models['Resource'] + */ +class IssueContract extends models['Resource'] { + /** + * Create a IssueContract. + * @member {string} title The issue title. + * @member {string} description Text describing the issue. + * @member {date} [createdDate] Date and time when the issue was created. + * @member {string} [state] Status of the issue. Possible values include: + * 'proposed', 'open', 'removed', 'resolved', 'closed' + * @member {string} userId A resource identifier for the user created the + * issue. + * @member {string} [apiId] A resource identifier for the API the issue was + * created for. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of IssueContract + * + * @returns {object} metadata of IssueContract + * + */ + mapper() { + return { + required: false, + serializedName: 'IssueContract', + type: { + name: 'Composite', + className: 'IssueContract', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + title: { + required: true, + serializedName: 'properties.title', + type: { + name: 'String' + } + }, + description: { + required: true, + serializedName: 'properties.description', + type: { + name: 'String' + } + }, + createdDate: { + required: false, + serializedName: 'properties.createdDate', + type: { + name: 'DateTime' + } + }, + state: { + required: false, + serializedName: 'properties.state', + type: { + name: 'String' + } + }, + userId: { + required: true, + serializedName: 'properties.userId', + type: { + name: 'String' + } + }, + apiId: { + required: false, + serializedName: 'properties.apiId', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = IssueContract; diff --git a/lib/services/apimanagement/lib/models/operationCollection.js b/lib/services/apimanagement/lib/models/operationCollection.js index 3cebcb1817..da3db9b3ed 100644 --- a/lib/services/apimanagement/lib/models/operationCollection.js +++ b/lib/services/apimanagement/lib/models/operationCollection.js @@ -38,6 +38,7 @@ class OperationCollection extends Array { modelProperties: { value: { required: false, + readOnly: true, serializedName: '', type: { name: 'Sequence', @@ -53,6 +54,7 @@ class OperationCollection extends Array { }, nextLink: { required: false, + readOnly: true, serializedName: 'nextLink', type: { name: 'String' diff --git a/lib/services/apimanagement/lib/models/schemaCollection.js b/lib/services/apimanagement/lib/models/schemaCollection.js index b7252838a7..38fc819938 100644 --- a/lib/services/apimanagement/lib/models/schemaCollection.js +++ b/lib/services/apimanagement/lib/models/schemaCollection.js @@ -38,6 +38,7 @@ class SchemaCollection extends Array { modelProperties: { value: { required: false, + readOnly: true, serializedName: '', type: { name: 'Sequence', @@ -53,6 +54,7 @@ class SchemaCollection extends Array { }, nextLink: { required: false, + readOnly: true, serializedName: 'nextLink', type: { name: 'String' diff --git a/lib/services/apimanagement/lib/operations/apiIssuAttachment.js b/lib/services/apimanagement/lib/operations/apiIssuAttachment.js new file mode 100644 index 0000000000..799d4829c0 --- /dev/null +++ b/lib/services/apimanagement/lib/operations/apiIssuAttachment.js @@ -0,0 +1,341 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets the entity state (Etag) version of the issue Attachment for an API + * specified by its identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} attachmentId Attachment identifier within an Issue. Must be + * unique in the current Issue. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _head(resourceGroupName, serviceName, apiId, issueId, attachmentId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (serviceName === null || serviceName === undefined || typeof serviceName.valueOf() !== 'string') { + throw new Error('serviceName cannot be null or undefined and it must be of type string.'); + } + if (serviceName !== null && serviceName !== undefined) { + if (serviceName.length > 50) + { + throw new Error('"serviceName" should satisfy the constraint - "MaxLength": 50'); + } + if (serviceName.length < 1) + { + throw new Error('"serviceName" should satisfy the constraint - "MinLength": 1'); + } + if (serviceName.match(/^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/) === null) + { + throw new Error('"serviceName" should satisfy the constraint - "Pattern": /^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/'); + } + } + if (apiId === null || apiId === undefined || typeof apiId.valueOf() !== 'string') { + throw new Error('apiId cannot be null or undefined and it must be of type string.'); + } + if (apiId !== null && apiId !== undefined) { + if (apiId.length > 80) + { + throw new Error('"apiId" should satisfy the constraint - "MaxLength": 80'); + } + if (apiId.length < 1) + { + throw new Error('"apiId" should satisfy the constraint - "MinLength": 1'); + } + if (apiId.match(/(^[\w]+$)|(^[\w][\w\-]+[\w]$)/) === null) + { + throw new Error('"apiId" should satisfy the constraint - "Pattern": /(^[\w]+$)|(^[\w][\w\-]+[\w]$)/'); + } + } + if (issueId === null || issueId === undefined || typeof issueId.valueOf() !== 'string') { + throw new Error('issueId cannot be null or undefined and it must be of type string.'); + } + if (issueId !== null && issueId !== undefined) { + if (issueId.length > 256) + { + throw new Error('"issueId" should satisfy the constraint - "MaxLength": 256'); + } + if (issueId.length < 1) + { + throw new Error('"issueId" should satisfy the constraint - "MinLength": 1'); + } + if (issueId.match(/^[^*#&+:<>?]+$/) === null) + { + throw new Error('"issueId" should satisfy the constraint - "Pattern": /^[^*#&+:<>?]+$/'); + } + } + if (attachmentId === null || attachmentId === undefined || typeof attachmentId.valueOf() !== 'string') { + throw new Error('attachmentId cannot be null or undefined and it must be of type string.'); + } + if (attachmentId !== null && attachmentId !== undefined) { + if (attachmentId.length > 256) + { + throw new Error('"attachmentId" should satisfy the constraint - "MaxLength": 256'); + } + if (attachmentId.length < 1) + { + throw new Error('"attachmentId" should satisfy the constraint - "MinLength": 1'); + } + if (attachmentId.match(/^[^*#&+:<>?]+$/) === null) + { + throw new Error('"attachmentId" should satisfy the constraint - "Pattern": /^[^*#&+:<>?]+$/'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serviceName}', encodeURIComponent(serviceName)); + requestUrl = requestUrl.replace('{apiId}', encodeURIComponent(apiId)); + requestUrl = requestUrl.replace('{issueId}', encodeURIComponent(issueId)); + requestUrl = requestUrl.replace('{attachmentId}', encodeURIComponent(attachmentId)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'HEAD'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a ApiIssuAttachment. */ +class ApiIssuAttachment { + /** + * Create a ApiIssuAttachment. + * @param {ApiManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._head = _head; + } + + /** + * Gets the entity state (Etag) version of the issue Attachment for an API + * specified by its identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} attachmentId Attachment identifier within an Issue. Must be + * unique in the current Issue. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + headWithHttpOperationResponse(resourceGroupName, serviceName, apiId, issueId, attachmentId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._head(resourceGroupName, serviceName, apiId, issueId, attachmentId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the entity state (Etag) version of the issue Attachment for an API + * specified by its identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} attachmentId Attachment identifier within an Issue. Must be + * unique in the current Issue. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + head(resourceGroupName, serviceName, apiId, issueId, attachmentId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._head(resourceGroupName, serviceName, apiId, issueId, attachmentId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._head(resourceGroupName, serviceName, apiId, issueId, attachmentId, options, optionalCallback); + } + } + +} + +module.exports = ApiIssuAttachment; diff --git a/lib/services/apimanagement/lib/operations/apiIssuComment.js b/lib/services/apimanagement/lib/operations/apiIssuComment.js new file mode 100644 index 0000000000..8d023ca3bd --- /dev/null +++ b/lib/services/apimanagement/lib/operations/apiIssuComment.js @@ -0,0 +1,341 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets the entity state (Etag) version of the issue Comment for an API + * specified by its identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} commentId Comment identifier within an Issue. Must be unique + * in the current Issue. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _head(resourceGroupName, serviceName, apiId, issueId, commentId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (serviceName === null || serviceName === undefined || typeof serviceName.valueOf() !== 'string') { + throw new Error('serviceName cannot be null or undefined and it must be of type string.'); + } + if (serviceName !== null && serviceName !== undefined) { + if (serviceName.length > 50) + { + throw new Error('"serviceName" should satisfy the constraint - "MaxLength": 50'); + } + if (serviceName.length < 1) + { + throw new Error('"serviceName" should satisfy the constraint - "MinLength": 1'); + } + if (serviceName.match(/^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/) === null) + { + throw new Error('"serviceName" should satisfy the constraint - "Pattern": /^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/'); + } + } + if (apiId === null || apiId === undefined || typeof apiId.valueOf() !== 'string') { + throw new Error('apiId cannot be null or undefined and it must be of type string.'); + } + if (apiId !== null && apiId !== undefined) { + if (apiId.length > 80) + { + throw new Error('"apiId" should satisfy the constraint - "MaxLength": 80'); + } + if (apiId.length < 1) + { + throw new Error('"apiId" should satisfy the constraint - "MinLength": 1'); + } + if (apiId.match(/(^[\w]+$)|(^[\w][\w\-]+[\w]$)/) === null) + { + throw new Error('"apiId" should satisfy the constraint - "Pattern": /(^[\w]+$)|(^[\w][\w\-]+[\w]$)/'); + } + } + if (issueId === null || issueId === undefined || typeof issueId.valueOf() !== 'string') { + throw new Error('issueId cannot be null or undefined and it must be of type string.'); + } + if (issueId !== null && issueId !== undefined) { + if (issueId.length > 256) + { + throw new Error('"issueId" should satisfy the constraint - "MaxLength": 256'); + } + if (issueId.length < 1) + { + throw new Error('"issueId" should satisfy the constraint - "MinLength": 1'); + } + if (issueId.match(/^[^*#&+:<>?]+$/) === null) + { + throw new Error('"issueId" should satisfy the constraint - "Pattern": /^[^*#&+:<>?]+$/'); + } + } + if (commentId === null || commentId === undefined || typeof commentId.valueOf() !== 'string') { + throw new Error('commentId cannot be null or undefined and it must be of type string.'); + } + if (commentId !== null && commentId !== undefined) { + if (commentId.length > 256) + { + throw new Error('"commentId" should satisfy the constraint - "MaxLength": 256'); + } + if (commentId.length < 1) + { + throw new Error('"commentId" should satisfy the constraint - "MinLength": 1'); + } + if (commentId.match(/^[^*#&+:<>?]+$/) === null) + { + throw new Error('"commentId" should satisfy the constraint - "Pattern": /^[^*#&+:<>?]+$/'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serviceName}', encodeURIComponent(serviceName)); + requestUrl = requestUrl.replace('{apiId}', encodeURIComponent(apiId)); + requestUrl = requestUrl.replace('{issueId}', encodeURIComponent(issueId)); + requestUrl = requestUrl.replace('{commentId}', encodeURIComponent(commentId)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'HEAD'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a ApiIssuComment. */ +class ApiIssuComment { + /** + * Create a ApiIssuComment. + * @param {ApiManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._head = _head; + } + + /** + * Gets the entity state (Etag) version of the issue Comment for an API + * specified by its identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} commentId Comment identifier within an Issue. Must be unique + * in the current Issue. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + headWithHttpOperationResponse(resourceGroupName, serviceName, apiId, issueId, commentId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._head(resourceGroupName, serviceName, apiId, issueId, commentId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the entity state (Etag) version of the issue Comment for an API + * specified by its identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} commentId Comment identifier within an Issue. Must be unique + * in the current Issue. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + head(resourceGroupName, serviceName, apiId, issueId, commentId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._head(resourceGroupName, serviceName, apiId, issueId, commentId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._head(resourceGroupName, serviceName, apiId, issueId, commentId, options, optionalCallback); + } + } + +} + +module.exports = ApiIssuComment; diff --git a/lib/services/apimanagement/lib/operations/apiIssue.js b/lib/services/apimanagement/lib/operations/apiIssue.js new file mode 100644 index 0000000000..4ac8c1d9b3 --- /dev/null +++ b/lib/services/apimanagement/lib/operations/apiIssue.js @@ -0,0 +1,1323 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets the entity state (Etag) version of the Issue for an API specified by + * its identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _head(resourceGroupName, serviceName, apiId, issueId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (serviceName === null || serviceName === undefined || typeof serviceName.valueOf() !== 'string') { + throw new Error('serviceName cannot be null or undefined and it must be of type string.'); + } + if (serviceName !== null && serviceName !== undefined) { + if (serviceName.length > 50) + { + throw new Error('"serviceName" should satisfy the constraint - "MaxLength": 50'); + } + if (serviceName.length < 1) + { + throw new Error('"serviceName" should satisfy the constraint - "MinLength": 1'); + } + if (serviceName.match(/^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/) === null) + { + throw new Error('"serviceName" should satisfy the constraint - "Pattern": /^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/'); + } + } + if (apiId === null || apiId === undefined || typeof apiId.valueOf() !== 'string') { + throw new Error('apiId cannot be null or undefined and it must be of type string.'); + } + if (apiId !== null && apiId !== undefined) { + if (apiId.length > 80) + { + throw new Error('"apiId" should satisfy the constraint - "MaxLength": 80'); + } + if (apiId.length < 1) + { + throw new Error('"apiId" should satisfy the constraint - "MinLength": 1'); + } + if (apiId.match(/(^[\w]+$)|(^[\w][\w\-]+[\w]$)/) === null) + { + throw new Error('"apiId" should satisfy the constraint - "Pattern": /(^[\w]+$)|(^[\w][\w\-]+[\w]$)/'); + } + } + if (issueId === null || issueId === undefined || typeof issueId.valueOf() !== 'string') { + throw new Error('issueId cannot be null or undefined and it must be of type string.'); + } + if (issueId !== null && issueId !== undefined) { + if (issueId.length > 256) + { + throw new Error('"issueId" should satisfy the constraint - "MaxLength": 256'); + } + if (issueId.length < 1) + { + throw new Error('"issueId" should satisfy the constraint - "MinLength": 1'); + } + if (issueId.match(/^[^*#&+:<>?]+$/) === null) + { + throw new Error('"issueId" should satisfy the constraint - "Pattern": /^[^*#&+:<>?]+$/'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serviceName}', encodeURIComponent(serviceName)); + requestUrl = requestUrl.replace('{apiId}', encodeURIComponent(apiId)); + requestUrl = requestUrl.replace('{issueId}', encodeURIComponent(issueId)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'HEAD'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets the details of the Issue for an API specified by its identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueContract} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, serviceName, apiId, issueId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (serviceName === null || serviceName === undefined || typeof serviceName.valueOf() !== 'string') { + throw new Error('serviceName cannot be null or undefined and it must be of type string.'); + } + if (serviceName !== null && serviceName !== undefined) { + if (serviceName.length > 50) + { + throw new Error('"serviceName" should satisfy the constraint - "MaxLength": 50'); + } + if (serviceName.length < 1) + { + throw new Error('"serviceName" should satisfy the constraint - "MinLength": 1'); + } + if (serviceName.match(/^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/) === null) + { + throw new Error('"serviceName" should satisfy the constraint - "Pattern": /^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/'); + } + } + if (apiId === null || apiId === undefined || typeof apiId.valueOf() !== 'string') { + throw new Error('apiId cannot be null or undefined and it must be of type string.'); + } + if (apiId !== null && apiId !== undefined) { + if (apiId.length > 80) + { + throw new Error('"apiId" should satisfy the constraint - "MaxLength": 80'); + } + if (apiId.length < 1) + { + throw new Error('"apiId" should satisfy the constraint - "MinLength": 1'); + } + if (apiId.match(/(^[\w]+$)|(^[\w][\w\-]+[\w]$)/) === null) + { + throw new Error('"apiId" should satisfy the constraint - "Pattern": /(^[\w]+$)|(^[\w][\w\-]+[\w]$)/'); + } + } + if (issueId === null || issueId === undefined || typeof issueId.valueOf() !== 'string') { + throw new Error('issueId cannot be null or undefined and it must be of type string.'); + } + if (issueId !== null && issueId !== undefined) { + if (issueId.length > 256) + { + throw new Error('"issueId" should satisfy the constraint - "MaxLength": 256'); + } + if (issueId.length < 1) + { + throw new Error('"issueId" should satisfy the constraint - "MinLength": 1'); + } + if (issueId.match(/^[^*#&+:<>?]+$/) === null) + { + throw new Error('"issueId" should satisfy the constraint - "Pattern": /^[^*#&+:<>?]+$/'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serviceName}', encodeURIComponent(serviceName)); + requestUrl = requestUrl.replace('{apiId}', encodeURIComponent(apiId)); + requestUrl = requestUrl.replace('{issueId}', encodeURIComponent(issueId)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['IssueContract']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Creates a new Issue for an API or updates an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} parameters Create parameters. + * + * @param {string} parameters.title The issue title. + * + * @param {string} parameters.description Text describing the issue. + * + * @param {date} [parameters.createdDate] Date and time when the issue was + * created. + * + * @param {string} [parameters.state] Status of the issue. Possible values + * include: 'proposed', 'open', 'removed', 'resolved', 'closed' + * + * @param {string} parameters.userId A resource identifier for the user created + * the issue. + * + * @param {string} [parameters.apiId] A resource identifier for the API the + * issue was created for. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.ifMatch] ETag of the Issue Entity. ETag should + * match the current entity state from the header response of the GET request + * or it should be * for unconditional update. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueContract} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(resourceGroupName, serviceName, apiId, issueId, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let ifMatch = (options && options.ifMatch !== undefined) ? options.ifMatch : undefined; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (serviceName === null || serviceName === undefined || typeof serviceName.valueOf() !== 'string') { + throw new Error('serviceName cannot be null or undefined and it must be of type string.'); + } + if (serviceName !== null && serviceName !== undefined) { + if (serviceName.length > 50) + { + throw new Error('"serviceName" should satisfy the constraint - "MaxLength": 50'); + } + if (serviceName.length < 1) + { + throw new Error('"serviceName" should satisfy the constraint - "MinLength": 1'); + } + if (serviceName.match(/^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/) === null) + { + throw new Error('"serviceName" should satisfy the constraint - "Pattern": /^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/'); + } + } + if (apiId === null || apiId === undefined || typeof apiId.valueOf() !== 'string') { + throw new Error('apiId cannot be null or undefined and it must be of type string.'); + } + if (apiId !== null && apiId !== undefined) { + if (apiId.length > 80) + { + throw new Error('"apiId" should satisfy the constraint - "MaxLength": 80'); + } + if (apiId.length < 1) + { + throw new Error('"apiId" should satisfy the constraint - "MinLength": 1'); + } + if (apiId.match(/(^[\w]+$)|(^[\w][\w\-]+[\w]$)/) === null) + { + throw new Error('"apiId" should satisfy the constraint - "Pattern": /(^[\w]+$)|(^[\w][\w\-]+[\w]$)/'); + } + } + if (issueId === null || issueId === undefined || typeof issueId.valueOf() !== 'string') { + throw new Error('issueId cannot be null or undefined and it must be of type string.'); + } + if (issueId !== null && issueId !== undefined) { + if (issueId.length > 256) + { + throw new Error('"issueId" should satisfy the constraint - "MaxLength": 256'); + } + if (issueId.length < 1) + { + throw new Error('"issueId" should satisfy the constraint - "MinLength": 1'); + } + if (issueId.match(/^[^*#&+:<>?]+$/) === null) + { + throw new Error('"issueId" should satisfy the constraint - "Pattern": /^[^*#&+:<>?]+$/'); + } + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (ifMatch !== null && ifMatch !== undefined && typeof ifMatch.valueOf() !== 'string') { + throw new Error('ifMatch must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serviceName}', encodeURIComponent(serviceName)); + requestUrl = requestUrl.replace('{apiId}', encodeURIComponent(apiId)); + requestUrl = requestUrl.replace('{issueId}', encodeURIComponent(issueId)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (ifMatch !== undefined && ifMatch !== null) { + httpRequest.headers['If-Match'] = ifMatch; + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['IssueContract']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['IssueContract']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['IssueContract']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Deletes the specified Issue from an API. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} ifMatch ETag of the Issue Entity. ETag should match the + * current entity state from the header response of the GET request or it + * should be * for unconditional update. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(resourceGroupName, serviceName, apiId, issueId, ifMatch, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (serviceName === null || serviceName === undefined || typeof serviceName.valueOf() !== 'string') { + throw new Error('serviceName cannot be null or undefined and it must be of type string.'); + } + if (serviceName !== null && serviceName !== undefined) { + if (serviceName.length > 50) + { + throw new Error('"serviceName" should satisfy the constraint - "MaxLength": 50'); + } + if (serviceName.length < 1) + { + throw new Error('"serviceName" should satisfy the constraint - "MinLength": 1'); + } + if (serviceName.match(/^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/) === null) + { + throw new Error('"serviceName" should satisfy the constraint - "Pattern": /^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/'); + } + } + if (apiId === null || apiId === undefined || typeof apiId.valueOf() !== 'string') { + throw new Error('apiId cannot be null or undefined and it must be of type string.'); + } + if (apiId !== null && apiId !== undefined) { + if (apiId.length > 80) + { + throw new Error('"apiId" should satisfy the constraint - "MaxLength": 80'); + } + if (apiId.length < 1) + { + throw new Error('"apiId" should satisfy the constraint - "MinLength": 1'); + } + if (apiId.match(/(^[\w]+$)|(^[\w][\w\-]+[\w]$)/) === null) + { + throw new Error('"apiId" should satisfy the constraint - "Pattern": /(^[\w]+$)|(^[\w][\w\-]+[\w]$)/'); + } + } + if (issueId === null || issueId === undefined || typeof issueId.valueOf() !== 'string') { + throw new Error('issueId cannot be null or undefined and it must be of type string.'); + } + if (issueId !== null && issueId !== undefined) { + if (issueId.length > 256) + { + throw new Error('"issueId" should satisfy the constraint - "MaxLength": 256'); + } + if (issueId.length < 1) + { + throw new Error('"issueId" should satisfy the constraint - "MinLength": 1'); + } + if (issueId.match(/^[^*#&+:<>?]+$/) === null) + { + throw new Error('"issueId" should satisfy the constraint - "Pattern": /^[^*#&+:<>?]+$/'); + } + } + if (ifMatch === null || ifMatch === undefined || typeof ifMatch.valueOf() !== 'string') { + throw new Error('ifMatch cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serviceName}', encodeURIComponent(serviceName)); + requestUrl = requestUrl.replace('{apiId}', encodeURIComponent(apiId)); + requestUrl = requestUrl.replace('{issueId}', encodeURIComponent(issueId)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (ifMatch !== undefined && ifMatch !== null) { + httpRequest.headers['If-Match'] = ifMatch; + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a ApiIssue. */ +class ApiIssue { + /** + * Create a ApiIssue. + * @param {ApiManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._head = _head; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + this._deleteMethod = _deleteMethod; + } + + /** + * Gets the entity state (Etag) version of the Issue for an API specified by + * its identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + headWithHttpOperationResponse(resourceGroupName, serviceName, apiId, issueId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._head(resourceGroupName, serviceName, apiId, issueId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the entity state (Etag) version of the Issue for an API specified by + * its identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + head(resourceGroupName, serviceName, apiId, issueId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._head(resourceGroupName, serviceName, apiId, issueId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._head(resourceGroupName, serviceName, apiId, issueId, options, optionalCallback); + } + } + + /** + * Gets the details of the Issue for an API specified by its identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, serviceName, apiId, issueId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serviceName, apiId, issueId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the details of the Issue for an API specified by its identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {IssueContract} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueContract} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, serviceName, apiId, issueId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serviceName, apiId, issueId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, serviceName, apiId, issueId, options, optionalCallback); + } + } + + /** + * Creates a new Issue for an API or updates an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} parameters Create parameters. + * + * @param {string} parameters.title The issue title. + * + * @param {string} parameters.description Text describing the issue. + * + * @param {date} [parameters.createdDate] Date and time when the issue was + * created. + * + * @param {string} [parameters.state] Status of the issue. Possible values + * include: 'proposed', 'open', 'removed', 'resolved', 'closed' + * + * @param {string} parameters.userId A resource identifier for the user created + * the issue. + * + * @param {string} [parameters.apiId] A resource identifier for the API the + * issue was created for. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.ifMatch] ETag of the Issue Entity. ETag should + * match the current entity state from the header response of the GET request + * or it should be * for unconditional update. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName, serviceName, apiId, issueId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, serviceName, apiId, issueId, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Creates a new Issue for an API or updates an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} parameters Create parameters. + * + * @param {string} parameters.title The issue title. + * + * @param {string} parameters.description Text describing the issue. + * + * @param {date} [parameters.createdDate] Date and time when the issue was + * created. + * + * @param {string} [parameters.state] Status of the issue. Possible values + * include: 'proposed', 'open', 'removed', 'resolved', 'closed' + * + * @param {string} parameters.userId A resource identifier for the user created + * the issue. + * + * @param {string} [parameters.apiId] A resource identifier for the API the + * issue was created for. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.ifMatch] ETag of the Issue Entity. ETag should + * match the current entity state from the header response of the GET request + * or it should be * for unconditional update. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {IssueContract} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueContract} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName, serviceName, apiId, issueId, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, serviceName, apiId, issueId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, serviceName, apiId, issueId, parameters, options, optionalCallback); + } + } + + /** + * Deletes the specified Issue from an API. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} ifMatch ETag of the Issue Entity. ETag should match the + * current entity state from the header response of the GET request or it + * should be * for unconditional update. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, serviceName, apiId, issueId, ifMatch, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, serviceName, apiId, issueId, ifMatch, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Deletes the specified Issue from an API. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} ifMatch ETag of the Issue Entity. ETag should match the + * current entity state from the header response of the GET request or it + * should be * for unconditional update. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName, serviceName, apiId, issueId, ifMatch, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, serviceName, apiId, issueId, ifMatch, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, serviceName, apiId, issueId, ifMatch, options, optionalCallback); + } + } + +} + +module.exports = ApiIssue; diff --git a/lib/services/apimanagement/lib/operations/apiIssueAttachment.js b/lib/services/apimanagement/lib/operations/apiIssueAttachment.js new file mode 100644 index 0000000000..7f5c6560de --- /dev/null +++ b/lib/services/apimanagement/lib/operations/apiIssueAttachment.js @@ -0,0 +1,1108 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets the details of the issue Attachment for an API specified by its + * identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} attachmentId Attachment identifier within an Issue. Must be + * unique in the current Issue. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueAttachmentContract} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, serviceName, apiId, issueId, attachmentId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (serviceName === null || serviceName === undefined || typeof serviceName.valueOf() !== 'string') { + throw new Error('serviceName cannot be null or undefined and it must be of type string.'); + } + if (serviceName !== null && serviceName !== undefined) { + if (serviceName.length > 50) + { + throw new Error('"serviceName" should satisfy the constraint - "MaxLength": 50'); + } + if (serviceName.length < 1) + { + throw new Error('"serviceName" should satisfy the constraint - "MinLength": 1'); + } + if (serviceName.match(/^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/) === null) + { + throw new Error('"serviceName" should satisfy the constraint - "Pattern": /^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/'); + } + } + if (apiId === null || apiId === undefined || typeof apiId.valueOf() !== 'string') { + throw new Error('apiId cannot be null or undefined and it must be of type string.'); + } + if (apiId !== null && apiId !== undefined) { + if (apiId.length > 80) + { + throw new Error('"apiId" should satisfy the constraint - "MaxLength": 80'); + } + if (apiId.length < 1) + { + throw new Error('"apiId" should satisfy the constraint - "MinLength": 1'); + } + if (apiId.match(/(^[\w]+$)|(^[\w][\w\-]+[\w]$)/) === null) + { + throw new Error('"apiId" should satisfy the constraint - "Pattern": /(^[\w]+$)|(^[\w][\w\-]+[\w]$)/'); + } + } + if (issueId === null || issueId === undefined || typeof issueId.valueOf() !== 'string') { + throw new Error('issueId cannot be null or undefined and it must be of type string.'); + } + if (issueId !== null && issueId !== undefined) { + if (issueId.length > 256) + { + throw new Error('"issueId" should satisfy the constraint - "MaxLength": 256'); + } + if (issueId.length < 1) + { + throw new Error('"issueId" should satisfy the constraint - "MinLength": 1'); + } + if (issueId.match(/^[^*#&+:<>?]+$/) === null) + { + throw new Error('"issueId" should satisfy the constraint - "Pattern": /^[^*#&+:<>?]+$/'); + } + } + if (attachmentId === null || attachmentId === undefined || typeof attachmentId.valueOf() !== 'string') { + throw new Error('attachmentId cannot be null or undefined and it must be of type string.'); + } + if (attachmentId !== null && attachmentId !== undefined) { + if (attachmentId.length > 256) + { + throw new Error('"attachmentId" should satisfy the constraint - "MaxLength": 256'); + } + if (attachmentId.length < 1) + { + throw new Error('"attachmentId" should satisfy the constraint - "MinLength": 1'); + } + if (attachmentId.match(/^[^*#&+:<>?]+$/) === null) + { + throw new Error('"attachmentId" should satisfy the constraint - "Pattern": /^[^*#&+:<>?]+$/'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serviceName}', encodeURIComponent(serviceName)); + requestUrl = requestUrl.replace('{apiId}', encodeURIComponent(apiId)); + requestUrl = requestUrl.replace('{issueId}', encodeURIComponent(issueId)); + requestUrl = requestUrl.replace('{attachmentId}', encodeURIComponent(attachmentId)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['IssueAttachmentContract']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Creates a new Attachment for the Issue in an API or updates an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} attachmentId Attachment identifier within an Issue. Must be + * unique in the current Issue. + * + * @param {object} parameters Create parameters. + * + * @param {string} parameters.title Filename by which the binary data will be + * saved. + * + * @param {string} parameters.contentFormat Either 'link' if content is + * provided via an HTTP link or the MIME type of the Base64-encoded binary data + * provided in the 'content' property. + * + * @param {string} parameters.content An HTTP link or Base64-encoded binary + * data. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.ifMatch] ETag of the Issue Entity. ETag should + * match the current entity state from the header response of the GET request + * or it should be * for unconditional update. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueAttachmentContract} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(resourceGroupName, serviceName, apiId, issueId, attachmentId, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let ifMatch = (options && options.ifMatch !== undefined) ? options.ifMatch : undefined; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (serviceName === null || serviceName === undefined || typeof serviceName.valueOf() !== 'string') { + throw new Error('serviceName cannot be null or undefined and it must be of type string.'); + } + if (serviceName !== null && serviceName !== undefined) { + if (serviceName.length > 50) + { + throw new Error('"serviceName" should satisfy the constraint - "MaxLength": 50'); + } + if (serviceName.length < 1) + { + throw new Error('"serviceName" should satisfy the constraint - "MinLength": 1'); + } + if (serviceName.match(/^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/) === null) + { + throw new Error('"serviceName" should satisfy the constraint - "Pattern": /^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/'); + } + } + if (apiId === null || apiId === undefined || typeof apiId.valueOf() !== 'string') { + throw new Error('apiId cannot be null or undefined and it must be of type string.'); + } + if (apiId !== null && apiId !== undefined) { + if (apiId.length > 80) + { + throw new Error('"apiId" should satisfy the constraint - "MaxLength": 80'); + } + if (apiId.length < 1) + { + throw new Error('"apiId" should satisfy the constraint - "MinLength": 1'); + } + if (apiId.match(/(^[\w]+$)|(^[\w][\w\-]+[\w]$)/) === null) + { + throw new Error('"apiId" should satisfy the constraint - "Pattern": /(^[\w]+$)|(^[\w][\w\-]+[\w]$)/'); + } + } + if (issueId === null || issueId === undefined || typeof issueId.valueOf() !== 'string') { + throw new Error('issueId cannot be null or undefined and it must be of type string.'); + } + if (issueId !== null && issueId !== undefined) { + if (issueId.length > 256) + { + throw new Error('"issueId" should satisfy the constraint - "MaxLength": 256'); + } + if (issueId.length < 1) + { + throw new Error('"issueId" should satisfy the constraint - "MinLength": 1'); + } + if (issueId.match(/^[^*#&+:<>?]+$/) === null) + { + throw new Error('"issueId" should satisfy the constraint - "Pattern": /^[^*#&+:<>?]+$/'); + } + } + if (attachmentId === null || attachmentId === undefined || typeof attachmentId.valueOf() !== 'string') { + throw new Error('attachmentId cannot be null or undefined and it must be of type string.'); + } + if (attachmentId !== null && attachmentId !== undefined) { + if (attachmentId.length > 256) + { + throw new Error('"attachmentId" should satisfy the constraint - "MaxLength": 256'); + } + if (attachmentId.length < 1) + { + throw new Error('"attachmentId" should satisfy the constraint - "MinLength": 1'); + } + if (attachmentId.match(/^[^*#&+:<>?]+$/) === null) + { + throw new Error('"attachmentId" should satisfy the constraint - "Pattern": /^[^*#&+:<>?]+$/'); + } + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (ifMatch !== null && ifMatch !== undefined && typeof ifMatch.valueOf() !== 'string') { + throw new Error('ifMatch must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serviceName}', encodeURIComponent(serviceName)); + requestUrl = requestUrl.replace('{apiId}', encodeURIComponent(apiId)); + requestUrl = requestUrl.replace('{issueId}', encodeURIComponent(issueId)); + requestUrl = requestUrl.replace('{attachmentId}', encodeURIComponent(attachmentId)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (ifMatch !== undefined && ifMatch !== null) { + httpRequest.headers['If-Match'] = ifMatch; + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['IssueAttachmentContract']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['IssueAttachmentContract']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['IssueAttachmentContract']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Deletes the specified comment from an Issue. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} attachmentId Attachment identifier within an Issue. Must be + * unique in the current Issue. + * + * @param {string} ifMatch ETag of the Issue Entity. ETag should match the + * current entity state from the header response of the GET request or it + * should be * for unconditional update. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(resourceGroupName, serviceName, apiId, issueId, attachmentId, ifMatch, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (serviceName === null || serviceName === undefined || typeof serviceName.valueOf() !== 'string') { + throw new Error('serviceName cannot be null or undefined and it must be of type string.'); + } + if (serviceName !== null && serviceName !== undefined) { + if (serviceName.length > 50) + { + throw new Error('"serviceName" should satisfy the constraint - "MaxLength": 50'); + } + if (serviceName.length < 1) + { + throw new Error('"serviceName" should satisfy the constraint - "MinLength": 1'); + } + if (serviceName.match(/^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/) === null) + { + throw new Error('"serviceName" should satisfy the constraint - "Pattern": /^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/'); + } + } + if (apiId === null || apiId === undefined || typeof apiId.valueOf() !== 'string') { + throw new Error('apiId cannot be null or undefined and it must be of type string.'); + } + if (apiId !== null && apiId !== undefined) { + if (apiId.length > 80) + { + throw new Error('"apiId" should satisfy the constraint - "MaxLength": 80'); + } + if (apiId.length < 1) + { + throw new Error('"apiId" should satisfy the constraint - "MinLength": 1'); + } + if (apiId.match(/(^[\w]+$)|(^[\w][\w\-]+[\w]$)/) === null) + { + throw new Error('"apiId" should satisfy the constraint - "Pattern": /(^[\w]+$)|(^[\w][\w\-]+[\w]$)/'); + } + } + if (issueId === null || issueId === undefined || typeof issueId.valueOf() !== 'string') { + throw new Error('issueId cannot be null or undefined and it must be of type string.'); + } + if (issueId !== null && issueId !== undefined) { + if (issueId.length > 256) + { + throw new Error('"issueId" should satisfy the constraint - "MaxLength": 256'); + } + if (issueId.length < 1) + { + throw new Error('"issueId" should satisfy the constraint - "MinLength": 1'); + } + if (issueId.match(/^[^*#&+:<>?]+$/) === null) + { + throw new Error('"issueId" should satisfy the constraint - "Pattern": /^[^*#&+:<>?]+$/'); + } + } + if (attachmentId === null || attachmentId === undefined || typeof attachmentId.valueOf() !== 'string') { + throw new Error('attachmentId cannot be null or undefined and it must be of type string.'); + } + if (attachmentId !== null && attachmentId !== undefined) { + if (attachmentId.length > 256) + { + throw new Error('"attachmentId" should satisfy the constraint - "MaxLength": 256'); + } + if (attachmentId.length < 1) + { + throw new Error('"attachmentId" should satisfy the constraint - "MinLength": 1'); + } + if (attachmentId.match(/^[^*#&+:<>?]+$/) === null) + { + throw new Error('"attachmentId" should satisfy the constraint - "Pattern": /^[^*#&+:<>?]+$/'); + } + } + if (ifMatch === null || ifMatch === undefined || typeof ifMatch.valueOf() !== 'string') { + throw new Error('ifMatch cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serviceName}', encodeURIComponent(serviceName)); + requestUrl = requestUrl.replace('{apiId}', encodeURIComponent(apiId)); + requestUrl = requestUrl.replace('{issueId}', encodeURIComponent(issueId)); + requestUrl = requestUrl.replace('{attachmentId}', encodeURIComponent(attachmentId)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (ifMatch !== undefined && ifMatch !== null) { + httpRequest.headers['If-Match'] = ifMatch; + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a ApiIssueAttachment. */ +class ApiIssueAttachment { + /** + * Create a ApiIssueAttachment. + * @param {ApiManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + this._deleteMethod = _deleteMethod; + } + + /** + * Gets the details of the issue Attachment for an API specified by its + * identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} attachmentId Attachment identifier within an Issue. Must be + * unique in the current Issue. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, serviceName, apiId, issueId, attachmentId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serviceName, apiId, issueId, attachmentId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the details of the issue Attachment for an API specified by its + * identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} attachmentId Attachment identifier within an Issue. Must be + * unique in the current Issue. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {IssueAttachmentContract} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueAttachmentContract} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, serviceName, apiId, issueId, attachmentId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serviceName, apiId, issueId, attachmentId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, serviceName, apiId, issueId, attachmentId, options, optionalCallback); + } + } + + /** + * Creates a new Attachment for the Issue in an API or updates an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} attachmentId Attachment identifier within an Issue. Must be + * unique in the current Issue. + * + * @param {object} parameters Create parameters. + * + * @param {string} parameters.title Filename by which the binary data will be + * saved. + * + * @param {string} parameters.contentFormat Either 'link' if content is + * provided via an HTTP link or the MIME type of the Base64-encoded binary data + * provided in the 'content' property. + * + * @param {string} parameters.content An HTTP link or Base64-encoded binary + * data. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.ifMatch] ETag of the Issue Entity. ETag should + * match the current entity state from the header response of the GET request + * or it should be * for unconditional update. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName, serviceName, apiId, issueId, attachmentId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, serviceName, apiId, issueId, attachmentId, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Creates a new Attachment for the Issue in an API or updates an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} attachmentId Attachment identifier within an Issue. Must be + * unique in the current Issue. + * + * @param {object} parameters Create parameters. + * + * @param {string} parameters.title Filename by which the binary data will be + * saved. + * + * @param {string} parameters.contentFormat Either 'link' if content is + * provided via an HTTP link or the MIME type of the Base64-encoded binary data + * provided in the 'content' property. + * + * @param {string} parameters.content An HTTP link or Base64-encoded binary + * data. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.ifMatch] ETag of the Issue Entity. ETag should + * match the current entity state from the header response of the GET request + * or it should be * for unconditional update. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {IssueAttachmentContract} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueAttachmentContract} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName, serviceName, apiId, issueId, attachmentId, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, serviceName, apiId, issueId, attachmentId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, serviceName, apiId, issueId, attachmentId, parameters, options, optionalCallback); + } + } + + /** + * Deletes the specified comment from an Issue. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} attachmentId Attachment identifier within an Issue. Must be + * unique in the current Issue. + * + * @param {string} ifMatch ETag of the Issue Entity. ETag should match the + * current entity state from the header response of the GET request or it + * should be * for unconditional update. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, serviceName, apiId, issueId, attachmentId, ifMatch, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, serviceName, apiId, issueId, attachmentId, ifMatch, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Deletes the specified comment from an Issue. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} attachmentId Attachment identifier within an Issue. Must be + * unique in the current Issue. + * + * @param {string} ifMatch ETag of the Issue Entity. ETag should match the + * current entity state from the header response of the GET request or it + * should be * for unconditional update. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName, serviceName, apiId, issueId, attachmentId, ifMatch, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, serviceName, apiId, issueId, attachmentId, ifMatch, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, serviceName, apiId, issueId, attachmentId, ifMatch, options, optionalCallback); + } + } + +} + +module.exports = ApiIssueAttachment; diff --git a/lib/services/apimanagement/lib/operations/apiIssueAttachments.js b/lib/services/apimanagement/lib/operations/apiIssueAttachments.js new file mode 100644 index 0000000000..6044fa5364 --- /dev/null +++ b/lib/services/apimanagement/lib/operations/apiIssueAttachments.js @@ -0,0 +1,613 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists all comments for the Issue assosiated with the specified API. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] | Field | Supported operators | + * Supported functions | + * |-------------|------------------------|-----------------------------------| + * | id | ge, le, eq, ne, gt, lt | substringof, startswith, endswith | + * | userId | ge, le, eq, ne, gt, lt | substringof, startswith, + * endswith | + * + * @param {number} [options.top] Number of records to return. + * + * @param {number} [options.skip] Number of records to skip. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueAttachmentCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByService(resourceGroupName, serviceName, apiId, issueId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let skip = (options && options.skip !== undefined) ? options.skip : undefined; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (serviceName === null || serviceName === undefined || typeof serviceName.valueOf() !== 'string') { + throw new Error('serviceName cannot be null or undefined and it must be of type string.'); + } + if (serviceName !== null && serviceName !== undefined) { + if (serviceName.length > 50) + { + throw new Error('"serviceName" should satisfy the constraint - "MaxLength": 50'); + } + if (serviceName.length < 1) + { + throw new Error('"serviceName" should satisfy the constraint - "MinLength": 1'); + } + if (serviceName.match(/^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/) === null) + { + throw new Error('"serviceName" should satisfy the constraint - "Pattern": /^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/'); + } + } + if (apiId === null || apiId === undefined || typeof apiId.valueOf() !== 'string') { + throw new Error('apiId cannot be null or undefined and it must be of type string.'); + } + if (apiId !== null && apiId !== undefined) { + if (apiId.length > 80) + { + throw new Error('"apiId" should satisfy the constraint - "MaxLength": 80'); + } + if (apiId.length < 1) + { + throw new Error('"apiId" should satisfy the constraint - "MinLength": 1'); + } + if (apiId.match(/(^[\w]+$)|(^[\w][\w\-]+[\w]$)/) === null) + { + throw new Error('"apiId" should satisfy the constraint - "Pattern": /(^[\w]+$)|(^[\w][\w\-]+[\w]$)/'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (issueId === null || issueId === undefined || typeof issueId.valueOf() !== 'string') { + throw new Error('issueId cannot be null or undefined and it must be of type string.'); + } + if (issueId !== null && issueId !== undefined) { + if (issueId.length > 256) + { + throw new Error('"issueId" should satisfy the constraint - "MaxLength": 256'); + } + if (issueId.length < 1) + { + throw new Error('"issueId" should satisfy the constraint - "MinLength": 1'); + } + if (issueId.match(/^[^*#&+:<>?]+$/) === null) + { + throw new Error('"issueId" should satisfy the constraint - "Pattern": /^[^*#&+:<>?]+$/'); + } + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (skip !== null && skip !== undefined && typeof skip !== 'number') { + throw new Error('skip must be of type number.'); + } + if (skip !== null && skip !== undefined) { + if (skip < 0) + { + throw new Error('"skip" should satisfy the constraint - "InclusiveMinimum": 0'); + } + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serviceName}', encodeURIComponent(serviceName)); + requestUrl = requestUrl.replace('{apiId}', encodeURIComponent(apiId)); + requestUrl = requestUrl.replace('{issueId}', encodeURIComponent(issueId)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + if (skip !== null && skip !== undefined) { + queryParameters.push('$skip=' + encodeURIComponent(skip.toString())); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['IssueAttachmentCollection']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists all comments for the Issue assosiated with the specified API. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueAttachmentCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByServiceNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['IssueAttachmentCollection']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a ApiIssueAttachments. */ +class ApiIssueAttachments { + /** + * Create a ApiIssueAttachments. + * @param {ApiManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._listByService = _listByService; + this._listByServiceNext = _listByServiceNext; + } + + /** + * Lists all comments for the Issue assosiated with the specified API. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] | Field | Supported operators | + * Supported functions | + * |-------------|------------------------|-----------------------------------| + * | id | ge, le, eq, ne, gt, lt | substringof, startswith, endswith | + * | userId | ge, le, eq, ne, gt, lt | substringof, startswith, + * endswith | + * + * @param {number} [options.top] Number of records to return. + * + * @param {number} [options.skip] Number of records to skip. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByServiceWithHttpOperationResponse(resourceGroupName, serviceName, apiId, issueId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByService(resourceGroupName, serviceName, apiId, issueId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all comments for the Issue assosiated with the specified API. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] | Field | Supported operators | + * Supported functions | + * |-------------|------------------------|-----------------------------------| + * | id | ge, le, eq, ne, gt, lt | substringof, startswith, endswith | + * | userId | ge, le, eq, ne, gt, lt | substringof, startswith, + * endswith | + * + * @param {number} [options.top] Number of records to return. + * + * @param {number} [options.skip] Number of records to skip. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {IssueAttachmentCollection} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueAttachmentCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByService(resourceGroupName, serviceName, apiId, issueId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByService(resourceGroupName, serviceName, apiId, issueId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByService(resourceGroupName, serviceName, apiId, issueId, options, optionalCallback); + } + } + + /** + * Lists all comments for the Issue assosiated with the specified API. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByServiceNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByServiceNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all comments for the Issue assosiated with the specified API. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {IssueAttachmentCollection} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueAttachmentCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByServiceNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByServiceNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByServiceNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = ApiIssueAttachments; diff --git a/lib/services/apimanagement/lib/operations/apiIssueComment.js b/lib/services/apimanagement/lib/operations/apiIssueComment.js new file mode 100644 index 0000000000..f6de9c5b41 --- /dev/null +++ b/lib/services/apimanagement/lib/operations/apiIssueComment.js @@ -0,0 +1,1098 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets the details of the issue Comment for an API specified by its + * identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} commentId Comment identifier within an Issue. Must be unique + * in the current Issue. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueCommentContract} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, serviceName, apiId, issueId, commentId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (serviceName === null || serviceName === undefined || typeof serviceName.valueOf() !== 'string') { + throw new Error('serviceName cannot be null or undefined and it must be of type string.'); + } + if (serviceName !== null && serviceName !== undefined) { + if (serviceName.length > 50) + { + throw new Error('"serviceName" should satisfy the constraint - "MaxLength": 50'); + } + if (serviceName.length < 1) + { + throw new Error('"serviceName" should satisfy the constraint - "MinLength": 1'); + } + if (serviceName.match(/^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/) === null) + { + throw new Error('"serviceName" should satisfy the constraint - "Pattern": /^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/'); + } + } + if (apiId === null || apiId === undefined || typeof apiId.valueOf() !== 'string') { + throw new Error('apiId cannot be null or undefined and it must be of type string.'); + } + if (apiId !== null && apiId !== undefined) { + if (apiId.length > 80) + { + throw new Error('"apiId" should satisfy the constraint - "MaxLength": 80'); + } + if (apiId.length < 1) + { + throw new Error('"apiId" should satisfy the constraint - "MinLength": 1'); + } + if (apiId.match(/(^[\w]+$)|(^[\w][\w\-]+[\w]$)/) === null) + { + throw new Error('"apiId" should satisfy the constraint - "Pattern": /(^[\w]+$)|(^[\w][\w\-]+[\w]$)/'); + } + } + if (issueId === null || issueId === undefined || typeof issueId.valueOf() !== 'string') { + throw new Error('issueId cannot be null or undefined and it must be of type string.'); + } + if (issueId !== null && issueId !== undefined) { + if (issueId.length > 256) + { + throw new Error('"issueId" should satisfy the constraint - "MaxLength": 256'); + } + if (issueId.length < 1) + { + throw new Error('"issueId" should satisfy the constraint - "MinLength": 1'); + } + if (issueId.match(/^[^*#&+:<>?]+$/) === null) + { + throw new Error('"issueId" should satisfy the constraint - "Pattern": /^[^*#&+:<>?]+$/'); + } + } + if (commentId === null || commentId === undefined || typeof commentId.valueOf() !== 'string') { + throw new Error('commentId cannot be null or undefined and it must be of type string.'); + } + if (commentId !== null && commentId !== undefined) { + if (commentId.length > 256) + { + throw new Error('"commentId" should satisfy the constraint - "MaxLength": 256'); + } + if (commentId.length < 1) + { + throw new Error('"commentId" should satisfy the constraint - "MinLength": 1'); + } + if (commentId.match(/^[^*#&+:<>?]+$/) === null) + { + throw new Error('"commentId" should satisfy the constraint - "Pattern": /^[^*#&+:<>?]+$/'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serviceName}', encodeURIComponent(serviceName)); + requestUrl = requestUrl.replace('{apiId}', encodeURIComponent(apiId)); + requestUrl = requestUrl.replace('{issueId}', encodeURIComponent(issueId)); + requestUrl = requestUrl.replace('{commentId}', encodeURIComponent(commentId)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['IssueCommentContract']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Creates a new Comment for the Issue in an API or updates an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} commentId Comment identifier within an Issue. Must be unique + * in the current Issue. + * + * @param {object} parameters Create parameters. + * + * @param {string} parameters.text Comment text. + * + * @param {date} [parameters.createdDate] Date and time when the comment was + * created. + * + * @param {string} parameters.userId A resource identifier for the user who + * left the comment. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.ifMatch] ETag of the Issue Entity. ETag should + * match the current entity state from the header response of the GET request + * or it should be * for unconditional update. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueCommentContract} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(resourceGroupName, serviceName, apiId, issueId, commentId, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let ifMatch = (options && options.ifMatch !== undefined) ? options.ifMatch : undefined; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (serviceName === null || serviceName === undefined || typeof serviceName.valueOf() !== 'string') { + throw new Error('serviceName cannot be null or undefined and it must be of type string.'); + } + if (serviceName !== null && serviceName !== undefined) { + if (serviceName.length > 50) + { + throw new Error('"serviceName" should satisfy the constraint - "MaxLength": 50'); + } + if (serviceName.length < 1) + { + throw new Error('"serviceName" should satisfy the constraint - "MinLength": 1'); + } + if (serviceName.match(/^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/) === null) + { + throw new Error('"serviceName" should satisfy the constraint - "Pattern": /^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/'); + } + } + if (apiId === null || apiId === undefined || typeof apiId.valueOf() !== 'string') { + throw new Error('apiId cannot be null or undefined and it must be of type string.'); + } + if (apiId !== null && apiId !== undefined) { + if (apiId.length > 80) + { + throw new Error('"apiId" should satisfy the constraint - "MaxLength": 80'); + } + if (apiId.length < 1) + { + throw new Error('"apiId" should satisfy the constraint - "MinLength": 1'); + } + if (apiId.match(/(^[\w]+$)|(^[\w][\w\-]+[\w]$)/) === null) + { + throw new Error('"apiId" should satisfy the constraint - "Pattern": /(^[\w]+$)|(^[\w][\w\-]+[\w]$)/'); + } + } + if (issueId === null || issueId === undefined || typeof issueId.valueOf() !== 'string') { + throw new Error('issueId cannot be null or undefined and it must be of type string.'); + } + if (issueId !== null && issueId !== undefined) { + if (issueId.length > 256) + { + throw new Error('"issueId" should satisfy the constraint - "MaxLength": 256'); + } + if (issueId.length < 1) + { + throw new Error('"issueId" should satisfy the constraint - "MinLength": 1'); + } + if (issueId.match(/^[^*#&+:<>?]+$/) === null) + { + throw new Error('"issueId" should satisfy the constraint - "Pattern": /^[^*#&+:<>?]+$/'); + } + } + if (commentId === null || commentId === undefined || typeof commentId.valueOf() !== 'string') { + throw new Error('commentId cannot be null or undefined and it must be of type string.'); + } + if (commentId !== null && commentId !== undefined) { + if (commentId.length > 256) + { + throw new Error('"commentId" should satisfy the constraint - "MaxLength": 256'); + } + if (commentId.length < 1) + { + throw new Error('"commentId" should satisfy the constraint - "MinLength": 1'); + } + if (commentId.match(/^[^*#&+:<>?]+$/) === null) + { + throw new Error('"commentId" should satisfy the constraint - "Pattern": /^[^*#&+:<>?]+$/'); + } + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (ifMatch !== null && ifMatch !== undefined && typeof ifMatch.valueOf() !== 'string') { + throw new Error('ifMatch must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serviceName}', encodeURIComponent(serviceName)); + requestUrl = requestUrl.replace('{apiId}', encodeURIComponent(apiId)); + requestUrl = requestUrl.replace('{issueId}', encodeURIComponent(issueId)); + requestUrl = requestUrl.replace('{commentId}', encodeURIComponent(commentId)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (ifMatch !== undefined && ifMatch !== null) { + httpRequest.headers['If-Match'] = ifMatch; + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['IssueCommentContract']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['IssueCommentContract']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['IssueCommentContract']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Deletes the specified comment from an Issue. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} commentId Comment identifier within an Issue. Must be unique + * in the current Issue. + * + * @param {string} ifMatch ETag of the Issue Entity. ETag should match the + * current entity state from the header response of the GET request or it + * should be * for unconditional update. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(resourceGroupName, serviceName, apiId, issueId, commentId, ifMatch, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (serviceName === null || serviceName === undefined || typeof serviceName.valueOf() !== 'string') { + throw new Error('serviceName cannot be null or undefined and it must be of type string.'); + } + if (serviceName !== null && serviceName !== undefined) { + if (serviceName.length > 50) + { + throw new Error('"serviceName" should satisfy the constraint - "MaxLength": 50'); + } + if (serviceName.length < 1) + { + throw new Error('"serviceName" should satisfy the constraint - "MinLength": 1'); + } + if (serviceName.match(/^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/) === null) + { + throw new Error('"serviceName" should satisfy the constraint - "Pattern": /^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/'); + } + } + if (apiId === null || apiId === undefined || typeof apiId.valueOf() !== 'string') { + throw new Error('apiId cannot be null or undefined and it must be of type string.'); + } + if (apiId !== null && apiId !== undefined) { + if (apiId.length > 80) + { + throw new Error('"apiId" should satisfy the constraint - "MaxLength": 80'); + } + if (apiId.length < 1) + { + throw new Error('"apiId" should satisfy the constraint - "MinLength": 1'); + } + if (apiId.match(/(^[\w]+$)|(^[\w][\w\-]+[\w]$)/) === null) + { + throw new Error('"apiId" should satisfy the constraint - "Pattern": /(^[\w]+$)|(^[\w][\w\-]+[\w]$)/'); + } + } + if (issueId === null || issueId === undefined || typeof issueId.valueOf() !== 'string') { + throw new Error('issueId cannot be null or undefined and it must be of type string.'); + } + if (issueId !== null && issueId !== undefined) { + if (issueId.length > 256) + { + throw new Error('"issueId" should satisfy the constraint - "MaxLength": 256'); + } + if (issueId.length < 1) + { + throw new Error('"issueId" should satisfy the constraint - "MinLength": 1'); + } + if (issueId.match(/^[^*#&+:<>?]+$/) === null) + { + throw new Error('"issueId" should satisfy the constraint - "Pattern": /^[^*#&+:<>?]+$/'); + } + } + if (commentId === null || commentId === undefined || typeof commentId.valueOf() !== 'string') { + throw new Error('commentId cannot be null or undefined and it must be of type string.'); + } + if (commentId !== null && commentId !== undefined) { + if (commentId.length > 256) + { + throw new Error('"commentId" should satisfy the constraint - "MaxLength": 256'); + } + if (commentId.length < 1) + { + throw new Error('"commentId" should satisfy the constraint - "MinLength": 1'); + } + if (commentId.match(/^[^*#&+:<>?]+$/) === null) + { + throw new Error('"commentId" should satisfy the constraint - "Pattern": /^[^*#&+:<>?]+$/'); + } + } + if (ifMatch === null || ifMatch === undefined || typeof ifMatch.valueOf() !== 'string') { + throw new Error('ifMatch cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serviceName}', encodeURIComponent(serviceName)); + requestUrl = requestUrl.replace('{apiId}', encodeURIComponent(apiId)); + requestUrl = requestUrl.replace('{issueId}', encodeURIComponent(issueId)); + requestUrl = requestUrl.replace('{commentId}', encodeURIComponent(commentId)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (ifMatch !== undefined && ifMatch !== null) { + httpRequest.headers['If-Match'] = ifMatch; + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a ApiIssueComment. */ +class ApiIssueComment { + /** + * Create a ApiIssueComment. + * @param {ApiManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + this._deleteMethod = _deleteMethod; + } + + /** + * Gets the details of the issue Comment for an API specified by its + * identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} commentId Comment identifier within an Issue. Must be unique + * in the current Issue. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, serviceName, apiId, issueId, commentId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serviceName, apiId, issueId, commentId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the details of the issue Comment for an API specified by its + * identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} commentId Comment identifier within an Issue. Must be unique + * in the current Issue. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {IssueCommentContract} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueCommentContract} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, serviceName, apiId, issueId, commentId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serviceName, apiId, issueId, commentId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, serviceName, apiId, issueId, commentId, options, optionalCallback); + } + } + + /** + * Creates a new Comment for the Issue in an API or updates an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} commentId Comment identifier within an Issue. Must be unique + * in the current Issue. + * + * @param {object} parameters Create parameters. + * + * @param {string} parameters.text Comment text. + * + * @param {date} [parameters.createdDate] Date and time when the comment was + * created. + * + * @param {string} parameters.userId A resource identifier for the user who + * left the comment. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.ifMatch] ETag of the Issue Entity. ETag should + * match the current entity state from the header response of the GET request + * or it should be * for unconditional update. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName, serviceName, apiId, issueId, commentId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, serviceName, apiId, issueId, commentId, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Creates a new Comment for the Issue in an API or updates an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} commentId Comment identifier within an Issue. Must be unique + * in the current Issue. + * + * @param {object} parameters Create parameters. + * + * @param {string} parameters.text Comment text. + * + * @param {date} [parameters.createdDate] Date and time when the comment was + * created. + * + * @param {string} parameters.userId A resource identifier for the user who + * left the comment. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.ifMatch] ETag of the Issue Entity. ETag should + * match the current entity state from the header response of the GET request + * or it should be * for unconditional update. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {IssueCommentContract} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueCommentContract} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName, serviceName, apiId, issueId, commentId, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, serviceName, apiId, issueId, commentId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, serviceName, apiId, issueId, commentId, parameters, options, optionalCallback); + } + } + + /** + * Deletes the specified comment from an Issue. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} commentId Comment identifier within an Issue. Must be unique + * in the current Issue. + * + * @param {string} ifMatch ETag of the Issue Entity. ETag should match the + * current entity state from the header response of the GET request or it + * should be * for unconditional update. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, serviceName, apiId, issueId, commentId, ifMatch, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, serviceName, apiId, issueId, commentId, ifMatch, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Deletes the specified comment from an Issue. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} commentId Comment identifier within an Issue. Must be unique + * in the current Issue. + * + * @param {string} ifMatch ETag of the Issue Entity. ETag should match the + * current entity state from the header response of the GET request or it + * should be * for unconditional update. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName, serviceName, apiId, issueId, commentId, ifMatch, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, serviceName, apiId, issueId, commentId, ifMatch, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, serviceName, apiId, issueId, commentId, ifMatch, options, optionalCallback); + } + } + +} + +module.exports = ApiIssueComment; diff --git a/lib/services/apimanagement/lib/operations/apiIssueComments.js b/lib/services/apimanagement/lib/operations/apiIssueComments.js new file mode 100644 index 0000000000..ff58ba92c8 --- /dev/null +++ b/lib/services/apimanagement/lib/operations/apiIssueComments.js @@ -0,0 +1,613 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists all comments for the Issue assosiated with the specified API. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] | Field | Supported operators | + * Supported functions | + * |-------------|------------------------|-----------------------------------| + * | id | ge, le, eq, ne, gt, lt | substringof, startswith, endswith | + * | userId | ge, le, eq, ne, gt, lt | substringof, startswith, + * endswith | + * + * @param {number} [options.top] Number of records to return. + * + * @param {number} [options.skip] Number of records to skip. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueCommentCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByService(resourceGroupName, serviceName, apiId, issueId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let skip = (options && options.skip !== undefined) ? options.skip : undefined; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (serviceName === null || serviceName === undefined || typeof serviceName.valueOf() !== 'string') { + throw new Error('serviceName cannot be null or undefined and it must be of type string.'); + } + if (serviceName !== null && serviceName !== undefined) { + if (serviceName.length > 50) + { + throw new Error('"serviceName" should satisfy the constraint - "MaxLength": 50'); + } + if (serviceName.length < 1) + { + throw new Error('"serviceName" should satisfy the constraint - "MinLength": 1'); + } + if (serviceName.match(/^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/) === null) + { + throw new Error('"serviceName" should satisfy the constraint - "Pattern": /^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/'); + } + } + if (apiId === null || apiId === undefined || typeof apiId.valueOf() !== 'string') { + throw new Error('apiId cannot be null or undefined and it must be of type string.'); + } + if (apiId !== null && apiId !== undefined) { + if (apiId.length > 80) + { + throw new Error('"apiId" should satisfy the constraint - "MaxLength": 80'); + } + if (apiId.length < 1) + { + throw new Error('"apiId" should satisfy the constraint - "MinLength": 1'); + } + if (apiId.match(/(^[\w]+$)|(^[\w][\w\-]+[\w]$)/) === null) + { + throw new Error('"apiId" should satisfy the constraint - "Pattern": /(^[\w]+$)|(^[\w][\w\-]+[\w]$)/'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (issueId === null || issueId === undefined || typeof issueId.valueOf() !== 'string') { + throw new Error('issueId cannot be null or undefined and it must be of type string.'); + } + if (issueId !== null && issueId !== undefined) { + if (issueId.length > 256) + { + throw new Error('"issueId" should satisfy the constraint - "MaxLength": 256'); + } + if (issueId.length < 1) + { + throw new Error('"issueId" should satisfy the constraint - "MinLength": 1'); + } + if (issueId.match(/^[^*#&+:<>?]+$/) === null) + { + throw new Error('"issueId" should satisfy the constraint - "Pattern": /^[^*#&+:<>?]+$/'); + } + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (skip !== null && skip !== undefined && typeof skip !== 'number') { + throw new Error('skip must be of type number.'); + } + if (skip !== null && skip !== undefined) { + if (skip < 0) + { + throw new Error('"skip" should satisfy the constraint - "InclusiveMinimum": 0'); + } + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serviceName}', encodeURIComponent(serviceName)); + requestUrl = requestUrl.replace('{apiId}', encodeURIComponent(apiId)); + requestUrl = requestUrl.replace('{issueId}', encodeURIComponent(issueId)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + if (skip !== null && skip !== undefined) { + queryParameters.push('$skip=' + encodeURIComponent(skip.toString())); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['IssueCommentCollection']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists all comments for the Issue assosiated with the specified API. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueCommentCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByServiceNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['IssueCommentCollection']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a ApiIssueComments. */ +class ApiIssueComments { + /** + * Create a ApiIssueComments. + * @param {ApiManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._listByService = _listByService; + this._listByServiceNext = _listByServiceNext; + } + + /** + * Lists all comments for the Issue assosiated with the specified API. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] | Field | Supported operators | + * Supported functions | + * |-------------|------------------------|-----------------------------------| + * | id | ge, le, eq, ne, gt, lt | substringof, startswith, endswith | + * | userId | ge, le, eq, ne, gt, lt | substringof, startswith, + * endswith | + * + * @param {number} [options.top] Number of records to return. + * + * @param {number} [options.skip] Number of records to skip. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByServiceWithHttpOperationResponse(resourceGroupName, serviceName, apiId, issueId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByService(resourceGroupName, serviceName, apiId, issueId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all comments for the Issue assosiated with the specified API. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] | Field | Supported operators | + * Supported functions | + * |-------------|------------------------|-----------------------------------| + * | id | ge, le, eq, ne, gt, lt | substringof, startswith, endswith | + * | userId | ge, le, eq, ne, gt, lt | substringof, startswith, + * endswith | + * + * @param {number} [options.top] Number of records to return. + * + * @param {number} [options.skip] Number of records to skip. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {IssueCommentCollection} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueCommentCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByService(resourceGroupName, serviceName, apiId, issueId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByService(resourceGroupName, serviceName, apiId, issueId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByService(resourceGroupName, serviceName, apiId, issueId, options, optionalCallback); + } + } + + /** + * Lists all comments for the Issue assosiated with the specified API. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByServiceNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByServiceNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all comments for the Issue assosiated with the specified API. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {IssueCommentCollection} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueCommentCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByServiceNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByServiceNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByServiceNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = ApiIssueComments; diff --git a/lib/services/apimanagement/lib/operations/apiIssues.js b/lib/services/apimanagement/lib/operations/apiIssues.js new file mode 100644 index 0000000000..3a575cfd2a --- /dev/null +++ b/lib/services/apimanagement/lib/operations/apiIssues.js @@ -0,0 +1,588 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists all issues assosiated with the specified API. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] | Field | Supported operators | + * Supported functions | + * |-------------|------------------------|-----------------------------------| + * | id | ge, le, eq, ne, gt, lt | substringof, startswith, endswith | + * | state | eq | + * | + * | userId | ge, le, eq, ne, gt, lt | substringof, startswith, + * endswith | + * + * @param {number} [options.top] Number of records to return. + * + * @param {number} [options.skip] Number of records to skip. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueCollection} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByService(resourceGroupName, serviceName, apiId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let skip = (options && options.skip !== undefined) ? options.skip : undefined; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (serviceName === null || serviceName === undefined || typeof serviceName.valueOf() !== 'string') { + throw new Error('serviceName cannot be null or undefined and it must be of type string.'); + } + if (serviceName !== null && serviceName !== undefined) { + if (serviceName.length > 50) + { + throw new Error('"serviceName" should satisfy the constraint - "MaxLength": 50'); + } + if (serviceName.length < 1) + { + throw new Error('"serviceName" should satisfy the constraint - "MinLength": 1'); + } + if (serviceName.match(/^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/) === null) + { + throw new Error('"serviceName" should satisfy the constraint - "Pattern": /^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/'); + } + } + if (apiId === null || apiId === undefined || typeof apiId.valueOf() !== 'string') { + throw new Error('apiId cannot be null or undefined and it must be of type string.'); + } + if (apiId !== null && apiId !== undefined) { + if (apiId.length > 80) + { + throw new Error('"apiId" should satisfy the constraint - "MaxLength": 80'); + } + if (apiId.length < 1) + { + throw new Error('"apiId" should satisfy the constraint - "MinLength": 1'); + } + if (apiId.match(/(^[\w]+$)|(^[\w][\w\-]+[\w]$)/) === null) + { + throw new Error('"apiId" should satisfy the constraint - "Pattern": /(^[\w]+$)|(^[\w][\w\-]+[\w]$)/'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (skip !== null && skip !== undefined && typeof skip !== 'number') { + throw new Error('skip must be of type number.'); + } + if (skip !== null && skip !== undefined) { + if (skip < 0) + { + throw new Error('"skip" should satisfy the constraint - "InclusiveMinimum": 0'); + } + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serviceName}', encodeURIComponent(serviceName)); + requestUrl = requestUrl.replace('{apiId}', encodeURIComponent(apiId)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + if (skip !== null && skip !== undefined) { + queryParameters.push('$skip=' + encodeURIComponent(skip.toString())); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['IssueCollection']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists all issues assosiated with the specified API. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueCollection} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByServiceNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['IssueCollection']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a ApiIssues. */ +class ApiIssues { + /** + * Create a ApiIssues. + * @param {ApiManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._listByService = _listByService; + this._listByServiceNext = _listByServiceNext; + } + + /** + * Lists all issues assosiated with the specified API. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] | Field | Supported operators | + * Supported functions | + * |-------------|------------------------|-----------------------------------| + * | id | ge, le, eq, ne, gt, lt | substringof, startswith, endswith | + * | state | eq | + * | + * | userId | ge, le, eq, ne, gt, lt | substringof, startswith, + * endswith | + * + * @param {number} [options.top] Number of records to return. + * + * @param {number} [options.skip] Number of records to skip. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByServiceWithHttpOperationResponse(resourceGroupName, serviceName, apiId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByService(resourceGroupName, serviceName, apiId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all issues assosiated with the specified API. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] | Field | Supported operators | + * Supported functions | + * |-------------|------------------------|-----------------------------------| + * | id | ge, le, eq, ne, gt, lt | substringof, startswith, endswith | + * | state | eq | + * | + * | userId | ge, le, eq, ne, gt, lt | substringof, startswith, + * endswith | + * + * @param {number} [options.top] Number of records to return. + * + * @param {number} [options.skip] Number of records to skip. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {IssueCollection} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueCollection} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByService(resourceGroupName, serviceName, apiId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByService(resourceGroupName, serviceName, apiId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByService(resourceGroupName, serviceName, apiId, options, optionalCallback); + } + } + + /** + * Lists all issues assosiated with the specified API. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByServiceNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByServiceNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all issues assosiated with the specified API. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {IssueCollection} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IssueCollection} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByServiceNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByServiceNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByServiceNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = ApiIssues; diff --git a/lib/services/apimanagement/lib/operations/index.d.ts b/lib/services/apimanagement/lib/operations/index.d.ts index 0b13b0b4ed..7f11d49aae 100644 --- a/lib/services/apimanagement/lib/operations/index.d.ts +++ b/lib/services/apimanagement/lib/operations/index.d.ts @@ -5240,6 +5240,1564 @@ export interface ApiDiagnosticLogger { listByServiceNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } +/** + * @class + * ApiIssues + * __NOTE__: An instance of this class is automatically created for an + * instance of the ApiManagementClient. + */ +export interface ApiIssues { + + + /** + * Lists all issues assosiated with the specified API. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] | Field | Supported operators | + * Supported functions | + * |-------------|------------------------|-----------------------------------| + * | id | ge, le, eq, ne, gt, lt | substringof, startswith, endswith | + * | state | eq | + * | + * | userId | ge, le, eq, ne, gt, lt | substringof, startswith, + * endswith | + * + * @param {number} [options.top] Number of records to return. + * + * @param {number} [options.skip] Number of records to skip. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByServiceWithHttpOperationResponse(resourceGroupName: string, serviceName: string, apiId: string, options?: { filter? : string, top? : number, skip? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all issues assosiated with the specified API. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] | Field | Supported operators | + * Supported functions | + * |-------------|------------------------|-----------------------------------| + * | id | ge, le, eq, ne, gt, lt | substringof, startswith, endswith | + * | state | eq | + * | + * | userId | ge, le, eq, ne, gt, lt | substringof, startswith, + * endswith | + * + * @param {number} [options.top] Number of records to return. + * + * @param {number} [options.skip] Number of records to skip. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {IssueCollection} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {IssueCollection} [result] - The deserialized result object if an error did not occur. + * See {@link IssueCollection} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByService(resourceGroupName: string, serviceName: string, apiId: string, options?: { filter? : string, top? : number, skip? : number, customHeaders? : { [headerName: string]: string; } }): Promise; + listByService(resourceGroupName: string, serviceName: string, apiId: string, callback: ServiceCallback): void; + listByService(resourceGroupName: string, serviceName: string, apiId: string, options: { filter? : string, top? : number, skip? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all issues assosiated with the specified API. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByServiceNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all issues assosiated with the specified API. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {IssueCollection} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {IssueCollection} [result] - The deserialized result object if an error did not occur. + * See {@link IssueCollection} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByServiceNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByServiceNext(nextPageLink: string, callback: ServiceCallback): void; + listByServiceNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ApiIssue + * __NOTE__: An instance of this class is automatically created for an + * instance of the ApiManagementClient. + */ +export interface ApiIssue { + + + /** + * Gets the entity state (Etag) version of the Issue for an API specified by + * its identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + headWithHttpOperationResponse(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the entity state (Etag) version of the Issue for an API specified by + * its identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + head(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + head(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, callback: ServiceCallback): void; + head(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets the details of the Issue for an API specified by its identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the details of the Issue for an API specified by its identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {IssueContract} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {IssueContract} [result] - The deserialized result object if an error did not occur. + * See {@link IssueContract} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, callback: ServiceCallback): void; + get(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Creates a new Issue for an API or updates an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} parameters Create parameters. + * + * @param {string} parameters.title The issue title. + * + * @param {string} parameters.description Text describing the issue. + * + * @param {date} [parameters.createdDate] Date and time when the issue was + * created. + * + * @param {string} [parameters.state] Status of the issue. Possible values + * include: 'proposed', 'open', 'removed', 'resolved', 'closed' + * + * @param {string} parameters.userId A resource identifier for the user created + * the issue. + * + * @param {string} [parameters.apiId] A resource identifier for the API the + * issue was created for. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.ifMatch] ETag of the Issue Entity. ETag should + * match the current entity state from the header response of the GET request + * or it should be * for unconditional update. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, parameters: models.IssueContract, options?: { ifMatch? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Creates a new Issue for an API or updates an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} parameters Create parameters. + * + * @param {string} parameters.title The issue title. + * + * @param {string} parameters.description Text describing the issue. + * + * @param {date} [parameters.createdDate] Date and time when the issue was + * created. + * + * @param {string} [parameters.state] Status of the issue. Possible values + * include: 'proposed', 'open', 'removed', 'resolved', 'closed' + * + * @param {string} parameters.userId A resource identifier for the user created + * the issue. + * + * @param {string} [parameters.apiId] A resource identifier for the API the + * issue was created for. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.ifMatch] ETag of the Issue Entity. ETag should + * match the current entity state from the header response of the GET request + * or it should be * for unconditional update. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {IssueContract} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {IssueContract} [result] - The deserialized result object if an error did not occur. + * See {@link IssueContract} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, parameters: models.IssueContract, options?: { ifMatch? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, parameters: models.IssueContract, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, parameters: models.IssueContract, options: { ifMatch? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes the specified Issue from an API. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} ifMatch ETag of the Issue Entity. ETag should match the + * current entity state from the header response of the GET request or it + * should be * for unconditional update. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, ifMatch: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes the specified Issue from an API. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} ifMatch ETag of the Issue Entity. ETag should match the + * current entity state from the header response of the GET request or it + * should be * for unconditional update. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, ifMatch: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, ifMatch: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, ifMatch: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ApiIssueComments + * __NOTE__: An instance of this class is automatically created for an + * instance of the ApiManagementClient. + */ +export interface ApiIssueComments { + + + /** + * Lists all comments for the Issue assosiated with the specified API. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] | Field | Supported operators | + * Supported functions | + * |-------------|------------------------|-----------------------------------| + * | id | ge, le, eq, ne, gt, lt | substringof, startswith, endswith | + * | userId | ge, le, eq, ne, gt, lt | substringof, startswith, + * endswith | + * + * @param {number} [options.top] Number of records to return. + * + * @param {number} [options.skip] Number of records to skip. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByServiceWithHttpOperationResponse(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, options?: { filter? : string, top? : number, skip? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all comments for the Issue assosiated with the specified API. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] | Field | Supported operators | + * Supported functions | + * |-------------|------------------------|-----------------------------------| + * | id | ge, le, eq, ne, gt, lt | substringof, startswith, endswith | + * | userId | ge, le, eq, ne, gt, lt | substringof, startswith, + * endswith | + * + * @param {number} [options.top] Number of records to return. + * + * @param {number} [options.skip] Number of records to skip. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {IssueCommentCollection} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {IssueCommentCollection} [result] - The deserialized result object if an error did not occur. + * See {@link IssueCommentCollection} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByService(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, options?: { filter? : string, top? : number, skip? : number, customHeaders? : { [headerName: string]: string; } }): Promise; + listByService(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, callback: ServiceCallback): void; + listByService(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, options: { filter? : string, top? : number, skip? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all comments for the Issue assosiated with the specified API. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByServiceNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all comments for the Issue assosiated with the specified API. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {IssueCommentCollection} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {IssueCommentCollection} [result] - The deserialized result object if an error did not occur. + * See {@link IssueCommentCollection} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByServiceNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByServiceNext(nextPageLink: string, callback: ServiceCallback): void; + listByServiceNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ApiIssuComment + * __NOTE__: An instance of this class is automatically created for an + * instance of the ApiManagementClient. + */ +export interface ApiIssuComment { + + + /** + * Gets the entity state (Etag) version of the issue Comment for an API + * specified by its identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} commentId Comment identifier within an Issue. Must be unique + * in the current Issue. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + headWithHttpOperationResponse(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, commentId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the entity state (Etag) version of the issue Comment for an API + * specified by its identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} commentId Comment identifier within an Issue. Must be unique + * in the current Issue. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + head(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, commentId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + head(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, commentId: string, callback: ServiceCallback): void; + head(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, commentId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ApiIssueComment + * __NOTE__: An instance of this class is automatically created for an + * instance of the ApiManagementClient. + */ +export interface ApiIssueComment { + + + /** + * Gets the details of the issue Comment for an API specified by its + * identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} commentId Comment identifier within an Issue. Must be unique + * in the current Issue. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, commentId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the details of the issue Comment for an API specified by its + * identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} commentId Comment identifier within an Issue. Must be unique + * in the current Issue. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {IssueCommentContract} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {IssueCommentContract} [result] - The deserialized result object if an error did not occur. + * See {@link IssueCommentContract} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, commentId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, commentId: string, callback: ServiceCallback): void; + get(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, commentId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Creates a new Comment for the Issue in an API or updates an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} commentId Comment identifier within an Issue. Must be unique + * in the current Issue. + * + * @param {object} parameters Create parameters. + * + * @param {string} parameters.text Comment text. + * + * @param {date} [parameters.createdDate] Date and time when the comment was + * created. + * + * @param {string} parameters.userId A resource identifier for the user who + * left the comment. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.ifMatch] ETag of the Issue Entity. ETag should + * match the current entity state from the header response of the GET request + * or it should be * for unconditional update. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, commentId: string, parameters: models.IssueCommentContract, options?: { ifMatch? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Creates a new Comment for the Issue in an API or updates an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} commentId Comment identifier within an Issue. Must be unique + * in the current Issue. + * + * @param {object} parameters Create parameters. + * + * @param {string} parameters.text Comment text. + * + * @param {date} [parameters.createdDate] Date and time when the comment was + * created. + * + * @param {string} parameters.userId A resource identifier for the user who + * left the comment. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.ifMatch] ETag of the Issue Entity. ETag should + * match the current entity state from the header response of the GET request + * or it should be * for unconditional update. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {IssueCommentContract} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {IssueCommentContract} [result] - The deserialized result object if an error did not occur. + * See {@link IssueCommentContract} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, commentId: string, parameters: models.IssueCommentContract, options?: { ifMatch? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, commentId: string, parameters: models.IssueCommentContract, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, commentId: string, parameters: models.IssueCommentContract, options: { ifMatch? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes the specified comment from an Issue. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} commentId Comment identifier within an Issue. Must be unique + * in the current Issue. + * + * @param {string} ifMatch ETag of the Issue Entity. ETag should match the + * current entity state from the header response of the GET request or it + * should be * for unconditional update. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, commentId: string, ifMatch: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes the specified comment from an Issue. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} commentId Comment identifier within an Issue. Must be unique + * in the current Issue. + * + * @param {string} ifMatch ETag of the Issue Entity. ETag should match the + * current entity state from the header response of the GET request or it + * should be * for unconditional update. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, commentId: string, ifMatch: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, commentId: string, ifMatch: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, commentId: string, ifMatch: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ApiIssueAttachments + * __NOTE__: An instance of this class is automatically created for an + * instance of the ApiManagementClient. + */ +export interface ApiIssueAttachments { + + + /** + * Lists all comments for the Issue assosiated with the specified API. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] | Field | Supported operators | + * Supported functions | + * |-------------|------------------------|-----------------------------------| + * | id | ge, le, eq, ne, gt, lt | substringof, startswith, endswith | + * | userId | ge, le, eq, ne, gt, lt | substringof, startswith, + * endswith | + * + * @param {number} [options.top] Number of records to return. + * + * @param {number} [options.skip] Number of records to skip. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByServiceWithHttpOperationResponse(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, options?: { filter? : string, top? : number, skip? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all comments for the Issue assosiated with the specified API. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] | Field | Supported operators | + * Supported functions | + * |-------------|------------------------|-----------------------------------| + * | id | ge, le, eq, ne, gt, lt | substringof, startswith, endswith | + * | userId | ge, le, eq, ne, gt, lt | substringof, startswith, + * endswith | + * + * @param {number} [options.top] Number of records to return. + * + * @param {number} [options.skip] Number of records to skip. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {IssueAttachmentCollection} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {IssueAttachmentCollection} [result] - The deserialized result object if an error did not occur. + * See {@link IssueAttachmentCollection} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByService(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, options?: { filter? : string, top? : number, skip? : number, customHeaders? : { [headerName: string]: string; } }): Promise; + listByService(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, callback: ServiceCallback): void; + listByService(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, options: { filter? : string, top? : number, skip? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all comments for the Issue assosiated with the specified API. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByServiceNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all comments for the Issue assosiated with the specified API. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {IssueAttachmentCollection} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {IssueAttachmentCollection} [result] - The deserialized result object if an error did not occur. + * See {@link IssueAttachmentCollection} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByServiceNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByServiceNext(nextPageLink: string, callback: ServiceCallback): void; + listByServiceNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ApiIssuAttachment + * __NOTE__: An instance of this class is automatically created for an + * instance of the ApiManagementClient. + */ +export interface ApiIssuAttachment { + + + /** + * Gets the entity state (Etag) version of the issue Attachment for an API + * specified by its identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} attachmentId Attachment identifier within an Issue. Must be + * unique in the current Issue. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + headWithHttpOperationResponse(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, attachmentId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the entity state (Etag) version of the issue Attachment for an API + * specified by its identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} attachmentId Attachment identifier within an Issue. Must be + * unique in the current Issue. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + head(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, attachmentId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + head(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, attachmentId: string, callback: ServiceCallback): void; + head(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, attachmentId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ApiIssueAttachment + * __NOTE__: An instance of this class is automatically created for an + * instance of the ApiManagementClient. + */ +export interface ApiIssueAttachment { + + + /** + * Gets the details of the issue Attachment for an API specified by its + * identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} attachmentId Attachment identifier within an Issue. Must be + * unique in the current Issue. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, attachmentId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the details of the issue Attachment for an API specified by its + * identifier. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} attachmentId Attachment identifier within an Issue. Must be + * unique in the current Issue. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {IssueAttachmentContract} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {IssueAttachmentContract} [result] - The deserialized result object if an error did not occur. + * See {@link IssueAttachmentContract} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, attachmentId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, attachmentId: string, callback: ServiceCallback): void; + get(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, attachmentId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Creates a new Attachment for the Issue in an API or updates an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} attachmentId Attachment identifier within an Issue. Must be + * unique in the current Issue. + * + * @param {object} parameters Create parameters. + * + * @param {string} parameters.title Filename by which the binary data will be + * saved. + * + * @param {string} parameters.contentFormat Either 'link' if content is + * provided via an HTTP link or the MIME type of the Base64-encoded binary data + * provided in the 'content' property. + * + * @param {string} parameters.content An HTTP link or Base64-encoded binary + * data. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.ifMatch] ETag of the Issue Entity. ETag should + * match the current entity state from the header response of the GET request + * or it should be * for unconditional update. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, attachmentId: string, parameters: models.IssueAttachmentContract, options?: { ifMatch? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Creates a new Attachment for the Issue in an API or updates an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} attachmentId Attachment identifier within an Issue. Must be + * unique in the current Issue. + * + * @param {object} parameters Create parameters. + * + * @param {string} parameters.title Filename by which the binary data will be + * saved. + * + * @param {string} parameters.contentFormat Either 'link' if content is + * provided via an HTTP link or the MIME type of the Base64-encoded binary data + * provided in the 'content' property. + * + * @param {string} parameters.content An HTTP link or Base64-encoded binary + * data. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.ifMatch] ETag of the Issue Entity. ETag should + * match the current entity state from the header response of the GET request + * or it should be * for unconditional update. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {IssueAttachmentContract} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {IssueAttachmentContract} [result] - The deserialized result object if an error did not occur. + * See {@link IssueAttachmentContract} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, attachmentId: string, parameters: models.IssueAttachmentContract, options?: { ifMatch? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, attachmentId: string, parameters: models.IssueAttachmentContract, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, attachmentId: string, parameters: models.IssueAttachmentContract, options: { ifMatch? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes the specified comment from an Issue. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} attachmentId Attachment identifier within an Issue. Must be + * unique in the current Issue. + * + * @param {string} ifMatch ETag of the Issue Entity. ETag should match the + * current entity state from the header response of the GET request or it + * should be * for unconditional update. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, attachmentId: string, ifMatch: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes the specified comment from an Issue. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} serviceName The name of the API Management service. + * + * @param {string} apiId API identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} issueId Issue identifier. Must be unique in the current API + * Management service instance. + * + * @param {string} attachmentId Attachment identifier within an Issue. Must be + * unique in the current Issue. + * + * @param {string} ifMatch ETag of the Issue Entity. ETag should match the + * current entity state from the header response of the GET request or it + * should be * for unconditional update. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, attachmentId: string, ifMatch: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, attachmentId: string, ifMatch: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, serviceName: string, apiId: string, issueId: string, attachmentId: string, ifMatch: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + /** * @class * AuthorizationServer diff --git a/lib/services/apimanagement/lib/operations/index.js b/lib/services/apimanagement/lib/operations/index.js index a5d998d55a..98ca92a21b 100644 --- a/lib/services/apimanagement/lib/operations/index.js +++ b/lib/services/apimanagement/lib/operations/index.js @@ -27,6 +27,14 @@ exports.ApiPolicy = require('./apiPolicy'); exports.ApiSchema = require('./apiSchema'); exports.ApiDiagnostic = require('./apiDiagnostic'); exports.ApiDiagnosticLogger = require('./apiDiagnosticLogger'); +exports.ApiIssues = require('./apiIssues'); +exports.ApiIssue = require('./apiIssue'); +exports.ApiIssueComments = require('./apiIssueComments'); +exports.ApiIssuComment = require('./apiIssuComment'); +exports.ApiIssueComment = require('./apiIssueComment'); +exports.ApiIssueAttachments = require('./apiIssueAttachments'); +exports.ApiIssuAttachment = require('./apiIssuAttachment'); +exports.ApiIssueAttachment = require('./apiIssueAttachment'); exports.AuthorizationServer = require('./authorizationServer'); exports.Backend = require('./backend'); exports.Certificate = require('./certificate'); diff --git a/lib/services/apimanagement/package.json b/lib/services/apimanagement/package.json index 8a9e6b9dd5..73d1daed63 100644 --- a/lib/services/apimanagement/package.json +++ b/lib/services/apimanagement/package.json @@ -4,7 +4,7 @@ "description": "ApiManagementClient Library with typescript type definitions for node", "version": "2.1.0-preview", "dependencies": { - "ms-rest": "^2.3.3", + "ms-rest": "^2.3.2", "ms-rest-azure": "^2.5.5" }, "keywords": [ "node", "azure" ],