mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-13 11:38:36 -05:00
New Operator, Alert and Proxy request handlers (#1846)
* Add agent dialog class * Rename agent dialog data classes * Alert dialog data updates * Create operator and proxy handlers
This commit is contained in:
79
extensions/agent/src/data/alertData.ts
Normal file
79
extensions/agent/src/data/alertData.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as sqlops from 'sqlops';
|
||||
import { AgentUtils } from '../agentUtils';
|
||||
import { IAgentDialogData } from '../interfaces';
|
||||
|
||||
export class AlertData implements IAgentDialogData {
|
||||
ownerUri: string;
|
||||
id: number;
|
||||
name: string;
|
||||
delayBetweenResponses: number;
|
||||
eventDescriptionKeyword: string;
|
||||
eventSource: string;
|
||||
hasNotification: number;
|
||||
includeEventDescription: string;
|
||||
isEnabled: boolean;
|
||||
jobId: string;
|
||||
jobName: string;
|
||||
lastOccurrenceDate: string;
|
||||
lastResponseDate: string;
|
||||
messageId: number;
|
||||
notificationMessage: string;
|
||||
occurrenceCount: number;
|
||||
performanceCondition: string;
|
||||
severity: number;
|
||||
databaseName: string;
|
||||
countResetDate: string;
|
||||
categoryName: string;
|
||||
alertType: string;
|
||||
wmiEventNamespace: string;
|
||||
wmiEventQuery: string;
|
||||
|
||||
constructor(ownerUri:string) {
|
||||
this.ownerUri = ownerUri;
|
||||
}
|
||||
|
||||
public async initialize() {
|
||||
}
|
||||
|
||||
public async save() {
|
||||
let agentService = await AgentUtils.getAgentService();
|
||||
let result = await agentService.createAlert(this.ownerUri, this.toAgentAlertInfo());
|
||||
if (!result || !result.success) {
|
||||
// TODO handle error here
|
||||
}
|
||||
}
|
||||
|
||||
public toAgentAlertInfo(): sqlops.AgentAlertInfo {
|
||||
return {
|
||||
id: this.id,
|
||||
name: this.name,
|
||||
delayBetweenResponses: this.delayBetweenResponses,
|
||||
eventDescriptionKeyword: this.eventDescriptionKeyword,
|
||||
eventSource: this.eventSource,
|
||||
hasNotification: this.hasNotification,
|
||||
includeEventDescription: sqlops.NotifyMethods.none, // this.includeEventDescription,
|
||||
isEnabled: this.isEnabled,
|
||||
jobId: this.jobId,
|
||||
jobName: this.jobName,
|
||||
lastOccurrenceDate: this.lastOccurrenceDate,
|
||||
lastResponseDate: this.lastResponseDate,
|
||||
messageId: this.messageId,
|
||||
notificationMessage: this.notificationMessage,
|
||||
occurrenceCount: this.occurrenceCount,
|
||||
performanceCondition: this.performanceCondition,
|
||||
severity: this.severity,
|
||||
databaseName: this.databaseName,
|
||||
countResetDate: this.countResetDate,
|
||||
categoryName: this.categoryName,
|
||||
alertType: sqlops.AlertType.sqlServerEvent, //this.alertType,
|
||||
wmiEventNamespace: this.wmiEventNamespace,
|
||||
wmiEventQuery: this.wmiEventQuery
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as sqlops from 'sqlops';
|
||||
import { AgentUtils } from '../agentUtils';
|
||||
|
||||
export class CreateAlertData {
|
||||
public ownerUri: string;
|
||||
private _alert: sqlops.AgentAlertInfo;
|
||||
|
||||
constructor(ownerUri:string) {
|
||||
this.ownerUri = ownerUri;
|
||||
}
|
||||
|
||||
public async initialize() {
|
||||
let agentService = await AgentUtils.getAgentService();
|
||||
|
||||
}
|
||||
|
||||
public async save() {
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as sqlops from 'sqlops';
|
||||
import { AgentUtils } from '../agentUtils';
|
||||
|
||||
export class CreateOperatorData {
|
||||
public ownerUri: string;
|
||||
private _alert: sqlops.AgentOperatorInfo;
|
||||
|
||||
constructor(ownerUri:string) {
|
||||
this.ownerUri = ownerUri;
|
||||
}
|
||||
|
||||
public async initialize() {
|
||||
let agentService = await AgentUtils.getAgentService();
|
||||
|
||||
}
|
||||
|
||||
public async save() {
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as sqlops from 'sqlops';
|
||||
import { AgentUtils } from '../agentUtils';
|
||||
|
||||
export class CreateProxyData {
|
||||
public ownerUri: string;
|
||||
private _alert: sqlops.AgentProxyInfo;
|
||||
|
||||
constructor(ownerUri:string) {
|
||||
this.ownerUri = ownerUri;
|
||||
}
|
||||
|
||||
public async initialize() {
|
||||
let agentService = await AgentUtils.getAgentService();
|
||||
|
||||
}
|
||||
|
||||
public async save() {
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,9 @@
|
||||
|
||||
import * as sqlops from 'sqlops';
|
||||
import { AgentUtils } from '../agentUtils';
|
||||
import { IAgentDialogData } from '../interfaces';
|
||||
|
||||
export class CreateJobData {
|
||||
export class JobData implements IAgentDialogData {
|
||||
|
||||
private readonly JobCompletionActionCondition_Always: string = 'When the job completes';
|
||||
private readonly JobCompletionActionCondition_OnFailure: string = 'When the job fails';
|
||||
@@ -5,8 +5,9 @@
|
||||
'use strict';
|
||||
|
||||
import { AgentUtils } from '../agentUtils';
|
||||
import { IAgentDialogData } from '../interfaces';
|
||||
|
||||
export class CreateStepData {
|
||||
export class JobStepData implements IAgentDialogData {
|
||||
public ownerUri: string;
|
||||
public jobId: string; //
|
||||
public jobName: string;
|
||||
@@ -37,6 +38,9 @@ export class CreateStepData {
|
||||
this.ownerUri = ownerUri;
|
||||
}
|
||||
|
||||
public async initialize() {
|
||||
}
|
||||
|
||||
public async save() {
|
||||
let agentService = await AgentUtils.getAgentService();
|
||||
agentService.createJobStep(this.ownerUri, {
|
||||
67
extensions/agent/src/data/operatorData.ts
Normal file
67
extensions/agent/src/data/operatorData.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as sqlops from 'sqlops';
|
||||
import { AgentUtils } from '../agentUtils';
|
||||
import { IAgentDialogData } from '../interfaces';
|
||||
|
||||
export class OperatorData implements IAgentDialogData {
|
||||
ownerUri: string;
|
||||
name: string;
|
||||
id: number;
|
||||
emailAddress: string;
|
||||
enabled: boolean;
|
||||
lastEmailDate: string;
|
||||
lastNetSendDate: string;
|
||||
lastPagerDate: string;
|
||||
pagerAddress: string;
|
||||
categoryName: string;
|
||||
pagerDays: string;
|
||||
saturdayPagerEndTime: string;
|
||||
saturdayPagerStartTime: string;
|
||||
sundayPagerEndTime: string;
|
||||
sundayPagerStartTime: string;
|
||||
netSendAddress: string;
|
||||
weekdayPagerStartTime: string;
|
||||
weekdayPagerEndTime: string;
|
||||
|
||||
constructor(ownerUri:string) {
|
||||
this.ownerUri = ownerUri;
|
||||
}
|
||||
|
||||
public async initialize() {
|
||||
}
|
||||
|
||||
public async save() {
|
||||
let agentService = await AgentUtils.getAgentService();
|
||||
let result = await agentService.createOperator(this.ownerUri, this.toAgentOperatorInfo());
|
||||
if (!result || !result.success) {
|
||||
// TODO handle error here
|
||||
}
|
||||
}
|
||||
|
||||
public toAgentOperatorInfo(): sqlops.AgentOperatorInfo {
|
||||
return {
|
||||
name: this.name,
|
||||
id: this.id,
|
||||
emailAddress: this.emailAddress,
|
||||
enabled: this.enabled,
|
||||
lastEmailDate: this.lastEmailDate,
|
||||
lastNetSendDate: this.lastNetSendDate,
|
||||
lastPagerDate: this.lastPagerDate,
|
||||
pagerAddress: this.pagerAddress,
|
||||
categoryName: this.categoryName,
|
||||
pagerDays: sqlops.WeekDays.weekDays, //this.pagerDays,
|
||||
saturdayPagerEndTime: this.saturdayPagerEndTime,
|
||||
saturdayPagerStartTime: this.saturdayPagerStartTime,
|
||||
sundayPagerEndTime: this.sundayPagerEndTime,
|
||||
sundayPagerStartTime: this.sundayPagerStartTime,
|
||||
netSendAddress: this.netSendAddress,
|
||||
weekdayPagerStartTime: this.weekdayPagerStartTime,
|
||||
weekdayPagerEndTime: this.weekdayPagerEndTime
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,9 @@
|
||||
|
||||
import * as sqlops from 'sqlops';
|
||||
import { AgentUtils } from '../agentUtils';
|
||||
import { IAgentDialogData } from '../interfaces';
|
||||
|
||||
export class PickScheduleData {
|
||||
export class PickScheduleData implements IAgentDialogData {
|
||||
public ownerUri: string;
|
||||
public schedules: sqlops.AgentJobScheduleInfo[];
|
||||
public selectedSchedule: sqlops.AgentJobScheduleInfo;
|
||||
|
||||
47
extensions/agent/src/data/proxyData.ts
Normal file
47
extensions/agent/src/data/proxyData.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as sqlops from 'sqlops';
|
||||
import { AgentUtils } from '../agentUtils';
|
||||
import { IAgentDialogData } from '../interfaces';
|
||||
|
||||
export class ProxyData implements IAgentDialogData {
|
||||
ownerUri: string;
|
||||
id: number;
|
||||
accountName: string;
|
||||
description: string;
|
||||
credentialName: string;
|
||||
credentialIdentity: string;
|
||||
credentialId: number;
|
||||
isEnabled: boolean;
|
||||
|
||||
constructor(ownerUri:string) {
|
||||
this.ownerUri = ownerUri;
|
||||
}
|
||||
|
||||
public async initialize() {
|
||||
}
|
||||
|
||||
public async save() {
|
||||
let agentService = await AgentUtils.getAgentService();
|
||||
let result = await agentService.createProxy(this.ownerUri, this.toAgentProxyInfo());
|
||||
if (!result || !result.success) {
|
||||
// TODO handle error here
|
||||
}
|
||||
}
|
||||
|
||||
public toAgentProxyInfo(): sqlops.AgentProxyInfo {
|
||||
return {
|
||||
id: this.id,
|
||||
accountName: this.accountName,
|
||||
description: this.description,
|
||||
credentialName: this.credentialName,
|
||||
credentialIdentity: this.credentialIdentity,
|
||||
credentialId: this.credentialId,
|
||||
isEnabled: this.isEnabled
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,9 @@
|
||||
|
||||
import * as sqlops from 'sqlops';
|
||||
import { AgentUtils } from '../agentUtils';
|
||||
import { IAgentDialogData } from '../interfaces';
|
||||
|
||||
export class CreateScheduleData {
|
||||
export class ScheduleData implements IAgentDialogData {
|
||||
public ownerUri: string;
|
||||
public schedules: sqlops.AgentJobScheduleInfo[];
|
||||
public selectedSchedule: sqlops.AgentJobScheduleInfo;
|
||||
Reference in New Issue
Block a user