From 4b96410b28db136523225e3fd41b1d8deaae73d1 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Thu, 17 May 2018 14:08:41 -0700 Subject: [PATCH] [AutoPR sql/resource-manager] [DO NOT MERGE] Update jobs.json to latest generated swagger file as well as it's updated examples (#2764) * Generated from 17163e4990a1c6b6e1238bdcf78a15d4e0948130 Updated readme.md to include jobs.json for 2017-03-01-preview where necessary. Regenerated swagger to include job step and target executions, sku name and capacity support in agent createOrUpdate and get, as well as filter for top executions. Job examples were updated to reflect correct json request and response paramters for agent and target group. * Generated from 734f2e9aca7cddbc2e2a673f6c18e211fce7079b Updates to jobs.json as well as examples, this time keeping out readme.md until ready to publish sdk * Generated from 748aec06ad4c47bd52dee94d189d9c3d7f391bca Updated readme.md to include jobs.json. Fixed job step output examples * Generated from a74684ba52dc7e4ea8b566425d98629cfcf4d01e Fixing readme.md based on feedback. Ordered jobs.json alphabetically in it's 2017-03-01-preview regions as well as removed comment for difference between v3 and v2 --- .../models/databaseVulnerabilityAssessment.js | 107 + ...baseVulnerabilityAssessmentRuleBaseline.js | 88 + ...VulnerabilityAssessmentRuleBaselineItem.js | 60 + ...abaseVulnerabilityAssessmentScansExport.js | 83 + .../sqlManagement2/lib/models/index.d.ts | 568 ++ .../sqlManagement2/lib/models/index.js | 29 + lib/services/sqlManagement2/lib/models/job.js | 108 + .../sqlManagement2/lib/models/jobAgent.js | 129 + .../lib/models/jobAgentListResult.js | 69 + .../lib/models/jobAgentUpdate.js | 59 + .../lib/models/jobCredential.js | 89 + .../lib/models/jobCredentialListResult.js | 69 + .../sqlManagement2/lib/models/jobExecution.js | 202 + .../lib/models/jobExecutionListResult.js | 69 + .../lib/models/jobExecutionTarget.js | 72 + .../lib/models/jobListResult.js | 69 + .../sqlManagement2/lib/models/jobSchedule.js | 92 + .../sqlManagement2/lib/models/jobStep.js | 155 + .../lib/models/jobStepAction.js | 73 + .../lib/models/jobStepExecutionOptions.js | 94 + .../lib/models/jobStepListResult.js | 69 + .../lib/models/jobStepOutput.js | 114 + .../sqlManagement2/lib/models/jobTarget.js | 108 + .../lib/models/jobTargetGroup.js | 88 + .../lib/models/jobTargetGroupListResult.js | 69 + .../sqlManagement2/lib/models/jobVersion.js | 72 + .../lib/models/jobVersionListResult.js | 69 + ...ilityAssessmentRecurringScansProperties.js | 79 + .../vulnerabilityAssessmentScanError.js | 62 + .../vulnerabilityAssessmentScanRecord.js | 156 + ...erabilityAssessmentScanRecordListResult.js | 69 + ...aseVulnerabilityAssessmentRuleBaselines.js | 832 ++ .../databaseVulnerabilityAssessmentScans.js | 1448 +++ .../databaseVulnerabilityAssessments.js | 867 ++ .../sqlManagement2/lib/operations/index.d.ts | 8287 ++++++++++++++--- .../sqlManagement2/lib/operations/index.js | 12 + .../lib/operations/jobAgents.js | 2182 +++++ .../lib/operations/jobCredentials.js | 1292 +++ .../lib/operations/jobExecutions.js | 2625 ++++++ .../lib/operations/jobStepExecutions.js | 903 ++ .../sqlManagement2/lib/operations/jobSteps.js | 2271 +++++ .../lib/operations/jobTargetExecutions.js | 1521 +++ .../lib/operations/jobTargetGroups.js | 1286 +++ .../lib/operations/jobVersions.js | 763 ++ .../sqlManagement2/lib/operations/jobs.js | 1333 +++ .../lib/sqlManagementClient.d.ts | 12 + .../sqlManagement2/lib/sqlManagementClient.js | 12 + lib/services/sqlManagement2/package.json | 7 +- 48 files changed, 27524 insertions(+), 1368 deletions(-) create mode 100644 lib/services/sqlManagement2/lib/models/databaseVulnerabilityAssessment.js create mode 100644 lib/services/sqlManagement2/lib/models/databaseVulnerabilityAssessmentRuleBaseline.js create mode 100644 lib/services/sqlManagement2/lib/models/databaseVulnerabilityAssessmentRuleBaselineItem.js create mode 100644 lib/services/sqlManagement2/lib/models/databaseVulnerabilityAssessmentScansExport.js create mode 100644 lib/services/sqlManagement2/lib/models/job.js create mode 100644 lib/services/sqlManagement2/lib/models/jobAgent.js create mode 100644 lib/services/sqlManagement2/lib/models/jobAgentListResult.js create mode 100644 lib/services/sqlManagement2/lib/models/jobAgentUpdate.js create mode 100644 lib/services/sqlManagement2/lib/models/jobCredential.js create mode 100644 lib/services/sqlManagement2/lib/models/jobCredentialListResult.js create mode 100644 lib/services/sqlManagement2/lib/models/jobExecution.js create mode 100644 lib/services/sqlManagement2/lib/models/jobExecutionListResult.js create mode 100644 lib/services/sqlManagement2/lib/models/jobExecutionTarget.js create mode 100644 lib/services/sqlManagement2/lib/models/jobListResult.js create mode 100644 lib/services/sqlManagement2/lib/models/jobSchedule.js create mode 100644 lib/services/sqlManagement2/lib/models/jobStep.js create mode 100644 lib/services/sqlManagement2/lib/models/jobStepAction.js create mode 100644 lib/services/sqlManagement2/lib/models/jobStepExecutionOptions.js create mode 100644 lib/services/sqlManagement2/lib/models/jobStepListResult.js create mode 100644 lib/services/sqlManagement2/lib/models/jobStepOutput.js create mode 100644 lib/services/sqlManagement2/lib/models/jobTarget.js create mode 100644 lib/services/sqlManagement2/lib/models/jobTargetGroup.js create mode 100644 lib/services/sqlManagement2/lib/models/jobTargetGroupListResult.js create mode 100644 lib/services/sqlManagement2/lib/models/jobVersion.js create mode 100644 lib/services/sqlManagement2/lib/models/jobVersionListResult.js create mode 100644 lib/services/sqlManagement2/lib/models/vulnerabilityAssessmentRecurringScansProperties.js create mode 100644 lib/services/sqlManagement2/lib/models/vulnerabilityAssessmentScanError.js create mode 100644 lib/services/sqlManagement2/lib/models/vulnerabilityAssessmentScanRecord.js create mode 100644 lib/services/sqlManagement2/lib/models/vulnerabilityAssessmentScanRecordListResult.js create mode 100644 lib/services/sqlManagement2/lib/operations/databaseVulnerabilityAssessmentRuleBaselines.js create mode 100644 lib/services/sqlManagement2/lib/operations/databaseVulnerabilityAssessmentScans.js create mode 100644 lib/services/sqlManagement2/lib/operations/databaseVulnerabilityAssessments.js create mode 100644 lib/services/sqlManagement2/lib/operations/jobAgents.js create mode 100644 lib/services/sqlManagement2/lib/operations/jobCredentials.js create mode 100644 lib/services/sqlManagement2/lib/operations/jobExecutions.js create mode 100644 lib/services/sqlManagement2/lib/operations/jobStepExecutions.js create mode 100644 lib/services/sqlManagement2/lib/operations/jobSteps.js create mode 100644 lib/services/sqlManagement2/lib/operations/jobTargetExecutions.js create mode 100644 lib/services/sqlManagement2/lib/operations/jobTargetGroups.js create mode 100644 lib/services/sqlManagement2/lib/operations/jobVersions.js create mode 100644 lib/services/sqlManagement2/lib/operations/jobs.js diff --git a/lib/services/sqlManagement2/lib/models/databaseVulnerabilityAssessment.js b/lib/services/sqlManagement2/lib/models/databaseVulnerabilityAssessment.js new file mode 100644 index 0000000000..1d1f3e0836 --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/databaseVulnerabilityAssessment.js @@ -0,0 +1,107 @@ +/* + * 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'); + +/** + * A database vulnerability assessment. + * + * @extends models['ProxyResource'] + */ +class DatabaseVulnerabilityAssessment extends models['ProxyResource'] { + /** + * Create a DatabaseVulnerabilityAssessment. + * @member {string} [storageContainerPath] A blob storage container path to + * hold the scan results (e.g. + * https://myStorage.blob.core.windows.net/VaScans/). + * @member {string} [storageContainerSasKey] A shared access signature (SAS + * Key) that has write access to the blob container specified in + * 'storageContainerPath' parameter. + * @member {object} [recurringScans] The recurring scans settings + * @member {boolean} [recurringScans.isEnabled] Recurring scans state. + * @member {boolean} [recurringScans.emailSubscriptionAdmins] Specifies that + * the schedule scan notification will be is sent to the subscription + * administrators. + * @member {array} [recurringScans.emails] Specifies an array of e-mail + * addresses to which the scan notification is sent. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of DatabaseVulnerabilityAssessment + * + * @returns {object} metadata of DatabaseVulnerabilityAssessment + * + */ + mapper() { + return { + required: false, + serializedName: 'DatabaseVulnerabilityAssessment', + type: { + name: 'Composite', + className: 'DatabaseVulnerabilityAssessment', + 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' + } + }, + storageContainerPath: { + required: false, + serializedName: 'properties.storageContainerPath', + type: { + name: 'String' + } + }, + storageContainerSasKey: { + required: false, + serializedName: 'properties.storageContainerSasKey', + type: { + name: 'String' + } + }, + recurringScans: { + required: false, + serializedName: 'properties.recurringScans', + type: { + name: 'Composite', + className: 'VulnerabilityAssessmentRecurringScansProperties' + } + } + } + } + }; + } +} + +module.exports = DatabaseVulnerabilityAssessment; diff --git a/lib/services/sqlManagement2/lib/models/databaseVulnerabilityAssessmentRuleBaseline.js b/lib/services/sqlManagement2/lib/models/databaseVulnerabilityAssessmentRuleBaseline.js new file mode 100644 index 0000000000..7428613ad7 --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/databaseVulnerabilityAssessmentRuleBaseline.js @@ -0,0 +1,88 @@ +/* + * 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'); + +/** + * A database vulnerability assessment rule baseline. + * + * @extends models['ProxyResource'] + */ +class DatabaseVulnerabilityAssessmentRuleBaseline extends models['ProxyResource'] { + /** + * Create a DatabaseVulnerabilityAssessmentRuleBaseline. + * @member {array} baselineResults The rule baseline result + */ + constructor() { + super(); + } + + /** + * Defines the metadata of DatabaseVulnerabilityAssessmentRuleBaseline + * + * @returns {object} metadata of DatabaseVulnerabilityAssessmentRuleBaseline + * + */ + mapper() { + return { + required: false, + serializedName: 'DatabaseVulnerabilityAssessmentRuleBaseline', + type: { + name: 'Composite', + className: 'DatabaseVulnerabilityAssessmentRuleBaseline', + 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' + } + }, + baselineResults: { + required: true, + serializedName: 'properties.baselineResults', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'DatabaseVulnerabilityAssessmentRuleBaselineItemElementType', + type: { + name: 'Composite', + className: 'DatabaseVulnerabilityAssessmentRuleBaselineItem' + } + } + } + } + } + } + }; + } +} + +module.exports = DatabaseVulnerabilityAssessmentRuleBaseline; diff --git a/lib/services/sqlManagement2/lib/models/databaseVulnerabilityAssessmentRuleBaselineItem.js b/lib/services/sqlManagement2/lib/models/databaseVulnerabilityAssessmentRuleBaselineItem.js new file mode 100644 index 0000000000..cec3924952 --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/databaseVulnerabilityAssessmentRuleBaselineItem.js @@ -0,0 +1,60 @@ +/* + * 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'; + +/** + * Properties for an Azure SQL Database Vulnerability Assessment rule + * baseline's result. + * + */ +class DatabaseVulnerabilityAssessmentRuleBaselineItem { + /** + * Create a DatabaseVulnerabilityAssessmentRuleBaselineItem. + * @member {array} result The rule baseline result + */ + constructor() { + } + + /** + * Defines the metadata of DatabaseVulnerabilityAssessmentRuleBaselineItem + * + * @returns {object} metadata of DatabaseVulnerabilityAssessmentRuleBaselineItem + * + */ + mapper() { + return { + required: false, + serializedName: 'DatabaseVulnerabilityAssessmentRuleBaselineItem', + type: { + name: 'Composite', + className: 'DatabaseVulnerabilityAssessmentRuleBaselineItem', + modelProperties: { + result: { + required: true, + serializedName: 'result', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = DatabaseVulnerabilityAssessmentRuleBaselineItem; diff --git a/lib/services/sqlManagement2/lib/models/databaseVulnerabilityAssessmentScansExport.js b/lib/services/sqlManagement2/lib/models/databaseVulnerabilityAssessmentScansExport.js new file mode 100644 index 0000000000..0a46456038 --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/databaseVulnerabilityAssessmentScansExport.js @@ -0,0 +1,83 @@ +/* + * 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'); + +/** + * A database Vulnerability Assessment scan export resource. + * + * @extends models['ProxyResource'] + */ +class DatabaseVulnerabilityAssessmentScansExport extends models['ProxyResource'] { + /** + * Create a DatabaseVulnerabilityAssessmentScansExport. + * @member {string} [exportedReportLocation] Location of the exported report + * (e.g. + * https://myStorage.blob.core.windows.net/VaScans/scans/serverName/databaseName/scan_scanId.xlsx). + */ + constructor() { + super(); + } + + /** + * Defines the metadata of DatabaseVulnerabilityAssessmentScansExport + * + * @returns {object} metadata of DatabaseVulnerabilityAssessmentScansExport + * + */ + mapper() { + return { + required: false, + serializedName: 'DatabaseVulnerabilityAssessmentScansExport', + type: { + name: 'Composite', + className: 'DatabaseVulnerabilityAssessmentScansExport', + 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' + } + }, + exportedReportLocation: { + required: false, + readOnly: true, + serializedName: 'properties.exportedReportLocation', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = DatabaseVulnerabilityAssessmentScansExport; diff --git a/lib/services/sqlManagement2/lib/models/index.d.ts b/lib/services/sqlManagement2/lib/models/index.d.ts index 363749ddaa..1f8c2b8106 100644 --- a/lib/services/sqlManagement2/lib/models/index.d.ts +++ b/lib/services/sqlManagement2/lib/models/index.d.ts @@ -1878,6 +1878,420 @@ export interface VirtualNetworkRule extends ProxyResource { readonly state?: string; } +/** + * @class + * Initializes a new instance of the DatabaseVulnerabilityAssessmentRuleBaselineItem class. + * @constructor + * Properties for an Azure SQL Database Vulnerability Assessment rule + * baseline's result. + * + * @member {array} result The rule baseline result + */ +export interface DatabaseVulnerabilityAssessmentRuleBaselineItem { + result: string[]; +} + +/** + * @class + * Initializes a new instance of the DatabaseVulnerabilityAssessmentRuleBaseline class. + * @constructor + * A database vulnerability assessment rule baseline. + * + * @member {array} baselineResults The rule baseline result + */ +export interface DatabaseVulnerabilityAssessmentRuleBaseline extends ProxyResource { + baselineResults: DatabaseVulnerabilityAssessmentRuleBaselineItem[]; +} + +/** + * @class + * Initializes a new instance of the VulnerabilityAssessmentRecurringScansProperties class. + * @constructor + * Properties of a Vulnerability Assessment recurring scans. + * + * @member {boolean} [isEnabled] Recurring scans state. + * @member {boolean} [emailSubscriptionAdmins] Specifies that the schedule scan + * notification will be is sent to the subscription administrators. Default + * value: true . + * @member {array} [emails] Specifies an array of e-mail addresses to which the + * scan notification is sent. + */ +export interface VulnerabilityAssessmentRecurringScansProperties { + isEnabled?: boolean; + emailSubscriptionAdmins?: boolean; + emails?: string[]; +} + +/** + * @class + * Initializes a new instance of the DatabaseVulnerabilityAssessment class. + * @constructor + * A database vulnerability assessment. + * + * @member {string} [storageContainerPath] A blob storage container path to + * hold the scan results (e.g. + * https://myStorage.blob.core.windows.net/VaScans/). + * @member {string} [storageContainerSasKey] A shared access signature (SAS + * Key) that has write access to the blob container specified in + * 'storageContainerPath' parameter. + * @member {object} [recurringScans] The recurring scans settings + * @member {boolean} [recurringScans.isEnabled] Recurring scans state. + * @member {boolean} [recurringScans.emailSubscriptionAdmins] Specifies that + * the schedule scan notification will be is sent to the subscription + * administrators. + * @member {array} [recurringScans.emails] Specifies an array of e-mail + * addresses to which the scan notification is sent. + */ +export interface DatabaseVulnerabilityAssessment extends ProxyResource { + storageContainerPath?: string; + storageContainerSasKey?: string; + recurringScans?: VulnerabilityAssessmentRecurringScansProperties; +} + +/** + * @class + * Initializes a new instance of the JobAgent class. + * @constructor + * An Azure SQL job agent. + * + * @member {object} [sku] The name and tier of the SKU. + * @member {string} [sku.name] The name of the SKU, typically, a letter + + * Number code, e.g. P3. + * @member {string} [sku.tier] The tier of the particular SKU, e.g. Basic, + * Premium. + * @member {string} [sku.size] Size of the particular SKU + * @member {string} [sku.family] If the service has different generations of + * hardware, for the same SKU, then that can be captured here. + * @member {number} [sku.capacity] Capacity of the particular SKU. + * @member {string} databaseId Resource ID of the database to store job + * metadata in. + * @member {string} [state] The state of the job agent. Possible values + * include: 'Creating', 'Ready', 'Updating', 'Deleting', 'Disabled' + */ +export interface JobAgent extends TrackedResource { + sku?: Sku; + databaseId: string; + readonly state?: string; +} + +/** + * @class + * Initializes a new instance of the JobAgentUpdate class. + * @constructor + * An update to an Azure SQL job agent. + * + * @member {object} [tags] Resource tags. + */ +export interface JobAgentUpdate { + tags?: { [propertyName: string]: string }; +} + +/** + * @class + * Initializes a new instance of the JobCredential class. + * @constructor + * A stored credential that can be used by a job to connect to target + * databases. + * + * @member {string} username The credential user name. + * @member {string} password The credential password. + */ +export interface JobCredential extends ProxyResource { + username: string; + password: string; +} + +/** + * @class + * Initializes a new instance of the JobExecutionTarget class. + * @constructor + * The target that a job execution is executed on. + * + * @member {string} [type] The type of the target. Possible values include: + * 'TargetGroup', 'SqlDatabase', 'SqlElasticPool', 'SqlShardMap', 'SqlServer' + * @member {string} [serverName] The server name. + * @member {string} [databaseName] The database name. + */ +export interface JobExecutionTarget { + readonly type?: string; + readonly serverName?: string; + readonly databaseName?: string; +} + +/** + * @class + * Initializes a new instance of the JobExecution class. + * @constructor + * An execution of a job + * + * @member {number} [jobVersion] The job version number. + * @member {string} [stepName] The job step name. + * @member {number} [stepId] The job step id. + * @member {uuid} [jobExecutionId] The unique identifier of the job execution. + * @member {string} [lifecycle] The detailed state of the job execution. + * Possible values include: 'Created', 'InProgress', + * 'WaitingForChildJobExecutions', 'WaitingForRetry', 'Succeeded', + * 'SucceededWithSkipped', 'Failed', 'TimedOut', 'Canceled', 'Skipped' + * @member {string} [provisioningState] The ARM provisioning state of the job + * execution. Possible values include: 'Created', 'InProgress', 'Succeeded', + * 'Failed', 'Canceled' + * @member {date} [createTime] The time that the job execution was created. + * @member {date} [startTime] The time that the job execution started. + * @member {date} [endTime] The time that the job execution completed. + * @member {number} [currentAttempts] Number of times the job execution has + * been attempted. + * @member {date} [currentAttemptStartTime] Start time of the current attempt. + * @member {string} [lastMessage] The last status or error message. + * @member {object} [target] The target that this execution is executed on. + * @member {string} [target.type] The type of the target. Possible values + * include: 'TargetGroup', 'SqlDatabase', 'SqlElasticPool', 'SqlShardMap', + * 'SqlServer' + * @member {string} [target.serverName] The server name. + * @member {string} [target.databaseName] The database name. + */ +export interface JobExecution extends ProxyResource { + readonly jobVersion?: number; + readonly stepName?: string; + readonly stepId?: number; + readonly jobExecutionId?: string; + readonly lifecycle?: string; + readonly provisioningState?: string; + readonly createTime?: Date; + readonly startTime?: Date; + readonly endTime?: Date; + currentAttempts?: number; + readonly currentAttemptStartTime?: Date; + readonly lastMessage?: string; + readonly target?: JobExecutionTarget; +} + +/** + * @class + * Initializes a new instance of the JobSchedule class. + * @constructor + * Scheduling properties of a job. + * + * @member {date} [startTime] Schedule start time. Default value: new + * Date('0001-01-01T00:00:00Z') . + * @member {date} [endTime] Schedule end time. Default value: new + * Date('9999-12-31T11:59:59Z') . + * @member {string} [type] Schedule interval type. Possible values include: + * 'Once', 'Recurring'. Default value: 'Once' . + * @member {boolean} [enabled] Whether or not the schedule is enabled. + * @member {string} [interval] Value of the schedule's recurring interval, if + * the scheduletype is recurring. ISO8601 duration format. + */ +export interface JobSchedule { + startTime?: Date; + endTime?: Date; + type?: string; + enabled?: boolean; + interval?: string; +} + +/** + * @class + * Initializes a new instance of the Job class. + * @constructor + * A job. + * + * @member {string} [description] User-defined description of the job. Default + * value: '' . + * @member {number} [version] The job version number. + * @member {object} [schedule] Schedule properties of the job. + * @member {date} [schedule.startTime] Schedule start time. + * @member {date} [schedule.endTime] Schedule end time. + * @member {string} [schedule.type] Schedule interval type. Possible values + * include: 'Once', 'Recurring' + * @member {boolean} [schedule.enabled] Whether or not the schedule is enabled. + * @member {string} [schedule.interval] Value of the schedule's recurring + * interval, if the scheduletype is recurring. ISO8601 duration format. + */ +export interface Job extends ProxyResource { + description?: string; + readonly version?: number; + schedule?: JobSchedule; +} + +/** + * @class + * Initializes a new instance of the JobStepAction class. + * @constructor + * The action to be executed by a job step. + * + * @member {string} [type] Type of action being executed by the job step. + * Possible values include: 'TSql'. Default value: 'TSql' . + * @member {string} [source] The source of the action to execute. Possible + * values include: 'Inline'. Default value: 'Inline' . + * @member {string} value The action value, for example the text of the T-SQL + * script to execute. + */ +export interface JobStepAction { + type?: string; + source?: string; + value: string; +} + +/** + * @class + * Initializes a new instance of the JobStepOutput class. + * @constructor + * The output configuration of a job step. + * + * @member {string} [type] The output destination type. Possible values + * include: 'SqlDatabase'. Default value: 'SqlDatabase' . + * @member {uuid} [subscriptionId] The output destination subscription id. + * @member {string} [resourceGroupName] The output destination resource group. + * @member {string} serverName The output destination server name. + * @member {string} databaseName The output destination database. + * @member {string} [schemaName] The output destination schema. Default value: + * 'dbo' . + * @member {string} tableName The output destination table. + * @member {string} credential The resource ID of the credential to use to + * connect to the output destination. + */ +export interface JobStepOutput { + type?: string; + subscriptionId?: string; + resourceGroupName?: string; + serverName: string; + databaseName: string; + schemaName?: string; + tableName: string; + credential: string; +} + +/** + * @class + * Initializes a new instance of the JobStepExecutionOptions class. + * @constructor + * The execution options of a job step. + * + * @member {number} [timeoutSeconds] Execution timeout for the job step. + * Default value: 43200 . + * @member {number} [retryAttempts] Maximum number of times the job step will + * be reattempted if the first attempt fails. Default value: 10 . + * @member {number} [initialRetryIntervalSeconds] Initial delay between retries + * for job step execution. Default value: 1 . + * @member {number} [maximumRetryIntervalSeconds] The maximum amount of time to + * wait between retries for job step execution. Default value: 120 . + * @member {number} [retryIntervalBackoffMultiplier] The backoff multiplier for + * the time between retries. Default value: 2 . + */ +export interface JobStepExecutionOptions { + timeoutSeconds?: number; + retryAttempts?: number; + initialRetryIntervalSeconds?: number; + maximumRetryIntervalSeconds?: number; + retryIntervalBackoffMultiplier?: number; +} + +/** + * @class + * Initializes a new instance of the JobStep class. + * @constructor + * A job step. + * + * @member {number} [stepId] The job step's index within the job. If not + * specified when creating the job step, it will be created as the last step. + * If not specified when updating the job step, the step id is not modified. + * @member {string} targetGroup The resource ID of the target group that the + * job step will be executed on. + * @member {string} credential The resource ID of the job credential that will + * be used to connect to the targets. + * @member {object} action The action payload of the job step. + * @member {string} [action.type] Type of action being executed by the job + * step. Possible values include: 'TSql' + * @member {string} [action.source] The source of the action to execute. + * Possible values include: 'Inline' + * @member {string} [action.value] The action value, for example the text of + * the T-SQL script to execute. + * @member {object} [output] Output destination properties of the job step. + * @member {string} [output.type] The output destination type. Possible values + * include: 'SqlDatabase' + * @member {uuid} [output.subscriptionId] The output destination subscription + * id. + * @member {string} [output.resourceGroupName] The output destination resource + * group. + * @member {string} [output.serverName] The output destination server name. + * @member {string} [output.databaseName] The output destination database. + * @member {string} [output.schemaName] The output destination schema. + * @member {string} [output.tableName] The output destination table. + * @member {string} [output.credential] The resource ID of the credential to + * use to connect to the output destination. + * @member {object} [executionOptions] Execution options for the job step. + * @member {number} [executionOptions.timeoutSeconds] Execution timeout for the + * job step. + * @member {number} [executionOptions.retryAttempts] Maximum number of times + * the job step will be reattempted if the first attempt fails. + * @member {number} [executionOptions.initialRetryIntervalSeconds] Initial + * delay between retries for job step execution. + * @member {number} [executionOptions.maximumRetryIntervalSeconds] The maximum + * amount of time to wait between retries for job step execution. + * @member {number} [executionOptions.retryIntervalBackoffMultiplier] The + * backoff multiplier for the time between retries. + */ +export interface JobStep extends ProxyResource { + stepId?: number; + targetGroup: string; + credential: string; + action: JobStepAction; + output?: JobStepOutput; + executionOptions?: JobStepExecutionOptions; +} + +/** + * @class + * Initializes a new instance of the JobTarget class. + * @constructor + * A job target, for example a specific database or a container of databases + * that is evaluated during job execution. + * + * @member {string} [membershipType] Whether the target is included or excluded + * from the group. Possible values include: 'Include', 'Exclude'. Default + * value: 'Include' . + * @member {string} type The target type. Possible values include: + * 'TargetGroup', 'SqlDatabase', 'SqlElasticPool', 'SqlShardMap', 'SqlServer' + * @member {string} [serverName] The target server name. + * @member {string} [databaseName] The target database name. + * @member {string} [elasticPoolName] The target elastic pool name. + * @member {string} [shardMapName] The target shard map. + * @member {string} [refreshCredential] The resource ID of the credential that + * is used during job execution to connect to the target and determine the list + * of databases inside the target. + */ +export interface JobTarget { + membershipType?: string; + type: string; + serverName?: string; + databaseName?: string; + elasticPoolName?: string; + shardMapName?: string; + refreshCredential?: string; +} + +/** + * @class + * Initializes a new instance of the JobTargetGroup class. + * @constructor + * A group of job targets. + * + * @member {array} members Members of the target group. + */ +export interface JobTargetGroup extends ProxyResource { + members: JobTarget[]; +} + +/** + * @class + * Initializes a new instance of the JobVersion class. + * @constructor + * A job version. + * + */ +export interface JobVersion extends ProxyResource { +} + /** * @class * Initializes a new instance of the LongTermRetentionBackup class. @@ -3066,6 +3480,64 @@ export interface ElasticPoolUpdate { tags?: { [propertyName: string]: string }; } +/** + * @class + * Initializes a new instance of the VulnerabilityAssessmentScanError class. + * @constructor + * Properties of a vulnerability assessment scan error. + * + * @member {string} [code] The error code. + * @member {string} [message] The error message. + */ +export interface VulnerabilityAssessmentScanError { + readonly code?: string; + readonly message?: string; +} + +/** + * @class + * Initializes a new instance of the VulnerabilityAssessmentScanRecord class. + * @constructor + * A vulnerability assessment scan record. + * + * @member {string} [scanId] The scan ID. + * @member {string} [triggerType] The scan trigger type. Possible values + * include: 'OnDemand', 'Recurring' + * @member {string} [state] The scan status. Possible values include: 'Passed', + * 'Failed', 'FailedToRun', 'InProgress' + * @member {date} [startTime] The scan start time (UTC). + * @member {date} [endTime] The scan end time (UTC). + * @member {array} [errors] The scan errors. + * @member {string} [storageContainerPath] The scan results storage container + * path. + * @member {number} [numberOfFailedSecurityChecks] The number of failed + * security checks. + */ +export interface VulnerabilityAssessmentScanRecord extends ProxyResource { + readonly scanId?: string; + readonly triggerType?: string; + readonly state?: string; + readonly startTime?: Date; + readonly endTime?: Date; + readonly errors?: VulnerabilityAssessmentScanError[]; + readonly storageContainerPath?: string; + readonly numberOfFailedSecurityChecks?: number; +} + +/** + * @class + * Initializes a new instance of the DatabaseVulnerabilityAssessmentScansExport class. + * @constructor + * A database Vulnerability Assessment scan export resource. + * + * @member {string} [exportedReportLocation] Location of the exported report + * (e.g. + * https://myStorage.blob.core.windows.net/VaScans/scans/serverName/databaseName/scan_scanId.xlsx). + */ +export interface DatabaseVulnerabilityAssessmentScansExport extends ProxyResource { + readonly exportedReportLocation?: string; +} + /** * @class * Initializes a new instance of the InstanceFailoverGroupReadWriteEndpoint class. @@ -3578,6 +4050,90 @@ export interface VirtualNetworkRuleListResult extends Array readonly nextLink?: string; } +/** + * @class + * Initializes a new instance of the JobAgentListResult class. + * @constructor + * A list of Azure SQL job agents. + * + * @member {string} [nextLink] Link to retrieve next page of results. + */ +export interface JobAgentListResult extends Array { + readonly nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the JobCredentialListResult class. + * @constructor + * A list of job credentials. + * + * @member {string} [nextLink] Link to retrieve next page of results. + */ +export interface JobCredentialListResult extends Array { + readonly nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the JobExecutionListResult class. + * @constructor + * A list of job executions. + * + * @member {string} [nextLink] Link to retrieve next page of results. + */ +export interface JobExecutionListResult extends Array { + readonly nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the JobListResult class. + * @constructor + * A list of jobs. + * + * @member {string} [nextLink] Link to retrieve next page of results. + */ +export interface JobListResult extends Array { + readonly nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the JobStepListResult class. + * @constructor + * A list of job steps. + * + * @member {string} [nextLink] Link to retrieve next page of results. + */ +export interface JobStepListResult extends Array { + readonly nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the JobTargetGroupListResult class. + * @constructor + * A list of target groups. + * + * @member {string} [nextLink] Link to retrieve next page of results. + */ +export interface JobTargetGroupListResult extends Array { + readonly nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the JobVersionListResult class. + * @constructor + * A list of job versions. + * + * @member {string} [nextLink] Link to retrieve next page of results. + */ +export interface JobVersionListResult extends Array { + readonly nextLink?: string; +} + /** * @class * Initializes a new instance of the LongTermRetentionBackupListResult class. @@ -3650,6 +4206,18 @@ export interface ElasticPoolOperationListResult extends Array { + readonly nextLink?: string; +} + /** * @class * Initializes a new instance of the InstanceFailoverGroupListResult class. diff --git a/lib/services/sqlManagement2/lib/models/index.js b/lib/services/sqlManagement2/lib/models/index.js index 86aa7c826a..ff9156e2cd 100644 --- a/lib/services/sqlManagement2/lib/models/index.js +++ b/lib/services/sqlManagement2/lib/models/index.js @@ -89,6 +89,24 @@ exports.SyncGroup = require('./syncGroup'); exports.SyncMember = require('./syncMember'); exports.SubscriptionUsage = require('./subscriptionUsage'); exports.VirtualNetworkRule = require('./virtualNetworkRule'); +exports.DatabaseVulnerabilityAssessmentRuleBaselineItem = require('./databaseVulnerabilityAssessmentRuleBaselineItem'); +exports.DatabaseVulnerabilityAssessmentRuleBaseline = require('./databaseVulnerabilityAssessmentRuleBaseline'); +exports.VulnerabilityAssessmentRecurringScansProperties = require('./vulnerabilityAssessmentRecurringScansProperties'); +exports.DatabaseVulnerabilityAssessment = require('./databaseVulnerabilityAssessment'); +exports.JobAgent = require('./jobAgent'); +exports.JobAgentUpdate = require('./jobAgentUpdate'); +exports.JobCredential = require('./jobCredential'); +exports.JobExecutionTarget = require('./jobExecutionTarget'); +exports.JobExecution = require('./jobExecution'); +exports.JobSchedule = require('./jobSchedule'); +exports.Job = require('./job'); +exports.JobStepAction = require('./jobStepAction'); +exports.JobStepOutput = require('./jobStepOutput'); +exports.JobStepExecutionOptions = require('./jobStepExecutionOptions'); +exports.JobStep = require('./jobStep'); +exports.JobTarget = require('./jobTarget'); +exports.JobTargetGroup = require('./jobTargetGroup'); +exports.JobVersion = require('./jobVersion'); exports.LongTermRetentionBackup = require('./longTermRetentionBackup'); exports.BackupLongTermRetentionPolicy = require('./backupLongTermRetentionPolicy'); exports.CompleteDatabaseRestoreDefinition = require('./completeDatabaseRestoreDefinition'); @@ -125,6 +143,9 @@ exports.ResourceMoveDefinition = require('./resourceMoveDefinition'); exports.ElasticPoolPerDatabaseSettings = require('./elasticPoolPerDatabaseSettings'); exports.ElasticPool = require('./elasticPool'); exports.ElasticPoolUpdate = require('./elasticPoolUpdate'); +exports.VulnerabilityAssessmentScanError = require('./vulnerabilityAssessmentScanError'); +exports.VulnerabilityAssessmentScanRecord = require('./vulnerabilityAssessmentScanRecord'); +exports.DatabaseVulnerabilityAssessmentScansExport = require('./databaseVulnerabilityAssessmentScansExport'); exports.InstanceFailoverGroupReadWriteEndpoint = require('./instanceFailoverGroupReadWriteEndpoint'); exports.InstanceFailoverGroupReadOnlyEndpoint = require('./instanceFailoverGroupReadOnlyEndpoint'); exports.PartnerRegionInfo = require('./partnerRegionInfo'); @@ -167,10 +188,18 @@ exports.SyncGroupListResult = require('./syncGroupListResult'); exports.SyncMemberListResult = require('./syncMemberListResult'); exports.SubscriptionUsageListResult = require('./subscriptionUsageListResult'); exports.VirtualNetworkRuleListResult = require('./virtualNetworkRuleListResult'); +exports.JobAgentListResult = require('./jobAgentListResult'); +exports.JobCredentialListResult = require('./jobCredentialListResult'); +exports.JobExecutionListResult = require('./jobExecutionListResult'); +exports.JobListResult = require('./jobListResult'); +exports.JobStepListResult = require('./jobStepListResult'); +exports.JobTargetGroupListResult = require('./jobTargetGroupListResult'); +exports.JobVersionListResult = require('./jobVersionListResult'); exports.LongTermRetentionBackupListResult = require('./longTermRetentionBackupListResult'); exports.ManagedDatabaseListResult = require('./managedDatabaseListResult'); exports.ServerDnsAliasListResult = require('./serverDnsAliasListResult'); exports.RestorePointListResult = require('./restorePointListResult'); exports.DatabaseOperationListResult = require('./databaseOperationListResult'); exports.ElasticPoolOperationListResult = require('./elasticPoolOperationListResult'); +exports.VulnerabilityAssessmentScanRecordListResult = require('./vulnerabilityAssessmentScanRecordListResult'); exports.InstanceFailoverGroupListResult = require('./instanceFailoverGroupListResult'); diff --git a/lib/services/sqlManagement2/lib/models/job.js b/lib/services/sqlManagement2/lib/models/job.js new file mode 100644 index 0000000000..a9e7856fc5 --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/job.js @@ -0,0 +1,108 @@ +/* + * 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'); + +/** + * A job. + * + * @extends models['ProxyResource'] + */ +class Job extends models['ProxyResource'] { + /** + * Create a Job. + * @member {string} [description] User-defined description of the job. + * Default value: '' . + * @member {number} [version] The job version number. + * @member {object} [schedule] Schedule properties of the job. + * @member {date} [schedule.startTime] Schedule start time. + * @member {date} [schedule.endTime] Schedule end time. + * @member {string} [schedule.type] Schedule interval type. Possible values + * include: 'Once', 'Recurring' + * @member {boolean} [schedule.enabled] Whether or not the schedule is + * enabled. + * @member {string} [schedule.interval] Value of the schedule's recurring + * interval, if the scheduletype is recurring. ISO8601 duration format. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Job + * + * @returns {object} metadata of Job + * + */ + mapper() { + return { + required: false, + serializedName: 'Job', + type: { + name: 'Composite', + className: 'Job', + 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' + } + }, + description: { + required: false, + serializedName: 'properties.description', + defaultValue: '', + type: { + name: 'String' + } + }, + version: { + required: false, + readOnly: true, + serializedName: 'properties.version', + type: { + name: 'Number' + } + }, + schedule: { + required: false, + serializedName: 'properties.schedule', + type: { + name: 'Composite', + className: 'JobSchedule' + } + } + } + } + }; + } +} + +module.exports = Job; diff --git a/lib/services/sqlManagement2/lib/models/jobAgent.js b/lib/services/sqlManagement2/lib/models/jobAgent.js new file mode 100644 index 0000000000..ad3639e243 --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/jobAgent.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'); + +/** + * An Azure SQL job agent. + * + * @extends models['TrackedResource'] + */ +class JobAgent extends models['TrackedResource'] { + /** + * Create a JobAgent. + * @member {object} [sku] The name and tier of the SKU. + * @member {string} [sku.name] The name of the SKU, typically, a letter + + * Number code, e.g. P3. + * @member {string} [sku.tier] The tier of the particular SKU, e.g. Basic, + * Premium. + * @member {string} [sku.size] Size of the particular SKU + * @member {string} [sku.family] If the service has different generations of + * hardware, for the same SKU, then that can be captured here. + * @member {number} [sku.capacity] Capacity of the particular SKU. + * @member {string} databaseId Resource ID of the database to store job + * metadata in. + * @member {string} [state] The state of the job agent. Possible values + * include: 'Creating', 'Ready', 'Updating', 'Deleting', 'Disabled' + */ + constructor() { + super(); + } + + /** + * Defines the metadata of JobAgent + * + * @returns {object} metadata of JobAgent + * + */ + mapper() { + return { + required: false, + serializedName: 'JobAgent', + type: { + name: 'Composite', + className: 'JobAgent', + 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' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + location: { + required: true, + serializedName: 'location', + type: { + name: 'String' + } + }, + sku: { + required: false, + serializedName: 'sku', + type: { + name: 'Composite', + className: 'Sku' + } + }, + databaseId: { + required: true, + serializedName: 'properties.databaseId', + type: { + name: 'String' + } + }, + state: { + required: false, + readOnly: true, + serializedName: 'properties.state', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = JobAgent; diff --git a/lib/services/sqlManagement2/lib/models/jobAgentListResult.js b/lib/services/sqlManagement2/lib/models/jobAgentListResult.js new file mode 100644 index 0000000000..ba4bbd8e5b --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/jobAgentListResult.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * A list of Azure SQL job agents. + */ +class JobAgentListResult extends Array { + /** + * Create a JobAgentListResult. + * @member {string} [nextLink] Link to retrieve next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of JobAgentListResult + * + * @returns {object} metadata of JobAgentListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'JobAgentListResult', + type: { + name: 'Composite', + className: 'JobAgentListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'JobAgentElementType', + type: { + name: 'Composite', + className: 'JobAgent' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = JobAgentListResult; diff --git a/lib/services/sqlManagement2/lib/models/jobAgentUpdate.js b/lib/services/sqlManagement2/lib/models/jobAgentUpdate.js new file mode 100644 index 0000000000..3f642c47d7 --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/jobAgentUpdate.js @@ -0,0 +1,59 @@ +/* + * 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'; + +/** + * An update to an Azure SQL job agent. + * + */ +class JobAgentUpdate { + /** + * Create a JobAgentUpdate. + * @member {object} [tags] Resource tags. + */ + constructor() { + } + + /** + * Defines the metadata of JobAgentUpdate + * + * @returns {object} metadata of JobAgentUpdate + * + */ + mapper() { + return { + required: false, + serializedName: 'JobAgentUpdate', + type: { + name: 'Composite', + className: 'JobAgentUpdate', + modelProperties: { + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = JobAgentUpdate; diff --git a/lib/services/sqlManagement2/lib/models/jobCredential.js b/lib/services/sqlManagement2/lib/models/jobCredential.js new file mode 100644 index 0000000000..dcdc5b6e02 --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/jobCredential.js @@ -0,0 +1,89 @@ +/* + * 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'); + +/** + * A stored credential that can be used by a job to connect to target + * databases. + * + * @extends models['ProxyResource'] + */ +class JobCredential extends models['ProxyResource'] { + /** + * Create a JobCredential. + * @member {string} username The credential user name. + * @member {string} password The credential password. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of JobCredential + * + * @returns {object} metadata of JobCredential + * + */ + mapper() { + return { + required: false, + serializedName: 'JobCredential', + type: { + name: 'Composite', + className: 'JobCredential', + 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' + } + }, + username: { + required: true, + serializedName: 'properties.username', + type: { + name: 'String' + } + }, + password: { + required: true, + serializedName: 'properties.password', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = JobCredential; diff --git a/lib/services/sqlManagement2/lib/models/jobCredentialListResult.js b/lib/services/sqlManagement2/lib/models/jobCredentialListResult.js new file mode 100644 index 0000000000..f35275547c --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/jobCredentialListResult.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * A list of job credentials. + */ +class JobCredentialListResult extends Array { + /** + * Create a JobCredentialListResult. + * @member {string} [nextLink] Link to retrieve next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of JobCredentialListResult + * + * @returns {object} metadata of JobCredentialListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'JobCredentialListResult', + type: { + name: 'Composite', + className: 'JobCredentialListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'JobCredentialElementType', + type: { + name: 'Composite', + className: 'JobCredential' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = JobCredentialListResult; diff --git a/lib/services/sqlManagement2/lib/models/jobExecution.js b/lib/services/sqlManagement2/lib/models/jobExecution.js new file mode 100644 index 0000000000..5992eadb78 --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/jobExecution.js @@ -0,0 +1,202 @@ +/* + * 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'); + +/** + * An execution of a job + * + * @extends models['ProxyResource'] + */ +class JobExecution extends models['ProxyResource'] { + /** + * Create a JobExecution. + * @member {number} [jobVersion] The job version number. + * @member {string} [stepName] The job step name. + * @member {number} [stepId] The job step id. + * @member {uuid} [jobExecutionId] The unique identifier of the job + * execution. + * @member {string} [lifecycle] The detailed state of the job execution. + * Possible values include: 'Created', 'InProgress', + * 'WaitingForChildJobExecutions', 'WaitingForRetry', 'Succeeded', + * 'SucceededWithSkipped', 'Failed', 'TimedOut', 'Canceled', 'Skipped' + * @member {string} [provisioningState] The ARM provisioning state of the job + * execution. Possible values include: 'Created', 'InProgress', 'Succeeded', + * 'Failed', 'Canceled' + * @member {date} [createTime] The time that the job execution was created. + * @member {date} [startTime] The time that the job execution started. + * @member {date} [endTime] The time that the job execution completed. + * @member {number} [currentAttempts] Number of times the job execution has + * been attempted. + * @member {date} [currentAttemptStartTime] Start time of the current + * attempt. + * @member {string} [lastMessage] The last status or error message. + * @member {object} [target] The target that this execution is executed on. + * @member {string} [target.type] The type of the target. Possible values + * include: 'TargetGroup', 'SqlDatabase', 'SqlElasticPool', 'SqlShardMap', + * 'SqlServer' + * @member {string} [target.serverName] The server name. + * @member {string} [target.databaseName] The database name. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of JobExecution + * + * @returns {object} metadata of JobExecution + * + */ + mapper() { + return { + required: false, + serializedName: 'JobExecution', + type: { + name: 'Composite', + className: 'JobExecution', + 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' + } + }, + jobVersion: { + required: false, + readOnly: true, + serializedName: 'properties.jobVersion', + type: { + name: 'Number' + } + }, + stepName: { + required: false, + readOnly: true, + serializedName: 'properties.stepName', + type: { + name: 'String' + } + }, + stepId: { + required: false, + readOnly: true, + serializedName: 'properties.stepId', + type: { + name: 'Number' + } + }, + jobExecutionId: { + required: false, + readOnly: true, + serializedName: 'properties.jobExecutionId', + type: { + name: 'String' + } + }, + lifecycle: { + required: false, + readOnly: true, + serializedName: 'properties.lifecycle', + type: { + name: 'String' + } + }, + provisioningState: { + required: false, + readOnly: true, + serializedName: 'properties.provisioningState', + type: { + name: 'String' + } + }, + createTime: { + required: false, + readOnly: true, + serializedName: 'properties.createTime', + type: { + name: 'DateTime' + } + }, + startTime: { + required: false, + readOnly: true, + serializedName: 'properties.startTime', + type: { + name: 'DateTime' + } + }, + endTime: { + required: false, + readOnly: true, + serializedName: 'properties.endTime', + type: { + name: 'DateTime' + } + }, + currentAttempts: { + required: false, + serializedName: 'properties.currentAttempts', + type: { + name: 'Number' + } + }, + currentAttemptStartTime: { + required: false, + readOnly: true, + serializedName: 'properties.currentAttemptStartTime', + type: { + name: 'DateTime' + } + }, + lastMessage: { + required: false, + readOnly: true, + serializedName: 'properties.lastMessage', + type: { + name: 'String' + } + }, + target: { + required: false, + readOnly: true, + serializedName: 'properties.target', + type: { + name: 'Composite', + className: 'JobExecutionTarget' + } + } + } + } + }; + } +} + +module.exports = JobExecution; diff --git a/lib/services/sqlManagement2/lib/models/jobExecutionListResult.js b/lib/services/sqlManagement2/lib/models/jobExecutionListResult.js new file mode 100644 index 0000000000..376f54f329 --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/jobExecutionListResult.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * A list of job executions. + */ +class JobExecutionListResult extends Array { + /** + * Create a JobExecutionListResult. + * @member {string} [nextLink] Link to retrieve next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of JobExecutionListResult + * + * @returns {object} metadata of JobExecutionListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'JobExecutionListResult', + type: { + name: 'Composite', + className: 'JobExecutionListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'JobExecutionElementType', + type: { + name: 'Composite', + className: 'JobExecution' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = JobExecutionListResult; diff --git a/lib/services/sqlManagement2/lib/models/jobExecutionTarget.js b/lib/services/sqlManagement2/lib/models/jobExecutionTarget.js new file mode 100644 index 0000000000..34ae012d68 --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/jobExecutionTarget.js @@ -0,0 +1,72 @@ +/* + * 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 target that a job execution is executed on. + * + */ +class JobExecutionTarget { + /** + * Create a JobExecutionTarget. + * @member {string} [type] The type of the target. Possible values include: + * 'TargetGroup', 'SqlDatabase', 'SqlElasticPool', 'SqlShardMap', 'SqlServer' + * @member {string} [serverName] The server name. + * @member {string} [databaseName] The database name. + */ + constructor() { + } + + /** + * Defines the metadata of JobExecutionTarget + * + * @returns {object} metadata of JobExecutionTarget + * + */ + mapper() { + return { + required: false, + serializedName: 'JobExecutionTarget', + type: { + name: 'Composite', + className: 'JobExecutionTarget', + modelProperties: { + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + serverName: { + required: false, + readOnly: true, + serializedName: 'serverName', + type: { + name: 'String' + } + }, + databaseName: { + required: false, + readOnly: true, + serializedName: 'databaseName', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = JobExecutionTarget; diff --git a/lib/services/sqlManagement2/lib/models/jobListResult.js b/lib/services/sqlManagement2/lib/models/jobListResult.js new file mode 100644 index 0000000000..f5f7560d99 --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/jobListResult.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * A list of jobs. + */ +class JobListResult extends Array { + /** + * Create a JobListResult. + * @member {string} [nextLink] Link to retrieve next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of JobListResult + * + * @returns {object} metadata of JobListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'JobListResult', + type: { + name: 'Composite', + className: 'JobListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'JobElementType', + type: { + name: 'Composite', + className: 'Job' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = JobListResult; diff --git a/lib/services/sqlManagement2/lib/models/jobSchedule.js b/lib/services/sqlManagement2/lib/models/jobSchedule.js new file mode 100644 index 0000000000..70cf27c51e --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/jobSchedule.js @@ -0,0 +1,92 @@ +/* + * 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'; + +/** + * Scheduling properties of a job. + * + */ +class JobSchedule { + /** + * Create a JobSchedule. + * @member {date} [startTime] Schedule start time. Default value: new + * Date('0001-01-01T00:00:00Z') . + * @member {date} [endTime] Schedule end time. Default value: new + * Date('9999-12-31T11:59:59Z') . + * @member {string} [type] Schedule interval type. Possible values include: + * 'Once', 'Recurring'. Default value: 'Once' . + * @member {boolean} [enabled] Whether or not the schedule is enabled. + * @member {string} [interval] Value of the schedule's recurring interval, if + * the scheduletype is recurring. ISO8601 duration format. + */ + constructor() { + } + + /** + * Defines the metadata of JobSchedule + * + * @returns {object} metadata of JobSchedule + * + */ + mapper() { + return { + required: false, + serializedName: 'JobSchedule', + type: { + name: 'Composite', + className: 'JobSchedule', + modelProperties: { + startTime: { + required: false, + serializedName: 'startTime', + defaultValue: new Date('0001-01-01T00:00:00Z'), + type: { + name: 'DateTime' + } + }, + endTime: { + required: false, + serializedName: 'endTime', + defaultValue: new Date('9999-12-31T11:59:59Z'), + type: { + name: 'DateTime' + } + }, + type: { + required: false, + serializedName: 'type', + defaultValue: 'Once', + type: { + name: 'Enum', + allowedValues: [ 'Once', 'Recurring' ] + } + }, + enabled: { + required: false, + serializedName: 'enabled', + type: { + name: 'Boolean' + } + }, + interval: { + required: false, + serializedName: 'interval', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = JobSchedule; diff --git a/lib/services/sqlManagement2/lib/models/jobStep.js b/lib/services/sqlManagement2/lib/models/jobStep.js new file mode 100644 index 0000000000..ae8cc6fbde --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/jobStep.js @@ -0,0 +1,155 @@ +/* + * 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'); + +/** + * A job step. + * + * @extends models['ProxyResource'] + */ +class JobStep extends models['ProxyResource'] { + /** + * Create a JobStep. + * @member {number} [stepId] The job step's index within the job. If not + * specified when creating the job step, it will be created as the last step. + * If not specified when updating the job step, the step id is not modified. + * @member {string} targetGroup The resource ID of the target group that the + * job step will be executed on. + * @member {string} credential The resource ID of the job credential that + * will be used to connect to the targets. + * @member {object} action The action payload of the job step. + * @member {string} [action.type] Type of action being executed by the job + * step. Possible values include: 'TSql' + * @member {string} [action.source] The source of the action to execute. + * Possible values include: 'Inline' + * @member {string} [action.value] The action value, for example the text of + * the T-SQL script to execute. + * @member {object} [output] Output destination properties of the job step. + * @member {string} [output.type] The output destination type. Possible + * values include: 'SqlDatabase' + * @member {uuid} [output.subscriptionId] The output destination subscription + * id. + * @member {string} [output.resourceGroupName] The output destination + * resource group. + * @member {string} [output.serverName] The output destination server name. + * @member {string} [output.databaseName] The output destination database. + * @member {string} [output.schemaName] The output destination schema. + * @member {string} [output.tableName] The output destination table. + * @member {string} [output.credential] The resource ID of the credential to + * use to connect to the output destination. + * @member {object} [executionOptions] Execution options for the job step. + * @member {number} [executionOptions.timeoutSeconds] Execution timeout for + * the job step. + * @member {number} [executionOptions.retryAttempts] Maximum number of times + * the job step will be reattempted if the first attempt fails. + * @member {number} [executionOptions.initialRetryIntervalSeconds] Initial + * delay between retries for job step execution. + * @member {number} [executionOptions.maximumRetryIntervalSeconds] The + * maximum amount of time to wait between retries for job step execution. + * @member {number} [executionOptions.retryIntervalBackoffMultiplier] The + * backoff multiplier for the time between retries. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of JobStep + * + * @returns {object} metadata of JobStep + * + */ + mapper() { + return { + required: false, + serializedName: 'JobStep', + type: { + name: 'Composite', + className: 'JobStep', + 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' + } + }, + stepId: { + required: false, + serializedName: 'properties.stepId', + type: { + name: 'Number' + } + }, + targetGroup: { + required: true, + serializedName: 'properties.targetGroup', + type: { + name: 'String' + } + }, + credential: { + required: true, + serializedName: 'properties.credential', + type: { + name: 'String' + } + }, + action: { + required: true, + serializedName: 'properties.action', + type: { + name: 'Composite', + className: 'JobStepAction' + } + }, + output: { + required: false, + serializedName: 'properties.output', + type: { + name: 'Composite', + className: 'JobStepOutput' + } + }, + executionOptions: { + required: false, + serializedName: 'properties.executionOptions', + type: { + name: 'Composite', + className: 'JobStepExecutionOptions' + } + } + } + } + }; + } +} + +module.exports = JobStep; diff --git a/lib/services/sqlManagement2/lib/models/jobStepAction.js b/lib/services/sqlManagement2/lib/models/jobStepAction.js new file mode 100644 index 0000000000..06414b7657 --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/jobStepAction.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'; + +/** + * The action to be executed by a job step. + * + */ +class JobStepAction { + /** + * Create a JobStepAction. + * @member {string} [type] Type of action being executed by the job step. + * Possible values include: 'TSql'. Default value: 'TSql' . + * @member {string} [source] The source of the action to execute. Possible + * values include: 'Inline'. Default value: 'Inline' . + * @member {string} value The action value, for example the text of the T-SQL + * script to execute. + */ + constructor() { + } + + /** + * Defines the metadata of JobStepAction + * + * @returns {object} metadata of JobStepAction + * + */ + mapper() { + return { + required: false, + serializedName: 'JobStepAction', + type: { + name: 'Composite', + className: 'JobStepAction', + modelProperties: { + type: { + required: false, + serializedName: 'type', + defaultValue: 'TSql', + type: { + name: 'String' + } + }, + source: { + required: false, + serializedName: 'source', + defaultValue: 'Inline', + type: { + name: 'String' + } + }, + value: { + required: true, + serializedName: 'value', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = JobStepAction; diff --git a/lib/services/sqlManagement2/lib/models/jobStepExecutionOptions.js b/lib/services/sqlManagement2/lib/models/jobStepExecutionOptions.js new file mode 100644 index 0000000000..0cea78cf12 --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/jobStepExecutionOptions.js @@ -0,0 +1,94 @@ +/* + * 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 execution options of a job step. + * + */ +class JobStepExecutionOptions { + /** + * Create a JobStepExecutionOptions. + * @member {number} [timeoutSeconds] Execution timeout for the job step. + * Default value: 43200 . + * @member {number} [retryAttempts] Maximum number of times the job step will + * be reattempted if the first attempt fails. Default value: 10 . + * @member {number} [initialRetryIntervalSeconds] Initial delay between + * retries for job step execution. Default value: 1 . + * @member {number} [maximumRetryIntervalSeconds] The maximum amount of time + * to wait between retries for job step execution. Default value: 120 . + * @member {number} [retryIntervalBackoffMultiplier] The backoff multiplier + * for the time between retries. Default value: 2 . + */ + constructor() { + } + + /** + * Defines the metadata of JobStepExecutionOptions + * + * @returns {object} metadata of JobStepExecutionOptions + * + */ + mapper() { + return { + required: false, + serializedName: 'JobStepExecutionOptions', + type: { + name: 'Composite', + className: 'JobStepExecutionOptions', + modelProperties: { + timeoutSeconds: { + required: false, + serializedName: 'timeoutSeconds', + defaultValue: 43200, + type: { + name: 'Number' + } + }, + retryAttempts: { + required: false, + serializedName: 'retryAttempts', + defaultValue: 10, + type: { + name: 'Number' + } + }, + initialRetryIntervalSeconds: { + required: false, + serializedName: 'initialRetryIntervalSeconds', + defaultValue: 1, + type: { + name: 'Number' + } + }, + maximumRetryIntervalSeconds: { + required: false, + serializedName: 'maximumRetryIntervalSeconds', + defaultValue: 120, + type: { + name: 'Number' + } + }, + retryIntervalBackoffMultiplier: { + required: false, + serializedName: 'retryIntervalBackoffMultiplier', + defaultValue: 2, + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = JobStepExecutionOptions; diff --git a/lib/services/sqlManagement2/lib/models/jobStepListResult.js b/lib/services/sqlManagement2/lib/models/jobStepListResult.js new file mode 100644 index 0000000000..c7d8733fdf --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/jobStepListResult.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * A list of job steps. + */ +class JobStepListResult extends Array { + /** + * Create a JobStepListResult. + * @member {string} [nextLink] Link to retrieve next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of JobStepListResult + * + * @returns {object} metadata of JobStepListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'JobStepListResult', + type: { + name: 'Composite', + className: 'JobStepListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'JobStepElementType', + type: { + name: 'Composite', + className: 'JobStep' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = JobStepListResult; diff --git a/lib/services/sqlManagement2/lib/models/jobStepOutput.js b/lib/services/sqlManagement2/lib/models/jobStepOutput.js new file mode 100644 index 0000000000..dd00174899 --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/jobStepOutput.js @@ -0,0 +1,114 @@ +/* + * 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 output configuration of a job step. + * + */ +class JobStepOutput { + /** + * Create a JobStepOutput. + * @member {string} [type] The output destination type. Possible values + * include: 'SqlDatabase'. Default value: 'SqlDatabase' . + * @member {uuid} [subscriptionId] The output destination subscription id. + * @member {string} [resourceGroupName] The output destination resource + * group. + * @member {string} serverName The output destination server name. + * @member {string} databaseName The output destination database. + * @member {string} [schemaName] The output destination schema. Default + * value: 'dbo' . + * @member {string} tableName The output destination table. + * @member {string} credential The resource ID of the credential to use to + * connect to the output destination. + */ + constructor() { + } + + /** + * Defines the metadata of JobStepOutput + * + * @returns {object} metadata of JobStepOutput + * + */ + mapper() { + return { + required: false, + serializedName: 'JobStepOutput', + type: { + name: 'Composite', + className: 'JobStepOutput', + modelProperties: { + type: { + required: false, + serializedName: 'type', + defaultValue: 'SqlDatabase', + type: { + name: 'String' + } + }, + subscriptionId: { + required: false, + serializedName: 'subscriptionId', + type: { + name: 'String' + } + }, + resourceGroupName: { + required: false, + serializedName: 'resourceGroupName', + type: { + name: 'String' + } + }, + serverName: { + required: true, + serializedName: 'serverName', + type: { + name: 'String' + } + }, + databaseName: { + required: true, + serializedName: 'databaseName', + type: { + name: 'String' + } + }, + schemaName: { + required: false, + serializedName: 'schemaName', + defaultValue: 'dbo', + type: { + name: 'String' + } + }, + tableName: { + required: true, + serializedName: 'tableName', + type: { + name: 'String' + } + }, + credential: { + required: true, + serializedName: 'credential', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = JobStepOutput; diff --git a/lib/services/sqlManagement2/lib/models/jobTarget.js b/lib/services/sqlManagement2/lib/models/jobTarget.js new file mode 100644 index 0000000000..e5b4d649dc --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/jobTarget.js @@ -0,0 +1,108 @@ +/* + * 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'; + +/** + * A job target, for example a specific database or a container of databases + * that is evaluated during job execution. + * + */ +class JobTarget { + /** + * Create a JobTarget. + * @member {string} [membershipType] Whether the target is included or + * excluded from the group. Possible values include: 'Include', 'Exclude'. + * Default value: 'Include' . + * @member {string} type The target type. Possible values include: + * 'TargetGroup', 'SqlDatabase', 'SqlElasticPool', 'SqlShardMap', 'SqlServer' + * @member {string} [serverName] The target server name. + * @member {string} [databaseName] The target database name. + * @member {string} [elasticPoolName] The target elastic pool name. + * @member {string} [shardMapName] The target shard map. + * @member {string} [refreshCredential] The resource ID of the credential + * that is used during job execution to connect to the target and determine + * the list of databases inside the target. + */ + constructor() { + } + + /** + * Defines the metadata of JobTarget + * + * @returns {object} metadata of JobTarget + * + */ + mapper() { + return { + required: false, + serializedName: 'JobTarget', + type: { + name: 'Composite', + className: 'JobTarget', + modelProperties: { + membershipType: { + required: false, + serializedName: 'membershipType', + defaultValue: 'Include', + type: { + name: 'Enum', + allowedValues: [ 'Include', 'Exclude' ] + } + }, + type: { + required: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + serverName: { + required: false, + serializedName: 'serverName', + type: { + name: 'String' + } + }, + databaseName: { + required: false, + serializedName: 'databaseName', + type: { + name: 'String' + } + }, + elasticPoolName: { + required: false, + serializedName: 'elasticPoolName', + type: { + name: 'String' + } + }, + shardMapName: { + required: false, + serializedName: 'shardMapName', + type: { + name: 'String' + } + }, + refreshCredential: { + required: false, + serializedName: 'refreshCredential', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = JobTarget; diff --git a/lib/services/sqlManagement2/lib/models/jobTargetGroup.js b/lib/services/sqlManagement2/lib/models/jobTargetGroup.js new file mode 100644 index 0000000000..f23a55c620 --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/jobTargetGroup.js @@ -0,0 +1,88 @@ +/* + * 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'); + +/** + * A group of job targets. + * + * @extends models['ProxyResource'] + */ +class JobTargetGroup extends models['ProxyResource'] { + /** + * Create a JobTargetGroup. + * @member {array} members Members of the target group. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of JobTargetGroup + * + * @returns {object} metadata of JobTargetGroup + * + */ + mapper() { + return { + required: false, + serializedName: 'JobTargetGroup', + type: { + name: 'Composite', + className: 'JobTargetGroup', + 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' + } + }, + members: { + required: true, + serializedName: 'properties.members', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'JobTargetElementType', + type: { + name: 'Composite', + className: 'JobTarget' + } + } + } + } + } + } + }; + } +} + +module.exports = JobTargetGroup; diff --git a/lib/services/sqlManagement2/lib/models/jobTargetGroupListResult.js b/lib/services/sqlManagement2/lib/models/jobTargetGroupListResult.js new file mode 100644 index 0000000000..181d09707b --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/jobTargetGroupListResult.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * A list of target groups. + */ +class JobTargetGroupListResult extends Array { + /** + * Create a JobTargetGroupListResult. + * @member {string} [nextLink] Link to retrieve next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of JobTargetGroupListResult + * + * @returns {object} metadata of JobTargetGroupListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'JobTargetGroupListResult', + type: { + name: 'Composite', + className: 'JobTargetGroupListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'JobTargetGroupElementType', + type: { + name: 'Composite', + className: 'JobTargetGroup' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = JobTargetGroupListResult; diff --git a/lib/services/sqlManagement2/lib/models/jobVersion.js b/lib/services/sqlManagement2/lib/models/jobVersion.js new file mode 100644 index 0000000000..b49fc3c14f --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/jobVersion.js @@ -0,0 +1,72 @@ +/* + * 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'); + +/** + * A job version. + * + * @extends models['ProxyResource'] + */ +class JobVersion extends models['ProxyResource'] { + /** + * Create a JobVersion. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of JobVersion + * + * @returns {object} metadata of JobVersion + * + */ + mapper() { + return { + required: false, + serializedName: 'JobVersion', + type: { + name: 'Composite', + className: 'JobVersion', + 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' + } + } + } + } + }; + } +} + +module.exports = JobVersion; diff --git a/lib/services/sqlManagement2/lib/models/jobVersionListResult.js b/lib/services/sqlManagement2/lib/models/jobVersionListResult.js new file mode 100644 index 0000000000..a2bb14997d --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/jobVersionListResult.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * A list of job versions. + */ +class JobVersionListResult extends Array { + /** + * Create a JobVersionListResult. + * @member {string} [nextLink] Link to retrieve next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of JobVersionListResult + * + * @returns {object} metadata of JobVersionListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'JobVersionListResult', + type: { + name: 'Composite', + className: 'JobVersionListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'JobVersionElementType', + type: { + name: 'Composite', + className: 'JobVersion' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = JobVersionListResult; diff --git a/lib/services/sqlManagement2/lib/models/vulnerabilityAssessmentRecurringScansProperties.js b/lib/services/sqlManagement2/lib/models/vulnerabilityAssessmentRecurringScansProperties.js new file mode 100644 index 0000000000..b08942b1ca --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/vulnerabilityAssessmentRecurringScansProperties.js @@ -0,0 +1,79 @@ +/* + * 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'; + +/** + * Properties of a Vulnerability Assessment recurring scans. + * + */ +class VulnerabilityAssessmentRecurringScansProperties { + /** + * Create a VulnerabilityAssessmentRecurringScansProperties. + * @member {boolean} [isEnabled] Recurring scans state. + * @member {boolean} [emailSubscriptionAdmins] Specifies that the schedule + * scan notification will be is sent to the subscription administrators. + * Default value: true . + * @member {array} [emails] Specifies an array of e-mail addresses to which + * the scan notification is sent. + */ + constructor() { + } + + /** + * Defines the metadata of VulnerabilityAssessmentRecurringScansProperties + * + * @returns {object} metadata of VulnerabilityAssessmentRecurringScansProperties + * + */ + mapper() { + return { + required: false, + serializedName: 'VulnerabilityAssessmentRecurringScansProperties', + type: { + name: 'Composite', + className: 'VulnerabilityAssessmentRecurringScansProperties', + modelProperties: { + isEnabled: { + required: false, + serializedName: 'isEnabled', + type: { + name: 'Boolean' + } + }, + emailSubscriptionAdmins: { + required: false, + serializedName: 'emailSubscriptionAdmins', + defaultValue: true, + type: { + name: 'Boolean' + } + }, + emails: { + required: false, + serializedName: 'emails', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = VulnerabilityAssessmentRecurringScansProperties; diff --git a/lib/services/sqlManagement2/lib/models/vulnerabilityAssessmentScanError.js b/lib/services/sqlManagement2/lib/models/vulnerabilityAssessmentScanError.js new file mode 100644 index 0000000000..29ed29a2d7 --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/vulnerabilityAssessmentScanError.js @@ -0,0 +1,62 @@ +/* + * 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'; + +/** + * Properties of a vulnerability assessment scan error. + * + */ +class VulnerabilityAssessmentScanError { + /** + * Create a VulnerabilityAssessmentScanError. + * @member {string} [code] The error code. + * @member {string} [message] The error message. + */ + constructor() { + } + + /** + * Defines the metadata of VulnerabilityAssessmentScanError + * + * @returns {object} metadata of VulnerabilityAssessmentScanError + * + */ + mapper() { + return { + required: false, + serializedName: 'VulnerabilityAssessmentScanError', + type: { + name: 'Composite', + className: 'VulnerabilityAssessmentScanError', + modelProperties: { + code: { + required: false, + readOnly: true, + serializedName: 'code', + type: { + name: 'String' + } + }, + message: { + required: false, + readOnly: true, + serializedName: 'message', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = VulnerabilityAssessmentScanError; diff --git a/lib/services/sqlManagement2/lib/models/vulnerabilityAssessmentScanRecord.js b/lib/services/sqlManagement2/lib/models/vulnerabilityAssessmentScanRecord.js new file mode 100644 index 0000000000..cbef4bb19f --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/vulnerabilityAssessmentScanRecord.js @@ -0,0 +1,156 @@ +/* + * 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'); + +/** + * A vulnerability assessment scan record. + * + * @extends models['ProxyResource'] + */ +class VulnerabilityAssessmentScanRecord extends models['ProxyResource'] { + /** + * Create a VulnerabilityAssessmentScanRecord. + * @member {string} [scanId] The scan ID. + * @member {string} [triggerType] The scan trigger type. Possible values + * include: 'OnDemand', 'Recurring' + * @member {string} [state] The scan status. Possible values include: + * 'Passed', 'Failed', 'FailedToRun', 'InProgress' + * @member {date} [startTime] The scan start time (UTC). + * @member {date} [endTime] The scan end time (UTC). + * @member {array} [errors] The scan errors. + * @member {string} [storageContainerPath] The scan results storage container + * path. + * @member {number} [numberOfFailedSecurityChecks] The number of failed + * security checks. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of VulnerabilityAssessmentScanRecord + * + * @returns {object} metadata of VulnerabilityAssessmentScanRecord + * + */ + mapper() { + return { + required: false, + serializedName: 'VulnerabilityAssessmentScanRecord', + type: { + name: 'Composite', + className: 'VulnerabilityAssessmentScanRecord', + 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' + } + }, + scanId: { + required: false, + readOnly: true, + serializedName: 'properties.scanId', + type: { + name: 'String' + } + }, + triggerType: { + required: false, + readOnly: true, + serializedName: 'properties.triggerType', + type: { + name: 'String' + } + }, + state: { + required: false, + readOnly: true, + serializedName: 'properties.state', + type: { + name: 'String' + } + }, + startTime: { + required: false, + readOnly: true, + serializedName: 'properties.startTime', + type: { + name: 'DateTime' + } + }, + endTime: { + required: false, + readOnly: true, + serializedName: 'properties.endTime', + type: { + name: 'DateTime' + } + }, + errors: { + required: false, + readOnly: true, + serializedName: 'properties.errors', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'VulnerabilityAssessmentScanErrorElementType', + type: { + name: 'Composite', + className: 'VulnerabilityAssessmentScanError' + } + } + } + }, + storageContainerPath: { + required: false, + readOnly: true, + serializedName: 'properties.storageContainerPath', + type: { + name: 'String' + } + }, + numberOfFailedSecurityChecks: { + required: false, + readOnly: true, + serializedName: 'properties.numberOfFailedSecurityChecks', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = VulnerabilityAssessmentScanRecord; diff --git a/lib/services/sqlManagement2/lib/models/vulnerabilityAssessmentScanRecordListResult.js b/lib/services/sqlManagement2/lib/models/vulnerabilityAssessmentScanRecordListResult.js new file mode 100644 index 0000000000..04d5447c1b --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/vulnerabilityAssessmentScanRecordListResult.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * A list of vulnerability assessment scan records. + */ +class VulnerabilityAssessmentScanRecordListResult extends Array { + /** + * Create a VulnerabilityAssessmentScanRecordListResult. + * @member {string} [nextLink] Link to retrieve next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of VulnerabilityAssessmentScanRecordListResult + * + * @returns {object} metadata of VulnerabilityAssessmentScanRecordListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'VulnerabilityAssessmentScanRecordListResult', + type: { + name: 'Composite', + className: 'VulnerabilityAssessmentScanRecordListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'VulnerabilityAssessmentScanRecordElementType', + type: { + name: 'Composite', + className: 'VulnerabilityAssessmentScanRecord' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = VulnerabilityAssessmentScanRecordListResult; diff --git a/lib/services/sqlManagement2/lib/operations/databaseVulnerabilityAssessmentRuleBaselines.js b/lib/services/sqlManagement2/lib/operations/databaseVulnerabilityAssessmentRuleBaselines.js new file mode 100644 index 0000000000..7a53ad9ef5 --- /dev/null +++ b/lib/services/sqlManagement2/lib/operations/databaseVulnerabilityAssessmentRuleBaselines.js @@ -0,0 +1,832 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets a database's vulnerability assessment rule baseline. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database for which the + * vulnerability assessment rule baseline is defined. + * + * @param {string} ruleId The vulnerability assessment rule ID. + * + * @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 DatabaseVulnerabilityAssessmentRuleBaseline} + * for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, serverName, databaseName, ruleId, 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 vulnerabilityAssessmentName = 'default'; + let baselineName = 'default'; + let apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (databaseName === null || databaseName === undefined || typeof databaseName.valueOf() !== 'string') { + throw new Error('databaseName cannot be null or undefined and it must be of type string.'); + } + if (ruleId === null || ruleId === undefined || typeof ruleId.valueOf() !== 'string') { + throw new Error('ruleId 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.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{databaseName}', encodeURIComponent(databaseName)); + requestUrl = requestUrl.replace('{vulnerabilityAssessmentName}', encodeURIComponent(vulnerabilityAssessmentName)); + requestUrl = requestUrl.replace('{ruleId}', encodeURIComponent(ruleId)); + requestUrl = requestUrl.replace('{baselineName}', encodeURIComponent(baselineName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(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['DatabaseVulnerabilityAssessmentRuleBaseline']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Creates or updates a database's vulnerability assessment rule baseline. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database for which the + * vulnerability assessment rule baseline is defined. + * + * @param {string} ruleId The vulnerability assessment rule ID. + * + * @param {object} parameters The requested rule baseline resource. + * + * @param {array} parameters.baselineResults The rule baseline result + * + * @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 DatabaseVulnerabilityAssessmentRuleBaseline} + * for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(resourceGroupName, serverName, databaseName, ruleId, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let vulnerabilityAssessmentName = 'default'; + let baselineName = 'default'; + let apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (databaseName === null || databaseName === undefined || typeof databaseName.valueOf() !== 'string') { + throw new Error('databaseName cannot be null or undefined and it must be of type string.'); + } + if (ruleId === null || ruleId === undefined || typeof ruleId.valueOf() !== 'string') { + throw new Error('ruleId cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + 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.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{databaseName}', encodeURIComponent(databaseName)); + requestUrl = requestUrl.replace('{vulnerabilityAssessmentName}', encodeURIComponent(vulnerabilityAssessmentName)); + requestUrl = requestUrl.replace('{ruleId}', encodeURIComponent(ruleId)); + requestUrl = requestUrl.replace('{baselineName}', encodeURIComponent(baselineName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['DatabaseVulnerabilityAssessmentRuleBaseline']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + 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['DatabaseVulnerabilityAssessmentRuleBaseline']().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); + }); +} + +/** + * Removes the database's vulnerability assessment rule baseline. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database for which the + * vulnerability assessment rule baseline is defined. + * + * @param {string} ruleId The vulnerability assessment rule ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(resourceGroupName, serverName, databaseName, ruleId, 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 vulnerabilityAssessmentName = 'default'; + let baselineName = 'default'; + let apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (databaseName === null || databaseName === undefined || typeof databaseName.valueOf() !== 'string') { + throw new Error('databaseName cannot be null or undefined and it must be of type string.'); + } + if (ruleId === null || ruleId === undefined || typeof ruleId.valueOf() !== 'string') { + throw new Error('ruleId 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.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{databaseName}', encodeURIComponent(databaseName)); + requestUrl = requestUrl.replace('{vulnerabilityAssessmentName}', encodeURIComponent(vulnerabilityAssessmentName)); + requestUrl = requestUrl.replace('{ruleId}', encodeURIComponent(ruleId)); + requestUrl = requestUrl.replace('{baselineName}', encodeURIComponent(baselineName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (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; + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a DatabaseVulnerabilityAssessmentRuleBaselines. */ +class DatabaseVulnerabilityAssessmentRuleBaselines { + /** + * Create a DatabaseVulnerabilityAssessmentRuleBaselines. + * @param {SqlManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + this._deleteMethod = _deleteMethod; + } + + /** + * Gets a database's vulnerability assessment rule baseline. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database for which the + * vulnerability assessment rule baseline is defined. + * + * @param {string} ruleId The vulnerability assessment rule ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, serverName, databaseName, ruleId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, databaseName, ruleId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a database's vulnerability assessment rule baseline. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database for which the + * vulnerability assessment rule baseline is defined. + * + * @param {string} ruleId The vulnerability assessment rule ID. + * + * @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 {DatabaseVulnerabilityAssessmentRuleBaseline} - 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 DatabaseVulnerabilityAssessmentRuleBaseline} + * for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, serverName, databaseName, ruleId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, databaseName, ruleId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, serverName, databaseName, ruleId, options, optionalCallback); + } + } + + /** + * Creates or updates a database's vulnerability assessment rule baseline. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database for which the + * vulnerability assessment rule baseline is defined. + * + * @param {string} ruleId The vulnerability assessment rule ID. + * + * @param {object} parameters The requested rule baseline resource. + * + * @param {array} parameters.baselineResults The rule baseline result + * + * @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. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName, serverName, databaseName, ruleId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, serverName, databaseName, ruleId, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Creates or updates a database's vulnerability assessment rule baseline. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database for which the + * vulnerability assessment rule baseline is defined. + * + * @param {string} ruleId The vulnerability assessment rule ID. + * + * @param {object} parameters The requested rule baseline resource. + * + * @param {array} parameters.baselineResults The rule baseline result + * + * @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 {DatabaseVulnerabilityAssessmentRuleBaseline} - 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 DatabaseVulnerabilityAssessmentRuleBaseline} + * for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName, serverName, databaseName, ruleId, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, serverName, databaseName, ruleId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, serverName, databaseName, ruleId, parameters, options, optionalCallback); + } + } + + /** + * Removes the database's vulnerability assessment rule baseline. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database for which the + * vulnerability assessment rule baseline is defined. + * + * @param {string} ruleId The vulnerability assessment rule ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, serverName, databaseName, ruleId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, serverName, databaseName, ruleId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Removes the database's vulnerability assessment rule baseline. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database for which the + * vulnerability assessment rule baseline is defined. + * + * @param {string} ruleId The vulnerability assessment rule ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName, serverName, databaseName, ruleId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, serverName, databaseName, ruleId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, serverName, databaseName, ruleId, options, optionalCallback); + } + } + +} + +module.exports = DatabaseVulnerabilityAssessmentRuleBaselines; diff --git a/lib/services/sqlManagement2/lib/operations/databaseVulnerabilityAssessmentScans.js b/lib/services/sqlManagement2/lib/operations/databaseVulnerabilityAssessmentScans.js new file mode 100644 index 0000000000..a710edfb82 --- /dev/null +++ b/lib/services/sqlManagement2/lib/operations/databaseVulnerabilityAssessmentScans.js @@ -0,0 +1,1448 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets a vulnerability assessment scan record of a database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @param {string} scanId The vulnerability assessment scan Id of the scan to + * retrieve. + * + * @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 VulnerabilityAssessmentScanRecord} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, serverName, databaseName, scanId, 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 vulnerabilityAssessmentName = 'default'; + let apiVersion = '2017-10-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (databaseName === null || databaseName === undefined || typeof databaseName.valueOf() !== 'string') { + throw new Error('databaseName cannot be null or undefined and it must be of type string.'); + } + if (scanId === null || scanId === undefined || typeof scanId.valueOf() !== 'string') { + throw new Error('scanId 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.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{databaseName}', encodeURIComponent(databaseName)); + requestUrl = requestUrl.replace('{vulnerabilityAssessmentName}', encodeURIComponent(vulnerabilityAssessmentName)); + requestUrl = requestUrl.replace('{scanId}', encodeURIComponent(scanId)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(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['VulnerabilityAssessmentScanRecord']().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); + }); +} + + +/** + * Executes a Vulnerability Assessment database scan. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @param {string} scanId The vulnerability assessment scan Id of the scan to + * retrieve. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _execute(resourceGroupName, serverName, databaseName, scanId, 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.'); + } + + // Send request + this.beginExecute(resourceGroupName, serverName, databaseName, scanId, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + + return callback(null, result, httpRequest, response); + }); + }); +} + +/** + * Lists the vulnerability assessment scans of a database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @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 VulnerabilityAssessmentScanRecordListResult} + * 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 _listByDatabase(resourceGroupName, serverName, databaseName, 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 vulnerabilityAssessmentName = 'default'; + let apiVersion = '2017-10-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (databaseName === null || databaseName === undefined || typeof databaseName.valueOf() !== 'string') { + throw new Error('databaseName 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.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{databaseName}', encodeURIComponent(databaseName)); + requestUrl = requestUrl.replace('{vulnerabilityAssessmentName}', encodeURIComponent(vulnerabilityAssessmentName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(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['VulnerabilityAssessmentScanRecordListResult']().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); + }); +} + +/** + * Convert an existing scan result to a human readable format. If already + * exists nothing happens + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the scanned database. + * + * @param {string} scanId The vulnerability assessment scan Id. + * + * @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 DatabaseVulnerabilityAssessmentScansExport} + * 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 _exportMethod(resourceGroupName, serverName, databaseName, scanId, 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 vulnerabilityAssessmentName = 'default'; + let apiVersion = '2017-10-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (databaseName === null || databaseName === undefined || typeof databaseName.valueOf() !== 'string') { + throw new Error('databaseName cannot be null or undefined and it must be of type string.'); + } + if (scanId === null || scanId === undefined || typeof scanId.valueOf() !== 'string') { + throw new Error('scanId 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.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{databaseName}', encodeURIComponent(databaseName)); + requestUrl = requestUrl.replace('{vulnerabilityAssessmentName}', encodeURIComponent(vulnerabilityAssessmentName)); + requestUrl = requestUrl.replace('{scanId}', encodeURIComponent(scanId)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + 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 && statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['DatabaseVulnerabilityAssessmentScansExport']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['DatabaseVulnerabilityAssessmentScansExport']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Executes a Vulnerability Assessment database scan. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @param {string} scanId The vulnerability assessment scan Id of the scan to + * retrieve. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _beginExecute(resourceGroupName, serverName, databaseName, scanId, 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 vulnerabilityAssessmentName = 'default'; + let apiVersion = '2017-10-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (databaseName === null || databaseName === undefined || typeof databaseName.valueOf() !== 'string') { + throw new Error('databaseName cannot be null or undefined and it must be of type string.'); + } + if (scanId === null || scanId === undefined || typeof scanId.valueOf() !== 'string') { + throw new Error('scanId 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.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{databaseName}', encodeURIComponent(databaseName)); + requestUrl = requestUrl.replace('{vulnerabilityAssessmentName}', encodeURIComponent(vulnerabilityAssessmentName)); + requestUrl = requestUrl.replace('{scanId}', encodeURIComponent(scanId)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + 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 && statusCode !== 202) { + 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; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the vulnerability assessment scans of a database. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link VulnerabilityAssessmentScanRecordListResult} + * 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 _listByDatabaseNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['VulnerabilityAssessmentScanRecordListResult']().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 DatabaseVulnerabilityAssessmentScans. */ +class DatabaseVulnerabilityAssessmentScans { + /** + * Create a DatabaseVulnerabilityAssessmentScans. + * @param {SqlManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._execute = _execute; + this._listByDatabase = _listByDatabase; + this._exportMethod = _exportMethod; + this._beginExecute = _beginExecute; + this._listByDatabaseNext = _listByDatabaseNext; + } + + /** + * Gets a vulnerability assessment scan record of a database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @param {string} scanId The vulnerability assessment scan Id of the scan to + * retrieve. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, serverName, databaseName, scanId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, databaseName, scanId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a vulnerability assessment scan record of a database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @param {string} scanId The vulnerability assessment scan Id of the scan to + * retrieve. + * + * @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 {VulnerabilityAssessmentScanRecord} - 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 VulnerabilityAssessmentScanRecord} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, serverName, databaseName, scanId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, databaseName, scanId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, serverName, databaseName, scanId, options, optionalCallback); + } + } + + /** + * Executes a Vulnerability Assessment database scan. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @param {string} scanId The vulnerability assessment scan Id of the scan to + * retrieve. + * + * @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. + */ + executeWithHttpOperationResponse(resourceGroupName, serverName, databaseName, scanId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._execute(resourceGroupName, serverName, databaseName, scanId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Executes a Vulnerability Assessment database scan. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @param {string} scanId The vulnerability assessment scan Id of the scan to + * retrieve. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + execute(resourceGroupName, serverName, databaseName, scanId, 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._execute(resourceGroupName, serverName, databaseName, scanId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._execute(resourceGroupName, serverName, databaseName, scanId, options, optionalCallback); + } + } + + /** + * Lists the vulnerability assessment scans of a database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @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. + */ + listByDatabaseWithHttpOperationResponse(resourceGroupName, serverName, databaseName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByDatabase(resourceGroupName, serverName, databaseName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the vulnerability assessment scans of a database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @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 {VulnerabilityAssessmentScanRecordListResult} - 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 VulnerabilityAssessmentScanRecordListResult} + * 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. + */ + listByDatabase(resourceGroupName, serverName, databaseName, 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._listByDatabase(resourceGroupName, serverName, databaseName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByDatabase(resourceGroupName, serverName, databaseName, options, optionalCallback); + } + } + + /** + * Convert an existing scan result to a human readable format. If already + * exists nothing happens + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the scanned database. + * + * @param {string} scanId The vulnerability assessment scan Id. + * + * @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. + */ + exportMethodWithHttpOperationResponse(resourceGroupName, serverName, databaseName, scanId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._exportMethod(resourceGroupName, serverName, databaseName, scanId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Convert an existing scan result to a human readable format. If already + * exists nothing happens + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the scanned database. + * + * @param {string} scanId The vulnerability assessment scan Id. + * + * @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 {DatabaseVulnerabilityAssessmentScansExport} - 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 DatabaseVulnerabilityAssessmentScansExport} + * 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. + */ + exportMethod(resourceGroupName, serverName, databaseName, scanId, 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._exportMethod(resourceGroupName, serverName, databaseName, scanId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._exportMethod(resourceGroupName, serverName, databaseName, scanId, options, optionalCallback); + } + } + + /** + * Executes a Vulnerability Assessment database scan. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @param {string} scanId The vulnerability assessment scan Id of the scan to + * retrieve. + * + * @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. + */ + beginExecuteWithHttpOperationResponse(resourceGroupName, serverName, databaseName, scanId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginExecute(resourceGroupName, serverName, databaseName, scanId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Executes a Vulnerability Assessment database scan. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @param {string} scanId The vulnerability assessment scan Id of the scan to + * retrieve. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + beginExecute(resourceGroupName, serverName, databaseName, scanId, 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._beginExecute(resourceGroupName, serverName, databaseName, scanId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginExecute(resourceGroupName, serverName, databaseName, scanId, options, optionalCallback); + } + } + + /** + * Lists the vulnerability assessment scans of a database. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByDatabaseNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByDatabaseNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the vulnerability assessment scans of a database. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {VulnerabilityAssessmentScanRecordListResult} - 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 VulnerabilityAssessmentScanRecordListResult} + * 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. + */ + listByDatabaseNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByDatabaseNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByDatabaseNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = DatabaseVulnerabilityAssessmentScans; diff --git a/lib/services/sqlManagement2/lib/operations/databaseVulnerabilityAssessments.js b/lib/services/sqlManagement2/lib/operations/databaseVulnerabilityAssessments.js new file mode 100644 index 0000000000..4b247b414f --- /dev/null +++ b/lib/services/sqlManagement2/lib/operations/databaseVulnerabilityAssessments.js @@ -0,0 +1,867 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets the database's vulnerability assessment. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database for which the + * vulnerability assessment is defined. + * + * @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 DatabaseVulnerabilityAssessment} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, serverName, databaseName, 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 vulnerabilityAssessmentName = 'default'; + let apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (databaseName === null || databaseName === undefined || typeof databaseName.valueOf() !== 'string') { + throw new Error('databaseName 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.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{databaseName}', encodeURIComponent(databaseName)); + requestUrl = requestUrl.replace('{vulnerabilityAssessmentName}', encodeURIComponent(vulnerabilityAssessmentName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(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['DatabaseVulnerabilityAssessment']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Creates or updates the database's vulnerability assessment. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database for which the + * vulnerability assessment is defined. + * + * @param {object} parameters The requested resource. + * + * @param {string} [parameters.storageContainerPath] A blob storage container + * path to hold the scan results (e.g. + * https://myStorage.blob.core.windows.net/VaScans/). + * + * @param {string} [parameters.storageContainerSasKey] A shared access + * signature (SAS Key) that has write access to the blob container specified in + * 'storageContainerPath' parameter. + * + * @param {object} [parameters.recurringScans] The recurring scans settings + * + * @param {boolean} [parameters.recurringScans.isEnabled] Recurring scans + * state. + * + * @param {boolean} [parameters.recurringScans.emailSubscriptionAdmins] + * Specifies that the schedule scan notification will be is sent to the + * subscription administrators. + * + * @param {array} [parameters.recurringScans.emails] Specifies an array of + * e-mail addresses to which the scan notification is sent. + * + * @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 DatabaseVulnerabilityAssessment} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(resourceGroupName, serverName, databaseName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let vulnerabilityAssessmentName = 'default'; + let apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (databaseName === null || databaseName === undefined || typeof databaseName.valueOf() !== 'string') { + throw new Error('databaseName cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + 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.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{databaseName}', encodeURIComponent(databaseName)); + requestUrl = requestUrl.replace('{vulnerabilityAssessmentName}', encodeURIComponent(vulnerabilityAssessmentName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['DatabaseVulnerabilityAssessment']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['DatabaseVulnerabilityAssessment']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['DatabaseVulnerabilityAssessment']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Removes the database's vulnerability assessment. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database for which the + * vulnerability assessment is defined. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(resourceGroupName, serverName, databaseName, 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 vulnerabilityAssessmentName = 'default'; + let apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (databaseName === null || databaseName === undefined || typeof databaseName.valueOf() !== 'string') { + throw new Error('databaseName 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.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{databaseName}', encodeURIComponent(databaseName)); + requestUrl = requestUrl.replace('{vulnerabilityAssessmentName}', encodeURIComponent(vulnerabilityAssessmentName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (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; + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a DatabaseVulnerabilityAssessments. */ +class DatabaseVulnerabilityAssessments { + /** + * Create a DatabaseVulnerabilityAssessments. + * @param {SqlManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + this._deleteMethod = _deleteMethod; + } + + /** + * Gets the database's vulnerability assessment. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database for which the + * vulnerability assessment is defined. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, serverName, databaseName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, databaseName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the database's vulnerability assessment. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database for which the + * vulnerability assessment is defined. + * + * @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 {DatabaseVulnerabilityAssessment} - 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 DatabaseVulnerabilityAssessment} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, serverName, databaseName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, databaseName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, serverName, databaseName, options, optionalCallback); + } + } + + /** + * Creates or updates the database's vulnerability assessment. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database for which the + * vulnerability assessment is defined. + * + * @param {object} parameters The requested resource. + * + * @param {string} [parameters.storageContainerPath] A blob storage container + * path to hold the scan results (e.g. + * https://myStorage.blob.core.windows.net/VaScans/). + * + * @param {string} [parameters.storageContainerSasKey] A shared access + * signature (SAS Key) that has write access to the blob container specified in + * 'storageContainerPath' parameter. + * + * @param {object} [parameters.recurringScans] The recurring scans settings + * + * @param {boolean} [parameters.recurringScans.isEnabled] Recurring scans + * state. + * + * @param {boolean} [parameters.recurringScans.emailSubscriptionAdmins] + * Specifies that the schedule scan notification will be is sent to the + * subscription administrators. + * + * @param {array} [parameters.recurringScans.emails] Specifies an array of + * e-mail addresses to which the scan notification is sent. + * + * @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. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName, serverName, databaseName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, serverName, databaseName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Creates or updates the database's vulnerability assessment. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database for which the + * vulnerability assessment is defined. + * + * @param {object} parameters The requested resource. + * + * @param {string} [parameters.storageContainerPath] A blob storage container + * path to hold the scan results (e.g. + * https://myStorage.blob.core.windows.net/VaScans/). + * + * @param {string} [parameters.storageContainerSasKey] A shared access + * signature (SAS Key) that has write access to the blob container specified in + * 'storageContainerPath' parameter. + * + * @param {object} [parameters.recurringScans] The recurring scans settings + * + * @param {boolean} [parameters.recurringScans.isEnabled] Recurring scans + * state. + * + * @param {boolean} [parameters.recurringScans.emailSubscriptionAdmins] + * Specifies that the schedule scan notification will be is sent to the + * subscription administrators. + * + * @param {array} [parameters.recurringScans.emails] Specifies an array of + * e-mail addresses to which the scan notification is sent. + * + * @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 {DatabaseVulnerabilityAssessment} - 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 DatabaseVulnerabilityAssessment} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName, serverName, databaseName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, serverName, databaseName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, serverName, databaseName, parameters, options, optionalCallback); + } + } + + /** + * Removes the database's vulnerability assessment. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database for which the + * vulnerability assessment is defined. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, serverName, databaseName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, serverName, databaseName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Removes the database's vulnerability assessment. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database for which the + * vulnerability assessment is defined. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName, serverName, databaseName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, serverName, databaseName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, serverName, databaseName, options, optionalCallback); + } + } + +} + +module.exports = DatabaseVulnerabilityAssessments; diff --git a/lib/services/sqlManagement2/lib/operations/index.d.ts b/lib/services/sqlManagement2/lib/operations/index.d.ts index bbd70b7886..a9b8aa86b3 100644 --- a/lib/services/sqlManagement2/lib/operations/index.d.ts +++ b/lib/services/sqlManagement2/lib/operations/index.d.ts @@ -16475,23 +16475,26 @@ export interface VirtualNetworkRules { /** * @class - * LongTermRetentionBackups + * DatabaseVulnerabilityAssessmentRuleBaselines * __NOTE__: An instance of this class is automatically created for an * instance of the SqlManagementClient. */ -export interface LongTermRetentionBackups { +export interface DatabaseVulnerabilityAssessmentRuleBaselines { /** - * Gets a long term retention backup. + * Gets a database's vulnerability assessment rule baseline. * - * @param {string} locationName The location of the database. + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. * - * @param {string} longTermRetentionServerName + * @param {string} serverName The name of the server. * - * @param {string} longTermRetentionDatabaseName + * @param {string} databaseName The name of the database for which the + * vulnerability assessment rule baseline is defined. * - * @param {string} backupName The backup name. + * @param {string} ruleId The vulnerability assessment rule ID. * * @param {object} [options] Optional Parameters. * @@ -16500,22 +16503,25 @@ export interface LongTermRetentionBackups { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - getWithHttpOperationResponse(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + getWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, ruleId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets a long term retention backup. + * Gets a database's vulnerability assessment rule baseline. * - * @param {string} locationName The location of the database. + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. * - * @param {string} longTermRetentionServerName + * @param {string} serverName The name of the server. * - * @param {string} longTermRetentionDatabaseName + * @param {string} databaseName The name of the database for which the + * vulnerability assessment rule baseline is defined. * - * @param {string} backupName The backup name. + * @param {string} ruleId The vulnerability assessment rule ID. * * @param {object} [options] Optional Parameters. * @@ -16529,7 +16535,7 @@ export interface LongTermRetentionBackups { * * {Promise} A promise is returned. * - * @resolve {LongTermRetentionBackup} - The deserialized result object. + * @resolve {DatabaseVulnerabilityAssessmentRuleBaseline} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -16537,29 +16543,36 @@ export interface LongTermRetentionBackups { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {LongTermRetentionBackup} [result] - The deserialized result object if an error did not occur. - * See {@link LongTermRetentionBackup} for more - * information. + * {DatabaseVulnerabilityAssessmentRuleBaseline} [result] - The deserialized result object if an error did not occur. + * See {@link DatabaseVulnerabilityAssessmentRuleBaseline} + * for more information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - get(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - get(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, callback: ServiceCallback): void; - get(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, databaseName: string, ruleId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, serverName: string, databaseName: string, ruleId: string, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, databaseName: string, ruleId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Deletes a long term retention backup. + * Creates or updates a database's vulnerability assessment rule baseline. * - * @param {string} locationName The location of the database + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. * - * @param {string} longTermRetentionServerName + * @param {string} serverName The name of the server. * - * @param {string} longTermRetentionDatabaseName + * @param {string} databaseName The name of the database for which the + * vulnerability assessment rule baseline is defined. * - * @param {string} backupName The backup name. + * @param {string} ruleId The vulnerability assessment rule ID. + * + * @param {object} parameters The requested rule baseline resource. + * + * @param {array} parameters.baselineResults The rule baseline result * * @param {object} [options] Optional Parameters. * @@ -16568,22 +16581,29 @@ export interface LongTermRetentionBackups { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - deleteMethodWithHttpOperationResponse(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, ruleId: string, parameters: models.DatabaseVulnerabilityAssessmentRuleBaseline, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Deletes a long term retention backup. + * Creates or updates a database's vulnerability assessment rule baseline. * - * @param {string} locationName The location of the database + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. * - * @param {string} longTermRetentionServerName + * @param {string} serverName The name of the server. * - * @param {string} longTermRetentionDatabaseName + * @param {string} databaseName The name of the database for which the + * vulnerability assessment rule baseline is defined. * - * @param {string} backupName The backup name. + * @param {string} ruleId The vulnerability assessment rule ID. + * + * @param {object} parameters The requested rule baseline resource. + * + * @param {array} parameters.baselineResults The rule baseline result * * @param {object} [options] Optional Parameters. * @@ -16597,7 +16617,7 @@ export interface LongTermRetentionBackups { * * {Promise} A promise is returned. * - * @resolve {null} - The deserialized result object. + * @resolve {DatabaseVulnerabilityAssessmentRuleBaseline} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -16605,63 +16625,61 @@ export interface LongTermRetentionBackups { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {null} [result] - The deserialized result object if an error did not occur. + * {DatabaseVulnerabilityAssessmentRuleBaseline} [result] - The deserialized result object if an error did not occur. + * See {@link DatabaseVulnerabilityAssessmentRuleBaseline} + * 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. */ - deleteMethod(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - deleteMethod(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, callback: ServiceCallback): void; - deleteMethod(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, ruleId: string, parameters: models.DatabaseVulnerabilityAssessmentRuleBaseline, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, ruleId: string, parameters: models.DatabaseVulnerabilityAssessmentRuleBaseline, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, ruleId: string, parameters: models.DatabaseVulnerabilityAssessmentRuleBaseline, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Lists all long term retention backups for a database. - * - * @param {string} locationName The location of the database + * Removes the database's vulnerability assessment rule baseline. * - * @param {string} longTermRetentionServerName + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. * - * @param {string} longTermRetentionDatabaseName + * @param {string} serverName The name of the server. * - * @param {object} [options] Optional Parameters. + * @param {string} databaseName The name of the database for which the + * vulnerability assessment rule baseline is defined. * - * @param {boolean} [options.onlyLatestPerDatabase] Whether or not to only get - * the latest backup for each database. + * @param {string} ruleId The vulnerability assessment rule ID. * - * @param {string} [options.databaseState] Whether to query against just live - * databases, just deleted databases, or all databases. Possible values - * include: 'All', 'Live', 'Deleted' + * @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. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listByDatabaseWithHttpOperationResponse(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, options?: { onlyLatestPerDatabase? : boolean, databaseState? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + deleteMethodWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, ruleId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Lists all long term retention backups for a database. - * - * @param {string} locationName The location of the database + * Removes the database's vulnerability assessment rule baseline. * - * @param {string} longTermRetentionServerName + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. * - * @param {string} longTermRetentionDatabaseName + * @param {string} serverName The name of the server. * - * @param {object} [options] Optional Parameters. + * @param {string} databaseName The name of the database for which the + * vulnerability assessment rule baseline is defined. * - * @param {boolean} [options.onlyLatestPerDatabase] Whether or not to only get - * the latest backup for each database. + * @param {string} ruleId The vulnerability assessment rule ID. * - * @param {string} [options.databaseState] Whether to query against just live - * databases, just deleted databases, or all databases. Possible values - * include: 'All', 'Live', 'Deleted' + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -16673,7 +16691,7 @@ export interface LongTermRetentionBackups { * * {Promise} A promise is returned. * - * @resolve {LongTermRetentionBackupListResult} - The deserialized result object. + * @resolve {null} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -16681,57 +16699,64 @@ export interface LongTermRetentionBackups { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {LongTermRetentionBackupListResult} [result] - The deserialized result object if an error did not occur. - * See {@link LongTermRetentionBackupListResult} for more - * information. + * {null} [result] - The deserialized result object if an error did not occur. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - listByDatabase(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, options?: { onlyLatestPerDatabase? : boolean, databaseState? : string, customHeaders? : { [headerName: string]: string; } }): Promise; - listByDatabase(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, callback: ServiceCallback): void; - listByDatabase(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, options: { onlyLatestPerDatabase? : boolean, databaseState? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, serverName: string, databaseName: string, ruleId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, serverName: string, databaseName: string, ruleId: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, serverName: string, databaseName: string, ruleId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * DatabaseVulnerabilityAssessments + * __NOTE__: An instance of this class is automatically created for an + * instance of the SqlManagementClient. + */ +export interface DatabaseVulnerabilityAssessments { /** - * Lists the long term retention backups for a given location. + * Gets the database's vulnerability assessment. * - * @param {string} locationName The location of the database + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. * - * @param {object} [options] Optional Parameters. + * @param {string} serverName The name of the server. * - * @param {boolean} [options.onlyLatestPerDatabase] Whether or not to only get - * the latest backup for each database. + * @param {string} databaseName The name of the database for which the + * vulnerability assessment is defined. * - * @param {string} [options.databaseState] Whether to query against just live - * databases, just deleted databases, or all databases. Possible values - * include: 'All', 'Live', 'Deleted' + * @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. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listByLocationWithHttpOperationResponse(locationName: string, options?: { onlyLatestPerDatabase? : boolean, databaseState? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + getWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Lists the long term retention backups for a given location. + * Gets the database's vulnerability assessment. * - * @param {string} locationName The location of the database + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. * - * @param {object} [options] Optional Parameters. + * @param {string} serverName The name of the server. * - * @param {boolean} [options.onlyLatestPerDatabase] Whether or not to only get - * the latest backup for each database. + * @param {string} databaseName The name of the database for which the + * vulnerability assessment is defined. * - * @param {string} [options.databaseState] Whether to query against just live - * databases, just deleted databases, or all databases. Possible values - * include: 'All', 'Live', 'Deleted' + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -16743,7 +16768,7 @@ export interface LongTermRetentionBackups { * * {Promise} A promise is returned. * - * @resolve {LongTermRetentionBackupListResult} - The deserialized result object. + * @resolve {DatabaseVulnerabilityAssessment} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -16751,61 +16776,101 @@ export interface LongTermRetentionBackups { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {LongTermRetentionBackupListResult} [result] - The deserialized result object if an error did not occur. - * See {@link LongTermRetentionBackupListResult} for more + * {DatabaseVulnerabilityAssessment} [result] - The deserialized result object if an error did not occur. + * See {@link DatabaseVulnerabilityAssessment} 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. */ - listByLocation(locationName: string, options?: { onlyLatestPerDatabase? : boolean, databaseState? : string, customHeaders? : { [headerName: string]: string; } }): Promise; - listByLocation(locationName: string, callback: ServiceCallback): void; - listByLocation(locationName: string, options: { onlyLatestPerDatabase? : boolean, databaseState? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, serverName: string, databaseName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, databaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Lists the long term retention backups for a given server. + * Creates or updates the database's vulnerability assessment. * - * @param {string} locationName The location of the database + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. * - * @param {string} longTermRetentionServerName + * @param {string} serverName The name of the server. * - * @param {object} [options] Optional Parameters. + * @param {string} databaseName The name of the database for which the + * vulnerability assessment is defined. * - * @param {boolean} [options.onlyLatestPerDatabase] Whether or not to only get - * the latest backup for each database. + * @param {object} parameters The requested resource. * - * @param {string} [options.databaseState] Whether to query against just live - * databases, just deleted databases, or all databases. Possible values - * include: 'All', 'Live', 'Deleted' + * @param {string} [parameters.storageContainerPath] A blob storage container + * path to hold the scan results (e.g. + * https://myStorage.blob.core.windows.net/VaScans/). + * + * @param {string} [parameters.storageContainerSasKey] A shared access + * signature (SAS Key) that has write access to the blob container specified in + * 'storageContainerPath' parameter. + * + * @param {object} [parameters.recurringScans] The recurring scans settings + * + * @param {boolean} [parameters.recurringScans.isEnabled] Recurring scans + * state. + * + * @param {boolean} [parameters.recurringScans.emailSubscriptionAdmins] + * Specifies that the schedule scan notification will be is sent to the + * subscription administrators. + * + * @param {array} [parameters.recurringScans.emails] Specifies an array of + * e-mail addresses to which the scan notification is sent. + * + * @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. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listByServerWithHttpOperationResponse(locationName: string, longTermRetentionServerName: string, options?: { onlyLatestPerDatabase? : boolean, databaseState? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.DatabaseVulnerabilityAssessment, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Lists the long term retention backups for a given server. + * Creates or updates the database's vulnerability assessment. * - * @param {string} locationName The location of the database + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. * - * @param {string} longTermRetentionServerName + * @param {string} serverName The name of the server. * - * @param {object} [options] Optional Parameters. + * @param {string} databaseName The name of the database for which the + * vulnerability assessment is defined. * - * @param {boolean} [options.onlyLatestPerDatabase] Whether or not to only get - * the latest backup for each database. + * @param {object} parameters The requested resource. * - * @param {string} [options.databaseState] Whether to query against just live - * databases, just deleted databases, or all databases. Possible values - * include: 'All', 'Live', 'Deleted' + * @param {string} [parameters.storageContainerPath] A blob storage container + * path to hold the scan results (e.g. + * https://myStorage.blob.core.windows.net/VaScans/). + * + * @param {string} [parameters.storageContainerSasKey] A shared access + * signature (SAS Key) that has write access to the blob container specified in + * 'storageContainerPath' parameter. + * + * @param {object} [parameters.recurringScans] The recurring scans settings + * + * @param {boolean} [parameters.recurringScans.isEnabled] Recurring scans + * state. + * + * @param {boolean} [parameters.recurringScans.emailSubscriptionAdmins] + * Specifies that the schedule scan notification will be is sent to the + * subscription administrators. + * + * @param {array} [parameters.recurringScans.emails] Specifies an array of + * e-mail addresses to which the scan notification is sent. + * + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -16817,7 +16882,7 @@ export interface LongTermRetentionBackups { * * {Promise} A promise is returned. * - * @resolve {LongTermRetentionBackupListResult} - The deserialized result object. + * @resolve {DatabaseVulnerabilityAssessment} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -16825,29 +16890,30 @@ export interface LongTermRetentionBackups { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {LongTermRetentionBackupListResult} [result] - The deserialized result object if an error did not occur. - * See {@link LongTermRetentionBackupListResult} for more + * {DatabaseVulnerabilityAssessment} [result] - The deserialized result object if an error did not occur. + * See {@link DatabaseVulnerabilityAssessment} 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. */ - listByServer(locationName: string, longTermRetentionServerName: string, options?: { onlyLatestPerDatabase? : boolean, databaseState? : string, customHeaders? : { [headerName: string]: string; } }): Promise; - listByServer(locationName: string, longTermRetentionServerName: string, callback: ServiceCallback): void; - listByServer(locationName: string, longTermRetentionServerName: string, options: { onlyLatestPerDatabase? : boolean, databaseState? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.DatabaseVulnerabilityAssessment, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.DatabaseVulnerabilityAssessment, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.DatabaseVulnerabilityAssessment, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Deletes a long term retention backup. - * - * @param {string} locationName The location of the database + * Removes the database's vulnerability assessment. * - * @param {string} longTermRetentionServerName + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. * - * @param {string} longTermRetentionDatabaseName + * @param {string} serverName The name of the server. * - * @param {string} backupName The backup name. + * @param {string} databaseName The name of the database for which the + * vulnerability assessment is defined. * * @param {object} [options] Optional Parameters. * @@ -16860,18 +16926,19 @@ export interface LongTermRetentionBackups { * * @reject {Error|ServiceError} - The error object. */ - beginDeleteMethodWithHttpOperationResponse(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + deleteMethodWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Deletes a long term retention backup. - * - * @param {string} locationName The location of the database + * Removes the database's vulnerability assessment. * - * @param {string} longTermRetentionServerName + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. * - * @param {string} longTermRetentionDatabaseName + * @param {string} serverName The name of the server. * - * @param {string} backupName The backup name. + * @param {string} databaseName The name of the database for which the + * vulnerability assessment is defined. * * @param {object} [options] Optional Parameters. * @@ -16899,16 +16966,28 @@ export interface LongTermRetentionBackups { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - beginDeleteMethod(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - beginDeleteMethod(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, callback: ServiceCallback): void; - beginDeleteMethod(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, serverName: string, databaseName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, serverName: string, databaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * JobAgents + * __NOTE__: An instance of this class is automatically created for an + * instance of the SqlManagementClient. + */ +export interface JobAgents { /** - * Lists all long term retention backups for a database. + * Gets a list of job agents in a server. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. * * @param {object} [options] Optional Parameters. * @@ -16917,17 +16996,20 @@ export interface LongTermRetentionBackups { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listByDatabaseNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listByServerWithHttpOperationResponse(resourceGroupName: string, serverName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Lists all long term retention backups for a database. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * Gets a list of job agents in a server. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. * * @param {object} [options] Optional Parameters. * @@ -16941,7 +17023,7 @@ export interface LongTermRetentionBackups { * * {Promise} A promise is returned. * - * @resolve {LongTermRetentionBackupListResult} - The deserialized result object. + * @resolve {JobAgentListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -16949,24 +17031,28 @@ export interface LongTermRetentionBackups { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {LongTermRetentionBackupListResult} [result] - The deserialized result object if an error did not occur. - * See {@link LongTermRetentionBackupListResult} for more - * information. + * {JobAgentListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobAgentListResult} 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. */ - listByDatabaseNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByDatabaseNext(nextPageLink: string, callback: ServiceCallback): void; - listByDatabaseNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + listByServer(resourceGroupName: string, serverName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByServer(resourceGroupName: string, serverName: string, callback: ServiceCallback): void; + listByServer(resourceGroupName: string, serverName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Lists the long term retention backups for a given location. + * Gets a job agent. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be retrieved. * * @param {object} [options] Optional Parameters. * @@ -16975,17 +17061,22 @@ export interface LongTermRetentionBackups { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listByLocationNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + getWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Lists the long term retention backups for a given location. + * Gets a job agent. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be retrieved. * * @param {object} [options] Optional Parameters. * @@ -16999,7 +17090,7 @@ export interface LongTermRetentionBackups { * * {Promise} A promise is returned. * - * @resolve {LongTermRetentionBackupListResult} - The deserialized result object. + * @resolve {JobAgent} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -17007,24 +17098,53 @@ export interface LongTermRetentionBackups { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {LongTermRetentionBackupListResult} [result] - The deserialized result object if an error did not occur. - * See {@link LongTermRetentionBackupListResult} for more - * information. + * {JobAgent} [result] - The deserialized result object if an error did not occur. + * See {@link JobAgent} 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. */ - listByLocationNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByLocationNext(nextPageLink: string, callback: ServiceCallback): void; - listByLocationNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, jobAgentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, serverName: string, jobAgentName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, jobAgentName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Lists the long term retention backups for a given server. + * Creates or updates a job agent. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be created or + * updated. + * + * @param {object} parameters The requested job agent resource state. + * + * @param {object} [parameters.sku] The name and tier of the SKU. + * + * @param {string} parameters.sku.name The name of the SKU, typically, a letter + * + Number code, e.g. P3. + * + * @param {string} [parameters.sku.tier] The tier of the particular SKU, e.g. + * Basic, Premium. + * + * @param {string} [parameters.sku.size] Size of the particular SKU + * + * @param {string} [parameters.sku.family] If the service has different + * generations of hardware, for the same SKU, then that can be captured here. + * + * @param {number} [parameters.sku.capacity] Capacity of the particular SKU. + * + * @param {string} parameters.databaseId Resource ID of the database to store + * job metadata in. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location Resource location. * * @param {object} [options] Optional Parameters. * @@ -17033,17 +17153,47 @@ export interface LongTermRetentionBackups { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listByServerNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, parameters: models.JobAgent, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Lists the long term retention backups for a given server. + * Creates or updates a job agent. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be created or + * updated. + * + * @param {object} parameters The requested job agent resource state. + * + * @param {object} [parameters.sku] The name and tier of the SKU. + * + * @param {string} parameters.sku.name The name of the SKU, typically, a letter + * + Number code, e.g. P3. + * + * @param {string} [parameters.sku.tier] The tier of the particular SKU, e.g. + * Basic, Premium. + * + * @param {string} [parameters.sku.size] Size of the particular SKU + * + * @param {string} [parameters.sku.family] If the service has different + * generations of hardware, for the same SKU, then that can be captured here. + * + * @param {number} [parameters.sku.capacity] Capacity of the particular SKU. + * + * @param {string} parameters.databaseId Resource ID of the database to store + * job metadata in. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location Resource location. * * @param {object} [options] Optional Parameters. * @@ -17057,7 +17207,7 @@ export interface LongTermRetentionBackups { * * {Promise} A promise is returned. * - * @resolve {LongTermRetentionBackupListResult} - The deserialized result object. + * @resolve {JobAgent} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -17065,30 +17215,20 @@ export interface LongTermRetentionBackups { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {LongTermRetentionBackupListResult} [result] - The deserialized result object if an error did not occur. - * See {@link LongTermRetentionBackupListResult} for more - * information. + * {JobAgent} [result] - The deserialized result object if an error did not occur. + * See {@link JobAgent} 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. */ - listByServerNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByServerNext(nextPageLink: string, callback: ServiceCallback): void; - listByServerNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; -} - -/** - * @class - * BackupLongTermRetentionPolicies - * __NOTE__: An instance of this class is automatically created for an - * instance of the SqlManagementClient. - */ -export interface BackupLongTermRetentionPolicies { + createOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, parameters: models.JobAgent, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, parameters: models.JobAgent, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, parameters: models.JobAgent, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Gets a database's long term retention policy. + * Deletes a job agent. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -17096,7 +17236,7 @@ export interface BackupLongTermRetentionPolicies { * * @param {string} serverName The name of the server. * - * @param {string} databaseName The name of the database. + * @param {string} jobAgentName The name of the job agent to be deleted. * * @param {object} [options] Optional Parameters. * @@ -17105,14 +17245,14 @@ export interface BackupLongTermRetentionPolicies { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - getWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + deleteMethodWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets a database's long term retention policy. + * Deletes a job agent. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -17120,7 +17260,7 @@ export interface BackupLongTermRetentionPolicies { * * @param {string} serverName The name of the server. * - * @param {string} databaseName The name of the database. + * @param {string} jobAgentName The name of the job agent to be deleted. * * @param {object} [options] Optional Parameters. * @@ -17134,7 +17274,7 @@ export interface BackupLongTermRetentionPolicies { * * {Promise} A promise is returned. * - * @resolve {BackupLongTermRetentionPolicy} - The deserialized result object. + * @resolve {null} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -17142,21 +17282,19 @@ export interface BackupLongTermRetentionPolicies { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {BackupLongTermRetentionPolicy} [result] - The deserialized result object if an error did not occur. - * See {@link BackupLongTermRetentionPolicy} for more - * information. + * {null} [result] - The deserialized result object if an error did not occur. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - get(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - get(resourceGroupName: string, serverName: string, databaseName: string, callback: ServiceCallback): void; - get(resourceGroupName: string, serverName: string, databaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, serverName: string, jobAgentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, serverName: string, jobAgentName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, serverName: string, jobAgentName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Sets a database's long term retention policy. + * Updates a job agent. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -17164,21 +17302,11 @@ export interface BackupLongTermRetentionPolicies { * * @param {string} serverName The name of the server. * - * @param {string} databaseName The name of the database. - * - * @param {object} parameters The long term retention policy info. - * - * @param {string} [parameters.weeklyRetention] The weekly retention policy for - * an LTR backup in an ISO 8601 format. - * - * @param {string} [parameters.monthlyRetention] The montly retention policy - * for an LTR backup in an ISO 8601 format. + * @param {string} jobAgentName The name of the job agent to be updated. * - * @param {string} [parameters.yearlyRetention] The yearly retention policy for - * an LTR backup in an ISO 8601 format. + * @param {object} parameters The update to the job agent. * - * @param {number} [parameters.weekOfYear] The week of year to take the yearly - * backup in an ISO 8601 format. + * @param {object} [parameters.tags] Resource tags. * * @param {object} [options] Optional Parameters. * @@ -17187,14 +17315,14 @@ export interface BackupLongTermRetentionPolicies { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - createOrUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.BackupLongTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + updateWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, parameters: models.JobAgentUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Sets a database's long term retention policy. + * Updates a job agent. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -17202,21 +17330,11 @@ export interface BackupLongTermRetentionPolicies { * * @param {string} serverName The name of the server. * - * @param {string} databaseName The name of the database. - * - * @param {object} parameters The long term retention policy info. - * - * @param {string} [parameters.weeklyRetention] The weekly retention policy for - * an LTR backup in an ISO 8601 format. - * - * @param {string} [parameters.monthlyRetention] The montly retention policy - * for an LTR backup in an ISO 8601 format. + * @param {string} jobAgentName The name of the job agent to be updated. * - * @param {string} [parameters.yearlyRetention] The yearly retention policy for - * an LTR backup in an ISO 8601 format. + * @param {object} parameters The update to the job agent. * - * @param {number} [parameters.weekOfYear] The week of year to take the yearly - * backup in an ISO 8601 format. + * @param {object} [parameters.tags] Resource tags. * * @param {object} [options] Optional Parameters. * @@ -17230,7 +17348,7 @@ export interface BackupLongTermRetentionPolicies { * * {Promise} A promise is returned. * - * @resolve {BackupLongTermRetentionPolicy} - The deserialized result object. + * @resolve {JobAgent} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -17238,21 +17356,20 @@ export interface BackupLongTermRetentionPolicies { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {BackupLongTermRetentionPolicy} [result] - The deserialized result object if an error did not occur. - * See {@link BackupLongTermRetentionPolicy} for more - * information. + * {JobAgent} [result] - The deserialized result object if an error did not occur. + * See {@link JobAgent} for more information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - createOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.BackupLongTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - createOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.BackupLongTermRetentionPolicy, callback: ServiceCallback): void; - createOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.BackupLongTermRetentionPolicy, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + update(resourceGroupName: string, serverName: string, jobAgentName: string, parameters: models.JobAgentUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, serverName: string, jobAgentName: string, parameters: models.JobAgentUpdate, callback: ServiceCallback): void; + update(resourceGroupName: string, serverName: string, jobAgentName: string, parameters: models.JobAgentUpdate, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Gets a database's long term retention policy. + * Creates or updates a job agent. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -17260,7 +17377,32 @@ export interface BackupLongTermRetentionPolicies { * * @param {string} serverName The name of the server. * - * @param {string} databaseName The name of the database. + * @param {string} jobAgentName The name of the job agent to be created or + * updated. + * + * @param {object} parameters The requested job agent resource state. + * + * @param {object} [parameters.sku] The name and tier of the SKU. + * + * @param {string} parameters.sku.name The name of the SKU, typically, a letter + * + Number code, e.g. P3. + * + * @param {string} [parameters.sku.tier] The tier of the particular SKU, e.g. + * Basic, Premium. + * + * @param {string} [parameters.sku.size] Size of the particular SKU + * + * @param {string} [parameters.sku.family] If the service has different + * generations of hardware, for the same SKU, then that can be captured here. + * + * @param {number} [parameters.sku.capacity] Capacity of the particular SKU. + * + * @param {string} parameters.databaseId Resource ID of the database to store + * job metadata in. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location Resource location. * * @param {object} [options] Optional Parameters. * @@ -17269,14 +17411,14 @@ export interface BackupLongTermRetentionPolicies { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listByDatabaseWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, parameters: models.JobAgent, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets a database's long term retention policy. + * Creates or updates a job agent. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -17284,7 +17426,32 @@ export interface BackupLongTermRetentionPolicies { * * @param {string} serverName The name of the server. * - * @param {string} databaseName The name of the database. + * @param {string} jobAgentName The name of the job agent to be created or + * updated. + * + * @param {object} parameters The requested job agent resource state. + * + * @param {object} [parameters.sku] The name and tier of the SKU. + * + * @param {string} parameters.sku.name The name of the SKU, typically, a letter + * + Number code, e.g. P3. + * + * @param {string} [parameters.sku.tier] The tier of the particular SKU, e.g. + * Basic, Premium. + * + * @param {string} [parameters.sku.size] Size of the particular SKU + * + * @param {string} [parameters.sku.family] If the service has different + * generations of hardware, for the same SKU, then that can be captured here. + * + * @param {number} [parameters.sku.capacity] Capacity of the particular SKU. + * + * @param {string} parameters.databaseId Resource ID of the database to store + * job metadata in. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location Resource location. * * @param {object} [options] Optional Parameters. * @@ -17298,7 +17465,7 @@ export interface BackupLongTermRetentionPolicies { * * {Promise} A promise is returned. * - * @resolve {BackupLongTermRetentionPolicy} - The deserialized result object. + * @resolve {JobAgent} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -17306,21 +17473,20 @@ export interface BackupLongTermRetentionPolicies { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {BackupLongTermRetentionPolicy} [result] - The deserialized result object if an error did not occur. - * See {@link BackupLongTermRetentionPolicy} for more - * information. + * {JobAgent} [result] - The deserialized result object if an error did not occur. + * See {@link JobAgent} 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. */ - listByDatabase(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByDatabase(resourceGroupName: string, serverName: string, databaseName: string, callback: ServiceCallback): void; - listByDatabase(resourceGroupName: string, serverName: string, databaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + beginCreateOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, parameters: models.JobAgent, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginCreateOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, parameters: models.JobAgent, callback: ServiceCallback): void; + beginCreateOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, parameters: models.JobAgent, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Sets a database's long term retention policy. + * Deletes a job agent. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -17328,21 +17494,7 @@ export interface BackupLongTermRetentionPolicies { * * @param {string} serverName The name of the server. * - * @param {string} databaseName The name of the database. - * - * @param {object} parameters The long term retention policy info. - * - * @param {string} [parameters.weeklyRetention] The weekly retention policy for - * an LTR backup in an ISO 8601 format. - * - * @param {string} [parameters.monthlyRetention] The montly retention policy - * for an LTR backup in an ISO 8601 format. - * - * @param {string} [parameters.yearlyRetention] The yearly retention policy for - * an LTR backup in an ISO 8601 format. - * - * @param {number} [parameters.weekOfYear] The week of year to take the yearly - * backup in an ISO 8601 format. + * @param {string} jobAgentName The name of the job agent to be deleted. * * @param {object} [options] Optional Parameters. * @@ -17351,14 +17503,14 @@ export interface BackupLongTermRetentionPolicies { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.BackupLongTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + beginDeleteMethodWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Sets a database's long term retention policy. + * Deletes a job agent. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -17366,21 +17518,81 @@ export interface BackupLongTermRetentionPolicies { * * @param {string} serverName The name of the server. * - * @param {string} databaseName The name of the database. + * @param {string} jobAgentName The name of the job agent to be deleted. * - * @param {object} parameters The long term retention policy info. + * @param {object} [options] Optional Parameters. * - * @param {string} [parameters.weeklyRetention] The weekly retention policy for - * an LTR backup in an ISO 8601 format. + * @param {object} [options.customHeaders] Headers that will be added to the + * request * - * @param {string} [parameters.monthlyRetention] The montly retention policy - * for an LTR backup in an ISO 8601 format. + * @param {ServiceCallback} [optionalCallback] - The optional callback. * - * @param {string} [parameters.yearlyRetention] The yearly retention policy for - * an LTR backup in an ISO 8601 format. + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. * - * @param {number} [parameters.weekOfYear] The week of year to take the yearly - * backup in an ISO 8601 format. + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + beginDeleteMethod(resourceGroupName: string, serverName: string, jobAgentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginDeleteMethod(resourceGroupName: string, serverName: string, jobAgentName: string, callback: ServiceCallback): void; + beginDeleteMethod(resourceGroupName: string, serverName: string, jobAgentName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Updates a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be updated. + * + * @param {object} parameters The update to the job agent. + * + * @param {object} [parameters.tags] Resource tags. + * + * @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. + */ + beginUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, parameters: models.JobAgentUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Updates a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be updated. + * + * @param {object} parameters The update to the job agent. + * + * @param {object} [parameters.tags] Resource tags. * * @param {object} [options] Optional Parameters. * @@ -17394,7 +17606,7 @@ export interface BackupLongTermRetentionPolicies { * * {Promise} A promise is returned. * - * @resolve {BackupLongTermRetentionPolicy} - The deserialized result object. + * @resolve {JobAgent} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -17402,41 +17614,23 @@ export interface BackupLongTermRetentionPolicies { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {BackupLongTermRetentionPolicy} [result] - The deserialized result object if an error did not occur. - * See {@link BackupLongTermRetentionPolicy} for more - * information. + * {JobAgent} [result] - The deserialized result object if an error did not occur. + * See {@link JobAgent} 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. */ - beginCreateOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.BackupLongTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - beginCreateOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.BackupLongTermRetentionPolicy, callback: ServiceCallback): void; - beginCreateOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.BackupLongTermRetentionPolicy, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; -} - -/** - * @class - * ManagedDatabases - * __NOTE__: An instance of this class is automatically created for an - * instance of the SqlManagementClient. - */ -export interface ManagedDatabases { + beginUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, parameters: models.JobAgentUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, parameters: models.JobAgentUpdate, callback: ServiceCallback): void; + beginUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, parameters: models.JobAgentUpdate, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Completes the restore operation on a managed database. - * - * @param {string} locationName The name of the region where the resource is - * located. + * Gets a list of job agents in a server. * - * @param {uuid} operationId Management operation id that this request tries to - * complete. - * - * @param {object} parameters The definition for completing the restore of this - * managed database. - * - * @param {string} parameters.lastBackupName The last backup name to apply + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. * * @param {object} [options] Optional Parameters. * @@ -17445,25 +17639,17 @@ export interface ManagedDatabases { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - completeRestoreWithHttpOperationResponse(locationName: string, operationId: string, parameters: models.CompleteDatabaseRestoreDefinition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listByServerNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Completes the restore operation on a managed database. - * - * @param {string} locationName The name of the region where the resource is - * located. - * - * @param {uuid} operationId Management operation id that this request tries to - * complete. - * - * @param {object} parameters The definition for completing the restore of this - * managed database. + * Gets a list of job agents in a server. * - * @param {string} parameters.lastBackupName The last backup name to apply + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. * * @param {object} [options] Optional Parameters. * @@ -17477,7 +17663,7 @@ export interface ManagedDatabases { * * {Promise} A promise is returned. * - * @resolve {null} - The deserialized result object. + * @resolve {JobAgentListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -17485,25 +17671,37 @@ export interface ManagedDatabases { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {null} [result] - The deserialized result object if an error did not occur. + * {JobAgentListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobAgentListResult} 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. */ - completeRestore(locationName: string, operationId: string, parameters: models.CompleteDatabaseRestoreDefinition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - completeRestore(locationName: string, operationId: string, parameters: models.CompleteDatabaseRestoreDefinition, callback: ServiceCallback): void; - completeRestore(locationName: string, operationId: string, parameters: models.CompleteDatabaseRestoreDefinition, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + listByServerNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByServerNext(nextPageLink: string, callback: ServiceCallback): void; + listByServerNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * JobCredentials + * __NOTE__: An instance of this class is automatically created for an + * instance of the SqlManagementClient. + */ +export interface JobCredentials { /** - * Gets a list of managed databases. + * Gets a list of jobs credentials. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} managedInstanceName The name of the managed instance. + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. * * @param {object} [options] Optional Parameters. * @@ -17512,20 +17710,22 @@ export interface ManagedDatabases { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listByInstanceWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listByAgentWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets a list of managed databases. + * Gets a list of jobs credentials. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} managedInstanceName The name of the managed instance. + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. * * @param {object} [options] Optional Parameters. * @@ -17539,7 +17739,7 @@ export interface ManagedDatabases { * * {Promise} A promise is returned. * - * @resolve {ManagedDatabaseListResult} - The deserialized result object. + * @resolve {JobCredentialListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -17547,29 +17747,31 @@ export interface ManagedDatabases { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {ManagedDatabaseListResult} [result] - The deserialized result object if an error did not occur. - * See {@link ManagedDatabaseListResult} for more + * {JobCredentialListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobCredentialListResult} 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. */ - listByInstance(resourceGroupName: string, managedInstanceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByInstance(resourceGroupName: string, managedInstanceName: string, callback: ServiceCallback): void; - listByInstance(resourceGroupName: string, managedInstanceName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + listByAgent(resourceGroupName: string, serverName: string, jobAgentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByAgent(resourceGroupName: string, serverName: string, jobAgentName: string, callback: ServiceCallback): void; + listByAgent(resourceGroupName: string, serverName: string, jobAgentName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Gets a managed database. + * Gets a jobs credential. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} managedInstanceName The name of the managed instance. + * @param {string} serverName The name of the server. * - * @param {string} databaseName The name of the database. + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} credentialName The name of the credential. * * @param {object} [options] Optional Parameters. * @@ -17578,22 +17780,24 @@ export interface ManagedDatabases { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - getWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + getWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, credentialName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets a managed database. + * Gets a jobs credential. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} managedInstanceName The name of the managed instance. + * @param {string} serverName The name of the server. * - * @param {string} databaseName The name of the database. + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} credentialName The name of the credential. * * @param {object} [options] Optional Parameters. * @@ -17607,7 +17811,7 @@ export interface ManagedDatabases { * * {Promise} A promise is returned. * - * @resolve {ManagedDatabase} - The deserialized result object. + * @resolve {JobCredential} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -17615,64 +17819,36 @@ export interface ManagedDatabases { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {ManagedDatabase} [result] - The deserialized result object if an error did not occur. - * See {@link ManagedDatabase} for more information. + * {JobCredential} [result] - The deserialized result object if an error did not occur. + * See {@link JobCredential} for more information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - get(resourceGroupName: string, managedInstanceName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - get(resourceGroupName: string, managedInstanceName: string, databaseName: string, callback: ServiceCallback): void; - get(resourceGroupName: string, managedInstanceName: string, databaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, jobAgentName: string, credentialName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, serverName: string, jobAgentName: string, credentialName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, jobAgentName: string, credentialName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Creates a new database or updates an existing database. + * Creates or updates a job credential. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} managedInstanceName The name of the managed instance. - * - * @param {string} databaseName The name of the database. - * - * @param {object} parameters The requested database resource state. - * - * @param {string} [parameters.collation] Collation of the managed database. - * - * @param {date} [parameters.restorePointInTime] Conditional. If createMode is - * PointInTimeRestore, this value is required. Specifies the point in time - * (ISO8601 format) of the source database that will be restored to create the - * new database. - * - * @param {string} [parameters.catalogCollation] Collation of the metadata - * catalog. Possible values include: 'DATABASE_DEFAULT', - * 'SQL_Latin1_General_CP1_CI_AS' - * - * @param {string} [parameters.createMode] Managed database create mode. - * PointInTimeRestore: Create a database by restoring a point in time backup of - * an existing database. SourceDatabaseName, SourceManagedInstanceName and - * PointInTime must be specified. RestoreExternalBackup: Create a database by - * restoring from external backup files. Collation, StorageContainerUri and - * StorageContainerSasToken must be specified. Possible values include: - * 'Default', 'RestoreExternalBackup', 'PointInTimeRestore' + * @param {string} serverName The name of the server. * - * @param {string} [parameters.storageContainerUri] Conditional. If createMode - * is RestoreExternalBackup, this value is required. Specifies the uri of the - * storage container where backups for this restore are stored. + * @param {string} jobAgentName The name of the job agent. * - * @param {string} [parameters.sourceDatabaseId] The resource identifier of the - * source database associated with create operation of this database. + * @param {string} credentialName The name of the credential. * - * @param {string} [parameters.storageContainerSasToken] Conditional. If - * createMode is RestoreExternalBackup, this value is required. Specifies the - * storage container sas token. + * @param {object} parameters The requested job credential state. * - * @param {object} [parameters.tags] Resource tags. + * @param {string} parameters.username The credential user name. * - * @param {string} parameters.location Resource location. + * @param {string} parameters.password The credential password. * * @param {object} [options] Optional Parameters. * @@ -17681,58 +17857,30 @@ export interface ManagedDatabases { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - createOrUpdateWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabase, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, credentialName: string, parameters: models.JobCredential, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Creates a new database or updates an existing database. + * Creates or updates a job credential. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} managedInstanceName The name of the managed instance. - * - * @param {string} databaseName The name of the database. - * - * @param {object} parameters The requested database resource state. - * - * @param {string} [parameters.collation] Collation of the managed database. - * - * @param {date} [parameters.restorePointInTime] Conditional. If createMode is - * PointInTimeRestore, this value is required. Specifies the point in time - * (ISO8601 format) of the source database that will be restored to create the - * new database. - * - * @param {string} [parameters.catalogCollation] Collation of the metadata - * catalog. Possible values include: 'DATABASE_DEFAULT', - * 'SQL_Latin1_General_CP1_CI_AS' - * - * @param {string} [parameters.createMode] Managed database create mode. - * PointInTimeRestore: Create a database by restoring a point in time backup of - * an existing database. SourceDatabaseName, SourceManagedInstanceName and - * PointInTime must be specified. RestoreExternalBackup: Create a database by - * restoring from external backup files. Collation, StorageContainerUri and - * StorageContainerSasToken must be specified. Possible values include: - * 'Default', 'RestoreExternalBackup', 'PointInTimeRestore' + * @param {string} serverName The name of the server. * - * @param {string} [parameters.storageContainerUri] Conditional. If createMode - * is RestoreExternalBackup, this value is required. Specifies the uri of the - * storage container where backups for this restore are stored. + * @param {string} jobAgentName The name of the job agent. * - * @param {string} [parameters.sourceDatabaseId] The resource identifier of the - * source database associated with create operation of this database. + * @param {string} credentialName The name of the credential. * - * @param {string} [parameters.storageContainerSasToken] Conditional. If - * createMode is RestoreExternalBackup, this value is required. Specifies the - * storage container sas token. + * @param {object} parameters The requested job credential state. * - * @param {object} [parameters.tags] Resource tags. + * @param {string} parameters.username The credential user name. * - * @param {string} parameters.location Resource location. + * @param {string} parameters.password The credential password. * * @param {object} [options] Optional Parameters. * @@ -17746,7 +17894,7 @@ export interface ManagedDatabases { * * {Promise} A promise is returned. * - * @resolve {ManagedDatabase} - The deserialized result object. + * @resolve {JobCredential} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -17754,28 +17902,30 @@ export interface ManagedDatabases { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {ManagedDatabase} [result] - The deserialized result object if an error did not occur. - * See {@link ManagedDatabase} for more information. + * {JobCredential} [result] - The deserialized result object if an error did not occur. + * See {@link JobCredential} for more information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - createOrUpdate(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabase, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - createOrUpdate(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabase, callback: ServiceCallback): void; - createOrUpdate(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabase, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, credentialName: string, parameters: models.JobCredential, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, credentialName: string, parameters: models.JobCredential, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, credentialName: string, parameters: models.JobCredential, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Deletes the managed database. + * Deletes a job credential. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} managedInstanceName The name of the managed instance. + * @param {string} serverName The name of the server. * - * @param {string} databaseName The name of the database. + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} credentialName The name of the credential. * * @param {object} [options] Optional Parameters. * @@ -17788,18 +17938,20 @@ export interface ManagedDatabases { * * @reject {Error|ServiceError} - The error object. */ - deleteMethodWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + deleteMethodWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, credentialName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Deletes the managed database. + * Deletes a job credential. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} managedInstanceName The name of the managed instance. + * @param {string} serverName The name of the server. * - * @param {string} databaseName The name of the database. + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} credentialName The name of the credential. * * @param {object} [options] Optional Parameters. * @@ -17827,55 +17979,5441 @@ export interface ManagedDatabases { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - deleteMethod(resourceGroupName: string, managedInstanceName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - deleteMethod(resourceGroupName: string, managedInstanceName: string, databaseName: string, callback: ServiceCallback): void; - deleteMethod(resourceGroupName: string, managedInstanceName: string, databaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, serverName: string, jobAgentName: string, credentialName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, serverName: string, jobAgentName: string, credentialName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, serverName: string, jobAgentName: string, credentialName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Updates an existing database. + * Gets a list of jobs credentials. * - * @param {string} resourceGroupName The name of the resource group that - * contains the resource. You can obtain this value from the Azure Resource - * Manager API or the portal. + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. * - * @param {string} managedInstanceName The name of the managed instance. + * @param {object} [options] Optional Parameters. * - * @param {string} databaseName The name of the database. + * @param {object} [options.customHeaders] Headers that will be added to the + * request * - * @param {object} parameters The requested database resource state. + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByAgentNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a list of jobs credentials. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {JobCredentialListResult} - 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. + * + * {JobCredentialListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobCredentialListResult} 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. + */ + listByAgentNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByAgentNext(nextPageLink: string, callback: ServiceCallback): void; + listByAgentNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * JobExecutions + * __NOTE__: An instance of this class is automatically created for an + * instance of the SqlManagementClient. + */ +export interface JobExecutions { + + + /** + * Lists all executions in a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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. + */ + listByAgentWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, options?: { createTimeMin? : Date, createTimeMax? : Date, endTimeMin? : Date, endTimeMax? : Date, isActive? : boolean, skip? : number, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all executions in a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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 {JobExecutionListResult} - 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. + * + * {JobExecutionListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobExecutionListResult} 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. + */ + listByAgent(resourceGroupName: string, serverName: string, jobAgentName: string, options?: { createTimeMin? : Date, createTimeMax? : Date, endTimeMin? : Date, endTimeMax? : Date, isActive? : boolean, skip? : number, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; + listByAgent(resourceGroupName: string, serverName: string, jobAgentName: string, callback: ServiceCallback): void; + listByAgent(resourceGroupName: string, serverName: string, jobAgentName: string, options: { createTimeMin? : Date, createTimeMax? : Date, endTimeMin? : Date, endTimeMax? : Date, isActive? : boolean, skip? : number, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Requests cancellation of a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {uuid} jobExecutionId The id of the job execution to cancel. + * + * @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. + */ + cancelWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Requests cancellation of a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {uuid} jobExecutionId The id of the job execution to cancel. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + cancel(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + cancel(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, callback: ServiceCallback): void; + cancel(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Starts an elastic job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @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. + */ + createWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Starts an elastic job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @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 {JobExecution} - 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. + * + * {JobExecution} [result] - The deserialized result object if an error did not occur. + * See {@link JobExecution} 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. + */ + create(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + create(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, callback: ServiceCallback): void; + create(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists a job's executions. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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. + */ + listByJobWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, options?: { createTimeMin? : Date, createTimeMax? : Date, endTimeMin? : Date, endTimeMax? : Date, isActive? : boolean, skip? : number, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists a job's executions. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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 {JobExecutionListResult} - 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. + * + * {JobExecutionListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobExecutionListResult} 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. + */ + listByJob(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, options?: { createTimeMin? : Date, createTimeMax? : Date, endTimeMin? : Date, endTimeMax? : Date, isActive? : boolean, skip? : number, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; + listByJob(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, callback: ServiceCallback): void; + listByJob(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, options: { createTimeMin? : Date, createTimeMax? : Date, endTimeMin? : Date, endTimeMax? : Date, isActive? : boolean, skip? : number, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {uuid} jobExecutionId The id of the job execution + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {uuid} jobExecutionId The id of the job execution + * + * @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 {JobExecution} - 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. + * + * {JobExecution} [result] - The deserialized result object if an error did not occur. + * See {@link JobExecution} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Creates or updatess a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The job execution id to create the job + * execution under. + * + * @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. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Creates or updatess a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The job execution id to create the job + * execution under. + * + * @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 {JobExecution} - 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. + * + * {JobExecution} [result] - The deserialized result object if an error did not occur. + * See {@link JobExecution} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Starts an elastic job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @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. + */ + beginCreateWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Starts an elastic job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @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 {JobExecution} - 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. + * + * {JobExecution} [result] - The deserialized result object if an error did not occur. + * See {@link JobExecution} 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. + */ + beginCreate(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginCreate(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, callback: ServiceCallback): void; + beginCreate(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Creates or updatess a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The job execution id to create the job + * execution under. + * + * @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. + */ + beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Creates or updatess a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The job execution id to create the job + * execution under. + * + * @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 {JobExecution} - 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. + * + * {JobExecution} [result] - The deserialized result object if an error did not occur. + * See {@link JobExecution} 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. + */ + beginCreateOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginCreateOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, callback: ServiceCallback): void; + beginCreateOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all executions in a job agent. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByAgentNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all executions in a job agent. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {JobExecutionListResult} - 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. + * + * {JobExecutionListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobExecutionListResult} 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. + */ + listByAgentNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByAgentNext(nextPageLink: string, callback: ServiceCallback): void; + listByAgentNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists a job's executions. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByJobNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists a job's executions. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {JobExecutionListResult} - 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. + * + * {JobExecutionListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobExecutionListResult} 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. + */ + listByJobNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByJobNext(nextPageLink: string, callback: ServiceCallback): void; + listByJobNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * Jobs + * __NOTE__: An instance of this class is automatically created for an + * instance of the SqlManagementClient. + */ +export interface Jobs { + + + /** + * Gets a list of jobs. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @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. + */ + listByAgentWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a list of jobs. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @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 {JobListResult} - 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. + * + * {JobListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobListResult} 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. + */ + listByAgent(resourceGroupName: string, serverName: string, jobAgentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByAgent(resourceGroupName: string, serverName: string, jobAgentName: string, callback: ServiceCallback): void; + listByAgent(resourceGroupName: string, serverName: string, jobAgentName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets a job. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a job. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @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 {Job} - 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. + * + * {Job} [result] - The deserialized result object if an error did not occur. + * See {@link Job} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Creates or updates a job. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {object} parameters The requested job state. + * + * @param {string} [parameters.description] User-defined description of the + * job. + * + * @param {object} [parameters.schedule] Schedule properties of the job. + * + * @param {date} [parameters.schedule.startTime] Schedule start time. + * + * @param {date} [parameters.schedule.endTime] Schedule end time. + * + * @param {string} [parameters.schedule.type] Schedule interval type. Possible + * values include: 'Once', 'Recurring' + * + * @param {boolean} [parameters.schedule.enabled] Whether or not the schedule + * is enabled. + * + * @param {string} [parameters.schedule.interval] Value of the schedule's + * recurring interval, if the scheduletype is recurring. ISO8601 duration + * format. + * + * @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. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, parameters: models.Job, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Creates or updates a job. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {object} parameters The requested job state. + * + * @param {string} [parameters.description] User-defined description of the + * job. + * + * @param {object} [parameters.schedule] Schedule properties of the job. + * + * @param {date} [parameters.schedule.startTime] Schedule start time. + * + * @param {date} [parameters.schedule.endTime] Schedule end time. + * + * @param {string} [parameters.schedule.type] Schedule interval type. Possible + * values include: 'Once', 'Recurring' + * + * @param {boolean} [parameters.schedule.enabled] Whether or not the schedule + * is enabled. + * + * @param {string} [parameters.schedule.interval] Value of the schedule's + * recurring interval, if the scheduletype is recurring. ISO8601 duration + * format. + * + * @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 {Job} - 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. + * + * {Job} [result] - The deserialized result object if an error did not occur. + * See {@link Job} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, parameters: models.Job, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, parameters: models.Job, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, parameters: models.Job, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes a job. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to delete. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes a job. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to delete. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets a list of jobs. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByAgentNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a list of jobs. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {JobListResult} - 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. + * + * {JobListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobListResult} 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. + */ + listByAgentNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByAgentNext(nextPageLink: string, callback: ServiceCallback): void; + listByAgentNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * JobStepExecutions + * __NOTE__: An instance of this class is automatically created for an + * instance of the SqlManagementClient. + */ +export interface JobStepExecutions { + + + /** + * Lists the step executions of a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The id of the job execution + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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. + */ + listByJobExecutionWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, options?: { createTimeMin? : Date, createTimeMax? : Date, endTimeMin? : Date, endTimeMax? : Date, isActive? : boolean, skip? : number, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the step executions of a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The id of the job execution + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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 {JobExecutionListResult} - 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. + * + * {JobExecutionListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobExecutionListResult} 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. + */ + listByJobExecution(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, options?: { createTimeMin? : Date, createTimeMax? : Date, endTimeMin? : Date, endTimeMax? : Date, isActive? : boolean, skip? : number, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; + listByJobExecution(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, callback: ServiceCallback): void; + listByJobExecution(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, options: { createTimeMin? : Date, createTimeMax? : Date, endTimeMin? : Date, endTimeMax? : Date, isActive? : boolean, skip? : number, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets a step execution of a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The unique id of the job execution + * + * @param {string} stepName The name of the step. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, stepName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a step execution of a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The unique id of the job execution + * + * @param {string} stepName The name of the step. + * + * @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 {JobExecution} - 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. + * + * {JobExecution} [result] - The deserialized result object if an error did not occur. + * See {@link JobExecution} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, stepName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, stepName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, stepName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the step executions of a job execution. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByJobExecutionNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the step executions of a job execution. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {JobExecutionListResult} - 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. + * + * {JobExecutionListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobExecutionListResult} 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. + */ + listByJobExecutionNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByJobExecutionNext(nextPageLink: string, callback: ServiceCallback): void; + listByJobExecutionNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * JobSteps + * __NOTE__: An instance of this class is automatically created for an + * instance of the SqlManagementClient. + */ +export interface JobSteps { + + + /** + * Gets all job steps in the specified job version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {number} jobVersion The version of the job to get. + * + * @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. + */ + listByVersionWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobVersion: number, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets all job steps in the specified job version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {number} jobVersion The version of the job to get. + * + * @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 {JobStepListResult} - 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. + * + * {JobStepListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobStepListResult} 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. + */ + listByVersion(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobVersion: number, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByVersion(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobVersion: number, callback: ServiceCallback): void; + listByVersion(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobVersion: number, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets the specified version of a job step. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {number} jobVersion The version of the job to get. + * + * @param {string} stepName The name of the job step. + * + * @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. + */ + getByVersionWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobVersion: number, stepName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the specified version of a job step. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {number} jobVersion The version of the job to get. + * + * @param {string} stepName The name of the job step. + * + * @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 {JobStep} - 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. + * + * {JobStep} [result] - The deserialized result object if an error did not occur. + * See {@link JobStep} 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. + */ + getByVersion(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobVersion: number, stepName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getByVersion(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobVersion: number, stepName: string, callback: ServiceCallback): void; + getByVersion(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobVersion: number, stepName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets all job steps for a job's current version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @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. + */ + listByJobWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets all job steps for a job's current version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @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 {JobStepListResult} - 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. + * + * {JobStepListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobStepListResult} 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. + */ + listByJob(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByJob(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, callback: ServiceCallback): void; + listByJob(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets a job step in a job's current version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {string} stepName The name of the job step. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, stepName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a job step in a job's current version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {string} stepName The name of the job step. + * + * @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 {JobStep} - 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. + * + * {JobStep} [result] - The deserialized result object if an error did not occur. + * See {@link JobStep} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, stepName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, stepName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, stepName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Creates or updates a job step. This will implicitly create a new job + * version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {string} stepName The name of the job step. + * + * @param {object} parameters The requested state of the job step. + * + * @param {number} [parameters.stepId] The job step's index within the job. If + * not specified when creating the job step, it will be created as the last + * step. If not specified when updating the job step, the step id is not + * modified. + * + * @param {string} parameters.targetGroup The resource ID of the target group + * that the job step will be executed on. + * + * @param {string} parameters.credential The resource ID of the job credential + * that will be used to connect to the targets. + * + * @param {object} parameters.action The action payload of the job step. + * + * @param {string} [parameters.action.type] Type of action being executed by + * the job step. Possible values include: 'TSql' + * + * @param {string} [parameters.action.source] The source of the action to + * execute. Possible values include: 'Inline' + * + * @param {string} parameters.action.value The action value, for example the + * text of the T-SQL script to execute. + * + * @param {object} [parameters.output] Output destination properties of the job + * step. + * + * @param {string} [parameters.output.type] The output destination type. + * Possible values include: 'SqlDatabase' + * + * @param {uuid} [parameters.output.subscriptionId] The output destination + * subscription id. + * + * @param {string} [parameters.output.resourceGroupName] The output destination + * resource group. + * + * @param {string} parameters.output.serverName The output destination server + * name. + * + * @param {string} parameters.output.databaseName The output destination + * database. + * + * @param {string} [parameters.output.schemaName] The output destination + * schema. + * + * @param {string} parameters.output.tableName The output destination table. + * + * @param {string} parameters.output.credential The resource ID of the + * credential to use to connect to the output destination. + * + * @param {object} [parameters.executionOptions] Execution options for the job + * step. + * + * @param {number} [parameters.executionOptions.timeoutSeconds] Execution + * timeout for the job step. + * + * @param {number} [parameters.executionOptions.retryAttempts] Maximum number + * of times the job step will be reattempted if the first attempt fails. + * + * @param {number} [parameters.executionOptions.initialRetryIntervalSeconds] + * Initial delay between retries for job step execution. + * + * @param {number} [parameters.executionOptions.maximumRetryIntervalSeconds] + * The maximum amount of time to wait between retries for job step execution. + * + * @param {number} [parameters.executionOptions.retryIntervalBackoffMultiplier] + * The backoff multiplier for the time between retries. + * + * @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. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, stepName: string, parameters: models.JobStep, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Creates or updates a job step. This will implicitly create a new job + * version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {string} stepName The name of the job step. + * + * @param {object} parameters The requested state of the job step. + * + * @param {number} [parameters.stepId] The job step's index within the job. If + * not specified when creating the job step, it will be created as the last + * step. If not specified when updating the job step, the step id is not + * modified. + * + * @param {string} parameters.targetGroup The resource ID of the target group + * that the job step will be executed on. + * + * @param {string} parameters.credential The resource ID of the job credential + * that will be used to connect to the targets. + * + * @param {object} parameters.action The action payload of the job step. + * + * @param {string} [parameters.action.type] Type of action being executed by + * the job step. Possible values include: 'TSql' + * + * @param {string} [parameters.action.source] The source of the action to + * execute. Possible values include: 'Inline' + * + * @param {string} parameters.action.value The action value, for example the + * text of the T-SQL script to execute. + * + * @param {object} [parameters.output] Output destination properties of the job + * step. + * + * @param {string} [parameters.output.type] The output destination type. + * Possible values include: 'SqlDatabase' + * + * @param {uuid} [parameters.output.subscriptionId] The output destination + * subscription id. + * + * @param {string} [parameters.output.resourceGroupName] The output destination + * resource group. + * + * @param {string} parameters.output.serverName The output destination server + * name. + * + * @param {string} parameters.output.databaseName The output destination + * database. + * + * @param {string} [parameters.output.schemaName] The output destination + * schema. + * + * @param {string} parameters.output.tableName The output destination table. + * + * @param {string} parameters.output.credential The resource ID of the + * credential to use to connect to the output destination. + * + * @param {object} [parameters.executionOptions] Execution options for the job + * step. + * + * @param {number} [parameters.executionOptions.timeoutSeconds] Execution + * timeout for the job step. + * + * @param {number} [parameters.executionOptions.retryAttempts] Maximum number + * of times the job step will be reattempted if the first attempt fails. + * + * @param {number} [parameters.executionOptions.initialRetryIntervalSeconds] + * Initial delay between retries for job step execution. + * + * @param {number} [parameters.executionOptions.maximumRetryIntervalSeconds] + * The maximum amount of time to wait between retries for job step execution. + * + * @param {number} [parameters.executionOptions.retryIntervalBackoffMultiplier] + * The backoff multiplier for the time between retries. + * + * @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 {JobStep} - 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. + * + * {JobStep} [result] - The deserialized result object if an error did not occur. + * See {@link JobStep} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, stepName: string, parameters: models.JobStep, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, stepName: string, parameters: models.JobStep, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, stepName: string, parameters: models.JobStep, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes a job step. This will implicitly create a new job version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {string} stepName The name of the job step to delete. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, stepName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes a job step. This will implicitly create a new job version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {string} stepName The name of the job step to delete. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, stepName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, stepName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, stepName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets all job steps in the specified job version. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByVersionNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets all job steps in the specified job version. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {JobStepListResult} - 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. + * + * {JobStepListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobStepListResult} 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. + */ + listByVersionNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByVersionNext(nextPageLink: string, callback: ServiceCallback): void; + listByVersionNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets all job steps for a job's current version. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByJobNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets all job steps for a job's current version. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {JobStepListResult} - 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. + * + * {JobStepListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobStepListResult} 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. + */ + listByJobNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByJobNext(nextPageLink: string, callback: ServiceCallback): void; + listByJobNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * JobTargetExecutions + * __NOTE__: An instance of this class is automatically created for an + * instance of the SqlManagementClient. + */ +export interface JobTargetExecutions { + + + /** + * Lists target executions for all steps of a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The id of the job execution + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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. + */ + listByJobExecutionWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, options?: { createTimeMin? : Date, createTimeMax? : Date, endTimeMin? : Date, endTimeMax? : Date, isActive? : boolean, skip? : number, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists target executions for all steps of a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The id of the job execution + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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 {JobExecutionListResult} - 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. + * + * {JobExecutionListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobExecutionListResult} 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. + */ + listByJobExecution(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, options?: { createTimeMin? : Date, createTimeMax? : Date, endTimeMin? : Date, endTimeMax? : Date, isActive? : boolean, skip? : number, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; + listByJobExecution(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, callback: ServiceCallback): void; + listByJobExecution(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, options: { createTimeMin? : Date, createTimeMax? : Date, endTimeMin? : Date, endTimeMax? : Date, isActive? : boolean, skip? : number, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the target executions of a job step execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The id of the job execution + * + * @param {string} stepName The name of the step. + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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. + */ + listByStepWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, stepName: string, options?: { createTimeMin? : Date, createTimeMax? : Date, endTimeMin? : Date, endTimeMax? : Date, isActive? : boolean, skip? : number, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the target executions of a job step execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The id of the job execution + * + * @param {string} stepName The name of the step. + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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 {JobExecutionListResult} - 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. + * + * {JobExecutionListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobExecutionListResult} 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. + */ + listByStep(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, stepName: string, options?: { createTimeMin? : Date, createTimeMax? : Date, endTimeMin? : Date, endTimeMax? : Date, isActive? : boolean, skip? : number, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; + listByStep(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, stepName: string, callback: ServiceCallback): void; + listByStep(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, stepName: string, options: { createTimeMin? : Date, createTimeMax? : Date, endTimeMin? : Date, endTimeMax? : Date, isActive? : boolean, skip? : number, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets a target execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The unique id of the job execution + * + * @param {string} stepName The name of the step. + * + * @param {uuid} targetId The target id. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, stepName: string, targetId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a target execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The unique id of the job execution + * + * @param {string} stepName The name of the step. + * + * @param {uuid} targetId The target id. + * + * @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 {JobExecution} - 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. + * + * {JobExecution} [result] - The deserialized result object if an error did not occur. + * See {@link JobExecution} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, stepName: string, targetId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, stepName: string, targetId: string, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobExecutionId: string, stepName: string, targetId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists target executions for all steps of a job execution. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByJobExecutionNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists target executions for all steps of a job execution. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {JobExecutionListResult} - 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. + * + * {JobExecutionListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobExecutionListResult} 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. + */ + listByJobExecutionNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByJobExecutionNext(nextPageLink: string, callback: ServiceCallback): void; + listByJobExecutionNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the target executions of a job step execution. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByStepNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the target executions of a job step execution. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {JobExecutionListResult} - 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. + * + * {JobExecutionListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobExecutionListResult} 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. + */ + listByStepNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByStepNext(nextPageLink: string, callback: ServiceCallback): void; + listByStepNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * JobTargetGroups + * __NOTE__: An instance of this class is automatically created for an + * instance of the SqlManagementClient. + */ +export interface JobTargetGroups { + + + /** + * Gets all target groups in an agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @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. + */ + listByAgentWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets all target groups in an agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @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 {JobTargetGroupListResult} - 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. + * + * {JobTargetGroupListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobTargetGroupListResult} 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. + */ + listByAgent(resourceGroupName: string, serverName: string, jobAgentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByAgent(resourceGroupName: string, serverName: string, jobAgentName: string, callback: ServiceCallback): void; + listByAgent(resourceGroupName: string, serverName: string, jobAgentName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets a target group. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} targetGroupName The name of the target group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, targetGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a target group. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} targetGroupName The name of the target group. + * + * @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 {JobTargetGroup} - 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. + * + * {JobTargetGroup} [result] - The deserialized result object if an error did not occur. + * See {@link JobTargetGroup} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, serverName: string, jobAgentName: string, targetGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, serverName: string, jobAgentName: string, targetGroupName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, jobAgentName: string, targetGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Creates or updates a target group. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} targetGroupName The name of the target group. + * + * @param {object} parameters The requested state of the target group. + * + * @param {array} parameters.members Members of the target group. + * + * @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. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, targetGroupName: string, parameters: models.JobTargetGroup, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Creates or updates a target group. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} targetGroupName The name of the target group. + * + * @param {object} parameters The requested state of the target group. + * + * @param {array} parameters.members Members of the target group. + * + * @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 {JobTargetGroup} - 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. + * + * {JobTargetGroup} [result] - The deserialized result object if an error did not occur. + * See {@link JobTargetGroup} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, targetGroupName: string, parameters: models.JobTargetGroup, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, targetGroupName: string, parameters: models.JobTargetGroup, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, serverName: string, jobAgentName: string, targetGroupName: string, parameters: models.JobTargetGroup, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes a target group. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} targetGroupName The name of the target group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, targetGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes a target group. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} targetGroupName The name of the target group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName: string, serverName: string, jobAgentName: string, targetGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, serverName: string, jobAgentName: string, targetGroupName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, serverName: string, jobAgentName: string, targetGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets all target groups in an agent. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByAgentNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets all target groups in an agent. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {JobTargetGroupListResult} - 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. + * + * {JobTargetGroupListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobTargetGroupListResult} 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. + */ + listByAgentNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByAgentNext(nextPageLink: string, callback: ServiceCallback): void; + listByAgentNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * JobVersions + * __NOTE__: An instance of this class is automatically created for an + * instance of the SqlManagementClient. + */ +export interface JobVersions { + + + /** + * Gets all versions of a job. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @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. + */ + listByJobWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets all versions of a job. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @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 {JobVersionListResult} - 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. + * + * {JobVersionListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobVersionListResult} 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. + */ + listByJob(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByJob(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, callback: ServiceCallback): void; + listByJob(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets a job version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {number} jobVersion The version of the job to get. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobVersion: number, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a job version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {number} jobVersion The version of the job to get. + * + * @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 {JobVersion} - 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. + * + * {JobVersion} [result] - The deserialized result object if an error did not occur. + * See {@link JobVersion} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobVersion: number, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobVersion: number, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, jobAgentName: string, jobName: string, jobVersion: number, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets all versions of a job. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByJobNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets all versions of a job. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {JobVersionListResult} - 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. + * + * {JobVersionListResult} [result] - The deserialized result object if an error did not occur. + * See {@link JobVersionListResult} 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. + */ + listByJobNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByJobNext(nextPageLink: string, callback: ServiceCallback): void; + listByJobNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * LongTermRetentionBackups + * __NOTE__: An instance of this class is automatically created for an + * instance of the SqlManagementClient. + */ +export interface LongTermRetentionBackups { + + + /** + * Gets a long term retention backup. + * + * @param {string} locationName The location of the database. + * + * @param {string} longTermRetentionServerName + * + * @param {string} longTermRetentionDatabaseName + * + * @param {string} backupName The backup 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. + */ + getWithHttpOperationResponse(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a long term retention backup. + * + * @param {string} locationName The location of the database. + * + * @param {string} longTermRetentionServerName + * + * @param {string} longTermRetentionDatabaseName + * + * @param {string} backupName The backup 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 {LongTermRetentionBackup} - 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. + * + * {LongTermRetentionBackup} [result] - The deserialized result object if an error did not occur. + * See {@link LongTermRetentionBackup} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, callback: ServiceCallback): void; + get(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes a long term retention backup. + * + * @param {string} locationName The location of the database + * + * @param {string} longTermRetentionServerName + * + * @param {string} longTermRetentionDatabaseName + * + * @param {string} backupName The backup 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. + */ + deleteMethodWithHttpOperationResponse(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes a long term retention backup. + * + * @param {string} locationName The location of the database + * + * @param {string} longTermRetentionServerName + * + * @param {string} longTermRetentionDatabaseName + * + * @param {string} backupName The backup 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 {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, callback: ServiceCallback): void; + deleteMethod(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all long term retention backups for a database. + * + * @param {string} locationName The location of the database + * + * @param {string} longTermRetentionServerName + * + * @param {string} longTermRetentionDatabaseName + * + * @param {object} [options] Optional Parameters. + * + * @param {boolean} [options.onlyLatestPerDatabase] Whether or not to only get + * the latest backup for each database. + * + * @param {string} [options.databaseState] Whether to query against just live + * databases, just deleted databases, or all databases. Possible values + * include: 'All', 'Live', 'Deleted' + * + * @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. + */ + listByDatabaseWithHttpOperationResponse(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, options?: { onlyLatestPerDatabase? : boolean, databaseState? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all long term retention backups for a database. + * + * @param {string} locationName The location of the database + * + * @param {string} longTermRetentionServerName + * + * @param {string} longTermRetentionDatabaseName + * + * @param {object} [options] Optional Parameters. + * + * @param {boolean} [options.onlyLatestPerDatabase] Whether or not to only get + * the latest backup for each database. + * + * @param {string} [options.databaseState] Whether to query against just live + * databases, just deleted databases, or all databases. Possible values + * include: 'All', 'Live', 'Deleted' + * + * @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 {LongTermRetentionBackupListResult} - 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. + * + * {LongTermRetentionBackupListResult} [result] - The deserialized result object if an error did not occur. + * See {@link LongTermRetentionBackupListResult} 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. + */ + listByDatabase(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, options?: { onlyLatestPerDatabase? : boolean, databaseState? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + listByDatabase(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, callback: ServiceCallback): void; + listByDatabase(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, options: { onlyLatestPerDatabase? : boolean, databaseState? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the long term retention backups for a given location. + * + * @param {string} locationName The location of the database + * + * @param {object} [options] Optional Parameters. + * + * @param {boolean} [options.onlyLatestPerDatabase] Whether or not to only get + * the latest backup for each database. + * + * @param {string} [options.databaseState] Whether to query against just live + * databases, just deleted databases, or all databases. Possible values + * include: 'All', 'Live', 'Deleted' + * + * @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. + */ + listByLocationWithHttpOperationResponse(locationName: string, options?: { onlyLatestPerDatabase? : boolean, databaseState? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the long term retention backups for a given location. + * + * @param {string} locationName The location of the database + * + * @param {object} [options] Optional Parameters. + * + * @param {boolean} [options.onlyLatestPerDatabase] Whether or not to only get + * the latest backup for each database. + * + * @param {string} [options.databaseState] Whether to query against just live + * databases, just deleted databases, or all databases. Possible values + * include: 'All', 'Live', 'Deleted' + * + * @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 {LongTermRetentionBackupListResult} - 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. + * + * {LongTermRetentionBackupListResult} [result] - The deserialized result object if an error did not occur. + * See {@link LongTermRetentionBackupListResult} 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. + */ + listByLocation(locationName: string, options?: { onlyLatestPerDatabase? : boolean, databaseState? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + listByLocation(locationName: string, callback: ServiceCallback): void; + listByLocation(locationName: string, options: { onlyLatestPerDatabase? : boolean, databaseState? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the long term retention backups for a given server. + * + * @param {string} locationName The location of the database + * + * @param {string} longTermRetentionServerName + * + * @param {object} [options] Optional Parameters. + * + * @param {boolean} [options.onlyLatestPerDatabase] Whether or not to only get + * the latest backup for each database. + * + * @param {string} [options.databaseState] Whether to query against just live + * databases, just deleted databases, or all databases. Possible values + * include: 'All', 'Live', 'Deleted' + * + * @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. + */ + listByServerWithHttpOperationResponse(locationName: string, longTermRetentionServerName: string, options?: { onlyLatestPerDatabase? : boolean, databaseState? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the long term retention backups for a given server. + * + * @param {string} locationName The location of the database + * + * @param {string} longTermRetentionServerName + * + * @param {object} [options] Optional Parameters. + * + * @param {boolean} [options.onlyLatestPerDatabase] Whether or not to only get + * the latest backup for each database. + * + * @param {string} [options.databaseState] Whether to query against just live + * databases, just deleted databases, or all databases. Possible values + * include: 'All', 'Live', 'Deleted' + * + * @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 {LongTermRetentionBackupListResult} - 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. + * + * {LongTermRetentionBackupListResult} [result] - The deserialized result object if an error did not occur. + * See {@link LongTermRetentionBackupListResult} 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. + */ + listByServer(locationName: string, longTermRetentionServerName: string, options?: { onlyLatestPerDatabase? : boolean, databaseState? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + listByServer(locationName: string, longTermRetentionServerName: string, callback: ServiceCallback): void; + listByServer(locationName: string, longTermRetentionServerName: string, options: { onlyLatestPerDatabase? : boolean, databaseState? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes a long term retention backup. + * + * @param {string} locationName The location of the database + * + * @param {string} longTermRetentionServerName + * + * @param {string} longTermRetentionDatabaseName + * + * @param {string} backupName The backup 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. + */ + beginDeleteMethodWithHttpOperationResponse(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes a long term retention backup. + * + * @param {string} locationName The location of the database + * + * @param {string} longTermRetentionServerName + * + * @param {string} longTermRetentionDatabaseName + * + * @param {string} backupName The backup 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 {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + beginDeleteMethod(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginDeleteMethod(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, callback: ServiceCallback): void; + beginDeleteMethod(locationName: string, longTermRetentionServerName: string, longTermRetentionDatabaseName: string, backupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all long term retention backups for a database. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByDatabaseNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all long term retention backups for a database. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {LongTermRetentionBackupListResult} - 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. + * + * {LongTermRetentionBackupListResult} [result] - The deserialized result object if an error did not occur. + * See {@link LongTermRetentionBackupListResult} 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. + */ + listByDatabaseNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByDatabaseNext(nextPageLink: string, callback: ServiceCallback): void; + listByDatabaseNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the long term retention backups for a given location. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByLocationNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the long term retention backups for a given location. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {LongTermRetentionBackupListResult} - 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. + * + * {LongTermRetentionBackupListResult} [result] - The deserialized result object if an error did not occur. + * See {@link LongTermRetentionBackupListResult} 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. + */ + listByLocationNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByLocationNext(nextPageLink: string, callback: ServiceCallback): void; + listByLocationNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the long term retention backups for a given server. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByServerNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the long term retention backups for a given server. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {LongTermRetentionBackupListResult} - 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. + * + * {LongTermRetentionBackupListResult} [result] - The deserialized result object if an error did not occur. + * See {@link LongTermRetentionBackupListResult} 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. + */ + listByServerNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByServerNext(nextPageLink: string, callback: ServiceCallback): void; + listByServerNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * BackupLongTermRetentionPolicies + * __NOTE__: An instance of this class is automatically created for an + * instance of the SqlManagementClient. + */ +export interface BackupLongTermRetentionPolicies { + + + /** + * Gets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @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 {BackupLongTermRetentionPolicy} - 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. + * + * {BackupLongTermRetentionPolicy} [result] - The deserialized result object if an error did not occur. + * See {@link BackupLongTermRetentionPolicy} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, serverName: string, databaseName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, databaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @param {object} parameters The long term retention policy info. + * + * @param {string} [parameters.weeklyRetention] The weekly retention policy for + * an LTR backup in an ISO 8601 format. + * + * @param {string} [parameters.monthlyRetention] The montly retention policy + * for an LTR backup in an ISO 8601 format. + * + * @param {string} [parameters.yearlyRetention] The yearly retention policy for + * an LTR backup in an ISO 8601 format. + * + * @param {number} [parameters.weekOfYear] The week of year to take the yearly + * backup in an ISO 8601 format. + * + * @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. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.BackupLongTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @param {object} parameters The long term retention policy info. + * + * @param {string} [parameters.weeklyRetention] The weekly retention policy for + * an LTR backup in an ISO 8601 format. + * + * @param {string} [parameters.monthlyRetention] The montly retention policy + * for an LTR backup in an ISO 8601 format. + * + * @param {string} [parameters.yearlyRetention] The yearly retention policy for + * an LTR backup in an ISO 8601 format. + * + * @param {number} [parameters.weekOfYear] The week of year to take the yearly + * backup in an ISO 8601 format. + * + * @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 {BackupLongTermRetentionPolicy} - 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. + * + * {BackupLongTermRetentionPolicy} [result] - The deserialized result object if an error did not occur. + * See {@link BackupLongTermRetentionPolicy} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.BackupLongTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.BackupLongTermRetentionPolicy, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.BackupLongTermRetentionPolicy, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @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. + */ + listByDatabaseWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @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 {BackupLongTermRetentionPolicy} - 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. + * + * {BackupLongTermRetentionPolicy} [result] - The deserialized result object if an error did not occur. + * See {@link BackupLongTermRetentionPolicy} 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. + */ + listByDatabase(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByDatabase(resourceGroupName: string, serverName: string, databaseName: string, callback: ServiceCallback): void; + listByDatabase(resourceGroupName: string, serverName: string, databaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @param {object} parameters The long term retention policy info. + * + * @param {string} [parameters.weeklyRetention] The weekly retention policy for + * an LTR backup in an ISO 8601 format. + * + * @param {string} [parameters.monthlyRetention] The montly retention policy + * for an LTR backup in an ISO 8601 format. + * + * @param {string} [parameters.yearlyRetention] The yearly retention policy for + * an LTR backup in an ISO 8601 format. + * + * @param {number} [parameters.weekOfYear] The week of year to take the yearly + * backup in an ISO 8601 format. + * + * @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. + */ + beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.BackupLongTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @param {object} parameters The long term retention policy info. + * + * @param {string} [parameters.weeklyRetention] The weekly retention policy for + * an LTR backup in an ISO 8601 format. + * + * @param {string} [parameters.monthlyRetention] The montly retention policy + * for an LTR backup in an ISO 8601 format. + * + * @param {string} [parameters.yearlyRetention] The yearly retention policy for + * an LTR backup in an ISO 8601 format. + * + * @param {number} [parameters.weekOfYear] The week of year to take the yearly + * backup in an ISO 8601 format. + * + * @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 {BackupLongTermRetentionPolicy} - 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. + * + * {BackupLongTermRetentionPolicy} [result] - The deserialized result object if an error did not occur. + * See {@link BackupLongTermRetentionPolicy} 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. + */ + beginCreateOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.BackupLongTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginCreateOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.BackupLongTermRetentionPolicy, callback: ServiceCallback): void; + beginCreateOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.BackupLongTermRetentionPolicy, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ManagedDatabases + * __NOTE__: An instance of this class is automatically created for an + * instance of the SqlManagementClient. + */ +export interface ManagedDatabases { + + + /** + * Completes the restore operation on a managed database. + * + * @param {string} locationName The name of the region where the resource is + * located. + * + * @param {uuid} operationId Management operation id that this request tries to + * complete. + * + * @param {object} parameters The definition for completing the restore of this + * managed database. + * + * @param {string} parameters.lastBackupName The last backup name to apply + * + * @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. + */ + completeRestoreWithHttpOperationResponse(locationName: string, operationId: string, parameters: models.CompleteDatabaseRestoreDefinition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Completes the restore operation on a managed database. + * + * @param {string} locationName The name of the region where the resource is + * located. + * + * @param {uuid} operationId Management operation id that this request tries to + * complete. + * + * @param {object} parameters The definition for completing the restore of this + * managed database. + * + * @param {string} parameters.lastBackupName The last backup name to apply + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + completeRestore(locationName: string, operationId: string, parameters: models.CompleteDatabaseRestoreDefinition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + completeRestore(locationName: string, operationId: string, parameters: models.CompleteDatabaseRestoreDefinition, callback: ServiceCallback): void; + completeRestore(locationName: string, operationId: string, parameters: models.CompleteDatabaseRestoreDefinition, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets a list of managed databases. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByInstanceWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a list of managed databases. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ManagedDatabaseListResult} - 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. + * + * {ManagedDatabaseListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ManagedDatabaseListResult} 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. + */ + listByInstance(resourceGroupName: string, managedInstanceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByInstance(resourceGroupName: string, managedInstanceName: string, callback: ServiceCallback): void; + listByInstance(resourceGroupName: string, managedInstanceName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets a managed database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} databaseName The name of the database. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a managed database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} databaseName The name of the database. + * + * @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 {ManagedDatabase} - 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. + * + * {ManagedDatabase} [result] - The deserialized result object if an error did not occur. + * See {@link ManagedDatabase} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, managedInstanceName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, managedInstanceName: string, databaseName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, managedInstanceName: string, databaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Creates a new database or updates an existing database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} databaseName The name of the database. + * + * @param {object} parameters The requested database resource state. + * + * @param {string} [parameters.collation] Collation of the managed database. + * + * @param {date} [parameters.restorePointInTime] Conditional. If createMode is + * PointInTimeRestore, this value is required. Specifies the point in time + * (ISO8601 format) of the source database that will be restored to create the + * new database. + * + * @param {string} [parameters.catalogCollation] Collation of the metadata + * catalog. Possible values include: 'DATABASE_DEFAULT', + * 'SQL_Latin1_General_CP1_CI_AS' + * + * @param {string} [parameters.createMode] Managed database create mode. + * PointInTimeRestore: Create a database by restoring a point in time backup of + * an existing database. SourceDatabaseName, SourceManagedInstanceName and + * PointInTime must be specified. RestoreExternalBackup: Create a database by + * restoring from external backup files. Collation, StorageContainerUri and + * StorageContainerSasToken must be specified. Possible values include: + * 'Default', 'RestoreExternalBackup', 'PointInTimeRestore' + * + * @param {string} [parameters.storageContainerUri] Conditional. If createMode + * is RestoreExternalBackup, this value is required. Specifies the uri of the + * storage container where backups for this restore are stored. + * + * @param {string} [parameters.sourceDatabaseId] The resource identifier of the + * source database associated with create operation of this database. + * + * @param {string} [parameters.storageContainerSasToken] Conditional. If + * createMode is RestoreExternalBackup, this value is required. Specifies the + * storage container sas token. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location Resource location. + * + * @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. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabase, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Creates a new database or updates an existing database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} databaseName The name of the database. + * + * @param {object} parameters The requested database resource state. + * + * @param {string} [parameters.collation] Collation of the managed database. + * + * @param {date} [parameters.restorePointInTime] Conditional. If createMode is + * PointInTimeRestore, this value is required. Specifies the point in time + * (ISO8601 format) of the source database that will be restored to create the + * new database. + * + * @param {string} [parameters.catalogCollation] Collation of the metadata + * catalog. Possible values include: 'DATABASE_DEFAULT', + * 'SQL_Latin1_General_CP1_CI_AS' + * + * @param {string} [parameters.createMode] Managed database create mode. + * PointInTimeRestore: Create a database by restoring a point in time backup of + * an existing database. SourceDatabaseName, SourceManagedInstanceName and + * PointInTime must be specified. RestoreExternalBackup: Create a database by + * restoring from external backup files. Collation, StorageContainerUri and + * StorageContainerSasToken must be specified. Possible values include: + * 'Default', 'RestoreExternalBackup', 'PointInTimeRestore' + * + * @param {string} [parameters.storageContainerUri] Conditional. If createMode + * is RestoreExternalBackup, this value is required. Specifies the uri of the + * storage container where backups for this restore are stored. + * + * @param {string} [parameters.sourceDatabaseId] The resource identifier of the + * source database associated with create operation of this database. + * + * @param {string} [parameters.storageContainerSasToken] Conditional. If + * createMode is RestoreExternalBackup, this value is required. Specifies the + * storage container sas token. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location Resource location. + * + * @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 {ManagedDatabase} - 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. + * + * {ManagedDatabase} [result] - The deserialized result object if an error did not occur. + * See {@link ManagedDatabase} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabase, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabase, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabase, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes the managed database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} databaseName The name of the database. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes the managed database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} databaseName The name of the database. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName: string, managedInstanceName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, managedInstanceName: string, databaseName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, managedInstanceName: string, databaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Updates an existing database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} databaseName The name of the database. + * + * @param {object} parameters The requested database resource state. + * + * @param {string} [parameters.collation] Collation of the managed database. + * + * @param {date} [parameters.restorePointInTime] Conditional. If createMode is + * PointInTimeRestore, this value is required. Specifies the point in time + * (ISO8601 format) of the source database that will be restored to create the + * new database. + * + * @param {string} [parameters.catalogCollation] Collation of the metadata + * catalog. Possible values include: 'DATABASE_DEFAULT', + * 'SQL_Latin1_General_CP1_CI_AS' + * + * @param {string} [parameters.createMode] Managed database create mode. + * PointInTimeRestore: Create a database by restoring a point in time backup of + * an existing database. SourceDatabaseName, SourceManagedInstanceName and + * PointInTime must be specified. RestoreExternalBackup: Create a database by + * restoring from external backup files. Collation, StorageContainerUri and + * StorageContainerSasToken must be specified. Possible values include: + * 'Default', 'RestoreExternalBackup', 'PointInTimeRestore' + * + * @param {string} [parameters.storageContainerUri] Conditional. If createMode + * is RestoreExternalBackup, this value is required. Specifies the uri of the + * storage container where backups for this restore are stored. + * + * @param {string} [parameters.sourceDatabaseId] The resource identifier of the + * source database associated with create operation of this database. + * + * @param {string} [parameters.storageContainerSasToken] Conditional. If + * createMode is RestoreExternalBackup, this value is required. Specifies the + * storage container sas token. + * + * @param {object} [parameters.tags] Resource tags. + * + * @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. + */ + updateWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabaseUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Updates an existing database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} databaseName The name of the database. + * + * @param {object} parameters The requested database resource state. + * + * @param {string} [parameters.collation] Collation of the managed database. + * + * @param {date} [parameters.restorePointInTime] Conditional. If createMode is + * PointInTimeRestore, this value is required. Specifies the point in time + * (ISO8601 format) of the source database that will be restored to create the + * new database. + * + * @param {string} [parameters.catalogCollation] Collation of the metadata + * catalog. Possible values include: 'DATABASE_DEFAULT', + * 'SQL_Latin1_General_CP1_CI_AS' + * + * @param {string} [parameters.createMode] Managed database create mode. + * PointInTimeRestore: Create a database by restoring a point in time backup of + * an existing database. SourceDatabaseName, SourceManagedInstanceName and + * PointInTime must be specified. RestoreExternalBackup: Create a database by + * restoring from external backup files. Collation, StorageContainerUri and + * StorageContainerSasToken must be specified. Possible values include: + * 'Default', 'RestoreExternalBackup', 'PointInTimeRestore' + * + * @param {string} [parameters.storageContainerUri] Conditional. If createMode + * is RestoreExternalBackup, this value is required. Specifies the uri of the + * storage container where backups for this restore are stored. + * + * @param {string} [parameters.sourceDatabaseId] The resource identifier of the + * source database associated with create operation of this database. + * + * @param {string} [parameters.storageContainerSasToken] Conditional. If + * createMode is RestoreExternalBackup, this value is required. Specifies the + * storage container sas token. + * + * @param {object} [parameters.tags] Resource tags. + * + * @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 {ManagedDatabase} - 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. + * + * {ManagedDatabase} [result] - The deserialized result object if an error did not occur. + * See {@link ManagedDatabase} 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, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabaseUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabaseUpdate, callback: ServiceCallback): void; + update(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabaseUpdate, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Completes the restore operation on a managed database. + * + * @param {string} locationName The name of the region where the resource is + * located. + * + * @param {uuid} operationId Management operation id that this request tries to + * complete. + * + * @param {object} parameters The definition for completing the restore of this + * managed database. + * + * @param {string} parameters.lastBackupName The last backup name to apply + * + * @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. + */ + beginCompleteRestoreWithHttpOperationResponse(locationName: string, operationId: string, parameters: models.CompleteDatabaseRestoreDefinition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Completes the restore operation on a managed database. + * + * @param {string} locationName The name of the region where the resource is + * located. + * + * @param {uuid} operationId Management operation id that this request tries to + * complete. + * + * @param {object} parameters The definition for completing the restore of this + * managed database. + * + * @param {string} parameters.lastBackupName The last backup name to apply + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + beginCompleteRestore(locationName: string, operationId: string, parameters: models.CompleteDatabaseRestoreDefinition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginCompleteRestore(locationName: string, operationId: string, parameters: models.CompleteDatabaseRestoreDefinition, callback: ServiceCallback): void; + beginCompleteRestore(locationName: string, operationId: string, parameters: models.CompleteDatabaseRestoreDefinition, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Creates a new database or updates an existing database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} databaseName The name of the database. + * + * @param {object} parameters The requested database resource state. + * + * @param {string} [parameters.collation] Collation of the managed database. + * + * @param {date} [parameters.restorePointInTime] Conditional. If createMode is + * PointInTimeRestore, this value is required. Specifies the point in time + * (ISO8601 format) of the source database that will be restored to create the + * new database. + * + * @param {string} [parameters.catalogCollation] Collation of the metadata + * catalog. Possible values include: 'DATABASE_DEFAULT', + * 'SQL_Latin1_General_CP1_CI_AS' + * + * @param {string} [parameters.createMode] Managed database create mode. + * PointInTimeRestore: Create a database by restoring a point in time backup of + * an existing database. SourceDatabaseName, SourceManagedInstanceName and + * PointInTime must be specified. RestoreExternalBackup: Create a database by + * restoring from external backup files. Collation, StorageContainerUri and + * StorageContainerSasToken must be specified. Possible values include: + * 'Default', 'RestoreExternalBackup', 'PointInTimeRestore' + * + * @param {string} [parameters.storageContainerUri] Conditional. If createMode + * is RestoreExternalBackup, this value is required. Specifies the uri of the + * storage container where backups for this restore are stored. + * + * @param {string} [parameters.sourceDatabaseId] The resource identifier of the + * source database associated with create operation of this database. + * + * @param {string} [parameters.storageContainerSasToken] Conditional. If + * createMode is RestoreExternalBackup, this value is required. Specifies the + * storage container sas token. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location Resource location. + * + * @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. + */ + beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabase, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Creates a new database or updates an existing database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} databaseName The name of the database. + * + * @param {object} parameters The requested database resource state. + * + * @param {string} [parameters.collation] Collation of the managed database. + * + * @param {date} [parameters.restorePointInTime] Conditional. If createMode is + * PointInTimeRestore, this value is required. Specifies the point in time + * (ISO8601 format) of the source database that will be restored to create the + * new database. + * + * @param {string} [parameters.catalogCollation] Collation of the metadata + * catalog. Possible values include: 'DATABASE_DEFAULT', + * 'SQL_Latin1_General_CP1_CI_AS' + * + * @param {string} [parameters.createMode] Managed database create mode. + * PointInTimeRestore: Create a database by restoring a point in time backup of + * an existing database. SourceDatabaseName, SourceManagedInstanceName and + * PointInTime must be specified. RestoreExternalBackup: Create a database by + * restoring from external backup files. Collation, StorageContainerUri and + * StorageContainerSasToken must be specified. Possible values include: + * 'Default', 'RestoreExternalBackup', 'PointInTimeRestore' + * + * @param {string} [parameters.storageContainerUri] Conditional. If createMode + * is RestoreExternalBackup, this value is required. Specifies the uri of the + * storage container where backups for this restore are stored. + * + * @param {string} [parameters.sourceDatabaseId] The resource identifier of the + * source database associated with create operation of this database. + * + * @param {string} [parameters.storageContainerSasToken] Conditional. If + * createMode is RestoreExternalBackup, this value is required. Specifies the + * storage container sas token. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location Resource location. + * + * @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 {ManagedDatabase} - 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. + * + * {ManagedDatabase} [result] - The deserialized result object if an error did not occur. + * See {@link ManagedDatabase} 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. + */ + beginCreateOrUpdate(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabase, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginCreateOrUpdate(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabase, callback: ServiceCallback): void; + beginCreateOrUpdate(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabase, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes the managed database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} databaseName The name of the database. + * + * @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. + */ + beginDeleteMethodWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes the managed database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} databaseName The name of the database. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + beginDeleteMethod(resourceGroupName: string, managedInstanceName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginDeleteMethod(resourceGroupName: string, managedInstanceName: string, databaseName: string, callback: ServiceCallback): void; + beginDeleteMethod(resourceGroupName: string, managedInstanceName: string, databaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Updates an existing database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} databaseName The name of the database. + * + * @param {object} parameters The requested database resource state. + * + * @param {string} [parameters.collation] Collation of the managed database. + * + * @param {date} [parameters.restorePointInTime] Conditional. If createMode is + * PointInTimeRestore, this value is required. Specifies the point in time + * (ISO8601 format) of the source database that will be restored to create the + * new database. + * + * @param {string} [parameters.catalogCollation] Collation of the metadata + * catalog. Possible values include: 'DATABASE_DEFAULT', + * 'SQL_Latin1_General_CP1_CI_AS' + * + * @param {string} [parameters.createMode] Managed database create mode. + * PointInTimeRestore: Create a database by restoring a point in time backup of + * an existing database. SourceDatabaseName, SourceManagedInstanceName and + * PointInTime must be specified. RestoreExternalBackup: Create a database by + * restoring from external backup files. Collation, StorageContainerUri and + * StorageContainerSasToken must be specified. Possible values include: + * 'Default', 'RestoreExternalBackup', 'PointInTimeRestore' + * + * @param {string} [parameters.storageContainerUri] Conditional. If createMode + * is RestoreExternalBackup, this value is required. Specifies the uri of the + * storage container where backups for this restore are stored. + * + * @param {string} [parameters.sourceDatabaseId] The resource identifier of the + * source database associated with create operation of this database. + * + * @param {string} [parameters.storageContainerSasToken] Conditional. If + * createMode is RestoreExternalBackup, this value is required. Specifies the + * storage container sas token. + * + * @param {object} [parameters.tags] Resource tags. + * + * @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. + */ + beginUpdateWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabaseUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Updates an existing database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} databaseName The name of the database. + * + * @param {object} parameters The requested database resource state. + * + * @param {string} [parameters.collation] Collation of the managed database. + * + * @param {date} [parameters.restorePointInTime] Conditional. If createMode is + * PointInTimeRestore, this value is required. Specifies the point in time + * (ISO8601 format) of the source database that will be restored to create the + * new database. + * + * @param {string} [parameters.catalogCollation] Collation of the metadata + * catalog. Possible values include: 'DATABASE_DEFAULT', + * 'SQL_Latin1_General_CP1_CI_AS' + * + * @param {string} [parameters.createMode] Managed database create mode. + * PointInTimeRestore: Create a database by restoring a point in time backup of + * an existing database. SourceDatabaseName, SourceManagedInstanceName and + * PointInTime must be specified. RestoreExternalBackup: Create a database by + * restoring from external backup files. Collation, StorageContainerUri and + * StorageContainerSasToken must be specified. Possible values include: + * 'Default', 'RestoreExternalBackup', 'PointInTimeRestore' + * + * @param {string} [parameters.storageContainerUri] Conditional. If createMode + * is RestoreExternalBackup, this value is required. Specifies the uri of the + * storage container where backups for this restore are stored. + * + * @param {string} [parameters.sourceDatabaseId] The resource identifier of the + * source database associated with create operation of this database. + * + * @param {string} [parameters.storageContainerSasToken] Conditional. If + * createMode is RestoreExternalBackup, this value is required. Specifies the + * storage container sas token. + * + * @param {object} [parameters.tags] Resource tags. + * + * @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 {ManagedDatabase} - 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. + * + * {ManagedDatabase} [result] - The deserialized result object if an error did not occur. + * See {@link ManagedDatabase} 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. + */ + beginUpdate(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabaseUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginUpdate(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabaseUpdate, callback: ServiceCallback): void; + beginUpdate(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabaseUpdate, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets a list of managed databases. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByInstanceNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a list of managed databases. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ManagedDatabaseListResult} - 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. + * + * {ManagedDatabaseListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ManagedDatabaseListResult} 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. + */ + listByInstanceNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByInstanceNext(nextPageLink: string, callback: ServiceCallback): void; + listByInstanceNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ServerAutomaticTuningOperations + * __NOTE__: An instance of this class is automatically created for an + * instance of the SqlManagementClient. + */ +export interface ServerAutomaticTuningOperations { + + + /** + * Retrieves server automatic tuning options. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, serverName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Retrieves server automatic tuning options. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @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 {ServerAutomaticTuning} - 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. + * + * {ServerAutomaticTuning} [result] - The deserialized result object if an error did not occur. + * See {@link ServerAutomaticTuning} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, serverName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, serverName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Update automatic tuning options on server. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {object} parameters The requested automatic tuning resource state. + * + * @param {string} [parameters.desiredState] Automatic tuning desired state. + * Possible values include: 'Custom', 'Auto', 'Unspecified' + * + * @param {object} [parameters.options] Automatic tuning options definition. + * + * @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. + */ + updateWithHttpOperationResponse(resourceGroupName: string, serverName: string, parameters: models.ServerAutomaticTuning, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Update automatic tuning options on server. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {object} parameters The requested automatic tuning resource state. + * + * @param {string} [parameters.desiredState] Automatic tuning desired state. + * Possible values include: 'Custom', 'Auto', 'Unspecified' + * + * @param {object} [parameters.options] Automatic tuning options definition. + * + * @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 {ServerAutomaticTuning} - 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. + * + * {ServerAutomaticTuning} [result] - The deserialized result object if an error did not occur. + * See {@link ServerAutomaticTuning} 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, serverName: string, parameters: models.ServerAutomaticTuning, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, serverName: string, parameters: models.ServerAutomaticTuning, callback: ServiceCallback): void; + update(resourceGroupName: string, serverName: string, parameters: models.ServerAutomaticTuning, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ServerDnsAliases + * __NOTE__: An instance of this class is automatically created for an + * instance of the SqlManagementClient. + */ +export interface ServerDnsAliases { + + + /** + * Gets a server DNS alias. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server that the alias is pointing + * to. + * + * @param {string} dnsAliasName The name of the server DNS alias. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, serverName: string, dnsAliasName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a server DNS alias. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server that the alias is pointing + * to. + * + * @param {string} dnsAliasName The name of the server DNS alias. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. * - * @param {string} [parameters.collation] Collation of the managed database. + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. * - * @param {date} [parameters.restorePointInTime] Conditional. If createMode is - * PointInTimeRestore, this value is required. Specifies the point in time - * (ISO8601 format) of the source database that will be restored to create the - * new database. + * {Promise} A promise is returned. * - * @param {string} [parameters.catalogCollation] Collation of the metadata - * catalog. Possible values include: 'DATABASE_DEFAULT', - * 'SQL_Latin1_General_CP1_CI_AS' + * @resolve {ServerDnsAlias} - The deserialized result object. * - * @param {string} [parameters.createMode] Managed database create mode. - * PointInTimeRestore: Create a database by restoring a point in time backup of - * an existing database. SourceDatabaseName, SourceManagedInstanceName and - * PointInTime must be specified. RestoreExternalBackup: Create a database by - * restoring from external backup files. Collation, StorageContainerUri and - * StorageContainerSasToken must be specified. Possible values include: - * 'Default', 'RestoreExternalBackup', 'PointInTimeRestore' + * @reject {Error|ServiceError} - The error object. * - * @param {string} [parameters.storageContainerUri] Conditional. If createMode - * is RestoreExternalBackup, this value is required. Specifies the uri of the - * storage container where backups for this restore are stored. + * {ServiceCallback} optionalCallback(err, result, request, response) * - * @param {string} [parameters.sourceDatabaseId] The resource identifier of the - * source database associated with create operation of this database. + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * @param {string} [parameters.storageContainerSasToken] Conditional. If - * createMode is RestoreExternalBackup, this value is required. Specifies the - * storage container sas token. + * {ServerDnsAlias} [result] - The deserialized result object if an error did not occur. + * See {@link ServerDnsAlias} for more information. * - * @param {object} [parameters.tags] Resource tags. + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, serverName: string, dnsAliasName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, serverName: string, dnsAliasName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, dnsAliasName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Creates a server dns alias. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server that the alias is pointing + * to. + * + * @param {string} dnsAliasName The name of the server DNS alias. * * @param {object} [options] Optional Parameters. * @@ -17884,56 +23422,92 @@ export interface ManagedDatabases { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - updateWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabaseUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, dnsAliasName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Updates an existing database. + * Creates a server dns alias. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} managedInstanceName The name of the managed instance. + * @param {string} serverName The name of the server that the alias is pointing + * to. * - * @param {string} databaseName The name of the database. + * @param {string} dnsAliasName The name of the server DNS alias. * - * @param {object} parameters The requested database resource state. + * @param {object} [options] Optional Parameters. * - * @param {string} [parameters.collation] Collation of the managed database. + * @param {object} [options.customHeaders] Headers that will be added to the + * request * - * @param {date} [parameters.restorePointInTime] Conditional. If createMode is - * PointInTimeRestore, this value is required. Specifies the point in time - * (ISO8601 format) of the source database that will be restored to create the - * new database. + * @param {ServiceCallback} [optionalCallback] - The optional callback. * - * @param {string} [parameters.catalogCollation] Collation of the metadata - * catalog. Possible values include: 'DATABASE_DEFAULT', - * 'SQL_Latin1_General_CP1_CI_AS' + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. * - * @param {string} [parameters.createMode] Managed database create mode. - * PointInTimeRestore: Create a database by restoring a point in time backup of - * an existing database. SourceDatabaseName, SourceManagedInstanceName and - * PointInTime must be specified. RestoreExternalBackup: Create a database by - * restoring from external backup files. Collation, StorageContainerUri and - * StorageContainerSasToken must be specified. Possible values include: - * 'Default', 'RestoreExternalBackup', 'PointInTimeRestore' + * {Promise} A promise is returned. * - * @param {string} [parameters.storageContainerUri] Conditional. If createMode - * is RestoreExternalBackup, this value is required. Specifies the uri of the - * storage container where backups for this restore are stored. + * @resolve {ServerDnsAlias} - The deserialized result object. * - * @param {string} [parameters.sourceDatabaseId] The resource identifier of the - * source database associated with create operation of this database. + * @reject {Error|ServiceError} - The error object. * - * @param {string} [parameters.storageContainerSasToken] Conditional. If - * createMode is RestoreExternalBackup, this value is required. Specifies the - * storage container sas token. + * {ServiceCallback} optionalCallback(err, result, request, response) * - * @param {object} [parameters.tags] Resource tags. + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ServerDnsAlias} [result] - The deserialized result object if an error did not occur. + * See {@link ServerDnsAlias} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName: string, serverName: string, dnsAliasName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, serverName: string, dnsAliasName: string, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, serverName: string, dnsAliasName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes the server DNS alias with the given name. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server that the alias is pointing + * to. + * + * @param {string} dnsAliasName The name of the server DNS alias. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, serverName: string, dnsAliasName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes the server DNS alias with the given name. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server that the alias is pointing + * to. + * + * @param {string} dnsAliasName The name of the server DNS alias. * * @param {object} [options] Optional Parameters. * @@ -17947,7 +23521,7 @@ export interface ManagedDatabases { * * {Promise} A promise is returned. * - * @resolve {ManagedDatabase} - The deserialized result object. + * @resolve {null} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -17955,31 +23529,99 @@ export interface ManagedDatabases { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {ManagedDatabase} [result] - The deserialized result object if an error did not occur. - * See {@link ManagedDatabase} for more information. + * {null} [result] - The deserialized result object if an error did not occur. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - update(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabaseUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - update(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabaseUpdate, callback: ServiceCallback): void; - update(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabaseUpdate, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, serverName: string, dnsAliasName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, serverName: string, dnsAliasName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, serverName: string, dnsAliasName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Completes the restore operation on a managed database. + * Gets a list of server DNS aliases for a server. * - * @param {string} locationName The name of the region where the resource is - * located. + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. * - * @param {uuid} operationId Management operation id that this request tries to - * complete. + * @param {string} serverName The name of the server that the alias is pointing + * to. * - * @param {object} parameters The definition for completing the restore of this - * managed database. + * @param {object} [options] Optional Parameters. * - * @param {string} parameters.lastBackupName The last backup name to apply + * @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. + */ + listByServerWithHttpOperationResponse(resourceGroupName: string, serverName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a list of server DNS aliases for a server. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server that the alias is pointing + * to. + * + * @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 {ServerDnsAliasListResult} - 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. + * + * {ServerDnsAliasListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ServerDnsAliasListResult} 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. + */ + listByServer(resourceGroupName: string, serverName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByServer(resourceGroupName: string, serverName: string, callback: ServiceCallback): void; + listByServer(resourceGroupName: string, serverName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Acquires server DNS alias from another server. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server that the alias is pointing + * to. + * + * @param {string} dnsAliasName The name of the server dns alias. + * + * @param {object} parameters + * + * @param {string} [parameters.oldServerDnsAliasId] The id of the server alias + * that will be acquired to point to this server instead. * * @param {object} [options] Optional Parameters. * @@ -17992,21 +23634,24 @@ export interface ManagedDatabases { * * @reject {Error|ServiceError} - The error object. */ - beginCompleteRestoreWithHttpOperationResponse(locationName: string, operationId: string, parameters: models.CompleteDatabaseRestoreDefinition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + acquireWithHttpOperationResponse(resourceGroupName: string, serverName: string, dnsAliasName: string, parameters: models.ServerDnsAliasAcquisition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Completes the restore operation on a managed database. + * Acquires server DNS alias from another server. * - * @param {string} locationName The name of the region where the resource is - * located. + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server that the alias is pointing + * to. * - * @param {uuid} operationId Management operation id that this request tries to - * complete. + * @param {string} dnsAliasName The name of the server dns alias. * - * @param {object} parameters The definition for completing the restore of this - * managed database. + * @param {object} parameters * - * @param {string} parameters.lastBackupName The last backup name to apply + * @param {string} [parameters.oldServerDnsAliasId] The id of the server alias + * that will be acquired to point to this server instead. * * @param {object} [options] Optional Parameters. * @@ -18034,57 +23679,22 @@ export interface ManagedDatabases { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - beginCompleteRestore(locationName: string, operationId: string, parameters: models.CompleteDatabaseRestoreDefinition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - beginCompleteRestore(locationName: string, operationId: string, parameters: models.CompleteDatabaseRestoreDefinition, callback: ServiceCallback): void; - beginCompleteRestore(locationName: string, operationId: string, parameters: models.CompleteDatabaseRestoreDefinition, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + acquire(resourceGroupName: string, serverName: string, dnsAliasName: string, parameters: models.ServerDnsAliasAcquisition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + acquire(resourceGroupName: string, serverName: string, dnsAliasName: string, parameters: models.ServerDnsAliasAcquisition, callback: ServiceCallback): void; + acquire(resourceGroupName: string, serverName: string, dnsAliasName: string, parameters: models.ServerDnsAliasAcquisition, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Creates a new database or updates an existing database. + * Creates a server dns alias. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} managedInstanceName The name of the managed instance. - * - * @param {string} databaseName The name of the database. - * - * @param {object} parameters The requested database resource state. - * - * @param {string} [parameters.collation] Collation of the managed database. - * - * @param {date} [parameters.restorePointInTime] Conditional. If createMode is - * PointInTimeRestore, this value is required. Specifies the point in time - * (ISO8601 format) of the source database that will be restored to create the - * new database. - * - * @param {string} [parameters.catalogCollation] Collation of the metadata - * catalog. Possible values include: 'DATABASE_DEFAULT', - * 'SQL_Latin1_General_CP1_CI_AS' - * - * @param {string} [parameters.createMode] Managed database create mode. - * PointInTimeRestore: Create a database by restoring a point in time backup of - * an existing database. SourceDatabaseName, SourceManagedInstanceName and - * PointInTime must be specified. RestoreExternalBackup: Create a database by - * restoring from external backup files. Collation, StorageContainerUri and - * StorageContainerSasToken must be specified. Possible values include: - * 'Default', 'RestoreExternalBackup', 'PointInTimeRestore' - * - * @param {string} [parameters.storageContainerUri] Conditional. If createMode - * is RestoreExternalBackup, this value is required. Specifies the uri of the - * storage container where backups for this restore are stored. - * - * @param {string} [parameters.sourceDatabaseId] The resource identifier of the - * source database associated with create operation of this database. - * - * @param {string} [parameters.storageContainerSasToken] Conditional. If - * createMode is RestoreExternalBackup, this value is required. Specifies the - * storage container sas token. - * - * @param {object} [parameters.tags] Resource tags. + * @param {string} serverName The name of the server that the alias is pointing + * to. * - * @param {string} parameters.location Resource location. + * @param {string} dnsAliasName The name of the server DNS alias. * * @param {object} [options] Optional Parameters. * @@ -18093,58 +23703,23 @@ export interface ManagedDatabases { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabase, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, dnsAliasName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Creates a new database or updates an existing database. + * Creates a server dns alias. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} managedInstanceName The name of the managed instance. - * - * @param {string} databaseName The name of the database. - * - * @param {object} parameters The requested database resource state. - * - * @param {string} [parameters.collation] Collation of the managed database. - * - * @param {date} [parameters.restorePointInTime] Conditional. If createMode is - * PointInTimeRestore, this value is required. Specifies the point in time - * (ISO8601 format) of the source database that will be restored to create the - * new database. - * - * @param {string} [parameters.catalogCollation] Collation of the metadata - * catalog. Possible values include: 'DATABASE_DEFAULT', - * 'SQL_Latin1_General_CP1_CI_AS' - * - * @param {string} [parameters.createMode] Managed database create mode. - * PointInTimeRestore: Create a database by restoring a point in time backup of - * an existing database. SourceDatabaseName, SourceManagedInstanceName and - * PointInTime must be specified. RestoreExternalBackup: Create a database by - * restoring from external backup files. Collation, StorageContainerUri and - * StorageContainerSasToken must be specified. Possible values include: - * 'Default', 'RestoreExternalBackup', 'PointInTimeRestore' - * - * @param {string} [parameters.storageContainerUri] Conditional. If createMode - * is RestoreExternalBackup, this value is required. Specifies the uri of the - * storage container where backups for this restore are stored. - * - * @param {string} [parameters.sourceDatabaseId] The resource identifier of the - * source database associated with create operation of this database. - * - * @param {string} [parameters.storageContainerSasToken] Conditional. If - * createMode is RestoreExternalBackup, this value is required. Specifies the - * storage container sas token. - * - * @param {object} [parameters.tags] Resource tags. + * @param {string} serverName The name of the server that the alias is pointing + * to. * - * @param {string} parameters.location Resource location. + * @param {string} dnsAliasName The name of the server DNS alias. * * @param {object} [options] Optional Parameters. * @@ -18158,7 +23733,7 @@ export interface ManagedDatabases { * * {Promise} A promise is returned. * - * @resolve {ManagedDatabase} - The deserialized result object. + * @resolve {ServerDnsAlias} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -18166,28 +23741,29 @@ export interface ManagedDatabases { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {ManagedDatabase} [result] - The deserialized result object if an error did not occur. - * See {@link ManagedDatabase} for more information. + * {ServerDnsAlias} [result] - The deserialized result object if an error did not occur. + * See {@link ServerDnsAlias} 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. */ - beginCreateOrUpdate(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabase, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - beginCreateOrUpdate(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabase, callback: ServiceCallback): void; - beginCreateOrUpdate(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabase, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + beginCreateOrUpdate(resourceGroupName: string, serverName: string, dnsAliasName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginCreateOrUpdate(resourceGroupName: string, serverName: string, dnsAliasName: string, callback: ServiceCallback): void; + beginCreateOrUpdate(resourceGroupName: string, serverName: string, dnsAliasName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Deletes the managed database. + * Deletes the server DNS alias with the given name. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} managedInstanceName The name of the managed instance. + * @param {string} serverName The name of the server that the alias is pointing + * to. * - * @param {string} databaseName The name of the database. + * @param {string} dnsAliasName The name of the server DNS alias. * * @param {object} [options] Optional Parameters. * @@ -18200,18 +23776,19 @@ export interface ManagedDatabases { * * @reject {Error|ServiceError} - The error object. */ - beginDeleteMethodWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + beginDeleteMethodWithHttpOperationResponse(resourceGroupName: string, serverName: string, dnsAliasName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Deletes the managed database. + * Deletes the server DNS alias with the given name. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} managedInstanceName The name of the managed instance. + * @param {string} serverName The name of the server that the alias is pointing + * to. * - * @param {string} databaseName The name of the database. + * @param {string} dnsAliasName The name of the server DNS alias. * * @param {object} [options] Optional Parameters. * @@ -18239,55 +23816,27 @@ export interface ManagedDatabases { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - beginDeleteMethod(resourceGroupName: string, managedInstanceName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - beginDeleteMethod(resourceGroupName: string, managedInstanceName: string, databaseName: string, callback: ServiceCallback): void; - beginDeleteMethod(resourceGroupName: string, managedInstanceName: string, databaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + beginDeleteMethod(resourceGroupName: string, serverName: string, dnsAliasName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginDeleteMethod(resourceGroupName: string, serverName: string, dnsAliasName: string, callback: ServiceCallback): void; + beginDeleteMethod(resourceGroupName: string, serverName: string, dnsAliasName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Updates an existing database. + * Acquires server DNS alias from another server. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} managedInstanceName The name of the managed instance. - * - * @param {string} databaseName The name of the database. - * - * @param {object} parameters The requested database resource state. - * - * @param {string} [parameters.collation] Collation of the managed database. - * - * @param {date} [parameters.restorePointInTime] Conditional. If createMode is - * PointInTimeRestore, this value is required. Specifies the point in time - * (ISO8601 format) of the source database that will be restored to create the - * new database. - * - * @param {string} [parameters.catalogCollation] Collation of the metadata - * catalog. Possible values include: 'DATABASE_DEFAULT', - * 'SQL_Latin1_General_CP1_CI_AS' - * - * @param {string} [parameters.createMode] Managed database create mode. - * PointInTimeRestore: Create a database by restoring a point in time backup of - * an existing database. SourceDatabaseName, SourceManagedInstanceName and - * PointInTime must be specified. RestoreExternalBackup: Create a database by - * restoring from external backup files. Collation, StorageContainerUri and - * StorageContainerSasToken must be specified. Possible values include: - * 'Default', 'RestoreExternalBackup', 'PointInTimeRestore' - * - * @param {string} [parameters.storageContainerUri] Conditional. If createMode - * is RestoreExternalBackup, this value is required. Specifies the uri of the - * storage container where backups for this restore are stored. + * @param {string} serverName The name of the server that the alias is pointing + * to. * - * @param {string} [parameters.sourceDatabaseId] The resource identifier of the - * source database associated with create operation of this database. + * @param {string} dnsAliasName The name of the server dns alias. * - * @param {string} [parameters.storageContainerSasToken] Conditional. If - * createMode is RestoreExternalBackup, this value is required. Specifies the - * storage container sas token. + * @param {object} parameters * - * @param {object} [parameters.tags] Resource tags. + * @param {string} [parameters.oldServerDnsAliasId] The id of the server alias + * that will be acquired to point to this server instead. * * @param {object} [options] Optional Parameters. * @@ -18296,56 +23845,28 @@ export interface ManagedDatabases { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - beginUpdateWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabaseUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + beginAcquireWithHttpOperationResponse(resourceGroupName: string, serverName: string, dnsAliasName: string, parameters: models.ServerDnsAliasAcquisition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Updates an existing database. + * Acquires server DNS alias from another server. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} managedInstanceName The name of the managed instance. - * - * @param {string} databaseName The name of the database. - * - * @param {object} parameters The requested database resource state. - * - * @param {string} [parameters.collation] Collation of the managed database. - * - * @param {date} [parameters.restorePointInTime] Conditional. If createMode is - * PointInTimeRestore, this value is required. Specifies the point in time - * (ISO8601 format) of the source database that will be restored to create the - * new database. - * - * @param {string} [parameters.catalogCollation] Collation of the metadata - * catalog. Possible values include: 'DATABASE_DEFAULT', - * 'SQL_Latin1_General_CP1_CI_AS' - * - * @param {string} [parameters.createMode] Managed database create mode. - * PointInTimeRestore: Create a database by restoring a point in time backup of - * an existing database. SourceDatabaseName, SourceManagedInstanceName and - * PointInTime must be specified. RestoreExternalBackup: Create a database by - * restoring from external backup files. Collation, StorageContainerUri and - * StorageContainerSasToken must be specified. Possible values include: - * 'Default', 'RestoreExternalBackup', 'PointInTimeRestore' - * - * @param {string} [parameters.storageContainerUri] Conditional. If createMode - * is RestoreExternalBackup, this value is required. Specifies the uri of the - * storage container where backups for this restore are stored. + * @param {string} serverName The name of the server that the alias is pointing + * to. * - * @param {string} [parameters.sourceDatabaseId] The resource identifier of the - * source database associated with create operation of this database. + * @param {string} dnsAliasName The name of the server dns alias. * - * @param {string} [parameters.storageContainerSasToken] Conditional. If - * createMode is RestoreExternalBackup, this value is required. Specifies the - * storage container sas token. + * @param {object} parameters * - * @param {object} [parameters.tags] Resource tags. + * @param {string} [parameters.oldServerDnsAliasId] The id of the server alias + * that will be acquired to point to this server instead. * * @param {object} [options] Optional Parameters. * @@ -18359,7 +23880,7 @@ export interface ManagedDatabases { * * {Promise} A promise is returned. * - * @resolve {ManagedDatabase} - The deserialized result object. + * @resolve {null} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -18367,20 +23888,19 @@ export interface ManagedDatabases { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {ManagedDatabase} [result] - The deserialized result object if an error did not occur. - * See {@link ManagedDatabase} for more information. + * {null} [result] - The deserialized result object if an error did not occur. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - beginUpdate(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabaseUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - beginUpdate(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabaseUpdate, callback: ServiceCallback): void; - beginUpdate(resourceGroupName: string, managedInstanceName: string, databaseName: string, parameters: models.ManagedDatabaseUpdate, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + beginAcquire(resourceGroupName: string, serverName: string, dnsAliasName: string, parameters: models.ServerDnsAliasAcquisition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginAcquire(resourceGroupName: string, serverName: string, dnsAliasName: string, parameters: models.ServerDnsAliasAcquisition, callback: ServiceCallback): void; + beginAcquire(resourceGroupName: string, serverName: string, dnsAliasName: string, parameters: models.ServerDnsAliasAcquisition, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Gets a list of managed databases. + * Gets a list of server DNS aliases for a server. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -18392,14 +23912,14 @@ export interface ManagedDatabases { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listByInstanceNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listByServerNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets a list of managed databases. + * Gets a list of server DNS aliases for a server. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -18416,7 +23936,7 @@ export interface ManagedDatabases { * * {Promise} A promise is returned. * - * @resolve {ManagedDatabaseListResult} - The deserialized result object. + * @resolve {ServerDnsAliasListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -18424,30 +23944,30 @@ export interface ManagedDatabases { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {ManagedDatabaseListResult} [result] - The deserialized result object if an error did not occur. - * See {@link ManagedDatabaseListResult} for more + * {ServerDnsAliasListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ServerDnsAliasListResult} 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. */ - listByInstanceNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByInstanceNext(nextPageLink: string, callback: ServiceCallback): void; - listByInstanceNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + listByServerNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByServerNext(nextPageLink: string, callback: ServiceCallback): void; + listByServerNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } /** * @class - * ServerAutomaticTuningOperations + * RestorePoints * __NOTE__: An instance of this class is automatically created for an * instance of the SqlManagementClient. */ -export interface ServerAutomaticTuningOperations { +export interface RestorePoints { /** - * Retrieves server automatic tuning options. + * Gets a list of database restore points. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -18455,6 +23975,8 @@ export interface ServerAutomaticTuningOperations { * * @param {string} serverName The name of the server. * + * @param {string} databaseName The name of the database. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -18462,14 +23984,14 @@ export interface ServerAutomaticTuningOperations { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - getWithHttpOperationResponse(resourceGroupName: string, serverName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listByDatabaseWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Retrieves server automatic tuning options. + * Gets a list of database restore points. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -18477,6 +23999,8 @@ export interface ServerAutomaticTuningOperations { * * @param {string} serverName The name of the server. * + * @param {string} databaseName The name of the database. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -18489,7 +24013,7 @@ export interface ServerAutomaticTuningOperations { * * {Promise} A promise is returned. * - * @resolve {ServerAutomaticTuning} - The deserialized result object. + * @resolve {RestorePointListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -18497,20 +24021,21 @@ export interface ServerAutomaticTuningOperations { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {ServerAutomaticTuning} [result] - The deserialized result object if an error did not occur. - * See {@link ServerAutomaticTuning} for more information. + * {RestorePointListResult} [result] - The deserialized result object if an error did not occur. + * See {@link RestorePointListResult} for more + * information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - get(resourceGroupName: string, serverName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - get(resourceGroupName: string, serverName: string, callback: ServiceCallback): void; - get(resourceGroupName: string, serverName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + listByDatabase(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByDatabase(resourceGroupName: string, serverName: string, databaseName: string, callback: ServiceCallback): void; + listByDatabase(resourceGroupName: string, serverName: string, databaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Update automatic tuning options on server. + * Creates a restore point for a data warehouse. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -18518,12 +24043,13 @@ export interface ServerAutomaticTuningOperations { * * @param {string} serverName The name of the server. * - * @param {object} parameters The requested automatic tuning resource state. + * @param {string} databaseName The name of the database. * - * @param {string} [parameters.desiredState] Automatic tuning desired state. - * Possible values include: 'Custom', 'Auto', 'Unspecified' + * @param {object} parameters The definition for creating the restore point of + * this database. * - * @param {object} [parameters.options] Automatic tuning options definition. + * @param {string} parameters.restorePointLabel The restore point label to + * apply * * @param {object} [options] Optional Parameters. * @@ -18532,14 +24058,14 @@ export interface ServerAutomaticTuningOperations { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - updateWithHttpOperationResponse(resourceGroupName: string, serverName: string, parameters: models.ServerAutomaticTuning, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + createWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.CreateDatabaseRestorePointDefinition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Update automatic tuning options on server. + * Creates a restore point for a data warehouse. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -18547,12 +24073,13 @@ export interface ServerAutomaticTuningOperations { * * @param {string} serverName The name of the server. * - * @param {object} parameters The requested automatic tuning resource state. + * @param {string} databaseName The name of the database. * - * @param {string} [parameters.desiredState] Automatic tuning desired state. - * Possible values include: 'Custom', 'Auto', 'Unspecified' + * @param {object} parameters The definition for creating the restore point of + * this database. * - * @param {object} [parameters.options] Automatic tuning options definition. + * @param {string} parameters.restorePointLabel The restore point label to + * apply * * @param {object} [options] Optional Parameters. * @@ -18566,7 +24093,7 @@ export interface ServerAutomaticTuningOperations { * * {Promise} A promise is returned. * - * @resolve {ServerAutomaticTuning} - The deserialized result object. + * @resolve {RestorePoint} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -18574,38 +24101,30 @@ export interface ServerAutomaticTuningOperations { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {ServerAutomaticTuning} [result] - The deserialized result object if an error did not occur. - * See {@link ServerAutomaticTuning} for more information. + * {RestorePoint} [result] - The deserialized result object if an error did not occur. + * See {@link RestorePoint} 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, serverName: string, parameters: models.ServerAutomaticTuning, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - update(resourceGroupName: string, serverName: string, parameters: models.ServerAutomaticTuning, callback: ServiceCallback): void; - update(resourceGroupName: string, serverName: string, parameters: models.ServerAutomaticTuning, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; -} - -/** - * @class - * ServerDnsAliases - * __NOTE__: An instance of this class is automatically created for an - * instance of the SqlManagementClient. - */ -export interface ServerDnsAliases { + create(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.CreateDatabaseRestorePointDefinition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + create(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.CreateDatabaseRestorePointDefinition, callback: ServiceCallback): void; + create(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.CreateDatabaseRestorePointDefinition, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Gets a server DNS alias. + * Gets a restore point. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} serverName The name of the server that the alias is pointing - * to. + * @param {string} serverName The name of the server. * - * @param {string} dnsAliasName The name of the server DNS alias. + * @param {string} databaseName The name of the database. + * + * @param {string} restorePointName The name of the restore point. * * @param {object} [options] Optional Parameters. * @@ -18614,23 +24133,24 @@ export interface ServerDnsAliases { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - getWithHttpOperationResponse(resourceGroupName: string, serverName: string, dnsAliasName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + getWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, restorePointName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets a server DNS alias. + * Gets a restore point. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} serverName The name of the server that the alias is pointing - * to. + * @param {string} serverName The name of the server. * - * @param {string} dnsAliasName The name of the server DNS alias. + * @param {string} databaseName The name of the database. + * + * @param {string} restorePointName The name of the restore point. * * @param {object} [options] Optional Parameters. * @@ -18644,7 +24164,7 @@ export interface ServerDnsAliases { * * {Promise} A promise is returned. * - * @resolve {ServerDnsAlias} - The deserialized result object. + * @resolve {RestorePoint} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -18652,29 +24172,30 @@ export interface ServerDnsAliases { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {ServerDnsAlias} [result] - The deserialized result object if an error did not occur. - * See {@link ServerDnsAlias} for more information. + * {RestorePoint} [result] - The deserialized result object if an error did not occur. + * See {@link RestorePoint} for more information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - get(resourceGroupName: string, serverName: string, dnsAliasName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - get(resourceGroupName: string, serverName: string, dnsAliasName: string, callback: ServiceCallback): void; - get(resourceGroupName: string, serverName: string, dnsAliasName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, databaseName: string, restorePointName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, serverName: string, databaseName: string, restorePointName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, databaseName: string, restorePointName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Creates a server dns alias. + * Deletes a restore point. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} serverName The name of the server that the alias is pointing - * to. + * @param {string} serverName The name of the server. * - * @param {string} dnsAliasName The name of the server DNS alias. + * @param {string} databaseName The name of the database. + * + * @param {string} restorePointName The name of the restore point. * * @param {object} [options] Optional Parameters. * @@ -18683,23 +24204,24 @@ export interface ServerDnsAliases { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - createOrUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, dnsAliasName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + deleteMethodWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, restorePointName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Creates a server dns alias. + * Deletes a restore point. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} serverName The name of the server that the alias is pointing - * to. + * @param {string} serverName The name of the server. * - * @param {string} dnsAliasName The name of the server DNS alias. + * @param {string} databaseName The name of the database. + * + * @param {string} restorePointName The name of the restore point. * * @param {object} [options] Optional Parameters. * @@ -18713,7 +24235,7 @@ export interface ServerDnsAliases { * * {Promise} A promise is returned. * - * @resolve {ServerDnsAlias} - The deserialized result object. + * @resolve {null} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -18721,29 +24243,33 @@ export interface ServerDnsAliases { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {ServerDnsAlias} [result] - The deserialized result object if an error did not occur. - * See {@link ServerDnsAlias} for more information. + * {null} [result] - The deserialized result object if an error did not occur. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - createOrUpdate(resourceGroupName: string, serverName: string, dnsAliasName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - createOrUpdate(resourceGroupName: string, serverName: string, dnsAliasName: string, callback: ServiceCallback): void; - createOrUpdate(resourceGroupName: string, serverName: string, dnsAliasName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, serverName: string, databaseName: string, restorePointName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, serverName: string, databaseName: string, restorePointName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, serverName: string, databaseName: string, restorePointName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Deletes the server DNS alias with the given name. + * Creates a restore point for a data warehouse. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} serverName The name of the server that the alias is pointing - * to. + * @param {string} serverName The name of the server. * - * @param {string} dnsAliasName The name of the server DNS alias. + * @param {string} databaseName The name of the database. + * + * @param {object} parameters The definition for creating the restore point of + * this database. + * + * @param {string} parameters.restorePointLabel The restore point label to + * apply * * @param {object} [options] Optional Parameters. * @@ -18752,23 +24278,28 @@ export interface ServerDnsAliases { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - deleteMethodWithHttpOperationResponse(resourceGroupName: string, serverName: string, dnsAliasName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + beginCreateWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.CreateDatabaseRestorePointDefinition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Deletes the server DNS alias with the given name. + * Creates a restore point for a data warehouse. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} serverName The name of the server that the alias is pointing - * to. + * @param {string} serverName The name of the server. * - * @param {string} dnsAliasName The name of the server DNS alias. + * @param {string} databaseName The name of the database. + * + * @param {object} parameters The definition for creating the restore point of + * this database. + * + * @param {string} parameters.restorePointLabel The restore point label to + * apply * * @param {object} [options] Optional Parameters. * @@ -18782,7 +24313,7 @@ export interface ServerDnsAliases { * * {Promise} A promise is returned. * - * @resolve {null} - The deserialized result object. + * @resolve {RestorePoint} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -18790,26 +24321,39 @@ export interface ServerDnsAliases { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {null} [result] - The deserialized result object if an error did not occur. + * {RestorePoint} [result] - The deserialized result object if an error did not occur. + * See {@link RestorePoint} 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. */ - deleteMethod(resourceGroupName: string, serverName: string, dnsAliasName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - deleteMethod(resourceGroupName: string, serverName: string, dnsAliasName: string, callback: ServiceCallback): void; - deleteMethod(resourceGroupName: string, serverName: string, dnsAliasName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + beginCreate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.CreateDatabaseRestorePointDefinition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginCreate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.CreateDatabaseRestorePointDefinition, callback: ServiceCallback): void; + beginCreate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.CreateDatabaseRestorePointDefinition, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * DatabaseOperations + * __NOTE__: An instance of this class is automatically created for an + * instance of the SqlManagementClient. + */ +export interface DatabaseOperations { /** - * Gets a list of server DNS aliases for a server. + * Cancels the asynchronous operation on the database. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} serverName The name of the server that the alias is pointing - * to. + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @param {uuid} operationId The operation identifier. * * @param {object} [options] Optional Parameters. * @@ -18818,21 +24362,24 @@ export interface ServerDnsAliases { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listByServerWithHttpOperationResponse(resourceGroupName: string, serverName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + cancelWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, operationId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets a list of server DNS aliases for a server. + * Cancels the asynchronous operation on the database. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} serverName The name of the server that the alias is pointing - * to. + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @param {uuid} operationId The operation identifier. * * @param {object} [options] Optional Parameters. * @@ -18846,7 +24393,7 @@ export interface ServerDnsAliases { * * {Promise} A promise is returned. * - * @resolve {ServerDnsAliasListResult} - The deserialized result object. + * @resolve {null} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -18854,35 +24401,27 @@ export interface ServerDnsAliases { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {ServerDnsAliasListResult} [result] - The deserialized result object if an error did not occur. - * See {@link ServerDnsAliasListResult} for more - * information. + * {null} [result] - The deserialized result object if an error did not occur. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - listByServer(resourceGroupName: string, serverName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByServer(resourceGroupName: string, serverName: string, callback: ServiceCallback): void; - listByServer(resourceGroupName: string, serverName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + cancel(resourceGroupName: string, serverName: string, databaseName: string, operationId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + cancel(resourceGroupName: string, serverName: string, databaseName: string, operationId: string, callback: ServiceCallback): void; + cancel(resourceGroupName: string, serverName: string, databaseName: string, operationId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Acquires server DNS alias from another server. + * Gets a list of operations performed on the database. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} serverName The name of the server that the alias is pointing - * to. - * - * @param {string} dnsAliasName The name of the server dns alias. - * - * @param {object} parameters + * @param {string} serverName The name of the server. * - * @param {string} [parameters.oldServerDnsAliasId] The id of the server alias - * that will be acquired to point to this server instead. + * @param {string} databaseName The name of the database. * * @param {object} [options] Optional Parameters. * @@ -18891,28 +24430,22 @@ export interface ServerDnsAliases { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - acquireWithHttpOperationResponse(resourceGroupName: string, serverName: string, dnsAliasName: string, parameters: models.ServerDnsAliasAcquisition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listByDatabaseWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Acquires server DNS alias from another server. - * - * @param {string} resourceGroupName The name of the resource group that - * contains the resource. You can obtain this value from the Azure Resource - * Manager API or the portal. - * - * @param {string} serverName The name of the server that the alias is pointing - * to. + * Gets a list of operations performed on the database. * - * @param {string} dnsAliasName The name of the server dns alias. + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. * - * @param {object} parameters + * @param {string} serverName The name of the server. * - * @param {string} [parameters.oldServerDnsAliasId] The id of the server alias - * that will be acquired to point to this server instead. + * @param {string} databaseName The name of the database. * * @param {object} [options] Optional Parameters. * @@ -18926,7 +24459,7 @@ export interface ServerDnsAliases { * * {Promise} A promise is returned. * - * @resolve {null} - The deserialized result object. + * @resolve {DatabaseOperationListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -18934,28 +24467,24 @@ export interface ServerDnsAliases { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {null} [result] - The deserialized result object if an error did not occur. + * {DatabaseOperationListResult} [result] - The deserialized result object if an error did not occur. + * See {@link DatabaseOperationListResult} 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. */ - acquire(resourceGroupName: string, serverName: string, dnsAliasName: string, parameters: models.ServerDnsAliasAcquisition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - acquire(resourceGroupName: string, serverName: string, dnsAliasName: string, parameters: models.ServerDnsAliasAcquisition, callback: ServiceCallback): void; - acquire(resourceGroupName: string, serverName: string, dnsAliasName: string, parameters: models.ServerDnsAliasAcquisition, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + listByDatabase(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByDatabase(resourceGroupName: string, serverName: string, databaseName: string, callback: ServiceCallback): void; + listByDatabase(resourceGroupName: string, serverName: string, databaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Creates a server dns alias. - * - * @param {string} resourceGroupName The name of the resource group that - * contains the resource. You can obtain this value from the Azure Resource - * Manager API or the portal. - * - * @param {string} serverName The name of the server that the alias is pointing - * to. + * Gets a list of operations performed on the database. * - * @param {string} dnsAliasName The name of the server DNS alias. + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. * * @param {object} [options] Optional Parameters. * @@ -18964,23 +24493,17 @@ export interface ServerDnsAliases { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, dnsAliasName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listByDatabaseNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Creates a server dns alias. - * - * @param {string} resourceGroupName The name of the resource group that - * contains the resource. You can obtain this value from the Azure Resource - * Manager API or the portal. - * - * @param {string} serverName The name of the server that the alias is pointing - * to. + * Gets a list of operations performed on the database. * - * @param {string} dnsAliasName The name of the server DNS alias. + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. * * @param {object} [options] Optional Parameters. * @@ -18994,7 +24517,7 @@ export interface ServerDnsAliases { * * {Promise} A promise is returned. * - * @resolve {ServerDnsAlias} - The deserialized result object. + * @resolve {DatabaseOperationListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -19002,29 +24525,40 @@ export interface ServerDnsAliases { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {ServerDnsAlias} [result] - The deserialized result object if an error did not occur. - * See {@link ServerDnsAlias} for more information. + * {DatabaseOperationListResult} [result] - The deserialized result object if an error did not occur. + * See {@link DatabaseOperationListResult} 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. */ - beginCreateOrUpdate(resourceGroupName: string, serverName: string, dnsAliasName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - beginCreateOrUpdate(resourceGroupName: string, serverName: string, dnsAliasName: string, callback: ServiceCallback): void; - beginCreateOrUpdate(resourceGroupName: string, serverName: string, dnsAliasName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + listByDatabaseNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByDatabaseNext(nextPageLink: string, callback: ServiceCallback): void; + listByDatabaseNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ElasticPoolOperations + * __NOTE__: An instance of this class is automatically created for an + * instance of the SqlManagementClient. + */ +export interface ElasticPoolOperations { /** - * Deletes the server DNS alias with the given name. + * Cancels the asynchronous operation on the elastic pool. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} serverName The name of the server that the alias is pointing - * to. + * @param {string} serverName The name of the server. * - * @param {string} dnsAliasName The name of the server DNS alias. + * @param {string} elasticPoolName + * + * @param {uuid} operationId The operation identifier. * * @param {object} [options] Optional Parameters. * @@ -19037,19 +24571,20 @@ export interface ServerDnsAliases { * * @reject {Error|ServiceError} - The error object. */ - beginDeleteMethodWithHttpOperationResponse(resourceGroupName: string, serverName: string, dnsAliasName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + cancelWithHttpOperationResponse(resourceGroupName: string, serverName: string, elasticPoolName: string, operationId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Deletes the server DNS alias with the given name. + * Cancels the asynchronous operation on the elastic pool. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} serverName The name of the server that the alias is pointing - * to. + * @param {string} serverName The name of the server. * - * @param {string} dnsAliasName The name of the server DNS alias. + * @param {string} elasticPoolName + * + * @param {uuid} operationId The operation identifier. * * @param {object} [options] Optional Parameters. * @@ -19077,27 +24612,21 @@ export interface ServerDnsAliases { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - beginDeleteMethod(resourceGroupName: string, serverName: string, dnsAliasName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - beginDeleteMethod(resourceGroupName: string, serverName: string, dnsAliasName: string, callback: ServiceCallback): void; - beginDeleteMethod(resourceGroupName: string, serverName: string, dnsAliasName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + cancel(resourceGroupName: string, serverName: string, elasticPoolName: string, operationId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + cancel(resourceGroupName: string, serverName: string, elasticPoolName: string, operationId: string, callback: ServiceCallback): void; + cancel(resourceGroupName: string, serverName: string, elasticPoolName: string, operationId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Acquires server DNS alias from another server. + * Gets a list of operations performed on the elastic pool. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} serverName The name of the server that the alias is pointing - * to. - * - * @param {string} dnsAliasName The name of the server dns alias. - * - * @param {object} parameters + * @param {string} serverName The name of the server. * - * @param {string} [parameters.oldServerDnsAliasId] The id of the server alias - * that will be acquired to point to this server instead. + * @param {string} elasticPoolName * * @param {object} [options] Optional Parameters. * @@ -19106,28 +24635,22 @@ export interface ServerDnsAliases { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - beginAcquireWithHttpOperationResponse(resourceGroupName: string, serverName: string, dnsAliasName: string, parameters: models.ServerDnsAliasAcquisition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listByElasticPoolWithHttpOperationResponse(resourceGroupName: string, serverName: string, elasticPoolName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Acquires server DNS alias from another server. + * Gets a list of operations performed on the elastic pool. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} serverName The name of the server that the alias is pointing - * to. - * - * @param {string} dnsAliasName The name of the server dns alias. - * - * @param {object} parameters + * @param {string} serverName The name of the server. * - * @param {string} [parameters.oldServerDnsAliasId] The id of the server alias - * that will be acquired to point to this server instead. + * @param {string} elasticPoolName * * @param {object} [options] Optional Parameters. * @@ -19141,7 +24664,7 @@ export interface ServerDnsAliases { * * {Promise} A promise is returned. * - * @resolve {null} - The deserialized result object. + * @resolve {ElasticPoolOperationListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -19149,19 +24672,21 @@ export interface ServerDnsAliases { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {null} [result] - The deserialized result object if an error did not occur. + * {ElasticPoolOperationListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ElasticPoolOperationListResult} 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. */ - beginAcquire(resourceGroupName: string, serverName: string, dnsAliasName: string, parameters: models.ServerDnsAliasAcquisition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - beginAcquire(resourceGroupName: string, serverName: string, dnsAliasName: string, parameters: models.ServerDnsAliasAcquisition, callback: ServiceCallback): void; - beginAcquire(resourceGroupName: string, serverName: string, dnsAliasName: string, parameters: models.ServerDnsAliasAcquisition, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + listByElasticPool(resourceGroupName: string, serverName: string, elasticPoolName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByElasticPool(resourceGroupName: string, serverName: string, elasticPoolName: string, callback: ServiceCallback): void; + listByElasticPool(resourceGroupName: string, serverName: string, elasticPoolName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Gets a list of server DNS aliases for a server. + * Gets a list of operations performed on the elastic pool. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -19173,14 +24698,14 @@ export interface ServerDnsAliases { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listByServerNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listByElasticPoolNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets a list of server DNS aliases for a server. + * Gets a list of operations performed on the elastic pool. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -19197,7 +24722,7 @@ export interface ServerDnsAliases { * * {Promise} A promise is returned. * - * @resolve {ServerDnsAliasListResult} - The deserialized result object. + * @resolve {ElasticPoolOperationListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -19205,65 +24730,65 @@ export interface ServerDnsAliases { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {ServerDnsAliasListResult} [result] - The deserialized result object if an error did not occur. - * See {@link ServerDnsAliasListResult} for more + * {ElasticPoolOperationListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ElasticPoolOperationListResult} 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. */ - listByServerNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByServerNext(nextPageLink: string, callback: ServiceCallback): void; - listByServerNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + listByElasticPoolNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByElasticPoolNext(nextPageLink: string, callback: ServiceCallback): void; + listByElasticPoolNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } /** * @class - * RestorePoints + * Capabilities * __NOTE__: An instance of this class is automatically created for an * instance of the SqlManagementClient. */ -export interface RestorePoints { +export interface Capabilities { /** - * Gets a list of database restore points. - * - * @param {string} resourceGroupName The name of the resource group that - * contains the resource. You can obtain this value from the Azure Resource - * Manager API or the portal. - * - * @param {string} serverName The name of the server. + * Gets the subscription capabilities available for the specified location. * - * @param {string} databaseName The name of the database. + * @param {string} locationName The location name whose capabilities are + * retrieved. * * @param {object} [options] Optional Parameters. * + * @param {string} [options.include] If specified, restricts the response to + * only include the selected item. Possible values include: + * 'supportedEditions', 'supportedElasticPoolEditions', + * 'supportedManagedInstanceVersions' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listByDatabaseWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listByLocationWithHttpOperationResponse(locationName: string, options?: { include? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets a list of database restore points. - * - * @param {string} resourceGroupName The name of the resource group that - * contains the resource. You can obtain this value from the Azure Resource - * Manager API or the portal. - * - * @param {string} serverName The name of the server. + * Gets the subscription capabilities available for the specified location. * - * @param {string} databaseName The name of the database. + * @param {string} locationName The location name whose capabilities are + * retrieved. * * @param {object} [options] Optional Parameters. * + * @param {string} [options.include] If specified, restricts the response to + * only include the selected item. Possible values include: + * 'supportedEditions', 'supportedElasticPoolEditions', + * 'supportedManagedInstanceVersions' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -19274,7 +24799,7 @@ export interface RestorePoints { * * {Promise} A promise is returned. * - * @resolve {RestorePointListResult} - The deserialized result object. + * @resolve {LocationCapabilities} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -19282,21 +24807,29 @@ export interface RestorePoints { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {RestorePointListResult} [result] - The deserialized result object if an error did not occur. - * See {@link RestorePointListResult} for more - * information. + * {LocationCapabilities} [result] - The deserialized result object if an error did not occur. + * See {@link LocationCapabilities} 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. */ - listByDatabase(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByDatabase(resourceGroupName: string, serverName: string, databaseName: string, callback: ServiceCallback): void; - listByDatabase(resourceGroupName: string, serverName: string, databaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + listByLocation(locationName: string, options?: { include? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + listByLocation(locationName: string, callback: ServiceCallback): void; + listByLocation(locationName: string, options: { include? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * DatabaseVulnerabilityAssessmentScans + * __NOTE__: An instance of this class is automatically created for an + * instance of the SqlManagementClient. + */ +export interface DatabaseVulnerabilityAssessmentScans { /** - * Creates a restore point for a data warehouse. + * Gets a vulnerability assessment scan record of a database. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -19306,11 +24839,8 @@ export interface RestorePoints { * * @param {string} databaseName The name of the database. * - * @param {object} parameters The definition for creating the restore point of - * this database. - * - * @param {string} parameters.restorePointLabel The restore point label to - * apply + * @param {string} scanId The vulnerability assessment scan Id of the scan to + * retrieve. * * @param {object} [options] Optional Parameters. * @@ -19319,14 +24849,14 @@ export interface RestorePoints { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - createWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.CreateDatabaseRestorePointDefinition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + getWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, scanId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Creates a restore point for a data warehouse. + * Gets a vulnerability assessment scan record of a database. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -19336,11 +24866,8 @@ export interface RestorePoints { * * @param {string} databaseName The name of the database. * - * @param {object} parameters The definition for creating the restore point of - * this database. - * - * @param {string} parameters.restorePointLabel The restore point label to - * apply + * @param {string} scanId The vulnerability assessment scan Id of the scan to + * retrieve. * * @param {object} [options] Optional Parameters. * @@ -19354,7 +24881,7 @@ export interface RestorePoints { * * {Promise} A promise is returned. * - * @resolve {RestorePoint} - The deserialized result object. + * @resolve {VulnerabilityAssessmentScanRecord} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -19362,20 +24889,21 @@ export interface RestorePoints { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {RestorePoint} [result] - The deserialized result object if an error did not occur. - * See {@link RestorePoint} for more information. + * {VulnerabilityAssessmentScanRecord} [result] - The deserialized result object if an error did not occur. + * See {@link VulnerabilityAssessmentScanRecord} 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. */ - create(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.CreateDatabaseRestorePointDefinition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - create(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.CreateDatabaseRestorePointDefinition, callback: ServiceCallback): void; - create(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.CreateDatabaseRestorePointDefinition, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, databaseName: string, scanId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, serverName: string, databaseName: string, scanId: string, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, databaseName: string, scanId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Gets a restore point. + * Executes a Vulnerability Assessment database scan. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -19385,7 +24913,8 @@ export interface RestorePoints { * * @param {string} databaseName The name of the database. * - * @param {string} restorePointName The name of the restore point. + * @param {string} scanId The vulnerability assessment scan Id of the scan to + * retrieve. * * @param {object} [options] Optional Parameters. * @@ -19394,14 +24923,14 @@ export interface RestorePoints { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - getWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, restorePointName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + executeWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, scanId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets a restore point. + * Executes a Vulnerability Assessment database scan. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -19411,7 +24940,8 @@ export interface RestorePoints { * * @param {string} databaseName The name of the database. * - * @param {string} restorePointName The name of the restore point. + * @param {string} scanId The vulnerability assessment scan Id of the scan to + * retrieve. * * @param {object} [options] Optional Parameters. * @@ -19425,7 +24955,7 @@ export interface RestorePoints { * * {Promise} A promise is returned. * - * @resolve {RestorePoint} - The deserialized result object. + * @resolve {null} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -19433,20 +24963,19 @@ export interface RestorePoints { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {RestorePoint} [result] - The deserialized result object if an error did not occur. - * See {@link RestorePoint} for more information. + * {null} [result] - The deserialized result object if an error did not occur. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - get(resourceGroupName: string, serverName: string, databaseName: string, restorePointName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - get(resourceGroupName: string, serverName: string, databaseName: string, restorePointName: string, callback: ServiceCallback): void; - get(resourceGroupName: string, serverName: string, databaseName: string, restorePointName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + execute(resourceGroupName: string, serverName: string, databaseName: string, scanId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + execute(resourceGroupName: string, serverName: string, databaseName: string, scanId: string, callback: ServiceCallback): void; + execute(resourceGroupName: string, serverName: string, databaseName: string, scanId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Deletes a restore point. + * Lists the vulnerability assessment scans of a database. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -19456,8 +24985,6 @@ export interface RestorePoints { * * @param {string} databaseName The name of the database. * - * @param {string} restorePointName The name of the restore point. - * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -19465,14 +24992,14 @@ export interface RestorePoints { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - deleteMethodWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, restorePointName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listByDatabaseWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Deletes a restore point. + * Lists the vulnerability assessment scans of a database. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -19482,8 +25009,6 @@ export interface RestorePoints { * * @param {string} databaseName The name of the database. * - * @param {string} restorePointName The name of the restore point. - * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -19496,7 +25021,7 @@ export interface RestorePoints { * * {Promise} A promise is returned. * - * @resolve {null} - The deserialized result object. + * @resolve {VulnerabilityAssessmentScanRecordListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -19504,19 +25029,22 @@ export interface RestorePoints { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {null} [result] - The deserialized result object if an error did not occur. + * {VulnerabilityAssessmentScanRecordListResult} [result] - The deserialized result object if an error did not occur. + * See {@link VulnerabilityAssessmentScanRecordListResult} + * 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. */ - deleteMethod(resourceGroupName: string, serverName: string, databaseName: string, restorePointName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - deleteMethod(resourceGroupName: string, serverName: string, databaseName: string, restorePointName: string, callback: ServiceCallback): void; - deleteMethod(resourceGroupName: string, serverName: string, databaseName: string, restorePointName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + listByDatabase(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByDatabase(resourceGroupName: string, serverName: string, databaseName: string, callback: ServiceCallback): void; + listByDatabase(resourceGroupName: string, serverName: string, databaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Creates a restore point for a data warehouse. + * Convert an existing scan result to a human readable format. If already + * exists nothing happens * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -19524,13 +25052,9 @@ export interface RestorePoints { * * @param {string} serverName The name of the server. * - * @param {string} databaseName The name of the database. - * - * @param {object} parameters The definition for creating the restore point of - * this database. + * @param {string} databaseName The name of the scanned database. * - * @param {string} parameters.restorePointLabel The restore point label to - * apply + * @param {string} scanId The vulnerability assessment scan Id. * * @param {object} [options] Optional Parameters. * @@ -19539,14 +25063,15 @@ export interface RestorePoints { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - beginCreateWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.CreateDatabaseRestorePointDefinition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + exportMethodWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, scanId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Creates a restore point for a data warehouse. + * Convert an existing scan result to a human readable format. If already + * exists nothing happens * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -19554,13 +25079,9 @@ export interface RestorePoints { * * @param {string} serverName The name of the server. * - * @param {string} databaseName The name of the database. - * - * @param {object} parameters The definition for creating the restore point of - * this database. + * @param {string} databaseName The name of the scanned database. * - * @param {string} parameters.restorePointLabel The restore point label to - * apply + * @param {string} scanId The vulnerability assessment scan Id. * * @param {object} [options] Optional Parameters. * @@ -19574,7 +25095,7 @@ export interface RestorePoints { * * {Promise} A promise is returned. * - * @resolve {RestorePoint} - The deserialized result object. + * @resolve {DatabaseVulnerabilityAssessmentScansExport} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -19582,29 +25103,21 @@ export interface RestorePoints { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {RestorePoint} [result] - The deserialized result object if an error did not occur. - * See {@link RestorePoint} for more information. + * {DatabaseVulnerabilityAssessmentScansExport} [result] - The deserialized result object if an error did not occur. + * See {@link DatabaseVulnerabilityAssessmentScansExport} + * 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. */ - beginCreate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.CreateDatabaseRestorePointDefinition, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - beginCreate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.CreateDatabaseRestorePointDefinition, callback: ServiceCallback): void; - beginCreate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.CreateDatabaseRestorePointDefinition, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; -} - -/** - * @class - * DatabaseOperations - * __NOTE__: An instance of this class is automatically created for an - * instance of the SqlManagementClient. - */ -export interface DatabaseOperations { + exportMethod(resourceGroupName: string, serverName: string, databaseName: string, scanId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + exportMethod(resourceGroupName: string, serverName: string, databaseName: string, scanId: string, callback: ServiceCallback): void; + exportMethod(resourceGroupName: string, serverName: string, databaseName: string, scanId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Cancels the asynchronous operation on the database. + * Executes a Vulnerability Assessment database scan. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -19614,7 +25127,8 @@ export interface DatabaseOperations { * * @param {string} databaseName The name of the database. * - * @param {uuid} operationId The operation identifier. + * @param {string} scanId The vulnerability assessment scan Id of the scan to + * retrieve. * * @param {object} [options] Optional Parameters. * @@ -19627,10 +25141,10 @@ export interface DatabaseOperations { * * @reject {Error|ServiceError} - The error object. */ - cancelWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, operationId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + beginExecuteWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, scanId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Cancels the asynchronous operation on the database. + * Executes a Vulnerability Assessment database scan. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -19640,7 +25154,8 @@ export interface DatabaseOperations { * * @param {string} databaseName The name of the database. * - * @param {uuid} operationId The operation identifier. + * @param {string} scanId The vulnerability assessment scan Id of the scan to + * retrieve. * * @param {object} [options] Optional Parameters. * @@ -19668,21 +25183,16 @@ export interface DatabaseOperations { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - cancel(resourceGroupName: string, serverName: string, databaseName: string, operationId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - cancel(resourceGroupName: string, serverName: string, databaseName: string, operationId: string, callback: ServiceCallback): void; - cancel(resourceGroupName: string, serverName: string, databaseName: string, operationId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + beginExecute(resourceGroupName: string, serverName: string, databaseName: string, scanId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginExecute(resourceGroupName: string, serverName: string, databaseName: string, scanId: string, callback: ServiceCallback): void; + beginExecute(resourceGroupName: string, serverName: string, databaseName: string, scanId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Gets a list of operations performed on the database. - * - * @param {string} resourceGroupName The name of the resource group that - * contains the resource. You can obtain this value from the Azure Resource - * Manager API or the portal. - * - * @param {string} serverName The name of the server. + * Lists the vulnerability assessment scans of a database. * - * @param {string} databaseName The name of the database. + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. * * @param {object} [options] Optional Parameters. * @@ -19691,22 +25201,17 @@ export interface DatabaseOperations { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listByDatabaseWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listByDatabaseNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets a list of operations performed on the database. - * - * @param {string} resourceGroupName The name of the resource group that - * contains the resource. You can obtain this value from the Azure Resource - * Manager API or the portal. - * - * @param {string} serverName The name of the server. + * Lists the vulnerability assessment scans of a database. * - * @param {string} databaseName The name of the database. + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. * * @param {object} [options] Optional Parameters. * @@ -19720,7 +25225,7 @@ export interface DatabaseOperations { * * {Promise} A promise is returned. * - * @resolve {DatabaseOperationListResult} - The deserialized result object. + * @resolve {VulnerabilityAssessmentScanRecordListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -19728,24 +25233,39 @@ export interface DatabaseOperations { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {DatabaseOperationListResult} [result] - The deserialized result object if an error did not occur. - * See {@link DatabaseOperationListResult} for more - * information. + * {VulnerabilityAssessmentScanRecordListResult} [result] - The deserialized result object if an error did not occur. + * See {@link VulnerabilityAssessmentScanRecordListResult} + * 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. */ - listByDatabase(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByDatabase(resourceGroupName: string, serverName: string, databaseName: string, callback: ServiceCallback): void; - listByDatabase(resourceGroupName: string, serverName: string, databaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + listByDatabaseNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByDatabaseNext(nextPageLink: string, callback: ServiceCallback): void; + listByDatabaseNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * InstanceFailoverGroups + * __NOTE__: An instance of this class is automatically created for an + * instance of the SqlManagementClient. + */ +export interface InstanceFailoverGroups { /** - * Gets a list of operations performed on the database. + * Gets a failover group. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} locationName The name of the region where the resource is + * located. + * + * @param {string} failoverGroupName The name of the failover group. * * @param {object} [options] Optional Parameters. * @@ -19754,17 +25274,23 @@ export interface DatabaseOperations { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listByDatabaseNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + getWithHttpOperationResponse(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets a list of operations performed on the database. + * Gets a failover group. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} locationName The name of the region where the resource is + * located. + * + * @param {string} failoverGroupName The name of the failover group. * * @param {object} [options] Optional Parameters. * @@ -19778,7 +25304,7 @@ export interface DatabaseOperations { * * {Promise} A promise is returned. * - * @resolve {DatabaseOperationListResult} - The deserialized result object. + * @resolve {InstanceFailoverGroup} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -19786,40 +25312,58 @@ export interface DatabaseOperations { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {DatabaseOperationListResult} [result] - The deserialized result object if an error did not occur. - * See {@link DatabaseOperationListResult} for more - * information. + * {InstanceFailoverGroup} [result] - The deserialized result object if an error did not occur. + * See {@link InstanceFailoverGroup} 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. */ - listByDatabaseNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByDatabaseNext(nextPageLink: string, callback: ServiceCallback): void; - listByDatabaseNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; -} - -/** - * @class - * ElasticPoolOperations - * __NOTE__: An instance of this class is automatically created for an - * instance of the SqlManagementClient. - */ -export interface ElasticPoolOperations { + get(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, locationName: string, failoverGroupName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, locationName: string, failoverGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Cancels the asynchronous operation on the elastic pool. + * Creates or updates a failover group. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} serverName The name of the server. + * @param {string} locationName The name of the region where the resource is + * located. * - * @param {string} elasticPoolName + * @param {string} failoverGroupName The name of the failover group. * - * @param {uuid} operationId The operation identifier. + * @param {object} parameters The failover group parameters. + * + * @param {object} parameters.readWriteEndpoint Read-write endpoint of the + * failover group instance. + * + * @param {string} parameters.readWriteEndpoint.failoverPolicy Failover policy + * of the read-write endpoint for the failover group. If failoverPolicy is + * Automatic then failoverWithDataLossGracePeriodMinutes is required. Possible + * values include: 'Manual', 'Automatic' + * + * @param {number} + * [parameters.readWriteEndpoint.failoverWithDataLossGracePeriodMinutes] Grace + * period before failover with data loss is attempted for the read-write + * endpoint. If failoverPolicy is Automatic then + * failoverWithDataLossGracePeriodMinutes is required. + * + * @param {object} [parameters.readOnlyEndpoint] Read-only endpoint of the + * failover group instance. + * + * @param {string} [parameters.readOnlyEndpoint.failoverPolicy] Failover policy + * of the read-only endpoint for the failover group. Possible values include: + * 'Disabled', 'Enabled' + * + * @param {array} parameters.partnerRegions Partner region information for the + * failover group. + * + * @param {array} parameters.managedInstancePairs List of managed instance + * pairs in the failover group. * * @param {object} [options] Optional Parameters. * @@ -19828,24 +25372,52 @@ export interface ElasticPoolOperations { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - cancelWithHttpOperationResponse(resourceGroupName: string, serverName: string, elasticPoolName: string, operationId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, locationName: string, failoverGroupName: string, parameters: models.InstanceFailoverGroup, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Cancels the asynchronous operation on the elastic pool. + * Creates or updates a failover group. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} serverName The name of the server. + * @param {string} locationName The name of the region where the resource is + * located. * - * @param {string} elasticPoolName + * @param {string} failoverGroupName The name of the failover group. * - * @param {uuid} operationId The operation identifier. + * @param {object} parameters The failover group parameters. + * + * @param {object} parameters.readWriteEndpoint Read-write endpoint of the + * failover group instance. + * + * @param {string} parameters.readWriteEndpoint.failoverPolicy Failover policy + * of the read-write endpoint for the failover group. If failoverPolicy is + * Automatic then failoverWithDataLossGracePeriodMinutes is required. Possible + * values include: 'Manual', 'Automatic' + * + * @param {number} + * [parameters.readWriteEndpoint.failoverWithDataLossGracePeriodMinutes] Grace + * period before failover with data loss is attempted for the read-write + * endpoint. If failoverPolicy is Automatic then + * failoverWithDataLossGracePeriodMinutes is required. + * + * @param {object} [parameters.readOnlyEndpoint] Read-only endpoint of the + * failover group instance. + * + * @param {string} [parameters.readOnlyEndpoint.failoverPolicy] Failover policy + * of the read-only endpoint for the failover group. Possible values include: + * 'Disabled', 'Enabled' + * + * @param {array} parameters.partnerRegions Partner region information for the + * failover group. + * + * @param {array} parameters.managedInstancePairs List of managed instance + * pairs in the failover group. * * @param {object} [options] Optional Parameters. * @@ -19859,7 +25431,7 @@ export interface ElasticPoolOperations { * * {Promise} A promise is returned. * - * @resolve {null} - The deserialized result object. + * @resolve {InstanceFailoverGroup} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -19867,27 +25439,29 @@ export interface ElasticPoolOperations { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {null} [result] - The deserialized result object if an error did not occur. + * {InstanceFailoverGroup} [result] - The deserialized result object if an error did not occur. + * See {@link InstanceFailoverGroup} 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. */ - cancel(resourceGroupName: string, serverName: string, elasticPoolName: string, operationId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - cancel(resourceGroupName: string, serverName: string, elasticPoolName: string, operationId: string, callback: ServiceCallback): void; - cancel(resourceGroupName: string, serverName: string, elasticPoolName: string, operationId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, locationName: string, failoverGroupName: string, parameters: models.InstanceFailoverGroup, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, locationName: string, failoverGroupName: string, parameters: models.InstanceFailoverGroup, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, locationName: string, failoverGroupName: string, parameters: models.InstanceFailoverGroup, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Gets a list of operations performed on the elastic pool. + * Deletes a failover group. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} serverName The name of the server. + * @param {string} locationName The name of the region where the resource is + * located. * - * @param {string} elasticPoolName + * @param {string} failoverGroupName The name of the failover group. * * @param {object} [options] Optional Parameters. * @@ -19896,22 +25470,23 @@ export interface ElasticPoolOperations { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listByElasticPoolWithHttpOperationResponse(resourceGroupName: string, serverName: string, elasticPoolName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + deleteMethodWithHttpOperationResponse(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets a list of operations performed on the elastic pool. + * Deletes a failover group. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} serverName The name of the server. + * @param {string} locationName The name of the region where the resource is + * located. * - * @param {string} elasticPoolName + * @param {string} failoverGroupName The name of the failover group. * * @param {object} [options] Optional Parameters. * @@ -19925,7 +25500,7 @@ export interface ElasticPoolOperations { * * {Promise} A promise is returned. * - * @resolve {ElasticPoolOperationListResult} - The deserialized result object. + * @resolve {null} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -19933,24 +25508,26 @@ export interface ElasticPoolOperations { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {ElasticPoolOperationListResult} [result] - The deserialized result object if an error did not occur. - * See {@link ElasticPoolOperationListResult} for more - * information. - * + * {null} [result] - The deserialized result object if an error did not occur. + * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - listByElasticPool(resourceGroupName: string, serverName: string, elasticPoolName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByElasticPool(resourceGroupName: string, serverName: string, elasticPoolName: string, callback: ServiceCallback): void; - listByElasticPool(resourceGroupName: string, serverName: string, elasticPoolName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, locationName: string, failoverGroupName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, locationName: string, failoverGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Gets a list of operations performed on the elastic pool. + * Lists the failover groups in a location. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} locationName The name of the region where the resource is + * located. * * @param {object} [options] Optional Parameters. * @@ -19959,17 +25536,21 @@ export interface ElasticPoolOperations { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listByElasticPoolNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listByLocationWithHttpOperationResponse(resourceGroupName: string, locationName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets a list of operations performed on the elastic pool. + * Lists the failover groups in a location. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} locationName The name of the region where the resource is + * located. * * @param {object} [options] Optional Parameters. * @@ -19983,7 +25564,7 @@ export interface ElasticPoolOperations { * * {Promise} A promise is returned. * - * @resolve {ElasticPoolOperationListResult} - The deserialized result object. + * @resolve {InstanceFailoverGroupListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -19991,64 +25572,59 @@ export interface ElasticPoolOperations { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {ElasticPoolOperationListResult} [result] - The deserialized result object if an error did not occur. - * See {@link ElasticPoolOperationListResult} for more + * {InstanceFailoverGroupListResult} [result] - The deserialized result object if an error did not occur. + * See {@link InstanceFailoverGroupListResult} 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. */ - listByElasticPoolNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByElasticPoolNext(nextPageLink: string, callback: ServiceCallback): void; - listByElasticPoolNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; -} - -/** - * @class - * Capabilities - * __NOTE__: An instance of this class is automatically created for an - * instance of the SqlManagementClient. - */ -export interface Capabilities { + listByLocation(resourceGroupName: string, locationName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByLocation(resourceGroupName: string, locationName: string, callback: ServiceCallback): void; + listByLocation(resourceGroupName: string, locationName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Gets the subscription capabilities available for the specified location. + * Fails over from the current primary managed instance to this managed + * instance. * - * @param {string} locationName The location name whose capabilities are - * retrieved. + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. * - * @param {object} [options] Optional Parameters. + * @param {string} locationName The name of the region where the resource is + * located. * - * @param {string} [options.include] If specified, restricts the response to - * only include the selected item. Possible values include: - * 'supportedEditions', 'supportedElasticPoolEditions', - * 'supportedManagedInstanceVersions' + * @param {string} failoverGroupName The name of the failover group. + * + * @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. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listByLocationWithHttpOperationResponse(locationName: string, options?: { include? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + failoverWithHttpOperationResponse(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets the subscription capabilities available for the specified location. + * Fails over from the current primary managed instance to this managed + * instance. * - * @param {string} locationName The location name whose capabilities are - * retrieved. + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. * - * @param {object} [options] Optional Parameters. + * @param {string} locationName The name of the region where the resource is + * located. * - * @param {string} [options.include] If specified, restricts the response to - * only include the selected item. Possible values include: - * 'supportedEditions', 'supportedElasticPoolEditions', - * 'supportedManagedInstanceVersions' + * @param {string} failoverGroupName The name of the failover group. + * + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -20060,7 +25636,7 @@ export interface Capabilities { * * {Promise} A promise is returned. * - * @resolve {LocationCapabilities} - The deserialized result object. + * @resolve {InstanceFailoverGroup} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -20068,29 +25644,21 @@ export interface Capabilities { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {LocationCapabilities} [result] - The deserialized result object if an error did not occur. - * See {@link LocationCapabilities} for more information. + * {InstanceFailoverGroup} [result] - The deserialized result object if an error did not occur. + * See {@link InstanceFailoverGroup} 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. */ - listByLocation(locationName: string, options?: { include? : string, customHeaders? : { [headerName: string]: string; } }): Promise; - listByLocation(locationName: string, callback: ServiceCallback): void; - listByLocation(locationName: string, options: { include? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; -} - -/** - * @class - * InstanceFailoverGroups - * __NOTE__: An instance of this class is automatically created for an - * instance of the SqlManagementClient. - */ -export interface InstanceFailoverGroups { + failover(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + failover(resourceGroupName: string, locationName: string, failoverGroupName: string, callback: ServiceCallback): void; + failover(resourceGroupName: string, locationName: string, failoverGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Gets a failover group. + * Fails over from the current primary managed instance to this managed + * instance. This operation might result in data loss. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -20112,10 +25680,11 @@ export interface InstanceFailoverGroups { * * @reject {Error|ServiceError} - The error object. */ - getWithHttpOperationResponse(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + forceFailoverAllowDataLossWithHttpOperationResponse(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets a failover group. + * Fails over from the current primary managed instance to this managed + * instance. This operation might result in data loss. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -20153,9 +25722,9 @@ export interface InstanceFailoverGroups { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - get(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - get(resourceGroupName: string, locationName: string, failoverGroupName: string, callback: ServiceCallback): void; - get(resourceGroupName: string, locationName: string, failoverGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + forceFailoverAllowDataLoss(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + forceFailoverAllowDataLoss(resourceGroupName: string, locationName: string, failoverGroupName: string, callback: ServiceCallback): void; + forceFailoverAllowDataLoss(resourceGroupName: string, locationName: string, failoverGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -20210,7 +25779,7 @@ export interface InstanceFailoverGroups { * * @reject {Error|ServiceError} - The error object. */ - createOrUpdateWithHttpOperationResponse(resourceGroupName: string, locationName: string, failoverGroupName: string, parameters: models.InstanceFailoverGroup, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName: string, locationName: string, failoverGroupName: string, parameters: models.InstanceFailoverGroup, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Creates or updates a failover group. @@ -20280,9 +25849,9 @@ export interface InstanceFailoverGroups { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - createOrUpdate(resourceGroupName: string, locationName: string, failoverGroupName: string, parameters: models.InstanceFailoverGroup, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - createOrUpdate(resourceGroupName: string, locationName: string, failoverGroupName: string, parameters: models.InstanceFailoverGroup, callback: ServiceCallback): void; - createOrUpdate(resourceGroupName: string, locationName: string, failoverGroupName: string, parameters: models.InstanceFailoverGroup, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + beginCreateOrUpdate(resourceGroupName: string, locationName: string, failoverGroupName: string, parameters: models.InstanceFailoverGroup, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginCreateOrUpdate(resourceGroupName: string, locationName: string, failoverGroupName: string, parameters: models.InstanceFailoverGroup, callback: ServiceCallback): void; + beginCreateOrUpdate(resourceGroupName: string, locationName: string, failoverGroupName: string, parameters: models.InstanceFailoverGroup, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -20308,7 +25877,7 @@ export interface InstanceFailoverGroups { * * @reject {Error|ServiceError} - The error object. */ - deleteMethodWithHttpOperationResponse(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + beginDeleteMethodWithHttpOperationResponse(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Deletes a failover group. @@ -20348,13 +25917,14 @@ export interface InstanceFailoverGroups { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - deleteMethod(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - deleteMethod(resourceGroupName: string, locationName: string, failoverGroupName: string, callback: ServiceCallback): void; - deleteMethod(resourceGroupName: string, locationName: string, failoverGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + beginDeleteMethod(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginDeleteMethod(resourceGroupName: string, locationName: string, failoverGroupName: string, callback: ServiceCallback): void; + beginDeleteMethod(resourceGroupName: string, locationName: string, failoverGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Lists the failover groups in a location. + * Fails over from the current primary managed instance to this managed + * instance. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -20363,6 +25933,8 @@ export interface InstanceFailoverGroups { * @param {string} locationName The name of the region where the resource is * located. * + * @param {string} failoverGroupName The name of the failover group. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -20370,14 +25942,15 @@ export interface InstanceFailoverGroups { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listByLocationWithHttpOperationResponse(resourceGroupName: string, locationName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + beginFailoverWithHttpOperationResponse(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Lists the failover groups in a location. + * Fails over from the current primary managed instance to this managed + * instance. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -20386,6 +25959,8 @@ export interface InstanceFailoverGroups { * @param {string} locationName The name of the region where the resource is * located. * + * @param {string} failoverGroupName The name of the failover group. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -20398,7 +25973,7 @@ export interface InstanceFailoverGroups { * * {Promise} A promise is returned. * - * @resolve {InstanceFailoverGroupListResult} - The deserialized result object. + * @resolve {InstanceFailoverGroup} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -20406,22 +25981,21 @@ export interface InstanceFailoverGroups { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {InstanceFailoverGroupListResult} [result] - The deserialized result object if an error did not occur. - * See {@link InstanceFailoverGroupListResult} for more - * information. + * {InstanceFailoverGroup} [result] - The deserialized result object if an error did not occur. + * See {@link InstanceFailoverGroup} 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. */ - listByLocation(resourceGroupName: string, locationName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByLocation(resourceGroupName: string, locationName: string, callback: ServiceCallback): void; - listByLocation(resourceGroupName: string, locationName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + beginFailover(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginFailover(resourceGroupName: string, locationName: string, failoverGroupName: string, callback: ServiceCallback): void; + beginFailover(resourceGroupName: string, locationName: string, failoverGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** * Fails over from the current primary managed instance to this managed - * instance. + * instance. This operation might result in data loss. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -20443,11 +26017,11 @@ export interface InstanceFailoverGroups { * * @reject {Error|ServiceError} - The error object. */ - failoverWithHttpOperationResponse(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + beginForceFailoverAllowDataLossWithHttpOperationResponse(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Fails over from the current primary managed instance to this managed - * instance. + * instance. This operation might result in data loss. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource @@ -20485,23 +26059,16 @@ export interface InstanceFailoverGroups { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - failover(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - failover(resourceGroupName: string, locationName: string, failoverGroupName: string, callback: ServiceCallback): void; - failover(resourceGroupName: string, locationName: string, failoverGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + beginForceFailoverAllowDataLoss(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginForceFailoverAllowDataLoss(resourceGroupName: string, locationName: string, failoverGroupName: string, callback: ServiceCallback): void; + beginForceFailoverAllowDataLoss(resourceGroupName: string, locationName: string, failoverGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Fails over from the current primary managed instance to this managed - * instance. This operation might result in data loss. - * - * @param {string} resourceGroupName The name of the resource group that - * contains the resource. You can obtain this value from the Azure Resource - * Manager API or the portal. - * - * @param {string} locationName The name of the region where the resource is - * located. + * Lists the failover groups in a location. * - * @param {string} failoverGroupName The name of the failover group. + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. * * @param {object} [options] Optional Parameters. * @@ -20510,24 +26077,17 @@ export interface InstanceFailoverGroups { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - forceFailoverAllowDataLossWithHttpOperationResponse(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listByLocationNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Fails over from the current primary managed instance to this managed - * instance. This operation might result in data loss. - * - * @param {string} resourceGroupName The name of the resource group that - * contains the resource. You can obtain this value from the Azure Resource - * Manager API or the portal. - * - * @param {string} locationName The name of the region where the resource is - * located. + * Lists the failover groups in a location. * - * @param {string} failoverGroupName The name of the failover group. + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. * * @param {object} [options] Optional Parameters. * @@ -20541,7 +26101,7 @@ export interface InstanceFailoverGroups { * * {Promise} A promise is returned. * - * @resolve {InstanceFailoverGroup} - The deserialized result object. + * @resolve {InstanceFailoverGroupListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -20549,58 +26109,38 @@ export interface InstanceFailoverGroups { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {InstanceFailoverGroup} [result] - The deserialized result object if an error did not occur. - * See {@link InstanceFailoverGroup} for more information. + * {InstanceFailoverGroupListResult} [result] - The deserialized result object if an error did not occur. + * See {@link InstanceFailoverGroupListResult} 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. - */ - forceFailoverAllowDataLoss(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - forceFailoverAllowDataLoss(resourceGroupName: string, locationName: string, failoverGroupName: string, callback: ServiceCallback): void; - forceFailoverAllowDataLoss(resourceGroupName: string, locationName: string, failoverGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * Creates or updates a failover group. - * - * @param {string} resourceGroupName The name of the resource group that - * contains the resource. You can obtain this value from the Azure Resource - * Manager API or the portal. - * - * @param {string} locationName The name of the region where the resource is - * located. - * - * @param {string} failoverGroupName The name of the failover group. - * - * @param {object} parameters The failover group parameters. - * - * @param {object} parameters.readWriteEndpoint Read-write endpoint of the - * failover group instance. - * - * @param {string} parameters.readWriteEndpoint.failoverPolicy Failover policy - * of the read-write endpoint for the failover group. If failoverPolicy is - * Automatic then failoverWithDataLossGracePeriodMinutes is required. Possible - * values include: 'Manual', 'Automatic' - * - * @param {number} - * [parameters.readWriteEndpoint.failoverWithDataLossGracePeriodMinutes] Grace - * period before failover with data loss is attempted for the read-write - * endpoint. If failoverPolicy is Automatic then - * failoverWithDataLossGracePeriodMinutes is required. - * - * @param {object} [parameters.readOnlyEndpoint] Read-only endpoint of the - * failover group instance. + */ + listByLocationNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByLocationNext(nextPageLink: string, callback: ServiceCallback): void; + listByLocationNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ShortTermRetentionPolicies + * __NOTE__: An instance of this class is automatically created for an + * instance of the SqlManagementClient. + */ +export interface ShortTermRetentionPolicies { + + + /** + * Gets a database's short term retention policy. * - * @param {string} [parameters.readOnlyEndpoint.failoverPolicy] Failover policy - * of the read-only endpoint for the failover group. Possible values include: - * 'Disabled', 'Enabled' + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. * - * @param {array} parameters.partnerRegions Partner region information for the - * failover group. + * @param {string} serverName The name of the server. * - * @param {array} parameters.managedInstancePairs List of managed instance - * pairs in the failover group. + * @param {string} databaseName The name of the database. * * @param {object} [options] Optional Parameters. * @@ -20609,52 +26149,22 @@ export interface InstanceFailoverGroups { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName: string, locationName: string, failoverGroupName: string, parameters: models.InstanceFailoverGroup, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + getWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Creates or updates a failover group. + * Gets a database's short term retention policy. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} locationName The name of the region where the resource is - * located. - * - * @param {string} failoverGroupName The name of the failover group. - * - * @param {object} parameters The failover group parameters. - * - * @param {object} parameters.readWriteEndpoint Read-write endpoint of the - * failover group instance. - * - * @param {string} parameters.readWriteEndpoint.failoverPolicy Failover policy - * of the read-write endpoint for the failover group. If failoverPolicy is - * Automatic then failoverWithDataLossGracePeriodMinutes is required. Possible - * values include: 'Manual', 'Automatic' - * - * @param {number} - * [parameters.readWriteEndpoint.failoverWithDataLossGracePeriodMinutes] Grace - * period before failover with data loss is attempted for the read-write - * endpoint. If failoverPolicy is Automatic then - * failoverWithDataLossGracePeriodMinutes is required. - * - * @param {object} [parameters.readOnlyEndpoint] Read-only endpoint of the - * failover group instance. - * - * @param {string} [parameters.readOnlyEndpoint.failoverPolicy] Failover policy - * of the read-only endpoint for the failover group. Possible values include: - * 'Disabled', 'Enabled' - * - * @param {array} parameters.partnerRegions Partner region information for the - * failover group. + * @param {string} serverName The name of the server. * - * @param {array} parameters.managedInstancePairs List of managed instance - * pairs in the failover group. + * @param {string} databaseName The name of the database. * * @param {object} [options] Optional Parameters. * @@ -20668,7 +26178,7 @@ export interface InstanceFailoverGroups { * * {Promise} A promise is returned. * - * @resolve {InstanceFailoverGroup} - The deserialized result object. + * @resolve {ShortTermRetentionPolicy} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -20676,29 +26186,34 @@ export interface InstanceFailoverGroups { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {InstanceFailoverGroup} [result] - The deserialized result object if an error did not occur. - * See {@link InstanceFailoverGroup} for more information. + * {ShortTermRetentionPolicy} [result] - The deserialized result object if an error did not occur. + * See {@link ShortTermRetentionPolicy} 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. */ - beginCreateOrUpdate(resourceGroupName: string, locationName: string, failoverGroupName: string, parameters: models.InstanceFailoverGroup, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - beginCreateOrUpdate(resourceGroupName: string, locationName: string, failoverGroupName: string, parameters: models.InstanceFailoverGroup, callback: ServiceCallback): void; - beginCreateOrUpdate(resourceGroupName: string, locationName: string, failoverGroupName: string, parameters: models.InstanceFailoverGroup, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, serverName: string, databaseName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, serverName: string, databaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Deletes a failover group. + * Updates a database's short term retention policy. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} locationName The name of the region where the resource is - * located. + * @param {string} serverName The name of the server. * - * @param {string} failoverGroupName The name of the failover group. + * @param {string} databaseName The name of the database. + * + * @param {object} parameters The short term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. * * @param {object} [options] Optional Parameters. * @@ -20707,23 +26222,27 @@ export interface InstanceFailoverGroups { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - beginDeleteMethodWithHttpOperationResponse(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.ShortTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Deletes a failover group. + * Updates a database's short term retention policy. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} locationName The name of the region where the resource is - * located. + * @param {string} serverName The name of the server. * - * @param {string} failoverGroupName The name of the failover group. + * @param {string} databaseName The name of the database. + * + * @param {object} parameters The short term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. * * @param {object} [options] Optional Parameters. * @@ -20737,7 +26256,7 @@ export interface InstanceFailoverGroups { * * {Promise} A promise is returned. * - * @resolve {null} - The deserialized result object. + * @resolve {ShortTermRetentionPolicy} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -20745,29 +26264,34 @@ export interface InstanceFailoverGroups { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {null} [result] - The deserialized result object if an error did not occur. + * {ShortTermRetentionPolicy} [result] - The deserialized result object if an error did not occur. + * See {@link ShortTermRetentionPolicy} 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. */ - beginDeleteMethod(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - beginDeleteMethod(resourceGroupName: string, locationName: string, failoverGroupName: string, callback: ServiceCallback): void; - beginDeleteMethod(resourceGroupName: string, locationName: string, failoverGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.ShortTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.ShortTermRetentionPolicy, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.ShortTermRetentionPolicy, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Fails over from the current primary managed instance to this managed - * instance. + * Updates a database's short term retention policy. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} locationName The name of the region where the resource is - * located. + * @param {string} serverName The name of the server. * - * @param {string} failoverGroupName The name of the failover group. + * @param {string} databaseName The name of the database. + * + * @param {object} parameters The short term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. * * @param {object} [options] Optional Parameters. * @@ -20776,24 +26300,27 @@ export interface InstanceFailoverGroups { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - beginFailoverWithHttpOperationResponse(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + updateWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.ShortTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Fails over from the current primary managed instance to this managed - * instance. + * Updates a database's short term retention policy. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} locationName The name of the region where the resource is - * located. + * @param {string} serverName The name of the server. * - * @param {string} failoverGroupName The name of the failover group. + * @param {string} databaseName The name of the database. + * + * @param {object} parameters The short term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. * * @param {object} [options] Optional Parameters. * @@ -20807,7 +26334,7 @@ export interface InstanceFailoverGroups { * * {Promise} A promise is returned. * - * @resolve {InstanceFailoverGroup} - The deserialized result object. + * @resolve {ShortTermRetentionPolicy} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -20815,30 +26342,34 @@ export interface InstanceFailoverGroups { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {InstanceFailoverGroup} [result] - The deserialized result object if an error did not occur. - * See {@link InstanceFailoverGroup} for more information. + * {ShortTermRetentionPolicy} [result] - The deserialized result object if an error did not occur. + * See {@link ShortTermRetentionPolicy} 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. */ - beginFailover(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - beginFailover(resourceGroupName: string, locationName: string, failoverGroupName: string, callback: ServiceCallback): void; - beginFailover(resourceGroupName: string, locationName: string, failoverGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + update(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.ShortTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.ShortTermRetentionPolicy, callback: ServiceCallback): void; + update(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.ShortTermRetentionPolicy, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Fails over from the current primary managed instance to this managed - * instance. This operation might result in data loss. + * Updates a database's short term retention policy. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} locationName The name of the region where the resource is - * located. + * @param {string} serverName The name of the server. * - * @param {string} failoverGroupName The name of the failover group. + * @param {string} databaseName The name of the database. + * + * @param {object} parameters The short term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. * * @param {object} [options] Optional Parameters. * @@ -20847,24 +26378,27 @@ export interface InstanceFailoverGroups { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - beginForceFailoverAllowDataLossWithHttpOperationResponse(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.ShortTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Fails over from the current primary managed instance to this managed - * instance. This operation might result in data loss. + * Updates a database's short term retention policy. * * @param {string} resourceGroupName The name of the resource group that * contains the resource. You can obtain this value from the Azure Resource * Manager API or the portal. * - * @param {string} locationName The name of the region where the resource is - * located. + * @param {string} serverName The name of the server. * - * @param {string} failoverGroupName The name of the failover group. + * @param {string} databaseName The name of the database. + * + * @param {object} parameters The short term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. * * @param {object} [options] Optional Parameters. * @@ -20878,7 +26412,7 @@ export interface InstanceFailoverGroups { * * {Promise} A promise is returned. * - * @resolve {InstanceFailoverGroup} - The deserialized result object. + * @resolve {ShortTermRetentionPolicy} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -20886,23 +26420,34 @@ export interface InstanceFailoverGroups { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {InstanceFailoverGroup} [result] - The deserialized result object if an error did not occur. - * See {@link InstanceFailoverGroup} for more information. + * {ShortTermRetentionPolicy} [result] - The deserialized result object if an error did not occur. + * See {@link ShortTermRetentionPolicy} 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. */ - beginForceFailoverAllowDataLoss(resourceGroupName: string, locationName: string, failoverGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - beginForceFailoverAllowDataLoss(resourceGroupName: string, locationName: string, failoverGroupName: string, callback: ServiceCallback): void; - beginForceFailoverAllowDataLoss(resourceGroupName: string, locationName: string, failoverGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + beginCreateOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.ShortTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginCreateOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.ShortTermRetentionPolicy, callback: ServiceCallback): void; + beginCreateOrUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.ShortTermRetentionPolicy, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Lists the failover groups in a location. + * Updates a database's short term retention policy. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @param {object} parameters The short term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. * * @param {object} [options] Optional Parameters. * @@ -20911,17 +26456,27 @@ export interface InstanceFailoverGroups { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listByLocationNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + beginUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.ShortTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Lists the failover groups in a location. + * Updates a database's short term retention policy. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} databaseName The name of the database. + * + * @param {object} parameters The short term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. * * @param {object} [options] Optional Parameters. * @@ -20935,7 +26490,7 @@ export interface InstanceFailoverGroups { * * {Promise} A promise is returned. * - * @resolve {InstanceFailoverGroupListResult} - The deserialized result object. + * @resolve {ShortTermRetentionPolicy} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -20943,17 +26498,17 @@ export interface InstanceFailoverGroups { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {InstanceFailoverGroupListResult} [result] - The deserialized result object if an error did not occur. - * See {@link InstanceFailoverGroupListResult} for more + * {ShortTermRetentionPolicy} [result] - The deserialized result object if an error did not occur. + * See {@link ShortTermRetentionPolicy} 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. */ - listByLocationNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByLocationNext(nextPageLink: string, callback: ServiceCallback): void; - listByLocationNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + beginUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.ShortTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.ShortTermRetentionPolicy, callback: ServiceCallback): void; + beginUpdate(resourceGroupName: string, serverName: string, databaseName: string, parameters: models.ShortTermRetentionPolicy, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } /** diff --git a/lib/services/sqlManagement2/lib/operations/index.js b/lib/services/sqlManagement2/lib/operations/index.js index 216e19d49f..7d011bc602 100644 --- a/lib/services/sqlManagement2/lib/operations/index.js +++ b/lib/services/sqlManagement2/lib/operations/index.js @@ -49,6 +49,17 @@ exports.SyncGroups = require('./syncGroups'); exports.SyncMembers = require('./syncMembers'); exports.SubscriptionUsages = require('./subscriptionUsages'); exports.VirtualNetworkRules = require('./virtualNetworkRules'); +exports.DatabaseVulnerabilityAssessmentRuleBaselines = require('./databaseVulnerabilityAssessmentRuleBaselines'); +exports.DatabaseVulnerabilityAssessments = require('./databaseVulnerabilityAssessments'); +exports.JobAgents = require('./jobAgents'); +exports.JobCredentials = require('./jobCredentials'); +exports.JobExecutions = require('./jobExecutions'); +exports.Jobs = require('./jobs'); +exports.JobStepExecutions = require('./jobStepExecutions'); +exports.JobSteps = require('./jobSteps'); +exports.JobTargetExecutions = require('./jobTargetExecutions'); +exports.JobTargetGroups = require('./jobTargetGroups'); +exports.JobVersions = require('./jobVersions'); exports.LongTermRetentionBackups = require('./longTermRetentionBackups'); exports.BackupLongTermRetentionPolicies = require('./backupLongTermRetentionPolicies'); exports.ManagedDatabases = require('./managedDatabases'); @@ -58,5 +69,6 @@ exports.RestorePoints = require('./restorePoints'); exports.DatabaseOperations = require('./databaseOperations'); exports.ElasticPoolOperations = require('./elasticPoolOperations'); exports.Capabilities = require('./capabilities'); +exports.DatabaseVulnerabilityAssessmentScans = require('./databaseVulnerabilityAssessmentScans'); exports.InstanceFailoverGroups = require('./instanceFailoverGroups'); exports.ShortTermRetentionPolicies = require('./shortTermRetentionPolicies'); diff --git a/lib/services/sqlManagement2/lib/operations/jobAgents.js b/lib/services/sqlManagement2/lib/operations/jobAgents.js new file mode 100644 index 0000000000..668c876352 --- /dev/null +++ b/lib/services/sqlManagement2/lib/operations/jobAgents.js @@ -0,0 +1,2182 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets a list of job agents in a server. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @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 JobAgentListResult} 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 _listByServer(resourceGroupName, serverName, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName 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.Sql/servers/{serverName}/jobAgents'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(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['JobAgentListResult']().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 job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be retrieved. + * + * @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 JobAgent} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, serverName, jobAgentName, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(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['JobAgent']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + + +/** + * Creates or updates a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be created or + * updated. + * + * @param {object} parameters The requested job agent resource state. + * + * @param {object} [parameters.sku] The name and tier of the SKU. + * + * @param {string} parameters.sku.name The name of the SKU, typically, a letter + * + Number code, e.g. P3. + * + * @param {string} [parameters.sku.tier] The tier of the particular SKU, e.g. + * Basic, Premium. + * + * @param {string} [parameters.sku.size] Size of the particular SKU + * + * @param {string} [parameters.sku.family] If the service has different + * generations of hardware, for the same SKU, then that can be captured here. + * + * @param {number} [parameters.sku.capacity] Capacity of the particular SKU. + * + * @param {string} parameters.databaseId Resource ID of the database to store + * job metadata in. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location Resource location. + * + * @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 JobAgent} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(resourceGroupName, serverName, jobAgentName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + + if (!callback) { + throw new Error('callback cannot be null.'); + } + + // Send request + this.beginCreateOrUpdate(resourceGroupName, serverName, jobAgentName, parameters, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['JobAgent']().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); + }); + }); +} + + +/** + * Deletes a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be deleted. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(resourceGroupName, serverName, jobAgentName, 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.'); + } + + // Send request + this.beginDeleteMethod(resourceGroupName, serverName, jobAgentName, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + + return callback(null, result, httpRequest, response); + }); + }); +} + + +/** + * Updates a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be updated. + * + * @param {object} parameters The update to the job agent. + * + * @param {object} [parameters.tags] Resource tags. + * + * @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 JobAgent} 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, serverName, jobAgentName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + + if (!callback) { + throw new Error('callback cannot be null.'); + } + + // Send request + this.beginUpdate(resourceGroupName, serverName, jobAgentName, parameters, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['JobAgent']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + + return callback(null, result, httpRequest, response); + }); + }); +} + +/** + * Creates or updates a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be created or + * updated. + * + * @param {object} parameters The requested job agent resource state. + * + * @param {object} [parameters.sku] The name and tier of the SKU. + * + * @param {string} parameters.sku.name The name of the SKU, typically, a letter + * + Number code, e.g. P3. + * + * @param {string} [parameters.sku.tier] The tier of the particular SKU, e.g. + * Basic, Premium. + * + * @param {string} [parameters.sku.size] Size of the particular SKU + * + * @param {string} [parameters.sku.family] If the service has different + * generations of hardware, for the same SKU, then that can be captured here. + * + * @param {number} [parameters.sku.capacity] Capacity of the particular SKU. + * + * @param {string} parameters.databaseId Resource ID of the database to store + * job metadata in. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location Resource location. + * + * @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 JobAgent} 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 _beginCreateOrUpdate(resourceGroupName, serverName, jobAgentName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['JobAgent']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201 && statusCode !== 202) { + 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['JobAgent']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['JobAgent']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Deletes a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be deleted. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _beginDeleteMethod(resourceGroupName, serverName, jobAgentName, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (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 && statusCode !== 202 && statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Updates a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be updated. + * + * @param {object} parameters The update to the job agent. + * + * @param {object} [parameters.tags] Resource tags. + * + * @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 JobAgent} 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 _beginUpdate(resourceGroupName, serverName, jobAgentName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(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(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['JobAgentUpdate']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 202) { + 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['JobAgent']().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 job agents in a server. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link JobAgentListResult} 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 _listByServerNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['JobAgentListResult']().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 JobAgents. */ +class JobAgents { + /** + * Create a JobAgents. + * @param {SqlManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._listByServer = _listByServer; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + this._deleteMethod = _deleteMethod; + this._update = _update; + this._beginCreateOrUpdate = _beginCreateOrUpdate; + this._beginDeleteMethod = _beginDeleteMethod; + this._beginUpdate = _beginUpdate; + this._listByServerNext = _listByServerNext; + } + + /** + * Gets a list of job agents in a server. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @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. + */ + listByServerWithHttpOperationResponse(resourceGroupName, serverName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByServer(resourceGroupName, serverName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a list of job agents in a server. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @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 {JobAgentListResult} - 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 JobAgentListResult} 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. + */ + listByServer(resourceGroupName, serverName, 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._listByServer(resourceGroupName, serverName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByServer(resourceGroupName, serverName, options, optionalCallback); + } + } + + /** + * Gets a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be retrieved. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, jobAgentName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be retrieved. + * + * @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 {JobAgent} - 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 JobAgent} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, serverName, jobAgentName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, jobAgentName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, serverName, jobAgentName, options, optionalCallback); + } + } + + /** + * Creates or updates a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be created or + * updated. + * + * @param {object} parameters The requested job agent resource state. + * + * @param {object} [parameters.sku] The name and tier of the SKU. + * + * @param {string} parameters.sku.name The name of the SKU, typically, a letter + * + Number code, e.g. P3. + * + * @param {string} [parameters.sku.tier] The tier of the particular SKU, e.g. + * Basic, Premium. + * + * @param {string} [parameters.sku.size] Size of the particular SKU + * + * @param {string} [parameters.sku.family] If the service has different + * generations of hardware, for the same SKU, then that can be captured here. + * + * @param {number} [parameters.sku.capacity] Capacity of the particular SKU. + * + * @param {string} parameters.databaseId Resource ID of the database to store + * job metadata in. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location Resource location. + * + * @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. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, serverName, jobAgentName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Creates or updates a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be created or + * updated. + * + * @param {object} parameters The requested job agent resource state. + * + * @param {object} [parameters.sku] The name and tier of the SKU. + * + * @param {string} parameters.sku.name The name of the SKU, typically, a letter + * + Number code, e.g. P3. + * + * @param {string} [parameters.sku.tier] The tier of the particular SKU, e.g. + * Basic, Premium. + * + * @param {string} [parameters.sku.size] Size of the particular SKU + * + * @param {string} [parameters.sku.family] If the service has different + * generations of hardware, for the same SKU, then that can be captured here. + * + * @param {number} [parameters.sku.capacity] Capacity of the particular SKU. + * + * @param {string} parameters.databaseId Resource ID of the database to store + * job metadata in. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location Resource location. + * + * @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 {JobAgent} - 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 JobAgent} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName, serverName, jobAgentName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, serverName, jobAgentName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, serverName, jobAgentName, parameters, options, optionalCallback); + } + } + + /** + * Deletes a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be deleted. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, serverName, jobAgentName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Deletes a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be deleted. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName, serverName, jobAgentName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, serverName, jobAgentName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, serverName, jobAgentName, options, optionalCallback); + } + } + + /** + * Updates a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be updated. + * + * @param {object} parameters The update to the job agent. + * + * @param {object} [parameters.tags] Resource tags. + * + * @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. + */ + updateWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(resourceGroupName, serverName, jobAgentName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Updates a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be updated. + * + * @param {object} parameters The update to the job agent. + * + * @param {object} [parameters.tags] Resource tags. + * + * @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 {JobAgent} - 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 JobAgent} 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, serverName, jobAgentName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._update(resourceGroupName, serverName, jobAgentName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(resourceGroupName, serverName, jobAgentName, parameters, options, optionalCallback); + } + } + + /** + * Creates or updates a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be created or + * updated. + * + * @param {object} parameters The requested job agent resource state. + * + * @param {object} [parameters.sku] The name and tier of the SKU. + * + * @param {string} parameters.sku.name The name of the SKU, typically, a letter + * + Number code, e.g. P3. + * + * @param {string} [parameters.sku.tier] The tier of the particular SKU, e.g. + * Basic, Premium. + * + * @param {string} [parameters.sku.size] Size of the particular SKU + * + * @param {string} [parameters.sku.family] If the service has different + * generations of hardware, for the same SKU, then that can be captured here. + * + * @param {number} [parameters.sku.capacity] Capacity of the particular SKU. + * + * @param {string} parameters.databaseId Resource ID of the database to store + * job metadata in. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location Resource location. + * + * @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. + */ + beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginCreateOrUpdate(resourceGroupName, serverName, jobAgentName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Creates or updates a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be created or + * updated. + * + * @param {object} parameters The requested job agent resource state. + * + * @param {object} [parameters.sku] The name and tier of the SKU. + * + * @param {string} parameters.sku.name The name of the SKU, typically, a letter + * + Number code, e.g. P3. + * + * @param {string} [parameters.sku.tier] The tier of the particular SKU, e.g. + * Basic, Premium. + * + * @param {string} [parameters.sku.size] Size of the particular SKU + * + * @param {string} [parameters.sku.family] If the service has different + * generations of hardware, for the same SKU, then that can be captured here. + * + * @param {number} [parameters.sku.capacity] Capacity of the particular SKU. + * + * @param {string} parameters.databaseId Resource ID of the database to store + * job metadata in. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location Resource location. + * + * @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 {JobAgent} - 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 JobAgent} 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. + */ + beginCreateOrUpdate(resourceGroupName, serverName, jobAgentName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._beginCreateOrUpdate(resourceGroupName, serverName, jobAgentName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginCreateOrUpdate(resourceGroupName, serverName, jobAgentName, parameters, options, optionalCallback); + } + } + + /** + * Deletes a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be deleted. + * + * @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. + */ + beginDeleteMethodWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginDeleteMethod(resourceGroupName, serverName, jobAgentName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Deletes a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be deleted. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + beginDeleteMethod(resourceGroupName, serverName, jobAgentName, 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._beginDeleteMethod(resourceGroupName, serverName, jobAgentName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginDeleteMethod(resourceGroupName, serverName, jobAgentName, options, optionalCallback); + } + } + + /** + * Updates a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be updated. + * + * @param {object} parameters The update to the job agent. + * + * @param {object} [parameters.tags] Resource tags. + * + * @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. + */ + beginUpdateWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginUpdate(resourceGroupName, serverName, jobAgentName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Updates a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent to be updated. + * + * @param {object} parameters The update to the job agent. + * + * @param {object} [parameters.tags] Resource tags. + * + * @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 {JobAgent} - 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 JobAgent} 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. + */ + beginUpdate(resourceGroupName, serverName, jobAgentName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._beginUpdate(resourceGroupName, serverName, jobAgentName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginUpdate(resourceGroupName, serverName, jobAgentName, parameters, options, optionalCallback); + } + } + + /** + * Gets a list of job agents in a server. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByServerNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByServerNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a list of job agents in a server. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {JobAgentListResult} - 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 JobAgentListResult} 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. + */ + listByServerNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByServerNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByServerNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = JobAgents; diff --git a/lib/services/sqlManagement2/lib/operations/jobCredentials.js b/lib/services/sqlManagement2/lib/operations/jobCredentials.js new file mode 100644 index 0000000000..edfaedfe78 --- /dev/null +++ b/lib/services/sqlManagement2/lib/operations/jobCredentials.js @@ -0,0 +1,1292 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets a list of jobs credentials. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @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 JobCredentialListResult} 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 _listByAgent(resourceGroupName, serverName, jobAgentName, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(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['JobCredentialListResult']().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 jobs credential. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} credentialName The name of the credential. + * + * @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 JobCredential} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, serverName, jobAgentName, credentialName, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (credentialName === null || credentialName === undefined || typeof credentialName.valueOf() !== 'string') { + throw new Error('credentialName 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{credentialName}', encodeURIComponent(credentialName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(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['JobCredential']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Creates or updates a job credential. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} credentialName The name of the credential. + * + * @param {object} parameters The requested job credential state. + * + * @param {string} parameters.username The credential user name. + * + * @param {string} parameters.password The credential password. + * + * @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 JobCredential} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(resourceGroupName, serverName, jobAgentName, credentialName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (credentialName === null || credentialName === undefined || typeof credentialName.valueOf() !== 'string') { + throw new Error('credentialName cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{credentialName}', encodeURIComponent(credentialName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['JobCredential']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['JobCredential']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['JobCredential']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Deletes a job credential. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} credentialName The name of the credential. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(resourceGroupName, serverName, jobAgentName, credentialName, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (credentialName === null || credentialName === undefined || typeof credentialName.valueOf() !== 'string') { + throw new Error('credentialName 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{credentialName}', encodeURIComponent(credentialName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (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 && statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets a list of jobs credentials. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link JobCredentialListResult} 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 _listByAgentNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['JobCredentialListResult']().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 JobCredentials. */ +class JobCredentials { + /** + * Create a JobCredentials. + * @param {SqlManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._listByAgent = _listByAgent; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + this._deleteMethod = _deleteMethod; + this._listByAgentNext = _listByAgentNext; + } + + /** + * Gets a list of jobs credentials. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @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. + */ + listByAgentWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByAgent(resourceGroupName, serverName, jobAgentName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a list of jobs credentials. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @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 {JobCredentialListResult} - 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 JobCredentialListResult} 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. + */ + listByAgent(resourceGroupName, serverName, jobAgentName, 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._listByAgent(resourceGroupName, serverName, jobAgentName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByAgent(resourceGroupName, serverName, jobAgentName, options, optionalCallback); + } + } + + /** + * Gets a jobs credential. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} credentialName The name of the credential. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, credentialName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, jobAgentName, credentialName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a jobs credential. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} credentialName The name of the credential. + * + * @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 {JobCredential} - 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 JobCredential} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, serverName, jobAgentName, credentialName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, jobAgentName, credentialName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, serverName, jobAgentName, credentialName, options, optionalCallback); + } + } + + /** + * Creates or updates a job credential. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} credentialName The name of the credential. + * + * @param {object} parameters The requested job credential state. + * + * @param {string} parameters.username The credential user name. + * + * @param {string} parameters.password The credential password. + * + * @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. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, credentialName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, serverName, jobAgentName, credentialName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Creates or updates a job credential. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} credentialName The name of the credential. + * + * @param {object} parameters The requested job credential state. + * + * @param {string} parameters.username The credential user name. + * + * @param {string} parameters.password The credential password. + * + * @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 {JobCredential} - 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 JobCredential} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName, serverName, jobAgentName, credentialName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, serverName, jobAgentName, credentialName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, serverName, jobAgentName, credentialName, parameters, options, optionalCallback); + } + } + + /** + * Deletes a job credential. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} credentialName The name of the credential. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, credentialName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, serverName, jobAgentName, credentialName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Deletes a job credential. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} credentialName The name of the credential. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName, serverName, jobAgentName, credentialName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, serverName, jobAgentName, credentialName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, serverName, jobAgentName, credentialName, options, optionalCallback); + } + } + + /** + * Gets a list of jobs credentials. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByAgentNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByAgentNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a list of jobs credentials. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {JobCredentialListResult} - 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 JobCredentialListResult} 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. + */ + listByAgentNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByAgentNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByAgentNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = JobCredentials; diff --git a/lib/services/sqlManagement2/lib/operations/jobExecutions.js b/lib/services/sqlManagement2/lib/operations/jobExecutions.js new file mode 100644 index 0000000000..21208c7764 --- /dev/null +++ b/lib/services/sqlManagement2/lib/operations/jobExecutions.js @@ -0,0 +1,2625 @@ +/* + * 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 executions in a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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 JobExecutionListResult} 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 _listByAgent(resourceGroupName, serverName, jobAgentName, 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 createTimeMin = (options && options.createTimeMin !== undefined) ? options.createTimeMin : undefined; + let createTimeMax = (options && options.createTimeMax !== undefined) ? options.createTimeMax : undefined; + let endTimeMin = (options && options.endTimeMin !== undefined) ? options.endTimeMin : undefined; + let endTimeMax = (options && options.endTimeMax !== undefined) ? options.endTimeMax : undefined; + let isActive = (options && options.isActive !== undefined) ? options.isActive : undefined; + let skip = (options && options.skip !== undefined) ? options.skip : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (createTimeMin && !(createTimeMin instanceof Date || + (typeof createTimeMin.valueOf() === 'string' && !isNaN(Date.parse(createTimeMin))))) { + throw new Error('createTimeMin must be of type date.'); + } + if (createTimeMax && !(createTimeMax instanceof Date || + (typeof createTimeMax.valueOf() === 'string' && !isNaN(Date.parse(createTimeMax))))) { + throw new Error('createTimeMax must be of type date.'); + } + if (endTimeMin && !(endTimeMin instanceof Date || + (typeof endTimeMin.valueOf() === 'string' && !isNaN(Date.parse(endTimeMin))))) { + throw new Error('endTimeMin must be of type date.'); + } + if (endTimeMax && !(endTimeMax instanceof Date || + (typeof endTimeMax.valueOf() === 'string' && !isNaN(Date.parse(endTimeMax))))) { + throw new Error('endTimeMax must be of type date.'); + } + if (isActive !== null && isActive !== undefined && typeof isActive !== 'boolean') { + throw new Error('isActive must be of type boolean.'); + } + if (skip !== null && skip !== undefined && typeof skip !== 'number') { + throw new Error('skip must be of type number.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/executions'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + if (createTimeMin !== null && createTimeMin !== undefined) { + queryParameters.push('createTimeMin=' + encodeURIComponent(client.serializeObject(createTimeMin))); + } + if (createTimeMax !== null && createTimeMax !== undefined) { + queryParameters.push('createTimeMax=' + encodeURIComponent(client.serializeObject(createTimeMax))); + } + if (endTimeMin !== null && endTimeMin !== undefined) { + queryParameters.push('endTimeMin=' + encodeURIComponent(client.serializeObject(endTimeMin))); + } + if (endTimeMax !== null && endTimeMax !== undefined) { + queryParameters.push('endTimeMax=' + encodeURIComponent(client.serializeObject(endTimeMax))); + } + if (isActive !== null && isActive !== undefined) { + queryParameters.push('isActive=' + encodeURIComponent(isActive.toString())); + } + if (skip !== null && skip !== undefined) { + queryParameters.push('$skip=' + encodeURIComponent(skip.toString())); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(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['JobExecutionListResult']().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); + }); +} + +/** + * Requests cancellation of a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {uuid} jobExecutionId The id of the job execution to cancel. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _cancel(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') { + throw new Error('jobName cannot be null or undefined and it must be of type string.'); + } + if (jobExecutionId === null || jobExecutionId === undefined || typeof jobExecutionId.valueOf() !== 'string' || !msRest.isValidUuid(jobExecutionId)) { + throw new Error('jobExecutionId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/cancel'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName)); + requestUrl = requestUrl.replace('{jobExecutionId}', encodeURIComponent(jobExecutionId.toString())); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + 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; + + return callback(null, result, httpRequest, response); + }); +} + + +/** + * Starts an elastic job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @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 JobExecution} 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 _create(resourceGroupName, serverName, jobAgentName, jobName, 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.'); + } + + // Send request + this.beginCreate(resourceGroupName, serverName, jobAgentName, jobName, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['JobExecution']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + + return callback(null, result, httpRequest, response); + }); + }); +} + +/** + * Lists a job's executions. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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 JobExecutionListResult} 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 _listByJob(resourceGroupName, serverName, jobAgentName, jobName, 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 createTimeMin = (options && options.createTimeMin !== undefined) ? options.createTimeMin : undefined; + let createTimeMax = (options && options.createTimeMax !== undefined) ? options.createTimeMax : undefined; + let endTimeMin = (options && options.endTimeMin !== undefined) ? options.endTimeMin : undefined; + let endTimeMax = (options && options.endTimeMax !== undefined) ? options.endTimeMax : undefined; + let isActive = (options && options.isActive !== undefined) ? options.isActive : undefined; + let skip = (options && options.skip !== undefined) ? options.skip : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') { + throw new Error('jobName cannot be null or undefined and it must be of type string.'); + } + if (createTimeMin && !(createTimeMin instanceof Date || + (typeof createTimeMin.valueOf() === 'string' && !isNaN(Date.parse(createTimeMin))))) { + throw new Error('createTimeMin must be of type date.'); + } + if (createTimeMax && !(createTimeMax instanceof Date || + (typeof createTimeMax.valueOf() === 'string' && !isNaN(Date.parse(createTimeMax))))) { + throw new Error('createTimeMax must be of type date.'); + } + if (endTimeMin && !(endTimeMin instanceof Date || + (typeof endTimeMin.valueOf() === 'string' && !isNaN(Date.parse(endTimeMin))))) { + throw new Error('endTimeMin must be of type date.'); + } + if (endTimeMax && !(endTimeMax instanceof Date || + (typeof endTimeMax.valueOf() === 'string' && !isNaN(Date.parse(endTimeMax))))) { + throw new Error('endTimeMax must be of type date.'); + } + if (isActive !== null && isActive !== undefined && typeof isActive !== 'boolean') { + throw new Error('isActive must be of type boolean.'); + } + if (skip !== null && skip !== undefined && typeof skip !== 'number') { + throw new Error('skip must be of type number.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + if (createTimeMin !== null && createTimeMin !== undefined) { + queryParameters.push('createTimeMin=' + encodeURIComponent(client.serializeObject(createTimeMin))); + } + if (createTimeMax !== null && createTimeMax !== undefined) { + queryParameters.push('createTimeMax=' + encodeURIComponent(client.serializeObject(createTimeMax))); + } + if (endTimeMin !== null && endTimeMin !== undefined) { + queryParameters.push('endTimeMin=' + encodeURIComponent(client.serializeObject(endTimeMin))); + } + if (endTimeMax !== null && endTimeMax !== undefined) { + queryParameters.push('endTimeMax=' + encodeURIComponent(client.serializeObject(endTimeMax))); + } + if (isActive !== null && isActive !== undefined) { + queryParameters.push('isActive=' + encodeURIComponent(isActive.toString())); + } + if (skip !== null && skip !== undefined) { + queryParameters.push('$skip=' + encodeURIComponent(skip.toString())); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(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['JobExecutionListResult']().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 job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {uuid} jobExecutionId The id of the job execution + * + * @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 JobExecution} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') { + throw new Error('jobName cannot be null or undefined and it must be of type string.'); + } + if (jobExecutionId === null || jobExecutionId === undefined || typeof jobExecutionId.valueOf() !== 'string' || !msRest.isValidUuid(jobExecutionId)) { + throw new Error('jobExecutionId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName)); + requestUrl = requestUrl.replace('{jobExecutionId}', encodeURIComponent(jobExecutionId.toString())); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(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['JobExecution']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + + +/** + * Creates or updatess a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The job execution id to create the job + * execution under. + * + * @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 JobExecution} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, 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.'); + } + + // Send request + this.beginCreateOrUpdate(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['JobExecution']().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); + }); + }); +} + +/** + * Starts an elastic job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @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 JobExecution} 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 _beginCreate(resourceGroupName, serverName, jobAgentName, jobName, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') { + throw new Error('jobName 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/start'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + 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 && statusCode !== 202) { + 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['JobExecution']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Creates or updatess a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The job execution id to create the job + * execution under. + * + * @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 JobExecution} 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 _beginCreateOrUpdate(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') { + throw new Error('jobName cannot be null or undefined and it must be of type string.'); + } + if (jobExecutionId === null || jobExecutionId === undefined || typeof jobExecutionId.valueOf() !== 'string' || !msRest.isValidUuid(jobExecutionId)) { + throw new Error('jobExecutionId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName)); + requestUrl = requestUrl.replace('{jobExecutionId}', encodeURIComponent(jobExecutionId.toString())); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (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 && statusCode !== 201 && statusCode !== 202) { + 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['JobExecution']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['JobExecution']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists all executions in a job agent. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link JobExecutionListResult} 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 _listByAgentNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['JobExecutionListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists a job's executions. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link JobExecutionListResult} 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 _listByJobNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['JobExecutionListResult']().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 JobExecutions. */ +class JobExecutions { + /** + * Create a JobExecutions. + * @param {SqlManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._listByAgent = _listByAgent; + this._cancel = _cancel; + this._create = _create; + this._listByJob = _listByJob; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + this._beginCreate = _beginCreate; + this._beginCreateOrUpdate = _beginCreateOrUpdate; + this._listByAgentNext = _listByAgentNext; + this._listByJobNext = _listByJobNext; + } + + /** + * Lists all executions in a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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. + */ + listByAgentWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByAgent(resourceGroupName, serverName, jobAgentName, 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 executions in a job agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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 {JobExecutionListResult} - 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 JobExecutionListResult} 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. + */ + listByAgent(resourceGroupName, serverName, jobAgentName, 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._listByAgent(resourceGroupName, serverName, jobAgentName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByAgent(resourceGroupName, serverName, jobAgentName, options, optionalCallback); + } + } + + /** + * Requests cancellation of a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {uuid} jobExecutionId The id of the job execution to cancel. + * + * @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. + */ + cancelWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._cancel(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Requests cancellation of a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {uuid} jobExecutionId The id of the job execution to cancel. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + cancel(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, 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._cancel(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._cancel(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options, optionalCallback); + } + } + + /** + * Starts an elastic job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @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. + */ + createWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, jobName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._create(resourceGroupName, serverName, jobAgentName, jobName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Starts an elastic job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @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 {JobExecution} - 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 JobExecution} 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. + */ + create(resourceGroupName, serverName, jobAgentName, jobName, 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._create(resourceGroupName, serverName, jobAgentName, jobName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._create(resourceGroupName, serverName, jobAgentName, jobName, options, optionalCallback); + } + } + + /** + * Lists a job's executions. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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. + */ + listByJobWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, jobName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByJob(resourceGroupName, serverName, jobAgentName, jobName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists a job's executions. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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 {JobExecutionListResult} - 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 JobExecutionListResult} 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. + */ + listByJob(resourceGroupName, serverName, jobAgentName, jobName, 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._listByJob(resourceGroupName, serverName, jobAgentName, jobName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByJob(resourceGroupName, serverName, jobAgentName, jobName, options, optionalCallback); + } + } + + /** + * Gets a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {uuid} jobExecutionId The id of the job execution + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {uuid} jobExecutionId The id of the job execution + * + * @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 {JobExecution} - 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 JobExecution} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options, optionalCallback); + } + } + + /** + * Creates or updatess a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The job execution id to create the job + * execution under. + * + * @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. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Creates or updatess a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The job execution id to create the job + * execution under. + * + * @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 {JobExecution} - 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 JobExecution} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options, optionalCallback); + } + } + + /** + * Starts an elastic job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @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. + */ + beginCreateWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, jobName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginCreate(resourceGroupName, serverName, jobAgentName, jobName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Starts an elastic job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @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 {JobExecution} - 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 JobExecution} 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. + */ + beginCreate(resourceGroupName, serverName, jobAgentName, jobName, 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._beginCreate(resourceGroupName, serverName, jobAgentName, jobName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginCreate(resourceGroupName, serverName, jobAgentName, jobName, options, optionalCallback); + } + } + + /** + * Creates or updatess a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The job execution id to create the job + * execution under. + * + * @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. + */ + beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginCreateOrUpdate(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Creates or updatess a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The job execution id to create the job + * execution under. + * + * @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 {JobExecution} - 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 JobExecution} 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. + */ + beginCreateOrUpdate(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, 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._beginCreateOrUpdate(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginCreateOrUpdate(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options, optionalCallback); + } + } + + /** + * Lists all executions in a job agent. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByAgentNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByAgentNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all executions in a job agent. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {JobExecutionListResult} - 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 JobExecutionListResult} 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. + */ + listByAgentNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByAgentNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByAgentNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Lists a job's executions. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByJobNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByJobNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists a job's executions. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {JobExecutionListResult} - 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 JobExecutionListResult} 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. + */ + listByJobNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByJobNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByJobNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = JobExecutions; diff --git a/lib/services/sqlManagement2/lib/operations/jobStepExecutions.js b/lib/services/sqlManagement2/lib/operations/jobStepExecutions.js new file mode 100644 index 0000000000..beaaaf53c1 --- /dev/null +++ b/lib/services/sqlManagement2/lib/operations/jobStepExecutions.js @@ -0,0 +1,903 @@ +/* + * 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 the step executions of a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The id of the job execution + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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 JobExecutionListResult} 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 _listByJobExecution(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, 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 createTimeMin = (options && options.createTimeMin !== undefined) ? options.createTimeMin : undefined; + let createTimeMax = (options && options.createTimeMax !== undefined) ? options.createTimeMax : undefined; + let endTimeMin = (options && options.endTimeMin !== undefined) ? options.endTimeMin : undefined; + let endTimeMax = (options && options.endTimeMax !== undefined) ? options.endTimeMax : undefined; + let isActive = (options && options.isActive !== undefined) ? options.isActive : undefined; + let skip = (options && options.skip !== undefined) ? options.skip : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') { + throw new Error('jobName cannot be null or undefined and it must be of type string.'); + } + if (jobExecutionId === null || jobExecutionId === undefined || typeof jobExecutionId.valueOf() !== 'string' || !msRest.isValidUuid(jobExecutionId)) { + throw new Error('jobExecutionId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + if (createTimeMin && !(createTimeMin instanceof Date || + (typeof createTimeMin.valueOf() === 'string' && !isNaN(Date.parse(createTimeMin))))) { + throw new Error('createTimeMin must be of type date.'); + } + if (createTimeMax && !(createTimeMax instanceof Date || + (typeof createTimeMax.valueOf() === 'string' && !isNaN(Date.parse(createTimeMax))))) { + throw new Error('createTimeMax must be of type date.'); + } + if (endTimeMin && !(endTimeMin instanceof Date || + (typeof endTimeMin.valueOf() === 'string' && !isNaN(Date.parse(endTimeMin))))) { + throw new Error('endTimeMin must be of type date.'); + } + if (endTimeMax && !(endTimeMax instanceof Date || + (typeof endTimeMax.valueOf() === 'string' && !isNaN(Date.parse(endTimeMax))))) { + throw new Error('endTimeMax must be of type date.'); + } + if (isActive !== null && isActive !== undefined && typeof isActive !== 'boolean') { + throw new Error('isActive must be of type boolean.'); + } + if (skip !== null && skip !== undefined && typeof skip !== 'number') { + throw new Error('skip must be of type number.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName)); + requestUrl = requestUrl.replace('{jobExecutionId}', encodeURIComponent(jobExecutionId.toString())); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + if (createTimeMin !== null && createTimeMin !== undefined) { + queryParameters.push('createTimeMin=' + encodeURIComponent(client.serializeObject(createTimeMin))); + } + if (createTimeMax !== null && createTimeMax !== undefined) { + queryParameters.push('createTimeMax=' + encodeURIComponent(client.serializeObject(createTimeMax))); + } + if (endTimeMin !== null && endTimeMin !== undefined) { + queryParameters.push('endTimeMin=' + encodeURIComponent(client.serializeObject(endTimeMin))); + } + if (endTimeMax !== null && endTimeMax !== undefined) { + queryParameters.push('endTimeMax=' + encodeURIComponent(client.serializeObject(endTimeMax))); + } + if (isActive !== null && isActive !== undefined) { + queryParameters.push('isActive=' + encodeURIComponent(isActive.toString())); + } + if (skip !== null && skip !== undefined) { + queryParameters.push('$skip=' + encodeURIComponent(skip.toString())); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(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['JobExecutionListResult']().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 step execution of a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The unique id of the job execution + * + * @param {string} stepName The name of the step. + * + * @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 JobExecution} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, stepName, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') { + throw new Error('jobName cannot be null or undefined and it must be of type string.'); + } + if (jobExecutionId === null || jobExecutionId === undefined || typeof jobExecutionId.valueOf() !== 'string' || !msRest.isValidUuid(jobExecutionId)) { + throw new Error('jobExecutionId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + if (stepName === null || stepName === undefined || typeof stepName.valueOf() !== 'string') { + throw new Error('stepName 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName)); + requestUrl = requestUrl.replace('{jobExecutionId}', encodeURIComponent(jobExecutionId.toString())); + requestUrl = requestUrl.replace('{stepName}', encodeURIComponent(stepName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(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['JobExecution']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the step executions of a job execution. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link JobExecutionListResult} 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 _listByJobExecutionNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['JobExecutionListResult']().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 JobStepExecutions. */ +class JobStepExecutions { + /** + * Create a JobStepExecutions. + * @param {SqlManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._listByJobExecution = _listByJobExecution; + this._get = _get; + this._listByJobExecutionNext = _listByJobExecutionNext; + } + + /** + * Lists the step executions of a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The id of the job execution + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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. + */ + listByJobExecutionWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByJobExecution(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the step executions of a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The id of the job execution + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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 {JobExecutionListResult} - 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 JobExecutionListResult} 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. + */ + listByJobExecution(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, 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._listByJobExecution(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByJobExecution(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options, optionalCallback); + } + } + + /** + * Gets a step execution of a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The unique id of the job execution + * + * @param {string} stepName The name of the step. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, stepName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, stepName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a step execution of a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The unique id of the job execution + * + * @param {string} stepName The name of the step. + * + * @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 {JobExecution} - 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 JobExecution} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, stepName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, stepName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, stepName, options, optionalCallback); + } + } + + /** + * Lists the step executions of a job execution. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByJobExecutionNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByJobExecutionNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the step executions of a job execution. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {JobExecutionListResult} - 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 JobExecutionListResult} 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. + */ + listByJobExecutionNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByJobExecutionNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByJobExecutionNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = JobStepExecutions; diff --git a/lib/services/sqlManagement2/lib/operations/jobSteps.js b/lib/services/sqlManagement2/lib/operations/jobSteps.js new file mode 100644 index 0000000000..bf9d99cf44 --- /dev/null +++ b/lib/services/sqlManagement2/lib/operations/jobSteps.js @@ -0,0 +1,2271 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets all job steps in the specified job version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {number} jobVersion The version of the job to get. + * + * @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 JobStepListResult} 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 _listByVersion(resourceGroupName, serverName, jobAgentName, jobName, jobVersion, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') { + throw new Error('jobName cannot be null or undefined and it must be of type string.'); + } + if (jobVersion === null || jobVersion === undefined || typeof jobVersion !== 'number') { + throw new Error('jobVersion cannot be null or undefined and it must be of type number.'); + } + 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}/steps'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName)); + requestUrl = requestUrl.replace('{jobVersion}', encodeURIComponent(jobVersion.toString())); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(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['JobStepListResult']().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 specified version of a job step. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {number} jobVersion The version of the job to get. + * + * @param {string} stepName The name of the job step. + * + * @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 JobStep} 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 _getByVersion(resourceGroupName, serverName, jobAgentName, jobName, jobVersion, stepName, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') { + throw new Error('jobName cannot be null or undefined and it must be of type string.'); + } + if (jobVersion === null || jobVersion === undefined || typeof jobVersion !== 'number') { + throw new Error('jobVersion cannot be null or undefined and it must be of type number.'); + } + if (stepName === null || stepName === undefined || typeof stepName.valueOf() !== 'string') { + throw new Error('stepName 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}/steps/{stepName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName)); + requestUrl = requestUrl.replace('{jobVersion}', encodeURIComponent(jobVersion.toString())); + requestUrl = requestUrl.replace('{stepName}', encodeURIComponent(stepName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(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['JobStep']().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 all job steps for a job's current version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @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 JobStepListResult} 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 _listByJob(resourceGroupName, serverName, jobAgentName, jobName, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') { + throw new Error('jobName 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(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['JobStepListResult']().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 job step in a job's current version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {string} stepName The name of the job step. + * + * @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 JobStep} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, serverName, jobAgentName, jobName, stepName, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') { + throw new Error('jobName cannot be null or undefined and it must be of type string.'); + } + if (stepName === null || stepName === undefined || typeof stepName.valueOf() !== 'string') { + throw new Error('stepName 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName)); + requestUrl = requestUrl.replace('{stepName}', encodeURIComponent(stepName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(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['JobStep']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Creates or updates a job step. This will implicitly create a new job + * version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {string} stepName The name of the job step. + * + * @param {object} parameters The requested state of the job step. + * + * @param {number} [parameters.stepId] The job step's index within the job. If + * not specified when creating the job step, it will be created as the last + * step. If not specified when updating the job step, the step id is not + * modified. + * + * @param {string} parameters.targetGroup The resource ID of the target group + * that the job step will be executed on. + * + * @param {string} parameters.credential The resource ID of the job credential + * that will be used to connect to the targets. + * + * @param {object} parameters.action The action payload of the job step. + * + * @param {string} [parameters.action.type] Type of action being executed by + * the job step. Possible values include: 'TSql' + * + * @param {string} [parameters.action.source] The source of the action to + * execute. Possible values include: 'Inline' + * + * @param {string} parameters.action.value The action value, for example the + * text of the T-SQL script to execute. + * + * @param {object} [parameters.output] Output destination properties of the job + * step. + * + * @param {string} [parameters.output.type] The output destination type. + * Possible values include: 'SqlDatabase' + * + * @param {uuid} [parameters.output.subscriptionId] The output destination + * subscription id. + * + * @param {string} [parameters.output.resourceGroupName] The output destination + * resource group. + * + * @param {string} parameters.output.serverName The output destination server + * name. + * + * @param {string} parameters.output.databaseName The output destination + * database. + * + * @param {string} [parameters.output.schemaName] The output destination + * schema. + * + * @param {string} parameters.output.tableName The output destination table. + * + * @param {string} parameters.output.credential The resource ID of the + * credential to use to connect to the output destination. + * + * @param {object} [parameters.executionOptions] Execution options for the job + * step. + * + * @param {number} [parameters.executionOptions.timeoutSeconds] Execution + * timeout for the job step. + * + * @param {number} [parameters.executionOptions.retryAttempts] Maximum number + * of times the job step will be reattempted if the first attempt fails. + * + * @param {number} [parameters.executionOptions.initialRetryIntervalSeconds] + * Initial delay between retries for job step execution. + * + * @param {number} [parameters.executionOptions.maximumRetryIntervalSeconds] + * The maximum amount of time to wait between retries for job step execution. + * + * @param {number} [parameters.executionOptions.retryIntervalBackoffMultiplier] + * The backoff multiplier for the time between retries. + * + * @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 JobStep} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(resourceGroupName, serverName, jobAgentName, jobName, stepName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') { + throw new Error('jobName cannot be null or undefined and it must be of type string.'); + } + if (stepName === null || stepName === undefined || typeof stepName.valueOf() !== 'string') { + throw new Error('stepName cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName)); + requestUrl = requestUrl.replace('{stepName}', encodeURIComponent(stepName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['JobStep']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['JobStep']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['JobStep']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Deletes a job step. This will implicitly create a new job version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {string} stepName The name of the job step to delete. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(resourceGroupName, serverName, jobAgentName, jobName, stepName, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') { + throw new Error('jobName cannot be null or undefined and it must be of type string.'); + } + if (stepName === null || stepName === undefined || typeof stepName.valueOf() !== 'string') { + throw new Error('stepName 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName)); + requestUrl = requestUrl.replace('{stepName}', encodeURIComponent(stepName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (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 && statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets all job steps in the specified job version. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link JobStepListResult} 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 _listByVersionNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['JobStepListResult']().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 all job steps for a job's current version. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link JobStepListResult} 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 _listByJobNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['JobStepListResult']().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 JobSteps. */ +class JobSteps { + /** + * Create a JobSteps. + * @param {SqlManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._listByVersion = _listByVersion; + this._getByVersion = _getByVersion; + this._listByJob = _listByJob; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + this._deleteMethod = _deleteMethod; + this._listByVersionNext = _listByVersionNext; + this._listByJobNext = _listByJobNext; + } + + /** + * Gets all job steps in the specified job version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {number} jobVersion The version of the job to get. + * + * @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. + */ + listByVersionWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, jobName, jobVersion, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByVersion(resourceGroupName, serverName, jobAgentName, jobName, jobVersion, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets all job steps in the specified job version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {number} jobVersion The version of the job to get. + * + * @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 {JobStepListResult} - 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 JobStepListResult} 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. + */ + listByVersion(resourceGroupName, serverName, jobAgentName, jobName, jobVersion, 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._listByVersion(resourceGroupName, serverName, jobAgentName, jobName, jobVersion, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByVersion(resourceGroupName, serverName, jobAgentName, jobName, jobVersion, options, optionalCallback); + } + } + + /** + * Gets the specified version of a job step. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {number} jobVersion The version of the job to get. + * + * @param {string} stepName The name of the job step. + * + * @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. + */ + getByVersionWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, jobName, jobVersion, stepName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._getByVersion(resourceGroupName, serverName, jobAgentName, jobName, jobVersion, stepName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the specified version of a job step. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {number} jobVersion The version of the job to get. + * + * @param {string} stepName The name of the job step. + * + * @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 {JobStep} - 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 JobStep} 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. + */ + getByVersion(resourceGroupName, serverName, jobAgentName, jobName, jobVersion, stepName, 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._getByVersion(resourceGroupName, serverName, jobAgentName, jobName, jobVersion, stepName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._getByVersion(resourceGroupName, serverName, jobAgentName, jobName, jobVersion, stepName, options, optionalCallback); + } + } + + /** + * Gets all job steps for a job's current version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @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. + */ + listByJobWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, jobName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByJob(resourceGroupName, serverName, jobAgentName, jobName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets all job steps for a job's current version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @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 {JobStepListResult} - 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 JobStepListResult} 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. + */ + listByJob(resourceGroupName, serverName, jobAgentName, jobName, 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._listByJob(resourceGroupName, serverName, jobAgentName, jobName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByJob(resourceGroupName, serverName, jobAgentName, jobName, options, optionalCallback); + } + } + + /** + * Gets a job step in a job's current version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {string} stepName The name of the job step. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, jobName, stepName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, jobAgentName, jobName, stepName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a job step in a job's current version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {string} stepName The name of the job step. + * + * @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 {JobStep} - 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 JobStep} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, serverName, jobAgentName, jobName, stepName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, jobAgentName, jobName, stepName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, serverName, jobAgentName, jobName, stepName, options, optionalCallback); + } + } + + /** + * Creates or updates a job step. This will implicitly create a new job + * version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {string} stepName The name of the job step. + * + * @param {object} parameters The requested state of the job step. + * + * @param {number} [parameters.stepId] The job step's index within the job. If + * not specified when creating the job step, it will be created as the last + * step. If not specified when updating the job step, the step id is not + * modified. + * + * @param {string} parameters.targetGroup The resource ID of the target group + * that the job step will be executed on. + * + * @param {string} parameters.credential The resource ID of the job credential + * that will be used to connect to the targets. + * + * @param {object} parameters.action The action payload of the job step. + * + * @param {string} [parameters.action.type] Type of action being executed by + * the job step. Possible values include: 'TSql' + * + * @param {string} [parameters.action.source] The source of the action to + * execute. Possible values include: 'Inline' + * + * @param {string} parameters.action.value The action value, for example the + * text of the T-SQL script to execute. + * + * @param {object} [parameters.output] Output destination properties of the job + * step. + * + * @param {string} [parameters.output.type] The output destination type. + * Possible values include: 'SqlDatabase' + * + * @param {uuid} [parameters.output.subscriptionId] The output destination + * subscription id. + * + * @param {string} [parameters.output.resourceGroupName] The output destination + * resource group. + * + * @param {string} parameters.output.serverName The output destination server + * name. + * + * @param {string} parameters.output.databaseName The output destination + * database. + * + * @param {string} [parameters.output.schemaName] The output destination + * schema. + * + * @param {string} parameters.output.tableName The output destination table. + * + * @param {string} parameters.output.credential The resource ID of the + * credential to use to connect to the output destination. + * + * @param {object} [parameters.executionOptions] Execution options for the job + * step. + * + * @param {number} [parameters.executionOptions.timeoutSeconds] Execution + * timeout for the job step. + * + * @param {number} [parameters.executionOptions.retryAttempts] Maximum number + * of times the job step will be reattempted if the first attempt fails. + * + * @param {number} [parameters.executionOptions.initialRetryIntervalSeconds] + * Initial delay between retries for job step execution. + * + * @param {number} [parameters.executionOptions.maximumRetryIntervalSeconds] + * The maximum amount of time to wait between retries for job step execution. + * + * @param {number} [parameters.executionOptions.retryIntervalBackoffMultiplier] + * The backoff multiplier for the time between retries. + * + * @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. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, jobName, stepName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, serverName, jobAgentName, jobName, stepName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Creates or updates a job step. This will implicitly create a new job + * version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {string} stepName The name of the job step. + * + * @param {object} parameters The requested state of the job step. + * + * @param {number} [parameters.stepId] The job step's index within the job. If + * not specified when creating the job step, it will be created as the last + * step. If not specified when updating the job step, the step id is not + * modified. + * + * @param {string} parameters.targetGroup The resource ID of the target group + * that the job step will be executed on. + * + * @param {string} parameters.credential The resource ID of the job credential + * that will be used to connect to the targets. + * + * @param {object} parameters.action The action payload of the job step. + * + * @param {string} [parameters.action.type] Type of action being executed by + * the job step. Possible values include: 'TSql' + * + * @param {string} [parameters.action.source] The source of the action to + * execute. Possible values include: 'Inline' + * + * @param {string} parameters.action.value The action value, for example the + * text of the T-SQL script to execute. + * + * @param {object} [parameters.output] Output destination properties of the job + * step. + * + * @param {string} [parameters.output.type] The output destination type. + * Possible values include: 'SqlDatabase' + * + * @param {uuid} [parameters.output.subscriptionId] The output destination + * subscription id. + * + * @param {string} [parameters.output.resourceGroupName] The output destination + * resource group. + * + * @param {string} parameters.output.serverName The output destination server + * name. + * + * @param {string} parameters.output.databaseName The output destination + * database. + * + * @param {string} [parameters.output.schemaName] The output destination + * schema. + * + * @param {string} parameters.output.tableName The output destination table. + * + * @param {string} parameters.output.credential The resource ID of the + * credential to use to connect to the output destination. + * + * @param {object} [parameters.executionOptions] Execution options for the job + * step. + * + * @param {number} [parameters.executionOptions.timeoutSeconds] Execution + * timeout for the job step. + * + * @param {number} [parameters.executionOptions.retryAttempts] Maximum number + * of times the job step will be reattempted if the first attempt fails. + * + * @param {number} [parameters.executionOptions.initialRetryIntervalSeconds] + * Initial delay between retries for job step execution. + * + * @param {number} [parameters.executionOptions.maximumRetryIntervalSeconds] + * The maximum amount of time to wait between retries for job step execution. + * + * @param {number} [parameters.executionOptions.retryIntervalBackoffMultiplier] + * The backoff multiplier for the time between retries. + * + * @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 {JobStep} - 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 JobStep} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName, serverName, jobAgentName, jobName, stepName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, serverName, jobAgentName, jobName, stepName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, serverName, jobAgentName, jobName, stepName, parameters, options, optionalCallback); + } + } + + /** + * Deletes a job step. This will implicitly create a new job version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {string} stepName The name of the job step to delete. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, jobName, stepName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, serverName, jobAgentName, jobName, stepName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Deletes a job step. This will implicitly create a new job version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {string} stepName The name of the job step to delete. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName, serverName, jobAgentName, jobName, stepName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, serverName, jobAgentName, jobName, stepName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, serverName, jobAgentName, jobName, stepName, options, optionalCallback); + } + } + + /** + * Gets all job steps in the specified job version. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByVersionNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByVersionNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets all job steps in the specified job version. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {JobStepListResult} - 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 JobStepListResult} 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. + */ + listByVersionNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByVersionNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByVersionNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Gets all job steps for a job's current version. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByJobNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByJobNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets all job steps for a job's current version. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {JobStepListResult} - 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 JobStepListResult} 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. + */ + listByJobNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByJobNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByJobNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = JobSteps; diff --git a/lib/services/sqlManagement2/lib/operations/jobTargetExecutions.js b/lib/services/sqlManagement2/lib/operations/jobTargetExecutions.js new file mode 100644 index 0000000000..a1604ff69e --- /dev/null +++ b/lib/services/sqlManagement2/lib/operations/jobTargetExecutions.js @@ -0,0 +1,1521 @@ +/* + * 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 target executions for all steps of a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The id of the job execution + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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 JobExecutionListResult} 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 _listByJobExecution(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, 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 createTimeMin = (options && options.createTimeMin !== undefined) ? options.createTimeMin : undefined; + let createTimeMax = (options && options.createTimeMax !== undefined) ? options.createTimeMax : undefined; + let endTimeMin = (options && options.endTimeMin !== undefined) ? options.endTimeMin : undefined; + let endTimeMax = (options && options.endTimeMax !== undefined) ? options.endTimeMax : undefined; + let isActive = (options && options.isActive !== undefined) ? options.isActive : undefined; + let skip = (options && options.skip !== undefined) ? options.skip : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') { + throw new Error('jobName cannot be null or undefined and it must be of type string.'); + } + if (jobExecutionId === null || jobExecutionId === undefined || typeof jobExecutionId.valueOf() !== 'string' || !msRest.isValidUuid(jobExecutionId)) { + throw new Error('jobExecutionId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + if (createTimeMin && !(createTimeMin instanceof Date || + (typeof createTimeMin.valueOf() === 'string' && !isNaN(Date.parse(createTimeMin))))) { + throw new Error('createTimeMin must be of type date.'); + } + if (createTimeMax && !(createTimeMax instanceof Date || + (typeof createTimeMax.valueOf() === 'string' && !isNaN(Date.parse(createTimeMax))))) { + throw new Error('createTimeMax must be of type date.'); + } + if (endTimeMin && !(endTimeMin instanceof Date || + (typeof endTimeMin.valueOf() === 'string' && !isNaN(Date.parse(endTimeMin))))) { + throw new Error('endTimeMin must be of type date.'); + } + if (endTimeMax && !(endTimeMax instanceof Date || + (typeof endTimeMax.valueOf() === 'string' && !isNaN(Date.parse(endTimeMax))))) { + throw new Error('endTimeMax must be of type date.'); + } + if (isActive !== null && isActive !== undefined && typeof isActive !== 'boolean') { + throw new Error('isActive must be of type boolean.'); + } + if (skip !== null && skip !== undefined && typeof skip !== 'number') { + throw new Error('skip must be of type number.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/targets'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName)); + requestUrl = requestUrl.replace('{jobExecutionId}', encodeURIComponent(jobExecutionId.toString())); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + if (createTimeMin !== null && createTimeMin !== undefined) { + queryParameters.push('createTimeMin=' + encodeURIComponent(client.serializeObject(createTimeMin))); + } + if (createTimeMax !== null && createTimeMax !== undefined) { + queryParameters.push('createTimeMax=' + encodeURIComponent(client.serializeObject(createTimeMax))); + } + if (endTimeMin !== null && endTimeMin !== undefined) { + queryParameters.push('endTimeMin=' + encodeURIComponent(client.serializeObject(endTimeMin))); + } + if (endTimeMax !== null && endTimeMax !== undefined) { + queryParameters.push('endTimeMax=' + encodeURIComponent(client.serializeObject(endTimeMax))); + } + if (isActive !== null && isActive !== undefined) { + queryParameters.push('isActive=' + encodeURIComponent(isActive.toString())); + } + if (skip !== null && skip !== undefined) { + queryParameters.push('$skip=' + encodeURIComponent(skip.toString())); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(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['JobExecutionListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the target executions of a job step execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The id of the job execution + * + * @param {string} stepName The name of the step. + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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 JobExecutionListResult} 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 _listByStep(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, stepName, 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 createTimeMin = (options && options.createTimeMin !== undefined) ? options.createTimeMin : undefined; + let createTimeMax = (options && options.createTimeMax !== undefined) ? options.createTimeMax : undefined; + let endTimeMin = (options && options.endTimeMin !== undefined) ? options.endTimeMin : undefined; + let endTimeMax = (options && options.endTimeMax !== undefined) ? options.endTimeMax : undefined; + let isActive = (options && options.isActive !== undefined) ? options.isActive : undefined; + let skip = (options && options.skip !== undefined) ? options.skip : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') { + throw new Error('jobName cannot be null or undefined and it must be of type string.'); + } + if (jobExecutionId === null || jobExecutionId === undefined || typeof jobExecutionId.valueOf() !== 'string' || !msRest.isValidUuid(jobExecutionId)) { + throw new Error('jobExecutionId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + if (stepName === null || stepName === undefined || typeof stepName.valueOf() !== 'string') { + throw new Error('stepName cannot be null or undefined and it must be of type string.'); + } + if (createTimeMin && !(createTimeMin instanceof Date || + (typeof createTimeMin.valueOf() === 'string' && !isNaN(Date.parse(createTimeMin))))) { + throw new Error('createTimeMin must be of type date.'); + } + if (createTimeMax && !(createTimeMax instanceof Date || + (typeof createTimeMax.valueOf() === 'string' && !isNaN(Date.parse(createTimeMax))))) { + throw new Error('createTimeMax must be of type date.'); + } + if (endTimeMin && !(endTimeMin instanceof Date || + (typeof endTimeMin.valueOf() === 'string' && !isNaN(Date.parse(endTimeMin))))) { + throw new Error('endTimeMin must be of type date.'); + } + if (endTimeMax && !(endTimeMax instanceof Date || + (typeof endTimeMax.valueOf() === 'string' && !isNaN(Date.parse(endTimeMax))))) { + throw new Error('endTimeMax must be of type date.'); + } + if (isActive !== null && isActive !== undefined && typeof isActive !== 'boolean') { + throw new Error('isActive must be of type boolean.'); + } + if (skip !== null && skip !== undefined && typeof skip !== 'number') { + throw new Error('skip must be of type number.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}/targets'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName)); + requestUrl = requestUrl.replace('{jobExecutionId}', encodeURIComponent(jobExecutionId.toString())); + requestUrl = requestUrl.replace('{stepName}', encodeURIComponent(stepName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + if (createTimeMin !== null && createTimeMin !== undefined) { + queryParameters.push('createTimeMin=' + encodeURIComponent(client.serializeObject(createTimeMin))); + } + if (createTimeMax !== null && createTimeMax !== undefined) { + queryParameters.push('createTimeMax=' + encodeURIComponent(client.serializeObject(createTimeMax))); + } + if (endTimeMin !== null && endTimeMin !== undefined) { + queryParameters.push('endTimeMin=' + encodeURIComponent(client.serializeObject(endTimeMin))); + } + if (endTimeMax !== null && endTimeMax !== undefined) { + queryParameters.push('endTimeMax=' + encodeURIComponent(client.serializeObject(endTimeMax))); + } + if (isActive !== null && isActive !== undefined) { + queryParameters.push('isActive=' + encodeURIComponent(isActive.toString())); + } + if (skip !== null && skip !== undefined) { + queryParameters.push('$skip=' + encodeURIComponent(skip.toString())); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(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['JobExecutionListResult']().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 target execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The unique id of the job execution + * + * @param {string} stepName The name of the step. + * + * @param {uuid} targetId The target id. + * + * @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 JobExecution} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, stepName, targetId, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') { + throw new Error('jobName cannot be null or undefined and it must be of type string.'); + } + if (jobExecutionId === null || jobExecutionId === undefined || typeof jobExecutionId.valueOf() !== 'string' || !msRest.isValidUuid(jobExecutionId)) { + throw new Error('jobExecutionId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + if (stepName === null || stepName === undefined || typeof stepName.valueOf() !== 'string') { + throw new Error('stepName cannot be null or undefined and it must be of type string.'); + } + if (targetId === null || targetId === undefined || typeof targetId.valueOf() !== 'string' || !msRest.isValidUuid(targetId)) { + throw new Error('targetId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}/targets/{targetId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName)); + requestUrl = requestUrl.replace('{jobExecutionId}', encodeURIComponent(jobExecutionId.toString())); + requestUrl = requestUrl.replace('{stepName}', encodeURIComponent(stepName)); + requestUrl = requestUrl.replace('{targetId}', encodeURIComponent(targetId.toString())); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(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['JobExecution']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists target executions for all steps of a job execution. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link JobExecutionListResult} 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 _listByJobExecutionNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['JobExecutionListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the target executions of a job step execution. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link JobExecutionListResult} 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 _listByStepNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['JobExecutionListResult']().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 JobTargetExecutions. */ +class JobTargetExecutions { + /** + * Create a JobTargetExecutions. + * @param {SqlManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._listByJobExecution = _listByJobExecution; + this._listByStep = _listByStep; + this._get = _get; + this._listByJobExecutionNext = _listByJobExecutionNext; + this._listByStepNext = _listByStepNext; + } + + /** + * Lists target executions for all steps of a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The id of the job execution + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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. + */ + listByJobExecutionWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByJobExecution(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists target executions for all steps of a job execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The id of the job execution + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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 {JobExecutionListResult} - 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 JobExecutionListResult} 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. + */ + listByJobExecution(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, 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._listByJobExecution(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByJobExecution(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, options, optionalCallback); + } + } + + /** + * Lists the target executions of a job step execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The id of the job execution + * + * @param {string} stepName The name of the step. + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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. + */ + listByStepWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, stepName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByStep(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, stepName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the target executions of a job step execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The id of the job execution + * + * @param {string} stepName The name of the step. + * + * @param {object} [options] Optional Parameters. + * + * @param {date} [options.createTimeMin] If specified, only job executions + * created at or after the specified time are included. + * + * @param {date} [options.createTimeMax] If specified, only job executions + * created before the specified time are included. + * + * @param {date} [options.endTimeMin] If specified, only job executions + * completed at or after the specified time are included. + * + * @param {date} [options.endTimeMax] If specified, only job executions + * completed before the specified time are included. + * + * @param {boolean} [options.isActive] If specified, only active or only + * completed job executions are included. + * + * @param {number} [options.skip] The number of elements in the collection to + * skip. + * + * @param {number} [options.top] The number of elements to return from the + * collection. + * + * @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 {JobExecutionListResult} - 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 JobExecutionListResult} 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. + */ + listByStep(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, stepName, 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._listByStep(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, stepName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByStep(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, stepName, options, optionalCallback); + } + } + + /** + * Gets a target execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The unique id of the job execution + * + * @param {string} stepName The name of the step. + * + * @param {uuid} targetId The target id. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, stepName, targetId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, stepName, targetId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a target execution. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {uuid} jobExecutionId The unique id of the job execution + * + * @param {string} stepName The name of the step. + * + * @param {uuid} targetId The target id. + * + * @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 {JobExecution} - 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 JobExecution} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, stepName, targetId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, stepName, targetId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, stepName, targetId, options, optionalCallback); + } + } + + /** + * Lists target executions for all steps of a job execution. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByJobExecutionNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByJobExecutionNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists target executions for all steps of a job execution. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {JobExecutionListResult} - 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 JobExecutionListResult} 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. + */ + listByJobExecutionNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByJobExecutionNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByJobExecutionNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Lists the target executions of a job step execution. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByStepNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByStepNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the target executions of a job step execution. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {JobExecutionListResult} - 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 JobExecutionListResult} 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. + */ + listByStepNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByStepNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByStepNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = JobTargetExecutions; diff --git a/lib/services/sqlManagement2/lib/operations/jobTargetGroups.js b/lib/services/sqlManagement2/lib/operations/jobTargetGroups.js new file mode 100644 index 0000000000..1506126565 --- /dev/null +++ b/lib/services/sqlManagement2/lib/operations/jobTargetGroups.js @@ -0,0 +1,1286 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets all target groups in an agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @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 JobTargetGroupListResult} 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 _listByAgent(resourceGroupName, serverName, jobAgentName, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(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['JobTargetGroupListResult']().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 target group. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} targetGroupName The name of the target group. + * + * @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 JobTargetGroup} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, serverName, jobAgentName, targetGroupName, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (targetGroupName === null || targetGroupName === undefined || typeof targetGroupName.valueOf() !== 'string') { + throw new Error('targetGroupName 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{targetGroupName}', encodeURIComponent(targetGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(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['JobTargetGroup']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Creates or updates a target group. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} targetGroupName The name of the target group. + * + * @param {object} parameters The requested state of the target group. + * + * @param {array} parameters.members Members of the target group. + * + * @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 JobTargetGroup} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(resourceGroupName, serverName, jobAgentName, targetGroupName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (targetGroupName === null || targetGroupName === undefined || typeof targetGroupName.valueOf() !== 'string') { + throw new Error('targetGroupName cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{targetGroupName}', encodeURIComponent(targetGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['JobTargetGroup']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['JobTargetGroup']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['JobTargetGroup']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Deletes a target group. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} targetGroupName The name of the target group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(resourceGroupName, serverName, jobAgentName, targetGroupName, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (targetGroupName === null || targetGroupName === undefined || typeof targetGroupName.valueOf() !== 'string') { + throw new Error('targetGroupName 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{targetGroupName}', encodeURIComponent(targetGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (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 && statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets all target groups in an agent. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link JobTargetGroupListResult} 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 _listByAgentNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['JobTargetGroupListResult']().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 JobTargetGroups. */ +class JobTargetGroups { + /** + * Create a JobTargetGroups. + * @param {SqlManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._listByAgent = _listByAgent; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + this._deleteMethod = _deleteMethod; + this._listByAgentNext = _listByAgentNext; + } + + /** + * Gets all target groups in an agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @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. + */ + listByAgentWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByAgent(resourceGroupName, serverName, jobAgentName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets all target groups in an agent. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @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 {JobTargetGroupListResult} - 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 JobTargetGroupListResult} 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. + */ + listByAgent(resourceGroupName, serverName, jobAgentName, 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._listByAgent(resourceGroupName, serverName, jobAgentName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByAgent(resourceGroupName, serverName, jobAgentName, options, optionalCallback); + } + } + + /** + * Gets a target group. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} targetGroupName The name of the target group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, targetGroupName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, jobAgentName, targetGroupName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a target group. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} targetGroupName The name of the target group. + * + * @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 {JobTargetGroup} - 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 JobTargetGroup} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, serverName, jobAgentName, targetGroupName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, jobAgentName, targetGroupName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, serverName, jobAgentName, targetGroupName, options, optionalCallback); + } + } + + /** + * Creates or updates a target group. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} targetGroupName The name of the target group. + * + * @param {object} parameters The requested state of the target group. + * + * @param {array} parameters.members Members of the target group. + * + * @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. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, targetGroupName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, serverName, jobAgentName, targetGroupName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Creates or updates a target group. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} targetGroupName The name of the target group. + * + * @param {object} parameters The requested state of the target group. + * + * @param {array} parameters.members Members of the target group. + * + * @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 {JobTargetGroup} - 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 JobTargetGroup} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName, serverName, jobAgentName, targetGroupName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, serverName, jobAgentName, targetGroupName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, serverName, jobAgentName, targetGroupName, parameters, options, optionalCallback); + } + } + + /** + * Deletes a target group. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} targetGroupName The name of the target group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, targetGroupName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, serverName, jobAgentName, targetGroupName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Deletes a target group. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} targetGroupName The name of the target group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName, serverName, jobAgentName, targetGroupName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, serverName, jobAgentName, targetGroupName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, serverName, jobAgentName, targetGroupName, options, optionalCallback); + } + } + + /** + * Gets all target groups in an agent. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByAgentNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByAgentNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets all target groups in an agent. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {JobTargetGroupListResult} - 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 JobTargetGroupListResult} 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. + */ + listByAgentNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByAgentNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByAgentNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = JobTargetGroups; diff --git a/lib/services/sqlManagement2/lib/operations/jobVersions.js b/lib/services/sqlManagement2/lib/operations/jobVersions.js new file mode 100644 index 0000000000..d37eece0f7 --- /dev/null +++ b/lib/services/sqlManagement2/lib/operations/jobVersions.js @@ -0,0 +1,763 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets all versions of a job. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @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 JobVersionListResult} 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 _listByJob(resourceGroupName, serverName, jobAgentName, jobName, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') { + throw new Error('jobName 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(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['JobVersionListResult']().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 job version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {number} jobVersion The version of the job to get. + * + * @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 JobVersion} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, serverName, jobAgentName, jobName, jobVersion, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') { + throw new Error('jobName cannot be null or undefined and it must be of type string.'); + } + if (jobVersion === null || jobVersion === undefined || typeof jobVersion !== 'number') { + throw new Error('jobVersion cannot be null or undefined and it must be of type number.'); + } + 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName)); + requestUrl = requestUrl.replace('{jobVersion}', encodeURIComponent(jobVersion.toString())); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(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['JobVersion']().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 all versions of a job. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link JobVersionListResult} 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 _listByJobNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['JobVersionListResult']().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 JobVersions. */ +class JobVersions { + /** + * Create a JobVersions. + * @param {SqlManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._listByJob = _listByJob; + this._get = _get; + this._listByJobNext = _listByJobNext; + } + + /** + * Gets all versions of a job. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @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. + */ + listByJobWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, jobName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByJob(resourceGroupName, serverName, jobAgentName, jobName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets all versions of a job. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @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 {JobVersionListResult} - 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 JobVersionListResult} 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. + */ + listByJob(resourceGroupName, serverName, jobAgentName, jobName, 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._listByJob(resourceGroupName, serverName, jobAgentName, jobName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByJob(resourceGroupName, serverName, jobAgentName, jobName, options, optionalCallback); + } + } + + /** + * Gets a job version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {number} jobVersion The version of the job to get. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, jobName, jobVersion, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, jobAgentName, jobName, jobVersion, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a job version. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job. + * + * @param {number} jobVersion The version of the job to get. + * + * @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 {JobVersion} - 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 JobVersion} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, serverName, jobAgentName, jobName, jobVersion, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, jobAgentName, jobName, jobVersion, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, serverName, jobAgentName, jobName, jobVersion, options, optionalCallback); + } + } + + /** + * Gets all versions of a job. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByJobNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByJobNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets all versions of a job. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {JobVersionListResult} - 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 JobVersionListResult} 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. + */ + listByJobNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByJobNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByJobNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = JobVersions; diff --git a/lib/services/sqlManagement2/lib/operations/jobs.js b/lib/services/sqlManagement2/lib/operations/jobs.js new file mode 100644 index 0000000000..01d36bc8f5 --- /dev/null +++ b/lib/services/sqlManagement2/lib/operations/jobs.js @@ -0,0 +1,1333 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets a list of jobs. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @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 JobListResult} 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 _listByAgent(resourceGroupName, serverName, jobAgentName, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(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['JobListResult']().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 job. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @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 Job} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, serverName, jobAgentName, jobName, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') { + throw new Error('jobName 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(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['Job']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Creates or updates a job. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {object} parameters The requested job state. + * + * @param {string} [parameters.description] User-defined description of the + * job. + * + * @param {object} [parameters.schedule] Schedule properties of the job. + * + * @param {date} [parameters.schedule.startTime] Schedule start time. + * + * @param {date} [parameters.schedule.endTime] Schedule end time. + * + * @param {string} [parameters.schedule.type] Schedule interval type. Possible + * values include: 'Once', 'Recurring' + * + * @param {boolean} [parameters.schedule.enabled] Whether or not the schedule + * is enabled. + * + * @param {string} [parameters.schedule.interval] Value of the schedule's + * recurring interval, if the scheduletype is recurring. ISO8601 duration + * format. + * + * @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 Job} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(resourceGroupName, serverName, jobAgentName, jobName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') { + throw new Error('jobName cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['Job']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['Job']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Job']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Deletes a job. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to delete. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(resourceGroupName, serverName, jobAgentName, jobName, 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 apiVersion = '2017-03-01-preview'; + // 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 (serverName === null || serverName === undefined || typeof serverName.valueOf() !== 'string') { + throw new Error('serverName cannot be null or undefined and it must be of type string.'); + } + if (jobAgentName === null || jobAgentName === undefined || typeof jobAgentName.valueOf() !== 'string') { + throw new Error('jobAgentName cannot be null or undefined and it must be of type string.'); + } + if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') { + throw new Error('jobName 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.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{serverName}', encodeURIComponent(serverName)); + requestUrl = requestUrl.replace('{jobAgentName}', encodeURIComponent(jobAgentName)); + requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (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 && statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets a list of jobs. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link JobListResult} 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 _listByAgentNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['JobListResult']().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 Jobs. */ +class Jobs { + /** + * Create a Jobs. + * @param {SqlManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._listByAgent = _listByAgent; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + this._deleteMethod = _deleteMethod; + this._listByAgentNext = _listByAgentNext; + } + + /** + * Gets a list of jobs. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @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. + */ + listByAgentWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByAgent(resourceGroupName, serverName, jobAgentName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a list of jobs. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @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 {JobListResult} - 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 JobListResult} 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. + */ + listByAgent(resourceGroupName, serverName, jobAgentName, 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._listByAgent(resourceGroupName, serverName, jobAgentName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByAgent(resourceGroupName, serverName, jobAgentName, options, optionalCallback); + } + } + + /** + * Gets a job. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, jobName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, jobAgentName, jobName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a job. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @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 {Job} - 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 Job} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, serverName, jobAgentName, jobName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, serverName, jobAgentName, jobName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, serverName, jobAgentName, jobName, options, optionalCallback); + } + } + + /** + * Creates or updates a job. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {object} parameters The requested job state. + * + * @param {string} [parameters.description] User-defined description of the + * job. + * + * @param {object} [parameters.schedule] Schedule properties of the job. + * + * @param {date} [parameters.schedule.startTime] Schedule start time. + * + * @param {date} [parameters.schedule.endTime] Schedule end time. + * + * @param {string} [parameters.schedule.type] Schedule interval type. Possible + * values include: 'Once', 'Recurring' + * + * @param {boolean} [parameters.schedule.enabled] Whether or not the schedule + * is enabled. + * + * @param {string} [parameters.schedule.interval] Value of the schedule's + * recurring interval, if the scheduletype is recurring. ISO8601 duration + * format. + * + * @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. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, jobName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, serverName, jobAgentName, jobName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Creates or updates a job. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to get. + * + * @param {object} parameters The requested job state. + * + * @param {string} [parameters.description] User-defined description of the + * job. + * + * @param {object} [parameters.schedule] Schedule properties of the job. + * + * @param {date} [parameters.schedule.startTime] Schedule start time. + * + * @param {date} [parameters.schedule.endTime] Schedule end time. + * + * @param {string} [parameters.schedule.type] Schedule interval type. Possible + * values include: 'Once', 'Recurring' + * + * @param {boolean} [parameters.schedule.enabled] Whether or not the schedule + * is enabled. + * + * @param {string} [parameters.schedule.interval] Value of the schedule's + * recurring interval, if the scheduletype is recurring. ISO8601 duration + * format. + * + * @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 {Job} - 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 Job} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName, serverName, jobAgentName, jobName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, serverName, jobAgentName, jobName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, serverName, jobAgentName, jobName, parameters, options, optionalCallback); + } + } + + /** + * Deletes a job. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to delete. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, serverName, jobAgentName, jobName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, serverName, jobAgentName, jobName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Deletes a job. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {string} jobAgentName The name of the job agent. + * + * @param {string} jobName The name of the job to delete. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName, serverName, jobAgentName, jobName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, serverName, jobAgentName, jobName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, serverName, jobAgentName, jobName, options, optionalCallback); + } + } + + /** + * Gets a list of jobs. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByAgentNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByAgentNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a list of jobs. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {JobListResult} - 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 JobListResult} 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. + */ + listByAgentNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByAgentNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByAgentNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = Jobs; diff --git a/lib/services/sqlManagement2/lib/sqlManagementClient.d.ts b/lib/services/sqlManagement2/lib/sqlManagementClient.d.ts index 9063d7659f..60e984b741 100644 --- a/lib/services/sqlManagement2/lib/sqlManagementClient.d.ts +++ b/lib/services/sqlManagement2/lib/sqlManagementClient.d.ts @@ -89,6 +89,17 @@ export default class SqlManagementClient extends AzureServiceClient { syncMembers: operations.SyncMembers; subscriptionUsages: operations.SubscriptionUsages; virtualNetworkRules: operations.VirtualNetworkRules; + databaseVulnerabilityAssessmentRuleBaselines: operations.DatabaseVulnerabilityAssessmentRuleBaselines; + databaseVulnerabilityAssessments: operations.DatabaseVulnerabilityAssessments; + jobAgents: operations.JobAgents; + jobCredentials: operations.JobCredentials; + jobExecutions: operations.JobExecutions; + jobs: operations.Jobs; + jobStepExecutions: operations.JobStepExecutions; + jobSteps: operations.JobSteps; + jobTargetExecutions: operations.JobTargetExecutions; + jobTargetGroups: operations.JobTargetGroups; + jobVersions: operations.JobVersions; longTermRetentionBackups: operations.LongTermRetentionBackups; backupLongTermRetentionPolicies: operations.BackupLongTermRetentionPolicies; managedDatabases: operations.ManagedDatabases; @@ -98,6 +109,7 @@ export default class SqlManagementClient extends AzureServiceClient { databaseOperations: operations.DatabaseOperations; elasticPoolOperations: operations.ElasticPoolOperations; capabilities: operations.Capabilities; + databaseVulnerabilityAssessmentScans: operations.DatabaseVulnerabilityAssessmentScans; instanceFailoverGroups: operations.InstanceFailoverGroups; shortTermRetentionPolicies: operations.ShortTermRetentionPolicies; } diff --git a/lib/services/sqlManagement2/lib/sqlManagementClient.js b/lib/services/sqlManagement2/lib/sqlManagementClient.js index 184fb325a5..788e602c20 100644 --- a/lib/services/sqlManagement2/lib/sqlManagementClient.js +++ b/lib/services/sqlManagement2/lib/sqlManagementClient.js @@ -106,6 +106,17 @@ class SqlManagementClient extends ServiceClient { this.syncMembers = new operations.SyncMembers(this); this.subscriptionUsages = new operations.SubscriptionUsages(this); this.virtualNetworkRules = new operations.VirtualNetworkRules(this); + this.databaseVulnerabilityAssessmentRuleBaselines = new operations.DatabaseVulnerabilityAssessmentRuleBaselines(this); + this.databaseVulnerabilityAssessments = new operations.DatabaseVulnerabilityAssessments(this); + this.jobAgents = new operations.JobAgents(this); + this.jobCredentials = new operations.JobCredentials(this); + this.jobExecutions = new operations.JobExecutions(this); + this.jobs = new operations.Jobs(this); + this.jobStepExecutions = new operations.JobStepExecutions(this); + this.jobSteps = new operations.JobSteps(this); + this.jobTargetExecutions = new operations.JobTargetExecutions(this); + this.jobTargetGroups = new operations.JobTargetGroups(this); + this.jobVersions = new operations.JobVersions(this); this.longTermRetentionBackups = new operations.LongTermRetentionBackups(this); this.backupLongTermRetentionPolicies = new operations.BackupLongTermRetentionPolicies(this); this.managedDatabases = new operations.ManagedDatabases(this); @@ -115,6 +126,7 @@ class SqlManagementClient extends ServiceClient { this.databaseOperations = new operations.DatabaseOperations(this); this.elasticPoolOperations = new operations.ElasticPoolOperations(this); this.capabilities = new operations.Capabilities(this); + this.databaseVulnerabilityAssessmentScans = new operations.DatabaseVulnerabilityAssessmentScans(this); this.instanceFailoverGroups = new operations.InstanceFailoverGroups(this); this.shortTermRetentionPolicies = new operations.ShortTermRetentionPolicies(this); this.models = models; diff --git a/lib/services/sqlManagement2/package.json b/lib/services/sqlManagement2/package.json index d5e5b8a331..a13187766e 100644 --- a/lib/services/sqlManagement2/package.json +++ b/lib/services/sqlManagement2/package.json @@ -4,10 +4,13 @@ "description": "SqlManagementClient Library with typescript type definitions for node", "version": "3.0.0", "dependencies": { - "ms-rest": "^2.3.2", + "ms-rest": "^2.3.3", "ms-rest-azure": "^2.5.5" }, - "keywords": [ "node", "azure" ], + "keywords": [ + "node", + "azure" + ], "license": "MIT", "main": "./lib/sqlManagementClient.js", "types": "./lib/sqlManagementClient.d.ts",