diff --git a/lib/services/eventHubManagement/lib/models/index.d.ts b/lib/services/eventHubManagement/lib/models/index.d.ts index a96bab08fd..48e0dc2336 100644 --- a/lib/services/eventHubManagement/lib/models/index.d.ts +++ b/lib/services/eventHubManagement/lib/models/index.d.ts @@ -428,6 +428,24 @@ export interface MessagingRegions extends TrackedResource { properties?: MessagingRegionsProperties; } +/** + * @class + * Initializes a new instance of the MessagingPlan class. + * @constructor + * Messaging Plan for the namespace + * + * @member {number} [sku] Sku type + * @member {number} [selectedEventHubUnit] Selected event hub unit + * @member {date} [updatedAt] The exact time the messaging plan was updated. + * @member {number} [revision] revision number + */ +export interface MessagingPlan extends TrackedResource { + readonly sku?: number; + readonly selectedEventHubUnit?: number; + readonly updatedAt?: Date; + readonly revision?: number; +} + /** * @class diff --git a/lib/services/eventHubManagement/lib/models/index.js b/lib/services/eventHubManagement/lib/models/index.js index 1916762b8c..04a95dd33d 100644 --- a/lib/services/eventHubManagement/lib/models/index.js +++ b/lib/services/eventHubManagement/lib/models/index.js @@ -37,6 +37,7 @@ exports.ErrorResponse = require('./errorResponse'); exports.ArmDisasterRecovery = require('./armDisasterRecovery'); exports.MessagingRegionsProperties = require('./messagingRegionsProperties'); exports.MessagingRegions = require('./messagingRegions'); +exports.MessagingPlan = require('./messagingPlan'); exports.OperationListResult = require('./operationListResult'); exports.EHNamespaceListResult = require('./eHNamespaceListResult'); exports.AuthorizationRuleListResult = require('./authorizationRuleListResult'); diff --git a/lib/services/eventHubManagement/lib/models/messagingPlan.js b/lib/services/eventHubManagement/lib/models/messagingPlan.js new file mode 100644 index 0000000000..000cfcf0e5 --- /dev/null +++ b/lib/services/eventHubManagement/lib/models/messagingPlan.js @@ -0,0 +1,129 @@ +/* + * 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'); + +/** + * Messaging Plan for the namespace + * + * @extends models['TrackedResource'] + */ +class MessagingPlan extends models['TrackedResource'] { + /** + * Create a MessagingPlan. + * @member {number} [sku] Sku type + * @member {number} [selectedEventHubUnit] Selected event hub unit + * @member {date} [updatedAt] The exact time the messaging plan was updated. + * @member {number} [revision] revision number + */ + constructor() { + super(); + } + + /** + * Defines the metadata of MessagingPlan + * + * @returns {object} metadata of MessagingPlan + * + */ + mapper() { + return { + required: false, + serializedName: 'MessagingPlan', + type: { + name: 'Composite', + className: 'MessagingPlan', + 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' + } + }, + location: { + required: false, + serializedName: 'location', + type: { + name: 'String' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + sku: { + required: false, + readOnly: true, + serializedName: 'properties.sku', + type: { + name: 'Number' + } + }, + selectedEventHubUnit: { + required: false, + readOnly: true, + serializedName: 'properties.selectedEventHubUnit', + type: { + name: 'Number' + } + }, + updatedAt: { + required: false, + readOnly: true, + serializedName: 'properties.updatedAt', + type: { + name: 'DateTime' + } + }, + revision: { + required: false, + readOnly: true, + serializedName: 'properties.revision', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = MessagingPlan; diff --git a/lib/services/eventHubManagement/lib/operations/index.d.ts b/lib/services/eventHubManagement/lib/operations/index.d.ts index a5264178c6..d8c475b52a 100644 --- a/lib/services/eventHubManagement/lib/operations/index.d.ts +++ b/lib/services/eventHubManagement/lib/operations/index.d.ts @@ -657,6 +657,67 @@ export interface Namespaces { update(resourceGroupName: string, namespaceName: string, parameters: models.EHNamespace, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + /** + * Gets messaging plan for specified namespace. + * + * @param {string} resourceGroupName Name of the resource group within the + * azure subscription. + * + * @param {string} namespaceName The Namespace name + * + * @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. + */ + getMessagingPlanWithHttpOperationResponse(resourceGroupName: string, namespaceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets messaging plan for specified namespace. + * + * @param {string} resourceGroupName Name of the resource group within the + * azure subscription. + * + * @param {string} namespaceName The Namespace name + * + * @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 {MessagingPlan} - 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. + * + * {MessagingPlan} [result] - The deserialized result object if an error did not occur. + * See {@link MessagingPlan} 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. + */ + getMessagingPlan(resourceGroupName: string, namespaceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getMessagingPlan(resourceGroupName: string, namespaceName: string, callback: ServiceCallback): void; + getMessagingPlan(resourceGroupName: string, namespaceName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + /** * Gets a list of authorization rules for a Namespace. * diff --git a/lib/services/eventHubManagement/lib/operations/namespaces.js b/lib/services/eventHubManagement/lib/operations/namespaces.js index 276bfb4dd0..e85f6de588 100644 --- a/lib/services/eventHubManagement/lib/operations/namespaces.js +++ b/lib/services/eventHubManagement/lib/operations/namespaces.js @@ -1037,6 +1037,173 @@ function _update(resourceGroupName, namespaceName, parameters, options, callback }); } +/** + * Gets messaging plan for specified namespace. + * + * @param {string} resourceGroupName Name of the resource group within the + * azure subscription. + * + * @param {string} namespaceName The Namespace name + * + * @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 MessagingPlan} 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 _getMessagingPlan(resourceGroupName, namespaceName, 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 (resourceGroupName !== null && resourceGroupName !== undefined) { + if (resourceGroupName.length > 90) + { + throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); + } + if (resourceGroupName.length < 1) + { + throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); + } + } + if (namespaceName === null || namespaceName === undefined || typeof namespaceName.valueOf() !== 'string') { + throw new Error('namespaceName cannot be null or undefined and it must be of type string.'); + } + if (namespaceName !== null && namespaceName !== undefined) { + if (namespaceName.length > 50) + { + throw new Error('"namespaceName" should satisfy the constraint - "MaxLength": 50'); + } + if (namespaceName.length < 6) + { + throw new Error('"namespaceName" should satisfy the constraint - "MinLength": 6'); + } + } + 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.EventHub/namespaces/{namespaceName}/messagingplan'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{namespaceName}', encodeURIComponent(namespaceName)); + 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['MessagingPlan']().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); + }); +} + /** * Gets a list of authorization rules for a Namespace. * @@ -2907,6 +3074,7 @@ class Namespaces { this._deleteMethod = _deleteMethod; this._get = _get; this._update = _update; + this._getMessagingPlan = _getMessagingPlan; this._listAuthorizationRules = _listAuthorizationRules; this._createOrUpdateAuthorizationRule = _createOrUpdateAuthorizationRule; this._deleteAuthorizationRule = _deleteAuthorizationRule; @@ -3628,6 +3796,94 @@ class Namespaces { } } + /** + * Gets messaging plan for specified namespace. + * + * @param {string} resourceGroupName Name of the resource group within the + * azure subscription. + * + * @param {string} namespaceName The Namespace name + * + * @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. + */ + getMessagingPlanWithHttpOperationResponse(resourceGroupName, namespaceName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._getMessagingPlan(resourceGroupName, namespaceName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets messaging plan for specified namespace. + * + * @param {string} resourceGroupName Name of the resource group within the + * azure subscription. + * + * @param {string} namespaceName The Namespace name + * + * @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 {MessagingPlan} - 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 MessagingPlan} 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. + */ + getMessagingPlan(resourceGroupName, namespaceName, 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._getMessagingPlan(resourceGroupName, namespaceName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._getMessagingPlan(resourceGroupName, namespaceName, options, optionalCallback); + } + } + /** * Gets a list of authorization rules for a Namespace. *