diff --git a/lib/services/searchManagement/LICENSE.txt b/lib/services/searchManagement/LICENSE.txt index 0313a903d7..5431ba98b9 100644 --- a/lib/services/searchManagement/LICENSE.txt +++ b/lib/services/searchManagement/LICENSE.txt @@ -1,21 +1,21 @@ -The MIT License (MIT) - -Copyright (c) 2017 Microsoft - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +The MIT License (MIT) + +Copyright (c) 2018 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/lib/services/searchManagement/README.md b/lib/services/searchManagement/README.md index 0759bb9257..04ca7f4c65 100644 --- a/lib/services/searchManagement/README.md +++ b/lib/services/searchManagement/README.md @@ -1,38 +1,40 @@ -# Microsoft Azure SDK for Node.js - SearchManagement - -This project provides a Node.js package that makes it easy to manage Microsoft Azure Search. -## API-Version: 2015-08-19 -## Minimum node.js version >= 6.x.x - -## How to Install - -```bash -npm install azure-arm-search -``` - -## How to Use - -### Authentication, client creation and listing services as an example - - ```javascript - const msRestAzure = require('ms-rest-azure'); - const SearchManagement = require("azure-arm-search"); - - // Interactive Login - // It provides a url and code that needs to be copied and pasted in a browser and authenticated over there. If successful, - // the user will get a DeviceTokenCredentials object. - msRestAzure.interactiveLogin().then((credentials) => { - let client = new SearchManagement(credentials, 'your-subscription-id'); - return client.services.listByResourceGroup('testrg'); - }).then((services) => { - console.log('List of services:'); - console.dir(services, {depth: null, colors: true}); -}).catch((err) => { - console.log('An error ocurred'); - console.dir(err, {depth: null, colors: true}); - }); -``` - -## Related projects - -- [Microsoft Azure SDK for Node.js](https://github.com/Azure/azure-sdk-for-node) \ No newline at end of file +--- +uid: azure-arm-search +summary: *content + +--- +# Microsoft Azure SDK for Node.js - SearchManagementClient +This project provides a Node.js package for accessing Azure. Right now it supports: +- **Node.js version 6.x.x or higher** + +## Features + + +## How to Install + +```bash +npm install azure-arm-search +``` + +## How to use + +### Authentication, client creation and list operations as an example. + +```javascript +const msRestAzure = require("ms-rest-azure"); +const SearchManagementClient = require("azure-arm-search"); +msRestAzure.interactiveLogin().then((creds) => { + const subscriptionId = ""; + const client = new SearchManagementClient(creds, subscriptionId); + return client.operations.list().then((result) => { + console.log("The result is:"); + console.log(result); + }); +}).catch((err) => { + console.log('An error occurred:'); + console.dir(err, {depth: null, colors: true}); +}); + +## Related projects + +- [Microsoft Azure SDK for Node.js](https://github.com/Azure/azure-sdk-for-node) diff --git a/lib/services/searchManagement/lib/models/identity.js b/lib/services/searchManagement/lib/models/identity.js new file mode 100644 index 0000000000..334b53a81b --- /dev/null +++ b/lib/services/searchManagement/lib/models/identity.js @@ -0,0 +1,71 @@ +/* + * 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'; + +/** + * Identity for the resource. + * + */ +class Identity { + /** + * Create a Identity. + * @member {string} [principalId] The principal ID of resource identity. + * @member {string} [tenantId] The tenant ID of resource. + */ + constructor() { + } + + /** + * Defines the metadata of Identity + * + * @returns {object} metadata of Identity + * + */ + mapper() { + return { + required: false, + serializedName: 'Identity', + type: { + name: 'Composite', + className: 'Identity', + modelProperties: { + principalId: { + required: false, + readOnly: true, + serializedName: 'principalId', + type: { + name: 'String' + } + }, + tenantId: { + required: false, + readOnly: true, + serializedName: 'tenantId', + type: { + name: 'String' + } + }, + type: { + required: true, + isConstant: true, + serializedName: 'type', + defaultValue: 'SystemAssigned', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = Identity; diff --git a/lib/services/searchManagement/lib/models/index.d.ts b/lib/services/searchManagement/lib/models/index.d.ts index 15b30744fd..dc0aad4d23 100644 --- a/lib/services/searchManagement/lib/models/index.d.ts +++ b/lib/services/searchManagement/lib/models/index.d.ts @@ -116,18 +116,24 @@ export interface Sku { * Azure Resource Manager to link resources together. * @member {string} [name] The name of the resource. * @member {string} [type] The resource type. - * @member {string} location The geographic location of the resource. This must - * be one of the supported and registered Azure Geo Regions (for example, West - * US, East US, Southeast Asia, and so forth). + * @member {string} [location] The geographic location of the resource. This + * must be one of the supported and registered Azure Geo Regions (for example, + * West US, East US, Southeast Asia, and so forth). This property is required + * when creating a new resource. * @member {object} [tags] Tags to help categorize the resource in the Azure * portal. + * @member {object} [identity] The identity of the resource. + * @member {string} [identity.principalId] The principal ID of resource + * identity. + * @member {string} [identity.tenantId] The tenant ID of resource. */ export interface Resource extends BaseResource { readonly id?: string; readonly name?: string; readonly type?: string; - location: string; + location?: string; tags?: { [propertyName: string]: string }; + identity?: Identity; } /** @@ -176,8 +182,9 @@ export interface Resource extends BaseResource { * the call to Create Search service. This is because the free service uses * capacity that is already set up. Possible values include: 'succeeded', * 'provisioning', 'failed' - * @member {object} sku The SKU of the Search Service, which determines price - * tier and capacity limits. + * @member {object} [sku] The SKU of the Search Service, which determines price + * tier and capacity limits. This property is required when creating a new + * Search Service. * @member {string} [sku.name] The SKU of the Search service. Valid values * include: 'free': Shared service. 'basic': Dedicated service with up to 3 * replicas. 'standard': Dedicated service with up to 12 partitions and 12 @@ -194,7 +201,63 @@ export interface SearchService extends Resource { readonly status?: string; readonly statusDetails?: string; readonly provisioningState?: string; - sku: Sku; + sku?: Sku; +} + +/** + * @class + * Initializes a new instance of the Identity class. + * @constructor + * Identity for the resource. + * + * @member {string} [principalId] The principal ID of resource identity. + * @member {string} [tenantId] The tenant ID of resource. + */ +export interface Identity { + readonly principalId?: string; + readonly tenantId?: string; +} + +/** + * @class + * Initializes a new instance of the OperationDisplay class. + * @constructor + * The object that describes the operation. + * + * @member {string} [provider] The friendly name of the resource provider. + * @member {string} [operation] The operation type: read, write, delete, + * listKeys/action, etc. + * @member {string} [resource] The resource type on which the operation is + * performed. + * @member {string} [description] The friendly name of the operation. + */ +export interface OperationDisplay { + readonly provider?: string; + readonly operation?: string; + readonly resource?: string; + readonly description?: string; +} + +/** + * @class + * Initializes a new instance of the Operation class. + * @constructor + * Describes a REST API operation. + * + * @member {string} [name] The name of the operation. This name is of the form + * {provider}/{resource}/{operation}. + * @member {object} [display] The object that describes the operation. + * @member {string} [display.provider] The friendly name of the resource + * provider. + * @member {string} [display.operation] The operation type: read, write, + * delete, listKeys/action, etc. + * @member {string} [display.resource] The resource type on which the operation + * is performed. + * @member {string} [display.description] The friendly name of the operation. + */ +export interface Operation { + readonly name?: string; + readonly display?: OperationDisplay; } /** @@ -212,6 +275,20 @@ export interface SearchManagementRequestOptions { } +/** + * @class + * Initializes a new instance of the OperationListResult class. + * @constructor + * The result of the request to list REST API operations. It contains a list of + * operations and a URL to get the next set of results. + * + * @member {string} [nextLink] The URL to get the next set of operation list + * results, if any. + */ +export interface OperationListResult extends Array { + readonly nextLink?: string; +} + /** * @class * Initializes a new instance of the ListQueryKeysResult class. diff --git a/lib/services/searchManagement/lib/models/index.js b/lib/services/searchManagement/lib/models/index.js index d393d21633..b945e293c5 100644 --- a/lib/services/searchManagement/lib/models/index.js +++ b/lib/services/searchManagement/lib/models/index.js @@ -25,6 +25,10 @@ exports.QueryKey = require('./queryKey'); exports.Sku = require('./sku'); exports.Resource = require('./resource'); exports.SearchService = require('./searchService'); +exports.Identity = require('./identity'); +exports.OperationDisplay = require('./operationDisplay'); +exports.Operation = require('./operation'); exports.SearchManagementRequestOptions = require('./searchManagementRequestOptions'); +exports.OperationListResult = require('./operationListResult'); exports.ListQueryKeysResult = require('./listQueryKeysResult'); exports.SearchServiceListResult = require('./searchServiceListResult'); diff --git a/lib/services/searchManagement/lib/models/operation.js b/lib/services/searchManagement/lib/models/operation.js new file mode 100644 index 0000000000..d342a4ce1a --- /dev/null +++ b/lib/services/searchManagement/lib/models/operation.js @@ -0,0 +1,73 @@ +/* + * 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'); + +/** + * Describes a REST API operation. + * + */ +class Operation { + /** + * Create a Operation. + * @member {string} [name] The name of the operation. This name is of the + * form {provider}/{resource}/{operation}. + * @member {object} [display] The object that describes the operation. + * @member {string} [display.provider] The friendly name of the resource + * provider. + * @member {string} [display.operation] The operation type: read, write, + * delete, listKeys/action, etc. + * @member {string} [display.resource] The resource type on which the + * operation is performed. + * @member {string} [display.description] The friendly name of the operation. + */ + constructor() { + } + + /** + * Defines the metadata of Operation + * + * @returns {object} metadata of Operation + * + */ + mapper() { + return { + required: false, + serializedName: 'Operation', + type: { + name: 'Composite', + className: 'Operation', + modelProperties: { + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + display: { + required: false, + readOnly: true, + serializedName: 'display', + type: { + name: 'Composite', + className: 'OperationDisplay' + } + } + } + } + }; + } +} + +module.exports = Operation; diff --git a/lib/services/searchManagement/lib/models/operationDisplay.js b/lib/services/searchManagement/lib/models/operationDisplay.js new file mode 100644 index 0000000000..06f752fe3f --- /dev/null +++ b/lib/services/searchManagement/lib/models/operationDisplay.js @@ -0,0 +1,82 @@ +/* + * 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'; + +/** + * The object that describes the operation. + * + */ +class OperationDisplay { + /** + * Create a OperationDisplay. + * @member {string} [provider] The friendly name of the resource provider. + * @member {string} [operation] The operation type: read, write, delete, + * listKeys/action, etc. + * @member {string} [resource] The resource type on which the operation is + * performed. + * @member {string} [description] The friendly name of the operation. + */ + constructor() { + } + + /** + * Defines the metadata of OperationDisplay + * + * @returns {object} metadata of OperationDisplay + * + */ + mapper() { + return { + required: false, + serializedName: 'Operation_display', + type: { + name: 'Composite', + className: 'OperationDisplay', + modelProperties: { + provider: { + required: false, + readOnly: true, + serializedName: 'provider', + type: { + name: 'String' + } + }, + operation: { + required: false, + readOnly: true, + serializedName: 'operation', + type: { + name: 'String' + } + }, + resource: { + required: false, + readOnly: true, + serializedName: 'resource', + type: { + name: 'String' + } + }, + description: { + required: false, + readOnly: true, + serializedName: 'description', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = OperationDisplay; diff --git a/lib/services/searchManagement/lib/models/operationListResult.js b/lib/services/searchManagement/lib/models/operationListResult.js new file mode 100644 index 0000000000..055dfd72eb --- /dev/null +++ b/lib/services/searchManagement/lib/models/operationListResult.js @@ -0,0 +1,63 @@ +/* + * 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'; + +/** + * The result of the request to list REST API operations. It contains a list of + * operations and a URL to get the next set of results. + */ +class OperationListResult extends Array { + /** + * Create a OperationListResult. + * @member {string} [nextLink] The URL to get the next set of operation list + * results, if any. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of OperationListResult + * + * @returns {object} metadata of OperationListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'OperationListResult', + type: { + name: 'Composite', + className: 'OperationListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'OperationElementType', + type: { + name: 'Composite', + className: 'Operation' + } + } + } + } + } + } + }; + } +} + +module.exports = OperationListResult; diff --git a/lib/services/searchManagement/lib/models/resource.js b/lib/services/searchManagement/lib/models/resource.js index e46f35b5f3..126c5de0cd 100644 --- a/lib/services/searchManagement/lib/models/resource.js +++ b/lib/services/searchManagement/lib/models/resource.js @@ -24,11 +24,16 @@ class Resource extends models['BaseResource'] { * Azure Resource Manager to link resources together. * @member {string} [name] The name of the resource. * @member {string} [type] The resource type. - * @member {string} location The geographic location of the resource. This + * @member {string} [location] The geographic location of the resource. This * must be one of the supported and registered Azure Geo Regions (for - * example, West US, East US, Southeast Asia, and so forth). + * example, West US, East US, Southeast Asia, and so forth). This property is + * required when creating a new resource. * @member {object} [tags] Tags to help categorize the resource in the Azure * portal. + * @member {object} [identity] The identity of the resource. + * @member {string} [identity.principalId] The principal ID of resource + * identity. + * @member {string} [identity.tenantId] The tenant ID of resource. */ constructor() { super(); @@ -73,7 +78,7 @@ class Resource extends models['BaseResource'] { } }, location: { - required: true, + required: false, serializedName: 'location', type: { name: 'String' @@ -92,6 +97,14 @@ class Resource extends models['BaseResource'] { } } } + }, + identity: { + required: false, + serializedName: 'identity', + type: { + name: 'Composite', + className: 'Identity' + } } } } diff --git a/lib/services/searchManagement/lib/models/searchService.js b/lib/services/searchManagement/lib/models/searchService.js index 537f63d385..a44f18dab2 100644 --- a/lib/services/searchManagement/lib/models/searchService.js +++ b/lib/services/searchManagement/lib/models/searchService.js @@ -62,8 +62,9 @@ class SearchService extends models['Resource'] { * 'succeeded' directly in the call to Create Search service. This is because * the free service uses capacity that is already set up. Possible values * include: 'succeeded', 'provisioning', 'failed' - * @member {object} sku The SKU of the Search Service, which determines price - * tier and capacity limits. + * @member {object} [sku] The SKU of the Search Service, which determines + * price tier and capacity limits. This property is required when creating a + * new Search Service. * @member {string} [sku.name] The SKU of the Search service. Valid values * include: 'free': Shared service. 'basic': Dedicated service with up to 3 * replicas. 'standard': Dedicated service with up to 12 partitions and 12 @@ -116,7 +117,7 @@ class SearchService extends models['Resource'] { } }, location: { - required: true, + required: false, serializedName: 'location', type: { name: 'String' @@ -136,6 +137,14 @@ class SearchService extends models['Resource'] { } } }, + identity: { + required: false, + serializedName: 'identity', + type: { + name: 'Composite', + className: 'Identity' + } + }, replicaCount: { required: false, serializedName: 'properties.replicaCount', @@ -196,7 +205,7 @@ class SearchService extends models['Resource'] { } }, sku: { - required: true, + required: false, serializedName: 'sku', type: { name: 'Composite', diff --git a/lib/services/searchManagement/lib/operations/index.d.ts b/lib/services/searchManagement/lib/operations/index.d.ts index 8dc9e79678..ccef8a88d1 100644 --- a/lib/services/searchManagement/lib/operations/index.d.ts +++ b/lib/services/searchManagement/lib/operations/index.d.ts @@ -12,6 +12,68 @@ import { ServiceClientOptions, RequestOptions, ServiceCallback, HttpOperationRes import * as models from '../models'; +/** + * @class + * Operations + * __NOTE__: An instance of this class is automatically created for an + * instance of the SearchManagementClient. + */ +export interface Operations { + + + /** + * Lists all of the available REST API operations of the Microsoft.Search + * provider. + * + * @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. + */ + listWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all of the available REST API operations of the Microsoft.Search + * provider. + * + * @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 {OperationListResult} - 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. + * + * {OperationListResult} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} 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. + */ + list(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + /** * @class * AdminKeys @@ -497,8 +559,9 @@ export interface Services { * 'default' or 'highDensity'. For all other SKUs, this value must be * 'default'. Possible values include: 'default', 'highDensity' * - * @param {object} service.sku The SKU of the Search Service, which determines - * price tier and capacity limits. + * @param {object} [service.sku] The SKU of the Search Service, which + * determines price tier and capacity limits. This property is required when + * creating a new Search Service. * * @param {string} [service.sku.name] The SKU of the Search service. Valid * values include: 'free': Shared service. 'basic': Dedicated service with up @@ -509,13 +572,16 @@ export interface Services { * you also set the hostingMode property to 'highDensity'). Possible values * include: 'free', 'basic', 'standard', 'standard2', 'standard3' * - * @param {string} service.location The geographic location of the resource. + * @param {string} [service.location] The geographic location of the resource. * This must be one of the supported and registered Azure Geo Regions (for - * example, West US, East US, Southeast Asia, and so forth). + * example, West US, East US, Southeast Asia, and so forth). This property is + * required when creating a new resource. * * @param {object} [service.tags] Tags to help categorize the resource in the * Azure portal. * + * @param {object} [service.identity] The identity of the resource. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.searchManagementRequestOptions] Additional @@ -572,8 +638,9 @@ export interface Services { * 'default' or 'highDensity'. For all other SKUs, this value must be * 'default'. Possible values include: 'default', 'highDensity' * - * @param {object} service.sku The SKU of the Search Service, which determines - * price tier and capacity limits. + * @param {object} [service.sku] The SKU of the Search Service, which + * determines price tier and capacity limits. This property is required when + * creating a new Search Service. * * @param {string} [service.sku.name] The SKU of the Search service. Valid * values include: 'free': Shared service. 'basic': Dedicated service with up @@ -584,13 +651,16 @@ export interface Services { * you also set the hostingMode property to 'highDensity'). Possible values * include: 'free', 'basic', 'standard', 'standard2', 'standard3' * - * @param {string} service.location The geographic location of the resource. + * @param {string} [service.location] The geographic location of the resource. * This must be one of the supported and registered Azure Geo Regions (for - * example, West US, East US, Southeast Asia, and so forth). + * example, West US, East US, Southeast Asia, and so forth). This property is + * required when creating a new resource. * * @param {object} [service.tags] Tags to help categorize the resource in the * Azure portal. * + * @param {object} [service.identity] The identity of the resource. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.searchManagementRequestOptions] Additional @@ -630,6 +700,167 @@ export interface Services { createOrUpdate(resourceGroupName: string, searchServiceName: string, service: models.SearchService, options: { searchManagementRequestOptions? : models.SearchManagementRequestOptions, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + /** + * Updates an existing Search service in the given resource group. + * + * @param {string} resourceGroupName The name of the resource group within the + * current subscription. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} searchServiceName The name of the Azure Search service to + * update. + * + * @param {object} service The definition of the Search service to update. + * + * @param {number} [service.replicaCount] The number of replicas in the Search + * service. If specified, it must be a value between 1 and 12 inclusive for + * standard SKUs or between 1 and 3 inclusive for basic SKU. + * + * @param {number} [service.partitionCount] The number of partitions in the + * Search service; if specified, it can be 1, 2, 3, 4, 6, or 12. Values greater + * than 1 are only valid for standard SKUs. For 'standard3' services with + * hostingMode set to 'highDensity', the allowed values are between 1 and 3. + * + * @param {string} [service.hostingMode] Applicable only for the standard3 SKU. + * You can set this property to enable up to 3 high density partitions that + * allow up to 1000 indexes, which is much higher than the maximum indexes + * allowed for any other SKU. For the standard3 SKU, the value is either + * 'default' or 'highDensity'. For all other SKUs, this value must be + * 'default'. Possible values include: 'default', 'highDensity' + * + * @param {object} [service.sku] The SKU of the Search Service, which + * determines price tier and capacity limits. This property is required when + * creating a new Search Service. + * + * @param {string} [service.sku.name] The SKU of the Search service. Valid + * values include: 'free': Shared service. 'basic': Dedicated service with up + * to 3 replicas. 'standard': Dedicated service with up to 12 partitions and 12 + * replicas. 'standard2': Similar to standard, but with more capacity per + * search unit. 'standard3': Offers maximum capacity per search unit with up to + * 12 partitions and 12 replicas (or up to 3 partitions with more indexes if + * you also set the hostingMode property to 'highDensity'). Possible values + * include: 'free', 'basic', 'standard', 'standard2', 'standard3' + * + * @param {string} [service.location] The geographic location of the resource. + * This must be one of the supported and registered Azure Geo Regions (for + * example, West US, East US, Southeast Asia, and so forth). This property is + * required when creating a new resource. + * + * @param {object} [service.tags] Tags to help categorize the resource in the + * Azure portal. + * + * @param {object} [service.identity] The identity of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.searchManagementRequestOptions] Additional + * parameters for the operation + * + * @param {uuid} [options.searchManagementRequestOptions.clientRequestId] A + * client-generated GUID value that identifies this request. If specified, this + * will be included in response information as a way to track the request. + * + * @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. + */ + updateWithHttpOperationResponse(resourceGroupName: string, searchServiceName: string, service: models.SearchService, options?: { searchManagementRequestOptions? : models.SearchManagementRequestOptions, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Updates an existing Search service in the given resource group. + * + * @param {string} resourceGroupName The name of the resource group within the + * current subscription. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} searchServiceName The name of the Azure Search service to + * update. + * + * @param {object} service The definition of the Search service to update. + * + * @param {number} [service.replicaCount] The number of replicas in the Search + * service. If specified, it must be a value between 1 and 12 inclusive for + * standard SKUs or between 1 and 3 inclusive for basic SKU. + * + * @param {number} [service.partitionCount] The number of partitions in the + * Search service; if specified, it can be 1, 2, 3, 4, 6, or 12. Values greater + * than 1 are only valid for standard SKUs. For 'standard3' services with + * hostingMode set to 'highDensity', the allowed values are between 1 and 3. + * + * @param {string} [service.hostingMode] Applicable only for the standard3 SKU. + * You can set this property to enable up to 3 high density partitions that + * allow up to 1000 indexes, which is much higher than the maximum indexes + * allowed for any other SKU. For the standard3 SKU, the value is either + * 'default' or 'highDensity'. For all other SKUs, this value must be + * 'default'. Possible values include: 'default', 'highDensity' + * + * @param {object} [service.sku] The SKU of the Search Service, which + * determines price tier and capacity limits. This property is required when + * creating a new Search Service. + * + * @param {string} [service.sku.name] The SKU of the Search service. Valid + * values include: 'free': Shared service. 'basic': Dedicated service with up + * to 3 replicas. 'standard': Dedicated service with up to 12 partitions and 12 + * replicas. 'standard2': Similar to standard, but with more capacity per + * search unit. 'standard3': Offers maximum capacity per search unit with up to + * 12 partitions and 12 replicas (or up to 3 partitions with more indexes if + * you also set the hostingMode property to 'highDensity'). Possible values + * include: 'free', 'basic', 'standard', 'standard2', 'standard3' + * + * @param {string} [service.location] The geographic location of the resource. + * This must be one of the supported and registered Azure Geo Regions (for + * example, West US, East US, Southeast Asia, and so forth). This property is + * required when creating a new resource. + * + * @param {object} [service.tags] Tags to help categorize the resource in the + * Azure portal. + * + * @param {object} [service.identity] The identity of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.searchManagementRequestOptions] Additional + * parameters for the operation + * + * @param {uuid} [options.searchManagementRequestOptions.clientRequestId] A + * client-generated GUID value that identifies this request. If specified, this + * will be included in response information as a way to track the request. + * + * @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 {SearchService} - 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. + * + * {SearchService} [result] - The deserialized result object if an error did not occur. + * See {@link SearchService} 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. + */ + update(resourceGroupName: string, searchServiceName: string, service: models.SearchService, options?: { searchManagementRequestOptions? : models.SearchManagementRequestOptions, customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, searchServiceName: string, service: models.SearchService, callback: ServiceCallback): void; + update(resourceGroupName: string, searchServiceName: string, service: models.SearchService, options: { searchManagementRequestOptions? : models.SearchManagementRequestOptions, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + /** * Gets the Search service with the given name in the given resource group. * @@ -979,8 +1210,9 @@ export interface Services { * 'default' or 'highDensity'. For all other SKUs, this value must be * 'default'. Possible values include: 'default', 'highDensity' * - * @param {object} service.sku The SKU of the Search Service, which determines - * price tier and capacity limits. + * @param {object} [service.sku] The SKU of the Search Service, which + * determines price tier and capacity limits. This property is required when + * creating a new Search Service. * * @param {string} [service.sku.name] The SKU of the Search service. Valid * values include: 'free': Shared service. 'basic': Dedicated service with up @@ -991,13 +1223,16 @@ export interface Services { * you also set the hostingMode property to 'highDensity'). Possible values * include: 'free', 'basic', 'standard', 'standard2', 'standard3' * - * @param {string} service.location The geographic location of the resource. + * @param {string} [service.location] The geographic location of the resource. * This must be one of the supported and registered Azure Geo Regions (for - * example, West US, East US, Southeast Asia, and so forth). + * example, West US, East US, Southeast Asia, and so forth). This property is + * required when creating a new resource. * * @param {object} [service.tags] Tags to help categorize the resource in the * Azure portal. * + * @param {object} [service.identity] The identity of the resource. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.searchManagementRequestOptions] Additional @@ -1054,8 +1289,9 @@ export interface Services { * 'default' or 'highDensity'. For all other SKUs, this value must be * 'default'. Possible values include: 'default', 'highDensity' * - * @param {object} service.sku The SKU of the Search Service, which determines - * price tier and capacity limits. + * @param {object} [service.sku] The SKU of the Search Service, which + * determines price tier and capacity limits. This property is required when + * creating a new Search Service. * * @param {string} [service.sku.name] The SKU of the Search service. Valid * values include: 'free': Shared service. 'basic': Dedicated service with up @@ -1066,13 +1302,16 @@ export interface Services { * you also set the hostingMode property to 'highDensity'). Possible values * include: 'free', 'basic', 'standard', 'standard2', 'standard3' * - * @param {string} service.location The geographic location of the resource. + * @param {string} [service.location] The geographic location of the resource. * This must be one of the supported and registered Azure Geo Regions (for - * example, West US, East US, Southeast Asia, and so forth). + * example, West US, East US, Southeast Asia, and so forth). This property is + * required when creating a new resource. * * @param {object} [service.tags] Tags to help categorize the resource in the * Azure portal. * + * @param {object} [service.identity] The identity of the resource. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.searchManagementRequestOptions] Additional diff --git a/lib/services/searchManagement/lib/operations/index.js b/lib/services/searchManagement/lib/operations/index.js index 6ab6da136d..e04a4f190c 100644 --- a/lib/services/searchManagement/lib/operations/index.js +++ b/lib/services/searchManagement/lib/operations/index.js @@ -14,6 +14,7 @@ 'use strict'; +exports.Operations = require('./operations'); exports.AdminKeys = require('./adminKeys'); exports.QueryKeys = require('./queryKeys'); exports.Services = require('./services'); diff --git a/lib/services/searchManagement/lib/operations/operations.js b/lib/services/searchManagement/lib/operations/operations.js new file mode 100644 index 0000000000..b2642589c4 --- /dev/null +++ b/lib/services/searchManagement/lib/operations/operations.js @@ -0,0 +1,240 @@ +/* + * 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 of the available REST API operations of the Microsoft.Search + * provider. + * + * @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 OperationListResult} 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 _list(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 (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.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('/') ? '' : '/') + 'providers/Microsoft.Search/operations'; + 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) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().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['OperationListResult']().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 Operations. */ +class Operations { + /** + * Create a Operations. + * @param {SearchManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + } + + /** + * Lists all of the available REST API operations of the Microsoft.Search + * provider. + * + * @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. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(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 of the available REST API operations of the Microsoft.Search + * provider. + * + * @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 {OperationListResult} - 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 OperationListResult} 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. + */ + list(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._list(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(options, optionalCallback); + } + } + +} + +module.exports = Operations; diff --git a/lib/services/searchManagement/lib/operations/services.js b/lib/services/searchManagement/lib/operations/services.js index 96ad258539..1267c1075c 100644 --- a/lib/services/searchManagement/lib/operations/services.js +++ b/lib/services/searchManagement/lib/operations/services.js @@ -51,8 +51,9 @@ const WebResource = msRest.WebResource; * 'default' or 'highDensity'. For all other SKUs, this value must be * 'default'. Possible values include: 'default', 'highDensity' * - * @param {object} service.sku The SKU of the Search Service, which determines - * price tier and capacity limits. + * @param {object} [service.sku] The SKU of the Search Service, which + * determines price tier and capacity limits. This property is required when + * creating a new Search Service. * * @param {string} [service.sku.name] The SKU of the Search service. Valid * values include: 'free': Shared service. 'basic': Dedicated service with up @@ -63,13 +64,16 @@ const WebResource = msRest.WebResource; * you also set the hostingMode property to 'highDensity'). Possible values * include: 'free', 'basic', 'standard', 'standard2', 'standard3' * - * @param {string} service.location The geographic location of the resource. + * @param {string} [service.location] The geographic location of the resource. * This must be one of the supported and registered Azure Geo Regions (for - * example, West US, East US, Southeast Asia, and so forth). + * example, West US, East US, Southeast Asia, and so forth). This property is + * required when creating a new resource. * * @param {object} [service.tags] Tags to help categorize the resource in the * Azure portal. * + * @param {object} [service.identity] The identity of the resource. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.searchManagementRequestOptions] Additional @@ -147,6 +151,235 @@ function _createOrUpdate(resourceGroupName, searchServiceName, service, options, }); } +/** + * Updates an existing Search service in the given resource group. + * + * @param {string} resourceGroupName The name of the resource group within the + * current subscription. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} searchServiceName The name of the Azure Search service to + * update. + * + * @param {object} service The definition of the Search service to update. + * + * @param {number} [service.replicaCount] The number of replicas in the Search + * service. If specified, it must be a value between 1 and 12 inclusive for + * standard SKUs or between 1 and 3 inclusive for basic SKU. + * + * @param {number} [service.partitionCount] The number of partitions in the + * Search service; if specified, it can be 1, 2, 3, 4, 6, or 12. Values greater + * than 1 are only valid for standard SKUs. For 'standard3' services with + * hostingMode set to 'highDensity', the allowed values are between 1 and 3. + * + * @param {string} [service.hostingMode] Applicable only for the standard3 SKU. + * You can set this property to enable up to 3 high density partitions that + * allow up to 1000 indexes, which is much higher than the maximum indexes + * allowed for any other SKU. For the standard3 SKU, the value is either + * 'default' or 'highDensity'. For all other SKUs, this value must be + * 'default'. Possible values include: 'default', 'highDensity' + * + * @param {object} [service.sku] The SKU of the Search Service, which + * determines price tier and capacity limits. This property is required when + * creating a new Search Service. + * + * @param {string} [service.sku.name] The SKU of the Search service. Valid + * values include: 'free': Shared service. 'basic': Dedicated service with up + * to 3 replicas. 'standard': Dedicated service with up to 12 partitions and 12 + * replicas. 'standard2': Similar to standard, but with more capacity per + * search unit. 'standard3': Offers maximum capacity per search unit with up to + * 12 partitions and 12 replicas (or up to 3 partitions with more indexes if + * you also set the hostingMode property to 'highDensity'). Possible values + * include: 'free', 'basic', 'standard', 'standard2', 'standard3' + * + * @param {string} [service.location] The geographic location of the resource. + * This must be one of the supported and registered Azure Geo Regions (for + * example, West US, East US, Southeast Asia, and so forth). This property is + * required when creating a new resource. + * + * @param {object} [service.tags] Tags to help categorize the resource in the + * Azure portal. + * + * @param {object} [service.identity] The identity of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.searchManagementRequestOptions] Additional + * parameters for the operation + * + * @param {uuid} [options.searchManagementRequestOptions.clientRequestId] A + * client-generated GUID value that identifies this request. If specified, this + * will be included in response information as a way to track the request. + * + * @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 SearchService} 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 _update(resourceGroupName, searchServiceName, service, 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 searchManagementRequestOptions = (options && options.searchManagementRequestOptions !== undefined) ? options.searchManagementRequestOptions : 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 (searchServiceName === null || searchServiceName === undefined || typeof searchServiceName.valueOf() !== 'string') { + throw new Error('searchServiceName cannot be null or undefined and it must be of type string.'); + } + if (service === null || service === undefined) { + throw new Error('service cannot be null or undefined.'); + } + 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); + } + let clientRequestId; + try { + if (searchManagementRequestOptions !== null && searchManagementRequestOptions !== undefined) + { + clientRequestId = searchManagementRequestOptions.clientRequestId; + if (clientRequestId !== null && clientRequestId !== undefined && !(typeof clientRequestId.valueOf() === 'string' && msRest.isValidUuid(clientRequestId))) { + throw new Error('clientRequestId must be of type string and must be a valid uuid.'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{searchServiceName}', encodeURIComponent(searchServiceName)); + 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 = 'PATCH'; + 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 (clientRequestId !== undefined && clientRequestId !== null) { + httpRequest.headers['x-ms-client-request-id'] = clientRequestId.toString(); + } + 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 (service !== null && service !== undefined) { + let requestModelMapper = new client.models['SearchService']().mapper(); + requestModel = client.serialize(requestModelMapper, service, 'service'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(service, 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) { + 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) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().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['SearchService']().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 the Search service with the given name in the given resource group. * @@ -859,8 +1092,9 @@ function _checkNameAvailability(name, options, callback) { * 'default' or 'highDensity'. For all other SKUs, this value must be * 'default'. Possible values include: 'default', 'highDensity' * - * @param {object} service.sku The SKU of the Search Service, which determines - * price tier and capacity limits. + * @param {object} [service.sku] The SKU of the Search Service, which + * determines price tier and capacity limits. This property is required when + * creating a new Search Service. * * @param {string} [service.sku.name] The SKU of the Search service. Valid * values include: 'free': Shared service. 'basic': Dedicated service with up @@ -871,13 +1105,16 @@ function _checkNameAvailability(name, options, callback) { * you also set the hostingMode property to 'highDensity'). Possible values * include: 'free', 'basic', 'standard', 'standard2', 'standard3' * - * @param {string} service.location The geographic location of the resource. + * @param {string} [service.location] The geographic location of the resource. * This must be one of the supported and registered Azure Geo Regions (for - * example, West US, East US, Southeast Asia, and so forth). + * example, West US, East US, Southeast Asia, and so forth). This property is + * required when creating a new resource. * * @param {object} [service.tags] Tags to help categorize the resource in the * Azure portal. * + * @param {object} [service.identity] The identity of the resource. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.searchManagementRequestOptions] Additional @@ -1082,6 +1319,7 @@ class Services { constructor(client) { this.client = client; this._createOrUpdate = _createOrUpdate; + this._update = _update; this._get = _get; this._deleteMethod = _deleteMethod; this._listByResourceGroup = _listByResourceGroup; @@ -1125,8 +1363,9 @@ class Services { * 'default' or 'highDensity'. For all other SKUs, this value must be * 'default'. Possible values include: 'default', 'highDensity' * - * @param {object} service.sku The SKU of the Search Service, which determines - * price tier and capacity limits. + * @param {object} [service.sku] The SKU of the Search Service, which + * determines price tier and capacity limits. This property is required when + * creating a new Search Service. * * @param {string} [service.sku.name] The SKU of the Search service. Valid * values include: 'free': Shared service. 'basic': Dedicated service with up @@ -1137,13 +1376,16 @@ class Services { * you also set the hostingMode property to 'highDensity'). Possible values * include: 'free', 'basic', 'standard', 'standard2', 'standard3' * - * @param {string} service.location The geographic location of the resource. + * @param {string} [service.location] The geographic location of the resource. * This must be one of the supported and registered Azure Geo Regions (for - * example, West US, East US, Southeast Asia, and so forth). + * example, West US, East US, Southeast Asia, and so forth). This property is + * required when creating a new resource. * * @param {object} [service.tags] Tags to help categorize the resource in the * Azure portal. * + * @param {object} [service.identity] The identity of the resource. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.searchManagementRequestOptions] Additional @@ -1212,8 +1454,9 @@ class Services { * 'default' or 'highDensity'. For all other SKUs, this value must be * 'default'. Possible values include: 'default', 'highDensity' * - * @param {object} service.sku The SKU of the Search Service, which determines - * price tier and capacity limits. + * @param {object} [service.sku] The SKU of the Search Service, which + * determines price tier and capacity limits. This property is required when + * creating a new Search Service. * * @param {string} [service.sku.name] The SKU of the Search service. Valid * values include: 'free': Shared service. 'basic': Dedicated service with up @@ -1224,13 +1467,16 @@ class Services { * you also set the hostingMode property to 'highDensity'). Possible values * include: 'free', 'basic', 'standard', 'standard2', 'standard3' * - * @param {string} service.location The geographic location of the resource. + * @param {string} [service.location] The geographic location of the resource. * This must be one of the supported and registered Azure Geo Regions (for - * example, West US, East US, Southeast Asia, and so forth). + * example, West US, East US, Southeast Asia, and so forth). This property is + * required when creating a new resource. * * @param {object} [service.tags] Tags to help categorize the resource in the * Azure portal. * + * @param {object} [service.identity] The identity of the resource. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.searchManagementRequestOptions] Additional @@ -1285,6 +1531,194 @@ class Services { } } + /** + * Updates an existing Search service in the given resource group. + * + * @param {string} resourceGroupName The name of the resource group within the + * current subscription. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} searchServiceName The name of the Azure Search service to + * update. + * + * @param {object} service The definition of the Search service to update. + * + * @param {number} [service.replicaCount] The number of replicas in the Search + * service. If specified, it must be a value between 1 and 12 inclusive for + * standard SKUs or between 1 and 3 inclusive for basic SKU. + * + * @param {number} [service.partitionCount] The number of partitions in the + * Search service; if specified, it can be 1, 2, 3, 4, 6, or 12. Values greater + * than 1 are only valid for standard SKUs. For 'standard3' services with + * hostingMode set to 'highDensity', the allowed values are between 1 and 3. + * + * @param {string} [service.hostingMode] Applicable only for the standard3 SKU. + * You can set this property to enable up to 3 high density partitions that + * allow up to 1000 indexes, which is much higher than the maximum indexes + * allowed for any other SKU. For the standard3 SKU, the value is either + * 'default' or 'highDensity'. For all other SKUs, this value must be + * 'default'. Possible values include: 'default', 'highDensity' + * + * @param {object} [service.sku] The SKU of the Search Service, which + * determines price tier and capacity limits. This property is required when + * creating a new Search Service. + * + * @param {string} [service.sku.name] The SKU of the Search service. Valid + * values include: 'free': Shared service. 'basic': Dedicated service with up + * to 3 replicas. 'standard': Dedicated service with up to 12 partitions and 12 + * replicas. 'standard2': Similar to standard, but with more capacity per + * search unit. 'standard3': Offers maximum capacity per search unit with up to + * 12 partitions and 12 replicas (or up to 3 partitions with more indexes if + * you also set the hostingMode property to 'highDensity'). Possible values + * include: 'free', 'basic', 'standard', 'standard2', 'standard3' + * + * @param {string} [service.location] The geographic location of the resource. + * This must be one of the supported and registered Azure Geo Regions (for + * example, West US, East US, Southeast Asia, and so forth). This property is + * required when creating a new resource. + * + * @param {object} [service.tags] Tags to help categorize the resource in the + * Azure portal. + * + * @param {object} [service.identity] The identity of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.searchManagementRequestOptions] Additional + * parameters for the operation + * + * @param {uuid} [options.searchManagementRequestOptions.clientRequestId] A + * client-generated GUID value that identifies this request. If specified, this + * will be included in response information as a way to track the request. + * + * @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. + */ + updateWithHttpOperationResponse(resourceGroupName, searchServiceName, service, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(resourceGroupName, searchServiceName, service, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Updates an existing Search service in the given resource group. + * + * @param {string} resourceGroupName The name of the resource group within the + * current subscription. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} searchServiceName The name of the Azure Search service to + * update. + * + * @param {object} service The definition of the Search service to update. + * + * @param {number} [service.replicaCount] The number of replicas in the Search + * service. If specified, it must be a value between 1 and 12 inclusive for + * standard SKUs or between 1 and 3 inclusive for basic SKU. + * + * @param {number} [service.partitionCount] The number of partitions in the + * Search service; if specified, it can be 1, 2, 3, 4, 6, or 12. Values greater + * than 1 are only valid for standard SKUs. For 'standard3' services with + * hostingMode set to 'highDensity', the allowed values are between 1 and 3. + * + * @param {string} [service.hostingMode] Applicable only for the standard3 SKU. + * You can set this property to enable up to 3 high density partitions that + * allow up to 1000 indexes, which is much higher than the maximum indexes + * allowed for any other SKU. For the standard3 SKU, the value is either + * 'default' or 'highDensity'. For all other SKUs, this value must be + * 'default'. Possible values include: 'default', 'highDensity' + * + * @param {object} [service.sku] The SKU of the Search Service, which + * determines price tier and capacity limits. This property is required when + * creating a new Search Service. + * + * @param {string} [service.sku.name] The SKU of the Search service. Valid + * values include: 'free': Shared service. 'basic': Dedicated service with up + * to 3 replicas. 'standard': Dedicated service with up to 12 partitions and 12 + * replicas. 'standard2': Similar to standard, but with more capacity per + * search unit. 'standard3': Offers maximum capacity per search unit with up to + * 12 partitions and 12 replicas (or up to 3 partitions with more indexes if + * you also set the hostingMode property to 'highDensity'). Possible values + * include: 'free', 'basic', 'standard', 'standard2', 'standard3' + * + * @param {string} [service.location] The geographic location of the resource. + * This must be one of the supported and registered Azure Geo Regions (for + * example, West US, East US, Southeast Asia, and so forth). This property is + * required when creating a new resource. + * + * @param {object} [service.tags] Tags to help categorize the resource in the + * Azure portal. + * + * @param {object} [service.identity] The identity of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.searchManagementRequestOptions] Additional + * parameters for the operation + * + * @param {uuid} [options.searchManagementRequestOptions.clientRequestId] A + * client-generated GUID value that identifies this request. If specified, this + * will be included in response information as a way to track the request. + * + * @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 {SearchService} - 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 SearchService} 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. + */ + update(resourceGroupName, searchServiceName, service, 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._update(resourceGroupName, searchServiceName, service, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(resourceGroupName, searchServiceName, service, options, optionalCallback); + } + } + /** * Gets the Search service with the given name in the given resource group. * @@ -1742,8 +2176,9 @@ class Services { * 'default' or 'highDensity'. For all other SKUs, this value must be * 'default'. Possible values include: 'default', 'highDensity' * - * @param {object} service.sku The SKU of the Search Service, which determines - * price tier and capacity limits. + * @param {object} [service.sku] The SKU of the Search Service, which + * determines price tier and capacity limits. This property is required when + * creating a new Search Service. * * @param {string} [service.sku.name] The SKU of the Search service. Valid * values include: 'free': Shared service. 'basic': Dedicated service with up @@ -1754,13 +2189,16 @@ class Services { * you also set the hostingMode property to 'highDensity'). Possible values * include: 'free', 'basic', 'standard', 'standard2', 'standard3' * - * @param {string} service.location The geographic location of the resource. + * @param {string} [service.location] The geographic location of the resource. * This must be one of the supported and registered Azure Geo Regions (for - * example, West US, East US, Southeast Asia, and so forth). + * example, West US, East US, Southeast Asia, and so forth). This property is + * required when creating a new resource. * * @param {object} [service.tags] Tags to help categorize the resource in the * Azure portal. * + * @param {object} [service.identity] The identity of the resource. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.searchManagementRequestOptions] Additional @@ -1829,8 +2267,9 @@ class Services { * 'default' or 'highDensity'. For all other SKUs, this value must be * 'default'. Possible values include: 'default', 'highDensity' * - * @param {object} service.sku The SKU of the Search Service, which determines - * price tier and capacity limits. + * @param {object} [service.sku] The SKU of the Search Service, which + * determines price tier and capacity limits. This property is required when + * creating a new Search Service. * * @param {string} [service.sku.name] The SKU of the Search service. Valid * values include: 'free': Shared service. 'basic': Dedicated service with up @@ -1841,13 +2280,16 @@ class Services { * you also set the hostingMode property to 'highDensity'). Possible values * include: 'free', 'basic', 'standard', 'standard2', 'standard3' * - * @param {string} service.location The geographic location of the resource. + * @param {string} [service.location] The geographic location of the resource. * This must be one of the supported and registered Azure Geo Regions (for - * example, West US, East US, Southeast Asia, and so forth). + * example, West US, East US, Southeast Asia, and so forth). This property is + * required when creating a new resource. * * @param {object} [service.tags] Tags to help categorize the resource in the * Azure portal. * + * @param {object} [service.identity] The identity of the resource. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.searchManagementRequestOptions] Additional diff --git a/lib/services/searchManagement/lib/searchManagementClient.d.ts b/lib/services/searchManagement/lib/searchManagementClient.d.ts index 73faa501eb..04051527d8 100644 --- a/lib/services/searchManagement/lib/searchManagementClient.d.ts +++ b/lib/services/searchManagement/lib/searchManagementClient.d.ts @@ -10,9 +10,10 @@ import { ServiceClientCredentials } from 'ms-rest'; import { AzureServiceClient, AzureServiceClientOptions } from 'ms-rest-azure'; +import * as models from "./models"; import * as operations from "./operations"; -declare class SearchManagementClient extends AzureServiceClient { +export default class SearchManagementClient extends AzureServiceClient { /** * Initializes a new instance of the SearchManagementClient class. * @constructor @@ -55,9 +56,10 @@ declare class SearchManagementClient extends AzureServiceClient { generateClientRequestId: boolean; // Operation groups + operations: operations.Operations; adminKeys: operations.AdminKeys; queryKeys: operations.QueryKeys; services: operations.Services; } -export = SearchManagementClient; +export { SearchManagementClient, models as SearchManagementModels }; diff --git a/lib/services/searchManagement/lib/searchManagementClient.js b/lib/services/searchManagement/lib/searchManagementClient.js index 96ff1bac58..8c147de773 100644 --- a/lib/services/searchManagement/lib/searchManagementClient.js +++ b/lib/services/searchManagement/lib/searchManagementClient.js @@ -72,6 +72,7 @@ class SearchManagementClient extends ServiceClient { if(options.generateClientRequestId !== null && options.generateClientRequestId !== undefined) { this.generateClientRequestId = options.generateClientRequestId; } + this.operations = new operations.Operations(this); this.adminKeys = new operations.AdminKeys(this); this.queryKeys = new operations.QueryKeys(this); this.services = new operations.Services(this); @@ -82,3 +83,6 @@ class SearchManagementClient extends ServiceClient { } module.exports = SearchManagementClient; +module.exports['default'] = SearchManagementClient; +module.exports.SearchManagementClient = SearchManagementClient; +module.exports.SearchManagementModels = models; diff --git a/lib/services/searchManagement/package.json b/lib/services/searchManagement/package.json index 53a731c9db..2ac61fb0a5 100644 --- a/lib/services/searchManagement/package.json +++ b/lib/services/searchManagement/package.json @@ -1,35 +1,25 @@ { "name": "azure-arm-search", "author": "Microsoft Corporation", - "contributors": [ - "Johnston, Bruce" - ], - "version": "1.1.0-preview", - "description": "Microsoft Azure Search Management Client Library for node", - "tags": [ - "azure", - "sdk" - ], + "description": "SearchManagementClient Library with typescript type definitions for node", + "version": "1.2.0-preview", + "dependencies": { + "ms-rest": "^2.3.3", + "ms-rest-azure": "^2.5.5" + }, "keywords": [ "node", "azure" ], + "license": "MIT", "main": "./lib/searchManagementClient.js", "types": "./lib/searchManagementClient.d.ts", - "license": "MIT", - "dependencies": { - "ms-rest": "^2.0.0", - "ms-rest-azure": "^2.0.0" - }, - "homepage": "http://github.com/Azure/azure-sdk-for-node", + "homepage": "http://github.com/azure/azure-sdk-for-node", "repository": { "type": "git", - "url": "git@github.com:Azure/azure-sdk-for-node.git" + "url": "https://github.com/azure/azure-sdk-for-node.git" }, "bugs": { "url": "http://github.com/Azure/azure-sdk-for-node/issues" - }, - "scripts": { - "test": "npm -s run-script jshint" } }