本文整理汇总了TypeScript中core/api/ApiService.API.one方法的典型用法代码示例。如果您正苦于以下问题:TypeScript API.one方法的具体用法?TypeScript API.one怎么用?TypeScript API.one使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core/api/ApiService.API
的用法示例。
在下文中一共展示了API.one方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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;
}
示例2:
this.accounts$ = Observable.defer(() => {
const promise = API.one('credentials')
.useCache()
.withParams({ expand: true })
.get();
return Observable.fromPromise<IAccountDetails[]>(promise);
})
示例3: 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();
});
}
示例4: getInstanceDetails
public static getInstanceDetails(account: string, region: string, id: string): IPromise<IInstance> {
return API.one('instances')
.one(account)
.one(region)
.one(id)
.get();
}
示例5: listJobsForMaster
public static listJobsForMaster(master: string): IPromise<string[]> {
return API.one('v2')
.one('builds')
.one(master)
.one('jobs')
.get();
}
示例6:
return $q((resolve, reject) => {
API.one('v2')
.one('pipelineTemplates')
.one('create')
.post(template)
.then(resolve, reject);
});
示例7: 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;
});
}
示例8: listPipelinesForTeam
public static listPipelinesForTeam(master: string, team: string): IPromise<string[]> {
return API.one('concourse')
.one(master)
.one('teams')
.one(team)
.one('pipelines')
.get();
}
示例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: listBuildsForJob
public static listBuildsForJob(master: string, job: string): IPromise<IBuild[]> {
return API.one('v2')
.one('builds')
.one(master)
.one('builds')
.one(job)
.get();
}