-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Maxime Dufour <[email protected]>
- Loading branch information
1 parent
925c8e7
commit 5fe2011
Showing
8 changed files
with
131 additions
and
12 deletions.
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 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,68 @@ | ||
|
||
import * as osc from "outscale-api"; | ||
import { FiltersDedicatedGroup } from "outscale-api"; | ||
import { getConfig, handleRejection } from '../cloud/cloud'; | ||
import { Profile } from "../flat/node"; | ||
|
||
|
||
// Retrieve all items of the resource DedicatedGroup | ||
export function getDedicatedGroups(profile: Profile, filters?: FiltersDedicatedGroup): Promise<Array<osc.DedicatedGroup> | string> { | ||
const config = getConfig(profile); | ||
const readParameters: osc.ReadDedicatedGroupsOperationRequest = { | ||
readDedicatedGroupsRequest: { | ||
filters: filters | ||
} | ||
}; | ||
|
||
const api = new osc.DedicatedGroupApi(config); | ||
return api.readDedicatedGroups(readParameters) | ||
.then((res: osc.ReadDedicatedGroupsResponse) => { | ||
if (res.dedicatedGroups === undefined || res.dedicatedGroups.length === 0) { | ||
return []; | ||
} | ||
return res.dedicatedGroups; | ||
}, (err_: any) => { | ||
return handleRejection(err_); | ||
}); | ||
} | ||
|
||
// Retrieve a specific item of the resource DedicatedGroup | ||
export function getDedicatedGroup(profile: Profile, resourceId: string): Promise<osc.DedicatedGroup | undefined | string> { | ||
const config = getConfig(profile); | ||
const readParameters: osc.ReadDedicatedGroupsOperationRequest = { | ||
readDedicatedGroupsRequest: { | ||
filters: { | ||
dedicatedGroupIds: [resourceId] | ||
} | ||
} | ||
}; | ||
|
||
const api = new osc.DedicatedGroupApi(config); | ||
return api.readDedicatedGroups(readParameters) | ||
.then((res: osc.ReadDedicatedGroupsResponse) => { | ||
if (res.dedicatedGroups === undefined || res.dedicatedGroups.length === 0) { | ||
return undefined; | ||
} | ||
return res.dedicatedGroups[0]; | ||
}, (err_: any) => { | ||
return handleRejection(err_); | ||
}); | ||
} | ||
|
||
// Delete a specific item the resource DedicatedGroup | ||
export function deleteDedicatedGroup(profile: Profile, resourceId: string): Promise<string | undefined> { | ||
const config = getConfig(profile); | ||
const deleteParameters: osc.DeleteDedicatedGroupOperationRequest = { | ||
deleteDedicatedGroupRequest: { | ||
dedicatedGroupId: resourceId | ||
} | ||
}; | ||
|
||
const api = new osc.DedicatedGroupApi(config); | ||
return api.deleteDedicatedGroup(deleteParameters) | ||
.then(() => { | ||
return undefined; | ||
}, (err_: any) => { | ||
return handleRejection(err_); | ||
}); | ||
} |
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,45 @@ | ||
import * as vscode from 'vscode'; | ||
import { ExplorerNode, ExplorerFolderNode, Profile, resourceNodeCompare } from '../../node'; | ||
import { FiltersFolderNode } from '../node.filterfolder'; | ||
import { ResourceNode } from '../../resources/node.resources'; | ||
import { FiltersDedicatedGroup, FiltersDedicatedGroupFromJSON } from 'outscale-api'; | ||
import { deleteDedicatedGroup, getDedicatedGroup, getDedicatedGroups } from '../../../cloud/dedicatedgroup'; | ||
|
||
export const DEDICATEDGROUP_FOLDER_NAME = "Dedicated Groups"; | ||
export class DedicatedGroupsFolderNode extends FiltersFolderNode<FiltersDedicatedGroup> implements ExplorerFolderNode { | ||
constructor(readonly profile: Profile) { | ||
super(profile, DEDICATEDGROUP_FOLDER_NAME); | ||
} | ||
|
||
getChildren(): Thenable<ExplorerNode[]> { | ||
this.updateFilters(); | ||
return getDedicatedGroups(this.profile, this.filters).then(results => { | ||
if (typeof results === "string") { | ||
vscode.window.showErrorMessage(vscode.l10n.t(`Error while reading {0}: {1}`, this.folderName, results)); | ||
return Promise.resolve([]); | ||
} | ||
const resources = []; | ||
for (const item of results) { | ||
|
||
if (typeof item.dedicatedGroupId === 'undefined') { | ||
|
||
continue; | ||
} | ||
|
||
if (typeof item.name === 'undefined') { | ||
|
||
continue; | ||
} | ||
|
||
resources.push(new ResourceNode(this.profile, item.name, item.dedicatedGroupId, "DedicatedGroup", deleteDedicatedGroup, getDedicatedGroup)); | ||
|
||
} | ||
return Promise.resolve(resources.sort(resourceNodeCompare)); | ||
}); | ||
|
||
} | ||
|
||
filtersFromJson(json: string): FiltersDedicatedGroup { | ||
return FiltersDedicatedGroupFromJSON(json); | ||
} | ||
} |
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