Use Graph beta for beta-only endpoints
All checks were successful
Trigger Cloudarix Deploy / call-webhook (push) Successful in 4s
All checks were successful
Trigger Cloudarix Deploy / call-webhook (push) Successful in 4s
This commit is contained in:
parent
b6d69295aa
commit
2eaf325770
@ -3,6 +3,19 @@ import { withRetry, isTransientError } from '../utils/retry';
|
|||||||
|
|
||||||
type GraphRecord = Record<string, unknown>;
|
type GraphRecord = Record<string, unknown>;
|
||||||
|
|
||||||
|
// Certain Intune resources exist only on the beta Graph surface.
|
||||||
|
const BETA_ENDPOINTS = new Set([
|
||||||
|
'/deviceManagement/configurationPolicies',
|
||||||
|
'/deviceManagement/intents',
|
||||||
|
]);
|
||||||
|
|
||||||
|
function baseUrlFor(endpoint: string) {
|
||||||
|
for (const beta of BETA_ENDPOINTS) {
|
||||||
|
if (endpoint.startsWith(beta)) return 'https://graph.microsoft.com/beta';
|
||||||
|
}
|
||||||
|
return 'https://graph.microsoft.com/v1.0';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch a Graph endpoint with pagination support for @odata.nextLink
|
* Fetch a Graph endpoint with pagination support for @odata.nextLink
|
||||||
* Returns an array of items aggregated across pages.
|
* Returns an array of items aggregated across pages.
|
||||||
@ -71,7 +84,8 @@ export async function fetchWithPagination(
|
|||||||
*/
|
*/
|
||||||
export async function fetchFromGraph(endpoint: string) {
|
export async function fetchFromGraph(endpoint: string) {
|
||||||
const token = await getGraphAccessToken();
|
const token = await getGraphAccessToken();
|
||||||
return fetchWithPagination(endpoint, token);
|
const baseUrl = baseUrlFor(endpoint);
|
||||||
|
return fetchWithPagination(endpoint, token, baseUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default fetchFromGraph;
|
export default fetchFromGraph;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user