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

Method modifyToken

CesiumIonClient/src/Connection.cpp:1015–1110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1013}
1014
1015Future<Response<NoValue>> Connection::modifyToken(
1016 const std::string& tokenID,
1017 const std::string& newName,
1018 const std::optional<std::vector<int64_t>>& newAssetIDs,
1019 const std::vector<std::string>& newScopes,
1020 const std::optional<std::vector<std::string>>& newAllowedUrls) const {
1021 return this->ensureValidToken().thenImmediately(
1022 [pAssetAccessor = this->_pAssetAccessor,
1023 asyncSystem = this->_asyncSystem,
1024 apiUrl = this->_apiUrl,
1025 tokenID,
1026 newName,
1027 newAssetIDs,
1028 newScopes,
1029 newAllowedUrls](Result<std::string>&& result) {
1030 if (!result.value) {
1031 return asyncSystem.createResolvedFuture(
1032 createNoValidTokenResponse<NoValue>(std::move(result)));
1033 }
1034
1035 std::string url = Uri::resolve(apiUrl, "v2/tokens/");
1036 url = Uri::resolve(url, tokenID);
1037
1038 rapidjson::StringBuffer tokenBuffer;
1039 rapidjson::Writer<rapidjson::StringBuffer> writer(tokenBuffer);
1040
1041 writer.StartObject();
1042
1043 writer.Key("name");
1044 writer.String(newName.c_str(), rapidjson::SizeType(newName.size()));
1045
1046 writer.Key("assetIds");
1047 if (newAssetIDs) {
1048 writer.StartArray();
1049 for (auto asset : newAssetIDs.value()) {
1050 writer.Int64(asset);
1051 }
1052 writer.EndArray();
1053 } else {
1054 writer.Null();
1055 }
1056
1057 writer.Key("scopes");
1058 writer.StartArray();
1059 for (auto& scope : newScopes) {
1060 writer.String(scope.c_str(), rapidjson::SizeType(scope.size()));
1061 }
1062 writer.EndArray();
1063
1064 writer.Key("newAllowedUrls");
1065 if (newAllowedUrls) {
1066 writer.StartArray();
1067 for (auto& allowedUrl : newAllowedUrls.value()) {
1068 writer.String(
1069 allowedUrl.c_str(),
1070 rapidjson::SizeType(allowedUrl.size()));
1071 }
1072 writer.EndArray();

Callers

nothing calls this directly

Calls 15

ensureValidTokenMethod · 0.95
NoValueClass · 0.85
thenImmediatelyMethod · 0.45
StartObjectMethod · 0.45
KeyMethod · 0.45
StringMethod · 0.45
sizeMethod · 0.45
StartArrayMethod · 0.45
Int64Method · 0.45
EndArrayMethod · 0.45
NullMethod · 0.45
EndObjectMethod · 0.45

Tested by

no test coverage detected