-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Firewall rule dialog creation support (#143)
* Revert "Revert "Firewall feature (#119)" (#126)" This reverts commit c8747de. * Shortening path length for install directory * Localizing firewall ui elements
- Loading branch information
1 parent
d508d4a
commit fd61ae8
Showing
7 changed files
with
148 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import * as azdata from 'azdata'; | ||
import { SqlOpsDataClient, SqlOpsFeature } from "dataprotocol-client"; | ||
import { ClientCapabilities, Disposable, RPCMessageType, ServerCapabilities } from "vscode-languageclient"; | ||
import { CreateFirewallRuleParams, CreateFirewallRuleRequest, HandleFirewallRuleParams, HandleFirewallRuleRequest } from "./contracts"; | ||
import * as UUID from 'vscode-languageclient/lib/utils/uuid'; | ||
import * as Utils from '../utils'; | ||
import { AzureMysqlResourceProviderName } from '../uiConstants'; | ||
|
||
|
||
|
||
export class FireWallFeature extends SqlOpsFeature<any> { | ||
|
||
private static readonly messagesTypes: RPCMessageType[] = [ | ||
CreateFirewallRuleRequest.type, | ||
HandleFirewallRuleRequest.type | ||
]; | ||
|
||
constructor(client: SqlOpsDataClient) { | ||
super(client, FireWallFeature.messagesTypes); | ||
} | ||
|
||
public fillClientCapabilities(capabilities: ClientCapabilities): void { | ||
Utils.ensure(capabilities, 'firewall')!.firewall = true; | ||
} | ||
|
||
public initialize(capabilities: ServerCapabilities): void { | ||
this.register(this.messages, { | ||
id: UUID.generateUuid(), | ||
registerOptions: undefined | ||
}); | ||
} | ||
|
||
protected registerProvider(options: any): Disposable { | ||
const client = this._client; | ||
|
||
let createFirewallRule = (account: azdata.Account, firewallruleInfo: azdata.FirewallRuleInfo): Thenable<azdata.CreateFirewallRuleResponse> => { | ||
return client.sendRequest(CreateFirewallRuleRequest.type, asCreateFirewallRuleParams(account, firewallruleInfo)); | ||
}; | ||
|
||
let handleFirewallRule = (errorCode: number, errorMessage: string, connectionTypeId: string): Thenable<azdata.HandleFirewallRuleResponse> => { | ||
let params: HandleFirewallRuleParams = { errorCode: errorCode, errorMessage: errorMessage, connectionTypeId: connectionTypeId }; | ||
return client.sendRequest(HandleFirewallRuleRequest.type, params); | ||
}; | ||
|
||
return azdata.resources.registerResourceProvider({ | ||
displayName: AzureMysqlResourceProviderName, | ||
id: 'Microsoft.Azure.MySQL.ResourceProvider', | ||
settings: { | ||
|
||
} | ||
}, { | ||
handleFirewallRule, | ||
createFirewallRule | ||
}); | ||
} | ||
} | ||
|
||
function asCreateFirewallRuleParams(account: azdata.Account, params: azdata.FirewallRuleInfo): CreateFirewallRuleParams { | ||
return { | ||
account: account, | ||
serverName: params.serverName, | ||
startIpAddress: params.startIpAddress, | ||
endIpAddress: params.endIpAddress, | ||
securityTokenMappings: params.securityTokenMappings, | ||
firewallRuleName: params.firewallRuleName | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters