-
Notifications
You must be signed in to change notification settings - Fork 81
Abstract the Postgres management client to allow both single and flexible server #1872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 16 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 dd449ba
reformat package json
tonybaloney a2a3c21
package updates
tonybaloney 30cc07a
Create an abstraction to list servers from both single and flexible
tonybaloney b959bca
Implement database listing
tonybaloney 0aee0c9
Implement the delete server method
tonybaloney 6f45fa8
Adapt the create server workflow to work with both single and flex
tonybaloney c82e084
Implement the firewall rule and server name APIs
tonybaloney c613c41
Update package lock
tonybaloney e9ac3af
Fix the single server password error
tonybaloney 9053fb3
Extend the base types
tonybaloney dbc4f71
Propagate client options to fix the API versioning errors
tonybaloney eaedf83
Remove the interface and update method names based on PR review
tonybaloney 27b5527
Document the storage sizes
tonybaloney 6c088fe
Add more skus
tonybaloney bb01e7a
Refactor from PR review
tonybaloney a653cb5
Update src/postgres/abstract/models.ts
tonybaloney 2e52481
Another round of PR revisions
tonybaloney c6244c5
Fix the abstract client listing
tonybaloney e3e9197
Update @azure/arm-postgresql-flexible to the patched version
tonybaloney 05f8b4a
Merge branch 'main' into postgres_patch_update
tonybaloney 4eaf7f1
Cleanup merge commit
tonybaloney 9626855
Switch server resoure on name lookup for resource type
tonybaloney cb353d4
Set default versions and mention preview to flexible
tonybaloney File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,22 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * 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 { createAzureClient, ISubscriptionContext } from "vscode-azureextensionui"; | ||
| import { PostgresServerType } from "./models"; | ||
|
|
||
| export type AbstractPostgresClient = PostgreSQLFlexibleManagementClient | PostgreSQLManagementClient; | ||
|
|
||
| export function createAbstractPostgresClient(serverType: PostgresServerType, clientInfo: ISubscriptionContext): AbstractPostgresClient { | ||
| switch (serverType) { | ||
| case PostgresServerType.Flexible: | ||
| return createAzureClient(clientInfo, PostgreSQLFlexibleManagementClient); | ||
| case PostgresServerType.Single: | ||
| return createAzureClient(clientInfo, PostgreSQLManagementClient); | ||
| default: | ||
| throw new Error("Service not implemented."); | ||
| } | ||
| } |
This file contains hidden or 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,60 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import * as FlexibleModels from "@azure/arm-postgresql-flexible/esm/models"; | ||
| import * as SingleModels from "@azure/arm-postgresql/esm/models"; | ||
|
tonybaloney marked this conversation as resolved.
Outdated
|
||
|
|
||
| export enum PostgresServerType { | ||
| Flexible, | ||
| Single | ||
| } | ||
|
|
||
| export type PostgresAbstractServer = (SingleModels.Server | FlexibleModels.Server) & { serverType?: PostgresServerType; } | ||
|
|
||
| export type PostgresAbstractServerList = Array<PostgresAbstractServer>; | ||
|
tonybaloney marked this conversation as resolved.
Outdated
|
||
|
|
||
| export type PostgresAbstractDatabase = SingleModels.Database | FlexibleModels.Database; | ||
|
|
||
| export type PostgresAbstractDatabaseList = Array<PostgresAbstractDatabase>; | ||
|
|
||
| /** | ||
| * Billing information related properties of a server. | ||
| */ | ||
| export interface AbstractSku { | ||
| /** | ||
| * The name of the sku, typically, tier + family + cores, e.g. B_Gen4_1, GP_Gen5_8. | ||
| */ | ||
| name: string; | ||
| /** | ||
| * The tier of the particular SKU, e.g. Basic. Possible values include: 'Basic', | ||
| * 'GeneralPurpose', 'MemoryOptimized' | ||
| */ | ||
| tier?: SingleModels.SkuTier | FlexibleModels.SkuTier; | ||
| /** | ||
| * The scale up/out capacity, representing server's compute units. | ||
| */ | ||
| capacity?: number; | ||
| /** | ||
| * The size code, to be interpreted by resource as appropriate. | ||
| */ | ||
| size?: string; | ||
| /** | ||
| * The family of hardware. | ||
| */ | ||
| family?: string; | ||
| } | ||
|
|
||
| export interface AbstractServerCreate { | ||
| location: string; | ||
| sku: AbstractSku; | ||
| administratorLogin: string; | ||
| administratorLoginPassword: string; | ||
| version: string; | ||
| storageMB: number; | ||
| } | ||
|
|
||
| export type AbstractNameAvailability = SingleModels.NameAvailability | FlexibleModels.NameAvailability; | ||
|
|
||
| export type AbstractFirewallRule = SingleModels.FirewallRule | FlexibleModels.FirewallRule; | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.