本文整理汇总了TypeScript中core/account/AccountService.AccountService类的典型用法代码示例。如果您正苦于以下问题:TypeScript AccountService类的具体用法?TypeScript AccountService怎么用?TypeScript AccountService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AccountService类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getRegions
public static getRegions(provider: string): IPromise<string[]> {
if (has(SETTINGS, `providers.${provider}.bakeryRegions`)) {
return $q.when(get(SETTINGS, `providers.${provider}.bakeryRegions`));
}
return AccountService.getUniqueAttributeForAllAccounts(provider, 'regions').then((regions: string[]) =>
regions.sort(),
);
}
示例2: restoreSnapshot
public static restoreSnapshot(app: Application, account: string, timestamp: number): IPromise<ITask> {
return AccountService.getAccountDetails(account).then(accountDetail => {
const jobs = this.buildRestoreSnapshotJob(app, accountDetail, timestamp);
return TaskExecutor.executeTask({
job: jobs,
application: app,
description: `Restore Snapshot ${timestamp} of application: ${app.name} for account: ${accountDetail.name}`,
});
});
}
示例3: normalizeSecurityGroup
public normalizeSecurityGroup(securityGroup: ISecurityGroup): IPromise<ISecurityGroup> {
return AccountService.getAccountDetails(securityGroup.account).then((accountDetails: IAccountDetails) => {
return this.providerServiceDelegate
.getDelegate<any>(
securityGroup.provider || securityGroup.type,
'securityGroup.transformer',
accountDetails && accountDetails.skin,
)
.normalizeSecurityGroup(securityGroup);
});
}
示例4: selectSkin
public selectSkin(provider: string): IPromise<string> {
return AccountService.getAllAccountDetailsForProvider(provider).then(accounts => {
const skins = uniq(accounts.map(a => a.skin).filter(v => !isNil(v)));
if (skins.length === 0) {
return CloudProviderRegistry.getProvider(provider).skin;
} else if (skins.length === 1) {
return skins[0];
} else {
return this.$uibModal.open({
templateUrl: require('./skinSelector.html'),
controller: 'skinSelectorCtrl as ctrl',
resolve: {
skinOptions: () => skins,
},
}).result;
}
});
}
示例5: function
controller: function(artifact: IArtifact) {
this.artifact = artifact;
this.artifact.type = 'helm/chart';
this.onAccountChange = () => {
this.artifact.artifactAccount = this.selectedArtifactAccount;
this.artifact.reference = this.selectedArtifactAccount;
ArtifactService.getArtifactNames('helm/chart', this.artifact.artifactAccount).then(names => {
this.chartNames = names;
});
this.chartVersions = [];
};
this.onNameChange = () => {
ArtifactService.getArtifactVersions('helm/chart', this.artifact.artifactAccount, this.artifact.name).then(
versions => {
this.chartVersions = versions;
},
);
};
AccountService.getArtifactAccounts().then(accounts => {
this.artifactAccounts = accounts
.filter(account => account.types.includes('helm/chart'))
.map(account => account.name);
if (artifact.artifactAccount) {
this.selectedArtifactAccount = accounts.filter(
account => account.types.includes('helm/chart') && account.name === this.artifact.artifactAccount,
)[0].name;
}
});
if (artifact.artifactAccount) {
ArtifactService.getArtifactNames('helm/chart', this.artifact.artifactAccount).then(names => {
this.chartNames = names;
});
if (artifact.name) {
ArtifactService.getArtifactVersions('helm/chart', this.artifact.artifactAccount, this.artifact.name).then(
versions => {
this.chartVersions = versions;
},
);
}
}
},
示例6: selectProvider
public selectProvider(
application: Application,
feature: string,
filterFn?: IProviderSelectionFilter,
): IPromise<string> {
return AccountService.applicationAccounts(application).then((accounts: IAccountDetails[]) => {
let reducedAccounts: IAccountDetails[] = [];
if (feature) {
reducedAccounts = accounts.filter(a => CloudProviderRegistry.hasValue(a.cloudProvider, feature));
}
if (filterFn) {
reducedAccounts = reducedAccounts.filter((acc: IAccountDetails) => {
return filterFn(application, acc, CloudProviderRegistry.getProvider(acc.cloudProvider, acc.skin));
});
}
// reduce the accounts to the smallest, unique collection taking into consideration the useProvider values
const reducedProviders = uniq(
reducedAccounts.map(a => {
const providerFeature = CloudProviderRegistry.getProvider(a.cloudProvider)[feature] || {};
return providerFeature.useProvider || a.cloudProvider;
}),
);
let provider;
if (reducedProviders.length > 1) {
provider = this.$uibModal.open({
templateUrl: require('./providerSelection.html'),
controller: 'ProviderSelectCtrl as ctrl',
resolve: {
providerOptions: () => reducedProviders,
},
}).result;
} else if (reducedProviders.length === 1) {
provider = this.$q.when(reducedProviders[0]);
} else {
provider = this.$q.when(SETTINGS.defaultProvider || 'aws');
}
return provider;
});
}
示例7:
const accountDetailPromises = accounts.map(account => AccountService.getAccountDetails(account));
示例8:
public $onInit(): void {
AccountService.challengeDestructiveActions(this.account).then(isProdAccount => {
this.accountType = isProdAccount ? 'prod' : this.account;
});
}