本文整理匯總了TypeScript中@dcos/http-service.request函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript request函數的具體用法?TypeScript request怎麽用?TypeScript request使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了request函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: createSchedule
export function createSchedule(jobID: string, schedule: JobSchedule) {
return request(`${Config.metronomeAPI}/v1/jobs/${jobID}/schedules`, {
method: "POST",
body: JSON.stringify(schedule),
headers: defaultHeaders
}).pipe(catchError(e => throwError({ ...e, type: "SCHEDULE" })));
}
示例2: buildRequestHeader
listPackageVersions: (packageName: string) =>
request<PackageVersionsResponse>(`${rootUrl || "/"}package/list-versions`, {
method: "POST",
body: JSON.stringify({
includePackageVersions: true,
packageName
}),
headers: {
Accept: buildRequestHeader(
"list-versions",
"response",
"package",
"v1"
),
"Content-type": buildRequestHeader(
"list-versions",
"request",
"package",
"v1"
)
}
}).pipe(
tap(requestResponse => {
if (requestResponse.code >= 300) {
throw new Error(getErrorMessage(requestResponse));
}
})
)
示例3: fetchJobs
export function fetchJobs(): Observable<RequestResponse<JobResponse[]>> {
return request(
`${
Config.metronomeAPI
}/v1/jobs?embed=activeRuns&embed=schedules&embed=historySummary`
);
}
示例4:
fetchVersion: (
rootUrl: string = "/"
): Observable<RequestResponse<UIVersionResponse>> => {
return request<UIVersionResponse>(
`${rootUrl}dcos-ui-update-service/api/v1/version/`
).pipe(tap(handleBadResponses));
},
示例5: updateSchedule
export function updateSchedule(
jobID: string,
schedule: JobSchedule
): Observable<RequestResponse<any>> {
return request(
`${Config.metronomeAPI}/v1/jobs/${jobID}/schedules/${schedule.id}`,
{ method: "PUT", headers: defaultHeaders, body: JSON.stringify(schedule) }
).pipe(catchError(e => throwError({ ...e, type: "SCHEDULE" })));
}
示例6: stopJobRun
export function stopJobRun(
jobID: string,
jobRunID: string
): Observable<RequestResponse<any>> {
return request(
`${Config.metronomeAPI}/v1/jobs/${jobID}/runs/${jobRunID}/actions/stop`,
{ headers: defaultHeaders, method: "POST", body: "{}" }
);
}
示例7: fetchJobDetail
export function fetchJobDetail(
jobID: string
): Observable<RequestResponse<JobDetailResponse>> {
return request(
`${
Config.metronomeAPI
}/v1/jobs/${jobID}?embed=activeRuns&embed=history&embed=schedules`
);
}
示例8: deleteJob
export function deleteJob(
jobID: string,
stopCurrentJobRuns = false
): Observable<RequestResponse<any>> {
return request(
`${
Config.metronomeAPI
}/v1/jobs/${jobID}?stopCurrentJobRuns=${stopCurrentJobRuns}`,
{ method: "DELETE", headers: defaultHeaders }
);
}