Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e59b5a5
Add flexible server to the package deps
tonybaloney Jun 17, 2021
dd449ba
reformat package json
tonybaloney Jun 18, 2021
a2a3c21
package updates
tonybaloney Jun 18, 2021
30cc07a
Create an abstraction to list servers from both single and flexible
tonybaloney Jun 18, 2021
b959bca
Implement database listing
tonybaloney Jun 18, 2021
0aee0c9
Implement the delete server method
tonybaloney Jun 18, 2021
6f45fa8
Adapt the create server workflow to work with both single and flex
tonybaloney Jun 18, 2021
c82e084
Implement the firewall rule and server name APIs
tonybaloney Jun 18, 2021
c613c41
Update package lock
tonybaloney Jun 18, 2021
e9ac3af
Fix the single server password error
tonybaloney Jun 18, 2021
9053fb3
Extend the base types
tonybaloney Jun 18, 2021
dbc4f71
Propagate client options to fix the API versioning errors
tonybaloney Jun 18, 2021
eaedf83
Remove the interface and update method names based on PR review
tonybaloney Jun 22, 2021
27b5527
Document the storage sizes
tonybaloney Jun 23, 2021
6c088fe
Add more skus
tonybaloney Jun 23, 2021
bb01e7a
Refactor from PR review
tonybaloney Jun 30, 2021
a653cb5
Update src/postgres/abstract/models.ts
tonybaloney Jun 30, 2021
2e52481
Another round of PR revisions
tonybaloney Jun 30, 2021
c6244c5
Fix the abstract client listing
tonybaloney Jun 30, 2021
e3e9197
Update @azure/arm-postgresql-flexible to the patched version
tonybaloney Jul 6, 2021
05f8b4a
Merge branch 'main' into postgres_patch_update
tonybaloney Jul 8, 2021
4eaf7f1
Cleanup merge commit
tonybaloney Jul 8, 2021
9626855
Switch server resoure on name lookup for resource type
tonybaloney Jul 8, 2021
cb353d4
Set default versions and mention preview to flexible
tonybaloney Jul 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 40 additions & 99 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,8 @@
},
"dependencies": {
"@azure/arm-cosmosdb": "^9.1.0",
"@azure/arm-postgresql": "^4.4.0",
"@azure/arm-postgresql": "^5.0.0",
"@azure/arm-postgresql-flexible": "^1.0.0",
"@azure/cosmos": "^3.6.3",
"antlr4ts": "^0.4.1-alpha.0",
"bson": "^1.1.3",
Expand Down
8 changes: 5 additions & 3 deletions src/AzureDBExperiences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export enum API {
Graph = 'Graph',
Table = 'Table',
Core = 'Core',
Postgres = 'Postgres'
Postgres = 'Postgres',
Comment thread
tonybaloney marked this conversation as resolved.
Outdated
PostgresFlexible = 'PostgresFlexible'
}

export enum DBAccountKind {
Expand Down Expand Up @@ -109,8 +110,9 @@ const CoreExperience: Experience = { api: API.Core, longName: "Core", descriptio
export const MongoExperience: Experience = { api: API.MongoDB, longName: "Azure Cosmos DB for MongoDB API", shortName: "MongoDB", kind: DBAccountKind.MongoDB, tag: "Azure Cosmos DB for MongoDB API" };
const TableExperience: Experience = { api: API.Table, longName: "Azure Table", shortName: "Table", kind: DBAccountKind.GlobalDocumentDB, capability: 'EnableTable', tag: "Azure Table" };
const GremlinExperience: Experience = { api: API.Graph, longName: "Gremlin", description: "(graph)", shortName: "Gremlin", kind: DBAccountKind.GlobalDocumentDB, capability: 'EnableGremlin', tag: "Gremlin (graph)" };
const PostgresExperience: Experience = { api: API.Postgres, longName: "PostgreSQL", shortName: "PostgreSQL" };
const PostgresSingleExperience: Experience = { api: API.Postgres, longName: "PostgreSQL Single Server", shortName: "PostgreSQLSingle"};
const PostgresFlexibleExperience: Experience = { api: API.PostgresFlexible, longName: "PostgreSQL Flexible Server", shortName: "PostgreSQLFlexible"};
Comment thread
tonybaloney marked this conversation as resolved.
Outdated

const cosmosExperiencesArray: Experience[] = [CoreExperience, MongoExperience, TableExperience, GremlinExperience];
const experiencesArray: Experience[] = [...cosmosExperiencesArray, PostgresExperience];
const experiencesArray: Experience[] = [...cosmosExperiencesArray, PostgresSingleExperience, PostgresFlexibleExperience];
const experiencesMap = new Map<API, Experience>(experiencesArray.map((info: Experience): [API, Experience] => [info.api, info]));
83 changes: 83 additions & 0 deletions src/postgres/abstract/AbstractPostgresClient.ts
Original file line number Diff line number Diff line change
@@ -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.
*--------------------------------------------------------------------------------------------*/

import { PostgreSQLManagementClient } from "@azure/arm-postgresql";
import { PostgreSQLFlexibleManagementClient } from "@azure/arm-postgresql-flexible";
import * as msRest from "@azure/ms-rest-js";
import { IMinimumServiceClientOptions } from "vscode-azureextensionui";
import { IAbstractPostgresClient } from "./IAbstractPostgresClient";
import { asAbstractDatabase, asFlexibleParameters, asSingleParameters, flexibleAsAbstractServer, singleAsAbstractServer } from "./maps";
import * as Models from "./models";

export class AbstractPostgresClient implements IAbstractPostgresClient {
Comment thread
tonybaloney marked this conversation as resolved.
Outdated
private postgresFlexibleClient: PostgreSQLFlexibleManagementClient;
private postgresSingleClient: PostgreSQLManagementClient;

constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: IMinimumServiceClientOptions) {
this.postgresFlexibleClient = new PostgreSQLFlexibleManagementClient(credentials, subscriptionId, options);
this.postgresSingleClient = new PostgreSQLManagementClient(credentials, subscriptionId, options);
}

async checkNameAvailability(serverType: Models.PostgresServerType, name: string) : Promise<Models.AbstractNameAvailability> {
switch (serverType){
case Models.PostgresServerType.Flexible:
return this.postgresFlexibleClient.checkNameAvailability.execute({name: name, type: "Microsoft.DBforPostgreSQL"});
case Models.PostgresServerType.Single:
return this.postgresSingleClient.checkNameAvailability.execute({name: name, type: "Microsoft.DBforPostgreSQL"});
default:
throw new Error("Service not implemented.");
}
}

async createFirewallRule(serverType: Models.PostgresServerType, resourceGroup: string, name: string, ruleName: string, rule: Models.AbstractFirewallRule): Promise<Models.AbstractFirewallRule> {
Comment thread
tonybaloney marked this conversation as resolved.
Outdated
switch (serverType){
case Models.PostgresServerType.Flexible:
return this.postgresFlexibleClient.firewallRules.createOrUpdate(resourceGroup, name, ruleName, rule);
case Models.PostgresServerType.Single:
return this.postgresSingleClient.firewallRules.createOrUpdate(resourceGroup, name, ruleName, rule);
default:
throw new Error("Service not implemented.");
}
}

async createServer(serverType: Models.PostgresServerType, resourceGroup: string, name: string, parameters: Models.AbstractServerCreate): Promise<Models.PostgresAbstractServer> {
Comment thread
tonybaloney marked this conversation as resolved.
Outdated
switch (serverType){
case Models.PostgresServerType.Flexible:
return flexibleAsAbstractServer(await this.postgresFlexibleClient.servers.create(resourceGroup, name, asFlexibleParameters(parameters)));
case Models.PostgresServerType.Single:
return singleAsAbstractServer(await this.postgresSingleClient.servers.create(resourceGroup, name, asSingleParameters(parameters)));
default:
throw new Error("Service not implemented.");
}
}

async deleteServer(serverType: Models.PostgresServerType, resourceGroup: string, name: string): Promise<msRest.RestResponse> {
switch (serverType){
case Models.PostgresServerType.Flexible:
return this.postgresFlexibleClient.servers.deleteMethod(resourceGroup, name);
case Models.PostgresServerType.Single:
return this.postgresSingleClient.servers.deleteMethod(resourceGroup, name);
default:
throw new Error("Service not implemented.");
}
}

async listServers(): Promise<Models.PostgresAbstractServerList> {
Comment thread
tonybaloney marked this conversation as resolved.
Outdated
const flexServers = (await this.postgresFlexibleClient.servers.list()).map(flexibleAsAbstractServer);
const singleServers = (await this.postgresSingleClient.servers.list()).map(singleAsAbstractServer);
return Array<Models.PostgresAbstractServer>().concat(flexServers, singleServers);
}

async listDatabases(serverType: Models.PostgresServerType, resourceGroup: string, name: string): Promise<Models.PostgresAbstractDatabaseList> {
switch (serverType){
case Models.PostgresServerType.Flexible:
return (await this.postgresFlexibleClient.databases.listByServer(resourceGroup, name)).map(asAbstractDatabase);
case Models.PostgresServerType.Single:
return (await this.postgresSingleClient.databases.listByServer(resourceGroup, name)).map(asAbstractDatabase);
default:
throw new Error("Service not implemented.");
}
}
}
16 changes: 16 additions & 0 deletions src/postgres/abstract/IAbstractPostgresClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as msRest from "@azure/ms-rest-js";
import * as Models from './models';

export interface IAbstractPostgresClient {
deleteServer(serverType: Models.PostgresServerType, resourceGroup: string, name: string): Promise<msRest.RestResponse>;
listDatabases(serverType: Models.PostgresServerType, resourceGroup: string, name: string): Promise<Models.PostgresAbstractDatabaseList>;
listServers(): Promise<Models.PostgresAbstractServerList>;
createServer(serverType: Models.PostgresServerType, resourceGroup: string, name: string, options: Models.AbstractServerCreate): Promise<Models.PostgresAbstractServer>;
checkNameAvailability(serverType: Models.PostgresServerType, name: string) : Promise<Models.AbstractNameAvailability>;
createFirewallRule(serverType: Models.PostgresServerType, resourceGroup: string, name: string, ruleName: string, rule: Models.AbstractFirewallRule) : Promise<Models.AbstractFirewallRule>;
}
Loading