本文整理汇总了TypeScript中core/api/ApiService.API类的典型用法代码示例。如果您正苦于以下问题:TypeScript API类的具体用法?TypeScript API怎么用?TypeScript API使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了API类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getInstanceDetails
public static getInstanceDetails(account: string, region: string, id: string): IPromise<IInstance> {
return API.one('instances')
.one(account)
.one(region)
.one(id)
.get();
}
示例2: waitUntilTaskIsDeleted
private static waitUntilTaskIsDeleted(taskId: string): IPromise<void> {
// wait until the task is gone, i.e. the promise from the get() is rejected, before succeeding
const deferred = $q.defer<void>();
API.one('tasks', taskId)
.get()
.then(
() => {
$timeout(
() => {
// task is still present, try again
this.waitUntilTaskIsDeleted(taskId).then(() => deferred.resolve());
},
1000,
false,
);
},
(resp: IHttpPromiseCallbackArg<any>) => {
if (resp.status === 404) {
// task is no longer present
deferred.resolve();
} else {
$timeout(
() => {
// task is maybe still present, try again
this.waitUntilTaskIsDeleted(taskId).then(deferred.resolve);
},
1000,
false,
);
}
},
);
return deferred.promise;
}
示例3:
return $q((resolve, reject) => {
API.one('v2')
.one('pipelineTemplates')
.one('create')
.post(template)
.then(resolve, reject);
});
示例4: getFallbackResults
public static search<T extends ISearchResult>(
searchParams: ISearchParams,
cache: ICache = null,
): IPromise<ISearchResults<T>> {
const defaultParams: ISearchParams = {
pageSize: SearchService.DEFAULT_PAGE_SIZE,
};
const params = { ...searchParams, ...defaultParams };
const requestBuilder = API.one('search').withParams(params);
if (cache) {
requestBuilder.useCache(cache);
}
return requestBuilder
.get()
.then((response: Array<ISearchResults<T>>) => {
return response[0] || getFallbackResults();
})
.catch((response: IHttpPromiseCallbackArg<any>) => {
$log.error(response.data, response);
return getFallbackResults();
});
}
示例5: getManifest
public static getManifest(account: string, location: string, name: string): IPromise<IManifest> {
return API.all('manifests')
.all(account)
.all(location)
.one(name)
.get();
}
示例6: listJobsForMaster
public static listJobsForMaster(master: string): IPromise<string[]> {
return API.one('v2')
.one('builds')
.one(master)
.one('jobs')
.get();
}
示例7:
this.accounts$ = Observable.defer(() => {
const promise = API.one('credentials')
.useCache()
.withParams({ expand: true })
.get();
return Observable.fromPromise<IAccountDetails[]>(promise);
})
示例8: getAllSecurityGroups
public getAllSecurityGroups(): IPromise<ISecurityGroupsByAccountSourceData> {
// Because these are cached in local storage, we unfortunately need to remove the moniker, as it triples the size
// of the object being stored, which blows out our LS quota for a sufficiently large footprint
const cache = InfrastructureCaches.get('securityGroups');
const cached = !!cache ? cache.get('allGroups') : null;
if (cached) {
return this.$q.resolve(cached);
}
return API.one('securityGroups')
.useCache()
.get()
.then((groupsByAccount: ISecurityGroupsByAccountSourceData) => {
Object.keys(groupsByAccount).forEach(account => {
Object.keys(groupsByAccount[account]).forEach(provider => {
Object.keys(groupsByAccount[account][provider]).forEach(region => {
groupsByAccount[account][provider][region].forEach(group => {
delete group.moniker;
});
});
});
});
if (cache) {
cache.put('allGroups', groupsByAccount);
}
return groupsByAccount;
});
}
示例9: getArtifactNames
public static getArtifactNames(type: string, accountName: string): IPromise<string[]> {
return API.one('artifacts')
.one('account')
.one(accountName)
.one('names')
.withParams({ type: type })
.get();
}
示例10: getJobConfig
public static getJobConfig(master: string, job: string): IPromise<IJobConfig> {
return API.one('v2')
.one('builds')
.one(master)
.one('jobs')
.one(job)
.get();
}