MCPcopy Create free account
hub / github.com/CesiumGS/cesium-native / appData

Method appData

CesiumIonClient/src/Connection.cpp:336–388  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

334}
335
336/* static */ CesiumAsync::Future<Response<ApplicationData>>
337CesiumIonClient::Connection::appData(
338 const CesiumAsync::AsyncSystem& asyncSystem,
339 const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
340 const std::string& apiUrl) {
341 return pAssetAccessor
342 ->get(
343 asyncSystem,
344 CesiumUtility::Uri::resolve(apiUrl, "/appData"),
345 {{"Accept", "application/json"}})
346 .thenImmediately([](std::shared_ptr<CesiumAsync::IAssetRequest>&&
347 pRequest) {
348 const IAssetResponse* pResponse = pRequest->response();
349 if (!pResponse) {
350 return createEmptyResponse<ApplicationData>();
351 }
352
353 if (pResponse->statusCode() < 200 || pResponse->statusCode() >= 300) {
354 return createErrorResponse<ApplicationData>(pResponse);
355 }
356
357 rapidjson::Document d;
358 if (!parseJsonObject(pResponse, d)) {
359 return createJsonErrorResponse<ApplicationData>(pResponse, d);
360 }
361 if (!d.IsObject()) {
362 return createJsonTypeResponse<ApplicationData>(pResponse, "object");
363 }
364
365 // There's a lot more properties available on the /appData endpoint, but
366 // we don't need them so we're ignoring them for now.
367 ApplicationData result;
368 std::string authenticationMode =
369 JsonHelpers::getStringOrDefault(d, "applicationMode", "cesium-ion");
370 if (authenticationMode == "single-user") {
371 result.authenticationMode = AuthenticationMode::SingleUser;
372 } else if (authenticationMode == "saml") {
373 result.authenticationMode = AuthenticationMode::Saml;
374 } else {
375 result.authenticationMode = AuthenticationMode::CesiumIon;
376 }
377 result.dataStoreType =
378 JsonHelpers::getStringOrDefault(d, "dataStoreType", "S3");
379 result.attribution =
380 JsonHelpers::getStringOrDefault(d, "attribution", "");
381
382 return Response<ApplicationData>{
383 std::move(result),
384 pResponse->statusCode(),
385 std::string(),
386 std::string()};
387 });
388}
389
390namespace {
391

Callers

nothing calls this directly

Calls 6

parseJsonObjectFunction · 0.85
getStringOrDefaultFunction · 0.85
thenImmediatelyMethod · 0.45
getMethod · 0.45
responseMethod · 0.45
statusCodeMethod · 0.45

Tested by

no test coverage detected