Fetch arc dc config profile list from azdata (#12678)

This commit is contained in:
Arvind Ranasaria
2020-09-30 14:25:15 -07:00
committed by GitHub
parent ab85028a94
commit 7bfea07b9b
4 changed files with 33 additions and 19 deletions

View File

@@ -11,8 +11,9 @@ import { apiService } from '../services/apiService';
import { throwUnless } from '../utils';
import { CacheManager } from './cacheManager';
export enum OptionsSourceType {
ArcControllersOptionsSource = 'ArcControllersOptionsSource'
export const enum OptionsSourceType {
ArcControllersOptionsSource = 'ArcControllersOptionsSource',
ArcControllerConfigProfilesOptionsSource = 'ArcControllerConfigProfilesOptionsSource'
}
export abstract class OptionsSource implements IOptionsSource {
@@ -20,14 +21,22 @@ export abstract class OptionsSource implements IOptionsSource {
get type(): OptionsSourceType { return this._type; }
get variableNames(): { [index: string]: string; } { return this._variableNames; }
abstract async getOptions(): Promise<string[] | CategoryValue[]>;
abstract async getVariableValue(variableName: string, input: string): Promise<string>;
abstract getIsPassword(variableName: string): boolean;
abstract getOptions(): Promise<string[] | CategoryValue[]>;
getVariableValue(variableName: string, controllerLabel: string): Promise<string> {
throw new Error(loc.variableValueFetchForUnsupportedVariable(variableName));
}
getIsPassword(variableName: string): boolean {
throw new Error(loc.isPasswordFetchForUnsupportedVariable(variableName));
}
constructor(private _variableNames: { [index: string]: string }, private _type: OptionsSourceType) {
}
}
/**
* Class that provides options sources for an Arc Data Controller
*/
export class ArcControllersOptionsSource extends OptionsSource {
private _cacheManager = new CacheManager<string, string>();
@@ -82,3 +91,12 @@ export class ArcControllersOptionsSource extends OptionsSource {
}
}
}
/**
* Class that provides options sources for an Arc Data Controller's Config Profiles
*/
export class ArcControllerConfigProfilesOptionsSource extends OptionsSource {
async getOptions(): Promise<string[]> {
return (await apiService.azdataApi.azdata.arc.dc.config.list()).result;
}
}